/* The lobby's look (index.html): night-time asphalt with a checkered sheen, glass panels, orange and yellow for what
   matters, and the eight drivers' colours on their seats, names and dots. Light when the system is. */
:root {
  --bg: #0d1020; --bg-2: #161a33; --glow-1: rgba(255, 138, 31, 0.22); --glow-2: rgba(74, 217, 255, 0.16);
  --glass: rgba(255, 255, 255, 0.06); --glass-strong: rgba(255, 255, 255, 0.11); --glass-line: rgba(255, 255, 255, 0.13);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  --text: #f4f2ff; --muted: #a9a6c4; --accent: #ff8a1f; --accent-2: #ffd23f; --accent-text: #1b1200;
  --ok: #5ee0a0; --warn: #ffd23f; --error: #ff7a8a;
  --p1: #ff8a1f; --p2: #4ad9ff; --p3: #5ee0a0; --p4: #ff5a9a; --p5: #b48cff; --p6: #ffd23f; --p7: #ff6a4a; --p8: #7cf2d0;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f1fb; --bg-2: #e7e9ff; --glow-1: rgba(255, 138, 31, 0.18); --glow-2: rgba(74, 160, 255, 0.16);
    --glass: rgba(255, 255, 255, 0.6); --glass-strong: rgba(255, 255, 255, 0.85); --glass-line: rgba(20, 20, 60, 0.1);
    --shadow: 0 12px 34px rgba(40, 30, 90, 0.14);
    --text: #1d1b33; --muted: #5f5c7a; --accent: #f07a10; --accent-2: #f5b800; --accent-text: #1b1200;
    --ok: #1f9e6a; --warn: #a36f00; --error: #c8324a;
    --p1: #f07a10; --p2: #1a9fd6; --p3: #1fae72; --p4: #e0367a; --p5: #7a52e0; --p6: #d19a00; --p7: #e04a2a; --p8: #17a88a;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg);
  background-image:
    radial-gradient(50vmax 40vmax at 10% 0%, var(--glow-1), transparent 70%),
    radial-gradient(45vmax 40vmax at 95% 100%, var(--glow-2), transparent 70%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.018) 0 25%, transparent 0 50%);
  background-size: auto, auto, 56px 56px;
  background-attachment: fixed;
}
[hidden] { display: none !important; }
h1 { font-size: clamp(34px, 7vw, 56px); margin: 0 0 4px; letter-spacing: -0.03em; font-weight: 900; font-style: italic; }
h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
p { margin: 0 0 12px; }
input, button { font: inherit; color: inherit; }
kbd { font: 12px ui-monospace, monospace; padding: 1px 6px; border-radius: 6px; background: var(--glass-strong); border: 1px solid var(--glass-line); }

/* Glass: every panel, card, input and button. */
.card, .panel, input, button {
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
}
.card, .panel { border-radius: 22px; padding: 22px; box-shadow: var(--shadow); }
input { width: 100%; padding: 11px 14px; border-radius: 12px; background: var(--glass-strong); }
input::placeholder { color: var(--muted); }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { padding: 11px 18px; border-radius: 12px; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s, background 0.12s; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255, 138, 31, 0.22); }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent;
  color: var(--accent-text); font-weight: 800;
}
button.primary.big { padding: 14px 26px; font-size: 18px; }
button.ghost { background: transparent; }
button.small { padding: 6px 12px; font-size: 14px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 14px; margin-top: 10px; }
.error { color: var(--error); min-height: 1.4em; margin-top: 16px; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; margin-right: 6px; }
.pill { display: inline-block; margin-left: 8px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--glass-strong); border: 1px solid var(--glass-line); vertical-align: middle; }

/* Home. */
.screen { max-width: 1000px; margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 16px 40px; }
.screen.wide { max-width: 1200px; }
.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.hero .lead { color: var(--muted); margin: 0; max-width: 560px; }
.flag { flex: none; width: 66px; height: 66px; border-radius: 18px; transform: rotate(-8deg); box-shadow: var(--shadow);
  background: repeating-conic-gradient(#fff 0 25%, #15172a 0 50%) 0 0 / 22px 22px; border: 3px solid var(--accent); }
.game-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; padding: 10px 14px;
  border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line); font-size: 14px; color: var(--muted); }
