/* ==========================================================================
   Gradicade
   ========================================================================== */
:root {
  --bg: #07030f;
  --bg2: #120826;
  --pink: #ff2bd6;
  --cyan: #00e5ff;
  --yellow: #ffe600;
  --purple: #7c4dff;
  --green: #39ff14;
  --text: #f4ecff;
  --muted: #a99bc9;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --term: 'VT323', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--term); font-size: 20px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--pixel); font-size: 9px; padding: 3px 5px; border-radius: 3px;
  border: 1px solid currentColor; margin: 0 2px; display: inline-block; line-height: 1;
}
.small { font-size: 16px; color: var(--muted); }
body.is-mobile .desktop-only { display: none !important; }
body:not(.is-mobile) .mobile-only { display: none !important; }

/* ---------- 3D scene ---------- */
#scene, #scene canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}
body.booting #scene { filter: blur(6px) brightness(0.55) saturate(1.2); transition: filter 1s; }
/* Phones: a full-screen blur over a live WebGL canvas is very expensive; just dim it. */
body.is-mobile.booting #scene { filter: brightness(0.45); }
body.is-mobile #boot-form { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(10,4,24,0.92); }
#scene { transition: filter 1.2s ease; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--pixel); font-size: 12px; letter-spacing: 1px;
  padding: 14px 22px; border-radius: 6px; border: 2px solid var(--pink);
  background: linear-gradient(180deg, rgba(255,43,214,0.28), rgba(255,43,214,0.08));
  color: #fff; text-shadow: 0 0 8px var(--pink);
  box-shadow: 0 0 14px rgba(255,43,214,0.55), inset 0 0 12px rgba(255,43,214,0.35);
  transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover, .btn:focus-visible { transform: translateY(-1px); box-shadow: 0 0 24px rgba(255,43,214,0.85), inset 0 0 16px rgba(255,43,214,0.5); outline: none; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { border-color: var(--cyan); background: rgba(0,229,255,0.08); text-shadow: 0 0 8px var(--cyan); box-shadow: 0 0 10px rgba(0,229,255,0.4); }
.btn.coin { border-color: var(--yellow); color: var(--yellow); text-shadow: 0 0 10px var(--yellow); background: rgba(255,230,0,0.08); box-shadow: 0 0 18px rgba(255,230,0,0.45), inset 0 0 12px rgba(255,230,0,0.25); }
.link { background: none; border: 0; color: var(--cyan); text-decoration: underline; font-size: 18px; padding: 4px; }

/* ==========================================================================
   Boot screen
   ========================================================================== */
#boot {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(124,77,255,0.25), transparent 60%), rgba(7,3,15,0.55);
  transition: opacity .9s ease, transform .9s ease;
  padding: 16px;
}
#boot.leaving { opacity: 0; transform: scale(1.08); pointer-events: none; }
.boot-inner { position: relative; z-index: 2; text-align: center; width: min(560px, 100%); }
.boot-grid {
  position: absolute; left: -50%; right: -50%; bottom: -10%; height: 55%; z-index: 1;
  background-image:
    linear-gradient(rgba(255,43,214,0.55) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,43,214,0.55) 2px, transparent 2px);
  background-size: 60px 60px;
  transform: perspective(300px) rotateX(62deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(to bottom, transparent, #000 40%);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%);
  animation: gridmove 2.4s linear infinite;
  opacity: .55; pointer-events: none;
}
@keyframes gridmove { to { background-position: 0 60px; } }

.logo { font-family: var(--pixel); margin: 0 0 10px; line-height: 1.15; font-size: clamp(30px, 8vw, 58px); letter-spacing: 2px; }
.logo span { display: inline; }
.logo .l1 { color: #fff; text-shadow: 0 0 6px #fff, 0 0 18px var(--pink), 0 0 36px var(--pink), 0 0 60px var(--pink); animation: flicker 6s infinite; }
.logo .l2 { color: var(--cyan); text-shadow: 0 0 6px #fff, 0 0 18px var(--cyan), 0 0 40px var(--cyan); }
@keyframes flicker { 0%, 92%, 94%, 97%, 100% { opacity: 1; } 93%, 96% { opacity: .35; } }
.tag { font-family: var(--pixel); font-size: 10px; color: var(--yellow); letter-spacing: 2px; margin: 0 0 30px; text-shadow: 0 0 8px rgba(255,230,0,0.6); }

#boot-form {
  background: rgba(12,5,30,0.78); border: 2px solid rgba(0,229,255,0.55); border-radius: 12px;
  padding: 26px 22px 18px; box-shadow: 0 0 30px rgba(0,229,255,0.25), inset 0 0 30px rgba(124,77,255,0.15);
  backdrop-filter: blur(6px);
}
#boot-form label { display: block; font-family: var(--pixel); font-size: 11px; color: var(--cyan); margin-bottom: 14px; letter-spacing: 1px; }
#nick {
  width: 100%; font-family: var(--pixel); font-size: 18px; text-align: center; text-transform: uppercase;
  padding: 14px; border-radius: 6px; border: 2px solid var(--purple); background: #05010c; color: #fff;
  outline: none; caret-color: var(--pink); letter-spacing: 2px;
  user-select: text; -webkit-user-select: text;
}
#nick:focus { border-color: var(--pink); box-shadow: 0 0 16px rgba(255,43,214,0.5); }
#nick::placeholder { color: #4a3a6e; }
#boot-form .btn { margin-top: 16px; width: 100%; font-size: 14px; padding: 16px; }
.welcome { font-family: var(--pixel); font-size: 11px; color: var(--cyan); margin: 0 0 12px; }
.ret-name { font-family: var(--pixel); font-size: 22px; color: #fff; text-shadow: 0 0 12px var(--pink); margin: 0 0 8px; word-break: break-all; }
.err { color: #ff6e6e; min-height: 22px; margin: 10px 0 0; font-size: 19px; }
.hint { font-family: var(--pixel); font-size: 8px; color: var(--muted); margin-top: 22px; line-height: 1.8; }
.loading-line { font-family: var(--pixel); font-size: 9px; color: var(--pink); margin-top: 8px; }
.loading-line .dot { display: inline-block; width: 8px; height: 8px; background: var(--pink); margin-right: 6px; animation: blink 0.8s steps(2) infinite; }
#boot.ready .loading-line { visibility: hidden; }
#boot:not(.ready) #boot-form .btn { opacity: .85; }

/* ==========================================================================
   HUD
   ========================================================================== */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; transition: opacity .4s; }
#hud.dim, #railbar.dim { opacity: 0; pointer-events: none !important; }
#hud.dim * { pointer-events: none !important; }
.hud-player {
  position: absolute; top: calc(14px + var(--safe-t)); left: 16px;
  display: grid; grid-template-columns: auto auto; gap: 2px 12px; align-items: baseline;
  padding: 10px 14px; border-radius: 8px; background: rgba(8,3,20,0.65);
  border: 1px solid rgba(255,43,214,0.5); box-shadow: 0 0 14px rgba(255,43,214,0.25);
}
.hud-player .nick { text-transform: uppercase; grid-column: 1 / -1; font-family: var(--pixel); font-size: 12px; color: #fff; text-shadow: 0 0 8px var(--pink); }
.hud-player .label { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.hud-player .arcade-score { font-family: var(--pixel); font-size: 12px; color: var(--yellow); text-shadow: 0 0 8px rgba(255,230,0,.6); }
.hud-player .rank { grid-column: 1 / -1; font-family: var(--pixel); font-size: 8px; color: var(--cyan); }
.hud-player .rank:empty { display: none; }

.hud-buttons { position: absolute; top: calc(14px + var(--safe-t)); right: 16px; display: flex; gap: 8px; pointer-events: auto; }
.hud-buttons button, .gh-btns button {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px;
  background: rgba(8,3,20,0.7); border: 1px solid rgba(0,229,255,0.55); color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,229,255,0.25); transition: box-shadow .2s, transform .1s;
}
.hud-buttons button:hover, .gh-btns button:hover { box-shadow: 0 0 18px rgba(0,229,255,0.65); }
.hud-buttons button:active { transform: scale(.94); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-action=mute] .off-icon { display: none; }
[data-action=mute].muted .off-icon { display: block; }
[data-action=mute].muted .on-icon { display: none; }
[data-action=mute].muted { color: #ff6e6e; border-color: #ff6e6e; }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px #fff, 0 0 12px var(--pink); opacity: .8;
}
#prompt {
  text-transform: uppercase;
  position: absolute; left: 50%; top: calc(50% + 46px); transform: translate(-50%, 8px);
  font-family: var(--pixel); font-size: 11px; line-height: 1.6; text-align: center; white-space: nowrap;
  padding: 10px 16px; border-radius: 6px; background: rgba(8,3,20,0.75); border: 1px solid rgba(255,255,255,0.25);
  opacity: 0; transition: opacity .18s, transform .18s; color: #fff;
}
#prompt.on { opacity: 1; transform: translate(-50%, 0); }
#prompt b { text-shadow: 0 0 8px currentColor; }
body.is-mobile #prompt { display: none; }
#click-to-look {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--pixel); font-size: 13px; color: #fff; text-align: center; padding: 22px 26px; border-radius: 10px;
  background: rgba(8,3,20,0.6); border: 1px solid rgba(255,43,214,0.5); text-shadow: 0 0 10px var(--pink);
  opacity: 0; transition: opacity .6s; pointer-events: none;
}
#click-to-look small { display: block; margin-top: 12px; font-size: 8px; color: var(--muted); text-shadow: none; }
#click-to-look.on { opacity: 1; }
.hud-keys { position: absolute; bottom: 16px; left: 16px; font-family: var(--pixel); font-size: 8px; color: var(--muted); opacity: .8; }
.hud-keys kbd { color: var(--cyan); margin-left: 10px; }
.hud-keys kbd:first-child { margin-left: 0; }

#toasts { position: fixed; top: calc(80px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 40; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  text-transform: uppercase;
  font-family: var(--pixel); font-size: 10px; line-height: 1.6; text-align: center; padding: 12px 18px; border-radius: 8px;
  background: rgba(8,3,20,0.85); border: 1px solid var(--cyan); box-shadow: 0 0 16px rgba(0,229,255,0.4);
  opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s;
}
.toast.on { opacity: 1; transform: none; }

