@font-face { font-family: 'Big Shoulders Display'; src: url('./assets/fonts/big-shoulders-display.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('./assets/fonts/ibm-plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('./assets/fonts/ibm-plex-mono-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('./assets/fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #04060a;
  --ink: #e9eef2;
  --muted: rgba(233, 238, 242, 0.62);
  --panel: rgba(9, 13, 20, 0.86);
  --panel-edge: rgba(255, 214, 150, 0.16);
  --amber: #ffb347;
  --cyan: #52e0ff;
  --band: var(--amber);
  --danger: #ff5a4a;
  --safe: #8dffb0;
  --tape: #ff7ab8;
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --body: 'Inter', system-ui, sans-serif;
  --hud-scale: 1;
  --fd-bg: #05070c;
  --fd-accent: #ffb347;
  --fd-accent-2: #52e0ff;
  --fd-text: #e9eef2;
  --fd-muted: rgba(233, 238, 242, 0.64);
  --fd-font: 'Inter', system-ui, sans-serif;
  --fd-title-font: 'Big Shoulders Display', sans-serif;
  --fd-focus: #ffd18a;
  --fd-glow-hue: 20deg;
}
html[data-band='cyan'] { --band: var(--cyan); }
html.large-hud { --hud-scale: 1.25; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--body); overflow: hidden; }
body { -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #ffd18a; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: #000; padding: 8px 12px; color: #fff; }
.skip-link:focus { left: 8px; }

.app { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; outline: none; }
#phaser-game, #phaser-game canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.app:not(.ready) .stage { opacity: 0; }

/* ---- HUD ------------------------------------------------------------------ */
.hud { position: absolute; inset: 0; pointer-events: none; font-size: calc(15px * var(--hud-scale)); }
.hud[hidden] { display: none; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(3, 5, 9, 0.88), rgba(3, 5, 9, 0.55) 70%, transparent);
}
.hud-floor { display: grid; gap: 1px; min-width: 0; }
.hud-floor span, .hud-meters span, .hud-band span { font: 600 0.68em var(--mono); letter-spacing: 0.14em; color: var(--muted); }
.hud-floor strong { font: 800 1.55em/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.hud-floor em { font: 500 0.86em var(--mono); color: var(--band); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-band { justify-self: center; text-align: center; display: grid; gap: 2px; padding: 6px 18px 8px; border: 1px solid color-mix(in srgb, var(--band) 45%, transparent); border-radius: 10px; background: rgba(5, 8, 14, 0.7); box-shadow: 0 0 22px color-mix(in srgb, var(--band) 22%, transparent), inset 0 0 18px color-mix(in srgb, var(--band) 10%, transparent); transition: border-color 0.25s, box-shadow 0.25s; }
.hud-band strong { font: 800 1.45em/1 var(--display); letter-spacing: 0.08em; color: var(--band); text-shadow: 0 0 12px color-mix(in srgb, var(--band) 60%, transparent); }
.hud-band .dial { position: relative; display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--amber), #3a4150 45% 55%, var(--cyan)); opacity: 0.8; }
.hud-band .dial b { position: absolute; top: -3px; width: 3px; height: 12px; background: #fff; left: 20%; box-shadow: 0 0 8px #fff; transition: left 0.3s cubic-bezier(.3,1.4,.5,1); }
.hud-band[data-band='cyan'] .dial b { left: 78%; }
.hud-meters { justify-self: end; display: flex; align-items: center; gap: 16px; }
.hud-fuses { display: flex; gap: 4px; }
.hud-fuses .fuse { width: calc(34px * var(--hud-scale)); height: calc(34px * var(--hud-scale)); object-fit: contain; filter: drop-shadow(0 0 6px rgba(255, 196, 120, 0.4)); }
.hud-fuses .fuse.blown { filter: grayscale(0.4) brightness(0.7); }
.hud-fuses .fuse.pop { animation: fuse-pop 0.6s ease-out; }
@keyframes fuse-pop { 0% { transform: scale(1.8) rotate(-12deg); filter: brightness(3); } 60% { transform: scale(0.9) rotate(4deg); } 100% { transform: none; } }
.hud-signal, .hud-time { display: grid; gap: 3px; }
.hud-signal .pips { display: flex; gap: 4px; }
.hud-signal .pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--band) 60%, transparent); }
.hud-signal .pips i.on { background: var(--band); box-shadow: 0 0 10px var(--band); }
.bar { display: block; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; min-width: 56px; }
.bar b { display: block; height: 100%; background: var(--band); transform-origin: left; }
.hud-time strong { font: 600 1.1em var(--mono); }
.hud-pause { pointer-events: auto; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(8, 11, 18, 0.8); border-radius: 8px; padding: 8px 12px; font: 600 0.78em var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.hud-alerts { position: absolute; top: calc(var(--hud-top-h, 86px) + 8px); left: max(14px, env(safe-area-inset-left)); display: grid; gap: 6px; justify-items: start; }
.hud-threat, .hud-window, .hud-surge, .hud-module, .hud-onair, .hud-flip, .hud-reels { font: 600 0.74em var(--mono); letter-spacing: 0.12em; text-transform: uppercase; padding: 5px 10px; border-radius: 6px; background: rgba(6, 9, 15, 0.78); border: 1px solid rgba(255, 255, 255, 0.12); display: flex; gap: 8px; align-items: center; }
.hud-threat::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--safe); box-shadow: 0 0 8px var(--safe); }
.hud-threat[data-level='hunt'] { color: var(--amber); }
.hud-threat[data-level='hunt']::before { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: blink 0.9s infinite; }
.hud-threat[data-level='chase'] { color: var(--danger); border-color: rgba(255, 90, 74, 0.6); }
.hud-threat[data-level='chase']::before { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: blink 0.35s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.hud-window[data-open='false'] strong { color: var(--danger); }
.hud-window[data-open='true'] strong { color: var(--safe); }
.hud-onair .lamp { width: 46px; height: 23px; object-fit: contain; vertical-align: middle; margin-right: 6px; }
.hud-onair[data-lit='true'] { color: #ffd6d6; border-color: rgba(255, 77, 94, 0.75); }
.hud-onair[data-lit='true'] strong { color: #ff6b7a; }
.hud-flip[data-warn='true'] { color: #fff; border-color: rgba(255, 255, 255, 0.7); animation: blink 0.3s infinite; }
.hud-flip .bar b { background: linear-gradient(90deg, var(--amber), var(--cyan)); }
.hud-reels { color: #ffd98a; }
.air-veil { position: fixed; inset: 0; pointer-events: none; z-index: 30; opacity: 0; transition: opacity .18s; box-shadow: inset 0 0 120px 10px rgba(255, 50, 70, 0.55), inset 0 0 0 4px rgba(255, 70, 90, 0.35); }
.air-veil.lit { opacity: 1; animation: onair-pulse 1.6s ease-in-out infinite; }
html.reduced-motion .air-veil.lit { animation: none; }
@keyframes onair-pulse { 50% { opacity: 0.6; } }
.hud-surge[data-warn='true'] { color: #fff; border-color: rgba(255, 255, 255, 0.7); animation: blink 0.4s infinite; }
.hud-surge .bar b { background: #dfe8ff; }
.hud-module strong { color: var(--band); }
.hud-preview { position: absolute; left: 50%; top: calc(var(--hud-top-h, 90px) + 10px); transform: translateX(-50%); font: 600 0.8em var(--mono); letter-spacing: 0.14em; padding: 8px 16px; border-radius: 999px; background: rgba(4, 6, 10, 0.82); border: 1px solid color-mix(in srgb, var(--band) 60%, transparent); display: flex; gap: 10px; align-items: baseline; white-space: nowrap; }
html[data-band='amber'] .hud-preview strong { color: var(--cyan); }
html[data-band='cyan'] .hud-preview strong { color: var(--amber); }
.hud-preview small { color: var(--muted); font-size: 0.85em; }
.hud-hint { position: absolute; right: max(14px, env(safe-area-inset-right)); top: calc(var(--hud-top-h, 90px) + 10px); max-width: min(330px, 42vw); padding: 12px 14px; border-radius: 10px; background: rgba(8, 11, 18, 0.9); border: 1px solid color-mix(in srgb, var(--band) 50%, transparent); display: grid; gap: 4px; animation: hint-in 0.35s cubic-bezier(.2,1.3,.4,1); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.hud-hint strong { font: 800 1.15em var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--band); }
.hud-hint span { font-size: 0.9em; line-height: 1.4; color: #d7dee6; }
@keyframes hint-in { from { opacity: 0; transform: translateY(-10px) scale(0.96); } }
.hud-caption { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; max-width: min(760px, 90vw); text-align: center; font: 500 0.9em/1.35 var(--mono); padding: 8px 14px; border-radius: 8px; background: rgba(4, 6, 10, 0.78); color: #dfe6ec; }
.hud-caption:empty { display: none; }
.hud-caption.fresh { animation: caption-in 0.3s ease-out; }
@keyframes caption-in { from { opacity: 0.2; transform: translate(-50%, 6px); } }
html.no-captions .hud-caption { opacity: 0.75; }

.floor-intro { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; text-align: center; animation: intro 2.6s ease-in-out forwards; pointer-events: none; }
.floor-intro span { font: 600 0.8em var(--mono); letter-spacing: 0.3em; color: var(--amber); }
.floor-intro strong { font: 800 clamp(2.6rem, 7vw, 5rem)/0.9 var(--display); letter-spacing: 0.06em; text-transform: uppercase; text-shadow: 0 0 30px rgba(0, 0, 0, 0.9), 0 0 18px color-mix(in srgb, var(--band) 40%, transparent); }
.floor-intro em { font: 500 0.95em var(--mono); font-style: normal; color: #d6dde4; text-shadow: 0 2px 10px #000; }
@keyframes intro { 0% { opacity: 0; letter-spacing: 0.4em; filter: blur(6px); } 15% { opacity: 1; letter-spacing: normal; filter: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }

/* ---- touch ----------------------------------------------------------------- */
.touch { position: absolute; inset: auto 0 0 0; display: none; justify-content: space-between; align-items: end; padding: 0 max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); pointer-events: none; }
html.touch-input .touch:not([hidden]) { display: flex; }
@media (hover: none) and (pointer: coarse) { .touch:not([hidden]) { display: flex; } }
.touch button { pointer-events: auto; touch-action: none; user-select: none; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(8, 11, 18, 0.62); color: var(--ink); border-radius: 14px; backdrop-filter: blur(4px); }
.touch button.down { background: color-mix(in srgb, var(--band) 35%, rgba(8, 11, 18, 0.7)); border-color: var(--band); }
.dpad { display: grid; grid-template: 'a up b' 52px 'left c right' 52px 'd down e' 52px / 52px 52px 52px; gap: 4px; }
.dpad button { padding: 0; border: 0; background: transparent; backdrop-filter: none; border-radius: 12px; }
.dpad button.down { background: transparent; filter: brightness(1.5) drop-shadow(0 0 8px var(--band)); }
.dpad .arrow { display: block; width: 100%; height: 100%; background: url(./assets/art/dpad-arrow.webp) center / contain no-repeat; }
.dpad [data-move='-1,0'] .arrow { transform: rotate(-90deg); } .dpad [data-move='1,0'] .arrow { transform: rotate(90deg); } .dpad [data-move='0,1'] .arrow { transform: rotate(180deg); }
.dpad [data-move='0,-1'] { grid-area: up; } .dpad [data-move='-1,0'] { grid-area: left; } .dpad [data-move='1,0'] { grid-area: right; } .dpad [data-move='0,1'] { grid-area: down; }
.touch-actions { display: flex; gap: 10px; align-items: end; }
.touch-tune { width: 104px; height: 104px; border-radius: 50% !important; font: 800 1.3em var(--display); letter-spacing: 0.1em; text-transform: uppercase; display: grid; place-content: center; border-color: color-mix(in srgb, var(--band) 70%, transparent) !important; box-shadow: 0 0 20px color-mix(in srgb, var(--band) 30%, transparent); }
.touch-tune small { font: 500 0.55em var(--mono); color: var(--muted); }
.touch-wait, .touch-module { height: 52px; padding: 0 14px; font: 600 0.8em var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
@media (max-height: 460px) {
  .hud-top { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .hud-floor strong { font-size: 1.15em; }
  .hud-floor span, .hud-signal span, .hud-time span, .hud-band span { display: none; }
  .hud-hint { max-width: 46vw; font-size: 0.85em; }
  .hud-caption { bottom: 8px; max-width: 46vw; font-size: 0.78em; }
  .dpad { grid-template-rows: 46px 46px 46px; grid-template-columns: 46px 46px 46px; }
  .touch-tune { width: 88px; height: 88px; }
}
@media (max-width: 720px) {
  .hud-top { grid-template-columns: 1fr auto; }
  .hud-band { grid-column: 1 / -1; grid-row: 2; justify-self: start; padding: 3px 10px; }
  .hud-band .dial { display: none; }
  .hud-meters { gap: 10px; }
  .hud-time { display: none; }
  .hud-floor strong { font-size: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* Portrait phones (24 Oct verifier, 390x844): the meters left the floor column ~90 px, so the zone line wrapped three
   times and the objective was cut to "Hold the re…"; the caption ran under the pad; the hint covered the floor at the
   top. Floor block and Pause share the first row, band, fuses and signal the second; caption and hint sit above the pad. */
@media (max-width: 560px) {
  .hud-top { grid-template-columns: auto auto 1fr auto; grid-template-areas: 'floor floor floor pause' 'band fuses signal time'; row-gap: 6px; column-gap: 10px; padding-bottom: 10px; }
  /* Gold medals depend on the time (round-2 verifier): a compact clock at the end of the second row. */
  .hud-time { display: grid; grid-area: time; justify-self: end; align-self: center; }
  .hud-time > span { display: none; }
  .hud-time strong { font-size: 0.95em; }
  .hud-meters { display: contents; }
  .hud-floor { grid-area: floor; }
  .hud-floor em { white-space: normal; }
  .hud-pause { grid-area: pause; justify-self: end; align-self: start; }
  .hud-band { grid-area: band; align-self: center; }
  .hud-band span { display: none; }
  .hud-fuses { grid-area: fuses; align-self: center; }
  .hud-fuses .fuse { width: calc(28px * var(--hud-scale)); height: calc(28px * var(--hud-scale)); }
  .hud-signal { grid-area: signal; justify-self: start; align-self: center; }
  .hud-signal > span { display: none; }
  .hud-caption { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 178px); left: 14px; right: 14px; transform: none; margin-inline: auto; width: fit-content; max-width: none; }
  .hud-caption.fresh { animation-name: caption-rise; }
  @keyframes caption-rise { from { opacity: 0.2; transform: translateY(6px); } }
  .hud-hint { top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 250px); left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); max-width: none; padding: 10px 12px; }
}

.toast { position: fixed; left: 50%; bottom: 70px; transform: translate(-50%, 20px); opacity: 0; transition: 0.25s; background: rgba(8, 11, 18, 0.94); border: 1px solid rgba(255, 255, 255, 0.18); padding: 10px 16px; border-radius: 8px; font: 500 0.9em var(--mono); pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
html.reduced-motion *, html.reduced-motion *::before { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
