@font-face {
  font-family: Oswald;
  src: url("/fonts/Oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}

:root {
  --ink: #f4ecdc;
  --dim: #b9ab94;
  --bg: #1b1720;
  --panel: #2a2330;
  --edge: #4a3d4f;
  --hot: #e0493a;
  --gold: #ecc846;
  --ok: #6fc36a;
  color-scheme: dark;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow-x: hidden; }

#app > section { display: none; }
#app[data-screen="lobby"] #lobby,
#app[data-screen="race"] #race,
#app[data-screen="result"] #result { display: block; }

button, input { font: inherit; color: inherit; }
button {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 4px;
  padding: 0.6em 1em;
  cursor: pointer;
}
button:hover { border-color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- lobby ---- */

#lobby, #result { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
/* the end of a race (V19): the spiked star with the word across it, as
   pc-end-winner-logo-01, then the still's line, as pc-end-winner-02 */
#star { position: relative; max-width: 30rem; margin: 0.5rem auto 1rem; aspect-ratio: 8 / 5; }
#star-burst svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#star-word {
  position: absolute; left: 0; right: 0; top: 50%; margin: 0; transform: translateY(-50%); text-align: center;
  font-family: Oswald, "Arial Narrow", Impact, sans-serif; font-weight: 700; font-size: clamp(2.2rem, 11vw, 4rem); line-height: 1;
  color: #f4ecdc; text-transform: uppercase; letter-spacing: 0.04em; text-shadow: 3px 3px 0 #000;
}
#result[data-outcome="qualified"] #star-word, #result[data-outcome="placed"] #star-word { color: #f05030; }
#star-still { position: absolute; left: 0; right: 0; bottom: -0.4rem; margin: 0; text-align: center; font-family: Oswald, "Arial Narrow", sans-serif; font-size: 1.1rem; }
#star.go #star-burst svg { animation: burst 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; }
#star.go #star-word { animation: word 0.4s 0.25s ease-out backwards; }
@keyframes word { from { transform: translateY(-50%) scale(0.7); opacity: 0; } to { transform: translateY(-50%); } }
#star.go #star-still { animation: pop 0.4s 0.9s ease-out backwards; }
@keyframes burst { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #star.go * { animation: none !important; } }
.masthead h1 {
  font-size: clamp(2.4rem, 9vw, 4.2rem);
  line-height: 1;
  margin: 0.4em 0 0.1em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-style: italic;
  color: var(--hot);
  text-shadow: 3px 3px 0 #000;
}
.tag { color: var(--dim); margin: 0 0 1.2rem; }
/* the bulletin board (V18): cork, the road's name in the original's
   orange-red condensed titles (#f05030), and its postcard pinned up */
#corkboard {
  position: relative; display: grid; grid-template-columns: 1fr minmax(9rem, 45%); gap: 1rem; align-items: start;
  margin: 0 0 1rem; padding: 1.1rem 1.1rem 1.3rem; border-radius: 6px; border: 2px solid #3a2a1c;
  background-color: #8a6440;
  background-image:
    radial-gradient(circle at 20% 30%, #0000 0 1px, #5a3e2440 1.5px 2px, #0000 2.5px),
    radial-gradient(circle at 70% 60%, #0000 0 1px, #a8805040 1.5px 2px, #0000 2.5px),
    linear-gradient(135deg, #7a5636, #9a7448 50%, #6e4c30);
  background-size: 7px 7px, 11px 11px, 100% 100%;
  box-shadow: inset 0 0 2.5rem #0008;
}
#cork-text { padding: 0.7rem 0.9rem; background: rgb(20 14 10 / 0.72); border-radius: 3px; }
#cork-road {
  margin: 0; font-family: Oswald, "Arial Narrow", Impact, sans-serif; font-weight: 600; font-size: clamp(1.8rem, 6vw, 2.8rem);
  line-height: 1.05; color: #f05030; text-shadow: 2px 2px 0 #000;
}
#cork-line { margin: 0.4rem 0 0.6rem; font-family: Oswald, "Arial Narrow", sans-serif; font-size: 1.05rem; line-height: 1.3; }
#cork-length { margin: 0; font-family: Oswald, "Arial Narrow", sans-serif; color: var(--dim); }
#cork-card { margin: 0; transform: rotate(4deg); box-shadow: 4px 6px 10px #000a; line-height: 0; position: relative; }
#cork-card img { width: 100%; height: auto; display: block; border: 6px solid #f4ecdc; box-sizing: border-box; }
/* the red pushpin at its top right */
#cork-card::after { content: ""; position: absolute; top: -0.45rem; right: 1rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8a70, #d22a1e 55%, #7a120c); box-shadow: 2px 3px 3px #0009; }
@media (max-width: 520px) { #corkboard { grid-template-columns: 1fr; } #cork-card { width: 70%; justify-self: end; margin-top: -0.4rem; } }
/* road and level picked as on the original's board: the yellow arrow, and the name in yellow */
#roads label:has(input:checked), #levels label:has(input:checked) { color: var(--gold); font-weight: bold; }
#roads label:has(input:checked)::before { content: "→"; color: var(--gold); margin-right: 0.15rem; }
.panel { background: var(--panel); border: 2px solid var(--edge); border-radius: 6px; padding: 1rem; margin: 0 0 1rem; }
.panel h2 { margin: 0 0 0.5rem; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); }
.field { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0 0 0.8rem; border: 0; padding: 0; }
.field > span, .field legend { color: var(--dim); min-width: 3.5rem; float: left; padding: 0; margin-right: 0.6rem; }
#ai-count { width: 12rem; max-width: 60%; accent-color: var(--hot); }
#ai-count-out { min-width: 2ch; font-variant-numeric: tabular-nums; }
#name { background: var(--bg); border: 2px solid var(--edge); border-radius: 4px; padding: 0.4em 0.6em; width: 14rem; max-width: 100%; }
#levels label, #roads label { display: inline-flex; align-items: center; gap: 0.2rem; margin-right: 0.6rem; }
/* a person's leathers: the main colour with the second across its top and the helmet's dot */
.swatch { display: inline-block; flex: none; width: 2.4rem; height: 2.4rem; border-radius: 0.35rem; box-shadow: 0 0 0 1px #0006 inset; vertical-align: middle; }
.queue { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.queue button { font-weight: bold; font-size: 1.05rem; text-align: left; }
.queue button small { display: block; font-weight: normal; color: var(--dim); font-size: 0.8rem; }
.queue button[aria-pressed="true"] { border-color: var(--hot); background: #3a2226; }
/* racing people is what the app is for, so its button is filled gold like
   Accept, the one other "do this" on the site; NPCs stay outlined */
#queue-human { color: var(--bg); background: var(--gold); border-color: var(--gold); }
#queue-human small { color: #3d3218; }
#queue-human:hover { border-color: var(--ink); }
/* queued for people: a thick red ring that breathes. The ring is a shadow
   on top of the 2px border, so the button keeps its size; the shared
   "searching" pulse is not used here because it fades the border to gold,
   which on a gold button looked the same as not being pressed at all */
#queue-human[aria-pressed="true"] {
  color: var(--bg); background: var(--gold); border-color: var(--hot);
  box-shadow: 0 0 0 3px var(--hot);
  animation: humans-breathe 1.8s ease-in-out infinite;
}
@keyframes humans-breathe {
  0%, 100% { box-shadow: 0 0 0 3px #e0493a, 0 0 4px 3px #e0493a33; }
  50% { box-shadow: 0 0 0 3px #e0493a66, 0 0 18px 6px #e0493a99; }
}
#pool { min-height: 1.4em; margin: 0.8rem 0 0; color: var(--gold); }
#leave { margin-top: 0.6rem; }
.hint { color: var(--dim); font-size: 0.9rem; margin: 0 0 0.6rem; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--edge); }
#quals td { text-align: center; }
#quals td.yes::after { content: "⚑"; color: var(--gold); }
#watch canvas { width: 100%; image-rendering: pixelated; display: block; background: #000; }
.keys, .credit { color: var(--dim); font-size: 0.9rem; }
.credit a { color: var(--gold); }

/* ---- race ---- */

#race { position: fixed; inset: 0; background: #000; }
#stage { position: absolute; inset: 0; }
#road { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#dash { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#flash { position: absolute; inset: 0; background: #ff2010; opacity: 0; pointer-events: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#banner {
  position: absolute; top: 18%; left: 0; right: 0; text-align: center;
  font-size: clamp(1.6rem, 6vw, 3.6rem); font-weight: bold; font-style: italic; text-transform: uppercase;
  color: var(--gold); text-shadow: 3px 3px 0 #000; pointer-events: none;
}

/* the picture darkened over the count (V16) */
#veil { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
/* the count on the grid: big white figures in the road ahead (V16) */
#count {
  position: absolute; top: 30%; left: 0; right: 0; text-align: center;
  font-size: clamp(5rem, 22vw, 12rem); font-weight: bold; line-height: 1;
  color: #fff; text-shadow: 5px 5px 0 #000; pointer-events: none;
}
#count[hidden] { display: none; }

/* leaving a race (H8): a corner button, and Esc, ask before letting go */
#quit {
  position: absolute; top: max(0.6rem, env(safe-area-inset-top)); left: max(0.6rem, env(safe-area-inset-left));
  padding: 0.3em 0.7em; font-size: 0.85rem; font-weight: bold; line-height: 1.1;
  background: rgb(18 15 21 / 0.7);
}
#quit small { display: block; font-size: 0.7rem; font-weight: normal; color: var(--dim); }
/* the round trip to the server, in the opposite corner (N14) */
#ping {
  position: absolute; top: max(0.6rem, env(safe-area-inset-top)); right: max(0.6rem, env(safe-area-inset-right)); margin: 0;
  padding: 0.3em 0.6em; border-radius: 4px; background: rgb(18 15 21 / 0.7);
  font-size: 0.85rem; font-weight: bold; font-variant-numeric: tabular-nums; pointer-events: none;
}
#ping[hidden], #app[data-screen="watch"] #ping { display: none; }
#ping.good { color: var(--ok); }
#ping.fair { color: var(--gold); }
#ping.poor { color: var(--hot); }
/* every person's place, in the upper left under the leave button (N6), and
   who has knocked the watching rider off before (O3) */
#people {
  position: absolute; top: calc(max(0.6rem, env(safe-area-inset-top)) + 2.9rem); left: max(0.6rem, env(safe-area-inset-left));
  list-style: none; margin: 0; padding: 0.25rem; width: min(15rem, 46vw); max-height: min(13.5rem, 34vh); overflow-y: auto;
  background: rgb(18 15 21 / 0.7); border-radius: 4px; font-size: 0.85rem; line-height: 1.2;
}
#people[hidden] { display: none; }
#people li { display: flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.25rem; border-radius: 3px; }
#people li.me { background: rgb(255 255 255 / 0.12); }
#people li.out { opacity: 0.55; }
#people b { min-width: 1.6ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--gold); }
#people .swatch { width: 0.95rem; height: 0.95rem; border-radius: 0.2rem; }
#people .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#people .feud { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 0.75rem; }
#people li.grudge .feud { color: var(--hot); font-weight: bold; }
/* the keys (R16) */
#controls summary { cursor: pointer; font-weight: bold; }
#controls summary .keys { font-weight: normal; margin-left: 0.6rem; }
#keymap { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.4rem 1rem; }
#keymap li { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
#keymap button { min-width: 6.5rem; font-variant-numeric: tabular-nums; }
#keymap button[aria-pressed="true"] { border-color: var(--hot); background: #3a2226; }
/* the race's chat (N7): newest at the bottom, top right under the ping */
#chat {
  position: absolute; top: calc(max(0.6rem, env(safe-area-inset-top)) + 2.4rem); right: max(0.6rem, env(safe-area-inset-right));
  list-style: none; margin: 0; padding: 0; width: min(17rem, 46vw); pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; font-size: 0.85rem; line-height: 1.25;
}
#chat li { padding: 0.2rem 0.5rem; border-radius: 4px; background: rgb(18 15 21 / 0.78); text-align: right; transition: opacity 0.6s; }
#chat li.old { opacity: 0; }
#chat li b { color: var(--gold); }
#chat li.status { color: var(--dim); font-style: italic; }
#say {
  position: absolute; top: max(0.6rem, env(safe-area-inset-top)); left: calc(max(0.6rem, env(safe-area-inset-left)) + 4.4rem);
  padding: 0.3em 0.7em; font-size: 0.85rem; font-weight: bold; line-height: 1.1; background: rgb(18 15 21 / 0.7);
}
#say small { display: block; font-size: 0.7rem; font-weight: normal; color: var(--dim); }
#dash-toggle {
  position: absolute; top: max(0.6rem, env(safe-area-inset-top)); left: calc(max(0.6rem, env(safe-area-inset-left)) + 8.6rem);
  padding: 0.3em 0.7em; font-size: 0.85rem; font-weight: bold; line-height: 1.1; background: rgb(18 15 21 / 0.7);
}
#dash-toggle small { display: block; font-size: 0.7rem; font-weight: normal; color: var(--dim); }
#dash-toggle[aria-pressed="true"] { border-color: var(--gold); }
#sayings {
  position: absolute; top: calc(max(0.6rem, env(safe-area-inset-top)) + 2.9rem); left: calc(max(0.6rem, env(safe-area-inset-left)) + 4.4rem); z-index: 2;
  list-style: none; margin: 0; padding: 0.3rem; background: var(--panel); border: 2px solid var(--edge); border-radius: 6px;
}
#sayings[hidden], #app[data-screen="watch"] #say, #app[data-screen="watch"] #sayings { display: none; }
#sayings button { display: block; width: 100%; text-align: left; margin: 0.1rem 0; padding: 0.35em 0.6em; font-size: 0.9rem; }
#sayings kbd { color: var(--dim); font-size: 0.75rem; margin-right: 0.4rem; font-family: inherit; }
@media (pointer: coarse), (max-width: 700px) { #say small, #dash-toggle small, #sayings kbd { display: none; } }
#loading-cards .feud { grid-column: 2; color: var(--hot); font-size: 0.85rem; font-weight: bold; }
#rooms .who .ping { color: var(--dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
#quit-ask {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(22rem, calc(100% - 2rem)); padding: 1.2rem; text-align: center;
  background: var(--panel); border: 2px solid var(--hot); border-radius: 4px;
}
#quit-ask[hidden] { display: none; }
#quit-head { margin: 0 0 0.4rem; font-size: 1.4rem; font-weight: bold; font-style: italic; text-transform: uppercase; color: var(--gold); }
#quit-ask .hint { margin: 0 0 1rem; color: var(--dim); font-size: 0.9rem; }
#quit-ask button { margin: 0 0.25rem; }
#quit-yes { border-color: var(--hot); }

