:root {
  --paper: #f3f4f2;
  --card: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5a6472;
  --line: #d6d9d4;
  --navy: #1f3a5f;
  --navy-deep: #15293f;
  --ball: #c9581c;    /* 4-shift marker, score */
  --veto: #9b2c2c;
  --warn: #8a5a00;
  --warn-bg: #fff3d1;
  --court: #e9dfc7;   /* on-floor cells */
  --radius: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
/* A hidden element stays hidden even when its class sets a display. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); line-height: 1.4; }
main { max-width: 1040px; margin: 0 auto; padding: 0 16px 48px; }

.top {
  max-width: 1040px; margin: 0 auto; padding: 20px 16px 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.local-tag { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.top-actions { display: flex; align-items: baseline; gap: 16px; margin-left: auto; }
.logout { margin: 0; }
.top-actions button.link { color: var(--ink-soft); font-size: 0.9rem; }
/* A short notice at the foot of the screen, so it never moves the board. */
.feedback-done {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 10;
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 8px 14px; font-size: 0.9rem;
  width: max-content; max-width: calc(100vw - 32px);
}
.feedback-done:empty { display: none; }
/* On a phone the title and Feedback share the first line, the tabs the second. */
@media (max-width: 600px) {
  .top-actions { order: 1; }
  .tabs { order: 2; flex-basis: 100%; }
}
#feedback {
  width: min(32rem, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; background: var(--card); color: var(--ink);
}
#feedback::backdrop { background: rgb(27 36 48 / 0.35); }
#feedback h2 { margin-top: 0; }
#feedback textarea {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--ink); resize: vertical;
}
#feedback textarea:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
h1 { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
h3 { font-size: 0.95rem; margin: 20px 0 6px; color: var(--ink-soft); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); }
.tabs a {
  color: var(--ink-soft); text-decoration: none; padding: 6px 12px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs a[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }
.tabs a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 4px 0 8px; }
.error { color: var(--veto); font-weight: 600; margin: 8px 0; }

