/* ============================================================
   Game-Day Rotations — self-contained stylesheet.
   Design tokens + app chrome + planner grid + printable sheet.
   To re-brand: change --accent / --accent-d (and the dark-mode
   pair below) — everything else follows the tokens.
   ============================================================ */

:root {
  /* light (default) — matched to vfwyouthgroup.org design tokens (brand red = Pantone 187C) */
  color-scheme: light;
  --bg: #faf7f4;             /* site --bg */
  --paper: #ffffff;          /* topbar / secondary surfaces (site --surface) */
  --panel: #ffffff;          /* cards (site --surface) */
  --ink: #241f1d;            /* site --ink */
  --muted: #6b615c;          /* site --text-secondary */
  --faint: #8a7e77;          /* site --text-muted */
  --line: #eae2dc;           /* hairlines (site --border) */
  --line-d: #d9cdc5;         /* site --border-dark */
  --accent: #a6192e;         /* THE action color (site --red) */
  --accent-d: #7e1223;       /* site --red-dark */
  --accent-soft: #b98a91;    /* site --footer-heading */
  --accent-tint: #f6dce0;    /* site --tint-light */
  --accent-tint-bd: #f0c2c9; /* site --tint-secondary */
  --tan: #f2eae4;            /* warm callout tint (derived from site borders) */
  --tan-border: #d9cdc5;
  --defense: #3a5a6b;
  --ok: #2e7d4f;
  --sub-bg: #e7f6ec;         /* "subbed in" box */
  --sub-bd: #51a96b;
  --sub-mark: #2e9e4f;
  --shadow: 0 1px 2px rgba(20,17,13,.04), 0 10px 28px rgba(20,17,13,.06);
  /* site typography: --serif carries the display face, --mono the eyebrow-label face */
  --serif: "Barlow Condensed", "Arial Narrow", sans-serif;   /* site --font-display */
  --sans: "Barlow", "Helvetica Neue", Arial, sans-serif;     /* site --font-body */
  --mono: "Barlow Condensed", "Arial Narrow", sans-serif;    /* tiny tracked-caps labels, like site .eyebrow */
}

/* dark mode — explicit choice (warm maroon-tinted darks derived from the brand red) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191114;
  --paper: #1f1518;
  --panel: #251a1d;
  --ink: #ece4e0;
  --muted: #a3928c;
  --faint: #6f625d;
  --line: #342629;
  --line-d: #46353a;
  --accent: #c41f37;         /* site --red-bright */
  --accent-d: #d94459;       /* hover lightens in the dark */
  --accent-soft: #b98a91;
  --accent-tint: #331419;
  --accent-tint-bd: #55232c;
  --tan: #281d20;
  --tan-border: #423134;
  --defense: #6d96ad;
  --ok: #6fbe8a;
  --sub-bg: #142b1c;
  --sub-bd: #2e6b45;
  --sub-mark: #6fbe8a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.4);
}
/* dark mode — OS preference, unless user picked light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191114;
    --paper: #1f1518;
    --panel: #251a1d;
    --ink: #ece4e0;
    --muted: #a3928c;
    --faint: #6f625d;
    --line: #342629;
    --line-d: #46353a;
    --accent: #c41f37;
    --accent-d: #d94459;
    --accent-soft: #b98a91;
    --accent-tint: #331419;
    --accent-tint-bd: #55232c;
    --tan: #281d20;
    --tan-border: #423134;
    --defense: #6d96ad;
    --ok: #6fbe8a;
    --sub-bg: #142b1c;
    --sub-bd: #2e6b45;
    --sub-mark: #6fbe8a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.4);
  }
}
/* print is always paper — whatever the screen theme. The :not() selector is needed to
   out-rank the OS-dark-preference block above (same specificity, this comes later). */