#touch { display: none; }
@media (pointer: coarse), (max-width: 700px) {
  #stage { bottom: 9.5rem; }
  #touch {
    display: flex; justify-content: space-between; align-items: stretch;
    position: absolute; left: 0; right: 0; bottom: 0; height: 9.5rem;
    padding: 0.5rem; gap: 0.5rem; background: #120f15;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .pad { display: grid; gap: 0.4rem; }
  /* the fists as two big buttons where the right thumb rests, get off small above them */
  .pad.right { grid-template-columns: 1fr 1fr; grid-template-rows: 44px 1fr; width: 50%; }
  .pad.right .small { grid-column: 1 / span 2; grid-row: 1; min-height: 44px; }
  .pad.right .big { grid-row: 2; }
  .pad.right .small small { display: inline; margin-left: 0.4em; }
  #stick { width: 45%; display: flex; align-items: center; justify-content: center; touch-action: none; }
  #stick-ring {
    position: relative; width: 8.5rem; height: 8.5rem; max-width: 100%; aspect-ratio: 1;
    border-radius: 50%; border: 2px solid #4a3f50; background: radial-gradient(#1d1822, #120f15 70%);
  }
  #stick-ring .tag { position: absolute; left: 50%; transform: translateX(-50%); font-size: 0.65rem; color: var(--dim); pointer-events: none; }
  #stick-ring .tag.up { top: 0.3rem; }
  #stick-ring .tag.down { bottom: 0.3rem; }
  #stick-knob {
    position: absolute; left: 50%; top: 50%; width: 3.4rem; height: 3.4rem; margin: -1.7rem 0 0 -1.7rem;
    border-radius: 50%; background: #3a3140; border: 2px solid var(--dim); pointer-events: none;
  }
  #stick.held #stick-knob { background: #3a2226; border-color: var(--hot); }
  .pad button { font-size: 1.4rem; font-weight: bold; padding: 0; line-height: 1; }
  .pad button small { display: block; font-size: 0.65rem; font-weight: normal; color: var(--dim); }
  .pad button.down { background: #3a2226; border-color: var(--hot); }
}

