/* ================================================================ fonts (self-hosted, no Google CDN) */
@font-face {
  font-family: 'Press Start 2P';
  src: url('/vendor/fonts/press-start-2p/press-start-2p-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('/vendor/fonts/pixelify-sans/pixelify-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('/vendor/fonts/pixelify-sans/pixelify-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('/vendor/fonts/pixelify-sans/pixelify-sans-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* ================================================================ tokens */
:root {
  --bg: #0b0820;
  --ink: #05030d;
  --panel: rgba(13, 9, 32, 0.88);
  --panel-hi: rgba(28, 20, 62, 0.92);
  --line: #3a2e6e;
  --line-hi: #5a4aa8;
  --text: #f3efff;
  --muted: #a69ccc;
  --accent: #3dffa2;
  --accent-dk: #18a865;
  --gold: #ffd23d;
  --pink: #ff3b6b;
  --cyan: #5ce1ff;
  --red: #ff4f4f;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --body: 'Pixelify Sans', ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas#screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  image-rendering: pixelated;
  background: var(--bg);
}
#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
}

h2, h3 { margin: 0; font-weight: 400; }
h2 { font-family: var(--pixel); font-size: clamp(16px, 2.2vw, 24px); letter-spacing: 1px; text-shadow: 3px 3px 0 var(--ink); }
h3 { font-family: var(--pixel); font-size: 11px; color: var(--muted); margin: 18px 0 10px; letter-spacing: 1px; text-transform: uppercase; }
h3:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
p { margin: 6px 0 0; }

/* ================================================================ screens */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: clamp(14px, 3vh, 36px) 16px;
  pointer-events: auto;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen.active { display: flex; animation: scrIn 0.32s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
.screen.overlay { background: rgba(5, 3, 13, 0.55); backdrop-filter: blur(2px); justify-content: center; }
.screen:not(#scr-title):not(.overlay) { background: linear-gradient(180deg, rgba(5, 3, 13, 0.72), rgba(5, 3, 13, 0.5) 40%, rgba(5, 3, 13, 0.8)); }
@keyframes scrIn {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.scr-head { text-align: center; margin-bottom: clamp(12px, 3vh, 28px); }
.scr-foot { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 22px; }

/* ================================================================ buttons */
.btn {
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  background: linear-gradient(180deg, #2b2158, #1b1440);
  border: 0;
  padding: 13px 18px;
  cursor: pointer;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--line), 0 5px 0 5px var(--ink);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s;
  outline: none;
  white-space: nowrap;
}
.btn:hover, .btn:focus {
  background: linear-gradient(180deg, #3d2f80, #281d60);
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--accent), 0 5px 0 5px var(--ink), 0 0 26px rgba(61, 255, 162, 0.35);
  transform: translateY(-2px);
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--accent), 0 1px 0 5px var(--ink); }
.btn.primary { background: linear-gradient(180deg, #3dffa2, #19b56c); color: #04140b; }
.btn.primary:hover, .btn.primary:focus { background: linear-gradient(180deg, #7affc4, #22cf80); }
.btn.danger { background: linear-gradient(180deg, #ff5a7a, #c8203f); }
.btn.small { font-size: 10px; padding: 10px 13px; }
.btn.icon { padding: 8px 10px; font-size: 16px; font-family: var(--body); }
.btn.wide { width: 100%; margin-top: 18px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.toggle::after { content: 'OFF'; }
.btn.toggle.on { background: linear-gradient(180deg, #3dffa2, #19b56c); color: #04140b; }
.btn.toggle.on::after { content: 'ON'; }
.btn.ready { background: linear-gradient(180deg, #ffd23d, #d39a12); color: #1a1000; }

/* ================================================================ title */
#scr-title { justify-content: flex-start; padding-bottom: 0; }
.title-wrap { display: flex; flex-direction: column; align-items: center; margin-top: auto; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; animation: float 4s ease-in-out infinite; }
.logo-line {
  font-family: var(--pixel);
  font-size: clamp(30px, min(8.5vw, 10.5vh), 104px);
  letter-spacing: 4px;
  background: linear-gradient(180deg, #fff6c8 0%, #ffd23d 35%, #ff7a3d 62%, #ff3b6b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(4px 4px 0 #2a0f4a) drop-shadow(4px 4px 0 #120826) drop-shadow(0 0 24px rgba(255, 59, 107, 0.35));
}
.logo-line.l2 {
  background: linear-gradient(180deg, #e9fff4 0%, #3dffa2 40%, #19b5a0 70%, #3a6bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  margin-top: 0.08em;
  filter: drop-shadow(4px 4px 0 #0b2a3f) drop-shadow(4px 4px 0 #061420) drop-shadow(0 0 24px rgba(61, 255, 162, 0.35));
}
@keyframes float { 50% { transform: translateY(-6px); } }
.hype-curve { width: min(520px, 86vw); margin-top: 6px; overflow: visible; }
.hype-curve path { fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 2; stroke-dasharray: 4 3; }
.hype-curve .hype-dot { fill: var(--gold); filter: drop-shadow(0 0 5px var(--gold)); }
.hype-curve text { font-family: var(--pixel); font-size: 6px; fill: rgba(255, 255, 255, 0.45); }
.tagline { font-family: var(--pixel); font-size: clamp(9px, 1.2vw, 12px); color: var(--muted); margin-top: 10px; letter-spacing: 2px; text-transform: uppercase; }
.press-start { margin-top: 38px; font-family: var(--pixel); font-size: 13px; color: var(--gold); animation: blink 1.1s steps(2) infinite; text-shadow: 2px 2px 0 var(--ink); }
@keyframes blink { 50% { opacity: 0; } }
.menu { display: flex; flex-direction: column; gap: 18px; margin-top: 34px; min-width: 280px; }
.menu .btn { font-size: 13px; padding: 15px 20px; }
.title-chars { display: flex; gap: clamp(4px, 2vw, 26px); justify-content: center; align-items: flex-end; margin-top: auto; padding-top: 24px; }
.title-chars canvas { width: 60px; height: 81px; image-rendering: pixelated; cursor: pointer; transition: transform 0.15s, filter 0.15s; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.5)); }
.title-chars canvas:hover { transform: translateY(-6px); }
.title-chars canvas.sel { filter: drop-shadow(0 0 10px var(--accent)) drop-shadow(0 4px 0 rgba(0, 0, 0, 0.5)); }
.foot { width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); padding: 14px 4px 12px; gap: 12px; flex-wrap: wrap; }
.pad-status.on { color: var(--accent); }

/* ================================================================ panels & forms */
.panel {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 0 0 0 3px var(--ink), 0 10px 0 3px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.03);
  padding: 18px;
  backdrop-filter: blur(3px);
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: 17px; }
.row > span:first-child { color: var(--muted); }
input[type='text'], input:not([type]), .code {
  font-family: var(--body);
  font-size: 18px;
  font-weight: 600;
  background: #07051a;
  color: var(--text);
  border: 3px solid var(--line);
  padding: 8px 10px;
  outline: none;
  min-width: 0;
  user-select: text;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 16px rgba(61, 255, 162, 0.25); }
input.code { font-family: var(--pixel); font-size: 16px; text-transform: uppercase; letter-spacing: 4px; width: 120px; text-align: center; }
.input-row { display: flex; gap: 12px; align-items: center; }
.input-row input { flex: 1; }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 200px; height: 10px; background: #07051a; border: 3px solid var(--line); outline: none; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 22px; background: var(--accent); border: 3px solid var(--ink); cursor: pointer; }
input[type='range']::-moz-range-thumb { width: 14px; height: 18px; background: var(--accent); border: 3px solid var(--ink); border-radius: 0; }
input[type='range']:focus { border-color: var(--accent); }

.cycler {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-width: 190px; font-family: var(--pixel); font-size: 10px; text-transform: uppercase;
  background: #07051a; border: 3px solid var(--line); padding: 7px 8px; cursor: pointer; outline: none;
}
.cycler .arr { color: var(--muted); padding: 0 4px; }
.cycler .val { flex: 1; text-align: center; }
.cycler:focus, .cycler:hover { border-color: var(--accent); }
.cycler:focus .arr { color: var(--accent); }
.cycler.readonly { cursor: default; opacity: 0.8; }
.cycler.readonly .arr { visibility: hidden; }

/* ================================================================ level cards */
.level-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 300px)); gap: 26px; justify-content: center; width: 100%; max-width: 1040px; }
.level-card {
  text-align: left; padding: 0; display: flex; flex-direction: column; font-family: var(--body); text-transform: none; letter-spacing: 0;
  background: var(--panel); white-space: normal;
}
.level-card .thumb { width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; display: block; border-bottom: 3px solid var(--ink); }
.level-card .info { padding: 12px 14px 16px; }
.level-card .w { font-family: var(--pixel); font-size: 9px; color: var(--muted); }
.level-card .n { font-family: var(--pixel); font-size: 12px; margin: 8px 0; line-height: 1.5; color: var(--text); }
.level-card .b { font-size: 15px; color: var(--muted); line-height: 1.3; min-height: 3.9em; }
.level-card .stats { display: flex; justify-content: space-between; margin-top: 12px; font-size: 15px; }
.level-card .stats b { color: var(--gold); }
.wafers { letter-spacing: 3px; }
.wafers i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #2a2450; border: 2px solid #4a4280; margin-right: 3px; vertical-align: -1px; }
.wafers i.on { background: radial-gradient(circle at 35% 35%, #fff3a3, #ffd23d 50%, #d99a1a); border-color: #8a5a0a; box-shadow: 0 0 8px rgba(255, 210, 61, 0.6); }

/* ================================================================ skins */
.skin-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 175px)); gap: 20px; width: 100%; max-width: 1200px; justify-content: center; }
@media (max-width: 1150px) { .skin-grid { grid-template-columns: repeat(3, minmax(0, 200px)); } }
@media (max-width: 560px) { .skin-grid { grid-template-columns: repeat(2, minmax(0, 200px)); } }
.skin-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px 14px; white-space: normal; text-transform: none; letter-spacing: 0; font-family: var(--body); background: var(--panel); }
.skin-card canvas { width: 100px; height: 135px; image-rendering: pixelated; }
.skin-card .n { font-family: var(--pixel); font-size: 12px; }
.skin-card .t { font-size: 14px; font-weight: 600; }
.skin-card .q { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.25; min-height: 3.75em; }
.skin-card.sel { box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--gold), 0 5px 0 5px var(--ink), 0 0 26px rgba(255, 210, 61, 0.35); }
.skin-card.sel::before { content: 'SELECTED'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--gold); color: #1a1000; font-family: var(--pixel); font-size: 8px; padding: 4px 6px; }

/* ================================================================ settings */
.settings { width: min(560px, 100%); }
.controls-ref { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 12px; display: grid; gap: 6px; font-size: 15px; }
.controls-ref div { display: flex; justify-content: space-between; gap: 12px; }
.controls-ref b { font-weight: 600; color: var(--accent); }
.controls-ref span { color: var(--muted); text-align: right; }

/* ================================================================ multiplayer */
.mp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; width: 100%; max-width: 1240px; }
.me-row { display: flex; gap: 14px; align-items: center; }
.me-avatar { width: 60px; height: 81px; image-rendering: pixelated; flex: none; }
.me-fields { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 0; }
.lobby-list { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; padding: 6px; }
.lobby-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; text-align: left; font-family: var(--body); text-transform: none; letter-spacing: 0; white-space: normal; padding: 10px 12px; }
.lobby-row .ln { font-weight: 700; font-size: 17px; }
.lobby-row .lm { font-size: 14px; color: var(--muted); grid-column: 1; }
.lobby-row .lc { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-family: var(--pixel); font-size: 11px; }
.lobby-row.playing { opacity: 0.6; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 15px; line-height: 1.4; }

/* ================================================================ lobby */
.lobby-head { display: flex; align-items: center; gap: 22px; text-align: left; flex-wrap: wrap; justify-content: center; }
.code-chip {
  font-family: var(--pixel); font-size: 22px; letter-spacing: 6px; color: var(--gold); background: #07051a; border: 3px dashed var(--gold);
  padding: 12px 14px 12px 20px; cursor: pointer; outline: none; position: relative;
}
.code-chip::after { content: 'CLICK TO COPY INVITE'; position: absolute; left: 0; right: 0; bottom: -18px; font-size: 7px; letter-spacing: 1px; color: var(--muted); text-align: center; }
.code-chip:focus, .code-chip:hover { border-style: solid; box-shadow: 0 0 20px rgba(255, 210, 61, 0.35); }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; width: 100%; max-width: 1040px; }
.player-list { display: flex; flex-direction: column; gap: 10px; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: rgba(255, 255, 255, 0.03); border: 2px solid var(--line); }
.player-row canvas { width: 40px; height: 54px; image-rendering: pixelated; flex: none; }
.player-row .pn { flex: 1; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .pn small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.badge { font-family: var(--pixel); font-size: 8px; padding: 5px 6px; background: #2a2450; color: var(--muted); }
.badge.ready { background: var(--accent); color: #04140b; }
.badge.host { background: var(--gold); color: #1a1000; }
.badge.me { background: var(--cyan); color: #021820; }
.kick { font-size: 9px; padding: 6px 8px; }
.chat { height: 170px; overflow-y: auto; background: #07051a; border: 3px solid var(--line); padding: 8px 10px; font-size: 15px; line-height: 1.35; margin-bottom: 12px; user-select: text; }
.chat .sys { color: var(--muted); font-style: italic; }
.chat b { font-weight: 700; }
.mode-help { font-size: 14px; line-height: 1.35; min-height: 2.7em; }

/* ================================================================ pause & results */
.pause-panel { width: min(420px, 100%); text-align: center; padding: 26px 26px 30px; }
.pause-panel .menu { margin-top: 24px; }
.results-panel { width: min(640px, 100%); text-align: center; padding: 26px; animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.res-title { font-family: var(--pixel); font-size: 10px; color: var(--muted); }
.res-level { font-family: var(--pixel); font-size: clamp(13px, 2vw, 17px); margin: 10px 0 18px; line-height: 1.5; }
.res-time { font-family: var(--pixel); font-size: clamp(30px, 6vw, 52px); color: var(--gold); text-shadow: 4px 4px 0 #3a1a00, 0 0 30px rgba(255, 210, 61, 0.4); }
.res-record { display: inline-block; margin-top: 12px; font-family: var(--pixel); font-size: 11px; background: var(--pink); color: #fff; padding: 7px 10px; animation: wobble 0.8s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(-3deg) scale(1.06); } }
.res-best { margin-top: 10px; color: var(--muted); font-size: 16px; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0; }
.res-stats > div { background: rgba(255, 255, 255, 0.04); border: 2px solid var(--line); padding: 12px 6px; }
.res-stats b { display: block; font-family: var(--pixel); font-size: 16px; margin-top: 8px; color: var(--text); }
.res-stats span { font-size: 14px; color: var(--muted); }
.res-quip { font-size: 16px; color: var(--muted); margin: 0 0 20px; font-style: italic; }
.res-btns { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.rank-list { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 22px; text-align: left; }
.rank-row { display: grid; grid-template-columns: 44px 44px 1fr auto; align-items: center; gap: 12px; padding: 6px 12px; background: rgba(255, 255, 255, 0.04); border: 2px solid var(--line); }
.rank-row.me { border-color: var(--cyan); }
.rank-row.p1 { border-color: var(--gold); background: rgba(255, 210, 61, 0.08); }
.rank-row .pl { font-family: var(--pixel); font-size: 16px; color: var(--muted); }
.rank-row.p1 .pl { color: var(--gold); }
.rank-row canvas { width: 36px; height: 48px; image-rendering: pixelated; }
.rank-row .nm { font-size: 18px; font-weight: 600; }
.rank-row .nm small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.rank-row .sc { font-family: var(--pixel); font-size: 12px; text-align: right; }

/* ================================================================ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--pixel); }
#hud[hidden] { display: none; }
.hud-left { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hud-chip { display: flex; align-items: center; gap: 8px; background: rgba(8, 6, 20, 0.72); border: 2px solid rgba(255, 255, 255, 0.12); padding: 6px 10px; font-size: 14px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4); }
.hud-chip canvas { width: 24px; height: 20px; image-rendering: pixelated; }
.hud-chip .of { color: var(--muted); font-size: 10px; }
.hud-chip.small { font-size: 11px; color: var(--muted); }
.hud-chip.small b { color: var(--text); }
.hud-chip .skull { color: var(--pink); }
.hud-chip.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }
.hud-chip.gold { padding: 6px 8px; gap: 6px; }
.hud-chip.gold i { width: 14px; height: 14px; border-radius: 50%; background: #2a2450; border: 2px solid #4a4280; }
.hud-chip.gold i.on { background: radial-gradient(circle at 35% 35%, #fff3a3, #ffd23d 50%, #d99a1a); border-color: #8a5a0a; box-shadow: 0 0 10px rgba(255, 210, 61, 0.8); }
.hud-center { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#hud-time { font-size: clamp(16px, 2.2vw, 22px); text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.7); letter-spacing: 1px; }
#hud-time.idle { color: var(--muted); }
#hud-sub { font-size: 10px; color: var(--gold); text-shadow: 2px 2px 0 #000; min-height: 10px; }
#hud-sub.warn { color: var(--pink); animation: blink 0.6s steps(2) infinite; }
#hud-progress { position: relative; width: min(46vw, 420px); height: 22px; display: none; }
#hud-progress.on { display: block; }
#hud-progress::before { content: ''; position: absolute; left: 0; right: 0; top: 14px; height: 4px; background: rgba(255, 255, 255, 0.15); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5); }
#hud-progress::after { content: ''; position: absolute; right: -4px; top: 6px; width: 4px; height: 16px; background: repeating-linear-gradient(#fff 0 4px, #000 4px 8px); }
#hud-progress .pip { position: absolute; top: 2px; width: 12px; height: 12px; border: 2px solid #000; transform: translateX(-50%); transition: left 0.15s linear; }
#hud-progress .pip.me { width: 14px; height: 14px; top: 1px; border-color: #fff; z-index: 2; }
.hud-right { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.power { display: flex; align-items: center; gap: 8px; background: rgba(8, 6, 20, 0.72); border: 2px solid var(--pc, #fff); padding: 5px 8px 5px 6px; font-size: 9px; animation: slideIn 0.3s ease-out; box-shadow: 0 0 14px color-mix(in srgb, var(--pc, #fff) 40%, transparent); }
.power canvas { width: 28px; height: 28px; image-rendering: pixelated; }
.power .bar { width: 70px; height: 5px; background: rgba(255, 255, 255, 0.15); margin-top: 5px; }
.power .bar i { display: block; height: 100%; background: var(--pc, #fff); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
#hud-scores { position: absolute; top: 120px; right: 14px; display: flex; flex-direction: column; gap: 4px; font-size: 10px; }
#hud-scores .sr { display: flex; gap: 10px; justify-content: space-between; min-width: 160px; background: rgba(8, 6, 20, 0.72); padding: 5px 8px; border-left: 4px solid var(--c, #fff); }
#hud-scores .sr.me { outline: 2px solid var(--cyan); }
#hud-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(60px, 14vw, 160px); color: var(--gold); text-shadow: 6px 6px 0 #3a1a00, 0 0 40px rgba(255, 210, 61, 0.6); pointer-events: none; }
#hud-count span { animation: countPop 0.9s ease-out both; }
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } to { transform: scale(0.9); opacity: 0; } }
#hud-intro { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); text-align: center; opacity: 0; pointer-events: none; width: min(90vw, 760px); }
#hud-intro.show { animation: intro 3.2s ease both; }
#hud-intro .w { font-size: 11px; color: var(--gold); letter-spacing: 3px; }
#hud-intro .n { font-size: clamp(18px, 3.4vw, 34px); margin: 14px 0; text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8); line-height: 1.35; }
#hud-intro .b { font-family: var(--body); font-size: clamp(14px, 1.6vw, 19px); color: #e4defa; text-shadow: 2px 2px 0 #000; line-height: 1.35; }
@keyframes intro {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  12%, 78% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -56%); }
}
#hud-hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-family: var(--body); font-size: 15px; color: rgba(255, 255, 255, 0.7); background: rgba(0, 0, 0, 0.45); padding: 6px 12px; transition: opacity 1s; white-space: nowrap; }
#hud-hint.gone { opacity: 0; }

/* ================================================================ toasts & wipe */
#toasts { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(92vw, 640px); }
.toast { font-family: var(--pixel); font-size: 11px; line-height: 1.5; padding: 9px 14px; background: rgba(8, 6, 20, 0.9); border: 2px solid var(--line-hi); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5); text-align: center; animation: toastIn 0.25s ease-out both, toastOut 0.4s ease-in 2.4s forwards; }
.toast.good { border-color: var(--accent); color: var(--accent); }
.toast.bad { border-color: var(--pink); color: #ff9db3; }
.toast.gold { border-color: var(--gold); color: var(--gold); font-size: 13px; }
.toast.power { border-color: var(--cyan); color: #c9f6ff; }
.toast.big { font-size: 28px; border: 0; background: none; box-shadow: none; color: var(--accent); text-shadow: 4px 4px 0 #04140b, 0 0 30px rgba(61, 255, 162, 0.6); animation: toastIn 0.25s ease-out both, toastOut 0.4s ease-in 0.9s forwards; }
.toast.err { border-color: var(--red); color: #ffb3b3; }
@keyframes toastIn { from { transform: translateY(-12px) scale(0.95); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-8px); opacity: 0; } }
#wipe { position: fixed; inset: 0; z-index: 40; pointer-events: none; background: var(--ink); clip-path: circle(0% at 50% 50%); }
#wipe.in { animation: wipeIn 0.35s ease-in forwards; }
#wipe.out { animation: wipeOut 0.45s ease-out forwards; }
@keyframes wipeIn { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(80% at 50% 50%); } }
@keyframes wipeOut { from { clip-path: circle(80% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }

/* ================================================================ responsive */
@media (max-width: 1000px) {
  .mp-grid { grid-template-columns: 1fr 1fr; }
  .lobby-list-panel { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .mp-grid, .lobby-grid { grid-template-columns: 1fr; }
  .title-chars canvas { width: 40px; height: 54px; }
  .menu { min-width: 0; width: 100%; }
  .row { flex-wrap: wrap; }
  .res-stats { grid-template-columns: 1fr 1fr 1fr; }
  #hud-progress { width: 40vw; }
}
@media (max-height: 640px) {
  .hype-curve { width: min(380px, 70vw); }
  .press-start { margin-top: 20px; }
  .menu { margin-top: 18px; gap: 12px; }
  .menu .btn { padding: 11px 18px; font-size: 11px; }
  .title-chars { padding-top: 10px; }
  .title-chars canvas { width: 40px; height: 54px; }
  .foot { padding: 8px 4px; }
  .scr-head { margin-bottom: 12px; }
  .level-card .b { display: none; }
  .skin-card canvas { width: 60px; height: 81px; }
  .skin-card .q { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .press-start, .res-record { animation: none; }
}
