/* Ruckus: the flat layer over the 3D view. This file is the STRUCTURE: where every part sits, how big its
   touch area is, when it shows, how it moves. It reads design tokens only; every colour, face, shape and
   curve comes from the chosen look (looks/<id>/look.css, scoped to [data-look] on <html>). docs/LOOKS.md
   lists the tokens and the parts. The values below are plain fallbacks: a look sets all of them.
   Three moods (data-theme on <html>: day, neon, studio) belong to the 3D world; a look reads over all three. */
:root {
  /* type */
  --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: var(--font); --display-style: normal; --display-stretch: 75%; --display-weight: 900;
  --label-case: uppercase; --label-tracking: 0.04em;
  /* plates: the HUD over the world */
  --plate: rgba(255, 255, 255, 0.92); --on-plate: #14161c; --on-plate-2: #4b5060; --plate-border: rgba(20, 22, 28, 0.14); --plate-shadow: 0 12px 30px -14px rgba(20, 30, 50, 0.5);
  --bar: transparent; --bar-shadow: none;
  /* sheets: the room sheet, the results */
  --surface: #ffffff; --surface-2: #f1f2f4; --text: #14161c; --text-2: #4b5060; --border: rgba(20, 22, 28, 0.16); --field: #f6f7f8;
  --sheet-top: 0px; --shadow-hard: 0 12px 30px -14px rgba(20, 30, 50, 0.5);
  /* accent and states */
  --accent: #14161c; --on-accent: #ffffff; --bad: #c8202c; --focus-ring: #14161c;
  /* shape */
  --radius-sm: 8px; --radius: 10px; --radius-lg: 14px; --line: 1px; --line-style: solid;
  --cut: none; --cut-sm: none; --bar-w: 4px;
  /* moments */
  --dim: rgba(8, 9, 12, 0.72); --lights-off: #2c2f36; --lights-on: #ffb000;
  /* the action button */
  --act-bg: #14161c; --act-ink: #ffffff; --act-ring: var(--you); --act-track: transparent; --act-lip: transparent; --act-travel: 0px;
  /* motion (the Feature Library's motion playbook names) */
  --motion-fast: 120ms; --motion-move: 220ms; --motion-enter: 320ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1); --ease-in: cubic-bezier(0.4, 0, 1, 1); --spring: cubic-bezier(0.3, 1.35, 0.5, 1);
  /* not a look's: the player's own colour (set from the game), the safe areas, the gutter, the bar */
  --you: #f2452b;
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
  --gut: 14px; --bar-h: 58px; --below-bar: calc(var(--sat) + var(--bar-h) + 10px);
}
/* The moods: the page behind the canvas and the browser's bar colour. */
[data-theme='day'] { --page: #a9d3f2; }
[data-theme='studio'] { --page: #c3c5ca; }
[data-theme='neon'] { --page: #05060d; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--on-plate); font: 500 14px/1.3 var(--font); overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#game { position: fixed; inset: 0; height: 100dvh; overflow: clip; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; }
button { font: inherit; color: inherit; }
b { font-weight: 800; }
[hidden] { display: none !important; }
.num, .bug-num, .b-val, .row .num, .row .gain, .row .place, .b-place { font-variant-numeric: tabular-nums; }
/* The display face: italic, narrow and heavy in Broadcast; the look decides. */
.display { font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); text-transform: var(--label-case); }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
/* A clipped plate (a look's cut corners) would cut an outside ring off: the ring goes inside. */
:is(.youchip, .iconbtn, .actbtn, .tabs [role="tab"]):focus-visible { outline-offset: -4px; }

/* A player's colour with their initial on it (never the colour alone). */
.ptag { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; background: var(--c); color: var(--ci, #fff); font: 900 12px/1 var(--font); font-style: normal; text-transform: uppercase; }

/* ---------- the top bar: the match card (left), your chip and pause (right) */
.top { position: absolute; left: 0; right: 0; top: 0; z-index: 5; height: calc(var(--sat) + var(--bar-h)); display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: var(--sat) calc(var(--sar) + var(--gut)) 0 calc(var(--sal) + var(--gut)); background: var(--bar); box-shadow: var(--bar-shadow); pointer-events: none; }
.match { min-width: 0; display: grid; gap: 3px; align-content: center; min-height: 44px; padding: 5px 10px; background: var(--plate); color: var(--on-plate); clip-path: var(--cut-sm); }
.mc-brand { display: none; }
.mc-game { font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); text-transform: var(--label-case); font-size: 18px; line-height: 1; white-space: nowrap; }
.mc-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mc-room { font-size: 11px; font-weight: 700; color: var(--on-plate-2); text-transform: var(--label-case); letter-spacing: var(--label-tracking); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pips { display: inline-flex; gap: 3px; flex: none; }
.pips i { width: 15px; height: 13px; display: grid; place-items: center; background: var(--lights-off); font: 900 9px/1 var(--font); font-style: normal; color: var(--ci, transparent); text-transform: uppercase; }
.pips i.won { background: var(--c); }
.pips i.now { background: var(--accent); }
.tools { display: flex; gap: 6px; flex: none; pointer-events: auto; }
.youchip, .iconbtn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 0; background: var(--plate); color: var(--on-plate); cursor: pointer; touch-action: manipulation; clip-path: var(--cut-sm); }
.youchip { max-width: min(44vw, 230px); padding-left: 8px; font-weight: 800; font-size: 13px; text-transform: var(--label-case); letter-spacing: var(--label-tracking); }
.youchip #youName { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.youchip .ptag { width: 24px; height: 24px; }
.youchip .chev { width: 12px; height: 12px; flex: none; opacity: 0.7; }
/* Alone: the way to invite friends, on the chip that opens the room sheet. */
/* On a narrow screen the badge takes the name's place (the colour tag still carries your initial). */
@media (max-width: 480px) { .youchip:has(.chip-invite:not([hidden])) #youName { display: none; } }
.chip-invite { flex: none; padding: 3px 6px; background: var(--accent); color: var(--on-accent); font: 900 11px/1 var(--font); text-transform: var(--label-case); letter-spacing: var(--label-tracking); border-radius: var(--radius-sm); }
.iconbtn svg { width: 20px; height: 20px; flex: none; }
#bPause[aria-pressed='false'] .tri, #bPause[aria-pressed='true'] .bars { display: none; }

/* ---------- labels in the world: name tags and the pad cards (the Feature Library layer, restyled) */
#labels .wpl-label { pointer-events: none !important; max-width: none; --wpl-gap: 6px; }
#labels .wpl-label[data-kind='tag'] { padding: 2px 8px 2px 6px; min-height: 20px; gap: 5px; border: 0; border-radius: 0; background: var(--plate); color: var(--on-plate); font: 700 12px/1.2 var(--font); box-shadow: 0 3px 10px -4px rgba(0, 0, 0, 0.5); }
#labels .wpl-label[data-kind='tag']::before { content: ''; width: 8px; height: 8px; background: var(--c); flex: none; }
#labels .wpl-label[data-kind='tag']::after { display: none; }
#labels .wpl-label[data-kind='tag'][data-status='you'] { background: var(--accent); color: var(--on-accent); font-weight: 800; }
#labels .wpl-label[data-status='off'] { opacity: 0 !important; }
/* Who is a real person: their tag is ringed in their colour; the bots' tags step back a little. */
#labels .wpl-label[data-kind='tag'][data-status='person'] { box-shadow: inset 0 0 0 2px var(--c), 0 3px 10px -4px rgba(0, 0, 0, 0.5); font-weight: 800; }
#labels .wpl-label[data-kind='tag'][data-status='bot'] { opacity: 0.72; }
/* A pad card slid down over its pad stays over the tags of those standing on it (its vote bars say who); yours stays on top. */
#labels .wpl-label[data-kind='pad'] { z-index: 50000 !important; }
#labels .wpl-label[data-kind='tag'][data-status='you'] { z-index: 60000 !important; }
#labels .wpl-label[data-kind='pad'] { display: block; padding: 0; width: 150px; border: 0; border-radius: 0; background: var(--plate); color: var(--on-plate); box-shadow: var(--plate-shadow); white-space: normal; overflow: visible; font: 600 12px/1.25 var(--font); }
#labels .wpl-label[data-kind='pad']::after { background: var(--on-plate); width: 2px; left: calc(50% - 1px); opacity: 0.5; }
.pad-card canvas { display: block; width: 100%; aspect-ratio: 16 / 9; background: #1a1c24; }
.pad-card .body { padding: 6px 9px 8px; display: grid; gap: 3px; }
.pad-card .name { display: flex; flex-wrap: wrap; row-gap: 3px; align-items: center; justify-content: space-between; gap: 6px; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 15px; line-height: 1; text-transform: var(--label-case); letter-spacing: 0.02em; }
.pad-card .soon { flex: none; font: 800 10px/1 var(--font); font-style: normal; letter-spacing: 0.06em; padding: 3px 5px; border: 1.5px solid currentColor; opacity: 0.8; }
.pad-card .goal { font-weight: 700; font-size: 13px; }
.pad-card .how { display: flex; align-items: center; gap: 5px; color: var(--on-plate-2); font-size: 12px; }
.pad-card .how svg { width: 18px; height: 18px; flex: none; }
.pad-card .votes { display: flex; gap: 3px; margin-top: 3px; }
.pad-card .votes i { flex: 1; height: 6px; background: var(--lights-off); }
.pad-card[data-ready='false'] canvas { filter: saturate(0.35) brightness(0.85); }
.pad-card[data-win='true'] { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- the scorebug: the game now, the same slot in every phase */
.bug, .brief, .board, .podium, .table, .hint, .banner, .news, .moment { position: absolute; z-index: 4; pointer-events: none; }
/* In the bar's middle on a wide or a short screen; under the match card on a phone held upright. */
.bug { left: 50%; top: calc(var(--sat) + (var(--bar-h) - 40px) / 2); z-index: 6; transform: translateX(-50%); display: flex; align-items: stretch; max-width: min(calc(100vw - 2 * var(--gut)), 560px); min-height: 40px; background: var(--plate); color: var(--on-plate); clip-path: var(--cut); opacity: 0; transition: opacity var(--motion-move) var(--ease-out); }
#game:not([data-phase='boot']):not([data-phase='nogl']) .bug { opacity: 1; }
[data-moment='on'] .bug { opacity: 0 !important; }
.bug-lights { display: none; align-items: center; gap: 4px; padding: 0 0 0 12px; }
.bug-lights i { width: 11px; height: 11px; border-radius: 50%; background: var(--lights-off); }
.bug-lights i.on { background: var(--lights-on); }
.bug[data-lights='1'] .bug-lights, .bug[data-lights='2'] .bug-lights, .bug[data-lights='3'] .bug-lights { display: inline-flex; }
.bug-num { display: grid; place-items: center; min-width: 2.2em; padding: 3px 8px 2px 14px; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 28px; line-height: 1; color: var(--accent-num, var(--on-plate)); }
.bug-num:empty { display: none; }
.bug-text { align-self: center; padding: 6px 16px 6px 6px; font-weight: 800; font-size: 13px; line-height: 1.2; text-transform: var(--label-case); letter-spacing: var(--label-tracking); min-width: 0; }
.bug-num:empty + .bug-text { padding-left: 16px; }

/* ---------- the intro: a title card */
.brief { left: 50%; top: calc(var(--below-bar) + 8px); transform: translate(-50%, -8px); width: min(calc(100vw - 2 * var(--gut)), 520px); display: grid; justify-items: center; gap: 8px; padding: 12px 16px 14px; text-align: center; background: var(--plate); color: var(--on-plate); clip-path: var(--cut); opacity: 0; transition: opacity var(--motion-enter) var(--ease-out), transform var(--motion-enter) var(--ease-out); }
[data-phase='intro'] .brief { opacity: 1; transform: translate(-50%, 0); }
.brief .kicker { font: 800 12px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; padding: 5px 8px; background: var(--accent); color: var(--on-accent); }
.brief h1 { margin: 0; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(30px, 7vw, 52px); line-height: 0.95; text-transform: var(--label-case); }
.brief .act, .hint .chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; clip-path: var(--cut-sm); }
.brief .tried { display: grid; grid-template-columns: auto auto; align-items: center; justify-content: center; gap: 6px 8px; font-size: 13px; font-weight: 600; color: var(--on-plate-2); }
.brief .dots { display: inline-flex; gap: 4px; }
.brief .dots i { width: 12px; height: 12px; border: 2px solid var(--c); background: transparent; }
.brief .dots i.on { background: var(--c); }
.brief .bar { grid-column: 1 / -1; height: 4px; width: 220px; margin: 0 auto; background: var(--lights-off); overflow: hidden; }
.brief .bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; }
kbd { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 4px; border: 1.5px solid currentColor; border-bottom-width: 3px; font: 800 12px/1 var(--font); }
kbd.wide { min-width: 62px; }
.glyph { width: 26px; height: 26px; flex: none; }

/* ---------- scores: the leaderboard */
.board { right: calc(var(--sar) + var(--gut)); top: var(--below-bar); display: grid; gap: 8px; justify-items: end; opacity: 0; transform: translateX(12px); transition: opacity var(--motion-move) var(--ease-out), transform var(--motion-move) var(--ease-out); }
[data-phase='play'] .board { opacity: 1; transform: none; }
.ringwrap { display: none; position: relative; width: 120px; height: 120px; }
#ring { width: 100%; height: 100%; transform: rotate(-90deg); }
#ring circle { fill: none; stroke-width: 11; }
#ring .track { stroke: var(--lights-off); }
.mine { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.mine b { font: 900 28px/1 var(--font); font-stretch: 72%; font-variant-numeric: tabular-nums; }
.mine span { font-size: 12px; font-weight: 700; color: var(--on-plate-2); }
#boardRows { list-style: none; margin: 0; padding: 0; width: 196px; display: grid; gap: 2px; }
#boardRows li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 24px; padding: 0 8px 0 0; background: var(--plate); color: var(--on-plate); border-left: var(--bar-w) solid var(--c); font-weight: 800; font-size: 12px; text-transform: var(--label-case); letter-spacing: var(--label-tracking); }
#boardRows .b-place { text-align: center; color: var(--on-plate-2); font-weight: 700; }
#boardRows .b-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#boardRows .b-val { text-align: right; min-width: 3.2em; }
#boardRows li.you { background: var(--accent); color: var(--on-accent); }
#boardRows li.you .b-place { color: inherit; opacity: 0.8; }
#boardRows li.person .b-name { text-decoration: underline 2px var(--c); text-underline-offset: 3px; }
#boardRows li.bot { opacity: 0.94; }
/* The flare: your row when you gain a place. */
#boardRows li.flare { animation: flare 900ms var(--ease-out); }
@keyframes flare { 0% { transform: translateX(-10px); box-shadow: 0 0 0 3px var(--lights-on); } 100% { transform: none; box-shadow: 0 0 0 0 transparent; } }

/* ---------- news: the lower third, one item at a time */
.news { left: calc(var(--sal)); bottom: calc(var(--sab) + 96px); max-width: min(calc(100vw - 2 * var(--gut)), 420px); z-index: 5; }
.news[data-on='false'] .news-item { visibility: hidden; }
.news-item { display: flex; align-items: stretch; min-height: 44px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-hard); clip-path: var(--cut); }
.news-item .ptag { width: auto; min-width: 8px; height: auto; padding: 0 7px; font-size: 14px; }
.news-item .ptag:empty { padding: 0 4px; }
.news-body { display: grid; align-content: center; gap: 2px; padding: 6px 14px 6px 10px; min-width: 0; }
.news-body b { font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 17px; line-height: 1.05; text-transform: var(--label-case); }
.news-body span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.news-item[data-state='in'] { animation: news-in var(--motion-enter) var(--spring) both; }
.news-item[data-state='out'] { animation: news-out var(--motion-move) var(--ease-in) both; }
@keyframes news-in { from { transform: translateX(-104%); } to { transform: none; } }
@keyframes news-out { to { transform: translateX(-104%); opacity: 0; } }

/* ---------- the stinger: Go, Time */
.banner { left: 50%; top: 36%; transform: translate(-50%, -50%); text-align: center; opacity: 0; white-space: nowrap; z-index: 5; }
.banner b { display: block; padding: 4px 26px 2px; background: var(--accent); color: var(--on-accent); font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(56px, 14vw, 120px); line-height: 0.95; text-transform: var(--label-case); clip-path: var(--cut); }
.banner span { display: inline-block; margin-top: 6px; padding: 5px 10px; background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; }
.banner.show { animation: stinger 1.5s var(--ease-out) both; }
@keyframes stinger { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); } }

/* ---------- the moment: full screen, over a dim */
.moment { inset: 0; z-index: 7; display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity var(--motion-enter) var(--ease-out), visibility 0s linear var(--motion-enter); }
[data-moment='on'] .moment { opacity: 1; visibility: visible; transition: opacity var(--motion-move) var(--ease-out), visibility 0s; }
.m-dim { position: absolute; inset: 0; background: var(--dim); }
.m-stage { position: relative; display: grid; justify-items: center; gap: 10px; padding: 0 calc(var(--gut) + var(--sal)); text-align: center; width: 100%; }
.m-lights { display: flex; gap: 10px; }
.m-lights i { width: 22px; height: 22px; border-radius: 50%; background: var(--lights-off); }
.m-lights i.on { background: var(--lights-on); }
.m-kicker { font-weight: 800; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--lights-on); }
.m-name { margin: 0; display: flex; align-items: center; justify-content: center; gap: 0.18em; max-width: 100%; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(54px, 15vw, 132px); line-height: 0.92; text-transform: var(--label-case); color: #fff; opacity: 0; transform: scale(1.08); transition: opacity var(--motion-enter) var(--ease-out), transform var(--motion-enter) var(--spring); }
.m-name span { min-width: 0; overflow-wrap: anywhere; padding: 0 0.06em; }
.m-name .ptag { font-size: 0.4em; width: 1.4em; height: 1.4em; font-style: normal; }
.moment.named .m-name { opacity: 1; transform: none; }
.m-line { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(26px, 6vw, 48px); line-height: 1; text-transform: var(--label-case); color: #fff; opacity: 0; transition: opacity var(--motion-enter) var(--ease-out) 120ms; }
.m-line .crown { width: 1.1em; height: 0.9em; }
.m-sub { font-weight: 800; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: #fff; padding: 4px 10px; border-left: var(--bar-w) solid var(--c); background: rgba(255, 255, 255, 0.08); opacity: 0; transition: opacity var(--motion-enter) var(--ease-out) 220ms; }
.moment.named .m-line, .moment.named .m-sub { opacity: 1; }

/* ---------- the results sheet (podium) and the standings */
.sheetcard { background: var(--surface); color: var(--text); border-top: var(--sheet-top) solid var(--accent); box-shadow: var(--shadow-hard); }
.sheet-h { margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 26px; line-height: 1; text-transform: var(--label-case); }
.sheet-h span { font: 600 13px/1.3 var(--font); color: var(--text-2); text-transform: none; letter-spacing: 0; }
.row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 3.4em; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px 0 0; border-left: var(--bar-w) solid var(--c); background: var(--surface-2); font-weight: 800; text-transform: var(--label-case); letter-spacing: var(--label-tracking); font-size: 14px; }
.row .place { text-align: center; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 18px; color: var(--text-2); }
.row .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .num { text-align: right; }
.row .gain { text-align: right; color: var(--coin-ink, #9a6a00); font-size: 13px; }
.row.you { background: var(--accent); color: var(--on-accent); }
.row.you .place, .row.you .gain { color: inherit; }
.coin { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #f5c542; border: 2px solid #9a7412; vertical-align: -1px; margin-right: 4px; }
.crown { width: 20px; height: 16px; vertical-align: -2px; margin-left: 6px; }

.podium { left: 50%; bottom: calc(var(--sab) + 18px); transform: translate(-50%, 16px); width: min(calc(100vw - 2 * var(--gut)), 480px); padding: 12px 14px 14px; display: grid; gap: 4px; opacity: 0; transition: opacity var(--motion-enter) var(--ease-out), transform var(--motion-enter) var(--spring); }
[data-phase='podium'][data-moment='off'] .podium { opacity: 1; transform: translate(-50%, 0); }
.podium .row:nth-of-type(1) { min-height: 42px; font-size: 16px; }
.podium .row:nth-of-type(1) .place { font-size: 24px; }

.table { right: calc(var(--sar) + 28px); top: 50%; transform: translate(0, -46%); width: min(calc(100vw - 2 * var(--gut)), 430px); padding: 14px; opacity: 0; transition: opacity var(--motion-enter) var(--ease-out), transform var(--motion-enter) var(--spring); }
[data-phase='standings'][data-moment='off'] .table { opacity: 1; transform: translate(0, -50%); }
.table .rows { position: relative; height: calc(8 * 38px); }
.table .row { position: absolute; left: 0; right: 0; top: 0; height: 34px; transition: transform 0.6s var(--spring); grid-template-columns: 28px minmax(0, 1fr) auto 3.4em; }
.table .row .num { font-size: 16px; }

/* ---------- the one hint: just above the controls, never in the middle */
.hint { left: 50%; bottom: calc(var(--sab) + 22px); transform: translateX(-50%); display: flex; gap: 8px; opacity: 0; transition: opacity var(--motion-enter) var(--ease-out); white-space: nowrap; z-index: 5; }
.hint.show { opacity: 1; }
[data-input='touch'] .hint { bottom: calc(var(--sab) + 172px); }
[data-phase='podium'] .hint, [data-phase='standings'] .hint { display: none; }

/* ---------- touch: a stick that appears under the left thumb, and one big button */
.touch { position: absolute; inset: 0; pointer-events: none; z-index: 3; display: none; }
[data-input='touch'] .touch { display: block; }
.stick { position: absolute; left: 0; top: 0; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid var(--stick-ink, #fff); background: rgba(10, 11, 15, 0.28); opacity: 0; transition: opacity var(--motion-fast); }
.stick.on { opacity: 0.9; }
.stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: var(--stick-knob, var(--accent)); }
.stickghost { position: absolute; left: calc(var(--sal) + 34px); bottom: calc(var(--sab) + 44px); width: 124px; height: 124px; border-radius: 50%; border: 2px dashed var(--stick-ink, #fff); opacity: 0; transition: opacity var(--motion-enter); display: grid; place-items: center; }
.stickghost i { width: 54px; height: 54px; border-radius: 50%; background: var(--stick-knob, var(--accent)); opacity: 0.6; animation: nudge 1.6s ease-in-out infinite; }
.stickghost span { position: absolute; top: -32px; left: 50%; transform: translateX(-50%); padding: 4px 9px; background: var(--plate); color: var(--on-plate); font-size: 13px; font-weight: 700; white-space: nowrap; }
.stickghost.show { opacity: 0.9; }
@keyframes nudge { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(20px, -14px); } 60% { transform: translate(-12px, -20px); } }
/* The action button: its element, id and handling are input.js's; only its paint is a look's. */
.actbtn { position: absolute; right: calc(var(--sar) + 26px); bottom: calc(var(--sab) + 40px); width: 104px; height: 104px; border-radius: 50%; border: 0; padding: 0; background: var(--act-bg); color: var(--act-ink); display: none; place-items: center; z-index: 8; cursor: pointer; touch-action: none;
  box-shadow: 0 var(--act-travel) 0 var(--act-lip), 0 calc(var(--act-travel) + 6px) 16px -6px rgba(0, 0, 0, 0.6); transition: transform 70ms var(--ease-out), box-shadow 70ms var(--ease-out);
  font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 19px; line-height: 1; text-transform: uppercase; letter-spacing: 0.03em; }
[data-input='touch'][data-phase='intro'] .actbtn, [data-input='touch'][data-phase='play'] .actbtn, [data-input='touch'][data-phase='podium'] .actbtn { display: grid; }
.actbtn svg { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); transform: rotate(-90deg); pointer-events: none; }
.actbtn .cd, .actbtn .cdtrack { fill: none; stroke-width: 6; }
.actbtn .cdtrack { stroke: var(--act-track); }
.actbtn .cd { stroke: var(--act-ring); stroke-dasharray: 289; stroke-dashoffset: 0; }
.actbtn.down { transform: translateY(var(--act-travel)) scale(0.96); box-shadow: 0 0 0 var(--act-lip), 0 4px 10px -6px rgba(0, 0, 0, 0.6); }
.actbtn[data-ready='false'] span { opacity: 0.6; }
#game[data-act='none'] .actbtn { display: none; }

/* ---------- states: paused, no WebGL, starting up */
.state { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; padding: calc(var(--sat) + 24px) calc(var(--sar) + 24px) calc(var(--sab) + 24px) calc(var(--sal) + 24px); background: var(--dim); }
.state-card { display: grid; justify-items: center; gap: 8px; max-width: 30em; padding: 18px 22px 20px; text-align: center; background: var(--surface); color: var(--text); border-top: var(--sheet-top) solid var(--accent); box-shadow: var(--shadow-hard); }
.state-card b { font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(28px, 8vw, 40px); line-height: 1; text-transform: var(--label-case); }
.state-card span { font-weight: 600; color: var(--text-2); }
.boot { display: none; background: var(--page); }
[data-phase='boot'] .boot { display: grid; }
.boot-bar { width: 160px; height: 4px; background: var(--lights-off); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: boot 1.1s ease-in-out infinite alternate; }
@keyframes boot { from { transform: translateX(-10%); } to { transform: translateX(160%); } }

/* ---------- the room sheet: a side panel on a wide screen, a bottom sheet on a phone held upright */
.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(400px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-hard); font: 500 14px/1.35 var(--font); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: var(--dim); }
.sheet[open] { animation: sheet-side var(--motion-enter) var(--ease-out); }
@keyframes sheet-side { from { transform: translateX(40px); opacity: 0; } }
.sheet-in { display: flex; flex-direction: column; min-height: 0; height: 100%; border-top: var(--sheet-top) solid var(--accent); padding: 0 0 var(--sab); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: calc(14px + var(--sat)) calc(16px + var(--sar)) 8px 18px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 28px; line-height: 1; text-transform: var(--label-case); }
.sheet-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; font-weight: 600; }
.sheet .iconbtn { background: var(--surface-2); color: var(--text); }
.tabs { display: flex; gap: 4px; padding: 0 calc(16px + var(--sar)) 0 18px; border-bottom: 2px solid var(--border); }
.tabs [role='tab'] { min-height: 44px; padding: 0 16px; border: 0; background: none; color: var(--text-2); font-weight: 800; font-size: 14px; text-transform: var(--label-case); letter-spacing: var(--label-tracking); cursor: pointer; box-shadow: inset 0 -3px 0 transparent; margin-bottom: -2px; }
.tabs [role='tab'][aria-selected='true'] { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent-line, var(--accent)); }
.panel { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px calc(16px + var(--sar)) 22px 18px; display: grid; align-content: start; gap: 16px; }
.panel h3, .seg legend, .switchrow label { margin: 0 0 6px; padding: 0; font-weight: 800; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.seats li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px 0 0; background: var(--surface-2); border-left: var(--bar-w) solid var(--c); font-weight: 700; }
.seats li .ptag { width: 24px; height: 24px; justify-self: center; }
.seats li .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats li em { font-style: normal; font-size: 11px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 5px; background: var(--accent); color: var(--on-accent); margin-left: 4px; }
.seats li .kind { font-size: 12px; font-weight: 700; color: var(--text-2); }
.seats li.person .kind { color: var(--text); }
.seats li.person .kind::before { content: '● '; color: var(--c); }
.seats li.bot { opacity: 0.85; }
.seats li.note { display: block; padding: 8px 10px; border-left-color: var(--accent); font-weight: 600; }
.sololine, .note { margin: 0; color: var(--text-2); font-weight: 600; font-size: 13px; }
.invite-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: start; }
.qr { width: 112px; aspect-ratio: 1; background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }
.invite-link { display: grid; gap: 6px; min-width: 0; }
.invite-link label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.sheet input:not([type='radio']):not([type='checkbox']) { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--field); color: var(--text); font: 700 16px/1.2 var(--font); }
#inviteLink { font-size: 13px; font-weight: 600; }
.btn { min-height: 44px; padding: 0 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: 800 14px/1 var(--font); text-transform: var(--label-case); letter-spacing: var(--label-tracking); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.namebox { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.namebox p { margin: 0; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.seg { margin: 0; padding: 0; border: 0; min-width: 0; }
.seg legend { display: flex; align-items: center; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg-opt { position: relative; flex: 1 1 auto; }
.seg-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: grid; place-items: center; min-height: 44px; padding: 0 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 800; font-size: 14px; text-transform: var(--label-case); letter-spacing: var(--label-tracking); }
.seg-opt input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.switchrow { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.switchrow label { margin: 0; display: flex; gap: 8px; align-items: center; }
.switchrow input { appearance: none; -webkit-appearance: none; width: 52px; height: 30px; margin: 7px 0; border-radius: 15px; background: var(--border); position: relative; cursor: pointer; flex: none; }
.switchrow input::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform var(--motion-fast) var(--ease-out); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.switchrow input:checked { background: var(--accent); }
.switchrow input:checked::after { transform: translateX(22px); }
.sheet kbd { min-width: 20px; height: 20px; font-size: 11px; color: var(--text-2); }

/* ============================================================ phones and small windows */
@media (max-width: 620px), (max-height: 480px) {
  :root { --gut: 10px; --bar-h: 52px; }
  #labels .wpl-label[data-kind='pad'] { width: 114px; font-size: 11px; }
  .pad-card .name { font-size: 13px; } .pad-card .goal { font-size: 12px; } .pad-card .how { font-size: 11px; } .pad-card .body { padding: 5px 7px 7px; }
  .pad-card .how span.long { display: none; }
  .mc-game { font-size: 16px; }
  /* Compact scores: the top three, and you. */
  #boardRows { width: 150px; }
  #boardRows li:nth-child(n + 4):not(.you) { display: none; }
  #boardRows li { min-height: 22px; font-size: 11px; }
}
/* A phone held upright: the bug on the left under the match card, the scores on the right beside it. */
@media (max-width: 620px) and (orientation: portrait) {
  .bug { top: var(--below-bar); z-index: 4; left: calc(var(--sal) + var(--gut)); transform: none; max-width: calc(100vw - 2 * var(--gut) - 160px); }
  [data-phase='plaza'] .bug, [data-phase='vote'] .bug, [data-phase='intro'] .bug, [data-phase='podium'] .bug, [data-phase='standings'] .bug { max-width: calc(100vw - 2 * var(--gut)); }
  .bug-num { font-size: 26px; padding-left: 12px; }
  .bug-text { font-size: 12px; padding-right: 12px; }
  /* Upright, the player stands about the middle: the title card waits low, just above the hands. */
  .brief { top: auto; bottom: calc(var(--sab) + 214px); transform: translate(-50%, 8px); padding: 10px 12px 12px; gap: 6px; }
  [data-input='keys'] .brief { bottom: calc(var(--sab) + 70px); }
  .brief h1 { font-size: 30px; }
  [data-phase='intro'] .news, [data-phase='podium'] .news, [data-phase='standings'] .news { bottom: auto; top: calc(var(--below-bar) + 54px); }
  .news { bottom: calc(var(--sab) + 216px); }
  [data-input='keys'] .news { bottom: calc(var(--sab) + 76px); }
  .podium { bottom: calc(var(--sab) + 14px); padding: 10px 12px 12px; }
  [data-input='touch'] .podium { bottom: calc(var(--sab) + 160px); }
  .table { padding: 12px; right: auto; left: 50%; top: auto; bottom: calc(var(--sab) + 12px); transform: translate(-50%, 12px); }
  [data-phase='standings'][data-moment='off'] .table { transform: translate(-50%, 0); }
  .table .rows { height: calc(8 * 36px); } .table .row { height: 32px; }
  .sheet-h { font-size: 22px; }
  .m-name { flex-direction: column; gap: 6px; }
  /* The sheet comes up from the bottom, within reach of the thumb. */
  .sheet { inset: auto 0 0 0; width: 100vw; height: auto; max-height: 88dvh; }
  .sheet[open] { animation-name: sheet-up; }
  .sheet-head { padding-top: 14px; }
  .invite-row { grid-template-columns: 96px minmax(0, 1fr); } .qr { width: 96px; }
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } }
/* A phone held sideways: little height, so the bug goes into the bar, the cards to the sides. */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --bar-h: 50px; --below-bar: calc(var(--sat) + var(--bar-h) + 8px); }
  .match { padding: 4px 9px; }
  .bug { max-width: 44vw; }
  .bug-num { font-size: 24px; }
  .bug-text { font-size: 12px; }
  .brief { left: calc(var(--sal) + var(--gut)); top: var(--below-bar); transform: translate(0, -8px); width: 280px; padding: 8px 10px 10px; gap: 5px; justify-items: start; text-align: left; }
  [data-phase='intro'] .brief { transform: none; }
  .brief h1 { font-size: 26px; }
  .brief .act { font-size: 13px; padding: 4px 10px; } .brief .tried { justify-content: start; font-size: 12px; } .brief .bar { margin: 0; width: 200px; }
  .news { left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 10px); max-width: min(44vw, 380px); }
  [data-input='keys'] .news { bottom: calc(var(--sab) + 64px); }
  [data-input='touch'] .hint { bottom: calc(var(--sab) + 70px); }
  .podium { left: calc(var(--sal) + var(--gut)); bottom: calc(var(--sab) + 10px); transform: translate(0, 12px); width: 300px; padding: 8px 10px 10px; gap: 3px; }
  [data-phase='podium'][data-moment='off'] .podium { transform: none; }
  .podium .sheet-h { font-size: 18px; margin-bottom: 4px; } .podium .sheet-h span { display: none; }
  .podium .row { min-height: 28px; font-size: 13px; } .podium .row:nth-of-type(1) { min-height: 32px; font-size: 14px; } .podium .row:nth-of-type(1) .place { font-size: 20px; }
  .table { padding: 8px 12px 10px; width: min(calc(100vw - 2 * var(--gut)), 600px); right: auto; left: 50%; top: auto; bottom: calc(var(--sab) + 8px); transform: translate(-50%, 10px); }
  [data-phase='standings'][data-moment='off'] .table { transform: translate(-50%, 0); }
  .table .sheet-h { font-size: 20px; margin-bottom: 6px; }
  .table .rows { height: calc(4 * 34px); }
  .table .row { height: 30px; width: calc(50% - 4px); right: auto; }
  .actbtn { width: 92px; height: 92px; bottom: calc(var(--sab) + 22px); }
  .stickghost { bottom: calc(var(--sab) + 26px); width: 104px; height: 104px; }
  .banner { top: 44%; }
  .m-stage { gap: 6px; } .m-name { font-size: clamp(44px, 11vw, 84px); } .m-line { font-size: 26px; } .m-lights i { width: 16px; height: 16px; }
  /* A short screen has no room for a tall card over each pad: the preview goes beside the words. */
  #labels .wpl-label[data-kind='pad'] { width: 142px; }
  .pad-card { display: grid; grid-template-columns: 46px 1fr; align-items: stretch; position: relative; }
  .pad-card canvas { width: 46px; height: 100%; aspect-ratio: auto; object-fit: cover; }
  .pad-card .body { padding: 4px 7px 6px; gap: 2px; }
  .pad-card .name { font-size: 12px; } .pad-card .soon { font-size: 9px; padding: 2px 4px; position: absolute; left: 4px; top: 4px; background: var(--plate); opacity: 1; }
  .pad-card .how svg { width: 14px; height: 14px; } .pad-card .how span { display: none; }
  .sheet { width: min(420px, 70vw); }
  .sheet-head { padding-top: calc(8px + var(--sat)); } .panel { gap: 12px; }
}

/* ============================================================ reduced motion: the same information, no travel */
[data-motion='reduce'] .news-item[data-state='in'] { animation: fade-in var(--motion-move) linear both; }
[data-motion='reduce'] .news-item[data-state='out'] { animation: fade-out var(--motion-move) linear both; }
[data-motion='reduce'] .banner.show { animation: fade-hold 1.5s linear both; }
/* Panels still fade in and out; where they come from is not shown (the transform jumps). */
[data-motion='reduce'] :is(.brief, .board, .podium, .table, .m-name, .sheet) { transition-property: opacity, visibility; }
[data-motion='reduce'] .table .row { transition: none; }
[data-motion='reduce'] #boardRows li.flare { animation: flare-still 900ms linear; }
[data-motion='reduce'] .stickghost i, [data-motion='reduce'] .boot-bar i { animation: none; }
[data-motion='reduce'] .sheet[open] { animation: fade-in var(--motion-move) linear; }
[data-motion='reduce'] .actbtn.down { transform: none; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-hold { 0% { opacity: 0; } 10%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes flare-still { 0%, 60% { box-shadow: 0 0 0 3px var(--lights-on); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (forced-colors: active) {
  .ptag, .pips i, #boardRows li, .row, .seats li { forced-color-adjust: none; }
  .bug, .match, .youchip, .iconbtn, .news-item, .sheetcard, .state-card, .brief { border: 1px solid CanvasText; }
}

/* ---------- the room: its code, private, the host's lock and remove; a refusal */
.roomcard { display: grid; gap: 8px; padding: 12px 14px; background: var(--surface-2); border-left: var(--bar-w) solid var(--accent); }
.room-code { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px; }
.room-code span { grid-column: 1 / -1; font-weight: 800; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.room-code b { font-family: var(--font-display); font-style: var(--display-style); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 40px; line-height: 1; text-transform: uppercase; letter-spacing: 0.04em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.room-code em { font-style: normal; font-weight: 800; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.roomcard .switchrow label { font-size: 13px; color: var(--text); }
.seats li em.host { background: var(--text); color: var(--surface); }
.seats .kick { min-height: 36px; padding: 0 10px; font-size: 12px; margin: 4px 0; }
.seats .kick.confirm { background: var(--bad); border-color: var(--bad); color: #fff; }
@media (pointer: coarse) { .seats .kick { min-height: 44px; margin: 0; } }
.seats li:has(.kick) { min-height: 44px; }
.invitestart { display: grid; gap: 8px; padding: 12px; background: var(--surface-2); border-left: var(--bar-w) solid var(--accent); }
.invitestart h3 { margin: 0; }
.invitestart .btn { justify-self: start; }
.invitestart .btn[disabled] { opacity: 0.7; cursor: progress; }
.note.bad { color: var(--bad); }
.newroom { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding-top: 4px; border-top: 1px solid var(--border); }
.refused { position: fixed; z-index: 20; }
.state-card .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.state-card .btn { min-height: 44px; }