/* ---- matchmaking (N9, N10) ---- */

#app[data-screen="loading"] #loading,
#app[data-screen="live"] #live,
#app[data-screen="leaders"] #leaders,
#app[data-screen="watch"] #race { display: block; }

/* in the queue: a bar pinned across the top, a pulse and a running clock */
#qbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.55rem 0.8rem; margin: 0 0 0.5rem;
  background: linear-gradient(90deg, #3a2226, #2a2330 70%);
  border-bottom: 2px solid var(--hot);
  box-shadow: 0 4px 18px #0008;
}
#qbar[hidden] { display: none; }
#qbar .q-what { flex: 1; min-width: 0; }
#qbar b { color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
#qbar-note { color: var(--dim); }
#qbar-time { font: 700 1.3rem Oswald, sans-serif; font-variant-numeric: tabular-nums; color: var(--ink); }
#qbar-x { padding: 0.2em 0.6em; }
.pulse { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--hot); flex: none; animation: pulse 1.2s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #e0493aaa; }
  100% { box-shadow: 0 0 0 0.9rem #e0493a00; }
}
.queue button[aria-pressed="true"] { animation: searching 1.6s ease-in-out infinite; }
@keyframes searching {
  50% { border-color: var(--gold); box-shadow: 0 0 14px #ecc84655; }
}

/* a match found: the whole page goes dark behind one card */
#found {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: radial-gradient(circle, #1b1720cc, #000e 70%);
  animation: fade-in 0.2s ease-out;
}
#found[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.found-card {
  width: min(24rem, calc(100% - 2rem)); padding: 1.6rem 1.4rem 1.2rem; text-align: center;
  background: var(--panel); border: 2px solid var(--gold); border-radius: 8px;
  box-shadow: 0 0 40px #ecc84633;
  animation: pop 0.28s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