.game-status.ready { color: var(--ok); }
.game-status.ready .spinner, .game-status.ready .meter, .game-status.error .spinner { display: none; }
.game-status.error { color: var(--error); }
.game-status .meter { flex: 1 1 140px; height: 6px; border-radius: 99px; background: var(--glass-strong); overflow: hidden; min-width: 100px; }
.game-status .meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s; }
.profile { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.field { display: block; flex: 1; min-width: 200px; max-width: 360px; font-weight: 700; margin: 0; }
.field input { margin-top: 6px; font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; }
.card p { color: var(--muted); }
.card .hint { margin: 0 0 12px; }
.quick-card { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, var(--glass)), color-mix(in srgb, var(--accent-2) 14%, var(--glass))); }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line); margin-bottom: 8px; }
.segmented .seg { flex: 1; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; font-weight: 650; font-size: 14px; backdrop-filter: none; }
.segmented .seg.on { background: var(--glass-strong); box-shadow: inset 0 0 0 2px var(--accent); }
.segmented .seg:hover { transform: none; box-shadow: none; }
#code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; }

/* Avatars: a picture or the name's first letter, in the seat's colour. */
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--seat, var(--accent)); color: #fff; font-weight: 800; font-size: 15px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border: 2px solid color-mix(in srgb, var(--seat, var(--accent)) 60%, #fff);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.tiny { width: 22px; height: 22px; font-size: 11px; border-width: 1px; }
.avatar.small { width: 30px; height: 30px; font-size: 13px; }
button.avatar.big { position: relative; width: 84px; height: 84px; padding: 0; font-size: 32px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.avatar.big #avatar-preview { display: grid; place-items: center; width: 100%; height: 100%; }
.avatar.big .edit { position: absolute; right: -2px; bottom: -2px; font-size: 18px; text-shadow: none; }

/* Room. */
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.bar > div { margin-right: auto; }
.code {
  font-size: 30px; letter-spacing: 0.2em; font-weight: 900; font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.banner { margin-bottom: 18px; padding: 12px 16px; border-radius: 16px; font-weight: 650;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, var(--glass)), var(--glass)); border: 1px solid var(--glass-line); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 820px) { .split { grid-template-columns: minmax(0, 1fr); } }
.stack { min-width: 0; }
.stack { display: grid; gap: 18px; align-content: start; }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seat {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 9px 12px; border-radius: 14px;
  background: color-mix(in srgb, var(--seat, transparent) 16%, var(--glass-strong));
  border: 1px solid color-mix(in srgb, var(--seat, var(--glass-line)) 50%, transparent);
}
.seat.empty { color: var(--muted); background: transparent; border-style: dashed; border-color: var(--glass-line); padding: 6px 12px; }
.seat .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.seat .tag { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--glass-strong); white-space: nowrap; }
.seat .tag.ready { color: var(--ok); }
.seat .tag.waiting { color: var(--muted); }
.seat .tag.host { color: var(--accent); font-weight: 700; }
.seat .tag.racing { color: var(--accent-2); }
.tag.game { font-size: 12px; padding: 3px 9px; border-radius: 99px; white-space: nowrap; background: var(--glass-strong); }
.tag.game.ready { color: var(--ok); }
.tag.game.waiting { color: var(--muted); }
.tag.game.error { color: var(--error); }
.grid-players .tag.game { background: rgba(255, 255, 255, 0.1); }
.grid-players .tag.game.waiting { color: rgba(255, 255, 255, 0.75); }
.countdown-box button.ghost.light { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.p1 { --seat: var(--p1); } .p2 { --seat: var(--p2); } .p3 { --seat: var(--p3); } .p4 { --seat: var(--p4); }
.p5 { --seat: var(--p5); } .p6 { --seat: var(--p6); } .p7 { --seat: var(--p7); } .p8 { --seat: var(--p8); }
.actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .hint { flex-basis: 100%; margin: 0; }
.actions.center { justify-content: center; }

/* Characters: a coloured badge with the name's initial (nothing of the game's art). */
.character { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14px; min-width: 0; }
.chr-badge { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--chr); color: #fff;
  font-weight: 900; font-size: 13px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); transform: rotate(-4deg); }