/* ---------- Mobile rail bar ---------- */
#railbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 8px;
  padding: 12px 16px calc(14px + var(--safe-b));
  background: linear-gradient(to top, rgba(7,3,15,0.92), rgba(7,3,15,0));
  transition: opacity .4s;
}
#railbar > button {
  height: 64px; font-size: 42px; line-height: 1; border-radius: 50%; border: 2px solid var(--cyan);
  background: rgba(8,3,20,0.7); color: var(--cyan); box-shadow: 0 0 14px rgba(0,229,255,0.4);
}
.rail-mid { text-align: center; }
.rail-label { font-family: var(--pixel); font-size: 11px; text-transform: uppercase; margin-bottom: 8px; text-shadow: 0 0 8px var(--pink); min-height: 14px; }
.rail-play { min-width: 150px; }
.rail-row { display: flex; gap: 10px; justify-content: center; align-items: center; }
.rail-menu {
  width: 48px; height: 48px; border-radius: 10px; border: 2px solid var(--pink); background: rgba(8,3,20,0.75);
  color: var(--pink); box-shadow: 0 0 12px rgba(255,43,214,0.4); display: grid; place-items: center; padding: 0;
}
.rail-menu svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
.rail-menu:active { transform: scale(.94); }
.machine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mc {
  --c: var(--cyan); display: flex; flex-direction: column; border-radius: 8px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: rgba(255,255,255,0.03);
}
.mc.on { box-shadow: 0 0 0 2px var(--c), 0 0 16px color-mix(in srgb, var(--c) 50%, transparent); }
.mc.dim { opacity: .55; }
.mc-go { flex: 1; text-align: left; background: none; border: 0; color: var(--text); padding: 10px 10px 8px; min-height: 64px; }
.mc-go b { display: block; font-family: var(--pixel); font-size: 8px; line-height: 1.5; color: var(--c); text-shadow: 0 0 8px color-mix(in srgb, var(--c) 60%, transparent); text-transform: uppercase; }
.mc-go span { display: block; font-family: var(--term); font-size: 17px; color: var(--muted); margin-top: 4px; }
.mc-act {
  border: 0; border-top: 1px solid color-mix(in srgb, var(--c) 40%, transparent); padding: 9px 4px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: #fff; font-family: var(--pixel); font-size: 8px;
}
.mc-act:active { background: color-mix(in srgb, var(--c) 40%, transparent); }
body.is-mobile .hud-player { top: calc(10px + var(--safe-t)); left: 10px; padding: 8px 10px; }
body.is-mobile .hud-buttons { top: calc(10px + var(--safe-t)); right: 10px; gap: 6px; }
body.is-mobile .hud-buttons button { width: 40px; height: 40px; }

/* ==========================================================================
   Game layer
   ========================================================================== */