@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    color-scheme: light;   /* native controls (check-off boxes) must print light, even from dark mode */
    --bg: #fff; --paper: #fff; --panel: #fff;
    --ink: #241f1d; --muted: #6b615c; --faint: #8a7e77;
    --line: #eae2dc; --line-d: #d9cdc5;
    --accent: #a6192e; --accent-d: #7e1223;
    --accent-tint: #f6dce0; --accent-tint-bd: #f0c2c9; --accent-soft: #b98a91;
    --tan: #f2eae4; --tan-border: #d9cdc5;
    --ok: #2e7d4f; --sub-bg: #e7f6ec; --sub-bd: #51a96b; --sub-mark: #2e9e4f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button { font-family: var(--sans); cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; }
::selection { background: var(--accent); color: #fff; }

/* ---- topbar ---- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 14px; padding: 0 18px; height: 56px; background: var(--paper);
  border-bottom: 2px solid var(--ink); }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; flex: none; }
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--ink); }
.brand-sub { font-family: var(--mono); font-weight: 600; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent-soft); }
.tabs { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 8px 13px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-radius: 0; display: flex; align-items: center; gap: 7px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -2px; height: 56px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.theme-toggle { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-d);
  background: var(--panel); color: var(--muted); font-size: 15px; line-height: 1; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- layout + shared bits ---- */
.view { max-width: 1160px; margin: 0 auto; padding: 26px 22px 60px; }
.empty-hint { font-size: 12.5px; color: var(--faint); font-style: italic; padding: 6px 2px; }
.btn { border: 1px solid var(--line-d); background: var(--panel); color: var(--ink); border-radius: 3px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }
.btn.danger:hover { border-color: var(--accent); color: var(--accent); }
.btn.armed, .btn.armed:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[disabled] { opacity: .45; cursor: default; }
.field label { display: block; font-family: var(--mono); font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.field { min-width: 0; }   /* grid items may shrink below content size (iOS date inputs) */
.field input, .field textarea { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line-d); border-radius: 3px;
  font-size: 13px; font-family: var(--sans); resize: vertical; background: var(--panel); color: var(--ink); }
/* iOS gives date inputs an intrinsic width that overflows grid columns — flatten it */
.field input[type="date"] { -webkit-appearance: none; appearance: none; height: 38px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

/* ---- app footer (screen only — .no-print hides it on the game sheet) ---- */
.app-foot { text-align: center; font-size: 12.5px; color: var(--muted);
  padding: 18px 22px 30px; border-top: 1px solid var(--line); margin-top: 10px; }
.app-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.app-foot a:hover { text-decoration: underline; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); background: var(--ink);
  color: var(--bg); padding: 11px 18px; font-size: 13px; font-weight: 600; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; }

/* the sheet and grids follow the screen theme; @media print forces them back to paper */

/* ============================================================
   Rotations planner + printable breakdown
   ============================================================ */
.rotations .view { max-width: 1100px; }
.section-title { font-size: 26px; margin: 0 0 4px; }
.section-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }

/* ---- roster ---- */
.roster-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; }
.roster-row .num { width: 54px; text-align: center; }
.roster-row .nm { flex: 1; min-width: 90px; }
.roster-row input { padding: 9px 10px; border: 1px solid var(--line-d); border-radius: 8px; font-size: 15px; font-family: var(--sans); background: var(--panel); color: var(--ink); }
.roster-row .ctl { display: flex; align-items: center; gap: 5px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; white-space: nowrap; }
.roster-row .ctl select { padding: 6px 6px; border: 1px solid var(--line-d); border-radius: 7px; font-size: 13px; font-family: var(--sans); background: var(--panel); color: var(--ink); }
#rosterList:not(.hints-open) .roster-row .ctl { display: none; }
.roster-row .ctl.chk input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.hints-box { margin: 0 0 14px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.hints-box summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.hints-box p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 9px 0 2px; }

/* ---- saved plans ---- */
.saved-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 15px; margin-bottom: 9px; box-shadow: var(--shadow); }
.sv-main { flex: 1; min-width: 180px; }
.sv-title { font-family: var(--serif); font-weight: 700; font-size: 18px; }
.sv-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.sv-badge { display: inline-block; margin-left: 6px; font-family: var(--sans); font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 20px; background: var(--tan); color: var(--accent-d); }
.sv-badge.final { background: rgba(111,190,138,.16); color: var(--ok, #2e7d46); }
.sv-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- plan form ---- */
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.avail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 6px; }
.player-toggle { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line-d);
  border-radius: 10px; background: var(--panel); font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; }