.chr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.character.small { font-size: 12px; gap: 4px; }
.character.small .chr-badge { width: 20px; height: 20px; font-size: 10px; border-radius: 6px; }
.characters { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.characters .chr-pick { position: relative; flex-direction: column; justify-content: flex-start; padding: 10px 8px 8px; }
.characters .chr-pick .character { flex-direction: column; gap: 8px; width: 100%; }
.characters .chr-pick .chr-badge { width: 84px; height: 84px; border-radius: 18px; font-size: 34px; transform: none;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18), 0 6px 14px rgba(0, 0, 0, 0.25); }
.characters .chr-pick .chr-name { text-align: center; white-space: normal; line-height: 1.2; }
.characters .chr-pick > .avatar { position: absolute; top: 6px; right: 6px; }
@media (max-width: 560px) { .characters { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .characters .chr-pick .chr-badge { width: 64px; height: 64px; font-size: 26px; } }
.seat .character .chr-badge.face, .grid-players .character .chr-badge.face { width: 30px; height: 30px; border-radius: 8px; transform: none; }
.chr-pick { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border-radius: 14px; min-width: 0; }
.chr-pick.mine { box-shadow: 0 0 0 3px var(--accent); background: var(--glass-strong); }
.chr-pick.taken { opacity: 0.5; }
.seat .character { margin-left: auto; }

/* The race's setup: cards with pictures. */
.setup h3 { margin: 16px 0 8px; font-size: 14px; font-weight: 750; }
.setup h3:first-child { margin-top: 0; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.cards-row.kind-track { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.pick { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 5px 5px 8px;
  border-radius: 16px; text-align: left; }
.pick .art { display: block; border-radius: 11px; overflow: hidden; aspect-ratio: 16 / 10; }
.pick .art svg, .pick .art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chr-badge.face { display: block; position: relative; padding: 0; overflow: hidden; background: #000; }
.chr-badge.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .logo { flex: none; width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35)); }
@media (max-width: 560px) { .hero .logo { width: 60px; height: 60px; } }
.pick-label { font-weight: 750; font-size: 13px; padding: 0 4px; line-height: 1.25; }
.pick-note { font-size: 11px; color: var(--muted); padding: 0 4px; }
.pick.picked { box-shadow: 0 0 0 3px var(--accent), var(--shadow); background: var(--glass-strong); }
.pick.mine { outline: 2px dashed var(--accent-2); outline-offset: 2px; }
.pick.soon { opacity: 0.5; }
.pick .check { position: absolute; top: 9px; right: 9px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 900; font-size: 13px; }
.pick .dots { position: absolute; top: 9px; left: 9px; display: flex; gap: 3px; flex-wrap: wrap; max-width: 70%; }
.pick .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--seat); border: 2px solid #fff; }
.pick:disabled { cursor: default; transform: none; }

/* Wins and positions. */
.wins, .score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wins li, .score-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--glass-strong); }
.wins li.hint { background: transparent; padding: 0; }
.wins .rank, .score-list .rank { width: 1.8em; text-align: center; font-size: 17px; font-weight: 900; }
.wins .who, .score-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.wins .count, .score-list .lap { color: var(--muted); font-size: 13px; white-space: nowrap; }
.board .stat { color: var(--muted); font-size: 12px; white-space: nowrap; }
.board .points { font-weight: 900; color: var(--accent-2); white-space: nowrap; min-width: 4.2em; text-align: right; }
.board-title { margin-top: 16px; }
@media (max-width: 560px) { .board .stat { display: none; } }
.recent-card { margin-bottom: 18px; }
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-room { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; }
.recent-room .code.small { font-size: 18px; }
.score-list li { border-left: 4px solid var(--seat); }
.score-list .done { color: var(--ok); font-weight: 700; font-size: 13px; }

