@font-face {
  font-family: "Press Start 2P";
  src: url(/assets/pressstart2p-latin.woff2) format("woff2");
  font-display: block;
}
@font-face {
  font-family: "DotGothic16";
  src: url(/assets/dotgothic16-latin.woff2) format("woff2");
  font-display: swap;
}

:root {
  --ink: #14121c;
  --night: #1c1340;
  --base: #181523;
  --deep: #120f1d;
  --panel: #2a2160;
  --panel-hover: #221a4e;
  --paper: #f6efd9;
  --paper-2: #e8dcbc;
  --on-paper: #1d1a2b;
  --on-paper-dim: #5d5570;
  --text: #f3ecd8;
  --text-dim: #bdb4d9;
  --gold: #ffcc33;
  --gold-hi: #ffe27a;
  --gold-lo: #c98a12;
  --ember: #ff6b4a;
  --ember-ink: #c73a1c;
  --hp: #4ade6b;
  --hp-mid: #f8c030;
  --hp-low: #f05050;
  --display: "Press Start 2P", ui-monospace, "SF Mono", Menlo, monospace;
  --body: "DotGothic16", ui-monospace, "SF Mono", Menlo, monospace;
  --header: 64px;
  --focus: var(--gold);
}

/* agent palette swaps */
.pal-ringo { --body: #e8503a; --body-d: #a8322a; --body-l: #ff8a6a; --glow: #7cf7ff; --led: #ffcc33; }
.pal-scout { --body: #3fb56a; --body-d: #237a46; --body-l: #86e6a2; --glow: #fff36b; --led: #ff6b4a; }
.pal-echo  { --body: #3f7fe0; --body-d: #2a529a; --body-l: #86b4ff; --glow: #9cffd8; --led: #ffcc33; }
.pal-tock  { --body: #f2b632; --body-d: #b07a1a; --body-l: #ffe07a; --glow: #ff8a7a; --led: #e8503a; }
.pal-sage  { --body: #9b6be8; --body-d: #63409e; --body-l: #c9a6ff; --glow: #ffe28a; --led: #7cf7ff; }

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header) + 8px);
}
body {
  margin: 0;
  font-family: var(--body);
  font-size: 20px;
  line-height: 1.6;
  color: var(--text);
  background: var(--base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--gold); color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.paper :focus-visible, .paper:focus-visible { --focus: var(--ember-ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  background: var(--gold); color: var(--ink); padding: 12px 16px;
  font-family: var(--display); font-size: 12px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- pixel sprites ---------- */
.px { width: 100%; height: auto; overflow: visible; image-rendering: pixelated; }
.px-robot .spr { animation: bob 1.1s steps(1) infinite; }
.px-robot .blink { opacity: 0; animation: blink 4.2s steps(1) infinite; }
.px-robot .talk { opacity: 0; }
.px-robot .led { animation: led 1.6s steps(1) infinite; }
.is-talking .px-robot .talk { animation: talk 0.22s steps(1) infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1px); } }
@keyframes blink { 0%, 93% { opacity: 0; } 94%, 97% { opacity: 1; } 98% { opacity: 0; } }
@keyframes talk { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
@keyframes led { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* brand "8" glyph */
.g8 { display: inline-block; width: 1em; height: 0.875em; vertical-align: baseline; }
.g8 svg { width: 100%; height: 100%; overflow: visible; }
.g8-m { fill: currentColor; }
.g8-s1, .g8-s2 { display: none; }
.wordmark .g8-s1 { display: inline; fill: var(--ember); }
.wordmark .g8-s2 { display: inline; fill: var(--ink); }

/* ---------- pixel boxes (9-slice SVG frames) ---------- */
.box {
  border: 12px solid transparent;
  border-image: url(/assets/frame-paper.svg) 4 fill / 12px / 0 stretch;
  image-rendering: pixelated;
}
.box.sm { border-width: 8px; border-image-width: 8px; }
.box.paper { color: var(--on-paper); }
.box.night { border-image-source: url(/assets/frame-night.svg); color: var(--text); }
.box.ink { border-image-source: url(/assets/frame-ink.svg); }

/* ---------- buttons ---------- */
.btn {
  --bg: var(--gold);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px;
  margin: 4px;
  padding: 14px 20px;
  font-family: var(--display); font-size: 12px; line-height: 1.2; letter-spacing: 0.04em;
  text-transform: uppercase; text-decoration: none; white-space: nowrap;
  color: var(--ink);
  background: var(--bg);
  border: 0; cursor: pointer;
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    inset 0 -4px 0 0 var(--gold-lo), inset 4px 4px 0 0 var(--gold-hi);
  transition: background-color 120ms ease-out;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: translateY(2px);
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    inset 0 4px 0 0 var(--gold-lo);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { --bg: var(--gold-hi); }
}
.btn-sm { min-height: 40px; padding: 10px 14px; font-size: 10px; }
.link-btn {
  background: none; border: 0; padding: 12px 8px; min-height: 44px; cursor: pointer;
  font-family: var(--display); font-size: 11px; text-transform: uppercase; color: var(--on-paper-dim);
  text-decoration: underline; text-underline-offset: 4px;
}

/* menu items with the blinking ▶ cursor */
.menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.menu-item {
  position: relative; display: flex; align-items: center;
  min-height: 44px; width: 100%;
  padding: 8px 12px 8px 30px;
  font-family: var(--display); font-size: 12px; line-height: 1.4; letter-spacing: 0.02em;
  text-transform: uppercase; text-decoration: none; text-align: left;
  color: var(--on-paper);
  background: none; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-item::before, .move::before, .tab::before {
  content: ""; position: absolute; left: 10px; top: 50%;
  width: 8px; height: 14px; margin-top: -7px;
  background: currentColor;
  -webkit-mask: url(/assets/cursor.svg) center / 100% 100% no-repeat;
          mask: url(/assets/cursor.svg) center / 100% 100% no-repeat;
  opacity: 0;
}
.menu-item:focus-visible::before, .menu-item.is-hot::before { opacity: 1; animation: cursor 1s steps(1) infinite; }
.menu:hover .menu-item.is-hot:not(:hover)::before, .menu:focus-within .menu-item.is-hot:not(:focus-visible)::before { opacity: 0; animation: none; }
@media (hover: hover) and (pointer: fine) {
  .menu-item:hover::before { opacity: 1; animation: cursor 1s steps(1) infinite; }
}
.menu-item:active { transform: translateX(2px); }
.menu-item.is-hot { color: var(--ember-ink); }
@keyframes cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* type chips */
.chip {
  display: inline-block; flex: none;
  padding: 6px 8px 5px;
  font-family: var(--display); font-size: 9px; line-height: 1; letter-spacing: 0.06em;
  color: var(--ink); background: var(--c, var(--gold));
  box-shadow: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink);
  margin: 2px;
}
.t-voice { --c: #ff8a6a; }
.t-intel { --c: #6ee08e; }
.t-loyalty { --c: #86b4ff; }
.t-time { --c: #ffd35a; }
.t-assist { --c: #c9a6ff; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  height: var(--header);
  background: var(--base);
  box-shadow: 0 4px 0 0 var(--ink);
}
.top-inner {
  max-width: 1240px; height: 100%; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--display); font-size: 12px; letter-spacing: 0.04em; text-decoration: none;
  margin-right: auto; padding: 6px 0;
}
.brand-bot { width: 26px; }
.brand-bot .spr { animation: none; }
.nav { display: flex; gap: 4px; }
.nav a {
  font-family: var(--display); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  text-decoration: none; color: var(--text-dim);
  padding: 14px 12px;
  transition: color 120ms ease-out;
}
@media (hover: hover) and (pointer: fine) { .nav a:hover { color: var(--gold); } }
.sound {
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  background: none; border: 0; cursor: pointer; color: var(--text-dim);
  transition: color 120ms ease-out;
}
.sound svg { width: 22px; }
.sound .snd-on, .sound[aria-pressed="true"] .snd-off { display: none; }
.sound[aria-pressed="true"] .snd-on { display: block; }
.sound[aria-pressed="true"] { color: var(--gold); }
@media (hover: hover) and (pointer: fine) { .sound:hover { color: var(--text); } }

/* ---------- hero / title screen ---------- */
.hero {
  position: relative; isolation: isolate;
  min-height: calc(100svh - var(--header));
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: clamp(32px, 7vh, 88px) 20px clamp(20px, 4vh, 40px);
  overflow: hidden;
  background: var(--night);
}
@media (min-height: 980px) { .hero { min-height: 900px; } }
.hero-bg {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%; max-width: none;
  object-fit: cover; object-position: 50% 100%;
  image-rendering: pixelated;
}
.sky { position: absolute; inset: 0 0 62% 0; z-index: -1; pointer-events: none; }
.twinkle {
  position: absolute; left: var(--x); top: var(--y);
  width: calc(var(--s) * 7px);
  animation: twinkle 3.2s steps(1) var(--d) infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 0.15; } 30% { opacity: 1; } 55% { opacity: 0.5; } 80% { opacity: 0.15; } }

.title { text-align: center; }
.eyebrow, .kicker {
  margin: 0 0 20px;
  font-family: var(--display); font-size: 11px; line-height: 1.6; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gold);
}
.eyebrow { text-shadow: 2px 2px 0 var(--ink); }
.wordmark {
  margin: 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(36px, 7.4vw, 104px); line-height: 1.05;
  color: var(--paper);
  text-shadow: 0.06em 0.06em 0 var(--ember), 0.12em 0.12em 0 var(--ink);
}
.wm-8 { color: var(--gold); }
.wm-8, .wm-a { display: inline-block; }

.hero-ui {
  position: relative;
  width: 100%; max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr minmax(260px, 330px); gap: 16px; align-items: stretch;
  padding-top: 96px;
}
.speaker { position: absolute; left: 28px; top: 0; width: 80px; }
.dialog { position: relative; padding: 18px 24px 22px; min-width: 0; }
.nameplate {
  position: absolute; top: -26px; left: 132px;
  padding: 8px 10px 7px;
  font-family: var(--display); font-size: 10px; line-height: 1; letter-spacing: 0.06em;
  color: var(--paper); background: var(--ember-ink);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink);
}
.say {
  margin: 0;
  font-size: 24px; line-height: 1.55;
  min-height: calc(3 * 1.55em);
  text-wrap: pretty;
}
.say .rest { visibility: hidden; }
.next {
  position: absolute; right: 6px; bottom: 2px;
  width: 44px; height: 44px; padding: 0;
  background: none; border: 0; cursor: pointer; color: var(--ember-ink);
}
.next::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 8px; margin: -4px 0 0 -7px;
  background: currentColor;
  -webkit-mask: url(/assets/next.svg) center / 100% 100% no-repeat;
          mask: url(/assets/next.svg) center / 100% 100% no-repeat;
  animation: nudge 0.8s steps(1) infinite;
}
.next[hidden] { display: none; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
.hero .dialog { cursor: pointer; }
.menu { padding: 12px 8px; align-self: stretch; display: flex; align-items: center; }
.menu ul { width: 100%; }

/* intro: title drops in like a cartridge boot, once per session */
.intro .wordmark { animation: drop 640ms steps(8) both; }
.intro .eyebrow { animation: appear 1ms 700ms both; }
.intro .hero-ui { animation: appear 1ms 900ms both; }
@keyframes drop { from { transform: translateY(-48px); opacity: 0; } 12% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes appear { from { visibility: hidden; } to { visibility: visible; } }

/* ---------- sections ---------- */
.section { position: relative; padding: clamp(80px, 11vw, 140px) 20px; }
.wrap { max-width: 1200px; margin: 0 auto; }
.head { max-width: 760px; margin-bottom: 48px; }
.head-row { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.head-row > div { max-width: 760px; }
h2 {
  margin: 0 0 20px;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(22px, 3.4vw, 38px); line-height: 1.4;
  color: var(--paper); text-wrap: balance;
  text-shadow: 3px 3px 0 var(--ink);
}
.lead { margin: 0; max-width: 60ch; font-size: 22px; line-height: 1.6; color: var(--text-dim); text-wrap: pretty; }

/* pixel ground strip between sections */
.party-section::before, .quest-section::before, .finale::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 8px, transparent 8px 16px);
  opacity: 0.8;
}

/* ---------- party ---------- */
.party-section { background: var(--base); }
.party { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; align-items: start; }
.party-list { padding: 10px 6px; display: grid; gap: 2px; }
.tab {
  position: relative;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px;
  width: 100%; min-height: 68px;
  padding: 10px 12px 10px 32px;
  text-align: left; background: transparent; border: 0; cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.tab-sprite { width: 40px; }
.tab-sprite .spr { animation: none; }
.tab[aria-selected="true"] .tab-sprite .spr { animation: bob 0.5s steps(1) infinite; }
.tab-text { display: grid; gap: 4px; min-width: 0; }
.tab-name { font-family: var(--display); font-size: 13px; letter-spacing: 0.04em; }
.tab-role { font-size: 17px; line-height: 1.2; color: var(--text-dim); }
.tab[aria-selected="true"] { background: var(--panel); }
.tab[aria-selected="true"]::before { opacity: 1; color: var(--gold); animation: cursor 1s steps(1) infinite; }
@media (hover: hover) and (pointer: fine) {
  .tab:hover:not([aria-selected="true"]) { background: var(--panel-hover); }
}

.panel { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 28px; padding: 20px; }
.panel[hidden] { display: none; }
.panel:focus-visible { outline-offset: 8px; }
.stage {
  position: relative; display: grid; place-items: end center;
  min-height: 300px; padding-bottom: 40px;
  background:
    linear-gradient(180deg, #cfe4ff 0 22%, #bcd8ff 22% 44%, #a8cbf8 44% 66%, #e9f1c8 66% 100%);
  box-shadow: 0 0 0 4px var(--ink);
  overflow: hidden;
}
.stage-no {
  position: absolute; top: 12px; left: 12px;
  font-family: var(--display); font-size: 10px; color: var(--on-paper);
  background: var(--paper); padding: 6px 8px 5px;
  box-shadow: 0 0 0 3px var(--ink);
}
.stage-floor { position: absolute; left: 50%; bottom: 22px; width: 168px; margin-left: -84px; z-index: 0; }
.stage-sprite { position: relative; z-index: 1; width: 128px; margin-bottom: 6px; }
.stage-sprite.hop { animation: hop 320ms steps(4); }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
.panel-info { min-width: 0; padding: 4px 4px 0 0; }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.panel-name { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.3; }
.panel-role { margin: 6px 0 14px; font-size: 18px; color: var(--on-paper-dim); }
.panel-blurb { margin: 0 0 22px; font-size: 21px; line-height: 1.6; max-width: 52ch; text-wrap: pretty; }
.moves-label {
  margin: 0 0 12px; font-family: var(--display); font-weight: 400; font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--on-paper-dim);
}
.moves { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.moves li {
  display: grid; gap: 6px; padding: 12px 14px;
  background: var(--paper-2);
  box-shadow: 0 0 0 2px rgba(20, 18, 28, 0.18);
}
.move-name { font-family: var(--display); font-size: 10px; line-height: 1.5; letter-spacing: 0.04em; }
.move-desc { font-size: 17px; line-height: 1.4; color: var(--on-paper-dim); }

/* ---------- battle ---------- */
.battle-section { background: var(--deep); }
.pips { display: flex; gap: 10px; margin: 0 0 8px; padding: 0; list-style: none; flex: none; }
.pips li {
  width: 20px; height: 20px; background: transparent;
  box-shadow: 0 0 0 4px var(--line, #3a2f74);
}
.pips li.done { background: var(--gold); box-shadow: 0 0 0 4px var(--ink), 0 0 0 6px var(--gold-lo); }
.arena { max-width: 1080px; margin: 0 auto; padding: 0; }
.screen {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  container-type: inline-size;
  background: #2b1f24;
}
.screen-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.foe { position: absolute; left: 80%; bottom: 50.5%; width: 16%; translate: -50% 0; }
.ally { position: absolute; left: 28%; bottom: 19%; width: 19%; translate: -50% 0; }
.foe-inner, .ally-inner { position: relative; }
.foe .is-off, .ally .is-off { display: none; }
.px-phone .spr { transform-box: fill-box; transform-origin: 50% 100%; animation: ring 1.4s steps(1) infinite; }
.px-phone .ring { animation: led 0.35s steps(1) infinite; }
@keyframes ring { 0%, 40%, 100% { transform: none; } 5%, 15%, 25%, 35% { transform: translateX(-1px); } 10%, 20%, 30% { transform: translateX(1px); } }
.px-ghost .spr { animation: bob 1.6s steps(1) infinite; }
.px-ghost .tear { animation: tear 2s steps(4) infinite; }
@keyframes tear { 0% { transform: translateY(0); opacity: 1; } 75% { transform: translateY(3px); opacity: 1; } 100% { transform: translateY(3px); opacity: 0; } }
.px-paper .spr { transform-box: fill-box; transform-origin: 50% 100%; animation: flutter 2.4s steps(1) infinite; }
@keyframes flutter { 0%, 100% { transform: none; } 50% { transform: skewX(-4deg); } }
.px-calendar .spr { animation: bob 2.2s steps(1) infinite; }

.foe.enter .foe-inner { animation: foe-in 420ms steps(7) both; }
@keyframes foe-in { from { transform: translateX(120%); } to { transform: none; } }
.foe.hit .foe-inner { animation: hit 560ms steps(1) both; }
@keyframes hit {
  0%, 25%, 50%, 75% { opacity: 0; transform: translateX(-4%); }
  12%, 37%, 62%, 87%, 100% { opacity: 1; transform: translateX(4%); }
}
.foe.shrug .foe-inner { animation: shrug 360ms steps(3); }
@keyframes shrug { 0%, 100% { transform: none; } 50% { transform: translateY(-8%); } }
.foe.faint .foe-inner { animation: faint 480ms steps(6) both; }
.foe.gone .foe-inner { opacity: 0; }
@keyframes faint { from { transform: none; clip-path: inset(0 0 0 0); } to { transform: translateY(60%); clip-path: inset(0 0 100% 0); } }
.ally.out .ally-inner { animation: ally-out 260ms steps(4) both; }
.ally.in .ally-inner { animation: ally-in 300ms steps(5) both; }
@keyframes ally-out { to { transform: translateX(-160%); } }
@keyframes ally-in { from { transform: translateX(-160%); } to { transform: none; } }
.ally.lunge .ally-inner { animation: lunge 300ms steps(3); }
@keyframes lunge { 0%, 100% { transform: none; } 40% { transform: translate(14%, -8%); } }
.ally.flinch .ally-inner { animation: shrug 300ms steps(3); }

.burst { position: absolute; left: 50%; top: 40%; width: 60%; translate: -50% -50%; opacity: 0; pointer-events: none; }
.burst.pop { animation: burst 420ms steps(1); }
@keyframes burst { 0% { opacity: 1; transform: scale(0.6); } 33% { opacity: 1; transform: scale(1); } 66% { opacity: 1; transform: scale(1.3); } 100% { opacity: 0; } }

.hpbox { position: absolute; display: grid; gap: 0.5em; padding: 0.9em 1.1em; font-size: clamp(8px, 1.45cqw, 14px); }
.hp-foe { left: 4%; top: 6%; min-width: 34%; }
.hp-ally { right: 4%; bottom: 6%; min-width: 34%; }
.hp-name { font-family: var(--display); font-size: 1em; letter-spacing: 0.04em; line-height: 1.2; }
.hp-row { display: flex; align-items: center; gap: 0.8em; }
.hp-tag {
  font-family: var(--display); font-size: 0.75em; color: var(--gold); background: var(--ink);
  padding: 0.35em 0.45em 0.25em;
}
.hp-val { font-family: var(--display); font-size: 1em; }
.bar { flex: 1; height: 0.75em; min-height: 6px; background: #4a4458; box-shadow: 0 0 0 2px var(--ink); }
.bar i { display: block; height: 100%; width: 100%; background: var(--hp); transform-origin: left; transform: scaleX(var(--hp-v, 1)); }
.bar i.mid { background: var(--hp-mid); }
.bar i.low { background: var(--hp-low); }

.console { display: grid; grid-template-columns: 1fr minmax(300px, 380px); gap: 0; background: var(--panel); }
.log { padding: 16px 22px; cursor: pointer; }
.log .say { font-size: 22px; }
.cmd { padding: 10px; display: grid; align-content: center; }
.cmd-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.move {
  position: relative; display: grid; gap: 4px; align-content: center;
  min-height: 64px; padding: 8px 8px 8px 26px;
  text-align: left; background: transparent; border: 0; cursor: pointer;
  color: var(--on-paper);
  -webkit-tap-highlight-color: transparent;
}
.move::before { left: 8px; }
.move span { font-family: var(--display); font-size: 11px; line-height: 1.4; letter-spacing: 0.02em; }
.move small { font-size: 15px; line-height: 1.2; color: var(--on-paper-dim); }
.move:focus-visible::before { opacity: 1; animation: cursor 1s steps(1) infinite; }
@media (hover: hover) and (pointer: fine) {
  .move:hover::before { opacity: 1; animation: cursor 1s steps(1) infinite; }
  .move:hover { background: var(--paper-2); }
}
.move:active { background: var(--paper-2); }
.cmd-moves[aria-busy="true"] .move { color: var(--on-paper-dim); cursor: progress; }
.cmd-moves[aria-busy="true"] .move::before { opacity: 0 !important; }
.cmd-next, .cmd-win { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 12px; }
.cmd-next[hidden], .cmd-win[hidden], .cmd-moves[hidden] { display: none; }

/* ---------- quest map ---------- */
.quest-section { background: var(--night); }
.map { padding: 0; }
.map-view { position: relative; aspect-ratio: 1584 / 672; overflow: hidden; container-type: inline-size; background: #3a9a3a; }
.map-bg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.clouds { position: absolute; inset: 0; pointer-events: none; }
.cloud-track { position: absolute; inset: 0; animation: drift var(--dur) linear var(--d) infinite; }
.cloud { position: absolute; left: 0; top: var(--y); width: var(--w); translate: -100% 0; }
.cloud .px { position: relative; opacity: 0.92; }
.cloud .cloud-shadow { position: absolute; left: 18%; top: 90%; opacity: 0.18; filter: brightness(0); }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(118%); } }

.pin {
  position: absolute; left: var(--x); top: var(--y);
  width: 4.2cqw; min-width: 26px; translate: -50% -100%;
  padding: 0; background: none; border: 0; cursor: pointer;
}
.pin .spr { animation: bob 1.2s steps(1) infinite; }
.pin:nth-of-type(2) .spr { animation-delay: -0.4s; }
.pin:nth-of-type(3) .spr { animation-delay: -0.8s; }
.pin b {
  position: absolute; left: 0; right: 0; top: 18%;
  font-family: var(--display); font-weight: 400; font-size: max(9px, 1.4cqw); line-height: 1; color: var(--ink);
  text-align: center;
}
.pin.is-on { --pin: var(--ember); }
.pin.is-on b { color: var(--paper); }
.walker-track { position: absolute; inset: 0; pointer-events: none; translate: 46.5% 58%; }
.walker { position: absolute; left: 0; top: 0; width: 4.6cqw; min-width: 28px; translate: -50% -96%; }
.walker.walking .spr { animation-duration: 0.22s; }

.steps { margin: 24px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step {
  position: relative; display: grid; gap: 10px; align-content: start;
  width: 100%; height: 100%; padding: 22px 22px 24px;
  text-align: left; cursor: pointer;
  background: var(--panel); border: 0; color: var(--text);
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink);
  transition: background-color 120ms ease-out;
  -webkit-tap-highlight-color: transparent;
}
.step-no { font-family: var(--display); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.step-title { font-family: var(--display); font-size: 15px; line-height: 1.4; }
.step-text { font-size: 19px; line-height: 1.55; color: var(--text-dim); text-wrap: pretty; }
.step[aria-pressed="true"] { background: var(--paper); color: var(--on-paper); }
.step[aria-pressed="true"] .step-no { color: var(--ember-ink); }
.step[aria-pressed="true"] .step-text { color: var(--on-paper-dim); }
.step[aria-pressed="true"]:focus-visible { --focus: var(--gold); }
@media (hover: hover) and (pointer: fine) {
  .step:hover:not([aria-pressed="true"]) { background: #33297a; }
}
.step:active { transform: translateY(2px); }

/* ---------- finale ---------- */
.finale { background: var(--night); text-align: center; overflow: hidden; isolation: isolate; }
.finale .sky { inset: 0; z-index: -1; }
.finale-wrap { max-width: 920px; display: flex; flex-direction: column; align-items: center; }
.finale h2 { margin-bottom: 40px; }
.lineup { display: flex; justify-content: center; gap: clamp(12px, 3vw, 36px); margin-bottom: 0; padding: 0 0 18px; position: relative; }
.lineup::after {
  content: ""; position: absolute; left: -40px; right: -40px; bottom: 0; height: 18px;
  background: repeating-linear-gradient(90deg, #3c8f4a 0 12px, #2f7a3e 12px 24px);
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink);
}
.lineup-bot { width: clamp(48px, 8vw, 84px); position: relative; z-index: 1; margin-bottom: -2px; }
.lineup-bot .spr { animation-delay: calc(var(--i) * -0.22s); }
.lineup-bot .blink { animation-delay: calc(var(--i) * -0.9s); }
.finale-ui { width: 100%; margin-top: 32px; display: grid; grid-template-columns: 1fr minmax(240px, 280px); gap: 16px; text-align: left; }
.finale .dialog { padding-top: 22px; }
.finale .nameplate { left: 20px; }

/* ---------- footer ---------- */
.foot { position: relative; background: var(--deep); padding: 56px 20px calc(32px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 0 0 var(--ink); }
.foot-patrol { position: absolute; left: 0; right: 0; top: -40px; height: 40px; pointer-events: none; overflow: hidden; }
.patrol-bot {
  position: absolute; bottom: 0; left: 0; width: 32px; pointer-events: auto; cursor: pointer;
  animation: patrol 26s steps(130) infinite;
}
.patrol-bot .spr { animation-duration: 0.3s; }
.patrol-bot.beep .px { animation: hop 320ms steps(4); }
@keyframes patrol {
  0% { transform: translateX(-40px); }
  49.9% { transform: translateX(calc(100vw - 8px)) scaleX(1); }
  50% { transform: translateX(calc(100vw - 8px)) scaleX(-1); }
  99.9% { transform: translateX(-40px) scaleX(-1); }
  100% { transform: translateX(-40px) scaleX(1); }
}
.foot-inner { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; font-size: 17px; color: var(--text-dim); }
.foot-brand { font-family: var(--display); font-size: 11px; color: var(--text); text-decoration: none; }
.foot-tag { margin-right: auto; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.foot-links a {
  font-family: var(--display); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text); text-decoration: none; padding: 14px 10px;
  transition: color 120ms ease-out;
}
@media (hover: hover) and (pointer: fine) { .foot-links a:hover { color: var(--gold); } }
.foot-links a[aria-current="page"] { color: var(--gold); }
.foot-copy { font-size: 15px; }

/* ---------- legal pages ---------- */
.doc-hero { position: relative; isolation: isolate; overflow: hidden; background: var(--night); padding: clamp(56px, 8vw, 96px) 20px 0; }
.doc-hero .sky { inset: 0; z-index: -1; }
.doc-hero-inner { max-width: 960px; }
.doc-title {
  margin: 0; font-family: var(--display); font-weight: 400;
  font-size: clamp(28px, 5vw, 56px); line-height: 1.2; color: var(--paper);
  text-shadow: 0.06em 0.06em 0 var(--ember), 0.12em 0.12em 0 var(--ink);
  text-wrap: balance;
}
.doc-meta { margin: 18px 0 0; font-size: 18px; color: var(--text-dim); }
.doc-tldr { position: relative; display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: end; margin-top: 44px; padding-bottom: 28px; }
.doc-speaker { width: 104px; justify-self: center; margin-bottom: -4px; }
.doc-tldr .dialog { padding: 22px 26px; }
.doc-tldr .nameplate { left: 22px; }
.doc-tldr .say { min-height: 0; font-size: 21px; }
.doc-ground {
  height: 24px; margin: 0 -20px;
  background: repeating-linear-gradient(90deg, #3c8f4a 0 12px, #2f7a3e 12px 24px);
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink);
}
.doc-body { padding: clamp(56px, 7vw, 88px) 20px clamp(96px, 10vw, 140px); background: var(--base); }
.doc-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; align-items: start; max-width: 1120px; }
.doc-toc { position: sticky; top: calc(var(--header) + 24px); padding: 14px 6px; }
.toc-label { margin: 0 0 8px 12px; font-family: var(--display); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.doc-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.doc-toc .menu-item { color: var(--text); font-size: 10px; min-height: 40px; gap: 10px; }
.toc-no { color: var(--text-dim); }
.doc-toc .menu-item.is-here { color: var(--gold); }
.doc-toc .menu-item.is-here::before { opacity: 1; }
.doc { position: relative; padding: clamp(24px, 4vw, 48px); }
.doc-peek { position: absolute; right: 36px; top: -80px; width: 56px; }
.doc-peek .px { transform: translateY(8px); }
.doc-sec { padding: 28px 0; border-top: 2px dashed rgba(20, 18, 28, 0.16); scroll-margin-top: calc(var(--header) + 24px); }
.doc-sec:first-of-type { border-top: 0; padding-top: 0; }
.doc h2 {
  display: flex; align-items: baseline; gap: 14px;
  margin: 0 0 16px; font-size: clamp(15px, 1.8vw, 19px); line-height: 1.5;
  color: var(--on-paper); text-shadow: none;
}
.sec-no {
  flex: none; font-size: 0.7em; color: var(--paper); background: var(--ember-ink);
  padding: 6px 7px 5px; box-shadow: 0 0 0 3px var(--ink);
}
.doc p, .doc li { font-size: 20px; line-height: 1.65; max-width: 64ch; text-wrap: pretty; }
.doc p { margin: 0 0 1.65em; }
.doc p:last-child { margin-bottom: 0; }
.doc ul { margin: 0 0 1.65em; padding: 0; list-style: none; display: grid; gap: 12px; }
.doc li { position: relative; padding-left: 28px; }
.doc li::before {
  content: ""; position: absolute; left: 4px; top: 0.55em; width: 8px; height: 8px;
  background: var(--ember-ink); box-shadow: 2px 2px 0 0 var(--ink);
}
.doc strong { font-weight: 400; background: linear-gradient(transparent 60%, rgba(255, 204, 51, 0.55) 60%); }
.doc a { color: var(--ember-ink); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.doc-sign { margin-top: 12px; padding-top: 28px; border-top: 4px solid var(--ink); display: grid; gap: 18px; }
.doc-sign-bots { display: flex; gap: 12px; }
.mini-bot { width: 36px; cursor: pointer; }
.mini-bot .spr { animation-delay: calc(var(--i) * -0.22s); }
.doc-sign p { margin: 0; }

/* ---------- 404 ---------- */
.lost { position: relative; isolation: isolate; overflow: hidden; background: var(--night); min-height: calc(100svh - var(--header)); padding: clamp(56px, 9vw, 112px) 20px; text-align: center; }
.lost .sky { inset: 0; z-index: -1; }
.lost-inner { max-width: 920px; display: flex; flex-direction: column; align-items: center; }
.lost-title { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(24px, 4.4vw, 48px); line-height: 1.3; color: var(--paper); text-shadow: 0.06em 0.06em 0 var(--ember), 0.12em 0.12em 0 var(--ink); text-wrap: balance; }
.lost-scene { position: relative; display: flex; align-items: end; justify-content: center; gap: clamp(48px, 12vw, 160px); margin: 48px 0 8px; height: 160px; width: 100%; }
.lost-bot { position: relative; width: 96px; }
.lost-bot .spr { animation: look 2.4s steps(1) infinite; }
@keyframes look { 0%, 45% { transform: translateX(0); } 50%, 95% { transform: translateX(1px); } }
.lost-q { position: absolute; top: -34px; right: -18px; font-family: var(--display); font-size: 28px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); animation: nudge 0.9s steps(1) infinite; }
.lost-ghost { width: 72px; align-self: start; opacity: 0.85; animation: flee 3.6s steps(12) infinite; }
@keyframes flee { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(24px, -12px); } }
.lost .finale-ui { margin-top: 24px; }

/* ---------- easter eggs ---------- */
.speaker, .lineup-bot, .lost-bot { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lineup-bot.hop .px, .speaker.hop .px, .mini-bot.hop .px, .lost-bot.hop .px { animation: hop 320ms steps(4); }
.zzz { position: absolute; right: -6px; top: -18px; font-family: var(--display); font-size: 14px; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); pointer-events: none; display: none; }
.sleepy .zzz { display: block; animation: zzz 2.4s steps(6) infinite; }
.sleepy .px-robot .blink { opacity: 1; animation: none; }
.sleepy .px-robot .spr { animation-duration: 2.4s; }
@keyframes zzz { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(14px, -28px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 95;
  width: min(560px, calc(100vw - 32px)); translate: -50% 0;
  padding: 18px 22px 20px;
  animation: toast-in 280ms steps(5) both;
}
.toast.out { animation: toast-out 180ms steps(3) both; }
.toast .nameplate { left: 18px; }
.toast p { margin: 0; font-size: 20px; line-height: 1.5; color: var(--on-paper); }
@keyframes toast-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(12px); opacity: 0; } }

.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; left: var(--x);
  width: var(--s); height: var(--s); background: var(--c);
  box-shadow: 2px 2px 0 0 rgba(20, 18, 28, 0.5);
  animation: fall var(--t) steps(var(--n)) var(--d) both;
}
@keyframes fall { to { transform: translate(var(--dx), 108vh); } }
html.party-mode .px-robot .spr { animation: dance 0.36s steps(1) infinite !important; }
@keyframes dance { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-1px, -2px); } 50% { transform: translate(0, 0); } 75% { transform: translate(1px, -2px); } }
html.party-mode .px-robot .eye, html.party-mode .px-robot .mouth { animation: rainbow 0.6s steps(1) infinite; }
@keyframes rainbow { 0% { fill: #ff6b6b; } 25% { fill: #ffd35a; } 50% { fill: #6ee08e; } 75% { fill: #86b4ff; } }
html.party-mode .wm-8 { animation: rainbow-text 0.5s steps(1) infinite; }
@keyframes rainbow-text { 0% { color: #ff6b6b; } 25% { color: #ffd35a; } 50% { color: #6ee08e; } 75% { color: #86b4ff; } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .party { grid-template-columns: 1fr; }
  .party-list { grid-template-columns: repeat(5, 1fr); padding: 8px; }
  .tab { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 12px 6px 14px; gap: 8px; }
  .tab::before { display: none; }
  .tab .chip, .tab-role { display: none; }
  .tab-name { font-size: 10px; }
  .console { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .doc-grid { grid-template-columns: 1fr; }
  .doc-toc { position: static; }
  .doc-tldr { grid-template-columns: 1fr; }
  .doc-speaker { justify-self: start; margin-left: 20px; width: 80px; margin-bottom: 8px; }
  .nav { display: none; }
  .hero-ui { grid-template-columns: 1fr; }
  .say { font-size: 21px; }
  .panel { grid-template-columns: 1fr; }
  .stage { min-height: 240px; }
  .steps { grid-template-columns: 1fr; }
  .finale-ui { grid-template-columns: 1fr; }
  .head-row { flex-direction: column; align-items: start; }
}
@media (max-width: 560px) {
  body { font-size: 18px; }
  .doc p, .doc li { font-size: 18px; }
  .doc-tldr .say { font-size: 19px; }
  .doc-peek { right: 20px; width: 44px; top: -64px; }
  .foot-tag { margin-right: 0; flex-basis: 100%; }
  .brand span { font-size: 10px; }
  .top-inner { gap: 4px; padding: 0 12px; }
  .lead { font-size: 19px; }
  .tab { padding: 10px 2px 12px; }
  .tab-sprite { width: 32px; }
  .tab-name { font-size: 8px; }
  .moves { grid-template-columns: 1fr; }
  .speaker { width: 64px; left: 16px; }
  .hero-ui { padding-top: 80px; }
  .nameplate { left: 96px; }
  .say { font-size: 19px; }
  .log .say { font-size: 19px; }
  .cmd-moves { grid-template-columns: 1fr 1fr; }
  .move span { font-size: 9px; }
  .move small { font-size: 13px; }
  .hpbox { font-size: 8px; padding: 0.6em 0.8em; border-width: 6px; border-image-width: 6px; }
}
@media (max-width: 359px) {
  .brand span { display: none; }
}

/* ---------- reduced motion: freeze everything ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .px-robot .blink, .px-robot .talk { opacity: 0 !important; }
  .confetti { display: none; }
  .patrol-bot { left: 24px; }
}
