/* ─── DESIGN TOKENS ────────────────────────────────────────────────────────── */
:root {
  --bg: #101510;
  --bg-2: #18201a;
  --panel: rgba(18, 24, 19, 0.94);
  --panel-2: rgba(26, 33, 27, 0.96);
  --line: rgba(255, 236, 193, 0.18);
  --line-strong: rgba(255, 236, 193, 0.34);
  --text: #f8efd6;
  --muted: #b8c0aa;
  --accent: #f0b44d;
  --accent-2: #7cc36d;
  --accent-3: #6ca8d8;
  --danger: #eb7a66;
  --shadow: rgba(0, 0, 0, 0.34);
  --radius: 18px;
  --pixel-shadow: 0 0 0 2px rgba(12, 16, 13, 0.95), 0 10px 20px rgba(0, 0, 0, 0.24);
  --title-font: "Rockwell", "Bookman Old Style", Georgia, serif;
  --ui-font: "Trebuchet MS", "Lucida Sans Unicode", sans-serif;

  --skin-hat: #ff4a4a;
  --skin-accent: #ffcc00;
  --skin-body: #4a90e2;
  --skin-boots: #50e3c2;

  --hotbar-h: 68px;
  --survival-h: 42px;
  --cashout-h: 50px;
  --bottom-bar-gap: 8px;
  --stage-bottom-pad: calc(
          var(--cashout-h) +
          var(--survival-h) +
          var(--hotbar-h) +
          var(--bottom-bar-gap) * 4 +
          16px
  );
}

/* ─── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--ui-font);
  color: var(--text);
  background:
          radial-gradient(circle at top left, rgba(240, 180, 77, 0.12), transparent 28%),
          radial-gradient(circle at bottom right, rgba(124, 195, 109, 0.12), transparent 30%),
          linear-gradient(145deg, #0e120f 0%, #1a231b 48%, #101510 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
          repeating-linear-gradient(0deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 8px),
          linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.34));
}

button, select { font: inherit; }

/* ─── SHELL ──────────────────────────────────────────────────────────────────── */
.app-shell {
  width: min(1420px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 26px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────────── */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  margin-bottom: 18px;
  text-align: center;
  gap: 16px;
}

.topbar-title {
  font-family: var(--title-font);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  color: #fff1c7;
  margin: 0;
  letter-spacing: 0.03em;
  padding: 8px 18px;
  text-shadow: 0 3px 0 #3d2a16, 0 0 18px rgba(240,180,77,0.34);
}

.coins-badge {
  position: absolute;
  right: 0;
  top: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  border: 2px solid rgba(255,211,118,0.34);
  background: linear-gradient(180deg, rgba(69,53,18,0.95), rgba(29,21,10,0.98));
  color: #ffd778;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: var(--pixel-shadow);
}

/* ─── CARD ───────────────────────────────────────────────────────────────────── */
.card {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 36px rgba(0,0,0,0.22);
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,244,212,0.05);
}

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