/* Chat. */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-home .chat { height: 400px; }
.chat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-home .key-hint { display: none; }
.messages { list-style: none; margin: 0 0 10px; padding: 4px; flex: 1; overflow-y: auto; min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.messages li { word-wrap: break-word; padding: 7px 11px; border-radius: 12px; background: var(--glass-strong); align-self: flex-start; max-width: 100%; }
.messages li.line { display: flex; gap: 8px; align-items: flex-start; }
.messages .name { font-weight: 800; color: var(--seat, var(--text)); margin-right: 6px; }
.messages .system { background: transparent; color: var(--muted); font-style: italic; font-size: 14px; align-self: center; text-align: center; }
.emoji-toggle { padding: 8px 10px; font-size: 18px; line-height: 1; }
.emoji-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; padding: 8px; margin-bottom: 8px;
  border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--glass-line); max-height: 150px; overflow-y: auto; }
.emoji-panel button { padding: 4px; font-size: 20px; line-height: 1.2; border: 0; background: transparent; backdrop-filter: none; }
.emoji-panel button:hover { background: var(--glass); transform: scale(1.15); box-shadow: none; }

/* The game: always there, behind the lobby while it waits (drawn, so the browser keeps it running), over it in a race. */
#play { position: fixed; inset: 0; background: #000; overflow: hidden; z-index: 10; }
#play.preloading { z-index: -1; opacity: 0; pointer-events: none; }
#play.preloading * { pointer-events: none !important; }
#play.preloading .hud, #play.preloading .touch, #play.preloading .call-play, #play.preloading .toasts { display: none; }
#game, #game iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80%; padding: 16px 20px; z-index: 6;
  color: #fff; border-radius: 16px; text-align: center; background: rgba(13, 16, 32, 0.8); border: 1px solid rgba(255, 255, 255, 0.2); }

/* The countdown, from Start until the player's race is under way. */
.countdown, .result { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; color: #fff;
  background: radial-gradient(60vmax 50vmax at 15% 10%, rgba(255, 138, 31, 0.35), transparent 70%),
    radial-gradient(60vmax 50vmax at 85% 90%, rgba(74, 217, 255, 0.28), transparent 70%), rgba(10, 12, 26, 0.94); }
