/* REDUX RUNNER - Round 5 UI: neon light-grid sci-fi. Glass panels (backdrop-filter, opaque fallback), light-line borders,
   Orbitron headings + Rajdhani text (self-hosted, OFL: assets/fonts). HUD stays blur-free (cheap over the live game). */
@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 500; font-display: swap; src: url(../assets/fonts/orbitron-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 700; font-display: swap; src: url(../assets/fonts/orbitron-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 900; font-display: swap; src: url(../assets/fonts/orbitron-latin-900-normal.woff2) format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 500; font-display: swap; src: url(../assets/fonts/rajdhani-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 600; font-display: swap; src: url(../assets/fonts/rajdhani-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 700; font-display: swap; src: url(../assets/fonts/rajdhani-latin-700-normal.woff2) format('woff2'); }

:root {
  --cyan: #22e8ff; --mag: #ff3df2; --lime: #b6ff3a; --red: #ff2448; --gold: #ffc83a; --violet: #8a5cff;
  --bg: #05060f; --text: #eaf6ff; --dim: rgba(214, 236, 255, 0.66);
  --panel: rgba(8, 12, 30, 0.9);
  --glass: linear-gradient(180deg, rgba(22, 34, 66, 0.52), rgba(6, 10, 28, 0.66));
  --line: rgba(110, 236, 255, 0.34); --line-hi: #7ff3ff;
  --hud-bg: rgba(5, 9, 24, 0.62);
  --btn-scale: 1;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --head: 'Orbitron', 'Arial Black', 'Helvetica Neue', Helvetica, system-ui, sans-serif;
  --font: 'Rajdhani', 'Helvetica Neue', Helvetica, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  position: fixed; inset: 0; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-weight: 600;
  overscroll-behavior: none; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
button { font-family: var(--head); font-weight: 700; color: inherit; touch-action: none; cursor: pointer; }
.hidden { display: none !important; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: fixed; inset: 0; z-index: 1; touch-action: none; }

/* ------------------------------------------------------------- glass + light lines */
.glass {
  position: relative; background: var(--glass); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 40px rgba(34, 232, 255, 0.05), 0 16px 48px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.35); backdrop-filter: blur(14px) saturate(1.35);
}
/* light-line corner brackets */
.glass::before, .card::before, .res-card::before {
  content: ""; position: absolute; inset: -1px; pointer-events: none; border-radius: inherit;
  --k: var(--line-hi);
  background:
    linear-gradient(var(--k), var(--k)) top left / 22px 2px no-repeat, linear-gradient(var(--k), var(--k)) top left / 2px 22px no-repeat,
    linear-gradient(var(--k), var(--k)) bottom right / 22px 2px no-repeat, linear-gradient(var(--k), var(--k)) bottom right / 2px 22px no-repeat;
  filter: drop-shadow(0 0 4px var(--k));
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--panel); }
}
/* Low tier: no blur behind panels (phones keep every ms for the game) */
body.lowfx .glass, body.lowfx .card { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--panel); }
.glass-k { font-family: var(--head); font-size: 10px; letter-spacing: 4px; color: var(--cyan); opacity: 0.85; display: flex; align-items: center; gap: 10px; }
.glass-k::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

/* ------------------------------------------------------------- HUD (no backdrop blur: cheap over the live game) */
#hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; font-family: var(--head); font-weight: 700; }
#hud .hud-btn, #hud .act, #tip.on { pointer-events: auto; }
.hud-btn {
  position: absolute; width: 64px; height: 64px; border-radius: 10px;
  background: var(--hud-bg); border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(34, 232, 255, 0.08), 0 0 14px rgba(34, 232, 255, 0.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
#btnPause { left: calc(12px + var(--sl)); top: calc(10px + var(--st)); }
#btnPause span { display: block; width: 24px; height: 3px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
#btnPause span:nth-child(2) { width: 16px; margin-left: 8px; }
#btnChar { left: calc(86px + var(--sl)); top: calc(10px + var(--st)); width: auto; padding: 0 16px; font-size: 12px; letter-spacing: 2px; color: var(--cyan); }

#topbar {
  position: absolute; top: calc(8px + var(--st)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 4px 18px;
  background: linear-gradient(180deg, rgba(5, 9, 24, 0.72), rgba(5, 9, 24, 0.5));
  border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px;
  font-size: 11px; letter-spacing: 2px; white-space: nowrap; color: var(--dim);
}
/* light lines running out from the status bar */
#topbar::before, #topbar::after { content: ""; position: absolute; top: 0; width: 22vw; height: 1px; pointer-events: none; }
#topbar::before { right: 100%; background: linear-gradient(270deg, var(--line-hi), transparent); }
#topbar::after { left: 100%; background: linear-gradient(90deg, var(--line-hi), transparent); }
#timer { font-family: var(--head); font-weight: 900; font-size: 26px; letter-spacing: 1px; color: #fff; min-width: 92px; text-align: center; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(34, 232, 255, 0.6); }
#timer.dim { font-size: 15px; color: var(--cyan); letter-spacing: 3px; min-width: 70px; }
#timer.hot { color: #fff; text-shadow: 0 0 14px var(--mag); }
#phase { color: var(--mag); }
#survivors b { color: var(--cyan); font-size: 18px; font-weight: 900; margin-right: 2px; }
.role {
  position: absolute; top: calc(54px + var(--st)); left: 50%; transform: translateX(-50%);
  padding: 3px 14px; border-radius: 4px; font-size: 11px; letter-spacing: 3px; white-space: nowrap;
  background: rgba(34, 232, 255, 0.14); color: var(--cyan); border: 1px solid rgba(34, 232, 255, 0.7);
}
.role.infected { background: rgba(255, 36, 72, 0.22); color: #ffd4da; border-color: var(--red); box-shadow: 0 0 18px rgba(255, 36, 72, 0.6); }
.role.off { display: none; }

#joyBase {
  position: absolute; left: 0; top: 0; width: calc(124px * var(--btn-scale)); height: calc(124px * var(--btn-scale));
  margin: calc(-62px * var(--btn-scale)) 0 0 calc(-62px * var(--btn-scale));
  border-radius: 50%; border: 2px solid rgba(34, 232, 255, 0.55); background: radial-gradient(circle, rgba(34, 232, 255, 0.04) 40%, rgba(34, 232, 255, 0.12));
  box-shadow: 0 0 16px rgba(34, 232, 255, 0.18), inset 0 0 18px rgba(34, 232, 255, 0.12);
  opacity: 0.3; transition: opacity 0.15s;
}
#joyBase::before { content: ""; position: absolute; inset: 14%; border-radius: 50%; border: 1px dashed rgba(34, 232, 255, 0.3); }
#joyBase.active { opacity: 1; }
#joyKnob {
  position: absolute; left: 50%; top: 50%; width: calc(58px * var(--btn-scale)); height: calc(58px * var(--btn-scale));
  margin: calc(-29px * var(--btn-scale)) 0 0 calc(-29px * var(--btn-scale));
  border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(190, 250, 255, 0.85), rgba(34, 232, 255, 0.5) 60%); border: 2px solid #bff8ff;
  box-shadow: 0 0 14px rgba(34, 232, 255, 0.6);
}
#joyBase.sprint { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 200, 58, 0.8), inset 0 0 20px rgba(255, 200, 58, 0.5); }
#joyBase.sprint #joyKnob { background: rgba(255, 200, 58, 0.85); border-color: #fff3c9; box-shadow: 0 0 18px var(--gold); }