#found-ring {
  --left: 1;
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--left) * 360deg), #4a3d4f 0);
  -webkit-mask: radial-gradient(circle, transparent 0 2.6rem, #000 2.65rem);
  mask: radial-gradient(circle, transparent 0 2.6rem, #000 2.65rem);
}
.ring { position: relative; width: 6.5rem; height: 6.5rem; margin: 0 auto 0.6rem; }
#found-secs {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 2.4rem Oswald, sans-serif; color: var(--ink);
}
#found-head { margin: 0; font: italic 700 2rem Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gold); }
#found-line { margin: 0.2rem 0 0.8rem; color: var(--dim); }
#found-boxes { list-style: none; display: flex; justify-content: center; gap: 0.35rem; padding: 0; margin: 0 0 1rem; }
#found-boxes li { width: 1.2rem; height: 1.2rem; border: 2px solid var(--edge); border-radius: 3px; transition: background 0.15s, border-color 0.15s; }
#found-boxes li.yes { background: var(--ok); border-color: var(--ok); }
#found-yes {
  display: block; width: 100%; margin: 0 0 0.5rem; padding: 0.8em;
  font: 700 1.3rem Oswald, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  color: #1b1720; background: var(--gold); border-color: var(--gold);
}
#found-yes:disabled { opacity: 0.45; cursor: default; }
#found-no { font-size: 0.9rem; padding: 0.35em 1em; background: transparent; }
#found-no:disabled { visibility: hidden; }
#found-wait { margin: 0.6rem 0 0; color: var(--ok); }

