/* Furball's web table. One dark palette, the board's own: deep navy field, grid blue, side colours blue (A) and
   red (B), gold for "your move". Phone first: board on top, panel below; side by side on wide screens. */
:root {
  --bg: #0b1020;
  --panel: #121a33;
  --panel-raised: #1a2446;
  --line: #2a3866;
  --text: #e8edff;
  --muted: #8fa3d9;
  --faint: #55638a;
  --side-a: #3d8bfd;
  --side-b: #ff5a3d;
  --gold: #ffd166;
  --good: #4cd98a;
  --bad: #ff6b6b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 15px/1.45 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(--gold); }

.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: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.32em;
  text-decoration: none;
  font-size: 15px;
}

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

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(--text);
  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(--muted); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.primary, .button.primary { background: #1f6fd1; border-color: #3d8bfd; font-weight: 600; }
button.seal { background: #1d6b45; border-color: var(--good); font-weight: 700; }
button.danger { background: #6b1d1d; border-color: var(--bad); }
button.piece { min-width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; }
button.selected { background: #1d6b45; border-color: var(--good); }
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: #0b1020; color: var(--text); }
select { max-width: 100%; text-overflow: ellipsis; }

/* The match screen. */
.match { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) {
  .match { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
  .match .side-column { position: sticky; top: 64px; }
}

.titlebar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; align-items: baseline; }
.titlebar .title { font-weight: 700; font-size: 16px; }
.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: #1b1300; background: var(--gold); border-color: var(--gold); }

.board {
  position: relative;
  background: #121a33;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.board svg { display: block; width: 100%; height: auto; }
.board.tappable { cursor: crosshair; outline: 2px dashed var(--gold); outline-offset: -2px; }
.caption { font-size: 12px; color: var(--muted); padding: 6px 2px 0; }
.history { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

.panel .headline { font-weight: 700; font-size: 16px; }
.plotted { font-size: 20px; font-weight: 800; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; min-height: 28px; }
.working { margin: 0; padding: 8px 10px; list-style: none; background: #0b1020; 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(--gold); }
.error { color: var(--bad); }
.situation { margin: 0; padding-left: 18px; font-size: 13px; }
.help { font-size: 14px; background: #0b1020; 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; }

.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(--text); 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: #0b1020; color: var(--text); }

.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(--muted);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

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

/* On a phone the five pieces share one row; the other buttons in a row share it evenly. */
.panel .row > button { flex: 1 1 auto; }
.panel .row > button.piece { flex: 1 1 0; min-width: 44px; padding-inline: 4px; }

/* 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 laid on the dark table. ---- */
:root {
  --paper: #f4f1ea;
  --ink: #1b1d22;
  --rule: #8a8578;
  --heat: #c8502b;
  --ap: #2b6cc8;
  --ink-muted: #6a675f;
}

/* Cockpit plates: one a seat, with a block of pips a ship (hull counts down, heat counts up, AP what is left). */
.plates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.plate { background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 8px; padding: 7px 9px 8px; min-width: 0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.plate.a { border-left: 6px solid var(--side-a); }
.plate.b { border-left: 6px solid var(--side-b); }
.plate .pilot { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; letter-spacing: 0.03em; min-width: 0; }
.plate .pilot svg { flex: none; }
.plate .pilot .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate .status { font-size: 10px; color: var(--ink-muted); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; margin-top: 1px; }
.plate .status.to-move { color: var(--heat); }
.cockpit { margin-top: 6px; }
.cockpit + .cockpit { border-top: 1px solid var(--rule); padding-top: 5px; }
.cockpit .ship-id { font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: var(--ink-muted); }
.pips { display: grid; grid-template-columns: 34px 1fr; gap: 3px 4px; align-items: center; }
.pips .lbl { font-size: 9px; font-weight: 800; letter-spacing: 0.14em; color: var(--ink); }
.pips .row { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.pip { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--ink); box-sizing: border-box; }
.pip.on { background: var(--ink); }
.pips.heat .lbl { color: var(--heat); }
.pips.heat .pip { border-color: var(--heat); }
.pips.heat .pip.on { background: var(--heat); }
.pips.ap .lbl { color: var(--ap); }
.pips.ap .pip { border-color: var(--ap); }
.pips.ap .pip.on { background: var(--ap); }
.pip.burn { width: auto; height: 13px; padding: 0 4px; border-radius: 7px; font-size: 7px; font-weight: 800; line-height: 10px; letter-spacing: 0.08em; color: var(--heat); background: rgba(200, 80, 43, 0.14); }
.pip.burn.on { background: var(--heat); color: var(--paper); }
.pips.dead .pip { opacity: 0.3; }

/* 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(--paper); color: var(--ink);
  border: 1.5px solid var(--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(--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(--ink); line-height: 1.2; }
.kcard .kind { font-size: 7px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-muted); }
.kcard .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 5px; margin-bottom: 5px; }
.kcard .stat { border: 1px solid var(--rule); border-radius: 5px; padding: 3px 5px 2px; }
.kcard .stat .lbl { font-size: 6.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--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(--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(--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(--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(--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(--ink-muted); }
.kcard .weapon .line b { color: var(--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(--rule); }
.kcard .bands th { font-size: 6.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--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(--rule); }
.kcard .kgrid th { font-size: 6.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; border-bottom: 1.5px solid var(--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(--ink-muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.kcard .kgrid td:first-child .note { font-weight: 500; color: var(--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(--ink); }
.kcard .kgrid .zero { color: var(--ink-muted); font-weight: 500; }
.kcard .notes { margin-top: auto; border-top: 1.5px solid var(--ink); padding-top: 4px; }
.kcard .notes p { margin: 0 0 2px; color: var(--ink-muted); }
.kcard .notes b, .kcard .notes strong { color: var(--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(--ink-muted); letter-spacing: 0.1em; }

/* On a narrow phone the two plates share the width: smaller pips so the heat row keeps BURN on its line. */
@media (max-width: 430px) {
  .pips { grid-template-columns: 30px 1fr; }
  .pip { width: 11px; height: 11px; }
  .pip.burn { height: 11px; font-size: 6px; line-height: 8px; padding: 0 3px; }
  .plate .pilot { font-size: 12px; }
}

/* 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(--text); 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(--gold); }
.pill.code { font-family: ui-monospace, Consolas, monospace; color: var(--text); }
.pill.clock { color: var(--text); font-variant-numeric: tabular-nums; }
.pill.clock.low { color: #1b1300; background: var(--bad); border-color: var(--bad); }
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.gain { color: var(--good); }
.loss { color: var(--bad); }
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 { color: var(--gold); }
.note-card textarea.note-text-box { min-height: 52px; }
