/*
 * The look: bold, saturated, high contrast (#25).
 *
 * Inspired by the colour language of Mario — red, coin yellow, pipe green,
 * sky blue — and by the chunky, outlined shapes of game UI. Deliberately NOT
 * their artwork, logos or typeface: nothing here should suggest this is
 * official. The font is Fredoka (SIL OFL), served by this app.
 *
 * Contrast is a requirement rather than a preference: this scoreboard sits on
 * a TV across a room. Every pairing below is measured, and the numbers are in
 * docs/DESIGN.md — the rule is 4.5:1 for text, 3:1 for large text.
 *
 * The trick that makes saturated colour safe: colour goes in BLOCKS with a
 * hard dark outline, and text sits on white, near-black, or a light tint —
 * never a mid-tone. A bright block never carries small text.
 */

/* The display face, for the ribbon and the headings only.
 *
 * Racers Delight, by @ImWhoreHay — a recreation of the lettering Mario Kart
 * World uses, given to Jonas by its maker. Credit to @ImWhoreHay, which is
 * what he asked for; the full note is in assets/fonts/README.md.
 *
 * Headings only on purpose: a face like this is made for four words at 2rem,
 * and at 15px in a table it would be unreadable. The body stays Fredoka, and
 * this falls back to it on its own if the file is not served. */