#game-layer { position: fixed; inset: 0; z-index: 20; --game-color: var(--pink); }
#game-layer::before {
  content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, #120626 0%, #030108 75%);
  opacity: 0; transition: opacity .35s ease;
}
#game-layer.shown::before { opacity: 1; }
.game-frame { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 14px 14px; }
.game-hud {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 4px 12px; opacity: 0; transform: translateY(-10px); transition: opacity .35s .1s, transform .35s .1s;
}
#game-layer.shown .game-hud { opacity: 1; transform: none; }
.gh-title { font-family: var(--pixel); font-size: 13px; text-transform: uppercase; text-shadow: 0 0 10px currentColor; margin-right: auto; }
.gh-stat { display: flex; flex-direction: column; gap: 4px; }
.gh-stat span { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.gh-stat b { font-family: var(--pixel); font-size: 13px; font-weight: normal; color: #fff; min-width: 3ch; }
#gh-score.beating { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }
.lives { color: #ff4d8d; letter-spacing: 2px; }
.gh-status { font-family: var(--pixel); font-size: 8px; color: #ff9e40; }
.gh-btns { display: flex; gap: 8px; }
.gh-btns button { width: 40px; height: 40px; }

.gh-btns #gh-music.on { background: rgba(0,229,255,0.18); }
/* In-game music panel: drops down under the header, over the screen. */
.gm-panel {
  position: absolute; z-index: 20; right: 14px; top: calc(70px + var(--safe-t)); width: min(300px, calc(100vw - 28px));
  padding: 14px; border-radius: 12px; background: rgba(8,3,20,0.94); border: 1px solid rgba(0,229,255,0.55);
  box-shadow: 0 0 24px rgba(0,229,255,0.3); display: flex; flex-direction: column; gap: 9px; font-family: var(--pixel);
}
.gm-panel[hidden] { display: none; }
.gm-now span { display: block; font-size: 7px; color: var(--muted); margin-bottom: 5px; }
.gm-now b { display: block; font-size: 11px; font-weight: normal; text-shadow: 0 0 8px currentColor; }
.gm-now small { display: block; font-size: 7px; color: #c8c0ff; margin-top: 5px; }
.gm-ctrl { display: flex; gap: 8px; justify-content: center; }
.gm-ctrl button, .gm-energy button {
  display: grid; place-items: center; border-radius: 8px; background: rgba(8,3,20,0.7);
  border: 1px solid rgba(0,229,255,0.55); color: var(--cyan); cursor: pointer;
}
.gm-ctrl button { width: 44px; height: 38px; }
.gm-ctrl button:hover, .gm-energy button:hover { box-shadow: 0 0 14px rgba(0,229,255,0.6); }
#gm-play .ic-pause, #gm-play.playing .ic-play { display: none; }
#gm-play.playing .ic-pause { display: block; }
.gm-label { font-size: 7px; color: var(--muted); display: flex; justify-content: space-between; }
.gm-label b { color: #fff; font-weight: normal; }
.gm-energy { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.gm-energy button { font-family: var(--pixel); font-size: 7px; padding: 8px 0; }
.gm-energy button.on { background: rgba(0,229,255,0.22); color: #fff; box-shadow: 0 0 10px rgba(0,229,255,0.5); }
.gm-panel input[type=range] { width: 100%; accent-color: #00e5ff; }

.game-stage { position: relative; flex: 1; display: grid; place-items: center; min-height: 0; }
.game-screen {
  position: relative; border-radius: 14px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 3px #1a1030, 0 0 0 6px color-mix(in srgb, var(--game-color) 60%, transparent), 0 0 50px color-mix(in srgb, var(--game-color) 45%, transparent);
  will-change: transform;
}
#game-layer.zooming .game-screen { box-shadow: none; border-radius: 4px; }
#game-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.crt-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.55) 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
  animation: crtflicker 0.15s infinite;
}
@keyframes crtflicker { 50% { opacity: .94; } }

.game-msg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; padding: 8px; transition: opacity .25s; }
#game-layer.zooming .game-msg { opacity: 0; }
.game-msg .panel, .game-msg button { pointer-events: auto; }
.panel {
  text-align: center; padding: 22px 24px; border-radius: 10px; max-width: min(520px, 92%); max-height: 100%; overflow: auto;
  background: rgba(5,1,14,0.86); border: 2px solid var(--game-color); box-shadow: 0 0 26px color-mix(in srgb, var(--game-color) 50%, transparent);
}
.panel h2 { font-family: var(--pixel); font-size: 20px; text-transform: uppercase; margin: 0 0 12px; color: #fff; text-shadow: 0 0 12px var(--game-color); }
.panel .desc { margin: 0 0 12px; font-size: 20px; color: var(--text); }
.panel .help { list-style: none; padding: 0; margin: 0 0 14px; font-family: var(--pixel); font-size: 8px; line-height: 2; color: var(--cyan); }
.panel .meta { font-family: var(--pixel); font-size: 8px; color: var(--yellow); line-height: 1.8; margin: 8px 0 14px; }
.panel .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.panel .small { margin: 12px 0 0; font-family: var(--pixel); font-size: 7px; line-height: 1.8; }
.big-score { font-family: var(--pixel); font-size: 30px; color: var(--yellow); text-shadow: 0 0 16px rgba(255,230,0,.7); margin: 4px 0 10px; }
.new-best { font-family: var(--pixel); font-size: 10px; color: var(--green); text-shadow: 0 0 10px var(--green); margin: 0 0 8px; }
.saving { font-family: var(--pixel); font-size: 8px; color: var(--muted); }
.mini-board { list-style: none; padding: 0; margin: 6px auto 0; max-width: 320px; text-align: left; font-family: var(--pixel); font-size: 9px; }
.mini-board li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; padding: 5px 6px; border-radius: 4px; }
.mini-board li.me { background: rgba(255,43,214,0.2); color: #fff; }
.mini-board b { font-weight: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-board em { font-style: normal; color: var(--yellow); }
.count {
  font-family: var(--pixel); font-size: clamp(48px, 12vw, 110px); color: #fff;
  text-shadow: 0 0 20px var(--game-color), 0 0 50px var(--game-color); animation: countpop .6s ease-out;
}
@keyframes countpop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.blink { animation: blink 1s steps(2) infinite; }
.blink-slow { animation: pulse 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes pulse { 50% { opacity: 0.55; } }

#flash { position: fixed; inset: 0; z-index: 25; pointer-events: none; opacity: 0; background: radial-gradient(circle, #fff 0%, rgba(255,43,214,0.6) 40%, transparent 75%); }
#flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- Touch pad ---------- */
#touchpad {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: 0;
  padding: 0 18px calc(18px + var(--safe-b));
}
.dpad {
  position: absolute; left: 18px; bottom: calc(18px + var(--safe-b)); width: 150px; height: 150px;
  display: grid; grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
}
.dpad.lr { height: 70px; width: 170px; grid-template: 1fr / 1fr 1fr; gap: 14px; }
.pad-btn {
  border-radius: 12px; border: 2px solid rgba(0,229,255,0.65); background: rgba(8,3,20,0.55);
  color: #fff; box-shadow: 0 0 12px rgba(0,229,255,0.3); touch-action: none; position: relative;
  font-family: var(--pixel); font-size: 10px;
}
.pad-btn.on { background: rgba(0,229,255,0.35); box-shadow: 0 0 22px rgba(0,229,255,0.8); }
.pad-btn[class*=dir-]::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: -8px 0 0 -8px;
  border: 8px solid transparent;
}
.dir-up { grid-area: 1 / 2; } .dir-up::after { border-bottom-color: var(--cyan) !important; margin-top: -12px !important; }
.dir-down { grid-area: 3 / 2; } .dir-down::after { border-top-color: var(--cyan) !important; margin-top: -4px !important; }
.dir-left { grid-area: 2 / 1; } .dir-left::after { border-right-color: var(--cyan) !important; margin-left: -12px !important; }
.dir-right { grid-area: 2 / 3; } .dir-right::after { border-left-color: var(--cyan) !important; margin-left: -4px !important; }
.dpad.lr .dir-left { grid-area: 1 / 1; } .dpad.lr .dir-right { grid-area: 1 / 2; }
.abtns { position: absolute; right: 18px; bottom: calc(26px + var(--safe-b)); display: flex; gap: 14px; align-items: flex-end; }
.abtns .pad-btn { width: 76px; height: 76px; border-radius: 50%; border-color: var(--pink); box-shadow: 0 0 14px rgba(255,43,214,0.4); }
.abtns .act-b { width: 64px; height: 64px; margin-bottom: 30px; border-color: var(--yellow); }
.abtns .pad-btn.on { background: rgba(255,43,214,0.4); }
/* Phones, portrait: a slim frame so the screen gets nearly the full width. */
body.is-mobile .game-frame { padding: calc(6px + var(--safe-t)) 4px 4px; padding-bottom: calc(190px + var(--safe-b)); }
body.is-mobile .game-hud { gap: 8px 12px; padding: 2px 4px 6px; }
body.is-mobile .gh-title { font-size: 9px; width: 100%; }
body.is-mobile .gh-stat span { font-size: 6px; }
body.is-mobile .gh-stat b { font-size: 11px; }
body.is-mobile .gh-btns button { width: 38px; height: 38px; }
body.is-mobile .game-screen { border-radius: 8px; }
#gh-rotate.on { background: rgba(0,229,255,0.18); }

/* Phones, landscape (turned sideways, or the layer turned by the rotate button): the screen takes
   the full height; the score sits in a slim column on the left, the buttons in one on the right,
   and the touch controls float over the screen's edges. */
body.is-mobile.land .game-frame { padding: 4px 56px 4px; }
body.is-mobile.land .game-hud { position: absolute; left: 4px; top: 6px; width: 48px; flex-direction: column; align-items: center; gap: 8px; padding: 0; z-index: 4; }
body.is-mobile.land .gh-title { display: none; }
body.is-mobile.land .gh-stat { align-items: center; }
body.is-mobile.land .gh-stat b { font-size: 9px; min-width: 0; }
body.is-mobile.land .gh-status { font-size: 6px; text-align: center; }
body.is-mobile.land .gh-btns { position: fixed; right: 6px; top: 6px; flex-direction: column; gap: 6px; z-index: 4; }
body.is-mobile.land .gh-btns button { width: 40px; height: 40px; }
body.is-mobile.land .dpad { left: 10px; bottom: 10px; }
body.is-mobile.land .abtns { right: 10px; bottom: 14px; }
body.is-mobile.land #touchpad.fill .dpad { left: 60px; }
body.is-mobile.land #touchpad.fill .abtns { right: 60px; }
body.is-mobile.land #touchpad.fill .pad-btn { background: rgba(8,3,20,0.22); }
body.is-mobile.land #touchpad.fill.alpha-solid .pad-btn { opacity: .72; }
body.is-mobile.land .gm-panel { top: 8px; right: 54px; }

/* The rotate button's fallback (phones that can't lock orientation): turn the whole game layer. */
body.rotated #game-layer { right: auto; bottom: auto; transform-origin: 0 0; transform: rotate(90deg) translateY(-100%); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(3,1,8,0.7); backdrop-filter: blur(4px); opacity: 0; transition: opacity .25s;
}
.modal.on { opacity: 1; }
.sheet {
  position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(180deg, #160a30, #0a0418); border: 2px solid var(--pink); border-radius: 14px;
  padding: 24px 22px; box-shadow: 0 0 40px rgba(255,43,214,0.35); transform: translateY(14px); transition: transform .25s;
}
.sheet.wide { width: min(680px, 100%); }
.modal.on .sheet { transform: none; }
.sheet h2 { font-family: var(--pixel); font-size: 18px; margin: 0 0 6px; color: var(--yellow); text-shadow: 0 0 12px rgba(255,230,0,.6); }
.sheet .sub { font-family: var(--pixel); font-size: 8px; color: var(--muted); margin: 0 0 16px; line-height: 1.6; }
.sheet p { line-height: 1.3; }
.close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; background: none; color: var(--pink); font-size: 32px; line-height: 1; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; scrollbar-width: thin; }
@media (min-width: 700px) { .tabs { flex-wrap: wrap; overflow: visible; } }
.tab {
  --c: var(--cyan);
  flex: none; text-transform: uppercase; font-family: var(--pixel); font-size: 8px; padding: 10px 12px; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); background: transparent; color: var(--c);
}
.tab.on { background: color-mix(in srgb, var(--c) 22%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 50%, transparent); color: #fff; }
.periods { display: flex; gap: 6px; margin-bottom: 14px; }
.periods button { flex: 1; font-family: var(--pixel); font-size: 7px; padding: 9px 4px; border-radius: 4px; border: 1px solid #3c2a66; background: transparent; color: var(--muted); }
.periods button.on { color: #fff; border-color: var(--purple); background: rgba(124,77,255,0.25); }
.board { list-style: none; margin: 0; padding: 0; font-family: var(--pixel); font-size: 10px; max-height: 46vh; overflow: auto; }
.board li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; padding: 10px 8px; border-bottom: 1px dashed #2a1c4a; align-items: center; }
.board .rk { color: var(--muted); }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .sc { color: var(--yellow); }
.board li.top1 .rk, .board li.top1 .nm { color: var(--yellow); text-shadow: 0 0 8px rgba(255,230,0,.6); }
.board li.top2 .rk, .board li.top2 .nm { color: #e0e0e0; }
.board li.top3 .rk, .board li.top3 .nm { color: #ff9e40; }
.board li.me { background: rgba(255,43,214,0.18); border-radius: 6px; }
.board li.loading, .board li.empty { display: block; text-align: center; color: var(--muted); padding: 30px 0; border: 0; }
.you { margin-top: 14px; font-family: var(--pixel); font-size: 10px; color: var(--cyan); text-align: center; }

.now { text-align: center; padding: 16px; border-radius: 10px; background: rgba(0,0,0,0.35); border: 1px solid #2a1c4a; margin: 12px 0 16px; }
.np-label { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.np-title { font-family: var(--pixel); font-size: 15px; margin: 10px 0 6px; text-shadow: 0 0 12px currentColor; }
.np-info, .np-time { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.np-bar { height: 6px; border-radius: 3px; background: #22163e; margin: 14px 0 6px; overflow: hidden; }
#jb-progress { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--cyan)); box-shadow: 0 0 10px var(--pink); transition: width .5s linear; }
.np-ctrls { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; }
.np-ctrls button { width: 46px; height: 46px; border-radius: 50%; border: 1px solid #3c2a66; background: rgba(8,3,20,0.6); color: var(--cyan); display: grid; place-items: center; }
.np-ctrls button.big { width: 60px; height: 60px; border: 2px solid var(--pink); color: #fff; box-shadow: 0 0 16px rgba(255,43,214,0.5); }
.np-ctrls button.on { color: var(--yellow); border-color: var(--yellow); }
.np-ctrls button.txt { width: auto; padding: 0 12px; border-radius: 23px; font-family: var(--pixel); font-size: 7px; }
#jb-play .pause { display: none; }
#jb-play.playing .pause { display: block; }
#jb-play.playing .play { display: none; }
.vols { display: grid; gap: 10px; margin-bottom: 16px; }
.vols label { display: grid; grid-template-columns: 80px 1fr; align-items: center; font-family: var(--pixel); font-size: 8px; color: var(--muted); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: #22163e; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 10px var(--pink); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--pink); box-shadow: 0 0 10px var(--pink); cursor: pointer; }
.playlist { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow: auto; }
.playlist li { --c: var(--cyan); display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 10px 8px; border-radius: 6px; cursor: pointer; font-size: 21px; align-items: center; }
.playlist li:hover { background: rgba(255,255,255,0.05); }
.playlist li.on { background: color-mix(in srgb, var(--c) 18%, transparent); color: #fff; }
.playlist li.on .t { color: var(--c); text-shadow: 0 0 8px var(--c); }
.playlist .n { font-family: var(--pixel); font-size: 8px; color: var(--muted); }
.playlist .d { color: var(--muted); }
.playlist .t small { display: block; font-family: var(--pixel); font-size: 6px; letter-spacing: 1px; color: var(--muted); margin-top: 3px; }
.playlist li.on .t small { color: var(--c); text-shadow: none; opacity: .8; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-family: var(--pixel); font-size: 8px; line-height: 1.6; margin: 16px 0; align-items: center; }
.help-grid div:nth-child(odd) { color: var(--cyan); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--pixel); }

@media (max-width: 560px) {
  html, body { font-size: 18px; }
  .tag { font-size: 8px; line-height: 1.8; letter-spacing: 1px; }
  .panel { padding: 16px 14px; max-width: 100%; }
  .panel h2 { font-size: 15px; }
  .panel .desc { font-size: 18px; }
  .panel .help { font-size: 7px; }
  .big-score { font-size: 24px; }
  .panel .btn { padding: 12px 16px; font-size: 10px; }
  .hud-player .nick { font-size: 10px; }
  .hud-player .arcade-score { font-size: 10px; }
  .board { font-size: 9px; }
  .board li { grid-template-columns: 34px 1fr auto; }
  .sheet { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-grid, .logo .l1, .crt-overlay, #click-to-look { animation: none; }
}

/* ==========================================================================
   Vibe Station (docked so the arcade stays visible while you change it)
   ========================================================================== */
.modal.dock { background: linear-gradient(90deg, transparent 40%, rgba(3,1,8,0.45)); backdrop-filter: none; place-items: stretch end; padding: 12px; }
.modal.dock .sheet { width: min(430px, 100%); max-height: calc(100vh - 24px); transform: translateX(24px); display: flex; flex-direction: column; padding: 20px 18px 16px; border-color: #39ffb0; box-shadow: 0 0 40px rgba(57,255,176,0.25); background: linear-gradient(180deg, rgba(22,10,48,0.94), rgba(10,4,24,0.94)); }
.modal.dock.on .sheet { transform: none; }
.modal.dock h2 { color: #39ffb0; text-shadow: 0 0 12px rgba(57,255,176,.6); }
.vb-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.vb-tabs button { flex: 1; font-family: var(--pixel); font-size: 7px; padding: 10px 4px; border-radius: 6px; border: 1px solid #3c2a66; background: transparent; color: var(--muted); }
.vb-tabs button.on { color: #fff; border-color: #39ffb0; background: rgba(57,255,176,0.16); box-shadow: 0 0 12px rgba(57,255,176,0.35); }
.vb-pane { flex: 1; min-height: 0; overflow: auto; padding: 2px; }
.vb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vb-card {
  --c: var(--pink); position: relative; display: flex; flex-direction: column; text-align: left; gap: 4px;
  padding: 0 0 10px; border-radius: 10px; overflow: hidden; background: rgba(255,255,255,0.03);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); transition: transform .12s, box-shadow .2s;
}
.vb-card:hover { transform: translateY(-1px); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent); }
.vb-card.on { box-shadow: 0 0 0 2px var(--c), 0 0 18px color-mix(in srgb, var(--c) 55%, transparent); }
.vb-card.on::after { content: 'ON'; position: absolute; top: 6px; right: 6px; font-family: var(--pixel); font-size: 7px; padding: 4px 5px; border-radius: 4px; background: var(--c); color: #05020e; }
.vb-sw { display: block; height: 64px; border-bottom: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.vb-card b { font-family: var(--pixel); font-size: 8px; line-height: 1.5; color: var(--c); padding: 0 10px; text-transform: uppercase; text-shadow: 0 0 8px color-mix(in srgb, var(--c) 50%, transparent); }
.vb-card small { font-size: 15px; line-height: 1.1; color: var(--muted); padding: 0 10px; }
.vb-card.piece { padding-top: 10px; }
.vb-icon { font-size: 30px; line-height: 1; padding: 2px 10px 4px; color: var(--c); text-shadow: 0 0 12px var(--c); }
.vb-music { text-align: center; padding: 16px 8px; display: grid; gap: 12px; justify-items: center; }
#vb-play svg { display: block; }
.vb-presets { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #2a1c4a; }
.vb-presets > span { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.vb-preset-row { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: thin; }
.vb-preset-row button { --c: var(--pink); flex: none; font-family: var(--pixel); font-size: 7px; padding: 9px 10px; border-radius: 16px; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); color: #fff; }
.vb-preset-row button:active { transform: scale(.96); }
body.is-mobile .modal.dock { place-items: end stretch; padding: 0; background: linear-gradient(0deg, rgba(3,1,8,0.5), transparent 55%); }
body.is-mobile .modal.dock .sheet { width: 100%; max-height: 56vh; border-radius: 16px 16px 0 0; transform: translateY(30px); padding-bottom: calc(14px + var(--safe-b)); }
body.is-mobile .modal.dock.on .sheet { transform: none; }
@media (orientation: landscape) and (max-height: 520px) {
  body.is-mobile .modal.dock { place-items: stretch end; }
  body.is-mobile .modal.dock .sheet { width: min(420px, 60vw); max-height: 100vh; border-radius: 16px 0 0 16px; }
}

/* ==========================================================================
   Touch-control layouts (mobile). #touchpad gets lay-* / size-* / alpha-* classes.
   ========================================================================== */
#touchpad { --pad: 1; --gap: 14px; }
#touchpad.size-s { --pad: 0.82; } #touchpad.size-l { --pad: 1.18; } #touchpad.size-xl { --pad: 1.36; }
#touchpad .dpad { width: calc(150px * var(--pad)); height: calc(150px * var(--pad)); }
#touchpad .dpad.lr { width: calc(170px * var(--pad)); height: calc(70px * var(--pad)); }
#touchpad .abtns .pad-btn { width: calc(76px * var(--pad)); height: calc(76px * var(--pad)); font-size: calc(10px * var(--pad)); }
#touchpad .abtns .act-b { width: calc(64px * var(--pad)); height: calc(64px * var(--pad)); margin-bottom: calc(30px * var(--pad)); }
#touchpad.alpha-soft .pad-btn { opacity: .7; }
#touchpad.alpha-ghost .pad-btn { opacity: .38; background: rgba(8,3,20,0.2); }
#touchpad .pad-btn.on { opacity: 1; }
/* Swapped two-hand: arrows right, buttons left. */
#touchpad.lay-swap .dpad { left: auto; right: 18px; }
#touchpad.lay-swap .abtns { right: auto; left: 18px; flex-direction: row-reverse; }
/* One-hand clusters: arrows + buttons side by side, anchored left / centre / right. */
#touchpad[class*="lay-one"] .cluster { position: absolute; bottom: calc(18px + var(--safe-b)); display: flex; align-items: flex-end; gap: 10px; }
#touchpad[class*="lay-one"] .dpad, #touchpad[class*="lay-one"] .abtns { position: relative; left: auto; right: auto; bottom: auto; }
#touchpad[class*="lay-one"] .abtns { flex-direction: column-reverse; gap: 10px; align-items: center; }
#touchpad[class*="lay-one"] .abtns .act-b { margin-bottom: 0; }
#touchpad.lay-one-left .cluster { left: 14px; }
#touchpad.lay-one-right .cluster { right: 14px; flex-direction: row-reverse; }
#touchpad.lay-one-center .cluster { left: 50%; transform: translateX(-50%); }
/* Split arrows: left arrow hard left, right arrow hard right, buttons in the middle. */
#touchpad.lay-split .dpad.lr { position: static; width: auto; height: 0; display: block; }
#touchpad.lay-split .dpad.lr .dir-left, #touchpad.lay-split .dpad.lr .dir-right {
  position: absolute; bottom: calc(18px + var(--safe-b)); width: calc(92px * var(--pad)); height: calc(110px * var(--pad));
}
#touchpad.lay-split .dpad.lr .dir-left { left: 12px; }
#touchpad.lay-split .dpad.lr .dir-right { right: 12px; }
#touchpad.lay-split .abtns { right: auto; left: 50%; transform: translateX(-50%); }
/* Buttons-only games: split A/B to the screen edges. */
#touchpad.lay-split.no-dpad .abtns { left: 12px; right: 12px; transform: none; justify-content: space-between; }
#touchpad.lay-split.no-dpad .abtns .act-b { margin-bottom: 0; }
body.is-mobile .game-frame.pad-tall { padding-bottom: calc(240px + var(--safe-b)); }
body.is-mobile.land .game-frame.pad-tall { padding-bottom: 4px; }
body.is-mobile.land #touchpad[class*="lay-one"] .cluster { bottom: 10px; }
body.is-mobile.land #touchpad.lay-swap .dpad { right: 10px; left: auto; } body.is-mobile.land #touchpad.lay-swap .abtns { left: 10px; right: auto; }
body.is-mobile.land #touchpad.fill.lay-swap .dpad { right: 60px; } body.is-mobile.land #touchpad.fill.lay-swap .abtns { left: 60px; }
body.is-mobile.land #touchpad.lay-split .dpad.lr .dir-left { left: 8px; } body.is-mobile.land #touchpad.lay-split .dpad.lr .dir-right { right: 8px; }

/* Touch-control settings sheet */
#pad-settings { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 14px; background: rgba(3,1,8,0.55); }
.ps-sheet { width: min(420px, 100%); max-height: 100%; overflow: auto; padding: 18px 16px; border-radius: 12px; background: rgba(10,4,24,0.95); border: 2px solid var(--cyan); box-shadow: 0 0 26px rgba(0,229,255,0.35); }
.ps-sheet h3 { font-family: var(--pixel); font-size: 13px; margin: 0 0 6px; color: var(--cyan); text-shadow: 0 0 10px rgba(0,229,255,.6); }
.ps-sub { font-family: var(--pixel); font-size: 7px; color: var(--muted); margin: 0 0 12px; line-height: 1.7; }
.ps-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.ps-group button { display: grid; gap: 6px; justify-items: center; padding: 10px 6px; border-radius: 8px; border: 1px solid #3c2a66; background: rgba(255,255,255,0.03); color: var(--text); font-family: var(--pixel); font-size: 7px; line-height: 1.5; }
.ps-group button.on, .ps-row button.on { border-color: var(--cyan); background: rgba(0,229,255,0.16); color: #fff; box-shadow: 0 0 12px rgba(0,229,255,0.35); }
.ps-mini { width: 92px; height: 40px; border-radius: 6px; background: #05020e; border: 1px solid #2a1c4a; position: relative; }
.ps-mini i { position: absolute; bottom: 5px; width: 14px; height: 14px; border-radius: 3px; background: var(--cyan); }
.ps-mini i.b { border-radius: 50%; background: var(--pink); width: 12px; height: 12px; }
.ps-label { font-family: var(--pixel); font-size: 7px; color: var(--muted); margin: 6px 0; }
.ps-row { display: flex; gap: 6px; margin-bottom: 8px; }
.ps-row button { flex: 1; padding: 10px 4px; border-radius: 6px; border: 1px solid #3c2a66; background: transparent; color: var(--muted); font-family: var(--pixel); font-size: 8px; }
.ps-note { font-size: 15px; color: var(--muted); margin: 8px 0 0; }
.ps-actions { display: flex; justify-content: center; margin-top: 10px; }
#touchpad .cluster { display: contents; }
#touchpad[class*="lay-one"] .cluster { display: flex; }
/* Narrow phones: stack the HUD buttons down the right edge so they never cover the score box. */
@media (max-width: 520px) {
  body.is-mobile .hud-buttons { flex-direction: column; gap: 6px; }
  body.is-mobile .hud-buttons button { width: 38px; height: 38px; }
}

/* 3D games: WebGL canvas under a transparent, smooth HUD canvas. */
.game-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.game-screen.webgl #game-canvas { position: relative; image-rendering: auto; }
.game-screen.webgl .crt-overlay { opacity: 0.3; }

/* Storage consent toggle on the entry screen. */
.consent { display: flex; gap: 10px; align-items: flex-start; text-align: left; margin: 14px auto 4px; max-width: 420px; cursor: pointer; font-size: 11px; line-height: 1.45; color: #b8b0d8; }
.consent input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.consent .switch { flex: 0 0 auto; width: 38px; height: 20px; border-radius: 12px; background: #2a2040; border: 1px solid #5a4c88; position: relative; margin-top: 2px; transition: background .2s; }
.consent .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #8a7cb8; transition: transform .2s, background .2s; }
.consent input:checked + .switch { background: #0a4a3a; border-color: #39ffb0; }
.consent input:checked + .switch::after { transform: translateX(18px); background: #39ffb0; box-shadow: 0 0 8px #39ffb0; }
.consent input:focus-visible + .switch { outline: 2px solid #00e5ff; outline-offset: 2px; }
.consent-text b { display: block; color: #fff; letter-spacing: 0.06em; margin-bottom: 2px; }
.privacy .link { margin-left: 6px; }
#boot-form label.consent { display: flex; font-family: inherit; font-size: 11px; color: #b8b0d8; letter-spacing: 0; margin: 14px auto 6px; text-transform: none; }
#boot-form label.consent .consent-text { font-family: system-ui, sans-serif; font-size: 11.5px; line-height: 1.45; }
#boot-form label.consent .consent-text b { font-family: var(--pixel); font-size: 10px; color: #fff; }

/* Four action buttons (fighting): a 2x2 face-button grid. BLOCK | SPECIAL over KICK | PUNCH. */
#touchpad .abtns.quad { display: grid; grid-template-columns: auto auto; grid-template-areas: "d c" "b a"; gap: calc(10px * var(--pad)); align-items: center; justify-items: center; }
#touchpad .abtns.quad .pad-btn { width: calc(66px * var(--pad)); height: calc(66px * var(--pad)); margin: 0; font-size: calc(9px * var(--pad)); }
#touchpad .abtns.quad .act-a { grid-area: a; width: calc(74px * var(--pad)); height: calc(74px * var(--pad)); }
#touchpad .abtns.quad .act-b { grid-area: b; border-color: var(--yellow); }
#touchpad .abtns.quad .act-c { grid-area: c; border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,229,255,0.4); }
#touchpad .abtns.quad .act-d { grid-area: d; border-color: #39ffb0; box-shadow: 0 0 14px rgba(57,255,176,0.35); }
#touchpad .abtns.quad .act-c.on { background: rgba(0,229,255,0.35); }
#touchpad .abtns.quad .act-d.on { background: rgba(57,255,176,0.3); }

/* Pause menu: a vertical list (keyboard focus highlighted). */
.panel.pause .menu-list { display: flex; flex-direction: column; gap: 8px; margin: 14px auto 8px; max-width: 280px; }
.panel.pause .menu-list .btn { width: 100%; }
.panel.pause .menu-list .btn.focus { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 18px var(--game-color); }
.panel.pause { max-height: calc(100% - 16px); overflow-y: auto; }
.panel.pause .menu-list { gap: 6px; }
.panel.pause .menu-list .btn { padding: 8px 12px; font-size: 11px; }

/* ---------- Game library ---------- */
#games-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 6; display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 12px 14px; border-radius: 999px; border: 2px solid var(--yellow, #ffe600);
  background: rgba(14,6,30,0.82); color: #fff; font-family: var(--pixel); font-size: 12px; letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 0 18px rgba(255,230,0,0.35), inset 0 0 12px rgba(255,230,0,0.12); pointer-events: auto;
  animation: fabPulse 3s ease-in-out infinite;
}
#games-fab svg { width: 24px; height: 24px; fill: none; stroke: #ffe600; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#games-fab:hover, #games-fab:focus-visible { background: rgba(60,40,10,0.9); outline: none; transform: translateY(-1px); }
@keyframes fabPulse { 50% { box-shadow: 0 0 26px rgba(255,230,0,0.55), inset 0 0 12px rgba(255,230,0,0.2); } }
#hud.dim #games-fab { opacity: 0; pointer-events: none; }
body.is-mobile #games-fab { bottom: calc(112px + var(--safe-b, 0px)); right: 10px; padding: 10px 14px 10px 12px; font-size: 11px; }
@media (min-width: 900px) { body:not(.is-mobile) .hud-keys { right: 170px; } }

#modal-games .sheet.library { width: min(1060px, 96vw); max-height: 92vh; display: flex; flex-direction: column; padding: 22px 22px 14px; border-color: var(--yellow, #ffe600); box-shadow: 0 0 44px rgba(255,230,0,0.18); }
#modal-games h2 { color: #ffe600; text-shadow: 0 0 12px rgba(255,230,0,.5); margin-bottom: 2px; }
.gl-sub { color: #b8b0d8; font-size: 13px; margin: 0 0 12px; }
.gl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.gl-tabs .tab { font-family: var(--pixel); font-size: 10px; padding: 8px 12px; border-radius: 999px; border: 1px solid #4a3a78; background: rgba(255,255,255,0.04); color: #c8c0ff; cursor: pointer; }
.gl-tabs .tab.on { border-color: #ffe600; color: #fff; background: rgba(255,230,0,0.14); }
.gl-body { overflow-y: auto; padding-right: 4px; flex: 1; min-height: 0; }
.gl-sec { margin-bottom: 18px; }
.gl-sec h3 { font-family: var(--pixel); font-size: 12px; color: #fff; letter-spacing: 1px; margin: 4px 0 10px; border-left: 3px solid #ffe600; padding-left: 8px; }
.gl-sec h3 small { font-family: system-ui, sans-serif; font-size: 12px; color: #8a7cb8; letter-spacing: 0; margin-left: 8px; }
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gl-card { display: flex; flex-direction: column; border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); border-radius: 12px; overflow: hidden; background: rgba(10,4,24,0.85); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.gl-card:hover, .gl-card:focus-visible { transform: translateY(-2px); box-shadow: 0 0 20px color-mix(in srgb, var(--c) 50%, transparent); outline: none; }
.gl-card.dim { opacity: 0.55; cursor: default; }
.gl-shot { background: #000; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.gl-shot canvas { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.gl-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.gl-info b { font-family: var(--pixel); font-size: 12px; color: var(--c); letter-spacing: 1px; }
.gl-info p { margin: 0; font-size: 12.5px; line-height: 1.4; color: #d8d0f0; flex: 1; }
.gl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gl-best { font-family: var(--pixel); font-size: 9px; color: #8a7cb8; }
.gl-play { font-size: 10px; padding: 7px 14px; }
.gl-soon { font-family: var(--pixel); font-size: 10px; color: #8a7cb8; text-align: center; margin: 6px 0 2px; }
body.is-mobile #modal-games .sheet.library { width: 100vw; max-height: 100%; height: 100%; border-radius: 0; padding: 16px 12px 10px; }
body.is-mobile .gl-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
body.is-mobile .gl-info p { font-size: 11.5px; }
@media (max-width: 380px) { body.is-mobile .gl-grid { grid-template-columns: 1fr; } }
/* Pause: dim the game behind so only the options read. */
.panel.pause { box-shadow: 0 0 0 100vmax rgba(3,1,8,0.6), 0 0 30px var(--game-color); }

/* Game library: smooth scrolling (no hover jumps, isolated card painting). */
#modal-games { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(3,1,8,0.82); }
.gl-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; will-change: scroll-position; }
.gl-card { transition: box-shadow .15s, border-color .15s; contain: layout paint; }
.gl-card:hover, .gl-card:focus-visible { transform: none; border-color: var(--c); }
.gl-shot canvas { transform: translateZ(0); }

/* Help: app/offline + settings */
.help-h3 { font-family: var(--pixel); font-size: 10px; color: var(--cyan); margin: 18px 0 8px; letter-spacing: 1px; }
.app-row { display: flex; gap: 8px; flex-wrap: wrap; }
.app-row .btn { font-size: 10px; padding: 10px 12px; }
.toggle-row { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: 12px; color: #b8b0d8; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-row .switch { flex: 0 0 auto; width: 38px; height: 20px; border-radius: 12px; background: #2a2040; border: 1px solid #5a4c88; position: relative; margin-top: 2px; transition: background .2s; }
.toggle-row .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #8a7cb8; transition: transform .2s, background .2s; }
.toggle-row input:checked + .switch { background: #0a4a3a; border-color: #39ffb0; }
.toggle-row input:checked + .switch::after { transform: translateX(18px); background: #39ffb0; box-shadow: 0 0 8px #39ffb0; }
.toggle-row b { display: block; font-family: var(--pixel); font-size: 9px; color: #fff; margin-bottom: 4px; }
#offline-badge { position: fixed; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); z-index: 30; font-family: var(--pixel); font-size: 8px; color: #ffb000; background: rgba(8,3,20,0.85); border: 1px solid #ffb000; border-radius: 6px; padding: 5px 8px; pointer-events: none; }

/* ---------- HUD nameplate: tickets, streak, prize frames ---------- */
button.hud-player { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.hud-player .ptitle { grid-column: 1 / -1; font-family: var(--pixel); font-size: 7px; color: var(--yellow); margin-top: -2px; }
.hud-player .ptitle:empty { display: none; }
.hud-player .tickets { grid-column: 1 / -1; font-family: var(--pixel); font-size: 9px; color: #ffd27a; }
.hud-player .tickets i { font-style: normal; }
.hud-player .streak { grid-column: 1 / -1; font-family: var(--pixel); font-size: 7px; color: #ff9e40; }
.frame-neon { border-color: #18ffff !important; box-shadow: 0 0 18px rgba(24,255,255,0.6), inset 0 0 10px rgba(24,255,255,0.25) !important; }
.frame-circuit { border: 2px dashed #39ff6a !important; box-shadow: 0 0 14px rgba(57,255,106,0.45) !important; animation: circuitFrame 2.4s linear infinite; }
@keyframes circuitFrame { 50% { border-color: #18ffff; } }
.frame-gold { border: 2px solid #ffd23a !important; box-shadow: 0 0 20px rgba(255,210,58,0.6), inset 0 0 12px rgba(255,210,58,0.25) !important; background: linear-gradient(135deg, rgba(60,40,0,0.7), rgba(8,3,20,0.7)) !important; }
.frame-glitch { border: 2px solid #ff2bd6 !important; animation: glitchFrame 1.2s steps(2) infinite; }
@keyframes glitchFrame { 0% { box-shadow: 3px 0 0 #18ffff, -3px 0 0 #ff2bd6; } 50% { box-shadow: -2px 1px 0 #18ffff, 2px -1px 0 #ff2bd6; transform: translateX(1px); } }
.rainbow { background: linear-gradient(90deg, #ff2bd6, #ffd23a, #39ff6a, #18ffff, #b040ff, #ff2bd6); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent !important; text-shadow: none !important; animation: rainbow 4s linear infinite; }
@keyframes rainbow { to { background-position: 300% 0; } }

/* ---------- Profile modal ---------- */
.sheet.profile { width: min(760px, 96vw); }
.pf-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.pf-name { padding: 10px 14px; border-radius: 8px; border: 1px solid rgba(255,43,214,0.5); background: rgba(8,3,20,0.65); }
.pf-name b { font-family: var(--pixel); font-size: 14px; color: #fff; display: block; }
.pf-name small { font-family: var(--pixel); font-size: 8px; color: var(--yellow); }
.pf-kpis { display: flex; gap: 14px; flex-wrap: wrap; }
.pf-kpis div, .pf-grid div { display: flex; flex-direction: column; gap: 4px; }
.pf-kpis span, .pf-grid span { font-family: var(--pixel); font-size: 7px; color: var(--muted); }
.pf-kpis b, .pf-grid b { font-family: var(--pixel); font-size: 12px; font-weight: normal; color: #fff; }
.pf-body { max-height: min(56vh, 520px); overflow: auto; padding-right: 4px; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 10px; border-radius: 8px; background: rgba(255,255,255,0.03); }
.pf-h3 { font-family: var(--pixel); font-size: 9px; color: var(--cyan); margin: 16px 0 8px; }
.pf-sub { font-family: var(--pixel); font-size: 8px; color: var(--muted); line-height: 1.7; }
.pf-sub b { color: #ffd27a; font-weight: normal; }
.pf-empty { color: var(--muted); font-size: 14px; padding: 20px 4px; }
.pf-table { width: 100%; border-collapse: collapse; font-family: var(--pixel); font-size: 8px; }
.pf-table th { text-align: left; color: var(--muted); font-weight: normal; padding: 6px; border-bottom: 1px solid #2a1c4a; }
.pf-table td { padding: 7px 6px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #fff; }
.pf-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pf-badge { padding: 10px; border-radius: 8px; border: 1px solid #2a1c4a; background: rgba(255,255,255,0.02); opacity: .5; display: flex; flex-direction: column; gap: 4px; }
.pf-badge.on { opacity: 1; border-color: rgba(255,210,58,0.6); box-shadow: 0 0 12px rgba(255,210,58,0.2); }
.pf-badge .ic { font-size: 20px; }
.pf-badge b { font-family: var(--pixel); font-size: 8px; color: #fff; line-height: 1.5; }
.pf-badge small { font-size: 12px; color: var(--muted); line-height: 1.2; }
.pf-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.pf-item { padding: 10px; border-radius: 8px; border: 1px solid #2a1c4a; background: rgba(255,255,255,0.02); display: flex; flex-direction: column; gap: 6px; }
.pf-item.own { border-color: rgba(57,255,106,0.5); }
.pf-item b { font-family: var(--pixel); font-size: 8px; color: #fff; line-height: 1.5; }
.pf-item small { font-size: 12px; color: var(--muted); line-height: 1.2; flex: 1; }
.pf-item .btn { font-size: 9px; padding: 8px; }
.pf-item .btn[disabled] { opacity: .4; }
.pf-item .owned { font-family: var(--pixel); font-size: 8px; color: #39ff6a; }
.pf-item .pv { font-family: var(--pixel); font-size: 12px; }
.pf-item .pv.frame { display: inline-block; padding: 6px 8px; border-radius: 6px; border: 1px solid #5a4c88; font-size: 9px; color: #fff; align-self: flex-start; }

/* ---------- Library: recently played, favourites, random ---------- */
.gl-random { font-size: 9px; padding: 7px 10px; margin-left: 8px; vertical-align: middle; }
.gl-fav { position: absolute; top: 6px; right: 6px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); background: rgba(8,3,20,0.7); color: #8a7cb8; font-size: 15px; line-height: 1; cursor: pointer; }
.gl-fav.on { color: #ffd23a; border-color: #ffd23a; box-shadow: 0 0 10px rgba(255,210,58,0.5); }
.gl-card { position: relative; }

/* ---------- First-visit tour ---------- */
#tour { position: fixed; inset: auto 0 calc(24px + var(--safe-b)) 0; z-index: 26; display: flex; justify-content: center; pointer-events: none; padding: 0 12px; }
.tour-card { pointer-events: auto; width: min(460px, 100%); padding: 16px 16px 12px; border-radius: 12px; background: rgba(10,4,24,0.94); border: 2px solid var(--cyan); box-shadow: 0 0 30px rgba(0,229,255,0.35); }
.tour-step { font-family: var(--pixel); font-size: 7px; color: var(--muted); margin: 0 0 6px; }
.tour-card h3 { font-family: var(--pixel); font-size: 12px; color: var(--yellow); margin: 0 0 8px; text-shadow: 0 0 8px rgba(255,230,0,0.5); }
.tour-card p { font-size: 15px; color: #d8d0f0; margin: 0 0 10px; line-height: 1.35; }
.tour-btns { display: flex; justify-content: flex-end; gap: 8px; }
.tour-btns .btn { font-size: 9px; padding: 9px 12px; }

/* Controller focus ring (menus driven with a gamepad). */
.pad-focus { outline: 3px solid #ffd23a !important; outline-offset: 2px; box-shadow: 0 0 16px rgba(255,210,58,0.7) !important; }

.gm-auto { font-size: 7px; color: #fff; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.gm-auto input { accent-color: #00e5ff; width: 16px; height: 16px; }
