/* style.css — DOM overlay styling. Colors come from theme.json (injected as --c-* by main.js);
   fallbacks below mirror theme.json v0 so the no-JS page still looks intentional. */
:root {
  --c-ink: #0b0b0b; --c-paper: #fffdf5; --c-accent: #f9c74f; --c-danger: #e63946; --c-skyHigh: #14205a; --c-skyLow: #9ad7ee;
  --c-hudText: #ffffff; --c-hudShadow: #000000; --c-coin: #f9c74f; --c-ground: #4caf50;
  --beat-top-offset: -10vh; /* beat panel vertical offset from the package hold line; mobile puts beats BELOW the package */
  --font-pixel: 'Press Start 2P', monospace; --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-body); color: var(--c-ink); background: var(--c-skyHigh); line-height: 1.5; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--font-pixel); line-height: 1.5; margin: 0 0 .6em; font-weight: 400; }

/* canvas = decoration, fixed behind everything */
#scene { position: fixed; top: 0; left: 0; z-index: 0; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
main { position: relative; z-index: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0 0 auto 0; z-index: 5; pointer-events: none; background: linear-gradient(rgba(0,0,0,.42), rgba(0,0,0,0)); font-family: var(--font-pixel); color: var(--c-hudText); text-shadow: 2px 2px 0 var(--c-hudShadow); font-size: clamp(10px, 1.4vw, 14px); padding: 14px 16px 30px; display: flex; justify-content: space-between; align-items: flex-start; }
.hud-left { letter-spacing: 1px; } .hud-k { opacity: .85; }
.hud-right { display: flex; gap: 18px; align-items: center; }
.hud-btn { pointer-events: auto; font: inherit; color: inherit; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.6); padding: 4px 8px; text-shadow: none; cursor: not-allowed; opacity: .7; }
.hud-hint { position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%); animation: blink 1.1s steps(2, end) infinite; font-size: clamp(10px, 1.6vw, 14px); transition: opacity .4s; }
.hud-hint.hidden { opacity: 0; animation: none; }
.hud-banner { position: fixed; left: 50%; top: 18vh; transform: translateX(-50%) scale(.9); font-size: clamp(14px, 3.2vw, 34px); color: var(--c-accent); opacity: 0; transition: opacity .3s, transform .3s; white-space: nowrap; text-shadow: 3px 3px 0 var(--c-hudShadow); }
.hud-banner.show { opacity: 1; transform: translateX(-50%) scale(1); }
#hud.panel-in-view .hud-banner, #hud.panel-in-view .hud-hint { opacity: 0 !important; animation: none; }
.hud-banner.flash { animation: flash 1s steps(2, end) 4; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes flash { 50% { opacity: .15; } }

/* score popups */
.popup { position: fixed; z-index: 6; pointer-events: none; font-family: var(--font-pixel); color: var(--c-coin); text-shadow: 2px 2px 0 var(--c-hudShadow); font-size: clamp(10px, 1.5vw, 14px); transform: translate(-50%, -50%); animation: pop .9s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -40%) } 15% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%, -160%) } }

