/* ------------------------------------------------------------------------------------------------
   Group finals broadcast: one match of a group (four-player) elimination bracket, for a stream overlay.

   The head-to-head finals page's tokens, status line and controls (bracket/broadcast.css), restated so
   the two stylesheets stay independent; the view between them is a different shape — a scoreboard
   grid of four players by the match's games — rather than a theme of the other.
   ------------------------------------------------------------------------------------------------ */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #111827;
  --border: #d0d0d8;
  --muted: #6b7280;
  --warning: #b45309;
  --on-game: #059669;
  --panel-bg: rgba(127, 127, 127, 0.07);
  /* The spotlight's why band: a cool tint, light enough to read bold text on. */
  --why-bg: rgba(14, 116, 144, 0.12);
  --win-bg: rgba(5, 150, 105, 0.12);
  /* The players' tints: blue, red, green, gold — the classic four, so a four-player group format
     has its colours waiting. Deliberately not the orange/blue/green/pink washes the queue board tints
     its tournaments with: on an event weekend those mean "which tournament", and two players in
     one match are in the same one. The blue and green here share hues with the board's second and
     third queues, which is tolerable because the two never share a page. Only the first two are
     used today. */
  --player-0: rgba(59, 130, 246, 0.22);
  --player-1: rgba(239, 68, 68, 0.20);
  --player-2: rgba(34, 197, 94, 0.22);
  --player-3: rgba(234, 179, 8, 0.28);
  /* Group match play qualifying's zones (qualifying-lines.js): byes (2 byes a deeper blue than 1), the A cut, the B cut, any after. */
  --zone-bye: #3b82f6;
  --zone-bye2: #1e40af;
  --zone-a: #047857;
  --zone-b: #b45309;
  --zone-c: #7c3aed;
}

/* Dark by default — group.js stamps <html data-theme="dark"> unless the URL says ?theme=light —
   because the page's home is OBS's browser, which can't state a colour-scheme preference and would
   render light, on a stream layout that is dark. The preference block below is for a page opened in
   an ordinary browser with no data-theme at all. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --text: #f3f4f6;
    --border: #3f3f46;
    --muted: #9ca3af;
    --warning: #fbbf24;
    --on-game: #34d399;
    --panel-bg: rgba(255, 255, 255, 0.06);
    --why-bg: rgba(125, 211, 252, 0.16);
    --win-bg: rgba(52, 211, 153, 0.18);
    --player-0: rgba(96, 165, 250, 0.36);
    --player-1: rgba(248, 113, 113, 0.34);
    --player-2: rgba(74, 222, 128, 0.32);
    --player-3: rgba(250, 204, 21, 0.34);
    --zone-bye: #bfdbfe;
    --zone-bye2: #60a5fa;
    --zone-a: #6ee7b7;
    --zone-b: #fcd34d;
    --zone-c: #c4b5fd;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117;
  --text: #f3f4f6;
  --border: #3f3f46;
  --muted: #9ca3af;
  --warning: #fbbf24;
  --on-game: #34d399;
  --panel-bg: rgba(255, 255, 255, 0.06);
  --why-bg: rgba(125, 211, 252, 0.16);
  --win-bg: rgba(52, 211, 153, 0.18);
  --player-0: rgba(96, 165, 250, 0.36);
  --player-1: rgba(248, 113, 113, 0.34);
  --player-2: rgba(74, 222, 128, 0.32);
  --player-3: rgba(250, 204, 21, 0.34);
  --zone-bye: #bfdbfe;
  --zone-bye2: #60a5fa;
  --zone-a: #6ee7b7;
  --zone-b: #fcd34d;
  --zone-c: #c4b5fd;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* One knob for every size on the page, from the smaller of width and height. The height term is set
   by the stack — the header, the board's two-line heading, four player rows, the cutline and the game
   on now — and the width term by eight columns of numbers beside the names; fitStage in group.js steps
   it down further when a window still doesn't hold the board. */
/* The ground is painted on html as well as body: an OBS browser source injects
   `body { background-color: rgba(0,0,0,0) }` as its default custom CSS, which beat body's own background
   and left the page see-through on the stream, tinted by whatever sat beneath it in the scene. OBS
   doesn't touch html, so with body cleared the page is still solid. (The menu page does the same.) */
html {
  background: var(--bg);
  color: var(--text);
  font-size: clamp(11px, min(2.3vw, 5.4vh), 44px);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  /* A little more above than below: the top edge is the one the stream layout crops closest to. */
  padding: 0.6rem 0.6rem 0.35rem;
  /* Clear of a phone's notch and home bar in landscape (zero elsewhere). */
  padding-left: max(0.6rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.6rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  color: var(--text);
  line-height: 1.25;
  /* Nothing scrolls, by design: the page fits itself to the window (see fitStage in group.js). */
  overflow: hidden;
  /* The visible height: a phone browser's 100vh counts the space behind its address and tool bars, which
     cut off the foot of the controls in portrait and pushed the board under the address bar in landscape. */
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* The stage and the controls set their own display, which would otherwise beat the hidden attribute's
   UA rule; group.js toggles visibility through that attribute. */
[hidden] { display: none !important; }

/* ---- Header ------------------------------------------------------------------------------------ */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.head {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

h1.title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 6em;
}

/* ---- The scoreboard ---------------------------------------------------------------------------- */

/* One grid: place, name (with the seed in its box), a column per game, the tiebreaker when there is one, the total.
   group.js sets the template on it, since the columns follow the match (CSS's repeat() can't take a
   count of zero, which a match without a tiebreaker would need). The names take what they need, up to
   40% of the width, and the games share the rest, for their machine names. The name takes what is left and is shrunk to fit rather than
   cut short; the game columns share a width wide enough for "P4" or "5", their machine names cut to
   it with an ellipsis. Rows are display: contents, so their cells sit in the grid's columns. */
.board {
  /* Every size on the board, so the other matches' smaller copy (.board.mini) is the same board scaled. */
  --u: 1rem;
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) repeat(5, minmax(2.6em, 4.2em)) minmax(2.8em, auto);
  column-gap: calc(0.25 * var(--u));
  row-gap: calc(0.18 * var(--u));
  align-items: stretch;
  min-height: 0;
}

.board .row { display: contents; }

.board .cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: calc(0.12 * var(--u)) calc(0.35 * var(--u));
  border-radius: calc(0.3 * var(--u));
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.board .head-cell {
  color: var(--muted);
  font-size: calc(0.75 * var(--u));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 calc(0.05 * var(--u)) calc(0.1 * var(--u));
}


/* A game's machine: its name running up a narrow column beside the game's points, read bottom to top,
   spanning every player row. Always one size; a name longer than the rows are tall goes onto two lines
   in a wider strip (.wrap, set by fitMachines in group.js), and only a name too long even for that is
   cut to fit with an ellipsis — by fitMachines, not by text-overflow, which Safari draws past the
   edge of rotated text and doesn't redo when the phone turns. Sized (contain: size) so a long name never stretches the rows, and painted over the cutline
   (it comes later in the board and has the page's ground) so the dashes stop either side of it. */
.board .machine {
  contain: size;
  width: calc(1.5 * var(--u));
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--bg);
}

/* No machine chosen yet: nothing to read, so the cutline goes straight through. */
.board .machine.empty {
  background: transparent;
}

.board .machine-text {
  writing-mode: vertical-rl;
  /* Every glyph turned with the line, so an apostrophe or a hyphen reads as it would across. */
  text-orientation: sideways;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: calc(1.08 * var(--u));
  font-weight: 600;
  line-height: 1.05;
  color: var(--muted);
}

/* A name too long for one line: two, balanced, in a strip wide enough for both. */
.board .machine.wrap { width: calc(2.75 * var(--u)); }

.board .machine.wrap .machine-text {
  white-space: normal;
  text-wrap: balance;
  text-align: center;
  max-height: calc(100% - 0.3em);
}

.board .machine.now .machine-text { color: var(--on-game); }

/* A game with nothing in its points yet (no player order): its machine's name across both its columns, in
   their panel, over every player row, in place of the empty cells (renderBoard). Written up the panel, read
   bottom to top as the narrow machine strips are, since the panel is taller than it is wide: a line runs the
   rows' height, so long words fit whole, and the lines stack across its width. A name too long for every line
   that fits across is first made smaller, just enough to fit whole, and only past a floor cut with an
   ellipsis, both by fitMachines. Painted over the cutline, as the upright names are. */
