/* LABY · Ghost Rails — polished 16-bit night railway. */

:root {
  --night-0: #07111f;
  --night-1: #0d1b2a;
  --night-2: #162b3d;
  --night-3: #23465a;
  --panel: #14283a;
  --panel-hi: #1e3a4d;
  --panel-lo: #091521;
  --paper: #fff1c1;
  --paper-dim: #d8d0a9;
  --sky: #5fc4c7;
  --mint: #83d69c;
  --gold: #f6c85f;
  --orange: #ef8b55;
  --coral: #e85d68;
  --purple: #9d78cc;
  --ink: #fff1c1;
  --muted: #b9c5b1;
  --dim: #738b86;
  --accent: var(--sky);
  --amber: var(--gold);
  --green: var(--mint);
  --pink: var(--coral);
  --violet: var(--purple);
  --danger: var(--coral);
  --panel-line: #36566a;
  --pixel: "Press Start 2P", "Courier New", monospace;
  --mono: "Pixelify Sans", "Courier New", ui-monospace, monospace;
  --sans: "Pixelify Sans", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --pixel-shadow: 0 5px 0 #050a12;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night-0);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font-family: inherit; }
button:focus-visible { outline: 3px solid var(--paper); outline-offset: 4px; }

.logo-kicker,
.hud-title strong,
.screen-head h2,
.lights-out,
.btn-main,
.brief h2,
.result h2,
.section-title { font-family: var(--pixel); }

#app {
  --board-top: 118px;
  --board-bottom: 20px;
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(95,196,199,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95,196,199,.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 25%, #173149 0, var(--night-0) 68%);
  background-size: 16px 16px, 16px 16px, auto;
}

#app::before,
#app::after {
  content: "";
  position: absolute;
  z-index: 24;
  pointer-events: none;
}
#app::before {
  inset: 0;
  border: 4px solid rgba(95,196,199,.1);
}
#app::after {
  right: 8px;
  bottom: 8px;
  width: 4px;
  height: 4px;
  background: var(--sky);
  box-shadow: -8px 0 var(--sky), 0 -8px var(--sky), -8px -8px var(--sky);
  opacity: .25;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

/* ── HUD ───────────────────────────────────────────────────── */

#hud[hidden], #pad[hidden] { display: none !important; }