@font-face {
  font-family: 'Racers Delight';
  src: url('/vendor/fonts/racers-delight.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Fredoka';
  src: url('/vendor/fonts/fredoka-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('/vendor/fonts/fredoka-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('/vendor/fonts/fredoka-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* The palette. Names say what they are for, not what they look like. */
  --ink: #16131f;           /* near-black: all body text */
  --ink-soft: #4a4458;      /* secondary text, still 7:1 on paper */
  --paper: #fffdf7;         /* warm white page */
  --surface: #ffffff;
  --line: #16131f;          /* outlines are ink, not grey — that is the look */
  --line-soft: #d8d2c4;

  --red: #d81f26;           /* blocks and the accent bar */
  --red-ink: #b3131a;       /* the same red, dark enough to be text */
  --blue: #0a6fb0;
  --blue-ink: #075a90;
  --green: #2f8f3e;
  --green-ink: #1d6b2a;
  --coin: #ffcf33;          /* always under ink, never behind white text */
  --coin-deep: #e8a900;

  --gold: #ffcf33;
  --silver: #d6dae2;
  --bronze: #e0a06a;

  --warn-ink: #8a4b00;      /* "needs review" text on paper */
  --warn-bg: #fff3d6;

  /* These three do NOT follow the theme, and that is the point. A medal badge
     is a light coin in both themes, so its text must stay dark; when it took
     --ink it turned white on gold in dark mode and measured 1.26:1. Same for
     the table header, which went near-black on near-black. Measured, not
     noticed by eye — see docs/DESIGN.md. */
  --badge-ink: #16131f;
  --header-bg: #16131f;
  --header-ink: #fffdf7;
  --cta-bg: #c1121a;        /* the red a button can carry white text on */
  --cta-ink: #ffffff;

  /* The frame, and what may be written on it. Deliberately identical in both
     themes. White on this red measures 4.83:1 — which is the reason not to
     brighten it further. */
  --frame: #e01b22;
  --on-frame: #ffffff;
  --on-frame-soft: #ffffff;

  --radius: 14px;
  --outline: 3px;
  /* The hard offset shadow that makes blocks read as objects. */
  --pop: 0 4px 0 var(--line);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #f4f4f4;
    --ink-soft: #b8b8b8;
    --paper: #121212;       /* neutral grey, no tint */
    --surface: #1d1d1d;
    --line: #000000;
    --line-soft: #3c3c3c;

    --red: #ff5a52;
    --red-ink: #ff8a83;
    --blue: #4db5f0;
    --blue-ink: #7fccf7;
    --green: #5ed46e;
    --green-ink: #86e493;
    --coin: #ffd84d;
    --coin-deep: #ffc21a;

    --gold: #ffd84d;
    --silver: #c8cedb;
    --bronze: #d9915a;

    --warn-ink: #ffce70;
    --warn-bg: #3a2c0c;

    /* The badge stays dark-on-light. The header inverts properly. The call to
       action becomes dark text on bright red, which is the pairing that has
       the contrast in a dark theme — white on bright red does not. */
    --header-bg: #000000;
    --header-ink: #fffdf7;
    --cta-bg: #ff5a52;
    --cta-ink: #16131f;
    /* --frame is NOT redefined here on purpose: the red is the constant. */

    --pop: 0 4px 0 #000000;
  }
}
:root[data-theme='dark'] {
  --ink: #f4f4f4; --ink-soft: #b8b8b8; --paper: #121212; --surface: #1d1d1d;
  --line: #000000; --line-soft: #3c3c3c;
  --red: #ff5a52; --red-ink: #ff8a83; --blue: #4db5f0; --blue-ink: #7fccf7;
  --green: #5ed46e; --green-ink: #86e493; --coin: #ffd84d; --coin-deep: #ffc21a;
  --gold: #ffd84d; --silver: #c8cedb; --bronze: #d9915a;
  --warn-ink: #ffce70; --warn-bg: #3a2c0c; --pop: 0 4px 0 #000000;
  --header-bg: #000000; --header-ink: #fffdf7; --cta-bg: #ff5a52; --cta-ink: #16131f;
}

* { box-sizing: border-box; }

/* The race bleeds to the viewport edges with 100vw, and 100vw counts the
   vertical scrollbar — so it overhangs the page by the scrollbar's width and
   the page can be dragged sideways by those few pixels.
 *
 * This has to be clipped on the ROOT. Setting it on `body` alone does not
 * work: the viewport takes its overflow from `html`, and `html` here is
 * `visible`. `clip` rather than `hidden` so nothing becomes a scroll
 * container and `position: sticky` keeps working. */
html {
  overflow-x: clip;
  /* Keep the scrollbar's space reserved whether or not there is one to show.
     Folding the race away makes the page short enough to lose the scrollbar,
     and without this the table changes width by the scrollbar's 15px as a
     side effect of a button that has nothing to do with its width. Ignored
     where scrollbars are overlays, which is most phones. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: clamp(14px, 3vw, 34px);
  /* The frame is the same sharp red in both themes — it is the thing that
     makes the page look like this app rather than a document. Nothing
     readable sits on it: every piece of text is on the sheet below. */
  background: var(--frame);
  color: var(--ink);
  font: 500 17px/1.5 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  /* Belt and braces with the rule on `html` above, which is the one that
     actually clips. */
  overflow-x: clip;
}

/* No sheet: the page IS the red, and only the things that hold data are
   framed. Everything loose — the title, the controls, the summary — is white
   on red, which measures 4.83:1 and is why the red is no darker than it is. */
main {
  position: relative;
  max-width: 60rem;
  margin: 0 auto;
  color: var(--on-frame);
}

h1 {
  font-family: 'Racers Delight', 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-style: italic;
  /* Big: it is the one thing on the page that is allowed to be. */
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1;
  margin: .1rem 0 1rem;
  color: var(--on-frame);
  /* No yellow band any more — the letters carry their own black edge, heavier
     underneath, the way the date pill below sits on its own shadow. The stroke
     is painted behind the fill so it thickens outward and leaves the letter
     shapes intact. */
  -webkit-text-stroke: 5px #000;
  paint-order: stroke fill;
  text-shadow: 0 7px 0 #000;
}

/* Firefox has no paint-order for text on some builds; without it the stroke
   would eat into the letters. A shadow-only outline is the safe version. */
@supports not (paint-order: stroke) {
  h1 {
    -webkit-text-stroke: 0;
    text-shadow:
      -3px 0 0 #000, 3px 0 0 #000, 0 -3px 0 #000, 0 3px 0 #000,
      -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
      0 7px 0 #000;
  }
}

h2 { font-style: italic; font-family: 'Racers Delight', 'Fredoka', system-ui, sans-serif; letter-spacing: .01em; }

.muted { color: var(--on-frame-soft); }
.error { color: var(--on-frame); font-weight: 700; }
.warn { color: var(--on-frame); font-weight: 700; }
a { color: var(--on-frame); font-weight: 700; }

/* Inside anything with its own surface, text goes back to ink. The panels are
   listed once, here, so a new one cannot quietly end up white on white. */
table, .reader, .queue li, #report > p, .place, .tag {
  color: var(--ink);
}
.reader label, .reader .muted, .queue li .muted, table .muted { color: var(--ink-soft); }
.reader a, .queue li a, #report > p a, table a,
.reader button.link, .queue li button.link, #report > p button.link, table button.link {
  color: var(--blue-ink);
}
#report > p.error, table .error { color: var(--red-ink); }
#report > p.warn { color: var(--warn-ink); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* --- controls ----------------------------------------------------------- */

