:root {
  --bg: #04050c;
  --panel: rgba(9, 12, 28, 0.86);
  --panel-solid: #0a0e22;
  --line: rgba(120, 160, 255, 0.16);
  --line-strong: rgba(120, 170, 255, 0.34);
  --text: #e8edff;
  --muted: #8b96ba;
  --accent: #00e5ff;
  --accent-2: #ff3df2;
  --good: #5dff9c;
  --warn: #ffb443;
  --radius: 14px;
  --hud-h: 56px;
  --font-display: 'Orbitron', 'Rajdhani', system-ui, sans-serif;
  --font-body: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font-family: var(--font-body); font-size: 17px; font-weight: 500; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
kbd {
  font-family: var(--font-body); font-weight: 700; font-size: 0.85em; padding: 1px 7px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- arena */
.arena { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 12px 12px; }
#app[data-screen='menu'] .arena, #app[data-screen='local'] .arena, #app[data-screen='online'] .arena,
#app[data-screen='lobby'] .arena, #app[data-screen='help'] .arena, #app[data-screen='about'] .arena,
#app[data-screen='winner'] .arena { padding-top: 12px; }

.stage {
  position: relative;
  aspect-ratio: 13 / 8;
  width: min(100%, calc((100vh - var(--hud-h) - 12px) * 1.625));
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(110, 170, 255, 0.25), 0 0 40px rgba(0, 160, 255, 0.18), 0 30px 80px rgba(0, 0, 0, 0.7);
  will-change: transform;
}
.layers, .layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.layer { display: block; }
.layer-glow { filter: blur(5px) saturate(1.3); opacity: 0.95; mix-blend-mode: screen; }
.layer-bonus { animation: bonus-pulse 2.4s ease-in-out infinite; }
@keyframes bonus-pulse { 50% { opacity: 0.72; } }

/* Menus sit over a dimmed attract-mode game. */
#app:not([data-screen='game']):not([data-screen='pause']) .stage { filter: saturate(1.1); }
#app:not([data-screen='game']):not([data-screen='pause']) .arena::after {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(4, 5, 12, 0.55), rgba(4, 5, 12, 0.88));
}

/* ---------------------------------------------------------------- HUD */
.hud {
  height: var(--hud-h); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  transition: opacity 0.3s, transform 0.3s;
}
#app:not([data-screen='game']):not([data-screen='pause']) .hud { opacity: 0; pointer-events: none; transform: translateY(-8px); }
.hud-left { display: flex; align-items: baseline; gap: 14px; min-width: 0; flex: none; }
.brand-mini {
  font-family: var(--font-display); font-weight: 900; letter-spacing: 0.18em; font-size: 15px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hud-round { color: var(--muted); font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
.scoreboard { flex: 1; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-width: 0; }
.chip {
  --c: hsl(var(--h) var(--s) var(--l));
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  transition: opacity 0.3s, filter 0.3s, transform 0.2s;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.chip .n { font-weight: 600; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip b {
  font-family: var(--font-display); font-size: 13px; min-width: 26px; text-align: center; padding: 2px 6px;
  border-radius: 999px; background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c);
}
.chip.dead { opacity: 0.38; filter: grayscale(0.7); }
.chip.mine { background: color-mix(in srgb, var(--c) 12%, transparent); }
.chip.bump { animation: bump 0.6s ease; }
@keyframes bump { 30% { transform: scale(1.15); } }
.hud-right { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--muted); transition: 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn.off { opacity: 0.55; }
/* Music and sound toggles for the menus, where the HUD is hidden. */
.corner-audio { position: fixed; top: 12px; right: 16px; z-index: 7; display: flex; gap: 6px; transition: opacity 0.2s; }
.corner-audio .icon-btn { background: rgba(5, 7, 18, 0.7); }
#app[data-screen='game'] .corner-audio, #app[data-screen='pause'] .corner-audio { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- countdown & banner */
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-display); font-weight: 900; font-size: clamp(60px, 12vw, 150px); color: #fff;
  text-shadow: 0 0 20px var(--accent), 0 0 60px var(--accent);
}
.countdown span { animation: count-pop 0.9s ease-out forwards; }
.countdown span.go { color: var(--good); text-shadow: 0 0 20px var(--good), 0 0 60px var(--good); }
@keyframes count-pop {
  0% { transform: scale(1.8); opacity: 0; }
  15% { transform: scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}

.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.96); text-align: center;
  padding: 26px 44px 24px; border-radius: 18px; min-width: min(460px, 90%);
  background: rgba(5, 7, 18, 0.78); border: 1px solid var(--line-strong);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.banner.intro { top: 28%; background: rgba(5, 7, 18, 0.55); }
.banner .kicker { margin-bottom: 4px; }
.banner .title {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(26px, 4vw, 46px); letter-spacing: 0.06em;
  color: var(--c, #fff); text-shadow: 0 0 18px var(--c, var(--accent));
}
.banner .sub { color: var(--muted); margin-top: 6px; font-size: 18px; }
.banner .actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }

.kicker { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.3em; color: var(--muted); text-transform: uppercase; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed; inset: 0; z-index: 5; display: none; place-items: center; padding: 16px; overflow-y: auto;
}
#app[data-screen='menu'] #screen-menu, #app[data-screen='local'] #screen-local, #app[data-screen='online'] #screen-online,
#app[data-screen='lobby'] #screen-lobby, #app[data-screen='help'] #screen-help, #app[data-screen='about'] #screen-about,
#app[data-screen='pause'] #screen-pause, #app[data-screen='winner'] #screen-winner { display: grid; }
.screen > * { animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.screen-menu { grid-template-rows: 1fr auto; }
.menu-center { display: flex; flex-direction: column; align-items: center; text-align: center; align-self: center; }
.logo {
  margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(48px, 11vw, 132px);
  letter-spacing: 0.08em; line-height: 1; display: flex;
}
.logo span:first-child { color: #dffcff; text-shadow: 0 0 6px #fff, 0 0 18px var(--accent), 0 0 48px var(--accent), 0 0 90px rgba(0, 229, 255, 0.5); }
.logo span:last-child { color: #ffe1fd; text-shadow: 0 0 6px #fff, 0 0 18px var(--accent-2), 0 0 48px var(--accent-2), 0 0 90px rgba(255, 61, 242, 0.5); animation: flicker 6s infinite; }
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: 0.55; } 94% { opacity: 1; } 96% { opacity: 0.7; } 97% { opacity: 1; } }
.tagline { margin: 14px 0 34px; color: var(--muted); font-size: clamp(17px, 2vw, 22px); letter-spacing: 0.08em; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: min(320px, 80vw); }

.about p { margin: 0 0 12px; line-height: 1.45; }
.about-links { list-style: none; padding: 0; margin: 18px 0 0; border-top: 1px solid var(--line); }
.about-links li { display: flex; gap: 16px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.about-links span { width: 120px; flex: none; color: var(--muted); font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; }
.about-links a { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- speed slider */
.speed-ctl { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.speed-ctl input { flex: 1; min-width: 0; accent-color: var(--accent); height: 28px; cursor: pointer; }
.speed-val { min-width: 64px; text-align: right; font-family: var(--font-display); font-weight: 700; color: var(--accent); }
.speed-reset:disabled { opacity: 0.35; cursor: default; }
.pause-speed { text-align: left; margin: 4px 0 14px; }
.pause-speed[hidden] { display: none; }
.pause-speed h3 small { text-transform: none; letter-spacing: 0.02em; font-family: var(--font-body); font-size: 13px; }
.look-ctl { display: grid; gap: 8px; }
.look-row { display: flex; align-items: center; gap: 12px; }
.look-row > span { width: 64px; flex: none; color: var(--muted); font-weight: 600; }
.look-ctl .seg { --c: var(--accent); flex: 1; max-width: 240px; grid-template-columns: repeat(2, 1fr); }
.look-ctl .seg button { padding: 6px 2px; font-size: 14px; }
.speed-ctl + h3 { margin-top: 18px; }

.panel {
  width: min(1060px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.panel-narrow { width: min(620px, 100%); }
.panel-head { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.panel-head .hint { grid-column: 2; margin: 2px 0 0; }
h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em; font-size: 24px; margin: 0 0 12px; }
h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: 0.14em; font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 6px 0 12px; }
.hint { color: var(--muted); margin: 0 0 12px; }
.back {
  grid-row: span 2; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: transparent;
  font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted);
}
.back:hover { color: var(--text); border-color: var(--line-strong); }
.panel-foot { display: flex; align-items: center; gap: 16px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.panel-foot .status { margin-right: auto; }
.status { color: var(--muted); min-height: 1.2em; }
.status.error { color: #ff7a8a; }
.setup-cols { display: grid; grid-template-columns: 1.55fr 1fr; gap: 28px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 820px) { .setup-cols, .help-cols { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative; cursor: pointer; border-radius: 12px; padding: 10px 18px; font-weight: 700; letter-spacing: 0.06em;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04); transition: 0.15s; text-transform: uppercase; font-size: 15px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 18px rgba(0, 229, 255, 0.25); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  border-color: transparent; color: #021014;
  background: linear-gradient(135deg, #3ef0ff, #00b3ff 55%, #7a5cff); box-shadow: 0 0 22px rgba(0, 200, 255, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 34px rgba(0, 220, 255, 0.6); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-big { padding: 14px 26px; font-size: 17px; }
.btn-small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- player cards */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.pcard {
  --c: hsl(var(--h) var(--s) var(--l));
  border-radius: var(--radius); padding: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
  transition: 0.2s; display: flex; flex-direction: column; gap: 10px;
}
.pcard.on { border-color: color-mix(in srgb, var(--c) 60%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent); box-shadow: 0 0 22px color-mix(in srgb, var(--c) 18%, transparent); }
.pcard-head { display: flex; align-items: center; gap: 9px; }
.pcard-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.pcard:not(.on) .dot { opacity: 0.35; box-shadow: none; }
.pcard-head .pname { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em; font-size: 14px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 5px 2px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.sel { background: color-mix(in srgb, var(--c) 25%, transparent); color: var(--text); }
.pkeys { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; color: var(--muted); font-size: 14px; }
.pcard:not(.on) .pkeys { opacity: 0.4; }
.key {
  min-width: 46px; padding: 5px 9px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px;
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.35); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
}
.key:hover { border-color: var(--c); }
.key.listening { border-color: var(--c); color: var(--c); animation: listen 0.8s infinite; }
@keyframes listen { 50% { box-shadow: 0 0 14px var(--c); } }
.pkeys .bot-label { font-style: italic; }

/* ---------------------------------------------------------------- mode cards */
.mode-list { display: flex; flex-direction: column; gap: 10px; }
.mode {
  text-align: left; cursor: pointer; border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02); transition: 0.2s;
}
.mode:hover:not(:disabled) { border-color: var(--line-strong); }
.mode.sel { border-color: var(--accent); background: rgba(0, 229, 255, 0.07); box-shadow: 0 0 20px rgba(0, 229, 255, 0.15); }
.mode:disabled { cursor: default; }
.mode:disabled:not(.sel) { opacity: 0.45; }
.mode .mname { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em; font-size: 15px; }
.mode .mdesc { color: var(--muted); font-size: 15px; margin-top: 2px; }
.mode .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.mode .tags span { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.mode-list.compact .mode { padding: 10px 14px; }
.mode-list.compact .tags { display: none; }

/* ---------------------------------------------------------------- help */
.rules { margin: 0 0 20px; padding-left: 20px; line-height: 1.55; }
.rules li { margin-bottom: 4px; }
.levels { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.levels li b { font-family: var(--font-display); font-size: 13px; letter-spacing: 0.08em; margin-right: 8px; }
.levels li span { color: var(--muted); }
.bonus-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.bonus-list li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; }
.bonus-list .icon { width: 56px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); }
.bonus-list .icon canvas { max-width: 46px; max-height: 38px; }
.bonus-list b { display: block; font-weight: 700; }
.bonus-list span { color: var(--muted); font-size: 15px; }

/* ---------------------------------------------------------------- online */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field span { font-size: 14px; color: var(--muted); letter-spacing: 0.04em; }
input {
  font: inherit; font-weight: 600; color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; outline: none; transition: 0.15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15); }
.online-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .online-actions { grid-template-columns: 1fr; } }
.oa-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: rgba(255, 255, 255, 0.02); }
.oa-card h3 { margin: 0; }
.oa-card p { margin: 0 0 auto; color: var(--muted); font-size: 15px; }
.code-input { font-family: var(--font-display); letter-spacing: 0.4em; text-transform: uppercase; text-align: center; font-size: 22px; }
.lobby-head { grid-template-columns: 1fr auto; }
.room-code {
  font-family: var(--font-display); font-weight: 900; font-size: 44px; letter-spacing: 0.25em; color: #e9fdff;
  text-shadow: 0 0 14px var(--accent), 0 0 36px rgba(0, 229, 255, 0.5);
}
.count { color: var(--text); margin-left: 6px; }
.roster { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.roster li {
  --c: hsl(var(--h) var(--s) var(--l));
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  background: color-mix(in srgb, var(--c) 7%, transparent);
}
.roster li i { width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.roster li .n { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.tag.you { border-color: var(--accent); color: var(--accent); }
.roster .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; padding: 0 4px; }
.roster .x:hover { color: #ff7a8a; }
.bot-buttons { display: flex; gap: 8px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.stepper button { width: 40px; height: 38px; border: 0; background: rgba(255, 255, 255, 0.04); cursor: pointer; font-size: 20px; }
.stepper button:hover:not(:disabled) { background: rgba(0, 229, 255, 0.12); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper span { min-width: 44px; text-align: center; font-family: var(--font-display); font-weight: 700; }
.locals-keys { color: var(--muted); font-size: 15px; margin-bottom: 18px; display: grid; gap: 4px; }
#app:not(.is-host) .host-only { display: none; }

/* ---------------------------------------------------------------- pause & toast */
.screen-pause { background: rgba(3, 4, 10, 0.6); }
.pause-panel { text-align: center; width: min(380px, 100%); }
.pause-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 20; padding: 10px 18px; border-radius: 12px;
  background: var(--panel-solid); border: 1px solid var(--line-strong); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  opacity: 0; transition: 0.25s; pointer-events: none; font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.mode-list + h3, .host-only > h3:first-child { margin-top: 20px; }

/* ---------------------------------------------------------------- match winner */
.screen-winner { background: rgba(3, 4, 10, 0.55); }
.winner-panel {
  --c: var(--accent); position: relative; overflow: hidden; text-align: center; width: min(480px, 100%);
  border-color: color-mix(in srgb, var(--c) 50%, transparent);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px color-mix(in srgb, var(--c) 22%, transparent);
}
.winner-glow {
  position: absolute; left: 50%; top: -120px; width: 360px; height: 260px; transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 40%, transparent), transparent); animation: glow 3s ease-in-out infinite;
}
@keyframes glow { 50% { opacity: 0.55; transform: translateX(-50%) scale(1.15); } }
.winner-panel > *:not(.winner-glow) { position: relative; }
.winner-cup {
  width: 64px; height: 64px; color: var(--c); margin: 4px auto 6px; display: block;
  filter: drop-shadow(0 0 8px var(--c)) drop-shadow(0 0 22px var(--c)); animation: cup 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes cup { from { transform: scale(0.3) rotate(-14deg); opacity: 0; } }
.winner-name {
  font-weight: 900; font-size: clamp(34px, 7vw, 54px); letter-spacing: 0.06em; margin: 6px 0 0; overflow-wrap: anywhere;
  color: color-mix(in srgb, var(--c) 35%, #fff); text-shadow: 0 0 10px var(--c), 0 0 34px var(--c);
}
.winner-sub { margin: 4px 0 20px; color: var(--muted); font-size: 18px; letter-spacing: 0.04em; }
.standings { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; text-align: left; }
.standings li {
  --pc: hsl(var(--h) var(--s) var(--l));
  display: grid; grid-template-columns: 10px minmax(0, 8em) 1fr 2.2em; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid transparent;
}
.standings li.champ { border-color: color-mix(in srgb, var(--pc) 45%, transparent); background: color-mix(in srgb, var(--pc) 10%, transparent); }
.standings i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.standings .n { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standings .bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.standings .bar span { display: block; height: 100%; background: var(--pc); box-shadow: 0 0 8px var(--pc); animation: grow 0.9s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes grow { from { width: 0; } }
.standings b { font-family: var(--font-display); text-align: right; color: var(--pc); }
.winner-note { margin: 0 0 14px; }
.winner-note[hidden] { display: none; }
.winner-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.winner-buttons .btn { flex: 1 1 130px; }
@media (max-width: 760px) { .screen { padding-top: 60px; } }

/* ---------------------------------------------------------------- keys & multiplayer hints */
.cap {
  --kc: var(--c, var(--accent));
  display: inline-grid; place-items: center; min-width: 30px; padding: 2px 8px; font-size: 16px; line-height: 1.3; color: #fff;
  border: 1px solid color-mix(in srgb, var(--kc) 70%, transparent); background: color-mix(in srgb, var(--kc) 16%, rgba(0, 0, 0, 0.5));
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 12px color-mix(in srgb, var(--kc) 30%, transparent);
}
.cap.big { min-width: 58px; padding: 6px 12px; font-size: 24px; border-radius: 10px; }
.pair { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; }
.pair small { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* setup cards: a human's keys are the thing to remember */
.pcard.human .pkeys { gap: 22px; min-height: 76px; padding: 6px 0 2px; }
.pcard .key.cap { cursor: pointer; font-family: var(--font-body); font-weight: 700; color: #fff; --kc: var(--c); }
.pcard .key.cap:hover { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 20px var(--c); }
.pcard .key.cap.listening { font-size: 15px; color: var(--c); }

.callout {
  border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; line-height: 1.4;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.03); color: var(--muted);
}
.callout b { color: var(--text); }
.callout.solo { border-color: color-mix(in srgb, var(--accent-2) 55%, transparent); background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.callout.solo b:first-child { color: #ffb6f9; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-weight: 700; }
.menu-note { margin: 22px 0 0; color: var(--muted); font-size: 16px; letter-spacing: 0.04em; }
.menu-note b { color: #ffb6f9; text-shadow: 0 0 12px rgba(255, 61, 242, 0.5); }

/* round intro: who steers with what */
.keys-reminder { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.keys-reminder .kicker { margin-bottom: 8px; }
.ctls { display: flex; flex-wrap: wrap; gap: 8px 10px; justify-content: center; }
.ctl {
  --c: hsl(var(--h) var(--s) var(--l));
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent);
}
.ctl i, .ctl-row i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.ctl .n { font-weight: 700; margin-right: 2px; }

/* help page and lobby: big keys with captions */
.help-controls {
  margin: -4px 0 22px; padding: 14px 16px 6px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); background: rgba(0, 229, 255, 0.05);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.1);
}
.help-controls[hidden] { display: none; }
.help-controls h3 { color: var(--accent); }
.ctl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 10px; }
.ctl-row {
  --c: hsl(var(--h) var(--s) var(--l));
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent);
}
.ctl-row .n { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locals-keys { color: var(--text); gap: 8px; }

/* ---------------------------------------------------------------- catch-up mode */
.catchup-ctl { text-align: left; }
.catchup-ctl .seg { --c: var(--accent); flex: 1; max-width: 240px; grid-template-columns: repeat(2, 1fr); }
.catchup-ctl .seg button { padding: 6px 2px; font-size: 14px; }
.catchup-ctl .look-row > span { width: 64px; flex: none; color: var(--muted); font-weight: 600; }
.cu-what { font-size: 14px; margin: 6px 0 8px; }
.cu-body[hidden] { display: none; }
.look-ctl + h3 { margin-top: 18px; }
.cu-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.cu-row span { width: 64px; flex: none; color: var(--muted); font-weight: 600; }
.cu-row input { flex: 1; min-width: 0; accent-color: var(--accent); height: 26px; cursor: pointer; }
.cu-row b { min-width: 56px; text-align: right; font-family: var(--font-display); color: var(--accent); }
.cu-foot { display: flex; align-items: center; gap: 10px; }
.cu-foot .hint { margin: 0; font-size: 14px; flex: 1; }
.chip .spd { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