/* touch action buttons (geometry unchanged since Round 4: tested for fit + no overlaps at 844x390) */
#buttons { position: absolute; right: calc(18px + var(--sr)); bottom: calc(14px + var(--sb)); width: 0; height: 0; }
.act {
  position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(40, 60, 110, 0.5), rgba(5, 9, 24, 0.62) 70%);
  border: 2px solid rgba(214, 240, 255, 0.55);
  box-shadow: inset 0 0 0 4px rgba(5, 9, 24, 0.35), inset 0 0 0 5px rgba(214, 240, 255, 0.12);
  font-size: calc(14px * var(--btn-scale)); letter-spacing: 1px;
  transition: transform 0.08s;
}
.act.down { transform: scale(0.92); background: rgba(255, 255, 255, 0.2); }
.jump { width: calc(100px * var(--btn-scale)); height: calc(100px * var(--btn-scale)); right: 0; bottom: 0; gap: calc(2px * var(--btn-scale)); }
.jump .chev { width: calc(16px * var(--btn-scale)); height: calc(16px * var(--btn-scale)); border-left: 3px solid #fff; border-top: 3px solid #fff; transform: rotate(45deg); margin-top: calc(8px * var(--btn-scale)); filter: drop-shadow(0 0 4px var(--cyan)); }
.special {
  width: calc(100px * var(--btn-scale)); height: calc(100px * var(--btn-scale));
  right: calc(112px * var(--btn-scale)); bottom: calc(58px * var(--btn-scale));
  border-color: transparent; --c: var(--cyan);
}
/* [R4] SPECIAL 2: slightly smaller, right above SPECIAL 1 (>= 67 px at the smallest button size) */
.special.s2 {
  width: calc(84px * var(--btn-scale)); height: calc(84px * var(--btn-scale));
  right: calc(118px * var(--btn-scale)); bottom: calc(170px * var(--btn-scale)); font-size: calc(12px * var(--btn-scale));
}
.special .tag { position: absolute; top: 14%; font-size: calc(9px * var(--btn-scale)); color: var(--c); opacity: 0.8; letter-spacing: 0; }
.special.s2 .tag { top: 12%; }
.special.s2 .hint { font-size: calc(9px * var(--btn-scale)); }
.special.none, .act.off { display: none; }
/* contextual GLIDE BOOST: takes JUMP's spot while the Glider glides; dots = charges left this glide */
.boost {
  width: calc(100px * var(--btn-scale)); height: calc(100px * var(--btn-scale)); right: 0; bottom: 0; gap: calc(6px * var(--btn-scale));
  border-color: var(--mag); background: color-mix(in srgb, var(--mag) 22%, rgba(8, 10, 28, 0.6));
}
.boost .lbl { color: #fff; text-shadow: 0 0 10px var(--mag); }
.boost.ready { animation: pulseMag 0.9s ease-in-out infinite; }
.boost.thrust { background: color-mix(in srgb, var(--mag) 60%, transparent); border-color: #fff; }
.boost.empty { border-color: rgba(255, 255, 255, 0.3); background: rgba(8, 10, 28, 0.55); }
.boost.empty .lbl { opacity: 0.45; text-shadow: none; }
.dots { display: flex; gap: 0.45em; }
.dots i { width: 0.62em; height: 0.62em; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.55); }
.dots i.on { background: #fff; border-color: #fff; box-shadow: 0 0 8px var(--mag), 0 0 3px #fff; }
@keyframes pulseMag { 0%, 100% { box-shadow: 0 0 8px var(--mag); } 50% { box-shadow: 0 0 28px var(--mag), 0 0 4px #fff; } }
.special svg { position: absolute; inset: -3px; width: calc(100% + 6px); height: calc(100% + 6px); transform: rotate(-90deg); }
.special circle { fill: none; stroke-width: 6; }
.special circle.bg { stroke: rgba(255, 255, 255, 0.14); }
.special circle.fg { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 276.5; filter: drop-shadow(0 0 3px var(--c)); }
.special .lbl { color: var(--c); position: relative; }
.special .hint { font-family: var(--font); font-size: calc(11px * var(--btn-scale)); color: rgba(255, 255, 255, 0.7); position: relative; min-height: 1em; }
.special.ready { animation: pulse 1.1s ease-in-out infinite; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--c) 28%, transparent), rgba(5, 9, 24, 0.6) 72%); }
.special.ready .lbl { color: #fff; text-shadow: 0 0 10px var(--c); }
.special.cool .lbl { opacity: 0.55; }
.special.blocked .lbl { opacity: 0.45; }
.special.active { background: color-mix(in srgb, var(--c) 45%, transparent); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 6px var(--c); } 50% { box-shadow: 0 0 26px var(--c), 0 0 4px #fff; } }
body.lefty #buttons { right: auto; left: calc(18px + var(--sl)); }
body.lefty .jump { right: auto; left: 0; }
body.lefty .special { right: auto; left: calc(112px * var(--btn-scale)); }
body.lefty .special.s2 { left: calc(118px * var(--btn-scale)); }
body.lefty .boost { right: auto; left: 0; }

#stamina { position: absolute; left: 50%; bottom: calc(26px + var(--sb)); width: 180px; height: 6px; margin-left: -90px; border-radius: 1px; background: rgba(255,255,255,0.12);
  opacity: 0; transition: opacity 0.2s; outline: 1px solid rgba(182, 255, 58, 0.35); outline-offset: 2px; }
#stamina.on { opacity: 1; }
#stamina div { height: 100%; width: 100%; background: linear-gradient(90deg, #7fe01c, var(--lime)); box-shadow: 0 0 10px var(--lime);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 14px, transparent 14px 16px); mask: repeating-linear-gradient(90deg, #000 0 14px, transparent 14px 16px); }
#stamina.low div { background: var(--red); box-shadow: 0 0 10px var(--red); }

/* Dasher double jump: two chevrons while airborne (lit = the air jump is still there) */
#airJump { position: absolute; left: 50%; bottom: calc(42px + var(--sb)); transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  padding: 3px 10px 3px 8px; border-radius: 4px; background: var(--hud-bg); border: 1px solid rgba(34, 232, 255, 0.7);
  font-size: 10px; letter-spacing: 2px; color: #fff; }
#airJump i { width: 10px; height: 10px; border-left: 3px solid var(--cyan); border-top: 3px solid var(--cyan); transform: rotate(45deg) translate(2px, 2px); }
#airJump b { font-weight: inherit; margin-left: 4px; }
#airJump.on { box-shadow: 0 0 14px rgba(34, 232, 255, 0.7); }
#airJump.used { opacity: 0.4; border-color: rgba(255, 255, 255, 0.3); }
#airJump.used i { border-color: rgba(255, 255, 255, 0.6); }
#airJump.off { display: none; }

/* Climber GRAPPLE: center reticle (lit = target in range) + marker on the target */
#reticle { --c: #ff8a1e; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s; }
#reticle i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255, 255, 255, 0.6); }
#reticle::before, #reticle::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.45); }
#reticle::before { left: 50%; top: -8px; bottom: -8px; width: 2px; margin-left: -1px; -webkit-mask: linear-gradient(#000 0 7px, transparent 7px calc(100% - 7px), #000 calc(100% - 7px)); mask: linear-gradient(#000 0 7px, transparent 7px calc(100% - 7px), #000 calc(100% - 7px)); }
#reticle::after { top: 50%; left: -8px; right: -8px; height: 2px; margin-top: -1px; -webkit-mask: linear-gradient(90deg, #000 0 7px, transparent 7px calc(100% - 7px), #000 calc(100% - 7px)); mask: linear-gradient(90deg, #000 0 7px, transparent 7px calc(100% - 7px), #000 calc(100% - 7px)); }
#reticle.dim { opacity: 0.55; }
#reticle.cool { opacity: 0.25; }
#reticle.lit { border-color: var(--c); transform: scale(1.18); box-shadow: 0 0 14px var(--c), inset 0 0 8px var(--c); }
#reticle.lit i, #reticle.lit::before, #reticle.lit::after { background: #fff; }
#reticle.off, #grappleMark.off { display: none; }
#grappleMark { --c: #ff8a1e; position: absolute; left: 0; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
#grappleMark::before { content: ""; position: absolute; inset: 0; border: 3px solid var(--c); transform: rotate(45deg); border-radius: 4px;
  box-shadow: 0 0 12px var(--c); animation: gmark 0.8s ease-in-out infinite; }
@keyframes gmark { 50% { transform: rotate(45deg) scale(0.72); } }

/* keyboard / gamepad: "SPACE - BOOST" while the Glider can boost */
#boostPrompt { position: absolute; left: 50%; bottom: calc(66px + var(--sb)); transform: translateX(-50%); display: flex; align-items: center; gap: 0.5em;
  padding: 0.35em 0.9em 0.35em 0.45em; border-radius: 8px; background: color-mix(in srgb, var(--mag) 20%, rgba(8, 10, 28, 0.75));
  border: 1px solid var(--mag); font-size: clamp(15px, 0.85vw + 7px, 24px); letter-spacing: 2px; color: #fff; }
#boostPrompt b { font-weight: inherit; text-shadow: 0 0 10px var(--mag); }
#boostPrompt .dots { font-size: 0.8em; margin-left: 0.2em; }
#boostPrompt.ready { animation: pulseMag 0.9s ease-in-out infinite; }
#boostPrompt.thrust { background: color-mix(in srgb, var(--mag) 55%, rgba(8, 10, 28, 0.6)); }
#boostPrompt.off { display: none; }

#toast { position: absolute; top: calc(84px + var(--st)); left: 50%; transform: translateX(-50%); font-family: var(--font); font-size: 15px; letter-spacing: 1px; white-space: nowrap;
  opacity: 0; transition: opacity 0.25s, transform 0.25s var(--ease); padding: 3px 14px; border-radius: 4px; background: rgba(5, 6, 15, 0.7); border-left: 2px solid var(--cyan); }
#toast.on { opacity: 1; }
#banner { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-family: var(--head); font-weight: 900; font-size: clamp(34px, 3vw + 18px, 72px); letter-spacing: 6px;
  opacity: 0; transform: scale(1.12); transition: opacity 0.2s, transform 0.35s var(--ease); text-shadow: 0 0 22px currentColor; }