label { display: block; font-size: .8rem; font-weight: 700; color: var(--on-frame); margin-bottom: .15rem; }

input, select, button {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .45rem .6rem;
  min-height: 44px;   /* a thumb, on a phone, in a hurry */
}
/* 24px, and the label around it is the real target: a checkbox on a phone
   gets tapped with a thumb while someone is holding a controller. */
input[type='checkbox'] { min-height: 0; width: 24px; height: 24px; accent-color: var(--red); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--blue-ink);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  background: var(--surface);
  box-shadow: var(--pop);
  transition: transform .06s ease, box-shadow .06s ease;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
button[type='submit'], #publish {
  background: var(--cta-bg);
  color: var(--cta-ink);
  border-color: var(--line);
}
button.link {
  background: none; border: none; box-shadow: none; padding: 0; min-height: 0;
  /* On the red by default, like every other loose control; inside a panel it
     goes back to the link blue below. "Log out" sat blue-on-red at 1.51:1. */
  color: var(--on-frame); text-decoration: underline; font-weight: 700;
}
button.remove {
  text-decoration: none; font-size: 1.4rem; line-height: 1;
  min-width: 44px; min-height: 44px; color: var(--ink-soft);
}
button.remove:hover { color: var(--red-ink); }

.row-fields { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.row-fields .grow { flex: 1 1 14rem; }
.row-fields input, .row-fields select { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.1rem 0; }
.checkbox-field { display: flex; align-items: end; }
.checkbox-field label { display: flex; align-items: center; gap: .5rem; color: inherit; font-size: 1rem; min-height: 44px; margin: 0; }
/* Explicit here, because `.checkbox-field input` outranks the type selector
   that sets the size: with `width: auto` the box rendered 13px wide while its
   height stayed 24. */
.checkbox-field input { width: 24px; height: 24px; flex: 0 0 auto; }

/* --- tables ------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: var(--outline) solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  /* A deeper shadow than the other blocks: on the red, this is the object the
     page is about. */
  box-shadow: 0 6px 0 rgba(0, 0, 0, .4);
}
thead th {
  font-style: italic;
  background: var(--header-bg);
  color: var(--header-ink);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: left;
  padding: .7rem .75rem;
}

/* The numbers need room to breathe more than the names do: they sit against
   the right edge, and a column of digits with no gutter reads as a block. */
td.num, th.num { padding-right: 1.1rem; padding-left: 1.1rem; }
#board td:last-child, #board th:last-child { padding-right: 1.4rem; }
td { padding: .55rem .75rem; border-bottom: 2px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--ink) 4%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input[type='text'] { width: 100%; }
td input[type='number'] { width: 5.5rem; }

/* --- the scoreboard ----------------------------------------------------- */

#board td:first-child { width: 3.4rem; }

/* Placement: a coin-shaped badge. The number is inside it, so the ranking
   never depends on the colour being seen. */
.place {
  display: inline-grid;
  place-items: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 .3rem;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  /* Follows the theme, because its background does. Only the medals below
     pin a dark ink, because only they are light in both themes — pinning it
     here made every badge from 4th place down dark-on-dark and invisible. */
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.place-1 { background: var(--gold); color: var(--badge-ink); }
.place-2 { background: var(--silver); color: var(--badge-ink); }
.place-3 { background: var(--bronze); color: var(--badge-ink); }

/* The leader also gets a star and a heavier row — shape and weight, not only
   a colour, so it survives a washed-out projector and colour-blindness. */
tr.leader td { background: color-mix(in srgb, var(--coin) 26%, transparent); }
tr.leader .player-name { font-weight: 700; }
.leader-star { margin-left: .3rem; }

.player-name { font-weight: 700; font-style: italic; }

/* Tags carry their own word. "bot" is readable if the border and tint are
   invisible to you. */
.tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .1rem .4rem;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink);
  margin-left: .35rem;
  white-space: nowrap;
}
.tag.warn-tag { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-ink); }

tr.needs-attention td { background: var(--warn-bg); }
.row-note { display: block; font-size: .74rem; font-weight: 600; color: var(--warn-ink); }
.row-note:empty { display: none; }

/* --- blocks ------------------------------------------------------------- */

.reader, .queue li, #report > p {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem;
}
/* No surface: the heading is loose text on the red, which is the point of
   framing only the board. It had one, and the white title disappeared into
   a white block. */