/* ─── MENU VIEW ──────────────────────────────────────────────────────────────── */
.menu-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-panel { display: none; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.menu-shell {
  width: min(880px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.menu-nav {
  width: min(360px, 100%);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(22,31,25,0.94), rgba(8,12,10,0.96));
}

.menu-panel {
  width: min(760px, 100%);
  max-height: min(52vh, 560px);
  overflow-y: auto;
  padding: 16px;
  border-radius: 8px;
  background: rgba(12,17,14,0.9);
}

/* ─── EYEBROW / HEADINGS ─────────────────────────────────────────────────────── */
.eyebrow {
  margin: 0 0 8px;
  color: #f2d794;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.topbar-title,
.hero-title,
.menu-panel h3,
.run-panel h3,
.summary-dialog h3 {
  font-family: var(--title-font);
  color: white;
  margin: 0;
  letter-spacing: 0.03em;
}

/* ─── PANEL STACK ────────────────────────────────────────────────────────────── */
.panel-stack,
.panel-stack-list,
.skin-list,
.inventory-list,
.rule-list,
.run-stats,
.control-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ─── CARDS / INFO ───────────────────────────────────────────────────────────── */
.stat-card,
.info-card,
.rule-card {
  padding: 16px;
}

.stat-card {
  flex: 1 1 170px;
  min-width: 140px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(12,17,14,0.48);
}

.info-card,
.rule-card,
.inventory-item,
.skin-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(12,17,14,0.48);
}

.stat-card strong,
.info-value {
  display: block;
  margin: 10px 0 6px;
  font-size: 1.18rem;
  color: #fff1c7;
}

.stat-card p { display: none; }

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.nav-button,
.secondary-button,
.cashout-button,
.menu-select,
.texture-pack-button {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 8px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.nav-button,
.secondary-button,
.texture-pack-button {
  padding: 13px 14px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(78,92,66,0.98), rgba(24,31,25,0.98));
  border-color: rgba(255,236,193,0.18);
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.nav-button {
  width: 100%;
  min-height: 56px;
  text-align: center;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-button--primary {
  min-height: 66px;
  color: #1b1208;
  background: linear-gradient(180deg, #ffd778, #d58a2d 58%, #8d4d1c);
  border-color: rgba(255,245,202,0.7);
  text-shadow: 0 1px 0 rgba(255,255,255,0.28);
}

.nav-button:hover,
.nav-button.is-active,
.secondary-button:hover,
.texture-pack-button:hover,
.texture-pack-button.is-active,
.cashout-button:hover,
.skin-card:hover,
.inventory-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.secondary-button:disabled,
.small-button:disabled,
.consumable-buy-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.mode-toggle-btn { border-left: 4px solid transparent; }
.mode-toggle-btn.active {
  background-color: #2f5d3d;
  border-left: 4px solid gold;
  font-weight: bold;
}

.new-profile {
  padding: 13px 14px;
  color: var(--text);
  background: linear-gradient(180deg, rgb(255 0 0 / 0.4), rgb(165 0 0 / 0.4));
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 14px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
  box-shadow: var(--pixel-shadow);
}
.new-profile:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.new-profile:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

/* ─── CHIPS / BADGES ─────────────────────────────────────────────────────────── */
.coins-badge,
.summary-chip,
.hud-chip,
.control-list li,
.secondary-button,
.nav-button,
.cashout-button {
  box-shadow: var(--pixel-shadow);
}

.shop-summary,
.run-stats {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.summary-chip,
.hud-chip {
  padding: 12px 14px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.06);
  background: rgba(16,20,17,0.88);
}

.summary-chip span,
.hud-chip span,
.inventory-meta,
.info-label {
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-chip strong,
.hud-chip strong {
  display: block;
  margin-top: 4px;
  color: #fff1c7;
}

/* ─── SKINS ──────────────────────────────────────────────────────────────────── */
.selected-skin-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.skin-preview {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(42,52,41,0.95), rgba(12,16,13,0.98));
  border: 2px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.skin-swatch {
  position: relative;
  width: 42px;
  height: 48px;
  image-rendering: pixelated;
  background:
          linear-gradient(#1a120b 0 0) top 0 left 10px / 22px 4px no-repeat,
          linear-gradient(var(--skin-hat) 0 0) top 4px left 7px / 28px 7px no-repeat,
          linear-gradient(var(--skin-hat) 0 0) top 10px left 4px / 34px 5px no-repeat,
          linear-gradient(rgba(255,255,255,0.28) 0 0) top 6px left 10px / 8px 2px no-repeat,
          linear-gradient(#f1c59a 0 0) top 15px left 13px / 16px 8px no-repeat,
          linear-gradient(#2a1a12 0 0) top 17px left 17px / 3px 2px no-repeat,
          linear-gradient(#2a1a12 0 0) top 17px left 23px / 3px 2px no-repeat,
          linear-gradient(var(--skin-accent) 0 0) top 23px left 10px / 22px 5px no-repeat,
          linear-gradient(var(--skin-body) 0 0) top 28px left 9px / 24px 13px no-repeat,
          linear-gradient(rgba(255,255,255,0.2) 0 0) top 30px left 12px / 5px 9px no-repeat,
          linear-gradient(var(--skin-boots) 0 0) top 41px left 10px / 8px 7px no-repeat,
          linear-gradient(var(--skin-boots) 0 0) top 41px left 24px / 8px 7px no-repeat;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.28), 0 8px 0 rgba(0,0,0,0.18);
}

.skin-list { gap: 12px; }

.skin-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  cursor: pointer;
  min-height: 92px;
}

.skin-card.is-selected {
  border-color: rgba(255,215,120,0.72);
  background: linear-gradient(180deg, rgba(52,45,25,0.82), rgba(18,23,18,0.9));
}

.skin-card__meta { min-width: 0; }
.skin-card__title { margin: 0 0 6px; font-size: 1.05rem; }

/* ─── SHOP / INVENTORY ───────────────────────────────────────────────────────── */
.inventory-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.inventory-item img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: 0 0 auto;
}

.inventory-item__title { margin: 0 0 6px; }

.inventory-item__actions {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}

.inventory-value { color: #fff1c7; font-weight: 700; }

.small-button {
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(92,57,31,0.96), rgba(52,29,16,0.96));
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #fff4cc;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.variant-prefix.is-golden { color: #ffd36f; }
.variant-prefix.is-diamond { color: #b9f3ff; }
.inventory-list.compact .inventory-item { padding: 10px; }

/* ─── RULES ──────────────────────────────────────────────────────────────────── */
.rule-list { gap: 12px; }
.rule-card { padding: 16px; }
.rule-card h4 { margin: 0 0 8px; }

.control-list { margin: 0; padding: 0; list-style: none; }
.control-list li {
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(16,20,17,0.84);
}

/* ─── CONSUMABLES ────────────────────────────────────────────────────────────── */
.consumable-buttons { display: flex; gap: 10px; margin: 12px 0; }

.consumable-buy-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: linear-gradient(180deg, rgba(48,61,51,0.96), rgba(27,35,30,0.96));
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease;
}
.consumable-buy-btn:hover { transform: translateY(-2px); border-color: var(--line-strong); }

.consumable-btn-icon { width: 32px; height: 32px; image-rendering: pixelated; }
.consumable-btn-icon + span { font-size: 0.9rem; }
.consumable-btn-icon + span + strong { font-size: 0.82rem; color: #ffd778; }

.consumable-stock { display: flex; gap: 14px; flex-wrap: wrap; }

.consumable-stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  font-size: 0.82rem;
  color: var(--muted);
}
.consumable-stock-chip strong { color: #fff1c7; }
.chip-icon { width: 16px; height: 16px; image-rendering: pixelated; }

/* ─── TEXTURE PACK ───────────────────────────────────────────────────────────── */
.menu-select {
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(26,34,28,0.98), rgba(18,24,19,0.98));
  color: var(--text);
  border-color: rgba(255,255,255,0.08);
}
.menu-select:focus { outline: none; border-color: var(--line-strong); }

.texture-button-row { display: flex; gap: 10px; margin: 10px 0; }
.texture-pack-button { flex: 1 1 0; border-radius: 8px; text-align: center; }
.texture-pack-button.is-active {
  color: #1b1208;
  background: linear-gradient(180deg, #ffd778, #d58a2d 58%, #8d4d1c);
  border-color: rgba(255,245,202,0.7);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   GAME VIEW
═══════════════════════════════════════════════════════════════════════════════ */

.game-view {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ─── GAME STAGE ─────────────────────────────────────────────────────────────── */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 0 var(--stage-bottom-pad) 0;
}

.game-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  image-rendering: pixelated;
}

#gameCanvas { background: #c9e7d2; }

/* ─── PICKUP FEED ────────────────────────────────────────────────────────────── */
.pickup-feed {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
  max-width: 220px;        /* constrained on all screens */
}

.pickup-card {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(9,12,10,0.85);
  box-shadow: var(--pixel-shadow);
}

.pickup-card__thumb {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: 0 0 auto;
}

.pickup-card__title { margin: 0; font-size: 0.72rem; line-height: 1.3; }
.pickup-card__meta  { margin: 0; color: var(--muted); font-size: 0.62rem; line-height: 1.3; }

/* ─── HUD ────────────────────────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  pointer-events: none;
  max-width: 55%;
}

.hud-chip {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(16,20,17,0.9);
  box-shadow: none;
}

.hud-chip span  { color: var(--muted); font-size: 0.6rem; display: block; line-height: 1.2; }
.hud-chip strong { display: block; margin-top: 1px; color: #fff1c7; font-size: 0.68rem; line-height: 1.2; }

/* ─── CASHOUT BUTTON ─────────────────────────────────────────────────────────── */
.cashout-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 20;
  height: var(--cashout-h);
  padding: 0 18px;
  border: 2px solid rgba(255,198,101,0.3);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(132,88,31,0.98), rgba(74,45,12,0.98));
  color: #fff0c6;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* ─── SURVIVAL BARS ──────────────────────────────────────────────────────────── */
.survival-bars {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--cashout-h) + var(--bottom-bar-gap));
  z-index: 20;
  display: flex;
  gap: 6px;
}

.survival-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  height: var(--survival-h);
  border-radius: 8px;
  background: rgba(12,17,14,0.90);
  border: 1px solid rgba(255,255,255,0.07);
  min-width: 0;
}

.survival-icon { width: 18px; height: 18px; flex: 0 0 auto; image-rendering: pixelated; }

.survival-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  overflow: hidden;
  min-width: 0;
}

.survival-fill { height: 100%; border-radius: 999px; transition: width 0.2s ease; }
.stamina-fill { background: linear-gradient(90deg, #c99b3a, #f0d060); }
.thirst-fill  { background: linear-gradient(90deg, #3a8fc9, #60c8f0); }

.survival-text {
  flex: 0 0 34px;
  text-align: right;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff1c7;
}

/* ─── HOTBAR ─────────────────────────────────────────────────────────────────── */
.hotbar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--cashout-h) + var(--bottom-bar-gap) + var(--survival-h) + var(--bottom-bar-gap));
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: var(--hotbar-h);
}

.hotbar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 52px;
  padding: 5px 7px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(12,17,14,0.90);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
  font-family: inherit;
  color: inherit;
}
.hotbar-slot:hover { transform: translateY(-3px); border-color: rgba(255,236,193,0.34); }

.hotbar-slot__icon  { width: 22px; height: 22px; image-rendering: pixelated; display: block; }
.hotbar-slot__label { font-size: 0.58rem; color: var(--muted); }
.hotbar-slot__count { font-size: 0.68rem; font-weight: 700; color: #fff1c7; line-height: 1; }
.hotbar-slot__action { font-size: 0.55rem; color: var(--accent); opacity: 0; transition: opacity 120ms ease; }
.hotbar-slot:hover .hotbar-slot__action { opacity: 1; }

.hotbar-label {
  font-size: 0.66rem;
  color: var(--muted);
  align-self: center;
  margin-right: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hotbar-empty {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(12,17,14,0.7);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ─── JOYSTICK ───────────────────────────────────────────────────────────────── */
.joystick-container {
  position: absolute;
  bottom: calc(8px + var(--cashout-h) + var(--bottom-bar-gap) + var(--survival-h) + var(--bottom-bar-gap) + var(--hotbar-h) + var(--bottom-bar-gap));
  left: 16px;
  width: 130px;
  height: 130px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.joystick-base {
  width: 110px;
  height: 110px;
  background: rgba(255,255,255,0.13);
  border: 3px solid rgba(255,255,255,0.38);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.joystick-stick {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.82);
  border-radius: 50%;
  position: absolute;
  top: calc(50% - 22px);
  left: calc(50% - 22px);
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  transition: transform 0.04s linear;
  will-change: transform;
}

/* ─── RUN PANEL (sidebar) ────────────────────────────────────────────────────── */
.run-panel {
  width: 300px;
  flex: 0 0 300px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: flex-start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.run-section { display: flex; flex-direction: column; gap: 12px; }

/* ─── DIALOGS ────────────────────────────────────────────────────────────────── */
.summary-dialog { border: 0; padding: 0; background: transparent; color: white; }
.summary-dialog::backdrop { background: rgba(7,9,8,0.72); }

.summary-dialog__content {
  min-width: min(460px, calc(100vw - 24px));
  padding: 22px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
}

.custom-world-dialog { border: 0; padding: 0; background: transparent; }
.custom-world-dialog::backdrop { background: rgba(7,9,8,0.78); }

.custom-world-dialog__content {
  min-width: min(640px, calc(100vw - 24px));
  max-width: 720px;
  padding: 22px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
  color: var(--text);
}

.custom-world-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 12px;
}

.custom-world-field { display: flex; flex-direction: column; gap: 8px; color: var(--muted); }

.custom-world-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(14,18,15,0.96);
  color: var(--text);
}
.custom-world-field input:focus { outline: none; border-color: var(--line-strong); }

.custom-world-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(16,20,17,0.84);
  border: 2px solid rgba(255,255,255,0.06);
  color: #f1d997;
}

.biome-picker {
  margin: 0;
  padding: 14px;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(12,17,14,0.88);
}
.biome-picker legend {
  padding: 0 8px;
  color: #f2d794;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.biome-check { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--text); }
.biome-check input { width: 18px; height: 18px; accent-color: #f0b44d; }

.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.dialog-actions > button { min-width: 140px; }

.card-dialog { border: 0; padding: 0; background: transparent; color: white; }
.card-dialog::backdrop { background: rgba(7,9,8,0.72); }
.dialog-content {
  min-width: min(420px, calc(100vw - 24px));
  padding: 22px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: 0 30px 60px rgba(0,0,0,0.35);
}
.dialog-title { font-family: var(--title-font); margin: 0; }
.dialog-body { margin-top: 12px; line-height: 1.5; }

/* ─── UTILITY ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  ≤ 1120px
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1120px) {
  .game-view { flex-direction: column; }

  .run-panel {
    width: 100%;
    flex: none;
    position: static;
    max-height: none;
  }

  .game-stage { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE PORTRAIT  ≤ 720px
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  :root {
    --hotbar-h: 58px;
    --survival-h: 36px;
    --cashout-h: 44px;
    --bottom-bar-gap: 5px;
  }

  .app-shell {
    width: 100%;
    padding: 8px 6px 12px;
  }

  /* Topbar stacks */
  .topbar {
    flex-direction: column;
    min-height: auto;
    gap: 4px;
    margin-bottom: 8px;
  }
  .coins-badge {
    position: static;
    font-size: 0.82rem;
    padding: 8px 12px;
  }

  /* Menu fills width */
  .menu-nav  { width: 100%; }
  .menu-panel { max-height: none; width: 100%; }

  /* Panels */
  .panel-heading,
  .inventory-item,
  .skin-card,
  .selected-skin-card { align-items: flex-start; }
  .inventory-item { flex-direction: column; }
  .inventory-item__actions { margin-left: 0; align-items: flex-start; text-align: left; }
  .texture-button-row  { flex-direction: column; }
  .consumable-buttons  { flex-direction: column; }

  /* Pickup feed — tiny, top-left, no overlap */
  .pickup-feed {
    top: 6px;
    left: 6px;
    max-width: 200px;
    gap: 4px;
  }

  .pickup-card {
    gap: 5px;
    padding: 4px 6px;
    border-radius: 8px;
  }

  .pickup-card__thumb { width: 22px; height: 22px; }
  .pickup-card__title { font-size: 0.62rem; }
  .pickup-card__meta  { font-size: 0.54rem; }

  /* HUD — tiny chips, top-right */
  .hud {
    top: 6px;
    right: 6px;
    max-width: 52%;
    gap: 4px;
  }

  .hud-chip { padding: 3px 6px; border-radius: 5px; }
  .hud-chip span   { font-size: 0.5rem; }
  .hud-chip strong { font-size: 0.58rem; margin-top: 0; }

  /* Cashout full width */
  .cashout-button {
    left: 6px;
    right: 6px;
    width: auto;
    text-align: center;
    font-size: 0.88rem;
    border-radius: 10px;
  }

  /* Survival + hotbar span full width */
  .survival-bars { left: 6px; right: 6px; gap: 5px; }
  .hotbar        { left: 6px; right: 6px; gap: 5px; }
  .hotbar-slot   { min-width: 46px; }

  /* Joystick smaller */
  .joystick-container { width: 100px; height: 100px; left: 10px; }
  .joystick-base      { width: 86px; height: 86px; }
  .joystick-stick     { width: 36px; height: 36px; top: calc(50% - 18px); left: calc(50% - 18px); }

  /* Run panel below canvas */
  .run-panel { width: 100%; flex: none; position: static; max-height: none; }

  /* Dialogs */
  .custom-world-dialog__content { min-width: calc(100vw - 20px); padding: 12px; }
  .custom-world-grid { grid-template-columns: 1fr; }
  .summary-dialog__content { min-width: calc(100vw - 20px); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE LANDSCAPE  (phone tilted)
   short viewport + wide width
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --hotbar-h: 48px;
    --survival-h: 30px;
    --cashout-h: 36px;
    --bottom-bar-gap: 4px;
  }

  .app-shell {
    width: 100%;
    padding: 4px 6px 8px;
  }

  /* Very compact topbar */
  .topbar {
    flex-direction: row;
    min-height: 40px;
    margin-bottom: 6px;
    justify-content: space-between;
  }
  .topbar-title { font-size: 1.1rem; padding: 4px 8px; }
  .coins-badge  { position: static; font-size: 0.76rem; padding: 5px 10px; }

  /* Menu: side-by-side nav + panel in landscape */
  .menu-shell {
    flex-direction: row;
    align-items: flex-start;
    width: 100%;
    gap: 10px;
  }
  .menu-nav  { width: 180px; flex: 0 0 180px; }
  .menu-panel { flex: 1; max-height: calc(100vh - 70px); }

  /* Game view: canvas left, run-panel right (compact) */
  .game-view { flex-direction: row; gap: 8px; align-items: flex-start; }

  .game-stage { flex: 1 1 auto; }

  .run-panel {
    width: 200px;
    flex: 0 0 200px;
    position: sticky;
    top: 4px;
    max-height: calc(100vh - 16px);
    padding: 8px;
    font-size: 0.8rem;
    gap: 8px;
  }

  /* Minimap smaller */
  #minimapCanvas { width: 100% !important; height: auto !important; }

  /* Pickup feed: ultra-compact, top-left */
  .pickup-feed {
    top: 4px;
    left: 4px;
    max-width: 250px;
    gap: 3px;
  }
  .pickup-card { padding: 3px 5px; gap: 4px; border-radius: 6px; }
  .pickup-card__thumb { width: 18px; height: 18px; }
  .pickup-card__title { font-size: 0.56rem; }
  .pickup-card__meta  { font-size: 0.5rem; }

  /* HUD: ultra-compact chips */
  .hud { top: 4px; right: 4px; gap: 3px; max-width: 48%; }
  .hud-chip { padding: 2px 5px; border-radius: 4px; }
  .hud-chip span   { font-size: 0.46rem; }
  .hud-chip strong { font-size: 0.52rem; }

  /* Cashout */
  .cashout-button {
    right: 4px;
    bottom: 4px;
    left: auto;
    width: auto;
    font-size: 0.76rem;
    height: var(--cashout-h);
    padding: 0 12px;
    border-radius: 8px;
  }

  /* Survival bars */
  .survival-bars { left: 4px; right: 4px; gap: 4px; }
  .survival-icon  { width: 14px; height: 14px; }
  .survival-track { height: 6px; }
  .survival-text  { font-size: 0.55rem; flex: 0 0 28px; }

  /* Hotbar */
  .hotbar { left: 4px; right: 4px; gap: 4px; }
  .hotbar-slot { min-width: 42px; padding: 3px 5px; }
  .hotbar-slot__icon  { width: 18px; height: 18px; }
  .hotbar-slot__count { font-size: 0.6rem; }
  .hotbar-label { font-size: 0.58rem; }

  /* Joystick: smaller, repositioned */
  .joystick-container { width: 84px; height: 84px; left: 8px; }
  .joystick-base      { width: 72px; height: 72px; border-width: 2px; }
  .joystick-stick     { width: 30px; height: 30px; top: calc(50% - 15px); left: calc(50% - 15px); }

  /* Dialogs */
  .custom-world-grid  { grid-template-columns: 1fr 1fr; }
  .summary-dialog__content,
  .custom-world-dialog__content { min-width: calc(100vw - 20px); padding: 10px; }
}