/* Stages: tall wrapper + sticky pin. No ScrollTrigger pin, so no layout swap and no CLS. */
.top { position: fixed; inset: 0 0 auto 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px; background: linear-gradient(var(--body) 40%, transparent); pointer-events: none; }
.top .px { --cell: 2px; color: var(--lcd-neon); }
.top { flex-wrap: wrap; row-gap: 6px; }
.top__state { --cell: 2px; color: var(--text-dim); position: relative; pointer-events: auto; }
.top__state::after { content: ""; position: absolute; inset: -15px -8px; }   /* 44 px tap target, look unchanged */
.top__legal { flex: 0 0 100%; margin: 0; font: 400 10px/1.2 var(--font-fallback); letter-spacing: .01em; color: var(--text-dim); text-shadow: 0 0 4px var(--body), 0 0 2px var(--body); }

.stage { position: relative; height: 230svh; }
.stage--end { height: auto; }
.stage__pin { position: sticky; top: 0; height: 100svh; display: grid; align-content: center; justify-items: center;
  gap: 18px; padding: 64px var(--gutter) calc(var(--dock-h) + 12px + env(safe-area-inset-bottom)); }

.panel { position: relative; width: 100%; max-width: 520px; padding: 20px 18px 22px; border-radius: 18px; color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(rgba(23,34,14,.17) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,34,14,.17) 1px, transparent 1px),
    radial-gradient(120% 90% at 30% 0%, #a9bd88 0%, var(--paper) 55%, #8aa06a 100%);
  background-size: 4px 4px, 4px 4px, auto;
  box-shadow: inset 0 0 0 2px #0b0e0a, inset 0 0 38px rgba(23,34,14,.45), 0 0 0 10px var(--body-3), 0 0 0 11px var(--line), 0 24px 60px rgba(0,0,0,.6);
  display: grid; gap: 14px; }
.panel .px { color: var(--ink); }
.panel__scan { position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(transparent 0, rgba(23,34,14,.14) 50%, transparent 100%); background-size: 100% 80px; background-repeat: no-repeat;
  animation: scan 5.5s linear infinite; }
@keyframes scan { from { background-position: 0 -80px; } to { background-position: 0 calc(100% + 80px); } }
@media (prefers-reduced-motion: reduce) { .panel__scan { animation: none; display: none; } }

.panel__bar { display: flex; justify-content: space-between; gap: 8px; --cell: 2px; opacity: .8; }
.panel h1 .px, .panel h2 .px, .px--head { --cell: 5px; }
.px--body { --cell: 3px; }
@media (min-width: 700px) { .px--head { --cell: 6px; } .px--body { --cell: 3px; } .panel { padding: 28px 30px 30px; } }

.note { margin: 0; max-width: 520px; width: 100%; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.key { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap); padding: 0 22px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--body-2); color: var(--lcd-neon); text-decoration: none; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.key--power { color: #fff; background: var(--red); border-color: var(--red); }
.key:hover { background: var(--body-3); }
.key--power:hover { background: #ff5252; }

/* Thumb-zone dock: six numbered keys in the bottom third. */
.dock { position: fixed; z-index: 6; inset: auto 0 0 0; display: flex; justify-content: center; gap: 8px;
  padding: 10px var(--gutter) max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--body) 38%); }
.dock a { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: 999px;
  border: 1px solid var(--line); background: var(--body-2); color: var(--text-dim); text-decoration: none; font-weight: 700; font-size: 15px; }
.dock a[aria-current] { color: var(--body); background: var(--lcd-neon); border-color: var(--lcd-neon); }
.dock a:hover { color: var(--lcd-neon); }
.dock a[aria-current]:hover { color: var(--body); }
@media (min-width: 700px) { .dock { inset: 0 0 0 auto; flex-direction: column; justify-content: center; padding: 0 var(--gutter); background: none; } }

/* ---- M3: live handset (stages 3 and 4) ---- */
:root { --pad-h: 0px; --gl-top: 156px; }
html[data-mode='boot'], html[data-mode='brick'], html[data-mode='drop'], html[data-mode='snake'] { --pad-h: 60px; }
html[data-mode='type'] { --pad-h: 116px; }

.stage__pin--hand { align-content: start; padding-top: 64px; }
.stage__top { width: 100%; max-width: 520px; display: grid; gap: 10px; }
.stage__top .px { color: var(--lcd-neon); --cell: 4px; }