#hud {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 10px 10px;
  background: linear-gradient(var(--night-0) 72%, transparent);
  pointer-events: none;
}
#hud button { pointer-events: auto; }
.hud-row { display: flex; align-items: center; gap: 10px; }
.hud-row:first-child {
  width: min(740px, 100%);
  min-height: 55px;
  margin: auto;
  padding: 7px;
  border: 3px solid #050a12;
  background: var(--panel);
  box-shadow: inset 0 0 0 2px #36566a, var(--pixel-shadow);
}
.hud-row--platforms { justify-content: center; min-height: 25px; }
.hud-title { display: flex; min-width: 0; flex-direction: column; line-height: 1.1; }
.hud-title strong { overflow: hidden; color: var(--paper); font-size: 9px; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.hud-title span { margin-top: 3px; color: var(--sky); font-size: 8px; letter-spacing: 1.8px; text-transform: uppercase; }
.hud-metrics { display: flex; align-self: stretch; margin-left: auto; }
.metric {
  display: flex;
  min-width: 56px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 2px solid #2a475a;
  line-height: 1;
}
.metric b { color: var(--paper); font-size: 15px; font-variant-numeric: tabular-nums; }
.metric span { margin-top: 5px; color: var(--dim); font-size: 7px; letter-spacing: 1.2px; text-transform: uppercase; }
.metric.over b { color: var(--coral); animation: pixelFlash .6s steps(2) infinite; }

.pips { display: flex; gap: 7px; }
.pip {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 3px solid #3f331a;
  background: #281f15;
  box-shadow: inset 0 0 0 1px #9b7131, 0 3px 0 #050a12;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
}
.pip.done { transform: translateY(-2px); border-color: #143421; background: var(--mint); box-shadow: inset 0 0 0 1px #d8ffc4, 0 3px 0 #050a12; color: #0a2016; }
.pip.next { animation: pipPulse 1s steps(2) infinite; }
@keyframes pipPulse { 50% { box-shadow: inset 0 0 0 1px #fff1c1, 0 0 0 3px rgba(246,200,95,.3), 0 3px 0 #050a12; } }

.combo { padding: 5px 8px 4px; border: 2px solid var(--coral); background: #351b28; color: #ff9b8e; font-size: 9px; font-weight: 700; text-transform: uppercase; }

.survey { display: flex; width: min(430px, 100%); margin: 0 auto; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; }
.survey-label { display: flex; align-items: center; gap: 7px; color: var(--paper); font-size: 9px; font-weight: 700; letter-spacing: 2px; text-shadow: 2px 2px #050a12; }
.survey-label em { color: var(--gold); font-style: normal; font-variant-numeric: tabular-nums; }
.survey-track { width: 100%; height: 7px; padding: 2px; background: #050a12; }
#survey-fill { width: 100%; height: 3px; background: repeating-linear-gradient(90deg, var(--mint) 0 8px, #b7ed9c 8px 12px, var(--gold) 12px 16px); }
.blink { color: var(--mint); animation: pixelFlash 1s steps(2) infinite; }
@keyframes pixelFlash { 50% { opacity: .3; } }

.lights-out {
  position: absolute;
  top: 45%;
  right: 0;
  left: 0;
  color: var(--paper);
  font-size: clamp(18px, 6vw, 30px);
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  text-shadow: 4px 4px #050a12, -2px -2px var(--night-3);
  animation: lightsOut 900ms steps(7) forwards;
  pointer-events: none;
}
@keyframes lightsOut { 0% { opacity: 0; transform: scale(1.5); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(.9); } }

/* ── Pixel controls ────────────────────────────────────────── */

#pad {
  position: absolute;
  right: 0;
  bottom: calc(12px + var(--safe-bottom));
  left: 0;
  z-index: 4;
  height: 150px;
  pointer-events: none;
}
#pad > * { pointer-events: auto; }
.pad-btn {
  position: absolute;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 4px solid #050a12;
  border-radius: 2px;
  background: #244357;
  box-shadow: inset 0 0 0 2px #4e7180, inset -6px -6px #172c3d, 0 6px 0 #050a12;
  color: var(--paper);
  font-size: 17px;
  text-shadow: 2px 2px #050a12;
}
.pad-btn:active { transform: translateY(5px); box-shadow: inset 0 0 0 2px #4e7180, inset -3px -3px #172c3d, 0 1px 0 #050a12; color: var(--gold); }
.pad-up { bottom: 96px; left: calc(50% - 27px); }
.pad-down { bottom: 0; left: calc(50% - 27px); }
.pad-left { bottom: 48px; left: calc(50% - 79px); }
.pad-right { bottom: 48px; left: calc(50% + 25px); }
.flare-btn {
  position: absolute;
  right: 14px;
  bottom: 37px;
  display: flex;
  width: 84px;
  height: 66px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 4px solid #050a12;
  border-radius: 2px;
  background: #4b2b23;
  box-shadow: inset 0 0 0 2px #8b5138, inset -6px -6px #2c1717, 0 6px 0 #050a12;
  color: var(--gold);
}
.flare-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: inset 0 0 0 2px #8b5138, 0 1px 0 #050a12; }
.flare-btn:disabled { opacity: .38; filter: saturate(.4); }
.flare-icon { font-size: 22px; text-shadow: 2px 2px #050a12; }
.flare-copy { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.flare-copy small { color: #e9b081; font-size: 7px; letter-spacing: 1px; }
.flare-copy b { margin-top: 5px; font-size: 13px; }

/* ── Screens ───────────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  background:
    linear-gradient(rgba(95,196,199,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95,196,199,.04) 1px, transparent 1px),
    radial-gradient(circle at 50% 12%, #19344a, var(--night-0) 70%);
  background-size: 16px 16px, 16px 16px, auto;
  animation: screenIn 180ms steps(4);
}
.screen.active { display: flex; }
.screen--center { align-items: center; justify-content: center; overflow-y: auto; padding: max(18px, var(--safe-top)) 20px max(20px, var(--safe-bottom)); text-align: center; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } }

.screen-head {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 4px solid #050a12;
  background: var(--panel);
  box-shadow: inset 0 -2px #36566a;
}
.screen-head h2 { margin: 0; color: var(--paper); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; text-shadow: 2px 2px #050a12; }
.star-total { margin-left: auto; color: var(--gold); font-size: 12px; font-weight: 700; }
.scroll { width: min(900px, 100%); flex: 1; align-self: center; overflow-y: auto; padding: 20px 16px calc(42px + var(--safe-bottom)); scrollbar-color: var(--night-3) var(--night-0); -webkit-overflow-scrolling: touch; }
.icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border: 3px solid #050a12;
  border-radius: 2px;
  background: #244357;
  box-shadow: inset 0 0 0 2px #4e7180, 0 4px 0 #050a12;
  color: var(--paper);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px #4e7180, 0 1px #050a12; }

/* ── Illustrated title ─────────────────────────────────────── */

.logo { width: min(360px, 100%); }
.logo-kicker { margin: 0 0 8px; color: var(--gold); font-size: 7px; font-weight: 700; letter-spacing: 1px; text-shadow: 2px 2px #050a12; }
.hero-frame {
  position: relative;
  width: min(340px, 86vw);
  margin: 0 auto -16px;
  border: 4px solid #050a12;
  background: #102438;
  box-shadow: inset 0 0 0 2px #36566a, 0 7px 0 #050a12;
}
.hero-frame::before,
.hero-frame::after { content: ""; position: absolute; z-index: 2; width: 8px; height: 8px; background: var(--gold); }
.hero-frame::before { top: 6px; left: 6px; }
.hero-frame::after { right: 6px; bottom: 6px; }
.hero-scene { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.px-sky { fill: #112b46; }
.px-stars { fill: #f8e7a1; }
.px-moon { fill: var(--gold); }
.px-moon-cut { fill: #112b46; }
.px-hill-back { fill: #24465a; }
.px-hill-front { fill: #183648; }
.px-platform { fill: #233a42; }
.px-platform-edge { fill: #567368; }
.px-sleepers { fill: #6f5532; }
.px-rails { fill: #c8c29e; }
.px-station { fill: #d66952; }
.px-station-window { fill: #f6cf68; }
.px-train { fill: #4ec0a3; }
.px-train-dark { fill: #247367; }
.px-train-window { fill: #9be8d2; }
.px-train-gold { fill: #f6c85f; }
.px-wheel { fill: #07111f; }
.px-wheel-hub { fill: #b5b28f; }
.px-smoke { fill: #8295a0; opacity: .7; }
.scene-sign { position: absolute; top: 9px; left: 12px; padding: 4px 5px 3px; background: #07111f; color: var(--mint); font-size: 6px; letter-spacing: 1px; }
.logo h1 {
  position: relative;
  z-index: 3;
  margin: 0;
  color: var(--paper);
  font-size: clamp(49px, 14vw, 72px);
  font-weight: 900;
  font-family: var(--pixel);
  letter-spacing: 10px;
  line-height: .95;
  text-indent: 10px;
  text-shadow: 4px 0 #da5b4a, 0 4px #da5b4a, 4px 4px #050a12, 7px 7px #050a12;
}
.logo-sub { margin: 8px 0 0; color: var(--sky); font-size: 9px; font-weight: 700; letter-spacing: 6px; text-indent: 6px; text-shadow: 2px 2px #050a12; text-transform: uppercase; }
.tagline { max-width: 390px; margin: 13px 0 15px; color: var(--paper-dim); font-family: var(--mono); font-size: 10px; line-height: 1.7; text-shadow: 2px 2px #050a12; }

.brain-strip {
  display: flex;
  width: min(350px, 100%);
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 10px 13px;
  border: 3px solid #050a12;
  background: var(--panel);
  box-shadow: inset 0 0 0 2px #36566a, var(--pixel-shadow);
}
.brain-strip-main { display: flex; flex-direction: column; align-items: flex-start; }
.brain-strip-main b { color: var(--gold); font-size: 25px; line-height: 1; text-shadow: 2px 2px #050a12; }
.brain-strip-main span, .brain-strip-side span { color: var(--dim); font-size: 6px; letter-spacing: 1.2px; text-transform: uppercase; }
.brain-strip-side { display: flex; flex: 1; justify-content: flex-end; gap: 14px; padding-left: 14px; border-left: 2px solid #36566a; }
.brain-strip-side div { display: flex; flex-direction: column; align-items: flex-start; }
.brain-strip-side b { color: var(--paper); font-size: 12px; }

.menu { display: flex; width: min(370px, 100%); flex-direction: column; gap: 9px; }
.menu-row { display: flex; gap: 9px; }
.menu-row .btn { flex: 1; }
.btn {
  position: relative;
  display: flex;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 10px 14px;
  border: 3px solid #050a12;
  border-radius: 2px;
  background: #1b3548;
  box-shadow: inset 0 0 0 2px #365a6d, 0 5px 0 #050a12;
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}
.btn:hover { background: #24485c; color: #fff9dc; }
.btn:active { transform: translateY(4px); box-shadow: inset 0 0 0 2px #365a6d, 0 1px #050a12; }
.btn-main { display: flex; align-items: center; gap: 7px; font-size: 8px; font-weight: 900; letter-spacing: 0; line-height: 1.4; text-transform: uppercase; }
.btn-sub { color: #8da9a5; font-size: 7px; letter-spacing: .3px; }
.btn--primary { background: #e76d4f; box-shadow: inset 0 0 0 2px #ffad70, 0 5px 0 #4c1f21; color: #fff3c4; }
.btn--primary:hover { background: #f27b53; }
.btn--primary .btn-sub { color: #ffe0a1; }
.btn--ghost { align-items: center; background: #102437; box-shadow: inset 0 0 0 2px #29475a, 0 4px 0 #050a12; text-align: center; }
.btn--danger { margin-top: 28px; color: #ff8f81; }
.menu > .btn { min-height: 57px; padding-left: 64px; }
.menu > .btn::before {
  position: absolute;
  left: 12px;
  display: grid;
  width: 38px;
  height: 34px;
  place-items: center;
  border: 3px solid #050a12;
  background: #274a59;
  box-shadow: inset 0 0 0 2px #5c7c78;
  color: var(--mint);
  font-size: 11px;
  font-weight: 900;
}
.menu > [data-action="play-campaign"]::before { content: "▶"; }
.menu > [data-action="play-daily"]::before { content: "24"; background: #4b3820; box-shadow: inset 0 0 0 2px #8d6a32; color: var(--gold); }
.menu > [data-action="play-gauntlet"]::before { content: "∞"; background: #42233b; box-shadow: inset 0 0 0 2px #764d72; color: #e897b4; font-size: 18px; }
.menu > .btn--primary::before { background: #9e3d38; box-shadow: inset 0 0 0 2px #e76d4f; color: var(--paper); }
.badge { padding: 3px 5px 2px; background: var(--mint); box-shadow: 2px 2px #050a12; color: #0a2016; font-size: 6px; font-style: normal; letter-spacing: 1px; }
.chips { display: flex; justify-content: center; gap: 8px; margin-top: 3px; }
.chip { min-height: 29px; padding: 6px 9px 5px; border: 2px solid #29475a; border-radius: 2px; background: #0d1b2a; color: var(--dim); font-size: 7px; cursor: pointer; text-transform: uppercase; }
.chip.on { border-color: #3b766f; color: var(--mint); }
.chip.on::before { content: "■ "; font-size: 5px; }
.control-hint { margin: 1px 0 0; color: #4e6b6d; font-size: 6px; letter-spacing: 1.6px; }
.ghost-btn { display: flex; min-height: 30px; align-items: center; gap: 7px; padding: 6px 11px 5px; border: 2px solid #29475a; border-radius: 2px; background: var(--panel); box-shadow: 0 3px #050a12; color: var(--paper-dim); font-size: 8px; }
.ghost-btn:hover { border-color: var(--sky); color: var(--paper); }
kbd { padding: 2px 5px 1px; border: 2px solid #050a12; background: #263d4b; box-shadow: inset 0 0 0 1px #526b73; color: var(--gold); font-size: 7px; }

/* ── Campaign map ──────────────────────────────────────────── */

.zone { position: relative; margin-bottom: 22px; padding: 15px; border: 3px solid #050a12; background: #122638; box-shadow: inset 0 0 0 2px #29495c, 0 5px 0 #050a12; }
.zone::before { content: ""; position: absolute; top: 7px; right: 7px; width: 5px; height: 5px; background: currentColor; box-shadow: -8px 0 currentColor, 0 8px currentColor, -8px 8px currentColor; opacity: .35; }
.zone-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; }
.zone-head h3 { margin: 0; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; text-shadow: 2px 2px #050a12; }
.zone-head span { margin-left: auto; color: var(--dim); font-size: 7px; line-height: 1.4; text-align: right; }
.zone-teach { max-width: 680px; margin: 0 0 13px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 9px; }
.level-tile { display: flex; aspect-ratio: 1; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 3px solid #050a12; border-radius: 2px; background: #1c3a4a; box-shadow: inset 0 0 0 2px #365c69, 0 4px 0 #050a12; color: var(--paper); font-size: 12px; font-weight: 700; cursor: pointer; }
.level-tile:hover:not(:disabled) { transform: translateY(-2px); background: #275366; }
.level-tile:disabled { opacity: .28; cursor: not-allowed; filter: grayscale(.6); }
.level-tile .tile-stars { min-height: 9px; color: var(--gold); font-size: 7px; letter-spacing: 1px; }
.level-tile.cleared { background: #164334; box-shadow: inset 0 0 0 2px #3c7d5a, 0 4px 0 #050a12; }
.level-tile.current { animation: currentTile 1s steps(2) infinite; }
@keyframes currentTile { 50% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 3px rgba(246,200,95,.28), 0 4px 0 #050a12; } }

/* ── Briefing and results ──────────────────────────────────── */

.brief, .result { position: relative; width: min(440px, 100%); padding: 25px 21px 21px; border: 4px solid #050a12; background: #142b3d; box-shadow: inset 0 0 0 2px #426177, 0 7px 0 #050a12; }
.brief::before, .result::before { content: ""; position: absolute; top: 8px; left: 8px; width: 6px; height: 6px; background: var(--gold); box-shadow: calc(100% + 4px) 0 var(--gold); }
.brief::after { content: "ROUTE CARTRIDGE"; display: block; margin-top: 17px; color: #4e6b6d; font-size: 6px; letter-spacing: 2px; }
.brief-zone { margin: 0 0 8px; color: var(--mint); font-size: 8px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; }
.brief h2 { margin: 0 0 13px; color: var(--paper); font-size: 16px; letter-spacing: 0; line-height: 1.5; text-shadow: 3px 3px #050a12; }
.brief-teach { margin: 0 0 17px; color: var(--paper-dim); font-size: 9px; line-height: 1.65; }
.brief-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin: 0 0 20px; padding: 0; list-style: none; }
.brief-facts li { padding: 5px 7px 4px; border: 2px solid #29495c; background: #0c1d2b; color: var(--muted); font-size: 7px; }
.brief-facts li b { color: var(--gold); }
.brief .btn { width: 100%; align-items: center; text-align: center; }
.stars { height: 40px; color: var(--gold); font-size: 30px; letter-spacing: 7px; text-shadow: 3px 3px #6b3d1f, 5px 5px #050a12; }
.stars .off { color: #31424a; text-shadow: 3px 3px #050a12; }
.stars .pop { display: inline-block; animation: starPop 420ms steps(5) backwards; }
@keyframes starPop { from { transform: scale(0) rotate(-45deg); opacity: 0; } }
.result h2 { margin: 8px 0 7px; color: var(--paper); font-size: 14px; line-height: 1.5; text-shadow: 3px 3px #050a12; }
.result-sub { margin: 0 0 14px; color: var(--paper-dim); font-size: 9px; line-height: 1.5; }
.points { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin-bottom: 16px; }
.points b { color: var(--mint); font-size: 29px; text-shadow: 3px 3px #12352b; }
.points span { color: #ff9b8e; font-size: 9px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 0 0 16px; padding: 0; list-style: none; }
.stat-grid li { display: flex; align-items: baseline; justify-content: space-between; padding: 8px; border: 2px solid #29495c; background: #0d1e2c; color: var(--muted); font-size: 7px; }
.stat-grid li b { color: var(--paper); font-size: 9px; }
.stat-grid li.good b { color: var(--mint); }
.stat-grid li.bad b { color: #ff8a7d; }
.brain-deltas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 17px; }
.brain-delta { padding: 6px 2px; border-bottom: 2px solid #29495c; text-align: center; }
.brain-delta b { display: block; font-size: 12px; }
.brain-delta span { display: block; margin-top: 3px; color: var(--dim); font-size: 6px; letter-spacing: .5px; text-transform: uppercase; }
.brain-delta em { font-size: 8px; font-style: normal; }
.up { color: var(--mint); }
.down { color: var(--coral); }
.result-actions { display: flex; flex-direction: column; gap: 8px; }
.result-actions .btn { align-items: center; text-align: center; }

/* ── Brain and help ────────────────────────────────────────── */

.brain-hero { margin-bottom: 21px; text-align: center; }
.brain-hero b { color: var(--gold); font-size: 47px; line-height: 1; text-shadow: 4px 4px #5a371f, 7px 7px #050a12; }
.brain-hero span { display: block; margin-top: 7px; color: var(--dim); font-size: 7px; letter-spacing: 2px; text-transform: uppercase; }
#spark { width: 100%; height: 90px; margin-top: 14px; image-rendering: pixelated; }
.tracks, .rank { padding: 13px; border: 3px solid #050a12; background: #122638; box-shadow: inset 0 0 0 2px #29495c, 0 4px 0 #050a12; }
.tracks { display: flex; flex-direction: column; gap: 13px; }
.track-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.track-head b { font-size: 9px; text-transform: uppercase; }
.track-head span { color: var(--gold); font-size: 9px; }
.track-blurb { margin: 4px 0 0; color: var(--dim); font-size: 7px; line-height: 1.4; }
.bar { height: 8px; padding: 2px; background: #050a12; }
.bar > div { height: 4px; background: repeating-linear-gradient(90deg, var(--mint) 0 8px, #b8f09c 8px 10px, var(--sky) 10px 16px); transition: width 500ms steps(10); }
.section-title { margin: 25px 0 10px; color: var(--sky); font-size: 8px; letter-spacing: 2px; text-transform: uppercase; text-shadow: 2px 2px #050a12; }
.rank-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.rank-row b { color: var(--paper); font-size: 12px; }
.rank-row span { color: var(--gold); font-size: 8px; }
.muted { color: var(--dim); font-size: 8px; line-height: 1.6; }
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 8px; }
.ach { padding: 10px; border: 3px solid #050a12; background: #101f2d; box-shadow: inset 0 0 0 1px #29495c; opacity: .42; }
.ach.won { background: #173b31; box-shadow: inset 0 0 0 1px #4b8561; opacity: 1; }
.ach b { display: block; margin-bottom: 4px; color: var(--paper); font-size: 8px; }
.ach span { color: var(--dim); font-size: 7px; line-height: 1.45; }
.help .steps { margin: 0 0 8px; padding-left: 20px; }
.help .steps li { margin-bottom: 11px; padding-left: 4px; color: var(--paper-dim); font-size: 9px; line-height: 1.65; }
.help .steps li::marker { color: var(--gold); font-weight: 900; }
.help .steps b { color: var(--paper); }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 8px; line-height: 1.5; }
.legend .swatch { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 0 !important; box-shadow: 2px 2px #050a12; font-size: 10px; font-weight: 700; }
.keys { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; color: var(--muted); font-size: 8px; line-height: 1.5; list-style: none; }

.toast {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  z-index: 30;
  max-width: 88vw;
  padding: 10px 13px 9px;
  transform: translateX(-50%);
  border: 3px solid #050a12;
  background: #4d301d;
  box-shadow: inset 0 0 0 2px #93613b, 0 5px 0 #050a12;
  color: var(--gold);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  animation: toastIn 180ms steps(4);
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (max-width: 759px) {
  #app { --board-top: 130px; --board-bottom: 168px; }
  .screen--center { justify-content: flex-start; padding-top: calc(13px + var(--safe-top)); }
  #screen-brief.screen--center, #screen-result.screen--center { justify-content: center; }
  .hero-frame { width: min(330px, 89vw); }
  .logo h1 { font-size: 50px; }
  .tagline { margin: 12px 0; }
  .brain-strip { margin-bottom: 13px; }
  .menu { gap: 8px; }
  .zone { padding: 13px; }
  .zone-head { align-items: flex-start; }
}

@media (max-width: 390px), (max-height: 730px) {
  .logo-kicker { display: none; }
  .hero-frame { width: min(286px, 82vw); margin-bottom: -13px; }
  .logo h1 { font-size: 42px; }
  .logo-sub { margin-top: 6px; }
  .tagline { margin: 8px 0 9px; font-size: 8px; }
  .brain-strip { margin-bottom: 10px; padding: 8px 11px; }
  .brain-strip-main b { font-size: 21px; }
  .menu > .btn { min-height: 50px; }
  .chips { margin-top: 0; }
  .control-hint { display: none; }
  .brief, .result { padding: 20px 16px 17px; }
}

@media (min-width: 760px) {
  #pad { display: none !important; }
  .screen-head { padding-right: max(24px, calc((100vw - 900px) / 2)); padding-left: max(24px, calc((100vw - 900px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