button {
  font: inherit; border-radius: var(--radius); padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
/* A tap acts at once and a quick second tap never zooms the page (the
   tournament cells and the rating tiles are tapped in a row). */
button, .tabs a, select, input { touch-action: manipulation; }
button, .tabs a { -webkit-tap-highlight-color: transparent; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; padding: 10px 18px; }
button.primary:hover { background: var(--navy-deep); }
button.quiet { background: transparent; }
button:disabled { opacity: 0.5; cursor: default; }
input[type=text], input[type=number] {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
.row-actions { display: flex; gap: 12px; align-items: center; margin: 14px 0; flex-wrap: wrap; }

.columns { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 32px; }
/* A column never grows past the page to fit a wide board: the board scrolls inside it. */
.columns > * { min-width: 0; }
@media (max-width: 820px) { .columns { grid-template-columns: 1fr; } }
/* The schedule lands under the setup on a narrow screen; after Generate the page goes to it. */
#result, #tour-result { scroll-margin-top: 8px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* attendance list */
.att { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.att li {
  display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.att li.out .who { color: var(--ink-soft); text-decoration: line-through; }
.att input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
.num { display: inline-block; min-width: 2ch; font-weight: 700; color: var(--ink-soft); margin-right: 6px; font-variant-numeric: tabular-nums; }
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who small { color: var(--ink-soft); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toggle { font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; }
.toggle.four[aria-pressed="true"] { background: var(--ball); border-color: var(--ball); color: #fff; }
.toggle.veto[aria-pressed="true"] { background: var(--veto); border-color: var(--veto); color: #fff; }
.att li.out .toggle { visibility: hidden; }

.weights { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; max-width: 420px; }
.weights label { font-size: 0.75rem; color: var(--ink-soft); text-align: center; }
.weights input { width: 100%; padding: 6px 2px; text-align: center; }

/* the board. The wrap is positioned so the cells' screen-reader words
   (placed absolutely) stay inside it instead of widening the page. */
.board-wrap { overflow-x: auto; position: relative; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
.board th, .board td { border: 1px solid var(--line); padding: 6px 4px; text-align: center; font-size: 0.85rem; min-width: 76px; }
.board th { font-weight: 700; }
.board thead th.shift { font-size: 1.1rem; color: var(--navy); }
.board thead th.half-label { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); padding: 4px; }
.board thead th.key { color: var(--ball); }
.board td.pos, .board th.pos { position: sticky; left: 0; background: var(--paper); font-weight: 700; color: var(--ink-soft); min-width: 44px; z-index: 1; }
.board th.pos { font-size: 0.75rem; font-weight: 600; }
.board td .n { font-weight: 700; color: var(--ink-soft); margin-right: 4px; }
/* A kid's rating at the position they play there, light red (1) to light
   green (5): the board's cells, its legend, and the call bar under it. */
.f1 { background: #f4c4bd; color: var(--ink); }
.f2 { background: #f8dcc4; color: var(--ink); }
.f3 { background: #f6edc8; color: var(--ink); }
.f4 { background: #dcebc7; color: var(--ink); }
.f5 { background: #bfe0bd; color: var(--ink); }
.board caption.fit-legend { caption-side: bottom; text-align: left; padding: 8px 0 2px; font-size: 0.8rem; color: var(--ink-soft); }
.fit-legend span:first-child { margin-right: 6px; vertical-align: middle; }
.fit-legend .swatch { display: inline-block; vertical-align: middle; width: 26px; height: 20px; line-height: 20px; margin-right: 3px; text-align: center; border-radius: 3px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Words for screen readers only (the colour says it on screen). */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.issues { list-style: none; margin: 0 0 8px; padding: 0; font-size: 0.9rem; }
.issues li { padding: 6px 10px; border-left: 3px solid var(--warn); background: var(--warn-bg); color: var(--warn); margin-bottom: 4px; border-radius: 0 var(--radius) var(--radius) 0; }
.issues li.error { border-left-color: var(--veto); background: #fbe9e9; color: var(--veto); }
.issues li.ok { border-left-color: var(--line); background: transparent; color: var(--ink-soft); padding-left: 0; }
/* halftime: a heavy dashed line between shift 4 and 5 */
.board th.half-end, .board td.half-end { border-right: 3px dashed var(--navy); }

.strip th, .strip td { border: 1px solid var(--line); padding: 5px 4px; text-align: center; font-size: 0.85rem; }
.strip td.name, .strip th.name { text-align: left; position: sticky; left: 0; background: var(--paper); min-width: 140px; }
.strip td.on { background: var(--court); font-weight: 700; }
.strip td.count { font-weight: 700; font-variant-numeric: tabular-nums; }
.strip td.count.four { color: var(--ball); }
.strip th.half-end, .strip td.half-end { border-right: 3px dashed var(--navy); }

/* roster */
.add-form { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.add-form #add-name { flex: 1; min-width: 160px; }
.roster th, .roster td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; font-size: 0.9rem; vertical-align: middle; }
.roster input[type=number] { width: 56px; }
.roster th { color: var(--ink-soft); font-weight: 600; font-size: 0.8rem; }
.roster input[type=number] { width: 60px; }
.roster input[type=text] { width: 100%; min-width: 120px; }
/* rating tiles: one number per position, shaded from faint (1) to navy (5) */
.rating-cell { position: relative; text-align: center; }
.roster th.rating-head { text-align: center; }
.roster .group-row th { border-bottom: none; padding-bottom: 0; }
.roster th.group { text-align: center; color: var(--navy); font-weight: 700; font-size: 0.8rem; border-bottom: 2px solid var(--navy); padding-bottom: 4px; }
.tile {
  width: 38px; height: 34px; padding: 0; border-radius: 4px; border: 1px solid transparent;
  font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums;
}
.tile.r1 { background: #eef0ee; color: var(--ink-soft); }
.tile.r2 { background: #d9dfe8; color: var(--navy); }
.tile.r3 { background: #b4c1d4; color: var(--navy-deep); }
.tile.r4 { background: #5c7799; color: #fff; }
.tile.r5 { background: var(--navy); color: #fff; }
.tile[aria-expanded="true"] { outline: 2px solid var(--navy); outline-offset: 1px; }
.picker {
  position: absolute; left: 50%; top: calc(100% - 6px); transform: translateX(-50%); z-index: 5;
  display: flex; gap: 4px; padding: 6px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(27, 36, 48, 0.15);
}
.picker .tile[aria-selected="true"] { outline: 2px solid var(--ball); outline-offset: 1px; }
.roster tbody tr:nth-last-child(-n+2) .picker { top: auto; bottom: calc(100% - 6px); }
.roster td.tally { text-align: center; color: var(--ink-soft); }
.roster button.del, .games button.del { color: var(--veto); border-color: transparent; background: transparent; }

@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 120ms; }
}

/* ---------- the coach's calls ---------- */
.board td.tap, .strip td.tap { padding: 0; }
td.tap > button { all: unset; display: block; box-sizing: border-box; width: 100%; cursor: pointer; text-align: center; }
.board td.tap > button { padding: 6px 4px; }
.strip td.tap > button { padding: 5px 4px; }
td.tap > button:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; }
td.called, td.sat-out, td.selected { position: relative; }
/* a small navy corner: the coach set this cell */
td.called::before { content: ""; position: absolute; top: 0; left: 0; border-top: 9px solid var(--navy); border-right: 9px solid transparent; pointer-events: none; }
/* hatching: the coach sat the kid out of this shift */
.strip td.sat-out { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6.5px); }
td.selected { outline: 2px solid var(--navy); outline-offset: -2px; }
.call-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 4px; }
/* Two rows when a spot on the board is selected: the spot, then the kid in it. */
.call-bar .call-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex-basis: 100%; }
.call-bar .call-row + .call-row { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.call-bar .who { font-weight: 700; margin-right: 6px; }
.undo-row { margin: 8px 0 0; }
.call-bar .hint { margin: 0 2px 0 6px; }
.call-bar button { padding: 5px 10px; font-size: 0.85rem; }
.call-bar button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.call-bar button.tile { width: 30px; height: 28px; padding: 0; border: 1px solid transparent; font-weight: 700; }
.call-bar button.tile[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.call-bar .kid-pick { display: inline-flex; align-items: center; gap: 5px; }
.call-bar .kid-pick .tile.mini { display: inline-block; width: 20px; height: 18px; line-height: 18px; font-size: 0.7rem; border-radius: 3px; margin: 0; }
.call-bar .quiet { margin-left: auto; }
.calls-list { list-style: none; margin: 0 0 8px; padding: 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.calls-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.calls-list button { padding: 3px 8px; font-size: 0.8rem; }
.call-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.call-add select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); max-width: 150px; }
.shift-picks { display: inline-flex; gap: 2px; }
.shift-pick { padding: 5px 0; width: 26px; text-align: center; font-size: 0.85rem; }
.shift-pick[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.error.small { font-size: 0.85rem; margin: 0; }

/* ---------- tournament ---------- */
.tour-head input { max-width: 320px; }
.tour-games { list-style: none; margin: 0 0 8px; padding: 0; }
.tour-games li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tour-games .game-n { width: 64px; font-weight: 600; }
.tour-games input[type=text] { flex: 1 1 160px; }
.tour-grid { border-collapse: collapse; }
.tour-grid th, .tour-grid td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: center; font-size: 0.9rem; }
.tour-grid th { color: var(--ink-soft); font-weight: 600; font-size: 0.8rem; }
.tour-grid .name { text-align: left; font-weight: 600; }
.tour-grid tr.gone td { color: var(--ink-soft); }
.tour-grid tr.gone td.name { text-decoration: line-through; }
.cell { min-width: 76px; font-size: 0.8rem; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.cell.four { background: var(--ball); border-color: var(--ball); color: #fff; font-weight: 700; }
.cell.away { background: transparent; color: var(--ink-soft); border-style: dashed; }
.tour-game { margin: 24px 0; }
.tour-game-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tour-game-head h3 { margin: 0; }
.tour-game .changed { color: var(--ball); font-weight: 600; }
.tour-head select { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--card); }
.cell:disabled { opacity: 0.6; cursor: default; }
.tour-game h4 { margin: 12px 0 6px; font-size: 0.9rem; color: var(--ink-soft); }
.tour-text p { max-width: 70ch; }
#tour-fairness td.behind { color: var(--ball); font-weight: 700; }

/* ---------- printable shift sheet ---------- */
.print-only { display: none; }
@media print {
  @page { size: landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .top, main, #feedback { display: none !important; }
  .print-only { display: block; }

  .sheet-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6mm; }
  .sheet-head h1 { font-size: 20pt; margin: 0; }
  .sheet-meta { display: flex; gap: 10mm; font-size: 12pt; }
  .sheet-meta .blank { display: inline-block; width: 50mm; border-bottom: 1px solid #000; vertical-align: baseline; }

  /* Rows are 11mm, or less when the page is short: a browser zoomed in
     (Chrome prints at the page's zoom) or a long roster lays the sheet out
     on a smaller page area, and 100vh is that area, so the rows shrink to
     keep the sheet on one page. --rows is set by the script. 44mm covers
     the title, the header row, the footnote and the borders. */
  table.sheet { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff;
    --row: min(11mm, calc((100vh - 44mm) / var(--rows, 12))); }
  .sheet th, .sheet td { border: 1px solid #000; text-align: center; height: var(--row); padding: 0; position: relative; }
  .sheet th { font-size: 13pt; font-weight: 700; height: min(9mm, var(--row)); }
  .sheet th.name, .sheet td.name { width: 40mm; text-align: left; padding-left: 3mm; font-size: 13pt; font-weight: 600; }
  .sheet th.total, .sheet td.total { width: 18mm; font-size: 12pt; }
  .sheet .half-end { border-right: 3px solid #000; }
  .sheet td.on .x { display: block; font-size: min(24pt, calc(var(--row) * 0.77)); font-weight: 800; line-height: var(--row); }
  .sheet td.on .pos { position: absolute; top: 1mm; right: 1.5mm; font-size: 8pt; line-height: 1; }
  .sheet-foot { margin-top: 4mm; font-size: 9pt; color: #000; }
  .sheet-page { break-after: page; page-break-after: always; }
  .sheet-page:last-child { break-after: auto; page-break-after: auto; }
  .fairness-page table { width: 100%; border-collapse: collapse; }
  .fairness-page th, .fairness-page td { border: 1px solid #000; padding: 1.5mm 2mm; font-size: 11pt; color: #000; }
  .fairness-page th { font-weight: 700; text-align: right; }
  .fairness-page th:first-child, .fairness-page td:first-child { text-align: left; }
  .fairness-page td.num-col { text-align: right; }
  .fairness-page td.behind { font-weight: 700; }
  .fairness-page p { font-size: 11pt; margin: 3mm 0 0; max-width: none; }
}

/* ---------- save row, season, game view ---------- */
.editing {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 16px 0 0; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: var(--radius);
}
.save-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.save-row input[type=date] { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--card); }
.save-row input[type=text] { min-width: 180px; }

.standings th, .standings td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; font-size: 0.9rem; }
.standings th { color: var(--ink-soft); font-weight: 600; font-size: 0.8rem; }
.standings .group-row th { border-bottom: none; padding-bottom: 0; }
.standings th.group { text-align: center; color: var(--navy); font-weight: 700; font-size: 0.8rem; border-bottom: 2px solid var(--navy); padding-bottom: 4px; }
.standings .num-col { text-align: right; font-variant-numeric: tabular-nums; }
.standings td.share { white-space: nowrap; }
.standings .mark { display: inline-block; width: 1.1em; text-align: right; font-size: 0.75rem; }
.standings td.share.behind { color: var(--ball); font-weight: 700; }
.standings td.share.ahead { color: var(--ink-soft); }
.standings tr.inactive td { color: var(--ink-soft); }
.standings tr.inactive small { font-size: 0.75rem; }
.standings tfoot td { color: var(--ink-soft); font-weight: 600; border-bottom: none; background: var(--paper); }

.games { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.games li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.games li button.link { flex: 1; }
.games li button.del { padding: 4px 8px; }
button.link { background: none; border: none; padding: 4px 0; color: var(--navy); cursor: pointer; text-align: left; font: inherit; }
button.link:hover { text-decoration: underline; }
.badge { font-size: 0.75rem; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.badge.actual { color: var(--navy); border-color: var(--navy); }

.game-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 20px 0 12px; }
.game-head input[type=date], .game-head input[type=text] { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--card); }
button.danger { color: var(--veto); margin-left: auto; }
.board td.edit select { font: inherit; font-size: 0.8rem; max-width: 100px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
.board td.np-cell { color: var(--ink-soft); background: var(--paper); }
.board .np-row th { font-weight: 500; font-size: 0.7rem; color: var(--ink-soft); padding: 2px; }
.board .np label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.board .np input { width: 12px; height: 12px; margin: 0; }
.issues li.note { border-left-color: var(--line); background: var(--paper); color: var(--ink-soft); }

.inactive { list-style: none; margin: 0; padding: 0; max-width: 420px; }
.inactive li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); }

.fairness-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 2px; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }
.fairness-row input { width: 64px; text-align: center; }

/* Login page: one small card, the same quiet look as the board. */
.login { max-width: 340px; margin: 48px auto; padding: 20px 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; }
.login h2 { margin: 0 0 4px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.login input { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; font-weight: 400; background: var(--card); }
.login .error { margin: 0; }
.login button { align-self: flex-start; }

/* ---------- phones ----------
   The board keeps its shape: four shifts fill the width, so the screen shows
   one half at a time and the halftime line is where a swipe lands. Who plays
   when and the Roster fit whole; the Standings and the tournament grid keep
   the kid's name pinned while the numbers scroll. */
@media (max-width: 600px) {
  main { padding: 0 12px 48px; }
  .top { padding: 14px 12px 0; gap: 10px 16px; }
  .tabs { justify-content: space-between; gap: 0; }
  .tabs a { padding: 10px 8px; }
  h2 { margin-top: 16px; }

  button { padding: 10px 14px; }
  button.primary { padding: 12px 18px; }
  .toggle { padding: 7px 12px; }
  .att li { padding: 5px 0; }
  .row-actions { gap: 8px 10px; }
  .save-row input[type=date], .save-row input[type=text],
  .game-head input[type=date], .game-head input[type=text], .tour-head input { flex: 1 1 100%; max-width: none; min-width: 0; }
  .add-form #add-name { min-width: 0; }
  .call-add select { max-width: 100%; }
  .call-bar button { padding: 7px 10px; }
  .call-bar button.tile { width: 34px; height: 32px; }
  .shift-pick { width: 30px; padding: 7px 0; }

  /* The board: one half per screen. */
  .board-wrap:has(> .board) { scroll-snap-type: x proximity; scroll-padding-left: 44px; }
  .board th, .board td { min-width: calc((100vw - 68px) / 4); padding: 9px 3px; font-size: 0.8rem; }
  .board td.tap > button { padding: 9px 3px; }
  .board td.pos, .board th.pos { min-width: 44px; width: 44px; }
  .board thead tr:nth-child(2) th:nth-child(2), .board thead tr:nth-child(2) th:nth-child(6) { scroll-snap-align: start; }
  .board thead th.shift { font-size: 1rem; }
  /* The legend stays put while the board swipes. */
  .board caption.fit-legend { position: sticky; left: 0; width: calc(100vw - 24px); padding-left: 2px; }

  /* Who plays when: fits the width. */
  .strip th, .strip td { padding: 7px 2px; font-size: 0.8rem; }
  .strip td.tap > button { padding: 7px 2px; }
  .strip td.name, .strip th.name { min-width: 0; width: 92px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Roster: fits the width. */
  .roster th, .roster td { padding: 6px 2px; }
  .roster td:first-child, .roster th:first-child { padding-left: 0; }
  .roster td:last-child, .roster th:last-child { padding-right: 0; }
  .roster input[type=text] { min-width: 0; padding: 8px 6px; }
  .tile { width: 36px; height: 36px; }
  .roster button.del { padding: 6px 4px; font-size: 0.8rem; }
  .roster .rating-cell:nth-last-child(-n+3) .picker { left: auto; right: 0; transform: none; }
  .roster .rating-cell:nth-child(2) .picker { left: 0; transform: none; }

  /* Standings and the tournament grid: the name stays put. */
  .standings th, .standings td { padding: 7px 6px; font-size: 0.85rem; }
  .standings th:first-child, .standings td:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); }
  .tour-grid th.name, .tour-grid td.name { position: sticky; left: 0; z-index: 1; background: var(--card); padding-left: 0; }
  .cell { min-width: 66px; padding: 6px 6px; }
  .tour-games .game-n { width: auto; }

  .board .np input { width: 16px; height: 16px; }
  .weights input { padding: 8px 0; }
  #feedback { padding: 14px 16px; }
}
/* A field under a finger keeps 16px text, or iPhones zoom in on it. */
@media (pointer: coarse) {
  .board td.edit select { font-size: 1rem; }
}
