/* The Tally WEGO web table. The site is black and white (the brand sheet): ink, muted and paper, light or dark. Colour
   belongs to the game: the board, the side colours where they point at a side, and the kit's heat and AP. The board's
   colours come from the player's board theme (BoardThemes on the server); app.js sets --side-a, --side-b and --board-bg
   from it. Phone first: board on top, panel below; side by side on wide screens. */
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --paper: #fff;
  --ink: #111;
  --muted: #555;
  --faint: #8a8a86;
  --line: #dcdcd8;
  --panel: #fff;
  --panel-raised: #f4f4f2;
  --side-a: #1f6fd1;
  --side-b: #d1341f;
  --board-bg: #0b1020;
  --radius: 10px;
  color-scheme: light;
}

/* Dark: the system's choice unless the player picked light, or the player's own choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e0e0e;
    --ink: #f4f4f2;
    --muted: #a7a7a3;
    --faint: #6b6b68;
    --line: #2b2b29;
    --panel: #0e0e0e;
    --panel-raised: #181817;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e0e0e;
  --ink: #f4f4f2;
  --muted: #a7a7a3;
  --faint: #6b6b68;
  --line: #2b2b29;
  --panel: #0e0e0e;
  --panel-raised: #181817;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--paper); color: var(--ink); }

body {
  font: 15px/1.45 "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--ink); text-underline-offset: 2px; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

/* The lockup at header size: the mark 26 px high and the cap height about 0.64 of it; the delta alone when narrow. */
.brand { display: flex; align-items: center; gap: 5px; color: var(--ink); text-decoration: none; line-height: 1; min-width: 0; }
.brand svg { display: block; flex: none; }
.brand .mark { width: 78px; height: 26px; }
.brand .delta { display: none; width: 20px; height: 20px; }
.brand .word { display: flex; align-items: baseline; gap: 6px; font-size: 23px; text-transform: uppercase; white-space: nowrap; }
.brand .tally { font-weight: 700; letter-spacing: -0.02em; }
.brand .wego { font-weight: 500; letter-spacing: 0.06em; }
.brand .tm { font-size: 0.42em; font-weight: 500; letter-spacing: 0; position: relative; top: -0.3em; margin-left: 1px; }
@media (max-width: 520px) {
  .brand .mark { display: none; }
  .brand .delta { display: block; }
  .brand .word { font-size: 19px; gap: 5px; }
}

/* The menu bar (docs/PLAN-SITE.md): the menu and the lockup on the left, where you are in the middle, who you are on
   the right. The same bar is on the platform page. */
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.where { font-size: 14px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { justify-self: end; }
.nav { position: relative; }
.nav > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); }
.nav > summary::-webkit-details-marker { display: none; }
.nav[open] > summary, .nav > summary:hover { border-color: var(--ink); }
.burger, .burger::before, .burger::after { display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 1px; content: ""; position: relative; }
.burger::before { position: absolute; top: -5px; }
.burger::after { position: absolute; top: 5px; }
.nav .menu { position: absolute; left: 0; top: calc(100% + 8px); width: 220px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius); z-index: 6; }
.nav .menu a { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav .menu a:hover, .nav .menu a.current { background: var(--panel-raised); }
.nav .menu a.current { font-weight: 700; }
.nav .menu-head { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--line); margin-top: 4px; }
.nav .menu a[data-section] { padding-left: 18px; }
/* On a phone the delta stands for the platform; the player's name gives way too. */
@media (max-width: 480px) {
  .brand .word { display: none; }
  .who .name { display: none; }
  .where { font-size: 12px; }
}
.intro { padding: 6px 0 2px; }
.intro p { margin: 0; max-width: 70ch; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stat { background: var(--panel-raised); border-radius: 8px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.who .button { white-space: nowrap; }

.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-width: 0; }
.who .name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }

/* The display menu: the site light or dark, and the board's theme. */
.display { position: relative; }
.display > summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 6px 2px; user-select: none; }
.display > summary::-webkit-details-marker { display: none; }
.display[open] > summary, .display > summary:hover { color: var(--ink); }
.display .menu { position: absolute; right: 0; top: calc(100% + 8px); width: 230px; display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius); z-index: 6; }
.display .menu select { width: 100%; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }

h1, h2, h3 { text-wrap: balance; margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

button, .button, select {
  font: inherit;
  color: var(--ink);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  min-height: 42px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
}
button:hover:not(:disabled), .button:hover { border-color: var(--ink); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.primary, .button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
button.seal { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; letter-spacing: 0.04em; }
button.danger { background: transparent; border: 1.5px dashed var(--ink); }
button.piece { min-width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; }
button.selected { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
button.ghost { background: transparent; }
button.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 18px, calc(100% - 10px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.row > label.field { flex: 1 1 150px; }
label.field select { width: 100%; }
label.field input[type=text] { width: 100%; box-sizing: border-box; font: inherit; font-size: 15px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
select { max-width: 100%; text-overflow: ellipsis; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; border: 1px solid var(--line); color: var(--muted); }
.pill.yours { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* The board keeps its own dark field in both site themes. */
.board { position: relative; background: var(--board-bg); overflow: hidden; }
.board svg { display: block; width: 100%; height: auto; }
.board.tappable { cursor: crosshair; outline: 2px dashed var(--accent, var(--ink)); outline-offset: 2px; }

.working { margin: 0; padding: 8px 10px; list-style: none; background: var(--panel-raised); border-radius: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.working li + li { margin-top: 2px; }
.total { font-weight: 700; }
.warn { color: var(--ink); font-weight: 600; }
.error { color: var(--ink); font-weight: 700; }
.situation { margin: 0; padding-left: 18px; font-size: 13px; }
.help { font-size: 14px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.help ul { margin: 6px 0; padding-left: 18px; }
.help p { margin: 6px 0; }
.small-print { font-size: 12px; color: var(--faint); }

.feed { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.feed .entry { padding: 6px 8px; background: var(--panel); border-radius: 6px; border-left: 3px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.feed .entry .turn { color: var(--faint); font-size: 11px; margin-right: 6px; }
.feed .entry.said { border-left-color: var(--ink); background: var(--panel-raised); }
.say input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 13px; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.say input:focus { outline: none; border-color: var(--muted); }
.notices { display: flex; align-items: center; gap: 6px; }
.account summary { cursor: pointer; }
.list.lessons > li { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-raised); border: 1px solid var(--line); }
.lesson .step { font-size: 1.05em; }
.row.spread { justify-content: space-between; }
.account input { flex: 1 1 200px; min-width: 0; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list a { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 8px; background: var(--panel-raised); color: var(--ink); text-decoration: none; border: 1px solid var(--line); }
.list a:hover { border-color: var(--muted); }

.hero { padding: 28px 4px 8px; }
.hero p { max-width: 62ch; color: var(--muted); }
.copy { display: flex; gap: 6px; }
.copy input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--panel-raised);
  border: 1px solid var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 60;
}

/* Nothing may push the page wider than the screen. */
.grid > *, .stack > * { min-width: 0; }
.list a > span:first-child { min-width: 0; }

/* Several ships a side (RULES-0.08a): a tab per ship, the move order as chips, and each ship's meters in the strip. */
.tabs > button { flex: 0 0 auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.chip button.small { padding: 2px 6px; min-width: 0; }
.ship-label { min-width: 2.5em; font-weight: 700; align-self: center; }

/* ---- The kit on the table (RULES-0.09a §5): paper cards and cockpit plates in the printed kit's own colours (docs/brand/BRAND.md). ---- */
:root {
  --card-paper: #fff;
  --card-ink: #111;
  --card-rule: #ccc;
  --heat: #c8502b;
  --ap: #2b6cc8;
  --card-ink-muted: #555;
}

/* The card viewer: the three cards, one at a time, scaled to the column (fitKit). */
.kit .tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.kit-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kit-stage { position: relative; width: 100%; overflow: hidden; }
.kit-stage .kcard { position: absolute; top: 0; left: 0; transform-origin: top left; }

/* The cards themselves: docs/cards/cards.css at its natural 2.5 × 3.5 in (240 × 336 px). */
.kcard {
  width: 240px; height: 336px;
  background: var(--card-paper); color: var(--card-ink);
  border: 1.5px solid var(--card-ink); border-radius: 10px;
  padding: 8px 9px; display: flex; flex-direction: column;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font: 8.5px/1.25 "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden; text-align: left;
}
.kcard header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid var(--card-ink); padding-bottom: 4px; margin-bottom: 6px; }
.kcard h2 { margin: 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 800; display: flex; align-items: center; gap: 6px; color: var(--card-ink); line-height: 1.2; }
.kcard .kind { font-size: 7px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--card-ink-muted); }
.kcard .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 5px; margin-bottom: 5px; }
.kcard .stat { background: var(--card-paper); color: var(--card-ink); border: 1px solid var(--card-rule); border-radius: 5px; padding: 3px 5px 2px; }
.kcard .stat .lbl { font-size: 6.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--card-ink-muted); }
.kcard .stat .val { font-size: 16px; font-weight: 800; line-height: 1; margin-top: 1px; }
.kcard .stat .val small { font-size: 8px; font-weight: 600; color: var(--card-ink-muted); margin-left: 2px; }
.kcard .stat.heat .val { color: var(--heat); }
.kcard .stat.ap .val { color: var(--ap); }
.kcard .track { display: flex; gap: 2px; margin-top: 2px; }
.kcard .track i { flex: 1; height: 5px; border: 1px solid var(--card-ink); border-radius: 1px; display: block; }
.kcard .track.heat i { border-color: var(--heat); }
.kcard .track.heat i.burn { background: var(--heat); }
.kcard .weapon { border: 1.5px solid var(--card-ink); border-radius: 6px; padding: 4px 5px 3px; margin-top: auto; margin-bottom: 8px; }
.kcard .weapon .title { display: flex; justify-content: space-between; white-space: nowrap; font-weight: 800; font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.kcard .weapon .title span:last-child { font-weight: 600; color: var(--card-ink-muted); font-size: 7px; letter-spacing: 0.03em; text-transform: none; }
.kcard .weapon .line { display: flex; justify-content: space-between; margin-top: 3px; color: var(--card-ink-muted); }
.kcard .weapon .line b { color: var(--card-ink); }
.kcard table { border-collapse: collapse; width: 100%; }
.kcard .bands { margin-top: 4px; }
.kcard .bands th, .kcard .bands td { text-align: center; padding: 1.5px 0; border-top: 1px solid var(--card-rule); }
.kcard .bands th { font-size: 6.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--card-ink-muted); font-weight: 600; border-top: none; }
.kcard .bands td:first-child { font-weight: 800; }
.kcard .crit { color: var(--heat); font-weight: 700; }
.kcard .kgrid th, .kcard .kgrid td { padding: 3px 2px; text-align: center; border-bottom: 1px solid var(--card-rule); }
.kcard .kgrid th { font-size: 6.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--card-ink-muted); font-weight: 600; border-bottom: 1.5px solid var(--card-ink); }
.kcard .kgrid th.l, .kcard .kgrid td.l { text-align: left; }
.kcard .kgrid td:first-child { text-align: left; font-weight: 800; white-space: nowrap; }
.kcard .kgrid td:first-child small { font-weight: 500; color: var(--card-ink-muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.kcard .kgrid td:first-child .note { font-weight: 500; color: var(--card-ink-muted); }
.kcard .kgrid .heat { color: var(--heat); font-weight: 700; }
.kcard .kgrid .ap { color: var(--ap); font-weight: 700; }
.kcard .kgrid .sep th { padding-top: 6px; border-bottom: 1.5px solid var(--card-ink); }
.kcard .kgrid .zero { color: var(--card-ink-muted); font-weight: 500; }
.kcard .notes { margin-top: auto; border-top: 1.5px solid var(--card-ink); padding-top: 4px; }
.kcard .notes p { margin: 0 0 2px; color: var(--card-ink-muted); }
.kcard .notes b, .kcard .notes strong { color: var(--card-ink); }
.kcard .legend { display: flex; justify-content: space-between; margin-top: 4px; font-size: 6.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.kcard .legend .h { color: var(--heat); }
.kcard .legend .a { color: var(--ap); }
.kcard .foot { margin-top: 3px; text-align: right; font-size: 6px; color: var(--card-ink-muted); letter-spacing: 0.1em; }

/* Notes to the designer: one a round, one at the end. */
.note-card textarea { width: 100%; min-height: 72px; resize: vertical; font: inherit; color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; box-sizing: border-box; }
.note-card textarea:focus { outline: none; border-color: var(--muted); }
.note-card .row select { flex: 0 1 140px; }
.note-card > button.ghost { width: 100%; text-align: left; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li { padding: 10px 12px; border-radius: 8px; background: var(--panel-raised); border: 1px solid var(--line); min-width: 0; }
.note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; overflow-wrap: anywhere; }
.note-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* The lobby's games, the codes, the ratings and the turn clock. */
.card.you { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list.games > li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 8px; background: var(--panel-raised); border: 1px solid var(--line); }
.list.games > li.stack { display: flex; flex-direction: column; align-items: stretch; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 18px; letter-spacing: 0.08em; color: var(--ink); }
.pill.code { font-family: ui-monospace, Consolas, monospace; color: var(--ink); }
.pill.clock { color: var(--ink); font-variant-numeric: tabular-nums; }
.pill.clock.low { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.gain { color: var(--ink); font-weight: 600; }
.loss { color: var(--muted); }
table.ratings { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.ratings th, table.ratings td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.ratings th { color: var(--muted); font-weight: 600; font-size: 13px; }
table.ratings tr.mine td { font-weight: 700; }
.note-card textarea.note-text-box { min-height: 52px; }

/* ---- The table (Matthew's layout, 2026-10-26): a status bar across the top, the rosters, the board and the orders in a
   16:9 frame on a landscape screen; stacked on a phone. The site stays black and white; the accent marks your move and
   the ship being ordered, the kit's colours mark heat and AP, and the side colours come from the board theme. ---- */
:root {
  --accent: #f5b942;
  --accent-ink: #1a1300;
  --accent-text: #8a5a00;
  --ok: #2f7d4a;
  --edge: #d1341f;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent-text: #f5b942; --ok: #7ed59a; --edge: #ff5a5a; }
}
:root[data-theme="dark"] { --accent-text: #f5b942; --ok: #7ed59a; --edge: #ff5a5a; }

body.at-table { padding-bottom: 0; }
body.at-table .top { display: none; }
body.at-table main { max-width: none; padding: 0; }

.table .label { font: 700 11px/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.table .label.accent { color: var(--accent-text); }
.table .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table .spacer { flex: 1 1 auto; }
.table .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.table .dot.side-a { background: var(--side-a); }
.table .dot.side-b { background: var(--side-b); }

/* The frame: 16:9, letterboxed on a wider screen rather than stretched. */
.table.wide {
  --gap: 12px;
  --side: clamp(300px, 22.7vw, 436px);
  height: 100vh; height: 100dvh;
  max-width: calc(100dvh * 16 / 9);
  margin: 0 auto;
  display: grid; grid-template-rows: 52px minmax(0, 1fr); gap: var(--gap); padding: var(--gap);
}
.table-body { display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--side); gap: var(--gap); min-height: 0; }

/* The status bar. */
.status { display: flex; align-items: center; gap: 14px; padding: 0 14px; min-width: 0; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 10px; }
.status .names { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.status .vs { color: var(--muted); font-weight: 500; }
.status .tag { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
.status .tag.mono { font-weight: 700; font-size: 13px; }
.turn-cluster { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); white-space: nowrap; }
.turn-cluster .big { font-size: 18px; font-weight: 700; }
.turn-cluster .divider { width: 1px; height: 20px; background: var(--line); }
.turn-cluster button.small { min-height: 30px; font-family: var(--mono); font-weight: 700; }
.phase { font: 700 12px/1 var(--mono); letter-spacing: 0.1em; color: var(--faint); }
.phase.now { color: var(--accent-text); }
.move { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); font: 700 13px/1 var(--mono); letter-spacing: 0.08em; white-space: nowrap; color: var(--muted); }
.move.yours { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.clock.low { text-decoration: underline; text-underline-offset: 3px; }
button.icon { position: relative; min-height: 36px; width: 36px; padding: 0; font-size: 16px; flex: none; }
.badge { position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 11px/18px var(--mono); }

/* The rosters: their flight above, yours below. */
.rosters { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); min-height: 0; }
.roster { display: flex; flex-direction: column; gap: 8px; padding: 14px; min-height: 0; overflow: auto; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 10px; }
.roster.pointed { outline: 2px solid var(--accent); outline-offset: 2px; }
.roster-head { display: flex; align-items: center; gap: 8px; }
.tcard { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.tcard.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tcard.dead .meters { opacity: 0.4; }
.tcard-head { display: flex; align-items: center; gap: 10px; font-size: 16px; min-width: 0; }
.tcard-head svg { flex: none; }
.status-chip, .chip-status { font: 700 11px/1 var(--mono); letter-spacing: 0.1em; padding: 5px 7px; border-radius: 5px; border: 1px solid var(--line); white-space: nowrap; }
.status-chip.dialing, .chip-status.dialing { color: var(--accent-text); border-color: var(--accent); }
.status-chip.ready, .chip-status.ready { color: var(--ok); border-color: var(--ok); }
.status-chip.dead, .chip-status.dead { color: var(--muted); }
.meters { display: grid; gap: 6px; }
.meter { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.meter .pips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.meter .pip { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--faint); display: inline-block; }
.meter.hull .pip.on { background: var(--ink); border-color: var(--ink); }
.meter.heat .pip { border-color: var(--heat); }
.meter.heat .pip.on { background: var(--heat); }
.meter.heat .pip.edge { border-color: var(--edge); border-width: 2px; }
.meter.ap .pip { border-color: var(--ap); }
.meter.ap .pip.on { background: var(--ap); }
.meter .count { font-size: 12px; font-weight: 700; color: var(--muted); }
.burn-tag { font: 700 10px/1 var(--mono); letter-spacing: 0.06em; color: var(--edge); padding: 2px 4px; border-radius: 3px; }
.burn-tag.on { background: var(--edge); color: #fff; }
.card-orders { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.piece-chip { font: 700 13px/1 var(--mono); padding: 6px 8px; border-radius: 5px; background: var(--panel-raised); border: 1px solid var(--line); }
.piece-chip.empty { border-style: dashed; color: var(--faint); background: transparent; }
button.link { background: none; border: none; min-height: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; font-size: 13px; }
button.link:hover:not(:disabled) { border: none; color: var(--muted); }

/* The board: the largest square that fits, with its toggles and the last turn over it. */
.stage { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; container-type: size; background: var(--board-bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stage-square { position: relative; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
.stage-square .board { width: 100%; height: 100%; border: none; border-radius: 0; }
.stage-square .board svg { width: 100%; height: 100%; }
.stage-square .board.tappable { outline-offset: -3px; }
.board.no-rings .ring { display: none; }
.board.no-grid .grid, .board.no-grid .rulers { display: none; }
.board-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.replay { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px); display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px; background: rgba(10, 13, 22, 0.82); border: 1px solid rgba(255, 255, 255, 0.14); }
.replay .label { color: #a9b5cf; }
.replay .summary { font: 500 12px/1.2 var(--mono); color: #c9d4ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* The board keeps its dark field in both site themes, so its buttons are dark too. */
button.tool { min-height: 32px; min-width: 34px; padding: 0 10px; font: 700 12px/1 var(--mono); letter-spacing: 0.06em; color: #e8edf7; background: rgba(10, 13, 22, 0.82); border-color: rgba(255, 255, 255, 0.22); }
button.tool:hover:not(:disabled) { border-color: #e8edf7; }
button.tool.on { color: var(--accent); border-color: var(--accent); }

/* The orders: the step's frame, the action pinned at the foot. */
.orders { display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 0; min-width: 0; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 10px; }
.orders.pointed { outline: 2px solid var(--accent); outline-offset: 2px; }
.orders-head { display: flex; align-items: center; gap: 8px; }
.orders-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.orders-body > * { flex: none; }
.orders-help { font-size: 13px; line-height: 1.45; color: var(--muted); }
.context { margin: 0; font-size: 15px; line-height: 1.4; color: var(--muted); }
.context strong { color: var(--ink); }
.context.result { color: var(--ink); font-size: 16px; }
.lesson { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--paper); }
.lesson .step p { margin: 4px 0; }
.rewind { font-size: 13px; }
.picker { display: flex; gap: 6px; }
.picker .pick { flex: 1 1 0; min-width: 0; font-family: var(--mono); font-weight: 700; font-size: 13px; padding-inline: 6px; }
.pick.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pick.done { color: var(--ok); }
.slots { display: flex; gap: 8px; }
.slot { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); }
.slot .mono { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slot.next { border: 1px dashed var(--accent); background: transparent; }
.slot.next .label, .slot.next .mono { color: var(--accent-text); }
.slots .slot:nth-child(n+6) { display: none; }
.pad { display: grid; gap: 6px; }
.pad button { min-width: 0; padding-inline: 4px; }
.pad.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pad.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pad.two, .pad.mods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pad.blocks { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.pad.actions { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.pad-key { min-height: 56px; font: 700 15px/1 var(--mono); letter-spacing: 0.04em; }
.pad-key.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pad-mod { font: 700 13px/1.25 var(--mono); text-transform: uppercase; flex-direction: column; gap: 2px; }
.pad-mod small { font-weight: 500; color: var(--muted); text-transform: none; }
.pad.mods .pad-mod { flex-direction: row; }
button.quiet { min-height: 40px; color: var(--muted); }
.block-row { display: flex; flex-direction: column; gap: 6px; }
.move-order { gap: 6px; }
button.seal.big, a.button.seal.big { width: 100%; min-height: 56px; font-size: 16px; font-family: var(--mono); letter-spacing: 0.06em; text-transform: uppercase; flex: none; }
a.button.seal.big { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.seal.big:not(:disabled):not(.danger) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* A seal that cannot go yet says why, in full. */
button.seal.big:disabled { opacity: 1; background: transparent; color: var(--faint); border-color: var(--line); }
button.seal.big.danger { background: transparent; color: var(--ink); border: 1.5px dashed var(--edge); }
.orders .table-story { padding: 10px; }

/* On a phone: the same table stacked, with nothing to scroll on a normal turn. */
/* The screen's height exactly, so the orders scroll inside and the seal stays in view; a very short screen scrolls the page. */
.table.narrow { display: flex; flex-direction: column; gap: 8px; padding: 8px; height: 100vh; height: 100dvh; min-height: 560px; }
.status.compact { flex: none; height: 44px; gap: 8px; padding: 0 8px; }
.status.compact .names { flex: 1 1 auto; text-align: center; font-size: 13px; }
.status.compact .move { height: 30px; padding: 0 8px; font-size: 12px; }
.turn-cluster.compact { border: none; background: none; padding: 0; gap: 6px; }
.turn-cluster.compact .big { font-size: 15px; }
.chips { flex: none; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
button.ship-chip { flex: none; min-height: 36px; padding: 6px 10px; gap: 6px; font-size: 12px; background: var(--panel-raised); white-space: nowrap; }
button.ship-chip.current { border-color: var(--accent); }
button.ship-chip.dead { opacity: 0.55; }
.chip-note { align-self: center; margin-left: auto; white-space: nowrap; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 8px; }
.table.narrow .stage { flex: none; width: 100%; height: min(calc(100vw - 16px), max(240px, calc(100dvh - 430px))); }
.table.narrow .board-tools { top: 6px; right: 6px; }
.table.narrow .replay { left: 6px; bottom: 6px; padding: 4px 6px; }
.table.narrow .orders { flex: 1 1 auto; min-height: 0; padding: 10px; gap: 8px; }
.table.narrow .pad.actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.table.narrow .pad-mod { font-size: 12px; min-height: 44px; padding: 4px; }
.table.narrow .pad-mod small { font-size: 10px; }
.table.narrow .orders-body { gap: 8px; }
.table.narrow .context { font-size: 13px; }
.table.narrow .slot { padding: 6px; }
.table.narrow .slot .mono { font-size: 16px; }
.table.narrow .pad-key { min-height: 48px; font-size: 13px; }
.table.narrow .pad.mods { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.table.narrow .long, .table.narrow .working, .table.narrow .orders-help { display: none; }
.table.narrow .situation { font-size: 12px; }
.table.narrow button.seal.big, .table.narrow a.button.seal.big { min-height: 50px; font-size: 14px; }

/* Over the table: the menu from the side, the sheets from the bottom (centred on a wide screen). */
.scrim { position: fixed; inset: 0; z-index: 40; display: flex; background: rgba(0, 0, 0, 0.45); }
.scrim.menu-scrim { justify-content: flex-end; }
.scrim.sheet-scrim { align-items: flex-end; justify-content: center; }
.drawer, .sheet { display: flex; flex-direction: column; gap: 12px; padding: 14px; overflow: auto; background: var(--paper); border: 1px solid var(--line); }
.drawer { width: min(440px, 100vw); height: 100%; border-width: 0 0 0 1px; }
.sheet { width: min(560px, 100vw); max-height: 88vh; max-height: 88dvh; border-radius: 14px 14px 0 0; }
.overlay-head { display: flex; align-items: center; gap: 8px; }
.drawer-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 900px) {
  .scrim.sheet-scrim { align-items: center; }
  .sheet { border-radius: 14px; }
}