/* loading: the road, then one card per person, filling as each loads */
#loading { position: fixed; inset: 0; overflow: auto; padding: 2rem 1rem; background: radial-gradient(ellipse at top, #3a2226, var(--bg) 60%); }
#loading header { text-align: center; margin: 0 0 1.5rem; }
#loading .kicker { margin: 0; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; }
#loading-head { margin: 0.1rem 0; font: italic 700 clamp(2.2rem, 8vw, 3.6rem) Oswald, sans-serif; text-transform: uppercase; color: var(--hot); text-shadow: 3px 3px 0 #000; }
#loading-line { margin: 0; color: var(--gold); font-weight: bold; }
/* the field talking on the grid (O7) */
#schmooze { list-style: none; padding: 0; margin: 0 auto 1rem; max-width: 44rem; display: grid; gap: 0.5rem; }
#schmooze li { padding: 0.55rem 0.8rem; background: var(--panel); border-left: 3px solid var(--gold); border-radius: 4px; line-height: 1.35; }
#schmooze li b { margin-right: 0.3rem; }
#schmooze li.cold { border-left-color: var(--hot); }
#loading-cards {
  list-style: none; padding: 0; margin: 0 auto 1rem; max-width: 64rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.8rem;
}
#loading-cards li {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 0.7rem; align-items: center;
  padding: 0.8rem; background: var(--panel); border: 2px solid var(--edge); border-radius: 6px;
  animation: pop 0.3s ease-out backwards;
}
#loading-cards li.me { border-color: var(--gold); }
#loading-cards li.ready { box-shadow: 0 0 0 1px var(--ok) inset; }
#loading-cards .swatch { grid-row: span 2; width: 3rem; height: 3rem; }
#loading-cards .who { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#loading-cards .ping { color: var(--dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
#loading-cards li.ready .ping { color: var(--ok); }
#loading-cards .bar { grid-column: 1 / -1; height: 0.45rem; margin-top: 0.6rem; background: #0006; border-radius: 1rem; overflow: hidden; }
#loading-cards .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--hot), var(--gold)); transition: width 0.3s ease-out; }
#loading-cards li.ready .bar i { background: var(--ok); }
#loading-note { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .pulse, .queue button[aria-pressed="true"], #queue-human[aria-pressed="true"], .found-card, #found, #loading-cards li { animation: none; }
}