#banner.on { opacity: 1; transform: scale(1); }
#banner small { display: block; font-family: var(--font); font-weight: 700; font-size: clamp(15px, 0.5vw + 12px, 22px); letter-spacing: 3px; margin-top: 6px; color: #fff; text-shadow: 0 0 6px #000, 0 0 2px #000; }
#vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 20, 60, 0.75) 100%); opacity: 0; }

/* [R5] first-time tips: top right, under the safe area; never over the buttons / reticle */
#tip { position: absolute; top: calc(10px + var(--st)); right: calc(12px + var(--sr)); max-width: min(360px, 40vw); display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 8px; border-radius: 6px; background: linear-gradient(90deg, rgba(5, 9, 24, 0.86), rgba(5, 9, 24, 0.7));
  border: 1px solid var(--line); border-left: 3px solid var(--c, var(--cyan)); box-shadow: 0 0 18px rgba(34, 232, 255, 0.18);
  font-family: var(--font); font-weight: 700; font-size: clamp(14px, 0.4vw + 11px, 19px); line-height: 1.2; letter-spacing: 0.5px;
  transition: opacity 0.25s, transform 0.35s var(--ease); }
#tip.off { opacity: 0; transform: translateX(24px); pointer-events: none; }
#tip .tip-k { flex: none; font-family: var(--head); font-size: 9px; letter-spacing: 2px; color: #05060f; background: var(--c, var(--cyan)); padding: 3px 5px; border-radius: 2px; }
#tip .tip-t b { font-family: var(--head); font-weight: 700; font-size: 0.82em; letter-spacing: 1px; color: var(--c, var(--cyan)); }
#tip .tip-t kbd { font-size: 0.78em; }
#tip .tip-x { flex: none; font-size: 20px; line-height: 1; color: var(--dim); padding: 0 2px 2px; }
body.in-kbm #tip .tip-x, body.in-pad #tip .tip-x { display: none; }
/* phones / small windows: under the top row (pause button / status bar); touch right-handed = left side (the buttons are right) */
@media (max-width: 1000px), (max-height: 500px) {
  #tip { top: calc(84px + var(--st)); max-width: min(270px, 31vw); }
  body.in-touch:not(.lefty) #tip { right: auto; left: calc(12px + var(--sl)); }
  body.in-touch:not(.lefty) #tip.off { transform: translateX(-24px); }
}

/* [R5] round flow */
#infTint { position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(255, 20, 60, 0.32) 88%, rgba(255, 20, 60, 0.5) 100%); }
#infTint.on { opacity: 1; animation: infPulse 2.4s ease-in-out infinite; }
@keyframes infPulse { 50% { opacity: 0.7; } }
#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255, 230, 235, 0.4), rgba(255, 36, 72, 0.6) 55%, rgba(120, 0, 20, 0.85)); }
#flash.go { animation: flash 0.75s ease-out forwards; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
#countdown { position: absolute; left: 50%; top: 40%; width: 0; height: 0; display: flex; align-items: center; justify-content: center; }
#countdown.off { display: none; }
#countdown b { position: absolute; font-family: var(--head); font-weight: 900; font-size: clamp(64px, 7vw + 30px, 170px); color: #fff; white-space: nowrap; letter-spacing: 4px;
  text-shadow: 0 0 18px var(--cyan), 0 0 48px var(--cyan); }
#countdown b::before { content: ""; position: absolute; left: 50%; top: 50%; width: 1.5em; height: 1.5em; margin: -0.75em 0 0 -0.75em; border-radius: 50%;
  border: 2px solid var(--cyan); box-shadow: 0 0 20px var(--cyan), inset 0 0 20px var(--cyan); opacity: 0; }