.result { background: rgba(10, 12, 26, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.countdown-box, .result-box { width: min(480px, 100%); text-align: center; max-height: 100%; overflow-y: auto; }
.countdown-box h2 { color: #fff; font-size: clamp(26px, 5vw, 38px); text-transform: none; letter-spacing: -0.01em; margin: 0; font-weight: 900; font-style: italic; }
.label.light, .muted-light { color: rgba(255, 255, 255, 0.72); }
.countdown-number { font-size: clamp(90px, 22vmin, 170px); font-weight: 900; line-height: 1; margin: 8px 0; font-style: italic;
  background: linear-gradient(180deg, #ffd23f, #ff8a1f); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(255, 138, 31, 0.25); }
.countdown-number.tick { animation: tick 0.9s ease-out; }
@keyframes tick { from { transform: scale(1.35); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
.grid-players { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; text-align: left; }
.grid-players li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border-left: 4px solid var(--seat); }
.grid-players .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.result-place { font-size: clamp(70px, 18vmin, 130px); font-weight: 900; font-style: italic; line-height: 1;
  background: linear-gradient(180deg, #ffd23f, #ff8a1f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-box .score-list { margin: 14px 0; text-align: left; color: var(--text); }
.result-box button.ghost.light { color: #fff; border-color: rgba(255, 255, 255, 0.3); }

/* The HUD, over the game. */
.hud { position: absolute; z-index: 8; pointer-events: none; }
.hud-buttons, .hud-chip { transition: opacity 0.5s; }
#play.idle .hud-buttons, #play.idle .hud-chip { opacity: 0.18; }
.hud-seats li.leader { border-color: var(--accent-2); box-shadow: 0 0 12px rgba(255, 210, 63, 0.35); }

/* Alerts: who hit whom, over the game, for a few seconds. */
.alerts { position: absolute; z-index: 8; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 58px); transform: translateX(-50%);
  margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  width: min(560px, calc(100vw - 24px)); }
.alert { padding: 9px 18px; border-radius: 14px; color: #fff; font-weight: 800; font-size: clamp(15px, 2.4vw, 20px); text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: alert-in 0.25s ease-out; transition: opacity 0.5s; }
.alert.hurt { background: rgba(200, 40, 60, 0.62); border: 1px solid rgba(255, 120, 130, 0.6); }
.alert.hit { background: rgba(30, 150, 90, 0.62); border: 1px solid rgba(120, 240, 170, 0.6); }
.alert.gone { opacity: 0; }
@keyframes alert-in { from { opacity: 0; transform: scale(0.85); } }
.banner.cup { background: linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 30%, var(--glass)), var(--glass)); }
.hud > * { pointer-events: auto; }
.hud-top { top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 10px; }
.hud-chip, .hud-button, .hud-seats li { background: rgba(13, 16, 32, 0.42); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.hud-chip { padding: 5px 12px; border-radius: 99px; font-size: 14px; }
.hud-chip .label { color: rgba(255, 255, 255, 0.7); }
.code.small { font-size: 15px; letter-spacing: 0.15em; }
.hud-seats { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; opacity: 0.9; }
.hud-seats li { padding: 3px 10px 3px 3px; border-radius: 99px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.hud-seats li .place { font-weight: 900; color: var(--seat); }
.hud-buttons { margin-left: auto; display: flex; gap: 8px; }
.hud-button { position: relative; width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 19px; line-height: 1; }
.hud-button.off { opacity: 0.5; }
.badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; }
.hud-panel { position: absolute; z-index: 9; right: max(12px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 54px);
  width: min(360px, calc(100vw - 24px)); max-height: calc(100% - 80px); overflow-y: auto; padding: 16px; border-radius: 20px; color: var(--text);
  background: color-mix(in srgb, var(--bg) 78%, transparent); border: 1px solid var(--glass-line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%); }
.chat-play { height: min(460px, calc(100% - 90px)); display: flex; }
.chat-play[hidden] { display: none !important; }
.chat-play .chat { flex: 1; }
.settings { display: grid; gap: 12px; }
.settings h2 { margin: 0; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.scoreboard h2 { margin-bottom: 10px; }
.scoreboard h2 .hint { text-transform: none; letter-spacing: 0; }

/* Chat notifications over the game: see-through, gone after a few seconds, never in the way of a click. */
.toasts { position: absolute; z-index: 8; left: max(14px, env(safe-area-inset-left)); bottom: 14px; margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px; max-width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.toasts li { display: flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 12px; color: #fff; font-size: 14px; word-wrap: break-word;
  background: rgba(13, 16, 32, 0.38); border: 1px solid rgba(255, 255, 255, 0.16); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); animation: toast-in 0.2s ease-out; transition: opacity 0.6s; }
.toasts li.gone { opacity: 0; }
.toasts .name { font-weight: 800; color: var(--seat, #fff); margin-right: 6px; }
.toasts .system { font-style: italic; opacity: 0.85; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.touch-active .toasts { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 54px); }

/* Touch controls: see-through, at the sides of the game's picture. */
.touch { position: absolute; inset: 0; z-index: 6; pointer-events: none; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch button, .stick { pointer-events: auto; touch-action: none; color: #fff; font-weight: 800; box-shadow: none; transform: none;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.32); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.touch button.held, .stick.held { background: rgba(255, 255, 255, 0.4); }
.touch-left, .touch-right { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.touch-left { left: max(14px, env(safe-area-inset-left)); align-items: flex-start; }
.touch-right { right: max(14px, env(safe-area-inset-right)); align-items: flex-end; }
.touch-shoulders { display: flex; gap: 8px; }
.touch-shoulders button { min-width: 56px; height: 40px; border-radius: 12px; padding: 0 10px; font-size: 14px; }
.touch-shoulders button.r1 { min-width: 92px; background: rgba(255, 138, 31, 0.32); }
.touch-shoulders small { font-weight: 600; font-size: 10px; opacity: 0.85; }
.stick { width: 36vmin; height: 36vmin; max-width: 176px; max-height: 176px; border-radius: 50%; position: relative; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%; border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
.face { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 2px; }
.face .ps { width: 62px; height: 62px; border-radius: 50%; padding: 0; font-size: 24px; }
.face .tri { grid-area: 1 / 2; color: #5ee0a0; } .face .sq { grid-area: 2 / 1; color: #ff7ad1; }
.face .ci { grid-area: 2 / 3; color: #ff6a6a; } .face .cr { grid-area: 3 / 2; color: #6ab8ff; width: 72px; height: 72px; margin: -5px; background: rgba(74, 160, 255, 0.28); }
.touch-start { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%) !important;
  padding: 6px 16px; border-radius: 99px; font-size: 12px; letter-spacing: 0.08em; }

/* The controls panel. */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 15, 0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-box { width: min(680px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; border-radius: 22px; color: var(--text);
  background: color-mix(in srgb, var(--bg) 90%, transparent); border: 1px solid var(--glass-line); box-shadow: var(--shadow); }
.modal-box .bar { margin-bottom: 8px; }
.modal-box .bar h2 { margin: 0 auto 0 0; }
.bindings { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: 14px; }
.bindings th { text-align: left; color: var(--muted); font-weight: 650; padding: 4px 6px; font-size: 13px; }
.bindings tbody th { color: var(--text); white-space: nowrap; }
.bindings td { padding: 6px; background: var(--glass); }
.bindings td:first-of-type { border-radius: 10px 0 0 10px; } .bindings td:last-child { border-radius: 0 10px 10px 0; }
.bindings td { padding: 3px 4px; }
.bindings .bind { width: 100%; padding: 6px 10px; font-size: 13px; text-align: left; border-radius: 10px; }
.bindings .bind.waiting { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); animation: pulse 1s infinite; }
.bindings td.live { width: 18px; }
.bindings tr.on td.live::after { content: ''; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.bindings tr.on th { color: var(--accent); }
.bindings tr.asking th { color: var(--accent-2); }
.wizard { padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 22%, var(--glass)); border: 1px solid var(--accent);
  margin: 0 0 10px; }
@keyframes pulse { 50% { opacity: 0.7; } }

/* The voice and video call: tiles in the waiting room, bubbles over the game. */
.call-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.call-buttons button { font-size: 14px; padding: 8px 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.tile { position: relative; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: rgba(13, 16, 32, 0.6);
  border: 2px solid color-mix(in srgb, var(--seat, var(--accent)) 70%, transparent); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.tile:not([data-key="me"]) video { transform: none; }
.tile .tile-avatar { position: absolute; inset: 0; display: none; place-items: center; }
.tile .tile-avatar .avatar { width: 52px; height: 52px; font-size: 22px; }
.tile.no-cam video { opacity: 0; }
.tile.no-cam .tile-avatar { display: grid; }
.tile-name { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 99px; font-size: 12px; color: #fff;
  background: rgba(13, 16, 32, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.call-play { position: absolute; z-index: 8; right: max(12px, env(safe-area-inset-right)); bottom: 12px; pointer-events: none; }
.call-play .call { pointer-events: auto; }
.call-play .call-buttons, .call-play .hint { display: none; }
.call-play .tiles { grid-template-columns: none; grid-auto-flow: row; gap: 8px; margin: 0; }
.call-play .tile { width: 118px; opacity: 0.92; }
.touch-active .call-play { right: auto; left: 50%; bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 54px); transform: translateX(-50%); }
.touch-active .call-play .tiles { grid-auto-flow: column; }
.touch-active .call-play .tile { width: 78px; }

/* A phone held upright in a race: a note to turn it. */
.rotate { display: none; position: absolute; inset: 0; z-index: 9; place-items: center; padding: 24px; text-align: center;
  font-size: 20px; font-weight: 700; color: #fff; background: rgba(13, 16, 32, 0.82); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
@media (pointer: coarse) and (orientation: portrait) { #play:not(.preloading) .rotate { display: grid; } }
@media (orientation: landscape) and (max-height: 500px) {
  .hud-top { top: 6px; }
  .hud-button { width: 36px; height: 36px; font-size: 16px; }
  .hud-seats { display: none; }
  .stick { width: 32vmin; height: 32vmin; }
  .face { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); }
  .face .ps { width: 52px; height: 52px; font-size: 20px; }
  .face .cr { width: 60px; height: 60px; }
}

.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent); border-right-color: var(--accent-2); animation: spin 0.9s linear infinite; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
  .hero { gap: 12px; }
  .flag { width: 48px; height: 48px; border-radius: 12px; background-size: 16px 16px; }
  .card, .panel { padding: 16px; border-radius: 18px; }
  .code { font-size: 24px; }
}