/* ---------- track + hero ---------- */
#track { position: relative; }
.hero { position: absolute; top: 0; left: 0; right: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 12vh 6vw; max-width: min(760px, 46vw); }
.hero-brand { font-family: var(--font-pixel); color: var(--c-accent); font-size: clamp(10px, 1.4vw, 13px); letter-spacing: 2px; text-shadow: 2px 2px 0 var(--c-hudShadow); margin: 0 0 1.2em; }
.hero h1 { color: #fff; font-size: clamp(18px, 3.4vw, 34px); text-shadow: 3px 3px 0 var(--c-hudShadow); max-width: 14em; }
.hero-copy { color: #fff; font-size: clamp(18px, 1.6vw, 21px); max-width: 34em; text-shadow: 1px 1px 0 rgba(0,0,0,.6); background: rgba(11,11,11,.28); padding: .6em .8em; border-left: 4px solid var(--c-accent); }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 1.2em; }

/* ---------- beats (real HTML, pinned beside the action) ---------- */
.beat { position: absolute; width: min(440px, 42vw); padding: 20px 22px 22px; background: rgba(255,253,245,.94); border: 3px solid var(--c-ink); box-shadow: 6px 6px 0 var(--c-ink); opacity: 0; transform: translateY(14px); transition: opacity .45s ease, transform .45s ease; }
.beat.side-left { left: 6vw; } .beat.side-right { right: 6vw; }
.beat.active { opacity: 1; transform: translateY(0); }
.beat-label { font-family: var(--font-pixel); font-size: clamp(9px, 1.1vw, 11px); color: var(--c-danger); margin: 0 0 1.2em; letter-spacing: 1px; }
.beat h2 { font-size: clamp(12px, 1.6vw, 16px); }
.beat-copy { font-size: 18px; margin: 0; }

/* ---------- stall variant: sticky centered beats + typewriter ---------- */
.beat-hold-track { position: absolute; left: 0; right: 0; pointer-events: none; }
.beat-hold-track .beat { position: -webkit-sticky; position: sticky; width: min(520px, 88vw); margin: 0 auto; transform: translateY(10px); pointer-events: auto; }
.beat-hold-track .beat.active { transform: translateY(0); }
.ch { display: inline; }
.ch-hid { visibility: hidden; }

/* ---------- landing / form / leaderboard ---------- */
#landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 8vh 5vw; }
@media (min-width: 1000px) { #landing { justify-content: flex-end; padding-right: 6vw; } }
.panel { width: min(540px, 92vw); background: var(--c-paper); border: 4px solid var(--c-ink); box-shadow: 10px 10px 0 var(--c-ink); padding: 28px clamp(18px, 4vw, 36px) 30px; }
#landing.landed .panel { animation: floatin .7s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes floatin { from { opacity: 0; transform: translateY(40px) } to { opacity: 1; transform: none } }
.land-kicker { font-family: var(--font-pixel); color: var(--c-ground); font-size: 12px; margin: 0 0 .8em; }
.land-banner { font-family: var(--font-pixel); color: var(--c-danger); font-size: clamp(16px, 3vw, 26px); margin: 0 0 .4em; }
.land-score { font-family: var(--font-pixel); font-size: 14px; margin: 0 0 1.6em; }
.land-title { font-size: clamp(13px, 2vw, 18px); }
.land-intro { font-size: 18px; margin: 0 0 1.2em; }
.initials-row { display: flex; gap: 12px; margin-bottom: 1.2em; }
.initial { width: 58px; height: 62px; text-align: center; font-family: var(--font-pixel); font-size: 24px; border: 3px solid var(--c-ink); background: #fff; text-transform: uppercase; }
.initial:focus, #score-form input:focus, #score-form select:focus { outline: 3px solid var(--c-accent); outline-offset: 1px; }
#score-form label { display: block; font-size: 16px; font-weight: 600; margin: 0 0 .9em; }
#score-form input:not(.initial), #score-form select { display: block; width: 100%; font: 16px var(--font-body); padding: 10px 12px; border: 3px solid var(--c-ink); background: #fff; margin-top: 4px; min-height: 44px; }
.btn-arcade, .btn-ghost { display: inline-block; font-family: var(--font-pixel); font-size: 12px; padding: 14px 18px; border: 3px solid var(--c-ink); text-decoration: none; cursor: pointer; min-height: 44px; line-height: 1.2; }
.btn-arcade { background: var(--c-accent); color: var(--c-ink); box-shadow: 4px 4px 0 var(--c-ink); transition: transform .08s, box-shadow .08s; }
.btn-arcade:hover, .btn-arcade:focus { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--c-ink); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: #fff; }
.land-reassure { font-size: 15px; opacity: .8; margin: 1em 0 0; }
.form-error { color: var(--c-danger); font-weight: 600; }
.leaderboard { list-style: none; margin: 0 0 1.2em; padding: 0; font-family: var(--font-pixel); font-size: clamp(10px, 1.5vw, 14px); }
.leaderboard li { display: grid; grid-template-columns: 2.2em 4em 1fr auto; gap: 14px; padding: 8px 6px; border-bottom: 2px dashed rgba(11,11,11,.25); white-space: pre; }
.leaderboard li.you { background: var(--c-accent); animation: youpulse 1.2s steps(2, end) 3; }
@keyframes youpulse { 50% { background: var(--c-paper); } }
.leaderboard .pts { text-align: right; } .leaderboard .tag { color: var(--c-danger); }
.confirm-line { font-size: 18px; font-weight: 600; }
.site-foot { padding: 20px 5vw 40px; color: #fff; font-size: 14px; opacity: .8; text-align: center; }

/* ---------- reduced motion: stepped scenes, everything readable ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .beat, .hud-banner, .hud-hint, .popup, #landing.landed .panel, .leaderboard li.you, .btn-arcade { transition: none; animation: none; }
  .beat { opacity: 1; transform: none; }
}

/* ---------- no-JS / crawler: clean stacked page ---------- */
html.no-js #scene, html.no-js #hud { display: none; }
html.no-js body { background: var(--c-skyHigh); }
html.no-js #track { height: auto !important; padding: 4vh 0; }
html.no-js .hero { position: static; min-height: 0; }
html.no-js .beat { position: static; opacity: 1; transform: none; width: min(640px, 90vw); margin: 24px auto; }
html.boot-failed #scene, html.boot-failed #hud { display: none; }
html.boot-failed .beat { opacity: 1; transform: none; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  :root { --beat-top-offset: 9vh; }
  .hero { max-width: none; justify-content: flex-end; padding-bottom: 7vh; }
  .hero .hero-brand { margin-bottom: .8em; }
  .hero h1.hero-h1, .hero h1 { font-size: 16px !important; max-width: none; }
  .hero .hero-copy { font-size: 16px; padding: .5em .7em; }
  .hero-ctas { gap: 10px; }
  #hud { font-size: 10px; }
  .beat { width: 86vw; left: 7vw !important; right: auto !important; padding: 16px; }
  .beat-copy { font-size: 17px; }
  .hero { padding: 14vh 7vw; }
  .hud-right { gap: 10px; }
}