.player-toggle.on { background: rgba(111,190,138,.16); border-color: var(--ok, #6fae73); }
.player-toggle.off { opacity: .55; }
.owe-pill { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: var(--tan); color: var(--accent-d); margin-left: auto; }

/* ---- editable rotation grid: Gantt (players = rows, periods = columns) ---- */
.sched-wrap { overflow: auto; -webkit-overflow-scrolling: touch; margin: 6px 0 4px; }
.rg-wrap { max-height: 74vh; }
.rgrid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.rgrid th, .rgrid td { padding: 0; border-bottom: 1px solid var(--line); }
.rgrid thead th { position: sticky; top: 0; z-index: 3; background: var(--bg); border-bottom: 1.5px solid var(--line-d); }
.rg-ph { text-align: center; font-family: var(--sans); padding: 5px 4px; min-width: 56px; vertical-align: bottom; }
.rg-ph .rg-p { display: block; font-weight: 800; font-size: 12px; color: var(--accent-d); }
.rg-ph .rg-q { display: block; font-size: 8px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.rg-ph .rg-cnt { display: block; font-size: 9px; font-weight: 700; color: var(--muted); }
.rg-ph .rg-cnt.bad { color: var(--accent); }
.rg-ph .rg-cnt.ok { color: var(--ok); }
.rg-corner { background: var(--bg); font-family: var(--sans); font-size: 10px; color: var(--muted); text-align: left; padding: 0 10px; min-width: 104px; }
.rg-corner.rg-minh { text-align: center; min-width: 48px; }
.rgrid tbody th.rg-name { position: sticky; left: 0; z-index: 2; background: var(--panel); text-align: left; padding: 4px 10px;
  white-space: nowrap; font-weight: 600; min-width: 104px; }
.rg-name .dot { width: 9px; height: 9px; margin-right: 7px; vertical-align: middle; }
/* drag-to-reorder rows (plan grid only) */
th.rg-name[draggable] { cursor: grab; }
th.rg-name[draggable]:active { cursor: grabbing; }
.rg-grip { color: var(--faint); font-size: 11px; margin-right: 6px; vertical-align: middle; }
tr.dragging { opacity: .45; }
tr.drop-above th, tr.drop-above td { border-top: 2px solid var(--accent) !important; }
tr.drop-below th, tr.drop-below td { border-bottom: 2px solid var(--accent) !important; }
.rg-cell { height: 30px; cursor: pointer; position: relative; }
.rg-bar { display: block; height: 20px; margin: 5px 0; background: transparent; }
.rg-cell.on .rg-bar { background: var(--accent); }
.rg-cell.on.rstart .rg-bar { border-top-left-radius: 6px; border-bottom-left-radius: 6px; margin-left: 4px; }
.rg-cell.on.rend .rg-bar { border-top-right-radius: 6px; border-bottom-right-radius: 6px; margin-right: 4px; }
.rg-cell.off { background: var(--bg); }                            /* bench shading */
.rg-cell.off:hover .rg-bar { background: var(--tan-border); border-radius: 6px; margin: 5px 4px; }  /* click affordance */
/* per-period validation: flag the whole period column */
.rg-ph.badcol { background: var(--accent-tint); }
.rg-cell.badcol { background: var(--accent-tint); }
.rg-cell.badcol.on .rg-bar { background: var(--accent); }
/* quarter + halftime column dividers */
.qstart { border-left: 1.5px dashed var(--line-d); }
.halfstart { border-left: 3px solid var(--accent); }
/* hover cross-highlight */
.hl-col { background: var(--tan) !important; }
.rgrid tr.hl-row th.rg-name, .rgrid tr.hl-row .rg-cell { background: var(--tan); }
.rgrid tr.hl-row .rg-cell.on .rg-bar { background: var(--accent-d); }
.rg-min { font-family: var(--sans); font-weight: 800; font-size: 11px; text-align: center; padding: 0 8px; white-space: nowrap; }
.rg-min.flag { color: var(--accent); }
.sched-legend { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.backup-note { font-size: 12px; color: var(--faint); margin: 0; }
.backup-note b { color: var(--muted); }
.backup-note a { color: var(--accent); font-weight: 600; text-decoration: none; }
.backup-note a:hover { text-decoration: underline; }

/* ---- breakdown / game sheet ---- */
.bd-empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.bd-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow); }
.sheet-head { border-bottom: 2px solid var(--accent); padding-bottom: 8px; margin-bottom: 14px; }
.sheet-title { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.sheet-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.bd-printhead { display: none; }   /* print-only duplicate of the sheet head — see @media print */
.sheet-portrait { max-width: 760px; margin: 0 auto; }

/* period × slot grid (rows stacked; .prow and .gap share the same columns) */
.sheet-grid { display: flex; flex-direction: column; }
.prow, .gap { display: grid; grid-template-columns: var(--cols); column-gap: 8px; }
.rlabel { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 0; }
.pchk input { width: 17px; height: 17px; accent-color: var(--accent); }
.rl-stack { display: flex; flex-direction: column; line-height: 1.12; }
.rl-per { font-family: var(--sans); font-weight: 800; font-size: 15px; color: var(--accent-d); }
.rl-q { font-family: var(--sans); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.rl-clock { font-family: var(--sans); font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pbox { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 54px;
  border: 1.5px solid var(--line-d); border-radius: 6px; font-size: 14px; font-weight: 600; padding: 4px; background: var(--panel); }
.pbox.sub { background: var(--sub-bg); border-color: var(--sub-bd); box-shadow: inset 4px 0 0 var(--sub-mark); }
.pbox .empty { color: var(--faint); font-weight: 400; }
/* gap row carries the red sub-in triangles; quarter boundary adds a faint line
   centered in the gap, spanning only the player columns (not the label column). */
.gap { align-items: center; min-height: 28px; position: relative; }
.gap.qline::after { content: ""; position: absolute; top: 50%; left: 0; width: var(--labelw);
  border-top: 1.5px dashed var(--line-d); }
.acell { display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.tri { width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-top: 11px solid var(--accent); }
/* halftime: strong, well-spaced band splitting the two halves */
.halfband { text-align: center; font-family: var(--sans); font-weight: 800; font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent); padding: 9px 0; margin: 8px 0; background: var(--tan);
  border-top: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); border-radius: 3px; }
.bd-min { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted); }
.bd-min b { color: var(--ink); }
.print-brand { display: none; }   /* site attribution, printed sheet only — see @media print */

/* player-rotation Gantt shown above the breakdown sheet (and printed with it) */
.bd-gantt { max-width: 760px; margin: 14px auto 20px; }
.bd-gantt-title { font-family: var(--serif); font-weight: 700; font-size: 18px; margin: 0 0 9px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); }
.bd-gantt .rg-cell { cursor: default; }
.bd-gantt .rgrid { width: 100%; }   /* match the breakdown's full width */
/* "At a glance" reads as a ruled grid, not a timeline: one discrete dot per period
   (runs are NOT joined here — the breakdown above already shows continuity), plus
   dividers on both axes so the eye can land on a single period/player cell. */
.bd-gantt .rg-cell, .bd-gantt .rg-ph,
.bd-gantt .rg-corner:not(.rg-minh), .bd-gantt tbody th.rg-name { border-right: 1px solid var(--line); }
.bd-gantt .rgrid th, .bd-gantt .rgrid td { border-bottom: 1px solid var(--line); }
.bd-gantt .rg-cell.off { background: transparent; }   /* gridlines do the work, not shading */
.bd-gantt .rg-cell .rg-bar,
.bd-gantt .rg-cell.on.rstart .rg-bar,
.bd-gantt .rg-cell.on.rend .rg-bar {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 13px; height: 13px; margin: 0; border-radius: 50%;
}

@media screen and (max-width: 820px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- print: breakdown sheet + rotation Gantt on one portrait letter page ---- */
@media print {
  /* slim page margins only — the clipboard-clip space at the top lives in content
     padding (below) instead, because phones IGNORE @page margins and substitute
     their own; content padding prints identically on every device */
  @page { size: portrait; margin: 0.25in 0.4in 0.25in; }
  .topbar, .no-print, .toast, .theme-toggle { display: none !important; }
  html, body, .rotations .view { background: #fff; }
  /* Force the print layout to letter content width on EVERY device. Phones otherwise
     lay print out at device width (~390px), where the sheet can't fit a page and
     engines clip or split it; with a fixed width the OS scales the desktop-identical
     rendering to the paper instead. */
  body { width: 7.7in; }
  .rotations .view { max-width: none; padding: 0; }
  #view-roster, #view-plan, #view-saved { display: none !important; }
  #view-breakdown { padding: 0.55in 0.45in 0; }   /* top = clipboard-clip clearance */
  /* print order matches the screen: title block, at-a-glance grid, then the period sheet */
  .bd-printhead { display: block; margin-bottom: 10px; }
  .sheet > .sheet-head { display: none; }
  /* both stretch to the full page width (no auto-margin centering) so they line up edge-to-edge */
  .sheet, .bd-gantt { box-shadow: none; border: 0; padding: 0; max-width: none; width: 100%; margin-left: 0; margin-right: 0; }
  /* the sheet must NOT be monolithic (break-inside: avoid on the whole card): on engines
     that lay print out at device width (iOS) it becomes taller than one page, and an
     unbreakable too-tall element gets CLIPPED — the sheet vanished from phone PDFs.
     Instead, keep each period row intact and let breaks fall between periods. */
  .bd-gantt, .prow, .gap, .halfband, .bd-min, .bd-printhead { break-inside: avoid; }
  /* paper never scrolls: on-screen scroll containers and min-widths must not survive
     into print, or engines that lay print out at device width (iOS) CLIP the overflow —
     the whole period sheet can silently disappear from the PDF */
  .sheet, .sched-wrap { overflow: visible; -webkit-overflow-scrolling: auto; }   /* touch-scrolling layers print blank on iOS */
  .sheet-grid { min-width: 0; }
  .rg-ph, .rg-corner, .rgrid tbody th.rg-name { min-width: 0; }
  /* distribute the at-a-glance columns evenly at any page width */
  .bd-gantt .rgrid { table-layout: fixed; }
  .bd-gantt .rg-corner:first-child { width: 21%; }
  .bd-gantt .rg-corner.rg-minh { width: 9%; }
  .pbox, .pbox.sub, .tri, .halfband, .rg-cell, .rg-cell .rg-bar, .badcol { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* breakdown: keep it readable — boxes a touch shorter, but gaps keep room for the triangles.
     min-width: 0 lets the 1fr columns shrink below the name's natural width on narrow page
     boxes (iOS) — without it the right-hand player columns get clipped off the page. */
  .pbox { min-height: 30px; padding: 2px 3px; font-size: 12px; min-width: 0; overflow: hidden; overflow-wrap: anywhere; }
  .prow, .gap { column-gap: 5px; }
  .rlabel, .rl-stack { min-width: 0; }
  .gap { min-height: 13px; }
  .acell { min-height: 13px; }
  .tri { border-left-width: 6px; border-right-width: 6px; border-top-width: 9px; }
  .halfband { margin: 3px 0; padding: 4px 0; }
  .sheet-head { padding-bottom: 5px; margin-bottom: 7px; }
  .bd-min { margin-top: 7px; padding-top: 5px; }
  .sched-wrap { margin: 0; }
  /* Gantt: very compact (dots on a ruled grid) so the readable breakdown fits below it. */
  .bd-gantt { margin-top: 0; margin-bottom: 14px; }
  .bd-gantt-title { font-size: 14px; margin-bottom: 4px; padding-bottom: 3px; border-bottom-width: 1.5px; }
  .rgrid thead th, .rgrid tbody th.rg-name { position: static; }
  .rg-cell { height: 15px; } .rg-cell .rg-bar { height: 9px; margin: 3px 0; }
  .bd-gantt .rg-cell .rg-bar,
  .bd-gantt .rg-cell.on.rstart .rg-bar,
  .bd-gantt .rg-cell.on.rend .rg-bar { width: 8px; height: 8px; }
  .rg-name { font-size: 9.5px; padding: 1px 6px 1px 4px; } .rg-name .dot { width: 6px; height: 6px; }
  .rg-ph { padding: 2px 3px; } .rg-p { font-size: 9px; } .rg-q { font-size: 6.5px; } .rg-cnt { font-size: 7px; }
  .rg-corner { font-size: 8px; } .rg-min { font-size: 8.5px; }
  .print-brand { display: block; text-align: center; font-family: var(--mono); font-size: 8px;
    letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-top: 9px; }
  /* at-a-glance: names sized to match the sheet's .pbox so the two blocks read as one document */
  .bd-gantt .rg-cell { height: 16px; }
  .bd-gantt .rg-name { font-size: 13px; padding: 1px 8px 1px 4px; }
  .bd-gantt .rg-name .dot { width: 8px; height: 8px; }
  .bd-gantt .rg-p { font-size: 11px; }
  .bd-gantt .rg-corner { font-size: 9.5px; } .bd-gantt .rg-min { font-size: 11px; }
  /* the Q tag and the n/5 validity count are planning aids — the sheet below already
     carries Q1–Q4 per period, so drop them in print and spend the height on the names */
  .bd-gantt .rg-q, .bd-gantt .rg-cnt { display: none; }
}

.sched-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--panel);
  border: 1px solid var(--line-d); }
.sheet { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sheet-grid { min-width: 540px; }

/* ---- mobile ---- */
@media screen and (max-width: 760px) {
  /* the four tabs can't share a row with the brand on a phone — "Saved" fell off
     the right edge (and the tab strip's scrollbar is hidden, so nothing hinted it
     scrolls). Two rows instead: brand + theme toggle, then four full-width tabs. */
  .topbar { padding: 0 12px; gap: 8px; flex-wrap: wrap; height: auto; }
  .brand { height: 46px; display: flex; align-items: center; }
  .theme-toggle { order: 2; margin-left: auto; }
  .tabs { order: 3; flex: 1 1 100%; margin-left: 0; border-top: 1px solid var(--line); }
  .tabs button { flex: 1; justify-content: center; height: 42px; padding: 0 4px; font-size: 13px; margin-bottom: 0; border-bottom-width: 3px; }
  .brand-sub { display: none; }
  .rotations .view { padding: 16px 12px 60px; }
  .bd-toolbar { flex-direction: column; align-items: flex-start; }
  .sheet { padding: 12px 8px; }
  /* the period sheet reads top-to-bottom: it must FIT the screen, never scroll
     sideways (the at-a-glance grid above it is the opposite — it keeps its
     horizontal scroll because periods read left-to-right) */
  .sheet { overflow-x: visible; }
  .sheet-grid { min-width: 0; --labelw: 60px !important; }   /* !important beats the inline --labelw */
  .prow, .gap { column-gap: 4px; }
  .rlabel { gap: 4px; padding-right: 0; }
  .pchk input { width: 14px; height: 14px; }
  .rl-per { font-size: 12px; }
  .rl-q { font-size: 7.5px; }
  .rl-clock { font-size: 8px; }
  .pbox { min-height: 44px; font-size: 9.5px; letter-spacing: -.01em; font-weight: 600; padding: 2px 2px; border-radius: 4px; overflow: hidden; overflow-wrap: anywhere; }
  .tri { border-left-width: 5px; border-right-width: 5px; border-top-width: 8px; }
  .gap { min-height: 22px; }
  .halfband { font-size: 9.5px; letter-spacing: .12em; padding: 6px 0; }
  .bd-min { font-size: 10px; }
}