.board .game-name {
  contain: size;
  min-height: 0;
  justify-content: center;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--panel-bg);
  padding: calc(0.3 * var(--u)) calc(0.3 * var(--u));
}

.board .game-name-text {
  writing-mode: vertical-rl;
  /* Every glyph turned with the line, so an apostrophe or a hyphen reads as it would across. */
  text-orientation: sideways;
  transform: rotate(180deg);
  white-space: normal;
  text-wrap: balance;
  text-align: center;
  overflow-wrap: anywhere;
  max-height: 100%;
  /* Stepped down by fitMachines (to GAME_NAME_FLOOR) where the panel is short, so the whole name fits. */
  font-size: calc(1.15 * var(--game-name-scale, 1) * var(--u));
  font-weight: 600;
  line-height: 1.1;
  color: var(--muted);
}

.board .game-name.now { box-shadow: inset 0 0 0 2px var(--on-game); }
.board .game-name.now .game-name-text { color: var(--on-game); }
.board.single-game .game-name.now,
.all-groups .board .game-name.now { box-shadow: none; }
.board.single-game .game-name.now .game-name-text,
.all-groups .board .game-name.now .game-name-text { color: var(--muted); }

.board .head-cell.now { color: var(--on-game); }

/* A game's heading is underlined across both its columns, tying its machine's name and its points together
   as the full-standings broadcast's headings do; the game on now's in the live colour. */
.board .head-cell.game-head {
  border-bottom: calc(0.12 * var(--u)) solid var(--border);
  border-radius: 0;
  padding-bottom: calc(0.15 * var(--u));
}

.board .head-cell.game-head.now { border-bottom-color: var(--on-game); }

.board .place {
  font-weight: 700;
  justify-content: flex-end;
  color: var(--muted);
}

.board .seed {
  flex: none;
  width: calc(var(--seed-digits, 1) * 1ch);
  text-align: right;
  color: var(--muted);
  font-size: max(0.6em, calc(0.55 * var(--u)));
  font-weight: 600;
  margin-right: 0.4em;
}

/* The name: the biggest type on the page, every row the same size (fitNames steps them down together
   until the longest fits), tinted by the player's slot in the group, which follows them as rows move.
   The seed leads inside the box, smaller than the name and scaled with it down to a readable floor,
   costing only its digits and a narrow gap —
   the box's padding is shared, not doubled. Every seed is as wide as the widest (group.js sets
   --seed-digits), right-aligned, so the names start together. */
.board .name {
  font-weight: 700;
  font-size: calc(var(--name-scale, 1.35) * var(--u));
  white-space: nowrap;
  overflow: hidden;
}

/* On the other matches' smaller boards a name too long for its column, at the smallest size they take, is
   cut with an ellipsis (fitNames in group.js). */
.board.mini .name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board .row[data-slot="0"] .name { background: var(--player-0); }
.board .row[data-slot="1"] .name { background: var(--player-1); }
.board .row[data-slot="2"] .name { background: var(--player-2); }
.board .row[data-slot="3"] .name { background: var(--player-3); }
/* The round's other groups aren't the match on stream: their names take no player tint, which would tie
   them to the main board's players. */
.board.mini .row[data-slot] .name { background: var(--panel-bg); }

/* Through whatever the games left bring (clinched), or level on the line, beside the place. */
.board .row.advancing .place { color: var(--on-game); }
.board .row.tied .place { color: var(--warning); }

/* The points: tight to their numbers, so the columns give their width to the names beside them. */
.board .pts,
.board .tb {
  padding: calc(0.04 * var(--u)) calc(0.12 * var(--u));
}

.board .pts,
.board .tb,
.board .total {
  justify-content: center;
  font-size: calc(1.15 * var(--u));
  font-weight: 600;
  background: var(--panel-bg);
}

/* The room a tiebreaker would take, there only while the page is sized (withGhosts in group.js). */
.board .ghost { visibility: hidden; }
.board:not(.ghosts) .ghost { display: none; }

/* A game's winner. */
.board .pts.won { background: var(--win-bg); font-weight: 800; }

/* The game on now: its column outlined, and until it's scored each cell shows the player's position. */
.board .pts.now { box-shadow: inset 0 0 0 2px var(--on-game); }
/* One game a round: nothing to tell the game on now from, so no outline, live-coloured heading or machine. */
.board.single-game .pts.now,
.all-groups .board .pts.now { box-shadow: none; }
.board.single-game .head-cell.now,
.board.single-game .machine.now .machine-text,
.all-groups .board .head-cell.now,
.all-groups .board .machine.now .machine-text { color: var(--muted); }
.board.single-game .head-cell.game-head.now,
.all-groups .board .head-cell.game-head.now { border-bottom-color: var(--border); }
.board .pts .position {
  font-size: calc(0.8 * var(--u));
  font-weight: 700;
  color: var(--on-game);
}

/* A machine score in before the game's result (P1's, while the others play): short, in the cell. */
.board .pts .score,
.board .tb .score {
  font-size: calc(0.8 * var(--u));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.board .pts.upcoming { opacity: 0.45; }

.board .tb { font-size: calc(0.95 * var(--u)); color: var(--muted); }
.board .tb.won { background: var(--win-bg); color: var(--text); font-weight: 800; }

/* Centred under its heading, in a column only as wide as the wider of the two. */
.board .total {
  font-size: calc(1.5 * var(--u));
  font-weight: 800;
  background: transparent;
  justify-content: center;
  padding-left: calc(0.1 * var(--u));
  padding-right: calc(0.1 * var(--u));
}

/* The cutline: a rule under the last place that goes through. */
.board .cutline {
  grid-column: 1 / -1;
  height: 0;
  border-top: 2px dashed var(--on-game);
  opacity: 0.7;
  margin: calc(0.05 * var(--u)) 0;
}

.board .cutline.unsettled { visibility: hidden; }

/* ---- A final's results ------------------------------------------------------------------------- */

/* A minute after a final is over, in the board's place: the champion in a gold panel on the left (a trophy,
   the name as large as fits, the seed, the games won and where, the total), and the other places down the
   right, each a badge with the place — silver, bronze, then plain — beside the name, seed and total. */
:root {
  --gold: #b7791f;
  --gold-soft: rgba(183, 121, 31, 0.14);
  --gold-line: rgba(183, 121, 31, 0.55);
  --silver: #94a3b8;
  --bronze: #b4682f;
}

:root[data-theme="dark"] {
  --gold: #f5c542;
  --gold-soft: rgba(245, 197, 66, 0.2);
  --gold-line: rgba(245, 197, 66, 0.55);
  --silver: #cbd5e1;
  --bronze: #d08a52;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gold: #f5c542;
    --gold-soft: rgba(245, 197, 66, 0.2);
    --gold-line: rgba(245, 197, 66, 0.55);
    --silver: #cbd5e1;
    --bronze: #d08a52;
  }
}

/* One game a round: its machine, which the board names nowhere else, in the text's colour. */
.title .title-machine { color: var(--text); }