/* ---- the pages: race, live (N11) ---- */

#nav { display: none; max-width: 44rem; margin: 0 auto; padding: 0.8rem 1rem 0; gap: 0.3rem; }
#app[data-screen="lobby"] #nav, #app[data-screen="live"] #nav, #app[data-screen="leaders"] #nav { display: flex; }
#nav a {
  padding: 0.45em 0.9em; border-radius: 4px 4px 0 0; border-bottom: 3px solid transparent;
  color: var(--dim); text-decoration: none; font-weight: bold; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.9rem;
}
#nav a:hover { color: var(--ink); }
#nav a[aria-current] { color: var(--gold); border-bottom-color: var(--gold); }
#nav .count:not(:empty) { display: inline-block; min-width: 1.4em; margin-left: 0.2em; padding: 0 0.35em; border-radius: 1em; background: var(--hot); color: #fff; font-size: 0.8rem; text-align: center; }

#live { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
#live-head { margin: 0.4rem 0 0.2rem; font: italic 700 2rem Oswald, sans-serif; text-transform: uppercase; color: var(--hot); text-shadow: 2px 2px 0 #000; }
#rooms { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.8rem; }
#rooms > li { background: var(--panel); border: 2px solid var(--edge); border-radius: 6px; padding: 0.9rem 1rem; }
.room-head { display: flex; align-items: baseline; gap: 0.2rem; flex-wrap: wrap; }
.room-head b { color: var(--gold); font-size: 1.1rem; }
.room-head span { color: var(--dim); }
.room-head .time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); }
#rooms .who { list-style: none; padding: 0; margin: 0.7rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
#rooms .who li { display: flex; align-items: center; gap: 0.45rem; }
#rooms .who .swatch { width: 1.6rem; height: 1.6rem; }
#rooms .who li.out { opacity: 0.5; }
.room-foot { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 0.9rem; }
.room-foot button { font-weight: bold; border-color: var(--gold); }

/* spectating: the race full screen, no touch pad, a strip to pick the rider and leave */
#spectate { display: none; }
#app[data-screen="watch"] #spectate {
  display: flex; align-items: center; gap: 0.5rem;
  position: absolute; top: max(0.6rem, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  padding: 0.35rem; background: rgb(18 15 21 / 0.8); border: 2px solid var(--edge); border-radius: 6px;
  max-width: calc(100% - 1rem);
}
#spectate p { margin: 0 0.4rem; text-align: center; min-width: 7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#spectate p small { display: block; color: var(--dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
#spectate b { color: var(--gold); }
#spectate button { padding: 0.35em 0.7em; }
#spec-stop small { color: var(--dim); font-size: 0.7rem; }
#app[data-screen="watch"] #quit, #app[data-screen="watch"] #touch { display: none; }
#app[data-screen="watch"] #stage { bottom: 0; }

/* ---- the leaderboard (N12) ---- */

#leaders { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
#leaders-head { margin: 0.4rem 0 0.2rem; font: italic 700 2rem Oswald, sans-serif; text-transform: uppercase; color: var(--hot); text-shadow: 2px 2px 0 #000; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 2px solid var(--edge); border-radius: 6px; margin-top: 1rem; }
#leaderboard th, #leaderboard td { white-space: nowrap; font-variant-numeric: tabular-nums; }
#leaderboard th:nth-child(n+3), #leaderboard td:nth-child(n+3) { text-align: right; }
#leaderboard td:nth-child(2) { max-width: 12rem; }
#leaderboard .rider { display: flex; align-items: baseline; gap: 0.35em; }
#leaderboard .rider-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#leaderboard .rider-no { flex: none; }
#leaderboard td:nth-child(3) { color: var(--gold); font-weight: bold; }
#leaderboard .rider-no { color: var(--dim); font-size: 0.85em; }
#leaderboard tbody tr:nth-child(-n+3) td:first-child { color: var(--gold); font-weight: bold; }
#leaderboard tr.me td { background: #3a2226; }