.gl { position: fixed; z-index: 3; left: 0; right: 0; top: var(--gl-top); bottom: calc(var(--dock-h) + var(--pad-h) + 8px);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility 0s .25s; }
html[data-mode='boot'] .gl, html[data-mode='brick'] .gl, html[data-mode='snake'] .gl, html[data-mode='type'] .gl, html[data-mode='drop'] .gl { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .25s ease; }
@media (prefers-reduced-motion: reduce) { .gl, html[data-mode] .gl { transition: none; } }
/* The drop starts above the frame: fade the top edge so the phone falls out of the dark, not out of a cut line. */
html[data-mode='drop'] .gl { -webkit-mask-image: linear-gradient(transparent 0, #000 16%); mask-image: linear-gradient(transparent 0, #000 16%); }
.gl__shadow { position: absolute; left: 0; top: 0; width: 100px; height: 16px; border-radius: 50%; pointer-events: none; opacity: 0; will-change: transform, opacity;
  background: radial-gradient(closest-side, rgba(0,0,0,.85), rgba(0,0,0,0)); transform-origin: 50% 50%; }
.no-gl .gl__shadow { display: none; }
.gl__canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.no-gl .gl__canvas { display: none; }
.no-gl [data-turn] { display: none; }
.lcd2d { display: none; position: absolute; inset: 0; align-items: flex-start; justify-content: center; padding: 0 var(--gutter); }
.no-gl .lcd2d { display: flex; }
.lcd2d__canvas { display: block; width: 100%; max-width: 420px; height: auto; image-rendering: pixelated; border-radius: 14px; box-shadow: 0 0 0 8px var(--body-3), 0 0 0 9px var(--line); }

/* Swipe surface over the LCD, only in Snake. It alone blocks page scroll, so the rest of the stage still scrolls. */
.hit { position: fixed; z-index: 4; pointer-events: none; touch-action: none; }
html[data-mode='snake'] .hit { pointer-events: auto; }

/* Thumb-zone pads sit right above the stage dock. */
.pad { position: fixed; z-index: 6; left: 0; right: 0; bottom: var(--dock-h); display: none; justify-content: center; gap: 8px; padding: 0 var(--gutter) 8px; flex-wrap: wrap; }
html[data-mode='boot'] .pad--boot, html[data-mode='brick'] .pad--brick, html[data-mode='drop'] .pad--drop, html[data-mode='snake'] .pad--snake, html[data-mode='type'] .pad--type { display: flex; }
.pad--type { max-width: 320px; margin: 0 auto; }
.pad button { position: relative; width: var(--tap); height: var(--tap); border-radius: 999px; border: 1px solid var(--line); background: var(--body-2); color: var(--lcd-neon);
  font: 700 16px/1 var(--font-fallback); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
.pad--snake button { width: 64px; }
.pad button small { position: absolute; bottom: 5px; left: 0; right: 0; text-align: center; font-size: 8px; color: var(--text-dim); letter-spacing: .04em; }
.pad button:active { background: var(--lcd-neon); color: var(--body); transform: translateY(1px); }
.pad button:active small { color: var(--body); }
.pad--snake button { flex-direction: column; padding-bottom: 8px; }
@media (min-width: 700px) {
  :root { --gl-top: 130px; }
  .pad { bottom: 22px; }
  html[data-mode='boot'], html[data-mode='brick'], html[data-mode='drop'], html[data-mode='snake'] { --pad-h: 40px; }
  html[data-mode='type'] { --pad-h: 60px; }
  .pad--type { max-width: none; flex-wrap: nowrap; }
  .gl { bottom: calc(var(--pad-h) + 34px); }
}

/* ---- M4: story stages, hold key, brick pad, reveal, footer scene, credits ---- */
@media (max-width: 379px) { .stage__top .px { --cell: 3px; } }

.reveal-ready .reveal { opacity: 0; transform: translateY(18px); transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
.reveal-ready .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal-ready .reveal { opacity: 1; transform: none; transition: none; } }

.pad--brick { gap: 6px; flex-wrap: nowrap; }
.pad--brick button { flex: 1 1 0; min-width: 44px; max-width: 58px; width: auto; font-size: 10px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.pad--brick button[data-turn] { font-size: 18px; }
.pad--boot, .pad--drop { padding-bottom: 8px; }

/* The red key: hold to charge, or tap and it charges itself. Fill is a transform, so nothing relayouts. */
.hold { position: relative; overflow: hidden; min-height: var(--tap); min-width: 220px; padding: 0 26px; border-radius: 999px; border: 1px solid var(--red); background: #2a0f0f; color: #fff;
  font: 700 13px/1 var(--font-fallback); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.hold__fill { position: absolute; inset: 0; background: var(--red); transform: scaleX(0); transform-origin: 0 50%; }
.hold__label { position: relative; }
.hold.is-on { background: var(--lcd-neon); border-color: var(--lcd-neon); color: var(--body); }
.hold--plain { border-color: var(--line); background: var(--body-2); color: var(--lcd-neon); }
.hold--plain:active { background: var(--lcd-neon); color: var(--body); }
.hold:focus-visible { outline-offset: 4px; }

/* Stage 6: one scene. ASCII phone fills the width and fades into the ground, the footer sits inside it. */
.scene { position: relative; min-height: 100svh; padding: 76px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.scene__copy { display: grid; gap: 10px; padding: 0 var(--gutter); max-width: 560px; width: 100%; margin: 0 auto; }
.scene__copy .px { color: var(--lcd-neon); --cell: 4px; }
.ascii { margin: 0; flex: 1 0 auto; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; width: 100%; padding-bottom: calc(var(--dock-h) + 130px);
  font: 400 calc(100vw / 32) / 1.04 var(--font-fallback); color: var(--lcd-neon); white-space: pre; text-align: center; letter-spacing: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 98%); mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 98%); }
.ascii .l { display: block; min-height: 1em; opacity: 0; transform: translateY(8px); transition: opacity .45s ease, transform .45s ease; transition-delay: calc(var(--i, 0) * 22ms); text-shadow: 0 0 6px rgba(0,255,65,.35); }
.ascii.is-in .l, .ascii:not(.is-wrapped) .l { opacity: 1; transform: none; }
.ascii .cur { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ascii .l { opacity: 1; transform: none; transition: none; } .ascii .cur { animation: none; } }
@media (min-width: 700px) { .ascii { font-size: min(calc(100vw / 60), 15px); } }

.foot { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; margin: 0; display: grid; justify-items: center; gap: 14px; text-align: center;
  padding: 36px var(--gutter) calc(var(--dock-h) + 18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(8,10,8,.82) 40%, var(--body) 100%); }
.foot__legal { margin: 0; color: var(--text); font-size: 13px; line-height: 1.5; max-width: 34ch; padding: 6px 12px; border-radius: 12px; background: rgba(8,10,8,.78); }
.foot__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.foot .key { cursor: pointer; font-family: var(--font-fallback); }
@media (min-width: 700px) { .foot { padding-bottom: 28px; } .foot__legal { max-width: none; } }

.key--red { color: #fff; background: var(--red); border-color: var(--red); }
.credits { width: min(560px, calc(100vw - 24px)); max-height: calc(100svh - 24px); margin: auto; padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--body); color: var(--text); overflow: auto; }
.credits::backdrop { background: rgba(0,0,0,.86); }
.credits__frame { border-radius: 14px; padding: 12px; background: var(--paper); box-shadow: inset 0 0 0 2px #0b0e0a, inset 0 0 30px rgba(23,34,14,.45); color: var(--ink); }
.credits__lcd canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; border-radius: 6px; }
.credits__plain { display: none; }
.credits.is-list .credits__plain, html:not(.js) .credits .credits__plain { display: block; }
.credits.is-list .credits__lcd, html:not(.js) .credits .credits__lcd { display: none; }
.credits:not(.is-list) .credits__plain { display: block; position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
.credits__h { margin: 0 0 8px; font-size: 18px; letter-spacing: .1em; text-transform: uppercase; }
.credits__list { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 15px; line-height: 1.45; }
.credits__bar { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.credits__bar .key { cursor: pointer; font-family: var(--font-fallback); }
html:not(.js) .credits { display: block; position: static; width: auto; max-height: none; margin: 24px auto; }
html:not(.js) .credits__bar, html:not(.js) [data-credits] { display: none; }
.pad .hold { width: auto; height: auto; min-width: 240px; white-space: nowrap; color: #fff; border-color: var(--red); background: #2a0f0f; transform: none; }
.pad .hold.is-on { background: var(--lcd-neon); border-color: var(--lcd-neon); color: var(--body); }
.pad .hold--plain { color: var(--lcd-neon); border-color: var(--line); background: var(--body-2); }
.pad .hold:active { transform: none; }
.pad .hold:active { background: #2a0f0f; color: #fff; }
.pad .hold.is-on:active { background: var(--lcd-neon); color: var(--body); }
.pad .hold--plain:active { background: var(--lcd-neon); color: var(--body); }
.pad .hold { width: 240px; padding: 0; }
.pad .hold .hold__label { position: absolute; inset: 0; display: grid; place-items: center; }
