:root {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --line: #d9d6cc;
  --accent: #1d1d1b; /* UI emphasis: neutral, so the board's colours stand alone */
  --water: #9cc3d6;
  --water-deep: #5f97b6;
  --water-high: #c9e2ee;
  --shoal: #b8ab84;
  --rim: #1d1d1b;
  --ground-low: #8f9a5c;
  --ground-mid: #b49b6a;
  --ground-high: #8c8379;
  --peak: #dfe9f3;
  --ice: #f7fbfe; /* a storm's ice (engine/storms.js): white, land and water alike */
  --air: #e3ecf2;
  /* The board's marks: one colour per kind of thing. */
  /* One colour per corner, everything of that corner's in it: craft, track, ports and fire. Corners
     are dealt at random when a bout starts; your colour is your corner's. */
  --c-a: #d4582a; /* orange */
  --c-b: #6d4fd8; /* violet */
  --c-c: #0891b2; /* cyan */
  --c-d: #db2777; /* pink */
  --c-e: #dc2626; /* red */
  --c-f: #2563eb; /* blue */
  --c-g: #0d9488; /* teal */
  --c-h: #e7e5df; /* white */
  --you: var(--c-a);
  --enemy: var(--c-b);
  /* Fire whose shooter you can't tell, with three or more corners. */
  --hostile: #4b4a45;
  --move: #3f9a1a;
  --course: #c99a06;
  --open-port: #8e9399;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a;
    --panel: #1d1f24;
    --ink: #e8e6df;
    --muted: #9a988f;
    --line: #2f323a;
    --accent: #f2efe6;
    --water: #2f6585;
    --water-deep: #1d4560;
    --water-high: #5a9bc0;
    --shoal: #9a8f6c;
    --rim: #000000;
    --ground-low: #6f8446;
    --ground-mid: #9e875a;
    --ground-high: #8c867d;
    --peak: #c9d8e6;
    --ice: #e9eff5;
    --air: #2a3036;
    --c-a: #f08a4b;
    --c-b: #a78bfa;
    --c-c: #22e1ff;
    --c-d: #ff6ec7;
    --c-e: #ff4d4d;
    --c-f: #4d7cff;
    --c-g: #19d3a2;
    --c-h: #f7f7f7;
    --hostile: #d9d6cc;
    --move: #8cff3d;
    --course: #ffe14d;
    --open-port: #b8bcc2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

h1 { margin: 0; font-size: 18px; letter-spacing: 0.04em; }
header .menu { font-size: 18px; line-height: 1; padding: 4px 10px; margin-right: -12px; }
header .menu.on { border-color: var(--accent); }

input, select, button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

/* The page fits the window and the board fills it; everything else floats over the board. */
main { flex: 1; min-height: 0; display: flex; }
#arena { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#map { position: absolute; inset: 0; }
#map canvas { display: block; position: absolute; inset: 0; }

/* Floating surfaces share one look: a translucent card that keeps the board legible behind it. */
.card, .turnbar, .view-controls, .drawer, #shot, #confirm, #dealt, #forfeit, #out, #outcome {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
}
.card { position: absolute; border-radius: 12px; padding: 12px 14px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.14); font-size: 13px; }
.card h2, .card h3 { margin: 0; font-size: 13px; font-weight: 600; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head .meta { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Whose turn, and the conditions: centred at the top, the first thing the eye meets. */
.turnbar { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 2px;
  padding: 8px 18px; border-radius: 12px; pointer-events: none; text-align: center; max-width: calc(100% - 640px); min-width: 220px; }
.turnbar strong { font-size: 15px; }
.turnbar span { color: var(--muted); font-size: 12px; }

/* You. */
.hud { top: 16px; left: 16px; width: 264px; display: grid; gap: 12px; }
.bars { display: grid; grid-template-columns: 56px 1fr 40px; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 12px; }
.bars output { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
/* The bars are neutral: no game colour on them. */
meter { width: 100%; height: 8px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 4px; border: 0; }
meter::-webkit-meter-bar { background: var(--line); border-radius: 4px; border: 0; height: 8px; }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { background: var(--ink); border-radius: 4px; }
meter::-moz-meter-bar { background: var(--ink); border-radius: 4px; }
.ammo { display: flex; flex-wrap: wrap; gap: 6px; }
.ammo span { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.ammo span.empty { opacity: 0.45; }
.shield-state { margin: 0; font-size: 12px; color: var(--ink); }
.turn { display: flex; gap: 8px; align-items: center; }
.turn #hold { flex: 1; padding: 7px 10px; }
/* The fuse: a bar along End turn's foot that runs down to the next timed step. */
.fuse { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--course); }
.fuse.burning { animation: fuse linear forwards; }
@keyframes fuse { from { width: 100%; } to { width: 0; } }

/* Settings: a section per group of parameters, a row per parameter. */
.settings { display: grid; gap: 10px; font-size: 12px; }
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0; display: grid; gap: 4px; min-inline-size: 0; min-width: 0; }
/* A fieldset is as wide as the drawer, never its widest child's: a wide table scrolls in its own box. */
.settings fieldset > * { min-width: 0; }
.settings fieldset fieldset { border-style: dashed; }
.settings legend { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; padding: 0 4px; }
.setting { display: grid; grid-template-columns: 1fr 112px; gap: 8px; align-items: center; }
.setting input { width: 100%; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.setting input[type=checkbox] { width: auto; justify-self: start; }
.setting input[readonly] { color: var(--muted); background: none; }
.admin-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.user-table.templates td { white-space: normal; overflow-wrap: anywhere; }
.user-table.templates td:first-child { width: 100%; }
.user-table.templates td:last-child { white-space: nowrap; }
.user-table.templates .admin-actions { gap: 4px; }
#tab-organizer fieldset { min-width: 0; }
.template-seat { justify-content: flex-start; min-width: 0; }
.template-seat > span { min-width: 1.5em; color: var(--muted); }
.template-seat input[type=number] { width: 4.5em; flex: none; }
.template-seat input[type=text] { flex: 1; min-width: 0; }
.settings textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.setting.changed span::after { content: ' •'; color: var(--course); }
.settings .actions { justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; padding: 8px 0; background: var(--panel); }
.settings p { margin: 0; }
.settings-part { display: grid; gap: 10px; }
.settings h3 { margin: 8px 0 0; font-size: 13px; letter-spacing: 0.02em; }
.settings details.rules { border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.settings details.rules[open] { padding-bottom: 8px; display: grid; gap: 4px; }
.settings details.rules > summary { cursor: pointer; padding: 8px 0; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.settings details.rules > summary .count { color: var(--course); font-weight: 400; font-size: 11px; }
.setting[title]:not([title=""]) > span { text-decoration: underline dotted; text-decoration-color: var(--muted); text-underline-offset: 3px; cursor: help; }
.hint { color: var(--muted); margin: 0; font-size: 12px; line-height: 1.45; }
.hint:empty { display: none; }

.view-controls { position: absolute; top: 16px; right: 16px; display: flex; gap: 4px; padding: 4px; border-radius: 10px; }
.view-controls button { border-color: transparent; background: none; min-width: 32px; }
.view-controls button:hover { border-color: var(--line); }
.view-controls button.on { border-color: #ff3b3b; }

/* Intel: a label, the answer, and a detail line, row by row. The answer takes the colour of
   whose it is. */
.intel { top: 64px; right: 16px; width: 264px; display: grid; gap: 10px; }
.row { display: grid; gap: 1px; padding-left: 10px; border-left: 3px solid var(--line); }
.row .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.row .value { font-weight: 600; white-space: pre-line; }
.row .sub { font-size: 12px; color: var(--muted); white-space: pre-line; }
.row.enemy { border-color: var(--enemy); } .row.enemy .value { color: var(--enemy); }
.row.you { border-color: var(--you); } .row.you .value { color: var(--you); }

.key { font-size: 12px; color: var(--muted); }
.key summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.key[open] { display: grid; gap: 4px; }
.key span { display: flex; gap: 8px; align-items: center; }
.key i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.key i.ring { background: none; border: 2px solid; width: 8px; height: 8px; }

/* Since your last turn: short sentences, each marked by whose it is. */
.feed { right: 16px; bottom: 16px; width: 320px; max-height: 40%; overflow: auto; display: grid; gap: 8px; }
.feed h3 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.feed ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.feed li { padding-left: 10px; border-left: 3px solid var(--line); line-height: 1.4; }
.feed li.enemy { border-color: var(--enemy); }
.feed li.you { border-color: var(--you); }
.feed li.quiet { color: var(--muted); }

/* The result: centred, over everything. */

/* The drawer slides in over the board's left edge, under the menu button, and out again; the board
   never resizes. */
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(420px, 100%);
  display: flex; flex-direction: column;
  border-width: 0 1px 0 0; border-radius: 0;
  transform: translateX(-100%); transition: transform 0.22s ease;
  box-shadow: 8px 0 28px rgb(0 0 0 / 0.18);
  z-index: 2;
}
.drawer.open { transform: none; }
/* The tabs fit one line at the drawer's width; past that (Debug mode's tab, a narrow screen) they wrap
   onto a second, and the close button keeps to the end of its line rather than being pushed out. */
.drawer nav { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.drawer nav button { flex: 1; border: 0; border-radius: 0; padding: 10px 2px; font-size: 13px; background: none; color: var(--muted); }
.drawer nav button.on { color: var(--ink); box-shadow: inset 0 -2px var(--accent); }
.drawer nav .close { flex: 0 0 44px; margin-left: auto; }
.tab { display: none; padding: 12px 16px; overflow: auto; margin: 0; flex: 1; min-height: 0; }
.tab.on { display: block; }
.help { font: 13px/1.55 system-ui, sans-serif; }
.help h3 { margin: 0 0 10px; font-size: 15px; }
.help p { margin: 0 0 10px; }
.help code { font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
.help pre { margin: 0 0 4px; white-space: pre-wrap; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0 0 12px; }
.help dt { font-weight: 600; }
.help dd { margin: 0; }
.help dl.calls { grid-template-columns: 1fr; gap: 2px; }
.help dl.calls dd { margin: 0 0 8px; color: var(--muted); }
.help details > summary { cursor: pointer; font-weight: 600; margin: 4px 0 8px; }

[hidden] { display: none !important; }
.actions { display: flex; gap: 6px; }

/* The debug panel: over the board's right edge, monospace, in the page's own colours. Nothing of
   it is drawn while it's hidden. */
.debug {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(580px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 28px rgb(0 0 0 / 0.18);
  z-index: 3;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.debug header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: none; }
.debug header strong { font-size: 13px; }
.debug header .close { margin-left: auto; }
.debug button, .debug select, .debug input { font: inherit; padding: 2px 8px; }
.debug-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.debug-filters label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.debug-filters input { width: 64px; }
.debug-lines { flex: 1 1 40%; min-height: 120px; overflow: auto; margin: 0; padding: 4px 0; list-style: none; }
.debug-lines li { padding: 1px 12px 1px 9px; border-left: 3px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.debug-lines li.refused summary { color: #c0392b; }
.debug-lines li.over summary, .debug-lines li.bout summary { font-weight: 600; }
.debug-lines li.view summary, .debug-lines li.preview summary { color: var(--muted); }
.debug-lines summary { cursor: pointer; list-style: none; }
.debug-lines summary::-webkit-details-marker { display: none; }
.debug-lines pre { margin: 2px 0 6px; padding: 6px 8px; background: var(--bg); border-radius: 6px; font-size: 11px; max-height: 260px; overflow: auto; }
.debug .sect { border-top: 1px solid var(--line); }
.debug .sect summary { padding: 5px 12px; cursor: pointer; color: var(--muted); }
.debug .sect pre { margin: 0; padding: 0 12px 8px; max-height: 220px; overflow: auto; }
.debug-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
.debug-replay label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.debug-replay select { max-width: 280px; }

/* The confirmations sit over the board's lower corner, so what they confirm stays in view. */
#shot, #confirm { position: absolute; left: 16px; bottom: 56px; margin: 0; width: min(380px, calc(100% - 32px)); padding: 14px 16px; color: var(--ink); border-radius: 10px; box-shadow: 0 8px 28px rgb(0 0 0 / 0.25); z-index: 1; }
#shot h2, #confirm h2, #dealt h2, #forfeit h2, #out h2 { margin: 0 0 2px; font-size: 15px; }
#shot .boon { display: inline-block; padding: 1px 7px; border: 1px solid var(--course); border-radius: 999px; color: var(--course); font-size: 11px; font-variant-numeric: tabular-nums; }
#shot .boon[hidden] { display: none; }
#shot p, #confirm p, #dealt p, #forfeit p, #out p { margin: 6px 0; }
/* A bout dealt while the lobby is up, or a forfeit: asked in the middle of the window, the page dimmed and softened behind it. */
#dealt, #forfeit, #out { width: min(380px, calc(100% - 32px)); padding: 14px 16px; color: var(--ink); border-radius: 10px; box-shadow: 0 8px 28px rgb(0 0 0 / 0.25); }
#dealt::backdrop, #forfeit::backdrop, .veil { background: rgb(0 0 0 / 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
/* Your corner out and the bout going on: the veil over the board and everything on it but the
   header, the menu's drawer and the lobby when asked for; the card over the veil, in the middle. */
.veil { position: absolute; inset: 0; z-index: 7; }
#out { position: absolute; inset: 0; margin: auto; height: fit-content; z-index: 8; }
body.veiled .drawer, body.veiled.lobby-open .splash { z-index: 9; }
body.veiled .turnbar, body.veiled .hud, body.veiled .intel, body.veiled .feed, body.veiled .view-controls, body.veiled .waiting, body.veiled .tv { visibility: hidden; }
body.veiled.lobby-open .splash, body.veiled.lobby-open .splash .tv-lobby { visibility: visible; }
body.veiled.lobby-open #out { display: none; }
.muted { color: var(--muted); }
.warn { color: var(--ink); font-weight: 600; }
.warn:empty { display: none; }
.shot-ammo { display: grid; gap: 6px; border: 0; padding: 0; margin: 10px 0; }
.shot-ammo label { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: baseline; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.shot-ammo label:has(input:checked) { border-color: var(--accent); }
.shot-ammo label:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.shot-ammo input { margin: 0; }
.shot-ammo small { grid-column: 2; color: var(--muted); }
.shot-angle { display: grid; grid-template-columns: auto 1fr 32px; gap: 8px; align-items: center; color: var(--muted); }
#shot .actions, #confirm .actions, #dealt .actions, #forfeit .actions, #out .actions { justify-content: flex-end; margin-top: 10px; }
button.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }

button:disabled { opacity: 0.45; cursor: not-allowed; }
pre { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }

/* Narrower: the turn bar moves to the bottom centre and the feed gives way to the board; on a phone
   the cards stack and intel gives way too. A dialog open over the board hides the turn bar. */
@media (max-width: 900px) {
  .turnbar { top: auto; bottom: 16px; max-width: calc(100% - 32px); }
  .feed { display: none; }
}
#arena:has(dialog[open]) .turnbar { visibility: hidden; }
@media (max-width: 640px) {
  .hud { left: 12px; right: 12px; width: auto; top: 60px; }
  .intel { display: none; }
  .view-controls { top: 8px; right: 12px; }
  #shot, #confirm { left: 12px; right: 12px; width: auto; bottom: 48px; }
}

/* The broadcast. Everything else on the board steps aside; the TV graphics take over. */
body.broadcast .hud, body.broadcast .intel, body.broadcast .feed, body.broadcast .turnbar, body.broadcast .view-controls { display: none; }
.tv { position: absolute; inset: 0; pointer-events: none; font-family: Anton, Impact, 'Arial Narrow Bold', sans-serif; text-transform: uppercase; color: #fff; }
/* The corners: a column of plates in each top corner of the screen and the turn in the middle,
   the sky between them left open for the action. */
.tv-score { position: absolute; top: 14px; left: 16px; right: 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; }
.tv-side, .tv-mid { background: linear-gradient(180deg, #16171c, #0b0b0e); border: 2px solid #2b2d35; border-radius: 6px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.5); overflow: hidden; }
.tv-side { display: grid; gap: 4px; padding: 8px 14px; min-width: 0; width: min(360px, 100%); border-left: 8px solid var(--tv-side); }
/* A column of plates each side of the turn; the right one mirrors the left. */
.tv-col { display: grid; gap: 6px; min-width: 0; }
.tv-col.left { justify-items: start; }
.tv-col.right { justify-items: end; }
.tv-col.right .tv-side { border-left: 0; border-right: 8px solid var(--tv-side); text-align: right; }
.tv-side.out { opacity: 0.4; }
/* Whose turn it is: a pill in the plate's top corner, the far end from the name's start, top right
   on the left's plates and top left on the right's mirrored ones; the name keeps clear of it. */
.tv-side { position: relative; }
.tv-pending { position: absolute; top: 6px; right: 6px; font-family: system-ui, sans-serif; font-style: normal; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; line-height: 1;
  color: #fff; background: #ff3b3b; padding: 3px 6px; border-radius: 2px; }
.tv-side:not(.pending) .tv-pending { display: none; }
/* The name's first line stops short of it; a plate too narrow for both puts the name under it. */
.tv-side.pending strong::before { content: ''; float: right; width: 64px; height: 12px; }
.tv-col.right .tv-pending { right: auto; left: 6px; }
.tv-col.right .tv-side.pending strong::before { float: left; }
.tv-side strong { font-size: 22px; letter-spacing: 0.03em; line-height: 1; }
.tv-side span { font-family: system-ui, sans-serif; font-size: 11px; color: #b9bac2; letter-spacing: 0.04em; }
/* The bar is stacked: a segment per piece, each its own colour, wide as its health leaves it. */
.tv-bar { display: flex; height: 10px; background: #2b2d35; border-radius: 2px; overflow: hidden; }
.tv-bar i { display: block; height: 100%; transition: width 0.6s ease; background: var(--tv-side); }
.tv-bar i + i { border-left: 1px solid #0b0b0e; }
/* Each segment says what it is on hover; the piece a player commands is lit, edged in white. */
.tv-bar:not(.tv-stamina) i { pointer-events: auto; }
.tv-bar i.on { box-shadow: inset 0 0 0 2px #fff; filter: brightness(1.15); }
.tv-bar.tv-stamina { height: 4px; }
.tv-side span b { font-weight: 600; }
.tv-col.right .tv-bar { transform: scaleX(-1); }
/* Three corners or more: the turn, then a plate each in a row, on one plate. */
.tv-score.many .tv-side { padding: 6px 12px; }
.tv-score.many .tv-side strong { font-size: 17px; }
.tv-score.many .tv-side span { font-size: 10px; }
.tv-mid { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 6px 16px; background: #000; min-width: 120px; }
.tv-mid strong { font-size: 24px; line-height: 1; }
.tv-mid #tv-cond { font-family: system-ui, sans-serif; font-size: 10px; color: #b9bac2; }
/* The broadcast's corner arrows, under the turn: the one thing on the plates that takes a click. */
.tv-nav { display: flex; gap: 6px; margin-top: 4px; }
.tv-nav button { pointer-events: auto; cursor: pointer; font-family: Anton, Impact, 'Arial Narrow Bold', sans-serif; font-size: 13px; line-height: 1; color: #fff;
  padding: 3px 14px; background: linear-gradient(180deg, #16171c, #0b0b0e); border: 1px solid #2b2d35; border-radius: 4px; }
.tv-nav button:hover { border-color: #ff3b3b; }
.tv-nav button:focus-visible { outline: 2px solid #ff3b3b; outline-offset: 1px; }
.tv-corner { pointer-events: auto; width: 20px; height: 22px; align-self: center; }
.tv-corner polygon { fill: var(--tv-cell); stroke: #2b2d35; stroke-width: 0.1; }
.tv-corner path { display: none; fill: none; stroke: currentColor; stroke-width: 0.2; stroke-linecap: round; }
.tv-corner.announcer path { display: inline; }
.tv-live { font-family: system-ui, sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: #ff3b3b; }

/* The call: a port claimed, slammed in at the top under the tale of the tape, small enough that
   the action is never behind it, and gone again. */
.tv-callout { position: absolute; top: 150px; left: 0; right: 0; text-align: center; font-size: clamp(22px, 3.2vw, 44px); line-height: 1; letter-spacing: 0.03em;
  -webkit-text-stroke: 1.5px #000; paint-order: stroke fill; text-shadow: 0 3px 0 #000, 0 0 18px rgb(0 0 0 / 0.5); opacity: 0; }
.tv-callout.go { animation: slam 1.5s cubic-bezier(.2,.9,.3,1.3) forwards; }
@keyframes slam {
  0% { opacity: 0; transform: scale(1.8) rotate(-6deg); }
  14% { opacity: 1; transform: scale(0.94) rotate(-3deg); }
  20% { transform: scale(1.04) rotate(-3deg) translateX(-6px); }
  26% { transform: scale(1) rotate(-3deg) translateX(6px); }
  32% { transform: scale(1) rotate(-3deg); }
  80% { opacity: 1; transform: scale(1.02) rotate(-3deg); }
  100% { opacity: 0; transform: scale(1.1) rotate(-3deg); }
}

/* The play by play: one line along the bottom, the latest thing that happened. */
.tv-ticker { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: #0b0b0e; border-top: 3px solid #ff3b3b; }
.tv-ticker .tv-live { color: #fff; background: #ff3b3b; padding: 2px 8px; border-radius: 2px; flex: none; }
/* A call is read whole: a long one runs onto a second line. */
#tv-ticker { font-family: system-ui, sans-serif; font-size: 14px; line-height: 1.3; text-transform: none; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
#tv-ticker b { font-family: Anton, Impact, sans-serif; font-weight: 400; letter-spacing: 0.03em; }
.tv-voice { margin-left: auto; flex: none; display: flex; align-items: center; gap: 8px; cursor: default; pointer-events: auto; }
.tv-voice[hidden] { display: none; }
.tv-voice button { font-size: 16px; line-height: 1; padding: 2px 6px; background: none; border: 1px solid #ffffff40; border-radius: 3px; cursor: pointer; }
.tv-voice button[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.tv-voice input { width: 90px; accent-color: #ff3b3b; cursor: pointer; }

/* The lower third: a nameplate sliding in from the left. */
.tv-lower { position: absolute; left: 28px; bottom: 74px; display: grid; gap: 2px; padding: 10px 22px 12px 16px; min-width: 300px; max-width: calc(100% - 56px);
  background: linear-gradient(90deg, #0b0b0e 70%, rgb(11 11 14 / 0.6)); border-left: 10px solid var(--tv-side, #ff3b3b); transform: translateX(-120%); transition: transform 0.45s cubic-bezier(.2,.9,.3,1.1); }
.tv-lower.in { transform: none; }
.tv-tag { font-family: system-ui, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; color: var(--tv-side, #ff3b3b); }
.tv-lower strong { font-size: 38px; line-height: 1; }
.tv-lower span:last-child { font-family: system-ui, sans-serif; font-size: 13px; color: #c9cad2; text-transform: none; }

/* The play by play. */
/* Whose eyes the camera is: small, bottom left, over the ticker. */
.tv-cam { position: absolute; bottom: 60px; left: 16px; padding: 2px 6px; background: rgb(11 11 14 / 0.7); border-left: 3px solid var(--tv-side, #ff3b3b); font-family: system-ui, sans-serif;
  font-size: 9px; font-weight: 600; letter-spacing: 0.1em; color: #c9cad2; }
.tv-cam:empty { display: none; }

/* The arena's side pickers carry their corner's colour. */
.corner { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.corner.a { background: var(--you); }
.corner.b { background: var(--enemy); }

/* The lobby: a table with a row per corner, empty rows waiting for contestants. */
.tv-lobby { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100% - 32px)); pointer-events: auto; z-index: 1;
  background: rgb(11 11 14 / 0.94); border: 2px solid #2b2d35; border-top: 4px solid #ff3b3b; border-radius: 6px; box-shadow: 0 16px 40px rgb(0 0 0 / 0.5); }
.tv-lobby header { display: grid; gap: 2px; padding: 14px 18px 10px; border-bottom: 1px solid #2b2d35; }
.tv-lobby header strong { font-size: 30px; line-height: 1; }
.tv-lobby header span:last-child { font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
/* The roster's columns hold still whatever the rows hold: the name takes what the rest leave. */
.tv-lobby table { width: 100%; table-layout: fixed; border-collapse: collapse; font-family: system-ui, sans-serif; text-transform: none; }
.tv-lobby th.num, .tv-lobby td.num { width: 2.2em; }
.tv-lobby th.plays, .tv-lobby td.plays { width: 118px; }
.tv-lobby th.status, .tv-lobby td.status { width: 128px; }
/* What plays a row fills its column, a long model's name cut short, never spilling into Status. */
.tv-lobby td.plays select { width: 100%; min-width: 0; box-sizing: border-box; text-overflow: ellipsis; }
/* Parameters: a gear at the end of a model row's picker; the popout opens by it. */
.tv-lobby button.parameters { padding: 0 4px; font-size: 15px; line-height: 1.4; color: #8b8c94; background: none; border-color: transparent; }
.tv-lobby button.parameters:hover { color: #fff; border-color: #34363f; }
.tv-lobby td.plays .picker { display: flex; align-items: center; gap: 4px; }
.tv-lobby td.plays .picker select { flex: 1; }
/* The next slot, open under the roster: pick what plays it and it's added. */
.tv-lobby tr.new td { border-top-style: dashed; }
#parameters { position: fixed; margin: 0; padding: 0; width: min(440px, calc(100vw - 32px)); color: #fff; background: rgb(11 11 14 / 0.98); border: 1px solid #34363f; border-radius: 6px; font-family: system-ui, sans-serif; text-transform: none; }
#parameters::backdrop { background: transparent; }
#parameters form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px; max-height: calc(100vh - 56px); overflow: auto; }
#parameters label { display: grid; gap: 3px; font-size: 12px; color: #b9bac2; }
#parameters label[hidden] { display: none; }
#parameters label.wide { grid-column: 1 / -1; }
#parameters input, #parameters select, #parameters textarea, #parameters button { font: 13px system-ui, sans-serif; color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; padding: 4px 8px; box-sizing: border-box; width: 100%; }
#parameters textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: 12px; }
#parameters button { grid-column: 2; justify-self: end; width: auto; }
@media (max-width: 560px) {
  .tv-lobby th, .tv-lobby td { padding-left: 8px; padding-right: 8px; }
  .tv-lobby th.plays, .tv-lobby td.plays { width: 96px; }
  .tv-lobby th.status, .tv-lobby td.status { width: 96px; }
}
.tv-lobby td.status { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tv-lobby td.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-lobby td.who input.name { max-width: none; }
.tv-lobby th { text-align: left; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: #8b8c94; padding: 8px 18px 6px; font-weight: 600; }
.tv-lobby td { padding: 12px 18px; border-top: 1px solid #22242b; font-size: 14px; }
.tv-lobby tr.a td.side { border-left: 6px solid var(--you); color: var(--you); }
.tv-lobby tr.b td.side { border-left: 6px solid var(--enemy); color: var(--enemy); }
.tv-lobby td.side { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.tv-lobby td.who { font-family: Anton, Impact, sans-serif; font-size: 16px; text-transform: uppercase; letter-spacing: 0.02em; }
.tv-lobby tr.open td.who { font-family: system-ui, sans-serif; font-size: 14px; font-style: italic; color: #6c6d75; text-transform: none; }
.tv-lobby td.status { color: #7fd07f; font-weight: 600; }
.tv-lobby tr.open td.status { color: #ffb347; }
.tv-lobby footer { padding: 10px 18px 14px; border-top: 1px solid #2b2d35; font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
.tv-lobby code { color: #fff; background: #1d1f25; padding: 1px 5px; border-radius: 3px; }
/* The lobby's controls: dark fields on the dark card, the pickers in the rows. */
.tv-lobby label { display: flex; gap: 6px; align-items: center; font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
.tv-lobby input, .tv-lobby select, .tv-lobby button { font-family: system-ui, sans-serif; font-size: 13px; text-transform: none; color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; padding: 4px 8px; }
.tv-lobby button.primary { background: #ff3b3b; border-color: #ff3b3b; color: #fff; font-weight: 700; }
.tv-lobby input[type=checkbox] { padding: 0; accent-color: #ff3b3b; }
.lobby-settings { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.tv-lobby footer { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
#lobby-note { flex: 1; min-width: 200px; }
.tv-lobby tr.open td.status { color: #ffb347; }
/* On the right: the replays, and the lobby during a bout; the bouts in progress, when they're shown,
   take the room before them. What's shown is the page's to say (paintControls, lobby.js). */
#masthead[hidden] { display: none; }
#menu-reel, #lobby-toggle { margin-left: auto; }
#menu-reel:not([hidden]) + #lobby-toggle { margin-left: 0; }
header .lobby-toggle.on { border-color: var(--accent); }
/* Signed out, the sign-in alone: none of the header's controls, nor the lobby. */
body[data-user="out"] :is(#panel, #live-bouts, #menu-reel, #lobby-toggle, #setup) { display: none; }
/* The bouts in progress, between who you are and the replays: small and muted, each a way to watch it. */
header .live-bouts { flex: 1 1 180px; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
header .live-bouts[hidden] { display: none; }
header .live-bouts button { display: inline-flex; gap: 0.6em; max-width: 100%; white-space: nowrap; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; }
header .live-bouts button:hover:not(:disabled) { color: var(--ink); text-decoration: underline; }
header .live-bouts span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
header .live-bouts span:last-child { flex: none; font-variant-numeric: tabular-nums; }
/* A seat thinking: its name and the clock, under the tale of the tape. */
.tv-thinking { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); padding: 5px 14px; background: #0b0b0e; border-bottom: 3px solid var(--tv-side, #ff3b3b);
  font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; color: #fff; text-transform: none; font-variant-numeric: tabular-nums; }
.tv-lobby a.join, .tv-lobby button.join { color: #fff; background: #ff3b3b; border-color: #ff3b3b; padding: 4px 12px; border-radius: 4px; text-decoration: none; font-weight: 700; cursor: pointer; }
.tv-lobby button.join.suggested { animation: beckon 1.4s ease-in-out infinite; }
@keyframes beckon { 0%, 100% { box-shadow: 0 0 0 0 rgb(255 59 59 / 0.7); } 50% { box-shadow: 0 0 0 8px rgb(255 59 59 / 0); transform: scale(1.06); } }
/* The player page: the lobby sits over the board until you've joined. */
header .muted { font-size: 13px; }
/* A seat in a bout another page referees: the arena's own controls aren't its to use. */
body[data-role="seat"] #start,
body[data-role="seat"] #rematch, body[data-role="seat"] #share-open, body[data-role="seat"] #share-row, body[data-role="seat"] #outcome-versus,
body[data-role="seat"] .drawer nav [data-tab=log], body[data-role="seat"] .drawer nav [data-tab=help] { display: none; }
/* Challenges: the score to beat, and sharing yours. */
.challenge { margin: 0; padding: 6px 8px; border-left: 3px solid var(--course); font-size: 12px; }
.versus { font-weight: 600; }
.share { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.share label { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.share input { font-size: 12px; }
#share-link { flex: 1 1 100%; }
#share-note { font-size: 12px; }

/* The broadcast's frames: a slate between bouts, fading in and out over the board; from one frame to
   the next only the card crossfades, the slate staying up. */
.tv-frame { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; background: #0b0b0e; opacity: 0; transition: opacity 0.6s ease; pointer-events: none; }
.tv-frame[hidden] { display: none; }
.tv-frame.in { opacity: 1; pointer-events: auto; }
.tv-frame-card { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 0 16px; max-width: min(900px, calc(100% - 32px)); transition: opacity 0.6s ease; }
.tv-frame-card.out { opacity: 0; }
.tv-frame-card .tv-tag { font-size: 13px; }
.tv-frame-card strong { font-family: Anton, Impact, sans-serif; font-size: clamp(32px, 7vw, 72px); line-height: 1.05; color: #fff; text-transform: uppercase; font-weight: 400; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.tv-frame-card strong span.name { display: block; font-family: inherit; font-size: 1em; color: inherit; }
.tv-frame-card strong span.vs { display: block; font-family: system-ui, sans-serif; font-size: 0.3em; text-transform: none; letter-spacing: 0.1em; color: #b9bac2; margin: 0.15em 0; }
.tv-frame-card span:not(.tv-tag) { font-family: system-ui, sans-serif; font-size: 16px; color: #c9cad2; }
.tv-frame-card img { max-width: min(480px, 80vw); max-height: 40vh; margin-top: 12px; }

/* The local page's front door. A brief loading mark while the client starts, then the lobby over
   the world, which turns slowly behind it. Play hides it all and shows the game's panels. */
.loading { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 10px; background: var(--bg); color: var(--muted);
  transition: opacity 0.4s ease; }
.loading strong { font-family: Anton, Impact, sans-serif; font-size: 34px; letter-spacing: 0.04em; color: var(--ink); text-transform: uppercase; font-weight: 400; }
.loading.done { opacity: 0; pointer-events: none; }
/* The loading mark: a hexagon that beats and turns from your colour to the enemy's inside a ring
   that spins. Only transform and opacity move, which the browser animates off the main thread, so
   it keeps going while a bout is being built. */
.loader { position: relative; display: grid; place-items: center; width: 78px; height: 78px; }
.loader::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgb(255 255 255 / 0.08);
  border-top-color: var(--you); border-right-color: var(--enemy); animation: spin 0.9s linear infinite; will-change: transform; }
.hexmark { position: relative; width: 44px; height: 50px; background: var(--you); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  animation: beat 1.2s ease-in-out infinite; will-change: transform; }
.hexmark::after { content: ''; position: absolute; inset: 0; background: var(--enemy); opacity: 0; animation: shade 1.2s ease-in-out infinite; will-change: opacity; }
.loading > span:last-child { animation: breathe 1.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes beat { 50% { transform: scale(0.72); } }
@keyframes shade { 50% { opacity: 1; } }
@keyframes breathe { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .loader::before, .hexmark, .hexmark::after, .loading > span:last-child, .waiting .spinner { animation-duration: 3s; } }
/* Between your turns: a small card centre screen, in the colour of the corner you're waiting on, up
   for the whole wait and fading in and out. Only its button takes a click: the board under it
   stays yours. */
.waiting { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px;
  background: #0b0b0e; border-bottom: 3px solid var(--tv-side, #ff3b3b); border-radius: 6px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  font: 700 13px system-ui, sans-serif; letter-spacing: 0.02em; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap;
  pointer-events: none; visibility: hidden; opacity: 0; transition: opacity 0.2s ease, visibility 0s 0.2s; }
.waiting.in { visibility: visible; opacity: 1; transition: opacity 0.2s ease; }
.waiting .spinner { width: 14px; height: 14px; border-radius: 50%; border: 3px solid rgb(255 255 255 / 0.12); border-top-color: var(--tv-side, #ff3b3b); animation: spin 0.9s linear infinite; will-change: transform; }
.waiting button { pointer-events: auto; font: 13px system-ui, sans-serif; color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; padding: 3px 8px; }
.waiting button:hover { border-color: #ff3b3b; }
.waiting button[hidden] { display: none; }
/* On your turn, the same card is the turnstile's: it says what it does next, and a click anywhere on
   it pauses the walk. */
.waiting.churn { pointer-events: auto; cursor: pointer; }
.waiting.churn:hover { border-bottom-color: #fff; }
/* The page's notice: a dark plate at the bottom, over the ticker's edge, above the programme's
   frames and the countdown but not the loading mark; it takes no clicks, so the board under it
   stays yours. */
.notice { position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 28; box-sizing: border-box; max-width: min(560px, calc(100% - 32px)); width: max-content;
  padding: 7px 12px; background: rgb(11 11 14 / 0.9); border: 1px solid #2b2d35; border-left: 4px solid #ff3b3b; border-radius: 6px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
  font: 13px/1.4 system-ui, sans-serif; color: #fff; pointer-events: none; visibility: hidden; opacity: 0; transition: opacity 0.2s ease, visibility 0s 0.2s; }
.notice.in { visibility: visible; opacity: 1; transition: opacity 0.2s ease; }
body.playing .notice { bottom: 16px; }
.splash { display: none; }
body.in-lobby .splash, body.lobby-open .splash { display: block; }
body.in-lobby .hud, body.in-lobby .intel, body.in-lobby .feed, body.in-lobby .turnbar, body.in-lobby .view-controls, body.in-lobby #tv { display: none; }
/* The programme's frames cover the lobby, but for one left open over the broadcast before it. */
body.programme.lobby-asked .splash { z-index: 26; }
/* The lobby card's parts (paintCard, lobby.js): the pickers sit in the row with the card's buttons. */
.lobby-pickers { display: contents; }
.lobby-lineup { display: grid; gap: 2px; margin-top: 8px; }
.lobby-lineup #lineup-names { font-family: Anton, Impact, sans-serif; font-size: 16px; text-transform: uppercase; letter-spacing: 0.02em; color: #fff; }
.lobby-lineup #lineup-sub { font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
.tv-lobby .lobby-settings button.link { padding: 0; border: 0; background: none; color: #b9bac2; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tv-lobby .lobby-settings button.link:hover { color: #fff; }
.lobby-sub { font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
.tv-lobby .challenge { margin: 0; padding: 10px 18px; border-left: 0; border-top: 1px solid #2b2d35; color: var(--course); font-family: system-ui, sans-serif; text-transform: none; }
/* Settings: undo a changed value, reset a section, reset everything. */
.setting { grid-template-columns: 1fr 112px 24px; }
.setting .undo { padding: 0 4px; font-size: 12px; line-height: 1.4; }
.settings.choosing .setting { grid-template-columns: 16px 1fr 112px 24px; }
.settings.choosing .setting > .show { order: -1; }
.settings.choosing legend .show, .settings.choosing summary .show { margin: 0 6px 0 0; }
.setting.kept-back > :not(.show) { opacity: 0.45; }
.settings .section-reset { justify-self: end; font-size: 11px; padding: 2px 8px; margin-top: 4px; }

/* The player's panels wear the broadcast's look: dark plates, the corner's colour down the edge,
   Anton for the headlines and the red for what to press. The settings drawer stays a plain menu. */
.card, .turnbar, .view-controls, #shot, #confirm, #dealt, #forfeit, #out, #outcome {
  background: rgb(11 11 14 / 0.9); border: 2px solid #2b2d35; border-radius: 6px; color: #fff; box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  --ink: #f2f2f4; --muted: #b9bac2; --line: #34363f; --panel: #0b0b0e; --accent: #ff3b3b; color-scheme: dark; }
.hud { border-left: 8px solid var(--you); }
.turnbar { border-top: 3px solid #ff3b3b; }
.turnbar strong, .card-head h2, #shot h2 { font-family: Anton, Impact, 'Arial Narrow Bold', sans-serif; font-weight: 400; text-transform: uppercase; letter-spacing: 0.03em; }
.turnbar strong { font-size: 20px; line-height: 1.1; }
.card-head h2 { font-size: 18px; line-height: 1; }
#shot h2 { font-size: 28px; line-height: 1; }
.feed h3, .row .label, .key summary { font-weight: 700; letter-spacing: 0.14em; color: #8b8c94; }
.card button, #shot button, #confirm button, #dealt button, #forfeit button, #out button, #outcome button, .view-controls button { color: #fff; background: #1d1f25; border-color: #34363f; }
.card button:hover, #shot button:hover, #outcome button:hover { border-color: #8b8c94; }
.card button.primary, #shot button.primary, #confirm button.primary, #dealt button.primary, #forfeit button.primary, #out button.primary, #outcome button.primary { background: #ff3b3b; border-color: #ff3b3b; color: #fff; font-weight: 700; }
.view-controls button.primary { background: #ff3b3b; border: 1px solid #000; color: #fff; font-weight: 700; }
/* End turn, when no piece waits for orders: it beckons. The turnstile's fuse burns along its foot. */
.view-controls #hold.due { animation: beckon 1.4s ease-in-out infinite; }
.view-controls #hold { position: relative; overflow: hidden; }
/* The piece's name, dimmed once it has acted this turn. */
.view-controls .piece-name { flex: 1; min-width: 64px; display: flex; align-items: center; justify-content: center; font-family: Anton, Impact, 'Arial Narrow Bold', sans-serif; font-size: 15px; text-transform: uppercase; letter-spacing: 0.03em; }
.view-controls .piece-name.acted { opacity: 0.55; }
/* Under the piece row, a thin bar for each outpost your corner holds, filled with its charge in your
   colour (--fill, its share), the rest dim. */
.view-controls .charges { flex-basis: 100%; display: flex; flex-direction: column; gap: 2px; }
.view-controls .charges i { display: block; height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--you) var(--fill, 0%), rgb(255 255 255 / 0.12) var(--fill, 0%)); }
/* Under them, the envelope at its own width, then Cancel orders and Shield sharing the rest equally,
   the envelope's place kept while it's hidden. */
.view-controls .controls-row { flex-basis: 100%; display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px; }
.view-controls .controls-row button { min-width: 0; padding: 4px 6px; font-size: 13px; white-space: nowrap; }
.view-controls .controls-row #objective { min-width: 32px; }
.view-controls .controls-row #course-clear { grid-column: 2; }
/* With a mech or drones outpost held, its readout takes a fourth share of the row: a button's size,
   not a button. */
.view-controls .controls-row:has(#deploy:not([hidden])) { grid-template-columns: auto 1fr 1fr 1fr; }
.view-controls #deploy { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 4px 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cfd3dc; border: 1px solid var(--line); border-radius: 6px; cursor: default; }
.view-controls #deploy[hidden] { display: none; }
/* Shield: powered, a blue fill breathing slowly, ready to arm; armed for its piece's next order, a
   green edge under it; up, lit green until your next turn; greyed when it can't go up. */
.view-controls #shield.powered { color: #fff; background: #2f6fdc; border-color: #4f8cf0; animation: shield-breath 2s ease-in-out infinite; }
.view-controls #shield.powered:hover { border-color: #cfe0ff; }
.view-controls #shield.armed { color: #7fd07f; box-shadow: inset 0 -3px #7fd07f; }
.view-controls #shield.up { color: #0b0b0e; background: #7fd07f; border-color: #7fd07f; box-shadow: 0 0 12px rgb(127 208 127 / 0.55); }
.view-controls #shield.up:disabled { opacity: 1; cursor: default; }
@keyframes shield-breath { 0%, 100% { background: #1d3f7a; box-shadow: 0 0 0 0 rgb(79 140 240 / 0); } 50% { background: #2f6fdc; box-shadow: 0 0 14px 2px rgb(79 140 240 / 0.6); } }
@media (prefers-reduced-motion: reduce) { .view-controls #shield.powered { animation-duration: 4s; } }
.card input, .card select, #shot input, #outcome input, .view-controls select { color: #fff; background: #1d1f25; border-color: #34363f; }

/* The lobby's table: room for eight corners, scrolling past that. A corner waiting for you shows
   your handle, faded until you join. */
.tv-lobby .rows { max-height: min(392px, 52vh); overflow-y: auto; }
.tv-lobby .rows thead th { position: sticky; top: 0; background: #0b0b0e; z-index: 1; }
.tv-lobby td { padding: 9px 18px; }
.tv-lobby tr.pending td.who { color: #8b8c94; }
.tv-lobby tr.pending td.status { color: inherit; }

/* The roster: a row per contestant, numbered; no corners until the bout starts. */
.tv-lobby td.num { color: #8b8c94; font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-lobby button.remove { margin-left: auto; padding: 0 6px; background: none; border-color: transparent; color: #8b8c94; }
.tv-lobby button.remove:hover { border-color: #34363f; color: #fff; }
.tv-lobby tr.mine td.who { color: #fff; }
.tv-lobby tr.mine td.status { color: #7fd07f; }
.tv-lobby button.leave { margin-left: 6px; padding: 1px 8px; font-size: 11px; }
.tv-lobby tr.gone td.status { color: #ffb347; }
.tv-lobby tr.gone td.who { color: #8b8c94; }
/* The settings row holds the lobby's widgets: the pickers, + Contestant, and the Start or End at
   its right end. The footer holds a note, when there is one, and the way to Replays. */
.lobby-settings { align-items: center; }
.lobby-settings input[type=number] { width: 56px; }
#start { margin-left: auto; }
.tv-lobby footer button.link { margin-left: auto; padding: 0; border: 0; background: none; color: #b9bac2; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tv-lobby footer button.link:hover { color: #fff; }

/* The countdown: 3, 2, 1 over everything, then black until the bout is ready, then the board. */
.countdown { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: auto; background: rgb(0 0 0 / 0.35); transition: background 0.35s ease, opacity 0.7s ease; }
.countdown[hidden] { display: none; }
.countdown strong { font-family: Anton, Impact, sans-serif; font-weight: 400; font-size: clamp(90px, 22vw, 240px); color: #fff; -webkit-text-stroke: 3px #000; paint-order: stroke fill; text-shadow: 0 8px 0 #000; }
.countdown.black { background: #000; }
.countdown.fade { opacity: 0; }
.tv-lobby footer a { color: #fff; }

/* The drawer: a solid dark panel in the same look as the other panels, so nothing behind it shows
   through. */
.drawer { background: #0b0b0e; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: #2b2d35; color: #f2f2f4;
  --ink: #f2f2f4; --muted: #8b8c94; --line: #2b2d35; --panel: #0b0b0e; --accent: #ff3b3b; color-scheme: dark; }
.drawer nav button { font-weight: 600; }
.drawer nav button.on { color: #fff; box-shadow: inset 0 -2px #ff3b3b; }
.drawer .tab input, .drawer .tab select { color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; }
.drawer .tab input[readonly] { color: #8b8c94; background: none; border-color: transparent; }
.drawer .tab button { color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; }
.drawer .tab button:hover { border-color: #8b8c94; }
.drawer .tab button.primary { background: #ff3b3b; border-color: #ff3b3b; font-weight: 700; }
.drawer .settings fieldset { border-color: #2b2d35; }
.drawer .settings legend { color: #8b8c94; font-weight: 700; letter-spacing: 0.12em; }
.drawer .settings details.rules { border-color: #2b2d35; }
.drawer .settings .actions { background: #0b0b0e; }
/* An open row's name: a text box, its hint the name you'd join under. */
.tv-lobby td.who input.name { width: 100%; max-width: 220px; font-size: 14px; }
.tv-lobby td.who .hint { font-family: system-ui, sans-serif; font-size: 14px; font-style: normal; color: #6c6d75; text-transform: none; }

/* Replays: the playlist, in the broadcast's look; and the reel playing, the board and the broadcast
   graphics alone, nothing else on the screen, not even the pointer. */
.reel-pick { width: min(680px, calc(100% - 32px)); max-height: calc(100% - 64px); padding: 0; display: none; flex-direction: column; color: #fff;
  background: rgb(11 11 14 / 0.96); border: 2px solid #2b2d35; border-top: 4px solid #ff3b3b; border-radius: 6px; box-shadow: 0 16px 40px rgb(0 0 0 / 0.5); }
.reel-pick[open] { display: flex; }
.reel-pick::backdrop { background: rgb(0 0 0 / 0.45); }
.reel-pick header { display: grid; gap: 2px; padding: 14px 18px 10px; border-bottom: 1px solid #2b2d35; font-family: Anton, Impact, sans-serif; text-transform: uppercase; }
.reel-pick header strong { font-size: 30px; line-height: 1; font-weight: 400; }
.reel-pick header span:last-child { font-family: system-ui, sans-serif; font-size: 12px; color: #b9bac2; text-transform: none; }
.reel-pick ol { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.reel-pick li { display: grid; grid-template-columns: 2.2em 6.5em 1fr auto auto; gap: 12px; align-items: baseline; padding: 10px 18px; border-top: 1px solid #22242b; cursor: pointer; font-size: 13px; }
.reel-pick li:first-child { border-top: 0; }
.reel-pick li:hover { background: #16171c; }
.reel-pick li .n { font-family: Anton, Impact, sans-serif; font-size: 18px; color: #ff3b3b; text-align: center; }
.reel-pick li:not(.on) .n { color: #4a4c55; }
.reel-pick li .when { color: #8b8c94; font-variant-numeric: tabular-nums; }
.reel-pick li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-pick li .how { color: #b9bac2; text-align: right; }
.reel-pick li.gone { cursor: default; color: #6c6d75; }
.reel-pick li.gone:hover { background: none; }
.reel-pick li.empty { display: block; cursor: default; color: #8b8c94; }
.reel-pick footer { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 18px 14px; border-top: 1px solid #2b2d35; font-size: 12px; color: #b9bac2; }
.reel-pick footer #reel-note { flex: 1; min-width: 12em; }
.reel-pick button { color: #fff; background: #1d1f25; border: 1px solid #34363f; border-radius: 4px; padding: 5px 12px; }
.reel-pick button.del { padding: 2px 8px; font-size: 11px; color: #b9bac2; }
.reel-pick .pending { padding: 2px 8px; font-size: 11px; color: #ff3b3b; border: 1px solid #ff3b3b; border-radius: 4px; }
.reel-pick button.del.armed { color: #fff; background: #ff3b3b; border-color: #ff3b3b; }
.reel-pick button.primary { background: #ff3b3b; border-color: #ff3b3b; font-weight: 700; }
body.reel { cursor: none; }
/* The show in a window has the header to leave it by, the pointer over it; the menu has no drawer to open. */
body.reel #masthead { cursor: auto; }
body.reel #panel { display: none; }
body.reel .drawer, body.reel .debug, body.reel .splash, body.reel .loading { display: none !important; }

/* Playing: your own view in the broadcast's frame. The scoreboard across the top, and End turn and
   your pieces in the controls under it; the cards and the ticker step aside, the board shows it. */
body.playing .intel, body.playing .feed, body.playing .turnbar, body.playing .tv-cam, body.playing .tv-callout, body.playing .tv-lower, body.playing .tv-thinking, body.playing .tv-ticker { display: none; }
/* The piece's controls under the turn, as wide as it: player.js puts them there. A refusal takes a
   line of its own under them. */
body.playing .tv-mid { min-width: 236px; }
body.playing .view-controls { top: 104px; left: 50%; right: auto; transform: translateX(-50%); box-sizing: border-box; flex-wrap: wrap; align-items: stretch; }
.view-controls .objective { flex-basis: 100%; padding: 4px 6px; max-width: 320px; max-height: 40vh; overflow-y: auto; font-size: 13px; line-height: 1.4; }
.view-controls .objective p { margin: 0 0 6px; white-space: pre-wrap; }
.view-controls .objective p.muted { margin: 0; font-size: 11px; }
.view-controls #objective { position: relative; }
.view-controls #objective.unread::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: #ff3b3b; }
.view-controls .offers { display: grid; gap: 4px; }
.view-controls .offers[hidden] { display: none; }
.view-controls .offer-pick { display: flex; gap: 4px; }
.view-controls .offer-pick select { flex: 1; min-width: 0; }
#offers-in > span, #offers-pacts > span { display: block; }
#offer-turns { width: 4em; }
.view-controls .whammy { display: grid; gap: 4px; }
.view-controls .whammy[hidden] { display: none; }
/* The slot: one reel window, its symbols spinning past on a pull and landing on the whammy pulled. */
.whammy-slot { font: 700 15px/1.6 ui-monospace, monospace; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.whammy-slot.spinning { filter: blur(0.6px); }
.whammy-slot.landed { border-color: #ff3b3b; }
.out-chip .offer-pick { display: flex; gap: 4px; }
.out-chip .offer-pick select { flex: 1; min-width: 0; }
.out-chip[hidden] { display: none; }
@media (max-width: 640px) {
  body.playing .view-controls { top: 196px; width: calc(100% - 24px); }
  /* The turn on top, the two plates side by side under it. */
  body.playing .tv-score { grid-template-columns: 1fr 1fr; gap: 6px; }
  body.playing .tv-score .tv-mid { grid-column: 1 / -1; order: -1; }
  body.playing .tv-score .tv-col { justify-items: stretch; }
  body.playing .tv-score .tv-side { width: auto; }
}
/* The key, at the top of Help. */
.key.legend { display: grid; gap: 6px; margin-bottom: 16px; }
.key.legend h3 { margin: 0 0 4px; }
/* The windsock's corner of the board: view3d draws the sock into it. */
.windsock { position: absolute; right: 16px; bottom: 16px; width: 112px; height: 112px; pointer-events: none; }
@media (max-width: 640px) { .windsock { right: 8px; bottom: 8px; width: 72px; height: 72px; } }

/* Signed out: the sign-in card in the lobby's place, over the world. */
.signin { width: min(380px, calc(100% - 32px)); }
.signin-fields { display: grid; gap: 10px; padding: 14px 18px; }
.signin-fields label { display: grid; grid-template-columns: 6em 1fr; }
.signin footer { display: flex; gap: 8px; align-items: center; }
.signin footer span { flex: 1; }
/* The User tab's tables: seat keys and bouts. */
.user-table { overflow-x: auto; }
.user-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.user-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 2px 6px 4px 0; }
.user-table td { padding: 3px 6px 3px 0; border-top: 1px solid var(--line); white-space: nowrap; }
.user-token { grid-template-columns: 1fr auto; }
/* The Admin tab's users: the name takes what the drawer has left, cut short where it runs over. */
.user-table.users td:nth-child(2) { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-table.users td:nth-child(n+5), .user-table.users th:nth-child(n+5) { text-align: right; }
.user-table.users th:first-child, .user-table.users td:first-child { width: 1px; }
.user-table.users input { margin: 0; vertical-align: middle; }
/* The Admin tab's bouts: the line-up takes what's left and is cut short, the bout's id cut short in a
   narrow column (the whole id on hover), the turn and the state at the right. */
.user-table.bouts th:first-child, .user-table.bouts td:first-child { width: 1px; }
.user-table.bouts td:nth-child(2) span { display: block; max-width: 8em; overflow: hidden; text-overflow: ellipsis; }
.user-table.bouts td:nth-child(3) { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-table.bouts td:nth-child(n+4), .user-table.bouts th:nth-child(n+4) { text-align: right; }
.user-table.bouts input { margin: 0; vertical-align: middle; }
.admin-actions .pages { flex: 1; }
/* The leaderboard: the name takes what's left and is cut short, the counts sit right; a heading is a
   button that sorts by it, the sorted one marked by a small arrow. */
.leaderboard { display: grid; gap: 8px; }
.user-table.board td:nth-child(2) { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-table.board td:nth-child(n+3), .user-table.board th:nth-child(n+3) { text-align: right; }
.user-table.board td:first-child { color: var(--muted); }
.user-table th button.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; white-space: nowrap; }
.user-table th button.sort:hover { color: var(--ink); }
.user-table th button.sort.down::after { content: ' \25BE'; }
.user-table th button.sort.up::after { content: ' \25B4'; }
.user-token input { font-family: ui-monospace, monospace; }

/* Your result: a plate in the bottom right corner, your corner's colour down its edge, the board seen
   through it; it never covers the board. */
#outcome.out-card { position: absolute; right: 16px; bottom: 60px; z-index: 6; width: min(300px, calc(100% - 32px)); box-sizing: border-box; display: grid; gap: 8px; padding: 10px 14px 12px;
  background: rgb(11 11 14 / 0.72); border-left: 8px solid var(--out-side, #8b8c94); font-size: 13px; }
#outcome[hidden] { display: none; }
.out-card p { margin: 0; }
.out-line span { color: var(--muted); }
/* Three numbers in a row, four two by two. */
.out-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; margin: 0; }
.out-stats.four { grid-template-columns: repeat(2, 1fr); }
.out-stats div { display: grid; gap: 1px; }
.out-stats dt { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; white-space: nowrap; text-transform: uppercase; color: #8b8c94; }
.out-stats dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.out-card .actions { justify-content: flex-end; }
.out-card .actions button { white-space: nowrap; }
.out-card .share { margin-top: 0; padding-top: 8px; }
/* Playing, the ticker is gone: the card sits lower. */
body.playing #outcome { bottom: 16px; }
@media (max-width: 640px) { #outcome.out-card { right: 12px; } #outcome.out-card { width: calc(100% - 24px); } }