#countdown.tick b { animation: cdIn 0.9s var(--ease) forwards; }
#countdown.tick b::before { animation: cdRing 0.9s ease-out forwards; }
#countdown.go b { color: #fff; animation: goIn 1.3s var(--ease) forwards; }
#countdown.go.surv b { text-shadow: 0 0 18px var(--cyan), 0 0 60px var(--cyan); }
#countdown.go.inf b { text-shadow: 0 0 18px var(--red), 0 0 60px var(--red); }
#countdown b small { display: block; text-align: center; font-family: var(--font); font-weight: 700; font-size: 0.16em; letter-spacing: 4px; margin-top: 0.2em; text-shadow: 0 0 6px #000; }
@keyframes cdIn { 0% { opacity: 0; transform: scale(1.8); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; transform: scale(0.94); } 100% { opacity: 0; transform: scale(0.8); } }
@keyframes cdRing { 0% { opacity: 0.9; transform: scale(0.6); } 100% { opacity: 0; transform: scale(2); } }
@keyframes goIn { 0% { opacity: 0; transform: scale(0.4); letter-spacing: 40px; } 18% { opacity: 1; transform: scale(1.08); letter-spacing: 8px; } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.3); } }
#alert { position: absolute; left: 50%; top: calc(82px + var(--st)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 26px 10px; border-radius: 4px; background: linear-gradient(180deg, rgba(60, 40, 0, 0.75), rgba(20, 12, 0, 0.6)); border: 1px solid var(--gold);
  box-shadow: 0 0 26px rgba(255, 200, 58, 0.45); white-space: nowrap; }