.board-head { margin-bottom: .6rem; }

/* Which board you are on, and the way to the other one. The current mode is
   not a link: a tab you can press that does nothing is a small lie. */
.mode-switch {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: -.4rem 0 1rem;
}
.mode-switch .current,
.mode-switch a {
  font-weight: 700;
  font-style: italic;
  padding: .35rem .9rem;
  border: 3px solid var(--line);
  border-radius: 99px;
  white-space: nowrap;
}
.mode-switch .current {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--pop);
}
.mode-switch a {
  color: var(--on-frame);
  background: transparent;
  border-color: rgba(0, 0, 0, .45);
  text-decoration: none;
}
.mode-switch a:hover { background: rgba(0, 0, 0, .18); }

/* The date range, as the pill those cards put the event ID in. */
#summary {
  display: inline-block;
  background: var(--coin);
  color: var(--badge-ink);
  font-weight: 700;
  font-style: italic;
  padding: .3rem .85rem;
  border: 3px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--pop);
  margin: .2rem 0 1rem;
}
.reader { box-shadow: var(--pop); margin-bottom: 1.2rem; }
.reader input[type='file'] { width: 100%; max-width: 28rem; }
.reader progress { width: 100%; margin-top: .5rem; height: 14px; }
#reader-status { margin: .5rem 0 0; }

.queue { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.queue li {
  margin-bottom: .5rem;
  display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
  box-shadow: var(--pop);
}

#report ul { margin: .25rem 0 .75rem; padding-left: 1.1rem; }
#report .ok { color: var(--green-ink); font-weight: 700; }
#report > p { box-shadow: var(--pop); }

hr { border: none; border-top: 3px solid var(--line-soft); margin: 2rem 0; }

/* --- the theme switch --------------------------------------------------- */

.theme-toggle {
  /* In the flow, at every width. Positioned in the corner it collided with the
     title — which is now the biggest thing on the page and grows with the
     viewport, so there is no corner it can reliably keep out of. */
  display: block;
  margin: 0 0 .4rem auto;
  font-size: .85rem;
  padding: .4rem .9rem;
  /* It sits on the red frame, so it brings its own surface rather than
     relying on whatever is behind it. */
  background: var(--surface);
  color: var(--ink);
  border: 3px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--pop);
}

/* --- phone -------------------------------------------------------------- */

@media (max-width: 34rem) {
  body { padding: 12px; font-size: 16px; }
  .theme-toggle { margin-bottom: .7rem; }
  td, th { padding: .3rem .4rem; }
  td input[type='number'] { width: 4rem; }
  .tag { font-size: .62rem; }
  /* Which columns are context rather than the answer is decided per mode in
     board.js, which marks them — counting positions here broke the moment a
     column moved. */
  .phone-hide { display: none; }
  /* The gutters that give the numbers air on a desktop push the table past
     375px, and a scoreboard you have to scroll sideways is a worse trade than
     slightly tighter figures. */
  td.num, th.num { padding-left: .45rem; padding-right: .45rem; }
  #board td:last-child, #board th:last-child { padding-right: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

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

/* The race is a surface the board sits ON, not a panel beside it (#39).
   It begins behind the table and runs off the right edge of the viewport. */
.board-layout {
  position: relative;
  display: grid;
  gap: 1.1rem;
  align-items: start;
}

/* The table rides above the race and keeps its own opaque background, which
   is what keeps it readable over a moving scene. */
.board-column { position: relative; z-index: 1; }

/* Square and unshadowed (#41). Both were right when this was a small card
   beside the table; on a surface that bleeds off the side of the screen a
   rounded corner only exists on one end, and a drop shadow makes the ground
   the board stands on look like it is floating above the page. */
.race-frame {
  position: relative;
  background: var(--surface);
  border: var(--outline) solid var(--line);
  overflow: hidden;
}
#race-stage { width: 100%; height: 22rem; }
#race-stage canvas { display: block; width: 100%; height: 100%; }
#race-labels { position: absolute; inset: 0; pointer-events: none; }

/* The tab that puts the race away (#49).
   On a phone it sits in the flow under the table; on a wide screen the rule
   below lifts it onto the table's right edge. The arrow points whichever way
   the race actually lies, which is the only thing making an arrow mean
   anything: left/right beside the table, up/down beneath it. */
.race-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.2rem;
  margin: .7rem auto 0;
  padding: 0;
  min-height: 0;
  background: var(--surface);
  color: var(--ink);
  border: var(--outline) solid var(--line);
  border-radius: 10px;
  box-shadow: var(--pop);
}
.race-toggle svg { transform: rotate(-90deg); transition: transform .18s ease; }
body.race-hidden .race-toggle svg { transform: rotate(90deg); }

