 :root {
  --bg-1: #0a0f18;
  --bg-2: #101827;
  --panel: rgba(15, 22, 35, 0.9);
  --panel-2: rgba(22, 31, 47, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #edf3ff;
  --muted: #b5c2d8;
  --accent: #8ee5ff;
  --accent-2: #b7ff74;
  --danger: #ff9b8f;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(123, 230, 255, 0.1), transparent 26%),
    radial-gradient(circle at left bottom, rgba(183, 255, 116, 0.08), transparent 24%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas {
  touch-action: manipulation;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.game-card,
.panel,
.overlay__panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 26, 39, 0.96), rgba(11, 17, 27, 0.92));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.topbar {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent);
}

h1,
h2,
h3,
p,
ul {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 12px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.text-input {
  width: 100%;
  min-height: 46px;
  margin-bottom: 14px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
}

.text-input::placeholder {
  color: #90a0ba;
}

.lead {
  margin-bottom: 0;
  max-width: 880px;
  line-height: 1.65;
  color: var(--muted);
}

.topbar__meta {
  display: grid;
  gap: 12px;
  align-content: start;
}

.meta-pill,
.hud__item,
.hotbar__slot,
.touch-btn,
.action-btn,
.secondary-btn,
.inventory-card,
.recipe-card,
.world-actions button {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
}

.meta-pill {
  border-radius: 18px;
  padding: 14px 16px;
}

.meta-pill span,
.hud__item span,
.hotbar__slot small,
.inventory-card small,
.recipe-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta-pill strong,
.hud__item strong {
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 360px);
  gap: 18px;
}

.game-card {
  padding: 16px;
}

.hud {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.hud__group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hud__item {
  border-radius: 16px;
  padding: 12px 14px;
}

.hud__tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hud__tips span,
.biome-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
}

.canvas-shell {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  background: #030912;
  border: 1px solid var(--line);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  cursor: crosshair;
}

.crosshair {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  pointer-events: none;
  opacity: 0.15;
}

.hotbar-wrap {
  margin-top: 14px;
}

.status-line {
  margin-bottom: 10px;
  color: var(--muted);
  min-height: 22px;
}

.quick-actions,
.overlay__actions,
.world-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-actions {
  margin-bottom: 10px;
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
}

.hotbar--inventory {
  margin-top: 4px;
}

.hotbar__slot {
  position: relative;
  padding: 10px 8px 8px;
  border-radius: 16px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  color: var(--text);
}

.hotbar__slot.is-active {
  outline: 2px solid var(--accent);
  background: rgba(142, 229, 255, 0.12);
}

.hotbar__swatch,
.inventory-card__swatch,
.recipe-card__swatch,
.storage-card__swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  image-rendering: pixelated;
  background-size: cover;
  background-position: center;
}

.hotbar__name {
  font-size: 12px;
  line-height: 1.25;
}

.hotbar__count {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.sidebar {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 20px;
}

.panel ul,
.panel p,
.overlay__note,
.recipe-card p,
.inventory-card p {
  color: var(--muted);
  line-height: 1.65;
}

.biome-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-btn,
.primary-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  color: var(--text);
  font: inherit;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.06);
}

.primary-btn {
  background: linear-gradient(180deg, rgba(142, 229, 255, 0.38), rgba(142, 229, 255, 0.2));
  border: 1px solid rgba(142, 229, 255, 0.4);
}

.primary-btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 15, 0.7);
  backdrop-filter: blur(14px);
  z-index: 50;
}

.overlay--hidden {
  display: none;
}

.overlay__panel {
  width: min(1100px, 100%);
  padding: 24px;
}

.hero-panel {
  width: min(620px, 100%);
}

.inventory-panel {
  max-height: min(90vh, 900px);
  overflow: auto;
}

.inventory-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.inventory-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

.inventory-layout--bottom {
  margin-top: 18px;
  grid-template-columns: 1.4fr 1fr;
}

.inventory-grid,
.recipes {
  display: grid;
  gap: 10px;
}

.inventory-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inventory-card,
.recipe-card,
.storage-card {
  border-radius: 18px;
  padding: 12px;
}

.inventory-card {
  text-align: left;
}

.inventory-card.is-selected {
  outline: 2px solid var(--accent);
  background: rgba(142, 229, 255, 0.12);
}

.inventory-card__row,
.recipe-card__row,
.storage-card__row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inventory-card strong,
.recipe-card strong,
.storage-card strong {
  display: block;
  margin-bottom: 2px;
}

.recipe-card button {
  margin-top: 8px;
}

.touch-ui {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  display: none;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  z-index: 6;
}

.touch-ui__move,
.touch-ui__actions {
  display: flex;
  gap: 10px;
}

.touch-btn,
.action-btn {
  min-width: 68px;
  min-height: 68px;
  border-radius: 20px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.touch-btn:active,
.action-btn:active,
.hotbar__slot:active,
.secondary-btn:active,
.primary-btn:active,
.inventory-card:active {
  transform: translateY(1px) scale(0.99);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inventory-layout,
  .inventory-layout--bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .hud__group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .hotbar,
  .hotbar--inventory,
  .inventory-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inventory-head {
    flex-direction: column;
  }
}

@media (hover: none), (pointer: coarse) {
  .touch-ui {
    display: flex;
    flex-wrap: wrap;
  }

  #gameCanvas {
    cursor: default;
  }
}


.storage-card {
  text-align: left;
  border-radius: 18px;
  padding: 12px;
}

.storage-card button {
  margin-top: 8px;
}