#alert.off { display: none; }
#alert.on { animation: alertIn 0.45s var(--ease), alertGlow 0.9s ease-in-out 0.45s 3; }
#alert .al-k { font-size: 9px; letter-spacing: 5px; color: var(--gold); }
#alert b { font-family: var(--head); font-weight: 900; font-size: clamp(20px, 1.3vw + 12px, 34px); letter-spacing: 4px; color: #fff; text-shadow: 0 0 14px var(--gold); }
#alert small { font-family: var(--font); font-weight: 700; font-size: 14px; letter-spacing: 2px; color: #ffe7a8; }
#alert.you { border-color: var(--cyan); box-shadow: 0 0 30px rgba(34, 232, 255, 0.5); background: linear-gradient(180deg, rgba(0, 50, 70, 0.78), rgba(0, 14, 24, 0.6)); }
#alert.you b { text-shadow: 0 0 14px var(--cyan); }
#alert.you .al-k { color: var(--cyan); }
@keyframes alertIn { 0% { opacity: 0; transform: translateX(-50%) scaleX(0.2); } 100% { opacity: 1; transform: translateX(-50%) scaleX(1); } }
@keyframes alertGlow { 50% { box-shadow: 0 0 44px rgba(255, 200, 58, 0.8); } }
/* INFECTED: big glitch title over the flash */
#banner.inf { color: var(--red); letter-spacing: 10px; }
#banner.inf.on { animation: glitch 0.5s steps(2) 2; }
@keyframes glitch { 0% { text-shadow: 3px 0 #fff, -3px 0 var(--red), 0 0 24px var(--red); transform: translateX(-3px); } 50% { text-shadow: -4px 0 #fff, 4px 0 var(--red), 0 0 30px var(--red); transform: translateX(3px) skewX(-6deg); } 100% { text-shadow: 0 0 22px var(--red); transform: none; } }

#results { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(4, 6, 16, 0.55), rgba(4, 6, 16, 0.82)); }
#results.off { display: none; }
#results.on .res-card { animation: resIn 0.55s var(--ease) both; }
.res-card { --k: var(--cyan); position: relative; min-width: min(560px, 80vw); padding: 18px 36px 20px; text-align: center; border-radius: 6px;
  background: linear-gradient(180deg, rgba(10, 18, 40, 0.86), rgba(5, 8, 22, 0.9)); border: 1px solid color-mix(in srgb, var(--k) 60%, transparent);
  box-shadow: 0 0 60px color-mix(in srgb, var(--k) 30%, transparent), inset 0 0 40px color-mix(in srgb, var(--k) 10%, transparent); }
.res-card::before { --k: inherit; }
#results.lose .res-card { --k: #9aa7c7; }
#results.inf .res-card { --k: var(--red); }
.res-k { font-size: 11px; letter-spacing: 6px; color: var(--k); }
.res-h { font-family: var(--head); font-weight: 900; font-size: clamp(40px, 4vw + 20px, 96px); letter-spacing: 8px; line-height: 1.05; margin: 4px 0 2px; color: #fff;
  text-shadow: 0 0 20px var(--k), 0 0 60px var(--k); }
#results.lose .res-h { color: #cfd8ee; text-shadow: 0 0 16px rgba(160, 175, 210, 0.5); }
.res-sub { font-family: var(--font); font-weight: 700; font-size: clamp(15px, 0.6vw + 11px, 24px); letter-spacing: 3px; color: var(--dim); }
.res-stats { display: flex; justify-content: center; gap: clamp(14px, 2vw, 40px); margin: 12px 0 4px; }
.res-stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px; padding: 6px 10px; border-top: 1px solid color-mix(in srgb, var(--k) 50%, transparent); }
.res-stats b { font-family: var(--head); font-weight: 900; font-size: clamp(20px, 1.2vw + 12px, 36px); color: #fff; font-variant-numeric: tabular-nums; }
.res-stats span { font-size: 10px; letter-spacing: 3px; color: var(--dim); }
.res-next { font-family: var(--font); font-size: 13px; letter-spacing: 3px; color: var(--dim); margin-top: 6px; }
@keyframes resIn { 0% { opacity: 0; transform: translateY(18px) scale(0.96); } 100% { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; z-index: 5;
  background: radial-gradient(ellipse at 50% 120%, rgba(34, 232, 255, 0.10), transparent 60%), linear-gradient(180deg, rgba(3, 5, 14, 0.78), rgba(3, 5, 14, 0.9));
  padding: calc(10px + var(--st)) calc(16px + var(--sr)) calc(10px + var(--sb)) calc(16px + var(--sl));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  animation: ovIn 0.3s var(--ease);
}
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------- character select */
#select { gap: 10px; }
.sel-head { display: flex; align-items: baseline; gap: 18px; z-index: 1; }
.sel-title { font-family: var(--head); font-weight: 900; font-size: 20px; letter-spacing: 4px; color: #fff; text-shadow: 0 0 14px rgba(34, 232, 255, 0.6); }
#selTimer { font-family: var(--head); font-size: 12px; letter-spacing: 2px; color: var(--mag); padding: 3px 10px; border: 1px solid rgba(255, 61, 242, 0.5); border-radius: 3px; }
#selTimer.cd { color: #fff; border-color: #fff; text-shadow: 0 0 10px var(--mag); animation: cdSel 1s ease-out infinite; }
@keyframes cdSel { 0% { box-shadow: 0 0 22px var(--mag); } 100% { box-shadow: 0 0 0 transparent; } }
#cards { display: flex; gap: 12px; width: 100%; max-width: 900px; justify-content: center; min-height: 0; position: relative; z-index: 1; }
#selGL { position: fixed; left: 0; top: 0; width: 1px; height: 1px; pointer-events: none; z-index: 2; }
#selGL.off { display: none; }
.card {
  --c: var(--cyan); position: relative; flex: 1 1 0; max-width: 290px; min-height: 190px; padding: 8px 10px 10px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(180deg, rgba(18, 28, 58, 0.62), rgba(6, 10, 26, 0.78)); border: 1px solid rgba(214, 240, 255, 0.14);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.card::before { --k: color-mix(in srgb, var(--c) 50%, transparent); }
.card.sel { border-color: var(--c); box-shadow: 0 0 26px color-mix(in srgb, var(--c) 55%, transparent), inset 0 0 30px color-mix(in srgb, var(--c) 14%, transparent); transform: translateY(-3px); }
.card.sel::before { --k: var(--c); }
.card.sel::after { content: "SELECTED"; position: absolute; top: 6px; right: 8px; font-family: var(--head); font-size: 8px; letter-spacing: 2px; color: #05060f; background: var(--c); padding: 2px 5px; border-radius: 2px; }
/* the figure: live 3D model (drawn by menuscene.js into #selGL over this box), portrait image as the fallback */
.card .fig { width: 44px; height: 74px; border-radius: 22px; background: linear-gradient(160deg, color-mix(in srgb, var(--c) 100%, #fff 25%), var(--c) 55%, color-mix(in srgb, var(--c) 55%, #000)); position: relative; margin: 2px 0 4px; box-shadow: 0 0 16px color-mix(in srgb, var(--c) 60%, transparent); }
.card .fig::after { content: ""; position: absolute; left: 6px; right: 6px; top: 14px; height: 9px; border-radius: 4px; background: #e9fbff; }
.card .fig.img { background-size: cover; background-position: center; border-radius: 12px; width: 70px; }
.card .fig.img::after { display: none; }
.card .fig.mdl { width: 120px; height: 104px; margin: -8px 0 -4px; background-size: contain; background-repeat: no-repeat; background-position: center bottom; background-color: transparent; box-shadow: none; border-radius: 0;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--c) 55%, transparent)); }
.card .fig.mdl::before { content: ""; position: absolute; left: 10%; right: 10%; bottom: 2px; height: 14px; border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--c) 55%, transparent), transparent 70%); }
#select.live3d .card .fig.mdl { background-image: none !important; filter: none; }
.card .nm { font-family: var(--head); font-weight: 900; font-size: 16px; letter-spacing: 3px; color: var(--c); text-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent); }
/* [R4] 3-line kit: special 1, special 2, signature */
.card .kits { display: flex; flex-direction: column; gap: 5px; width: 100%; text-align: left; }
.kit { display: flex; gap: 7px; align-items: flex-start; }
.kit .tg { flex: none; width: 19px; height: 19px; margin-top: 1px; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-family: var(--head); font-size: 10px; color: #fff; background: color-mix(in srgb, var(--c) 30%, transparent); border: 1px solid color-mix(in srgb, var(--c) 80%, #fff); }
.kit.sig .tg { background: transparent; border-style: dashed; color: var(--c); }
.kit .kt { font-family: var(--font); font-weight: 600; font-size: 12.5px; line-height: 1.2; color: rgba(234, 246, 255, 0.78); }
.kit .kt b { font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: 1px; color: #fff; margin-right: 5px; }
.kit .kt em { font-style: normal; font-family: var(--head); font-size: 9.5px; color: rgba(255, 255, 255, 0.5); margin-right: 5px; }
.kit.sig .kt b { color: var(--c); }
.card .sp { font-size: 12px; color: #fff; letter-spacing: 1px; }
.card .bl { font-size: 12px; color: rgba(234, 246, 255, 0.78); line-height: 1.25; }
.card .cd { font-size: 11px; color: rgba(255, 255, 255, 0.5); margin-top: auto; }
/* phone landscape: shorter figure so figure + name + 3-line kit + READY fit in 390 px */
@media (max-height: 500px) {
  #select { gap: 7px; }
  #select .card { min-height: 0; gap: 2px; padding-top: 6px; }
  #select .card .fig.mdl { width: 110px; height: 86px; margin: -4px 0 -2px; }
  #select .card .nm { font-size: 14px; }
  #select .primary { min-height: 48px; }
  .sel-title { font-size: 16px; }
  .kit .kt { font-size: 12px; line-height: 1.16; }
  .card.sel::after { display: none; }
}
/* big desktop windows: bigger cards and figures */
@media (min-width: 1200px) and (min-height: 700px) {
  #cards { max-width: 1240px; gap: 22px; }
  #cards .card { max-width: 390px; padding: 14px 20px 20px; gap: 8px; }
  #cards .card .fig.mdl { width: 260px; height: 270px; margin: -4px 0 0; }
  #cards .card .nm { font-size: 26px; letter-spacing: 5px; }
  #cards .card .kits { gap: 10px; }
  .kit { gap: 10px; }
  .kit .tg { width: 26px; height: 26px; font-size: 12px; }
  .kit .kt { font-size: 17px; }
  .kit .kt b { font-size: 14px; }
  .kit .kt em { font-size: 12px; }
  .sel-title { font-size: 34px; letter-spacing: 6px; }
  #selTimer { font-size: 16px; padding: 5px 14px; }
  #select { gap: 22px; }
  .card.sel::after { font-size: 10px; top: 10px; right: 12px; }
}

.primary {
  position: relative; min-width: 220px; min-height: 56px; padding: 0 30px; border-radius: 4px; font-size: 17px; letter-spacing: 4px; font-weight: 900;
  background: linear-gradient(90deg, #ff3df2, #8a5cff 50%, #22e8ff); border: none; color: #05060f;
  box-shadow: 0 0 24px rgba(255, 61, 242, 0.4), 0 0 24px rgba(34, 232, 255, 0.3);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: transform 0.1s, filter 0.2s;
}
.primary:hover { filter: brightness(1.15); }
.primary:active { transform: scale(0.96); }
#btnReady { z-index: 1; }

/* ------------------------------------------------------------- pause + settings */
#pause .panel {
  width: min(600px, 100%); max-height: 100%; overflow-y: auto; touch-action: pan-y; padding: 12px 18px 14px;
  display: flex; flex-direction: column; gap: 9px;
}
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.p-title { font-family: var(--head); font-weight: 900; font-size: 20px; letter-spacing: 5px; color: #fff; text-shadow: 0 0 12px var(--cyan); }
.p-bots { flex: 0 1 300px; }
.p-btns { display: flex; gap: 8px; }
.p-btns .primary { flex: 1.4; min-width: 0; min-height: 52px; }
.ghost { flex: 1; min-height: 52px; border-radius: 4px; border: 1px solid rgba(34,232,255,0.5); background: rgba(34,232,255,0.07); font-size: 12px; letter-spacing: 2px; color: #dff8ff;
  transition: background 0.2s, border-color 0.2s; }
.ghost:hover { background: rgba(34,232,255,0.16); border-color: var(--cyan); }
.ghost:active { transform: scale(0.96); }
.ghost.slim { flex: none; min-height: 40px; padding: 0 14px; font-size: 11px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; min-height: 42px; background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 11px; letter-spacing: 2px; color: var(--dim);
  transition: color 0.2s, border-color 0.2s, background 0.2s; }
.tab:hover { color: #fff; }
.tab.on { color: #fff; border-bottom-color: var(--cyan); background: linear-gradient(0deg, rgba(34, 232, 255, 0.16), transparent); text-shadow: 0 0 8px var(--cyan); }
.tabpanes { min-height: 150px; }
.pane { display: none; flex-direction: column; gap: 9px; padding-top: 4px; }
.pane.on { display: flex; animation: paneIn 0.25s var(--ease); }
@keyframes paneIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.setting { display: flex; flex-direction: column; gap: 4px; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.setting label { display: flex; gap: 8px; align-items: baseline; }
.setting output { font-family: var(--head); font-size: 11px; color: var(--cyan); }
.setting.row { flex-direction: row; justify-content: space-between; align-items: center; }
.setting input[type=range] { width: 100%; height: 30px; accent-color: var(--cyan); touch-action: none; }
.toggle { flex: none; width: 60px; height: 32px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.06); position: relative; transition: background 0.2s, border-color 0.2s; }
.toggle::after { content: ""; position: absolute; top: 4px; left: 5px; width: 22px; height: 22px; border-radius: 50%; background: #8a99aa; transition: left 0.18s var(--ease), background 0.2s; }
.toggle.on { background: rgba(34, 232, 255, 0.22); border-color: var(--cyan); box-shadow: 0 0 10px rgba(34, 232, 255, 0.35); }
.toggle.on::after { left: 31px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.hint, .help { font-family: var(--font); font-weight: 600; font-size: 14px; color: rgba(234,246,255,0.72); line-height: 1.3; }
.hint { color: var(--gold); }
.lime { color: var(--lime); }

/* ------------------------------------------------------------- intro: RR monogram light-line reveal */
#intro {
  position: fixed; inset: 0; z-index: 8; overflow: hidden;
  background: radial-gradient(ellipse at 50% 58%, #170b3a 0%, #070718 55%, #03030a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  transition: opacity 0.45s;
}
#intro.out { opacity: 0; pointer-events: none; }
.intro-floor { position: absolute; left: -50%; right: -50%; bottom: -10%; height: 55%; transform: perspective(380px) rotateX(62deg); transform-origin: 50% 100%;
  background-image: linear-gradient(rgba(34, 232, 255, 0.35) 1px, transparent 1px), linear-gradient(90deg, rgba(34, 232, 255, 0.35) 1px, transparent 1px);
  background-size: 60px 60px; -webkit-mask: linear-gradient(transparent, #000 60%); mask: linear-gradient(transparent, #000 60%);
  opacity: 0; animation: floorIn 1.4s 0.1s ease-out forwards, floorRun 3s linear infinite; }
@keyframes floorIn { to { opacity: 0.55; } }
@keyframes floorRun { to { background-position: 0 60px; } }
.intro-logo { position: relative; width: clamp(150px, 26vw, 300px); }
.rr-logo { display: block; width: 100%; height: auto; overflow: visible; }
.rr-logo use { fill: none; stroke-width: 9; stroke-linecap: square; stroke-linejoin: miter; }
.rr-logo .r1 { stroke: url(#rrCyan); filter: drop-shadow(0 0 4px #22e8ff) drop-shadow(0 0 12px #22e8ff); }
.rr-logo .r2 { stroke: url(#rrMag); filter: drop-shadow(0 0 4px #ff3df2) drop-shadow(0 0 12px #ff3df2); }
.rr-logo.draw use { stroke-dasharray: 100 100; stroke-dashoffset: 100; animation: draw 0.95s cubic-bezier(.6, 0, .2, 1) forwards; }
.rr-logo.draw .r1 { animation-delay: 0.15s; }
.rr-logo.draw .r2 { animation-delay: 0.42s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.intro-logo .sweep { position: absolute; inset: -10% -20%; pointer-events: none; opacity: 0;
  background: linear-gradient(100deg, transparent 40%, rgba(255, 255, 255, 0.75) 50%, transparent 60%); mix-blend-mode: overlay;
  animation: sweep 0.8s 1.25s ease-in-out forwards; }
@keyframes sweep { 0% { opacity: 1; transform: translateX(-60%); } 100% { opacity: 0; transform: translateX(60%); } }
.intro-logo { animation: logoPop 0.5s 1.25s var(--ease) both; }
@keyframes logoPop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.title { font-family: var(--head); font-weight: 900; font-size: clamp(20px, 3.4vw, 46px); letter-spacing: 0.5em; padding-left: 0.5em; white-space: nowrap; color: #fff;
  text-shadow: 0 0 14px rgba(34, 232, 255, 0.55); display: flex; gap: 0.6em;
  opacity: 0; animation: titleIn 0.8s 1.35s var(--ease) forwards; }
.title span { color: var(--mag); text-shadow: 0 0 14px rgba(255, 61, 242, 0.6); }
@keyframes titleIn { 0% { opacity: 0; letter-spacing: 1.2em; filter: blur(6px); } 100% { opacity: 1; letter-spacing: 0.5em; filter: blur(0); } }
#introSub { font-size: clamp(12px, 1vw + 6px, 18px); letter-spacing: 8px; color: rgba(234, 246, 255, 0.6); opacity: 0; animation: fadeIn 0.6s 1.9s forwards; }
#introTap { font-family: var(--head); font-size: 15px; letter-spacing: 6px; color: var(--cyan); animation: blink 1.2s ease-in-out infinite; padding: 16px 40px; margin-top: 6px;
  border-top: 1px solid rgba(34, 232, 255, 0.4); border-bottom: 1px solid rgba(34, 232, 255, 0.4); }
#introLoad { font-family: var(--head); font-size: 11px; letter-spacing: 5px; color: rgba(255,255,255,0.4); margin-top: 6px; }
/* skip: jump every intro animation to its end state */
#intro.skip *, #intro.skip *::before, #intro.skip *::after { animation-delay: 0s !important; animation-duration: 0.01s !important; }
#intro.skip .intro-floor { animation: floorIn 0.01s forwards, floorRun 3s linear infinite !important; }
#intro.skip #introTap { animation: blink 1.2s ease-in-out infinite !important; }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes blink { 50% { opacity: 0.35; } }

/* ------------------------------------------------------------- misc */
#rotate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  font-family: var(--head); font-size: 18px; letter-spacing: 3px; color: #fff; }
#rotate small { font-family: var(--font); font-size: 14px; color: rgba(255,255,255,0.6); letter-spacing: 0; }
.rot-icon { width: 44px; height: 76px; border: 3px solid var(--cyan); border-radius: 10px; animation: rot 1.8s ease-in-out infinite; box-shadow: 0 0 18px var(--cyan); }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) { #rotate { display: flex; } }

#offline { position: fixed; left: 50%; bottom: calc(10px + var(--sb)); transform: translateX(-50%); z-index: 6; font-size: 13px; padding: 6px 12px; border-radius: 4px; background: rgba(0,0,0,0.6); color: var(--gold); }
#debug {
  position: fixed; right: calc(6px + var(--sr)); top: calc(6px + var(--st)); z-index: 20; pointer-events: none;
  font: 11px/1.3 ui-monospace, Menlo, monospace; color: #b6ff3a; background: rgba(0, 0, 0, 0.6); padding: 6px 8px; border-radius: 6px;
  white-space: pre; max-height: 70vh; overflow: hidden;
}

/* ------------------------------------------------------------- main menu: brand left, glass column right, live 3D behind */
#menu {
  flex-direction: row; justify-content: space-between; align-items: center; gap: 24px;
  background: linear-gradient(90deg, rgba(3, 5, 14, 0.82) 0%, rgba(3, 5, 14, 0.25) 46%, rgba(3, 5, 14, 0.15) 60%, rgba(3, 5, 14, 0.7) 100%);
  padding-left: calc(32px + var(--sl)); padding-right: calc(28px + var(--sr));
}
#menu > * { position: relative; }
.menu-grid { position: absolute !important; inset: 0; pointer-events: none; opacity: 0.5;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px); }
.menu-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; animation: brandIn 0.7s var(--ease) both; }
.menu-brand .rr-logo { width: clamp(110px, 13vw, 250px); margin-bottom: 6px; }
.menu-name { font-family: var(--head); font-weight: 900; font-size: clamp(22px, 2.4vw, 50px); letter-spacing: 0.32em; line-height: 1.05; color: #fff; text-shadow: 0 0 16px rgba(34, 232, 255, 0.5); display: flex; flex-direction: column; }
.menu-name span { color: var(--mag); text-shadow: 0 0 16px rgba(255, 61, 242, 0.55); }
.menu-tag { font-size: clamp(12px, 0.5vw + 9px, 18px); letter-spacing: 7px; color: var(--dim); padding-left: 2px; }
.menu-tag::before { content: ""; display: inline-block; width: 26px; height: 1px; background: var(--cyan); vertical-align: middle; margin-right: 10px; box-shadow: 0 0 6px var(--cyan); }
@keyframes brandIn { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
.menu-col { display: flex; flex-direction: column; gap: 10px; width: min(420px, 52vw); padding: 14px 16px 16px; animation: colIn 0.6s 0.08s var(--ease) both; }
@keyframes colIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.mbtn {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 66px; padding: 10px 46px 10px 18px;
  border-radius: 4px; border: 1px solid rgba(34, 232, 255, 0.45); background: linear-gradient(90deg, rgba(34, 232, 255, 0.12), rgba(10, 14, 36, 0.5));
  font-size: 19px; letter-spacing: 4px; text-align: left; color: #fff; overflow: hidden;
  transition: transform 0.15s var(--ease), border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.mbtn small { font-family: var(--font); font-weight: 600; font-size: 14px; letter-spacing: 0.5px; color: rgba(234, 246, 255, 0.74); }
.mbtn .mb-go { position: absolute; right: 18px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-right: 3px solid currentColor; border-top: 3px solid currentColor; transform: rotate(45deg); opacity: 0.7; transition: right 0.2s; }
.mbtn:hover { border-color: var(--cyan); box-shadow: 0 0 20px rgba(34, 232, 255, 0.35); }
.mbtn:hover .mb-go { right: 13px; opacity: 1; }
.mbtn::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.18), transparent); transition: left 0.5s; pointer-events: none; }
.mbtn:hover::after { left: 120%; }
.mbtn.hot { border: none; background: linear-gradient(90deg, rgba(255, 61, 242, 0.92), rgba(138, 92, 255, 0.92) 55%, rgba(34, 232, 255, 0.92)); box-shadow: 0 0 26px rgba(255, 61, 242, 0.4);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); }
.mbtn.hot .mb-t { text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); }
.mbtn.hot small { color: rgba(255, 255, 255, 0.95); }
.mbtn.small { width: auto; min-height: 56px; flex-direction: row; align-items: center; justify-content: center; gap: 8px; font-size: 12px; letter-spacing: 2px; padding: 0 14px; }
.mbtn.small::after { display: none; }
.gear { width: 16px; height: 16px; border-radius: 50%; border: 3px dotted var(--cyan); box-shadow: inset 0 0 0 3px rgba(34, 232, 255, 0.4); }
.mbtn:active { transform: scale(0.97); }
.menu-row { display: flex; gap: 8px; align-items: stretch; }
.chips { display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 4px; background: rgba(5, 9, 24, 0.55); border: 1px solid rgba(214, 240, 255, 0.16); flex: 1; }
.chips-lbl { font-family: var(--head); font-size: 9px; letter-spacing: 2px; color: var(--dim); padding: 0 6px; }
.chips button { flex: 1; min-height: 46px; border-radius: 3px; border: none; background: transparent; font-size: 10.5px; letter-spacing: 1px; color: var(--dim); transition: background 0.2s, color 0.2s; }
.chips button:hover { color: #fff; }
.chips button.on { background: var(--cyan); color: #05060f; box-shadow: 0 0 12px rgba(34,232,255,0.6); }
#pause .chips button { min-height: 40px; }
@media (min-width: 1200px) and (min-height: 700px) {
  .menu-col { width: 480px; gap: 14px; padding: 20px 22px 22px; }
  .mbtn { min-height: 84px; font-size: 24px; padding-left: 24px; }
  .mbtn small { font-size: 17px; }
  .mbtn.small { min-height: 60px; font-size: 13px; }
  .glass-k { font-size: 12px; }
  #menu { padding-left: calc(7vw + var(--sl)); padding-right: calc(6vw + var(--sr)); }
  #pause .panel { width: 680px; padding: 18px 24px 20px; gap: 12px; }
  .p-title { font-size: 26px; }
  .tab { font-size: 13px; min-height: 48px; }
  .setting { font-size: 17px; }
  .help { font-size: 16px; }
}

/* control layout preview: a mini landscape phone */
#layoutPreview { position: relative; width: 100%; max-width: 280px; aspect-ratio: 844 / 390; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(34,232,255,0.05); align-self: center; overflow: hidden; }
#layoutPreview::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed rgba(255,255,255,0.18); }
#layoutPreview > div { position: absolute; border-radius: 50%; }
.lp-joy { width: calc(14.7% * var(--btn-scale)); aspect-ratio: 1; left: 8%; bottom: 14%; border: 2px solid var(--cyan); background: rgba(34,232,255,0.15); }
.lp-look { top: 40%; right: 34%; font-size: 9px; letter-spacing: 1px; color: rgba(255,255,255,0.4); border-radius: 0 !important; }
.lp-jump { width: calc(11.8% * var(--btn-scale)); aspect-ratio: 1; right: 2%; bottom: 3.5%; border: 2px solid #fff; }
.lp-sp { width: calc(11.8% * var(--btn-scale)); aspect-ratio: 1; right: calc(2% + 13.3% * var(--btn-scale)); bottom: calc(3.5% + 14.9% * var(--btn-scale)); border: 2px solid var(--mag); }
.lp-sp2 { width: calc(9.95% * var(--btn-scale)); aspect-ratio: 1; right: calc(2% + 14% * var(--btn-scale)); bottom: calc(3.5% + 43.6% * var(--btn-scale)); border: 2px solid var(--cyan); }
.lp-pause { width: 7.6%; aspect-ratio: 1; left: 1.4%; top: 2.5%; border-radius: 4px !important; border: 2px solid var(--cyan); }
body.lefty .lp-joy { left: auto; right: 8%; }
body.lefty .lp-look { right: auto; left: 34%; }
body.lefty .lp-jump { right: auto; left: 2%; }
body.lefty .lp-sp { right: auto; left: calc(2% + 13.3% * var(--btn-scale)); }
body.lefty .lp-sp2 { right: auto; left: calc(2% + 14% * var(--btn-scale)); }
@media (max-height: 340px) { .mbtn { min-height: 56px; } .menu-brand .rr-logo { width: 96px; } }
@media (max-height: 500px) {
  .menu-col { gap: 8px; padding: 10px 12px 12px; }
  .mbtn { min-height: 62px; font-size: 17px; }
  .mbtn small { font-size: 13px; }
}

/* Low tier: no post-processing, so the vignette is a cheap CSS overlay */
#cssGrade { position: fixed; inset: 0; pointer-events: none; z-index: 1; display: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(4, 0, 18, 0.55) 100%); }
body.css-grade #cssGrade { display: block; }
#touch { z-index: 1; }

/* ------------------------------------------------------------- desktop controls (Round 3): keyboard + mouse, gamepad */
/* body.in-touch | in-kbm | in-pad = the last input method used */
body:not(.in-kbm):not(.in-pad) .desk-only, body:not(.in-pad) .pad-only { display: none !important; }
body.in-kbm .touch-only, body.in-pad .touch-only, body.in-kbm #joyBase, body.in-pad #joyBase,
body.in-kbm #buttons, body.in-pad #buttons { display: none !important; }
body.in-pad #touch { cursor: none; }

kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.9em; height: 1.9em; padding: 0 0.45em;
  border-radius: 0.3em; font-family: var(--head); font-weight: 700; font-size: 0.74em; letter-spacing: 0.5px; line-height: 1;
  color: #05060f; background: linear-gradient(180deg, #f2fbff, #c9e6f5); box-shadow: 0 2px 0 #6f87a8, 0 0 8px rgba(34, 232, 255, 0.35);
}
kbd + kbd { margin-left: 0.25em; }
kbd.face { width: 1.9em; padding: 0; border-radius: 50%; color: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
kbd.f-green { background: #2fc25a; } kbd.f-yellow { background: #e6b422; } kbd.f-red { background: #f2394f; } kbd.f-blue { background: #2f86ff; } kbd.f-pink { background: #e85fc4; }
kbd.sh { background: #c9d6ea; border-radius: 0.6em 0.6em 0.4em 0.4em; }
kbd.stick { width: 1.9em; padding: 0; border-radius: 50%; background: #2a3150; color: #e6f4ff; box-shadow: inset 0 0 0 2px #8fa3c7, 0 0 8px rgba(34, 232, 255, 0.35); }

.kh {
  display: inline-flex; align-items: center; gap: 0.5em; padding: 0.3em 0.75em 0.3em 0.35em; border-radius: 4px;
  background: var(--hud-bg); border: 1px solid rgba(214, 240, 255, 0.16); white-space: nowrap;
  font-family: var(--font); font-weight: 700; font-size: clamp(13px, 0.75vw + 5px, 18px); letter-spacing: 1px; color: rgba(234, 246, 255, 0.9);
}
.kh b { font-weight: inherit; }

#hMenu { position: absolute; left: calc(12px + var(--sl)); top: calc(82px + var(--st)); }
#hMove { position: absolute; left: calc(14px + var(--sl)); bottom: calc(16px + var(--sb)); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
#ctlHints {
  position: absolute; right: calc(16px + var(--sr)); bottom: calc(16px + var(--sb));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#hRow { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 46vw; }
@media (max-width: 1000px) { #hRow { max-width: 36vw; } }   /* wrap into two rows, clear of the stamina bar */
/* [R4] desktop special cards: cooldown ring + keys + name + state, SPECIAL 2 above SPECIAL 1 */
.hsp {
  --c: var(--cyan); position: relative; display: flex; align-items: center; gap: 0.55em;
  min-width: clamp(240px, 16vw, 330px); padding: 0.28em 0.9em 0.28em 0.28em; border-radius: 2em;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 14%, rgba(5, 9, 24, 0.72)), rgba(5, 9, 24, 0.72)); border: 1px solid var(--c);
  font-family: var(--head); font-weight: 700; font-size: clamp(14px, 0.8vw + 6px, 20px); letter-spacing: 1.5px;
}
#hSpecial2 { font-size: clamp(13px, 0.7vw + 5.5px, 18px); }
.hsp .ring { position: relative; flex: none; width: 2.3em; height: 2.3em; }
.hsp .ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hsp circle { fill: rgba(5, 9, 24, 0.6); stroke-width: 8; }
.hsp circle.bg { stroke: rgba(255, 255, 255, 0.14); }
.hsp circle.fg { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 263.9; stroke-dashoffset: 0; }
.hsp .ring em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 0.72em; color: var(--c); }
.hsp .keys { display: inline-flex; font-size: 0.86em; }
.hsp .nm { color: var(--c); }
.hsp .st { margin-left: auto; padding-left: 0.6em; font-size: 0.68em; color: rgba(255, 255, 255, 0.72); font-variant-numeric: tabular-nums; }
.hsp.ready { animation: pulse 1.1s ease-in-out infinite; }
.hsp.ready .nm { color: #fff; text-shadow: 0 0 10px var(--c); }
.hsp.ready .ring em { color: #fff; }
.hsp.cool .nm, .hsp.blocked .nm { opacity: 0.55; }
.hsp.active { background: color-mix(in srgb, var(--c) 40%, rgba(8, 10, 28, 0.7)); }
.hsp.none { display: none; }

#lockHint {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%); padding: 10px 22px; border-radius: 4px; text-align: center;
  background: rgba(5, 9, 24, 0.75); border: 1px solid var(--cyan); box-shadow: 0 0 18px rgba(34, 232, 255, 0.45);
  font-size: clamp(15px, 0.9vw + 8px, 22px); letter-spacing: 4px; color: #fff; animation: blink 1.6s ease-in-out infinite;
}
#lockHint small { display: block; margin-top: 4px; font-family: var(--font); font-weight: 600; font-size: 0.66em; letter-spacing: 1px; color: rgba(234, 246, 255, 0.72); }

.ovl-hint { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ovl-hint .kh { font-size: 12px; padding: 3px 8px 3px 3px; }
.ovl-hint .lead { width: 100%; font-family: var(--head); font-size: 10px; letter-spacing: 3px; color: var(--cyan); }
#selHints { justify-content: center; z-index: 1; }
body.in-kbm .help, body.in-pad .help { line-height: 1.8; }
.help kbd { font-size: 0.8em; height: 1.7em; min-width: 1.7em; }
.help kbd.face, .help kbd.stick { width: 1.7em; }

/* gamepad focus ring in menus */
body.in-pad .pad-focus { outline: 2px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 18px rgba(255, 200, 58, 0.6); }
body.in-pad .card.pad-focus { outline-offset: -1px; }

/* phones: tighter HUD type */
@media (max-height: 500px) {
  #timer { font-size: 22px; min-width: 80px; }
  #topbar { font-size: 10px; gap: 10px; padding: 3px 14px; }
  #survivors b { font-size: 16px; }
  .role { top: calc(50px + var(--st)); font-size: 10px; }
  #toast { top: calc(76px + var(--st)); font-size: 14px; }
  #alert { top: calc(70px + var(--st)); padding: 5px 18px 7px; }
  #tip { font-size: 14px; padding: 6px 8px 6px 6px; }
  .res-card { padding: 12px 24px 14px; }
  .res-stats { margin: 6px 0 2px; }
  #pause .panel { padding: 8px 14px 10px; gap: 7px; }
  .tab { min-height: 38px; }
}
/* big desktop windows: larger HUD type */
@media (min-width: 1200px) and (min-height: 700px) {
  #timer { font-size: 34px; min-width: 120px; }
  #topbar { font-size: 13px; padding: 6px 26px; gap: 20px; }
  #survivors b { font-size: 22px; }
  .role { top: calc(66px + var(--st)); font-size: 13px; padding: 4px 18px; }
  #toast { top: calc(100px + var(--st)); font-size: 18px; }
  #alert { top: calc(104px + var(--st)); }
  #hMenu { top: calc(84px + var(--st)); }
}

/* motion-sensitive players: no animated transitions, no flashing */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  #flash { display: none; }
  .intro-floor { animation: floorIn 0.01ms forwards !important; }
}