/* Away means gone, not merely invisible: `display: none` keeps the race out
   of the intersection observer, so a board that starts with the race hidden
   never fetches three.js at all. */
body.race-hidden #race { display: none; }

/* Wide screens: the race is lifted out of the grid and stretched from the
   table's left edge to the right edge of the viewport, underneath the board.
   The grid keeps a second column so the table does not grow over the whole
   surface; nothing is placed in it. These rules come AFTER the base ones on
   purpose — `#race-stage { height: 22rem }` has the same specificity, and
   when this block sat above it the stage kept 22rem and the frame below the
   canvas rendered as a bare rectangle. */
@media (min-width: 60rem) {
  /* The table is as wide as its contents, whether the race is out or not, so
     folding the race away does not resize the scoreboard under your eyes.
     The race takes whatever is left; it is behind the table and bleeds off
     the right of the viewport anyway, so it does not need a share to be
     negotiated. */
  .board-layout { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
  #board { width: auto; }

  #race {
    position: absolute;
    /* Inset from the board's top and bottom so the table meets the surface
       with room rather than butting into its edge. */
    top: 2em;
    bottom: 2em;
    left: 0;
    /* `main` is centred inside the body's padding, so half the viewport less
       half of this container reaches exactly the viewport's right edge. */
    right: calc(50% - 50vw);
    z-index: 0;
  }
  #race .race-frame { height: 100%; }
  #race #race-stage { height: 100%; }

  .race-toggle {
    position: absolute;
    /* Centred on the table's height. Done with auto margins between a top and
       a bottom of 0 rather than `translateY(-50%)`, because buttons here take
       a `translateY(3px)` when pressed and the two transforms would fight —
       the tab would jump to the top of the table on every click. */
    top: 0;
    bottom: 0;
    margin-block: auto;
    /* Flush against the table: the tab's own left edge lands exactly on the
       table's right border, which it then borrows instead of drawing its own.
       Offsetting by the outline as well left a gap the width of the border. */
    right: -2.6rem;
    margin-inline: 0;
    border-radius: 0 10px 10px 0;
    border-left-width: 0;
  }
  .race-toggle svg { transform: rotate(180deg); }
  body.race-hidden .race-toggle svg { transform: rotate(0deg); }

  /* Race away: the same single column, so the table does not change size. */
  body.race-hidden .board-layout { grid-template-columns: minmax(0, max-content); }
}

.race-label {
  position: absolute;
  top: 0;
  left: 0;
  font-weight: 700;
  font-style: italic;
  font-size: .72rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0 .25rem;
  white-space: nowrap;
  will-change: transform;
}
.race-label.leading { background: var(--coin); color: var(--badge-ink); border-color: var(--line); }

/* The flat fallback, for a browser with no WebGL. */
.race-flat #race-stage { height: auto; }
.lanes { position: relative; height: 100%; }
.kart {
  position: absolute;
  display: flex;
  align-items: center;
  left: calc(var(--at) * (100% - 9.8rem) / 100% + 7.2rem);
  transition: left .9s cubic-bezier(.4, 0, .2, 1);
  white-space: nowrap;
}
.kart-name {
  position: absolute;
  left: calc(-7.2rem + .4rem);
  width: 6.4rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  font-style: italic;
  font-size: .78rem;
  color: var(--ink);
}
.kart.leading .kart-name {
  background: var(--coin); color: var(--badge-ink);
  border-radius: 6px; padding: 0 .25rem; width: auto; max-width: 6.4rem;
}


/* On a phone the race spans the viewport's whole width and gets taller.
   Below the table rather than behind it: a phone has no room to spare, and
   the table would cover most of the surface (#39). */
@media (max-width: 60rem) {
  #race {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    width: 100vw;
  }
  #race .race-frame { border-left: 0; border-right: 0; }
  #race-stage { height: 60vh; min-height: 20rem; }
}

@media (max-width: 34rem) {
  .race-label { font-size: .66rem; }
  .kart { left: calc(var(--at) * (100% - 7.6rem) / 100% + 5.4rem); }
  .kart-name { left: calc(-5.4rem + .3rem); width: 4.8rem; font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .kart { transition: none; }
}