.title .title-tag {
  margin-left: 0.6em;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.results {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 0.45rem;
}

.champion {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  border: 0.06rem solid var(--gold-line);
  background: linear-gradient(135deg, var(--gold-soft), transparent 65%), var(--panel-bg);
}

.champion .trophy { width: 2.3rem; height: 2.3rem; fill: var(--gold); }
.champion .trophy .handles { fill: none; stroke: var(--gold); stroke-width: 4; }
.champion .trophy .stem { opacity: 0.8; }

.champion-text { min-width: 0; }

.champion-label {
  color: var(--gold);
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.champion-name {
  font-size: calc(var(--champ-scale, 1) * 1.65rem);
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0.05rem 0 0.12rem;
}

.champion-meta {
  color: var(--muted);
  font-size: 0.5rem;
  line-height: 1.2;
}

.champion-meta b { color: var(--text); font-weight: 700; }

.champion-total { text-align: right; }
.champion-total .num {
  color: var(--gold);
  font-size: 2.3rem;
  font-weight: 900;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}
.champion-total .unit {
  color: var(--muted);
  font-size: 0.45rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.places {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: grid;
  grid-auto-rows: 1fr;
  gap: 0.25rem;
}

.place-card {
  --c: var(--border);
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0.45rem 0.12rem 0.3rem;
  border-radius: 0.25rem;
  border-left: 0.12rem solid var(--c);
  background: var(--panel-bg);
}

.place-card.silver { --c: var(--silver); }
.place-card.bronze { --c: var(--bronze); }

.place-card .medal {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--bg);
  background: var(--c);
}

.place-card:not(.silver):not(.bronze) .medal {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 0.06rem var(--border);
}

.place-card .place-name {
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-card .place-name small {
  margin-left: 0.4em;
  color: var(--muted);
  font-size: 0.5em;
  font-weight: 600;
}

.places.no-seeds .place-name small { display: none; }

.place-card .place-total {
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Under it, the panel takes the rest of the page, and the group's scoreboard is one of its slides, at the
   other groups' smaller size but keeping its players' tints (it's the match on stream): the champion's row
   picked out in gold. */
.lower.results-lower .field { min-height: 5rem; }

.field-slide.group-slide {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.group-slide .board { flex: none; }
.group-slide .board.mini .row[data-slot="0"] .name { background: var(--player-0); }
.group-slide .board.mini .row[data-slot="1"] .name { background: var(--player-1); }
.group-slide .board.mini .row[data-slot="2"] .name { background: var(--player-2); }
.group-slide .board.mini .row[data-slot="3"] .name { background: var(--player-3); }

/* Its title line is left empty (the page's heading names it), holding its room. */
.field-title.untitled { visibility: hidden; }
.group-slide .board .row:first-of-type .place,
.group-slide .board .row:first-of-type .total { color: var(--gold); }

/* ---- The other matches and the standings ------------------------------------------------------- */

/* Under the match on stream: the round's other groups, one at a time, each swiped in from the right as
   the last leaves to the left (group.js), beside the tournament's standings scrolling in the bottom
   right. It takes what height the page has left, so the standings have room even in a final, where
   there is no other match. */
.lower {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 26%);
  column-gap: 0.9rem;
  margin-top: 0.25rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--border);
}

.lower-title {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.others {
  grid-column: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* "Other matches", on the line of the group showing: held over the start of that line, on the page's
   ground, so each slide's own line (which leaves it room, .others-title-room) swipes in under it. */
.others-title,
.others-title-room {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.others-title {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  margin: 0;
  padding-right: 0.6rem;
  line-height: inherit;
  color: var(--text);
  background: var(--bg);
}

.others-title-room { visibility: hidden; flex: none; }

/* The slides — every other match, not just the one showing — stack in one cell, so the window is as
   tall as the tallest of them and holds still as they rotate; it's clipped so a slide off to the side
   never widens the page. Only the one showing (and one swiping out) is seen. */
.others-viewport {
  display: grid;
  overflow: hidden;
  min-width: 0;
}

.other-slide {
  grid-area: 1 / 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--bg);
  will-change: transform;
  visibility: hidden;
}

.other-slide.showing,
.other-slide.leaving { visibility: visible; }

/* The one coming in is drawn over the one going out. */
.other-slide.showing:not(.leaving) { z-index: 1; }

.other-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

.other-head .other-label { font-weight: 700; flex: none; }

.other-head .other-state {
  flex: 0 1000 auto;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.other-head .other-state.live { color: var(--on-game); }

/* The gutter: each slide's heading ("Other groups", then the group and its state, or "Results") stacked down its left
   rather than on a line over it, which gives the rows that line. The section's title stays over the top of it. */
.others.gutter { --gutter: 7.4rem; }

.others.gutter .other-slide {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  column-gap: 0.8rem;
  align-items: start;
}

.others.gutter .other-slide > .other-head {
  grid-column: 1;
  grid-row: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  white-space: normal;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.others.gutter .other-slide > :not(.other-head) { grid-column: 2; grid-row: 1; min-width: 0; }
.others.gutter .other-head > * { max-width: 100%; }
.others.gutter .other-head .other-state { flex: none; overflow: visible; }
.others.gutter .card-head .card-title { white-space: normal; }
/* A board of one game: its machine (and the ▶ while it's played) on the line under the group's name. */
.others.gutter .other-label .other-sep { display: none; }
.others.gutter .other-label .other-machine { display: block; }

.others.gutter .others-title,
.others.gutter .others-title-room {
  white-space: normal;
  width: var(--gutter);
  padding-right: 0;
  line-height: 1.15;
}

.others.gutter .others-title-room { display: block; margin-bottom: 0.15rem; }

/* A little smaller than the match on stream. */
.board.mini { --u: 0.78rem; }

/* The spotlight's reason a group is featured, over its names in the heading row, which has room there. */
.board .cell.why {
  color: var(--text);
  font-size: calc(0.95 * var(--u));
  font-weight: 700;
  /* On a tinted band, led by a star in the live colour: it's about who is playing. No taller than the headings
     beside it ("Total"), so a featured board is no taller than any other. */
  background: var(--why-bg);
  line-height: 1.05;
  padding-block: 0;
  align-self: end;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* In CSS, so it stays as the line's text is swapped for a shorter one (fitWhy). */
.board .cell.why::before { content: "★ "; color: var(--on-game); }

/* Several groups to a card, side by side: each a short column of its players, as tall as one group's board. */
.pack {
  display: grid;
  grid-template-columns: repeat(var(--pack-columns, 4), minmax(0, 1fr));
  gap: 0.35rem 1.1rem;
  min-width: 0;
  --u: 0.78rem;
}

.pack-group { display: flex; flex-direction: column; gap: calc(0.18 * var(--u)); min-width: 0; }

/* A group's rows share columns sized to their content, so each player's numbers sit just after the longest name in
   the group rather than across at the column's far edge, beside the next group's names. */
.pack-rows {
  display: grid;
  grid-template-columns: minmax(0, max-content) auto auto;
  justify-content: start;
  align-items: baseline;
  column-gap: 0.5em;
  row-gap: calc(0.18 * var(--u));
  min-width: 0;
  font-size: calc(1.1 * var(--u));
}

.pack-rows.no-gain { grid-template-columns: minmax(0, max-content) auto; }

.pack-head {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  min-width: 0;
  font-size: calc(0.95 * var(--u));
  white-space: nowrap;
  border-bottom: calc(0.08 * var(--u)) solid var(--border);
  padding-bottom: calc(0.12 * var(--u));
}

.pack-label { color: var(--muted); flex: none; }

/* The machine is what a viewer knows the group by: it leads, the group's number beside it in grey. */
.pack-machine {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pack-machine .live, .other-head .other-label .live { color: var(--on-game); }

/* A row of the group's grid (.pack-rows): its cells sit in the grid's columns. */
.pack-row {
  display: contents;
  line-height: 1.3;
  white-space: nowrap;
}

.pack-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pack-gain { color: var(--on-game); font-variant-numeric: tabular-nums; font-size: 0.85em; }
.pack-total { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; }

.standings {
  grid-column: 2;
  min-width: 0;
  min-height: 6rem;
  display: flex;
  flex-direction: column;
}

/* "after Round 3" on its own line under the title, so the narrow column never cuts it short. */
.standings-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.standings-sub:empty { display: none; }

/* The list's window: it takes the column's height without adding to it (the list is laid out inside an
   absolutely placed box), and scrolls by itself — never by hand — fading at the bottom before it jumps
   back to the top. */
.standings-viewport {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

.standings-scroll {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transition: opacity 0.45s;
}

.standings-scroll.fading { opacity: 0; }

.standings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.standings-list li {
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr) auto;
  gap: 0.4em;
  align-items: baseline;
  font-size: 0.8rem;
  line-height: 1.3;
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.standings-list .pos { color: var(--muted); font-weight: 700; text-align: right; }
.standings-list .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standings-list .pts { color: var(--muted); }
/* A knockout player out on strikes: still listed, after those still in, faded. */
.standings-list li.out { opacity: 0.45; }
.board .row.out .name, .board .row.out .place { opacity: 0.55; }
.board .cell.total.out { text-decoration: line-through; text-decoration-thickness: 0.08em; opacity: 0.7; }

/* Early in qualifying, on a short, wide stage (fitStage): the standings down the whole right side, from the
   header's line to the bottom, the header, board and other groups beside them. */
.stage.tall-standings { position: relative; padding-right: calc(max(9rem, 24%) + 0.9rem); }
.stage.tall-standings .lower { grid-template-columns: minmax(0, 1fr); }
.stage.tall-standings .standings {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: max(9rem, 24%);
}

/* No standings to show beside them yet: the other matches and the cards take the whole width. */
.lower.no-standings .others { grid-column: 1 / -1; }

/* ---- The cards ----------------------------------------------------------------------------------- */

/* Rotated in after the other matches (or a final's field pages): what the players did on the machine being
   played in qualifying, the group that plays it next, and the players themselves. Each is a slide like an
   other match's, with its own title on the line "Other matches" otherwise holds — which steps aside while
   a card shows. Sized like the other matches' smaller boards, so the rotation doesn't resize the page. */
.others.card-on .others-title { visibility: hidden; }

/* A long title ("Up next for Group 1: Pokémon (Premium/LE) in qualifying") keeps its line: the line under
   it gives way first, then the title itself is cut. */
.card-head .card-title {
  flex: none;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* A grid of the card's columns; each row is display: contents, so its cells line up down the card. */
.card-grid {
  display: grid;
  column-gap: 0.3rem;
  row-gap: 0.2rem;
  align-items: stretch;
  margin-top: 0.1rem;
  font-size: 0.86rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.card-row { display: contents; }

.card-h {
  align-self: end;
  padding-bottom: 0.12rem;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-h.left,
.card-cell.left { text-align: left; }

/* P1–P4: the player's place in the game's order, in the live colour as the board's cells have it. */
.card-order {
  align-self: center;
  color: var(--on-game);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.card-name {
  min-width: 0;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-row[data-slot="0"] .card-name { background: var(--player-0); }
.card-row[data-slot="1"] .card-name { background: var(--player-1); }
.card-row[data-slot="2"] .card-name { background: var(--player-2); }
.card-row[data-slot="3"] .card-name { background: var(--player-3); }
/* The next group on the machine is another group: no tints, as on the other matches' boards. */
.card-next .card-row[data-slot] .card-name { background: var(--panel-bg); }

.card-cell {
  min-width: 0;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  background: var(--panel-bg);
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cell.big { font-size: 1.1em; }
/* The best of the group's bests on the machine. */
.card-cell.top { background: var(--win-bg); }
.card-cell.muted { color: var(--muted); font-weight: 500; }
.card-cell.left { font-weight: 600; }
.card-cell .unit { margin-left: 0.3em; color: var(--muted); font-size: 0.75em; font-weight: 500; }
.card-cell.class { font-weight: 800; }
/* The machine's top score in all of qualifying, under the group's: a rule across the card sets it apart,
   and it takes no tint of the group's — it isn't one of theirs. */
.card-rule {
  grid-column: 1 / -1;
  height: 0;
  margin: 0.1rem 0 0;
  border-top: 2px dashed var(--border);
}
.card-high .card-cell { background: transparent; }
.card-high .high-label {
  color: var(--muted);
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  align-self: center;
}
.card-high .high-name { font-weight: 600; }

/* Where a player is from: smaller than the card's figures, and a long city wraps to a second line rather
   than being cut off (a third is cut). */
.card-cell.from {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 0.78em;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Under a final a card is one of the field's pages: its title takes the field's own line, so its own head
   is left out, and it stacks rather than taking the pages' three columns. */
.field-slide.card-slide {
  display: flex;
  flex-direction: column;
}

.field-slide.card-slide .card-head { display: none; }

/* Room for a card's five lines under the field's title, so the page is fitted around it (fitStage). */
.field.has-cards { min-height: 8.5rem; }

/* Between games (group.js, renderIdleField): the big wins, one line each — who, on what, why, where they are
   now — in columns down the card, at the field's own size. */
.wins-list {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, max-content) minmax(0, 1fr) auto;
  column-gap: 0.7em;
  row-gap: 0.14rem;
  font-size: 0.8rem;
  line-height: 1.25;
}

.win-row { display: contents; }

.win-row > span {
  padding: 0.04rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.win-name { font-weight: 700; }
.win-name::before { content: "★ "; color: var(--on-game); }
.win-machine { color: var(--muted); font-weight: 600; }
.win-why { color: var(--on-game); font-weight: 700; }
.win-place { color: var(--muted); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Between games the panel is the stream's whole story, so its lines are larger than under a final. */
.idle-lower .field-column li,
.idle-lower .wins-list { font-size: 0.95rem; }
.idle-lower .pack { --u: 0.9rem; }

/* A knockout's players out, in the standings across the width, as in the column. */
.field-column li.out { opacity: 0.45; }

/* ---- The whole field, under a final ------------------------------------------------------------ */

/* In a round of one group, the width the other matches and the standings column share goes to the whole
   field, three columns a page (group.js pages it to the height it's given and swipes the pages in turn).
   Like the standings column it takes the height left without adding to it. */
.field {
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 6rem;
  display: flex;
  flex-direction: column;
}

.field-title {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
}

.field-sub {
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-sub:empty { display: none; }

.field-page {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.field-viewport {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

/* The pages stack in the one cell, as the other matches' slides do; only the one showing (and one
   swiping out) is seen. */
.field-slides {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.field-slide {
  grid-area: 1 / 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 0.45rem;
  align-items: start;
  background: var(--bg);
  will-change: transform;
  visibility: hidden;
}

.field-slide.showing,
.field-slide.leaving { visibility: visible; }

.field-slide.showing:not(.leaving) { z-index: 1; }

.field-column {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}

/* A player: one bar, as the scoreboard's cells are — the place at its left edge, the name, and the
   points in a well of their own at the right, with their unit. */
.field-column li {
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr) auto;
  align-items: stretch;
  font-size: 0.8rem;
  line-height: 1.25;
  border-radius: 0.25rem;
  background: var(--panel-bg);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.field-column li > span { padding: 0.04rem 0; }

.field-column .pos {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
  padding-right: 0.3em;
}

.field-column .who {
  padding-right: 0.3em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* As wide as its points and no wider: the number in a slot two digits wide (the most a bracket's
   standings run to), so the points still line up down a column. */
.field-column .pts {
  margin-left: 0.25em;
  padding: 0.04rem 0.3em 0.04rem 0.25em;
  text-align: right;
  font-weight: 600;
  background: var(--panel-bg);
}

.field-column .pts .num {
  display: inline-block;
  min-width: 2ch;
}

.field-column .pts .unit {
  margin-left: 0.15em;
  color: var(--muted);
  font-size: 0.75em;
  font-weight: 500;
}

.field-column .pts:empty { display: none; }

/* Qualifying's players, under the bracket's: the same bars, the names a little quieter. */
.field-column li.qualifying .who { font-weight: 500; }

/* "Qualifying", where the bracket's players end: a line the height of a player's, so the pages' sums hold. */
.field-column li.divider {
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  background: none;
}

.field-column .divider-text {
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.field-column .divider-text::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* "1–4: still playing", where another division's players still in its final will be placed. */
.field-column li.note {
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  background: none;
}

.field-column .note-text,
.standings-list .note-text {
  padding-left: 0.3em;
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- The game on now --------------------------------------------------------------------------- */

.now {
  flex: none;
  margin: 0;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Once the match is over, who goes through (or the tie still to settle), in the game's place. */
.now.result { font-weight: 700; color: var(--on-game); }
.now.result.tie { color: var(--warning); }

.now .marker { color: var(--on-game); margin-right: 0.35em; }
.now .what { font-weight: 700; }
.now .order { color: var(--muted); }
.now .order b { color: var(--text); font-weight: 600; }
.now .order .now-score { color: var(--on-game); font-weight: 700; font-variant-numeric: tabular-nums; }

/* While a game is on: the lead ("▶ Game 1 · <machine>") held, the order and scores beside it in a ticker
   that runs on a loop when they don't fit (group.js, nowTicker). The lead gives way only past half the line. */
.now.playing { display: flex; align-items: baseline; }
.now.playing .lead {
  flex: none;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 0.6em;
}
.now .ticker { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.now .ticker-track { display: inline-flex; will-change: transform; }
.now .ticker-copy { flex: none; }
/* The second copy only shows while running, a gap and a divider after the first. */
.now .ticker-copy + .ticker-copy { display: none; }
.now.ticking .ticker-copy { padding-right: 2.5em; }
.now.ticking .ticker-copy + .ticker-copy { display: inline; }
/* Faded at both ends while running, so the names slide in and out rather than being cut. */
.now.ticking .ticker {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 1.2em, #000 calc(100% - 1.6em), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 1.2em, #000 calc(100% - 1.6em), transparent 100%);
}
/* Not running (it fits, or reduced motion): cut with an ellipsis, as the line always was. */
.now:not(.ticking) .ticker { text-overflow: ellipsis; white-space: nowrap; }
/* Too little room for even one player of the order: none of it (nowTicker). */
.now.no-room .ticker { visibility: hidden; }
.now:not(.ticking) .ticker-track { display: inline; }


.status {
  margin: 0 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  overflow: clip visible;
}

.snapshot-status {
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0 0 0 0.45rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.snapshot-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}

.snapshot-status.pulse .snapshot-dot { animation: snapshot-pulse 0.9s ease-out; }

@keyframes snapshot-pulse {
  0% { opacity: 1; transform: scale(1.6); }
  100% { opacity: 0.35; transform: scale(1); }
}

.snapshot-status[aria-pressed="true"] .snapshot-dot { opacity: 1; }

/* The gear: the same size and colour as the dot, so it reads as part of the status line rather than
   as a control the stream's viewers are meant to notice. The padding is the target. */
.open-controls {
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0.15rem 0 0.15rem 0.55rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  /* Never narrower than a fingertip, where the page's text is small (a phone): the gear stays its size,
     centred in the target... */
  justify-content: center;
  min-width: 44px;
  box-sizing: border-box;
  position: relative;
}
/* ...nor shorter: the target reaches down past the status line (an invisible layer), so the line keeps its
   height and its backing doesn't cover what's under it. */
.open-controls::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: max(100%, 44px);
}

.open-controls svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
  opacity: 0.55;
}

.open-controls:hover svg,
.open-controls:focus-visible svg { opacity: 1; }

/* The status line is chrome — hidden unless the page was asked for it (?chrome=1), and shown while
   the pointer is moving, which is the operator in OBS's interact window. group.js sets both
   attributes. It floats over the right end of the heading rather than taking room beside it, so
   moving the mouse never wraps the heading or pushes the board down past the window's foot. */
/* Visible overflow, so the gear's fingertip target can hang below a heading shorter than it (a phone); the title
   cuts its own text, and the line clips only sideways. */
:root[data-chrome="0"] .head { position: relative; overflow: visible; }
:root[data-chrome="0"] .status {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding-left: 1.2rem;
  background: linear-gradient(to right, transparent, var(--bg) 1.2rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

:root[data-chrome="0"][data-pointer="active"] .status {
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .snapshot-status.pulse .snapshot-dot { animation: none; }
  .status { transition: none; }
}

/* ---- The view ---------------------------------------------------------------------------------- */

/* One grid for the whole page. The scoreboard's four columns — position, seed, name, wins — size to
   their content, and a fifth takes what is left for the game in progress, beside the players rather
   than under them. Row 1 is the round name (over the first three columns), the match's length (over
   the wins) and the top-right aside; row 2 the scoreboard's headings; rows 3 and 4 the players; row 5
   the games, across everything, with the height that is left — fitStage scales their rows down when
   a long match has more of them than the window holds.

   The name column can shrink below its content (the fifth column can't go below its minimum), which
   is when fitTogether steps the two names down; the round name spanning it stretches it to fit itself


/* The one place the page scrolls: a bracket round has more matches, and a bank more machines, than a
   short window holds, and the operator is the only one looking. */
.controls {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.controls-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

/* A completed round on the match list, folded: its heading is the summary. */
.round-group > summary {
  cursor: pointer;
  list-style: none;
}

.round-group > summary::before {
  content: "\25B8";
  display: inline-block;
  width: 1em;
}

.round-group[open] > summary::before { content: "\25BE"; }

.round-group > .match-button {
  display: grid;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.3rem;
}

.controls-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.match-list,
.played-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* The bracket the match belongs to, and its round, as a strip above the matches — only where the
   board carries more than one bracket, since on a single one the round alone says where we are. */
.match-group {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.2rem;
}

/* One match: seeds, names and the score, tall enough to hit from OBS's interact window. */
.match-button {
  font: inherit;
  font-size: 0.95rem;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.35rem 0.6rem;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 0.5rem;
  min-width: 0;
  line-height: 1.25;
}

.match-button:hover,
.match-button:focus-visible { border-color: var(--text); }

.match-button[aria-selected="true"] { border-color: var(--on-game); box-shadow: inset 0 0 0 1px var(--on-game); }

.match-button .pairing {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-button .match-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.match-button .match-state {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.8rem;
}

/* A group's games under its players: a chip per game, its number and machine — ✓ and faded once
   played, ▶ and outlined while on, plain while to come — wrapping as the width needs. */
.match-button .game-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.game-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  max-width: 100%;
  min-width: 0;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.1rem 0.4rem;
}

.game-chip-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.game-chip-machine {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.game-chip.played { color: var(--muted); border-style: dashed; }
.game-chip.now { border-color: var(--on-game); color: var(--on-game); font-weight: 600; }

/* The second list, by machine: each group's game on it, faded once played, marked while on. */
.machine-group { color: var(--text); font-weight: 700; }
.match-button.by-machine.played { color: var(--muted); }
.match-button.by-machine.played .pairing { font-weight: 500; }
.match-button.by-machine.now .match-score { color: var(--on-game); }
.match-button.by-machine .match-score { font-weight: 600; }

/* ---- Quick picks, folding sections and rounds ------------------------------------------------- */

/* The round's other groups also playing the game on now: a row of big buttons over everything else, the
   ones on it now outlined in the live colour, so the next group to show is one tap away. */
.quick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.35rem;
}

.quick-button {
  font: inherit;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.45rem 0.6rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  line-height: 1.25;
}

.quick-button:hover,
.quick-button:focus-visible { border-color: var(--text); }
/* The next group on the machine (or one already on it) outlined in the live colour; a group mid-game
   among the others marked by its live state line alone. */
.quick-button.now { border-color: var(--on-game); box-shadow: inset 0 0 0 1px var(--on-game); }
.quick-button.live .quick-state { color: var(--on-game); font-weight: 600; }

/* "Stay on Jaws" and "Or switch to another group", each a labelled row of buttons. */
.quick-block { display: flex; flex-direction: column; gap: 0.25rem; }
.quick-label {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quick-group { font-weight: 700; font-size: 1.05rem; }
.quick-state { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-button.now .quick-state { color: var(--on-game); font-weight: 600; }
.quick-machine { font-size: 0.85rem; }
.quick-players {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-players { color: var(--muted); }

/* A section's heading is its fold switch: a caret, the name, and what's set there, muted, beside it. */
.section-toggle {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0.15rem 0;
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-align: left;
  cursor: pointer;
}

.section-caret::before { content: "\25BE"; display: inline-block; width: 0.9em; }
.control.folded .section-caret::before { content: "\25B8"; }
.section-summary {
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Folded: the heading alone. */
.control.folded > :not(h2) { display: none !important; }

/* A round on the match list, as a fold: its name and how its groups stand. */
.round-summary { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.15rem 0; }
.round-summary .round-name { font-weight: 700; }
.round-summary .round-count { text-transform: none; letter-spacing: 0; }

/* "Hide completed games", over the match list, on its own line. */
.hide-completed { align-self: flex-start; }

/* The tournaments' show/hide buttons, over the match list. */
.tournament-filter { flex-wrap: wrap; }
.filter-button[aria-pressed="true"] { border-color: var(--on-game); box-shadow: inset 0 0 0 1px var(--on-game); }
.filter-button[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.field-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Every machine on one screen: as many columns as fit. */
.arena-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.3rem;
}

.arena-button,
.choice-button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.3rem 0.6rem 0.35rem;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* The name over its "game 2" marker, so a long name has the button's whole width to wrap in. */
.arena-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
}

/* The name wraps rather than truncating: the operator picking a machine needs the whole name. */
.arena-button .arena-label {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.arena-button:hover,
.arena-button:focus-visible,
.choice-button:hover,
.choice-button:focus-visible { border-color: var(--text); }

.arena-button[aria-selected="true"],
.choice-button[aria-checked="true"],
.choice-button[aria-pressed="true"] { border-color: var(--on-game); box-shadow: inset 0 0 0 1px var(--on-game); }

/* A machine already used in this match: still pickable (a rematch on a machine happens), but marked. */
.arena-button .used {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  flex: none;
}

/* The players side by side, each tinted like their row on the scoreboard — and, where the choice
   allows it, "Match Play" after them, untinted. */
.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.choice .choice-button { flex: 1 1 auto; }

.choice-button[data-side="0"] { background: var(--player-0); }
.choice-button[data-side="1"] { background: var(--player-1); }
.choice-button[data-side="2"] { background: var(--player-2); }
.choice-button[data-side="3"] { background: var(--player-3); }

.control-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Something the operator should fix before it shows on stream (a game with no machine, say): amber, set
   apart from the grey hints around it. */
.control-warning {
  margin: 0;
  padding: 0.35rem 0.6rem;
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: var(--warning);
  font-size: 0.85rem;
  font-weight: 600;
}
.control-warning[hidden] { display: none; }

/* In a game's row, right under its machine picker. */
.game-row .game-warning { display: block; margin-top: 0.3rem; }

/* The games table: one row per game — its number, machine and what Match Play has for it on a line,
   the machine grid under that, then the three choices side by side, wrapping on a narrow window. */
.games-control-list {
  display: flex;
  flex-direction: column;
}

.game-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.25rem 1.2rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}

/* The game in progress is marked on its number and its tag; the rows are otherwise alike, so the eye
   isn't asked to learn two layouts. */
.game-row.current .game-what .num,
.game-row.current .game-what .game-now {
  color: var(--on-game);
}

.game-row .game-what .game-now {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* The game on a line of its own — number, machine, what Match Play has — with the controls under it. */
.game-row .game-what {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.95rem;
  line-height: 1.25;
}

.game-row .game-what .num {
  color: var(--muted);
  font-weight: 600;
}

.game-row .game-what .game-machine {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-row .game-what .game-recorded {
  color: var(--muted);
  font-size: 0.8rem;
}

.game-row .field { flex: 0 1 auto; }

/* "Remove game", at the far end of the game's line. */
.game-row .game-what .remove-game {
  margin-left: auto;
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
}

/* "Add game", under the list, when the page brings up no next game itself. */
.games-control-foot:has(> [hidden]) { display: none; }
.games-control-foot {
  display: flex;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}

/* The machine grid takes the whole row for its width, the choices dropping under it. */
.game-row .field.wide {
  flex: 1 1 100%;
  min-width: 0;
}

/* The untinted "Match Play" / "Unknown" / "Playing" buttons, and the "Match Play" tile on a grid. */
.choice-button.fallback,
.arena-button.fallback { background: transparent; }

.game-row .choice-button {
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
}

.controls-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.3rem 0 0.5rem;
  border-top: 1px solid var(--border);
}

.pill {
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  cursor: pointer;
  flex: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.pill:hover,
.pill:focus-visible { border-color: var(--text); }

.warning {
  margin: 0.2rem 0 0;
  color: var(--warning);
  font-size: 0.85rem;
}


/* ---- Controls specific to a group ------------------------------------------------------------- */

.order-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

/* The score boxes: one per player, in the game's order, tinted like their row. */
.score-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.3rem;
}

.score-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.3rem;
  border-radius: 0.45rem;
  min-width: 0;
}

.score-field[data-side="0"] { background: var(--player-0); }
.score-field[data-side="1"] { background: var(--player-1); }
.score-field[data-side="2"] { background: var(--player-2); }
.score-field[data-side="3"] { background: var(--player-3); }

.score-field .slot-tag { color: var(--on-game); font-weight: 800; flex: none; }
.score-field .score-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score-input {
  flex: 1 1 6rem;
  min-width: 0;
  font: inherit;
  font-size: 1rem; /* 16px or more, so a phone doesn't zoom in on focus */
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.2rem 0.4rem;
}

.score-input:focus-visible { outline: none; border-color: var(--text); }

/* A fixed width for the tag, filled or not ("P1", "4th"), so tapping doesn't resize the buttons. */
.order-picker .choice-button .slot-tag {
  display: inline-block;
  width: 2.1em;
  color: var(--on-game);
  font-weight: 800;
  margin-right: 0.3em;
  text-align: left;
}

.game-row select {
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.2rem 0.4rem;
  max-width: 100%;
}

.socket-log-text {
  width: 100%;
  box-sizing: border-box;
  font: 0.75rem ui-monospace, SFMono-Regular, Menlo, monospace;
  color: inherit;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
}

/* The Sync section: the secret box and its button on one line, the status under them. */
.sync-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0;
}

.sync-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 1rem; /* 16px or more, so a phone doesn't zoom in on focus */
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.3rem 0.5rem;
}

.sync-input:focus-visible { outline: none; border-color: var(--text); }

.sync-tools {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sync-status[data-state="error"] { color: var(--warning, inherit); }

/* The preview at the foot of the controls (preview.js): the page at the OBS source's size in an iframe,
   scaled to the controls' width. The box keeps the source's shape; the frame takes no pointer, so the
   preview's own chrome never wakes. */
/* Border-box: the border inside the 100%, or the box runs 2px past the controls and gives them a sideways scrollbar. */
.preview-box {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.preview-size {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-size-input {
  width: 8em;
  font: inherit;
  font-size: 1rem; /* 16px or more, so a phone doesn't zoom in on focus */
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
}

/* The foot: "After a reload, show" beside View stream display. */
.controls-foot { align-items: center; }

.stay-here {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.stay-here input { width: 1.1rem; height: 1.1rem; margin: 0; }

.stay-here[hidden] { display: none; }

/* All boards and View stream display at the top of the controls: bigger, easier to hit on a phone or in OBS's interact window. */
.pill.pill-big {
  font-size: 1.15rem;
  padding: 0.55rem 1.2rem;
  white-space: nowrap;
}

.controls-buttons .stay-here { white-space: nowrap; }

/* "…and on the next game's machine": under the machine card's choice it depends on, greyed out while that's off. */
.card-choice-sub { margin-left: 1.6rem; }
.card-choice-sub.disabled { opacity: 0.5; }

/* Queue changes mode: an amber frame round the controls and the panel stuck to their top, so it's
   plain at a glance that changes made here aren't on stream yet. */
.controls.queuing::after {
  content: "";
  position: fixed;
  inset: 0;
  border: 4px solid var(--queue, #f5b301);
  pointer-events: none;
  z-index: 4;
}




.queue-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--queue, #f5b301);
  color: #1a1400;
  border-radius: 0 0 10px 10px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.queue-panel[hidden] { display: none; }

.queue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}

.queue-title { margin: 0; font-size: 0.95rem; }

.queue-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.queue-panel .pill {
  border-color: #1a1400;
  font-size: 1rem;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
}

.queue-panel .pill.queue-apply { background: #1a1400; color: #f5b301; }
.queue-panel .pill:disabled { opacity: 0.4; cursor: default; }

.queue-empty { margin: 0; font-size: 0.85rem; }
.queue-empty[hidden] { display: none; }

.queue-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  max-height: 30vh;
  overflow-y: auto;
}

.queue-list:empty { display: none; }
.queue-conflict { font-weight: 700; }

.pill:disabled { opacity: 0.45; cursor: default; }

.preview-queued {
  align-self: flex-start;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1400;
  background: var(--queue, #f5b301);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.preview-queued[hidden] { display: none; }

/* "After a reload, show: These settings / The stream display", under the top bar and again by the bottom View stream display. */



.reload-choice {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.reload-label { font-size: 0.9rem; }

/* At the foot, the choice keeps its label and both buttons on one line, and "View stream display" goes onto
   the line under it when there's no room beside it, rather than one of the choice's buttons wrapping alone. */
.controls-foot { flex-wrap: wrap; row-gap: 0.4rem; }
.controls-foot .reload-choice { flex-wrap: nowrap; white-space: nowrap; }

/* The reload choice reads as a setting, not as buttons that act: each option a radio mark and its words, with
   no button's frame, the chosen one's mark filled. View stream display, the one button that does something,
   is filled solid (.pill-go), and at the foot it sits apart at the right, so a streamer told "tap View
   stream display" can't take one for the other. */
.reload-choice .choice-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 500;
  background: transparent;
  border-color: transparent;
  padding-left: 0.35rem;
  padding-right: 0.45rem;
}
.reload-choice .choice-button::before {
  content: "";
  flex: none;
  width: 0.95em;
  height: 0.95em;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--muted);
}
.reload-choice .choice-button[aria-checked="true"] { border-color: transparent; box-shadow: none; font-weight: 700; }
.reload-choice .choice-button[aria-checked="true"]::before {
  border-color: var(--on-game);
  background: radial-gradient(circle, var(--on-game) 0 40%, transparent 45%);
}
.reload-choice .choice-button:hover,
.reload-choice .choice-button:focus-visible { border-color: var(--border); }
.reload-label { color: var(--muted); }

.pill.pill-go { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.pill.pill-go:hover,
.pill.pill-go:focus-visible { opacity: 0.85; }
.pill.pill-go:disabled { opacity: 0.45; }
.controls-foot .reload-choice { margin-right: auto; }

/* ---- Before the start ------------------------------------------------------------------------------ */

/* The bracket's players, machines and groups, a card at a time (renderPreStart): the card slides of the
   lower panel at the size of the board they stand in for. */
.prestart {
  flex: none;
  min-width: 0;
}

.prestart .card-head { font-size: 1rem; }
/* The machines card's line under its title ("High scores from the 8 machines in …") takes a line of its own and
   wraps, so a long qualifier's name is never cut. */
.prestart .pre-machines .card-head { flex-wrap: wrap; row-gap: 0; }
.prestart .pre-machines .card-head .other-state { flex-basis: 100%; white-space: normal; }
.prestart .card-grid { font-size: 1rem; row-gap: 0.25rem; }
.prestart .card-h { font-size: 0.7rem; }
.prestart .pre-seed-cell { color: var(--muted); font-size: 1rem; padding: 0 0.2rem; }
.prestart .card-name { background: var(--panel-bg); }

/* The first round's groups: a box per group, two across, each player under its label with their seed. */
.pre-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.8rem;
  margin-top: 0.2rem;
}

.pre-group {
  min-width: 0;
  padding: 0.3rem 0.5rem 0.4rem;
  border-radius: 0.35rem;
  background: var(--panel-bg);
}

.pre-group-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pre-group-player {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.pre-group-player .pre-seed {
  flex: none;
  min-width: 1.4em;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pre-group-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The Follow section's player picker, and the refresh row at the top of the match list. */
.follow-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.follow-player select { font: inherit; padding: 0.3rem 0.4rem; border-radius: 0.4rem; max-width: 100%; }

.refresh-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
  margin-bottom: 0.6rem;
}

.pre-start-button { display: block; margin-bottom: 0.5rem; }

/* The machines card with no qualifying high scores: two columns side by side, each its own grid with its own
   header. A long machine name wraps within its cell, so the whole name shows at the card's size. */
.pre-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.2rem;
  align-items: start;
}
.prestart .card-name.wrap {
  white-space: normal;
  /* Between words; mid-word only for a single word wider than the cell. */
  overflow-wrap: break-word;
  text-overflow: clip;
}

/* Queue changes and After a reload, each a section of its own: the queue's button big, at its own width. */
#queue-start { align-self: flex-start; justify-self: start; width: auto; }

/* Following a machine: its groups in order, each with its place ("Up now", "Next", "3rd") ahead of its players. */
.follow-lineup { margin-top: 0.6rem; }
.lineup-button { display: flex; align-items: baseline; gap: 0.6rem; }
.lineup-button .lineup-place { flex: none; min-width: 4.5em; color: var(--muted); font-weight: 700; }
.lineup-button.set .lineup-place { color: var(--on-game); }
.follow-lineup #follow-lineup-clear { margin-top: 0.3rem; }

/* Follow's machine buttons: the groups yet to play each machine, as a count after its name. */
.machine-follow .machine-count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 0.5em;
  padding: 0 0.35em;
  border-radius: 999px;
  background: var(--border);
  font-size: 0.85em;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.machine-follow .machine-count.none { opacity: 0.45; }

/* ---- All finals groups (?all=1) ------------------------------------------------------------------ */

/* Every group of the round at once, the other matches' slides laid out rather than stacked for a
   rotation: one column, or two when that fits them larger (group.js), beside the field's standings. */
.all-groups .lower { border-top: 0; margin-top: 0; padding-top: 0; }
.all-groups .others-title,
.all-groups .others-title-room { display: none; }
.all-groups .others-viewport {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}
.all-groups .other-slide { grid-area: auto; visibility: visible; }
/* Each group one shaded box, its title and rows in it, rather than a bar behind each name. */
.all-groups .other-slide { background: var(--panel-bg); border-radius: 0.5rem; padding: 0.35rem 0.6rem 0.5rem; }
.all-groups .board.mini .row[data-slot] .name { background: none; }

/* The stages (still playing, yet to start, done), each a heading over its groups in columns. Where the groups
   don't all fit, a section is held to a height (group.js) and its groups scroll inside it, the heading staying. */
.all-groups .all-section { box-sizing: border-box; flex: none; display: flex; flex-direction: column; min-height: 0; }
.all-groups .all-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(var(--all-columns, 1), minmax(0, 1fr));
  align-content: start;
  gap: 1.3rem 2.4rem;
  transition: opacity 0.5s;
}
.all-groups .all-grid.fading { opacity: 0; }
.all-groups .all-stage {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.3rem;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.all-groups .all-stage[hidden] { display: none; }
.all-groups .all-stage-count { font-weight: 600; opacity: 0.8; }
/* Those still playing: the whole section boxed in the live colour, its heading in it. */
.all-groups .all-section.playing.headed {
  padding: 0.3rem 0.45rem 0.45rem;
  border: 2px solid var(--on-game);
  border-radius: 0.5rem;
}
.all-groups .all-section.playing .all-stage { color: var(--on-game); border-bottom-color: color-mix(in srgb, var(--on-game) 45%, transparent); }
.all-groups .standings-list li.divider { display: block; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.7rem; padding-top: 0.3rem; }
.all-groups .standings-list li.note { display: block; }
.all-groups .standings-list .unit { margin-left: 0.2em; font-size: 0.85em; }
/* The standings no wider than their names and points need, so in a wide window the points stay by the
   names and the groups get the rest. */
.all-groups .lower { grid-template-columns: minmax(0, 1fr) minmax(9rem, min(26%, 17rem)); }
.all-groups .board:has(> .choice-button) { display: flex; flex-wrap: wrap; gap: 0.5rem; align-content: start; }

/* ---- Group match play qualifying: the lines (qualifying-lines.js) ------------------------------- */

.zone-bye1 { color: var(--zone-bye); --line: var(--zone-bye); }
.zone-bye2 { color: var(--zone-bye2); --line: var(--zone-bye2); }
.zone-cutA, .zone-cutF { color: var(--zone-a); --line: var(--zone-a); }
.zone-cutB { color: var(--zone-b); --line: var(--zone-b); }
.zone-cutC, .zone-cutD, .zone-cutE { color: var(--zone-c); --line: var(--zone-c); }
.zone-out { color: var(--muted); }

/* Beside the title: a line's name with where it stood at the start of the round, the round's end and qualifying's
   end (renderLineNote), the one the chips measure against in the line's colour. The note turns through every line:
   all of them stacked in one grid cell, so it keeps the widest one's width, the one shown fading in. */
.line-note {
  flex: none;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  display: inline-grid;
  line-height: 1.15;
}
.line-note[hidden] { display: none; }
.head .line-note { margin-left: auto; }
.line-note .ln-slide {
  grid-area: 1 / 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  column-gap: 0.3em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}
.line-note .ln-slide.shown { opacity: 1; visibility: visible; transition: opacity 0.8s ease, visibility 0s; }
@media (prefers-reduced-motion: reduce) { .line-note .ln-slide, .line-note .ln-slide.shown { transition: none; } }
.line-note .ln-name { margin-right: 0.15em; text-align: right; }
.line-note .ln-value { font-weight: 800; text-align: right; }
.line-note .ln-arrow { text-align: center; }
.line-note .ln-value:not([class*="zone-"]) { color: var(--text); opacity: 0.6; }
.line-note .ln-arrow { font-weight: 600; opacity: 0.7; }
.line-note .ln-label {
  font-size: 0.56em;
  font-weight: 600;
  line-height: 0.95;
  text-align: right;
  margin-left: 0.15em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Group match play qualifying: the game's line above the board, the note at its right end (placeNowLine). */
.now-row { flex: none; display: flex; align-items: baseline; gap: 1em; min-width: 0; }
.now-row .now { flex: 1 1 auto; min-width: 0; }
.now-row .line-note { flex: none; margin-left: auto; font-size: 0.95rem; }

/* With the note in the head, the status (and the gear to the controls) mustn't be squeezed to nothing behind it:
   it keeps its width and goes onto the next line instead. */
.head:has(.line-note:not([hidden])) .status { flex-shrink: 0; }

/* After the total: the player's place in the whole qualifier, in its zone's colour, and their chip. */
.board .standing {
  justify-content: flex-end;
  font-size: calc(1 * var(--u));
  font-weight: 700;
  white-space: nowrap;
}
/* Ahead of the place, once three rounds are in: the player's place over the last rounds, better higher. */
.board .trend { padding-left: 0; }
.board .standing .spark, .board .trend .spark {
  flex: none;
  width: calc(2 * var(--u));
  height: calc(0.85 * var(--u));
  margin-right: calc(0.3 * var(--u));
  overflow: visible;
  color: var(--muted);
}
/* The place is right-aligned in its cell, so the sparkline goes to the column's left edge: every row's lines up,
   however wide its place ("T-30th" or "7th"). */
.board .standing { column-gap: calc(0.3 * var(--u)); }
.board .standing .spark { margin-right: auto; }
.board .standing .spark-up, .board .trend .spark-up { color: var(--zone-a); }
.board .spark polyline { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.board .spark circle { fill: currentColor; }
.board .chip-cell { padding: calc(0.06 * var(--u)) 0; }
.board .chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 0 calc(0.45 * var(--u));
  border-radius: calc(0.3 * var(--u));
  font-size: calc(0.8 * var(--u));
  font-weight: 800;
  white-space: nowrap;
  background: var(--panel-bg);
}
.board .chip-need { background: color-mix(in srgb, var(--zone-a) 22%, transparent); color: var(--text); }
/* Holding a line ("3 pts over Bye", "On Bye"): that line's colour. Chasing it ("2 pts to Bye"): muted. */
.board .chip-up, .board .chip-line { background: color-mix(in srgb, var(--line, var(--zone-a)) 42%, transparent); color: var(--text); }
.board .chip-down { background: color-mix(in srgb, var(--muted) 14%, transparent); color: color-mix(in srgb, var(--text) 78%, var(--muted)); }
.board .chip-long { color: var(--text); }
/* Chasing: the line's name in its colour, so the chip still says which line. */
/* The chip is a flex box, so the space before the name collapses: put it back as a margin. */
.board .chip .chip-name { margin-left: 0.25em; }
.board .chip-down .chip-name { color: var(--line, var(--text)); }
.board .chip-clinched { background: var(--zone-a); color: #052e1c; }
.board .chip-out { color: var(--muted); }
/* In as it stands, with groups still to finish: the line's colour, outlined rather than filled as clinched is. */
.board .chip-likely,
.board .chip-possible { box-shadow: inset 0 0 0 2px currentColor; background: color-mix(in srgb, currentColor 12%, transparent); }
.board .possible-note { color: var(--muted); font-size: calc(0.7 * var(--u)); font-weight: 600; padding-top: 0; }

/* The standings around the line: place, name, a dot while their group plays, points; the line drawn across. */
.cut-list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  column-gap: 0.4rem;
  row-gap: 0.12rem;
  margin-top: 0.15rem;
  font-size: 0.86rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.cut-row { display: contents; }
.cut-row > span { padding: 0.05rem 0.3rem; border-radius: 0.25rem; }
.cut-pos { font-weight: 700; text-align: right; }
.cut-name { color: var(--text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cut-live { color: var(--on-game); font-size: 0.7em; align-self: center; }
.cut-pts { color: var(--text); font-weight: 800; text-align: right; background: var(--panel-bg); }
.cut-row.mine .cut-name { background: var(--panel-bg); box-shadow: inset 0 0 0 2px var(--on-game); }
.cut-line {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cut-line::before, .cut-line::after { content: ""; flex: 1; border-top: 2px dashed currentColor; }

/* Each line's projected end, with how many have clinched it and how many can still reach it. */
.line-tiles {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.4rem;
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}
.line-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.3rem 0.2rem;
  border-radius: 0.35rem;
  background: var(--panel-bg);
  border-top: 3px solid currentColor;
}
.line-tile-label { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; white-space: nowrap; }
.line-tile-end { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.line-tile-count { font-size: 0.72rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.line-tile-count.reach { color: var(--muted); }
/* Before anyone has clinched a line or fallen out of reach (group.js): the projected end alone, larger. */
.line-tiles.no-counts .line-tile { justify-content: center; padding: 0.45rem 0.2rem; }
.line-tiles.no-counts .line-tile-end { font-size: 2rem; }

/* One game a round (renderLinesBoard): the board as the mockups have it — the game's order (a final's finish once
   in), name, a qualifier's game points, total, place in the field, chip — the total its largest figure. */
/* The match on stream's packed to the left: the name bars only as long as the names need (group.js), the figures
   right beside them. */
.board.lines-board:not(.mini) { justify-content: start; }
.board.lines-board .order { justify-content: center; min-width: 2.2em; }
.board.lines-board .order.now { color: var(--on-game); }
.board.lines-board .order.won { color: var(--on-game); }
/* The figures centred under their headings, as the multi-game board's total is (the headings are centred). */
/* As large as the row lets them be without making it taller than the name's box: no line spacing or padding above
   and below. */
.board.lines-board .total { font-size: calc(1.75 * var(--u)); font-weight: 800; background: none; justify-content: center; line-height: 1; padding-block: 0; }
/* A qualifying group's game points (7/5/3/1), beside the total: the winner's lit. */
.board.lines-board .game-points { font-size: calc(1.5 * var(--u)); font-weight: 800; color: var(--muted); justify-content: center; min-width: 2.2em; line-height: 1; padding-block: 0; }
.board.lines-board .game-points.won { color: var(--on-game); }

/* The qualifying rounds control: Match Play's, this round the last, or a total typed in. */
.rounds-total { display: flex; align-items: center; gap: 0.4rem; flex: 1 1 12rem; }
.rounds-input { flex: 0 1 6rem; }
/* Beside the line note the game and machine come first; only the player order gives way. */
.now-row .now.playing .lead { max-width: none; }

/* A group's state ("Through: Mo F. & Ed N.") that doesn't fit beside its name and machine goes to the next line
   whole, cut short only if it can't fit a line of its own. Not on a card, whose line under its title gives way. */
.other-head:not(.card-head) { flex-wrap: wrap; row-gap: 0; }
.other-head:not(.card-head) .other-state { flex: 0 0 auto; max-width: 100%; }

/* Replay mode: the queue's panel and frame, in blue, while the page shows a finished tournament as it stood. */
.controls.replaying::after {
  content: "";
  position: fixed;
  inset: 0;
  border: 4px solid var(--replay, #5aa9ff);
  pointer-events: none;
  z-index: 4;
}
.replay-panel { background: var(--replay, #5aa9ff); color: #04121f; }
.replay-panel .pill { border-color: #04121f; }
.replay-panel .pill.replay-live,
.replay-panel .pill.replay-view { background: #04121f; color: #5aa9ff; }
.replay-panel .queue-empty { margin: 0; font-size: 0.85rem; }
.replay-group { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; padding: 0.15rem 0; }
.replay-group .match-button { flex: 1 1 14rem; }
.replay-step-head { display: flex; align-items: center; gap: 0.5rem; }
.replay-where { flex: 1; text-align: center; font-weight: 700; }
.replay-nav:disabled { opacity: 0.4; }
.replay-steps { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.replay-panel .pill.replay-step { background: transparent; color: #04121f; }
.replay-panel .pill.replay-step[aria-pressed="true"] { background: #04121f; color: #5aa9ff; }
.replay-group .match-button[aria-selected="true"] { border-color: var(--replay, #5aa9ff); box-shadow: inset 0 0 0 1px var(--replay, #5aa9ff); }

/* Synced: a green frame round the controls, under the queue's and the replay's (those say more about
   what a change here does), and a badge at their top naming the secret by its first word. */
.controls.synced::before {
  content: "";
  position: fixed;
  inset: 0;
  border: 4px solid var(--synced, #3ecf6e);
  pointer-events: none;
  z-index: 3;
}
.sync-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #04170b;
  background: var(--synced, #3ecf6e);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  text-decoration: none;
}
.sync-badge::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}
.sync-badge[data-state="connecting"]::before { opacity: 0.4; }
.sync-badge[data-state="error"] { background: #ff8a65; color: #1f0a04; }
.sync-badge[hidden] { display: none; }
.controls.synced[data-sync="error"]::before { border-color: #ff8a65; }

/* Sync paused in this tab: the frame grey and dashed, the badge grey with a hollow dot, so it's plain
   this tab has its own settings and isn't sending anything to the stream. */
.controls.sync-paused::before {
  content: "";
  position: fixed;
  inset: 0;
  border: 4px dashed #9aa0a6;
  pointer-events: none;
  z-index: 3;
}
.sync-badge[data-state="paused"] { background: #9aa0a6; color: #121417; }
.sync-badge[data-state="paused"]::before { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }

/* The secret box and its two buttons wrap on a phone. */
.sync-form { flex-wrap: wrap; }
.sync-form .sync-input { min-width: 12rem; }
.sync-form .pill[hidden], .sync-tools .pill[hidden] { display: none; }
