/* "Club": a printed scorecard rather than a dashboard.
 *
 * There is no accent HUE. Interaction is ink inversion and rule weight, which
 * is what a scorecard has always used -- and it keeps the palette clear of the
 * four colours that are already load-bearing DATA here: the red and yellow
 * rocks, and the green 12-foot and blue 4-foot of the painted ice. The old
 * --accent (#2b6cb0) sat a few degrees off the 4-foot blue, so "this is
 * interactive" and "this is the four-foot" were near neighbours.
 *
 * --onaccent exists because --accent inverts between the modes: ink on paper,
 * paper on oak. Every fill that used to hardcode #fff on top of --accent now
 * reads this instead, or the dark mode would put white text on a pale fill.
 * The #fff that sits on --red is NOT that, and stays put. */
:root {
  --bg:#f3f0e7; --panel:#fffdf7; --ink:#16130c; --muted:#6d6455;
  --line:#dcd5c3; --accent:#16130c; --onaccent:#fffdf7;
  --soft:#eee8da; --band:#f7f3ea;
  --red:#d13438; --yellow:#e8b400;
  --warn:#8a4f12; --warnbg:#f3e3c6; --ok:#2f7a37; --okbg:#e2efd9;
  --ice:#fffdf7; --iceline:#cfc8b6; --rail:#8c8472;
  --display:"Archivo Narrow",system-ui,-apple-system,"Segoe UI",sans-serif;
}
/* Warm dark: oak and charcoal, not the blue-grey it replaces, or the two modes
   read as two different products.
   --ice/--iceline/--rail are deliberately NOT redefined here. Nothing in either
   stylesheet reads them -- the house is drawn from PAINT in core/constants.mjs,
   a JS constant that cannot see prefers-color-scheme -- so overriding them
   would be dead code claiming the ice follows the mode. It does not, and it
   should not: a curling sheet is a lit white surface whatever the room is
   doing, and the rings and rocks have to keep the colours they have on the ice.
   The :root copies above are kept only to stay in step with PAINT. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#17140f; --panel:#211c14; --ink:#f2ece0; --muted:#a2977f;
    --line:#372f22; --accent:#f2ece0; --onaccent:#17140f;
    --soft:#2c251a; --band:#262017;
    --warn:#e0a94a; --warnbg:#3a2c11; --ok:#7fbf6a; --okbg:#1c2c16;
  }
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink);
       font:14px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif; }
header { padding:10px 16px; border-bottom:1px solid var(--line);
         background:var(--panel); display:flex; gap:12px; align-items:center;
         flex-wrap:wrap; position:sticky; top:0; z-index:5; }
/* The header is a stacking context, so #menu's own z-index only counts inside
   it: while ⋯ is open the header itself must clear the phone's House-tab house
   and the edit-mode house (8/9), or they cover the menu from I played… down. */
body[data-menu="open"] header { z-index:10; }
/* The condensed face carries the headings and every number; body copy stays on
   the system sans, which is what a dense charting form wants at 13px. The stack
   falls back to system-ui by design: the face comes from a CDN, so an offline
   `curling-score serve` loses the character but keeps the layout. */
h1 { font-family:var(--display); font-size:17px; margin:0; font-weight:700;
     white-space:nowrap; }
/* The title reads as a title until you reach for it. */
h1 a { text-decoration:none; color:inherit; }
h1 a:hover { color:var(--accent); text-decoration:underline; }
h2 { font-family:var(--display); font-size:13px; margin:0 0 8px; font-weight:700;
     color:var(--ink); text-transform:uppercase; letter-spacing:.09em; }
h3 { font-family:var(--display); font-size:13px; margin:14px 0 6px; font-weight:700;
     color:var(--muted); text-transform:uppercase; letter-spacing:.07em; }

/* Numerals in the condensed face, everywhere a figure is meant to be compared
   down a column: the scoreboard, the grade row, the clock totals, the rock
   chips and the watch list. tabular-nums stays on each of them -- the face is
   a change of voice, not a substitute for the figures lining up. */
.shot, .scorebtns button, .pill, th, dd, table, #stoneChip,
.wsc, .wdisc, .wsecs, .wtotals, .wen { font-family:var(--display); }
.muted { color:var(--muted); }
.grow { flex:1 1 auto; }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
a { color:var(--accent); }

/* React mounts into a container, and <header>, <main> and #report were body's
   own children. `display:contents` makes that container generate no box, so
   the grid below lays out exactly as it did -- the same technique #menu uses
   a little further down, for the same reason. */
#root { display:contents; }

/* Laid out by area so the shot detail sits right under the video: the house
   and the chart panel span the rows beside it, and the last row is 1fr so a
   tall column grows that row rather than opening a gap under the video. See
   docs/superpowers/specs/2026-09-24-desktop-shot-detail-design.md §1. */
main { display:grid; gap:14px; padding:14px;
       grid-template-columns:minmax(0,1fr) minmax(290px,360px) 310px;
       grid-template-areas: "play house chart" "detail house chart";
       grid-template-rows: auto 1fr;
       align-items:start; }
#playCard { grid-area: play; }
#detailCard { grid-area: detail; }
#houseCard { grid-area: house; }
#chart { grid-area: chart; }
@media (max-width:1180px){ main { grid-template-columns:minmax(0,1fr) 320px;
  grid-template-areas: "play house" "detail house" "chart house";
  grid-template-rows: auto auto 1fr; } }
@media (max-width:820px){ main { grid-template-columns:1fr;
  grid-template-areas: "play" "detail" "house" "chart";
  grid-template-rows: none; } }
/* The phone layouts place these cards themselves, and a grid-area naming an
   area that no longer exists would push a card into the implicit grid, so
   the names go as well as the areas. */
@media (max-width:640px){
  main { grid-template-areas: none; }
  #playCard, #houseCard, #chart { grid-area: auto; }
  #detailCard { display: none; }
}

/* --- shot detail (desktop) ---------------------------------------------- */
/* The phone's Detail rules live inside its media query; these are the
   desktop card's own. The strip scales to the card through its viewBox. */
#detailCard { container-type: inline-size; }
#detailCard .dstrip { display: block; width: 100%; height: auto; background: var(--ice);
                      border: 1px solid var(--line); border-radius: 4px; }
#detailCard .dstrip-none { aspect-ratio: 660 / 114; }
/* The delivery close up under the strip, the same way round and as wide. */
#detailCard .dlv { display: block; width: 100%; height: auto; background: var(--ice);
                   border: 1px solid var(--line); border-radius: 4px; margin-top: 6px; }
#detailCard .dlvnone { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
/* At 1440 x 900 the video's natural height leaves only ~300 px under it, so
   these six rows are tighter than the phone's: less row padding and a closer
   line-height, not a smaller number (font-size stays 19px, matching the
   mockup) and not fewer columns. Frees ~34 px, enough for the card to clear
   the fold with the ~6 px margin the design calls for. */
#detailCard .dfigs { margin: 4px 0 0; display: grid; gap: 0 18px;
                     grid-template-columns: repeat(3, minmax(0, 1fr)); }
#detailCard .dfig { padding: 3px 0; border-bottom: 1px solid var(--line); min-width: 0;
                    line-height: 1.3; }
#detailCard .dfig dt { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
                       color: var(--muted); font-weight: 600; }
#detailCard .dfig .dval { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 700;
                          line-height: 1.05; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The three .dfigs columns are minmax(0,1fr): their width comes from the
   card's own width, not the viewport's, and the grid-template-columns
   change at each of main's breakpoints resets it, so the card is narrowest
   right after 1180px and right after 820px rather than at the viewport
   extremes. Measured at 1181x900 and 821x900 (card 440px/444px, columns
   126px/127.3px, 18px gap): a 19px "6 ft 1 in narrow" (16 chars) already
   overflows there, and a 17-char value ("1 ft 10 in narrow") measures
   130.3px at 16px -- the reviewer's suggested step -- which still overflows
   both columns (by 4.3px and 3.0px). 15px measures 122.2px, clearing both
   with 3.8px and 5.2px to spare (measured with a DOM Range, since scrollWidth
   floors at clientWidth once nothing overflows and cannot show the margin).
   500px sits between the card widths that still overflow at 19px (up to
   ~487px, measured at 864x900) and the ones that already clear it (from
   ~502px, measured at 1228x900), so it catches both narrow points while
   leaving 1280x900 (554px) and 1440x900 (699px) at the full size. This rule
   must stay after the plain .dval rule above: same specificity, so source
   order decides, and a container query earlier in the file loses the
   cascade. */
@container (max-width: 500px) {
  #detailCard .dfig .dval { font-size: 15px; }
}
#detailCard .dfig .dnote { margin: 0; font-size: 11.5px; color: var(--muted);
                           display: flex; align-items: center; gap: 5px; }
#detailCard .dcap { font-size: 11px; color: var(--muted); margin: 3px 0 0; }
#detailCard .dnone { font-size: 14px; color: var(--muted); margin: 0; }
.card { background:var(--panel); border:1px solid var(--line);
        border-radius:10px; padding:12px; }

select, button, input, textarea {
  font:inherit; padding:5px 9px; border-radius:7px; color:var(--ink);
  border:1px solid var(--line); background:var(--panel); }
button { cursor:pointer; }
button:hover:not(:disabled) { border-color:var(--accent); }
button:disabled { opacity:.4; cursor:default; }
button.on { background:var(--accent); color:var(--onaccent); border-color:transparent; }
textarea { width:100%; resize:vertical; min-height:44px; }
input[type=text] { width:100%; }
label.chk { display:flex; gap:6px; align-items:center; cursor:pointer;
            font-size:13px; }

/* --- video ------------------------------------------------------------- */
.video { position:relative; width:100%; aspect-ratio:16/9; background:#000;
         border-radius:8px; overflow:hidden; }
.video iframe, .video > div { width:100%; height:100%; border:0; }
.fallback { display:grid; place-items:center; height:100%; padding:20px;
            text-align:center; color:#ddd; background:#222; font-size:13px; }

/* --- shot chips -------------------------------------------------------- */
.shots { display:flex; flex-wrap:wrap; gap:4px; margin-top:10px; }
.shot { width:30px; height:30px; border-radius:7px; border:1px solid var(--line);
        display:grid; place-items:center; font-size:11px; cursor:pointer;
        background:var(--panel); font-variant-numeric:tabular-nums; position:relative; }
.shot.red { background:var(--red); color:#fff; border-color:transparent; }
.shot.yellow { background:var(--yellow); color:#1a1a1a; border-color:transparent; }
.shot.sel { outline:3px solid var(--accent); outline-offset:1px; }
.shot.unknown { border:2px dashed var(--warn); opacity:.75; }
.shot.graded::after { content:""; position:absolute; right:2px; bottom:2px;
                      width:5px; height:5px; border-radius:50%; background:var(--ok); }

.warn { background:var(--warnbg); color:var(--warn); border-radius:7px;
        padding:7px 10px; margin-top:9px; font-size:13px; }

/* --- doubles: the end box (hammer, power play, swap toggles) ----------- */
.wpp { font-size:12px; padding:1px 7px; border-radius:999px; background:var(--warnbg); color:var(--warn); white-space:nowrap; }
#endBox { margin-top:12px; }
#endBox label { display:block; margin:4px 0; }
/* A switch that was not saved: nobody signed in, or the server said why. */
.endnote { margin:6px 0 0; font-size:13px; color:var(--warn); }
.endnote button { min-height:44px; margin-left:6px; }
.endfacts { display:flex; gap:8px; flex-wrap:wrap; align-items:center; font-size:13px; margin:4px 0; }

/* --- house ------------------------------------------------------------- */
#house { width:100%; height:auto; display:block; touch-action:none;
         cursor:crosshair; }
#house .stone { cursor:grab; }
.tools { display:flex; gap:6px; align-items:center; flex-wrap:wrap;
         margin-bottom:8px; }
.swatchbtn { width:26px; height:26px; border-radius:50%; padding:0;
             border:2px solid var(--line); }
.swatchbtn.red { background:var(--red); }
.swatchbtn.yellow { background:var(--yellow); }
.swatchbtn.on { border-color:var(--accent); box-shadow:0 0 0 2px var(--accent); }

/* --- chart panel ------------------------------------------------------- */
.pick { display:flex; flex-wrap:wrap; gap:4px; }
.pick button { padding:4px 8px; font-size:12px; }
.scorebtns button { width:34px; padding:5px 0; font-variant-numeric:tabular-nums; }
/* A score gets circled on a scorecard, not filled in. The type row above keeps
   the ink fill, so the two selections stop reading as the same gesture -- with
   no accent hue they were both a solid ink block and competed. (0,2,1) over
   button.on's (0,1,1), so this wins without touching that rule. */
.scorebtns button.on { background:var(--panel); color:var(--ink);
                       border:2px solid var(--ink); font-weight:700; }
#score td.unread { opacity: 0.45; }
.scorekey { display: flex; gap: 12px; flex-wrap: wrap;
            font-size: 12px; opacity: 0.7; margin: 6px 0 0; }
dl { display:grid; grid-template-columns:auto 1fr; gap:3px 10px; margin:8px 0 0;
     font-size:13px; }
dt { color:var(--muted); }
dd { margin:0; font-variant-numeric:tabular-nums; }
.queue { max-height:220px; overflow:auto; margin-top:6px; }
.queue button { display:block; width:100%; text-align:left; margin-bottom:3px;
                font-size:12px; }
details { margin-top:12px; border-top:1px solid var(--line); padding-top:8px; }
summary { cursor:pointer; color:var(--muted); font-size:13px; }
table { border-collapse:collapse; width:100%; font-variant-numeric:tabular-nums; }
th,td { padding:4px 6px; text-align:center; border-bottom:1px solid var(--line); }
th { color:var(--muted); font-weight:600; font-size:12px; }
td.name, th.name { text-align:left; font-weight:600; }
.swatch { display:inline-block; width:10px; height:10px; border-radius:50%;
          margin-right:6px; }

.pill { padding:3px 9px; border-radius:999px; font-size:12px;
        border:1px solid var(--line); white-space:nowrap; }
.pill.ok { background:var(--okbg); color:var(--ok); border-color:transparent; }
.pill.bad { background:var(--warnbg); color:var(--warn); border-color:transparent; }
/* A game still being played. The same red in both themes: it reads as "on
 * air", which neither the warning nor the ok colours do. */
.pill.live, .wlive { background:#c0392b; color:#fff; border-color:transparent;
  text-transform:uppercase; letter-spacing:.04em; font-weight:650; }
.wlive { font-size:11px; padding:1px 6px; border-radius:999px; margin-left:6px; white-space:nowrap; }

/* --- report ------------------------------------------------------------ */
/* The game report: a by-end table, the two teams head to head, the clock and
   the detail, as on board B of the "Game Report Readability" canvas
   (docs/superpowers/specs/2026-10-01-game-report-and-entered-scores-design.md).
   Set in Source Sans 3 like the games page, with tabular figures so every
   column of numbers lines up. Team colours are SVG fills (.rpt-dot, the
   duel bars), because a CSS background is dropped when the page prints. */
/* Source Sans 3 (SIL OFL 1.1, source-sans-3.OFL.txt): the latin subset, every
   weight from 400 to 700 in one variable file. Shipped with the viewer rather
   than fetched from Google, because the viewer reaches for nothing but
   YouTube and so keeps working offline under `curling-score serve`
   (tests/test_frontend_build.py). */
@font-face { font-family:"Source Sans 3"; font-style:normal; font-weight:400 700;
             font-display:swap; src:url("source-sans-3.woff2") format("woff2"); }
#report { padding:24px 28px 40px; display:none;
          font-family:"Source Sans 3",system-ui,-apple-system,"Segoe UI",sans-serif;
          font-size:15px; line-height:1.4; font-variant-numeric:tabular-nums; }
#report.show { display:block; }
body.reporting main { display:none; }
#report table, #report th, #report button { font-family:inherit; }
.rpt { max-width:1216px; margin:0 auto; display:flex; flex-direction:column; gap:20px; }
.rpt .card { border-radius:12px; padding:20px 24px; min-width:0; }
.rpt h2 { font-family:inherit; font-size:19px; font-weight:700; line-height:1.2;
          text-transform:none; letter-spacing:0; margin:0; color:var(--ink); }
.rpt h3 { font-family:inherit; font-size:15px; font-weight:700; text-transform:none;
          letter-spacing:0; color:var(--ink); margin:0 0 6px; }
.rpt .sub { font-size:14px; color:var(--muted); margin:2px 0 14px; }
.rpt-dot { flex:none; }
.rpt-dot.red circle { fill:var(--red); }
.rpt-dot.yellow circle { fill:var(--yellow); }
.rpt-team { display:inline-flex; align-items:center; gap:8px; font-weight:600; }
.rpt-head { display:flex; align-items:flex-end; gap:16px 20px; flex-wrap:wrap; }
.rpt-meta { font-size:15px; color:var(--muted); margin-bottom:4px; }
.rpt-title { font-family:inherit; font-size:34px; line-height:1.1; font-weight:700;
             text-transform:none; letter-spacing:0; white-space:normal;
             display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.rpt-title .v { color:var(--muted); font-weight:400; font-size:26px; }
.rpt-cover { display:inline-flex; align-items:center; gap:10px; min-height:40px;
             padding:6px 16px; border-radius:999px; border:0; cursor:pointer;
             background:var(--warnbg); color:var(--warn); font-size:15px; font-weight:600; }
.rpt-cover:disabled { cursor:default; }
.rpt-top { display:grid; grid-template-columns:minmax(0,7fr) minmax(0,5fr); gap:20px;
           align-items:stretch; }
/* A game of more than four ends does not fit beside the head-to-head at
   1280 px, and below 1240 px nor do four: the by-end table then takes the
   full width, and the two comparisons sit side by side under it. */
.rpt-top.long { grid-template-columns:minmax(0,1fr); }
.rpt-top.long .rpt-h2h-body { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:20px 40px; }
.rpt-top.long .rpt-h2h-body > div + div { border-top:0; padding-top:0; }
@media (max-width: 1240px) and (min-width: 821px) {
  .rpt-top { grid-template-columns:minmax(0,1fr); }
  .rpt-h2h-body { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:20px 40px; }
  .rpt-h2h-body > div + div { border-top:0; padding-top:0; }
}

/* By end. The table is as wide as its columns, not the card: numbers spread
   across a wide card are numbers the eye cannot track along a row. */
.rpt-scroll { overflow-x:auto; }
.rpt-byend { width:auto; font-size:17px; }
.rpt-byend th, .rpt-byend td { border:0; padding:0 10px; height:38px; text-align:center;
                               font-size:inherit; color:var(--ink); }
.rpt-byend thead th { height:32px; font-size:13px; font-weight:600; color:var(--muted);
                      white-space:nowrap; }
.rpt-byend th[scope=row] { text-align:left; padding-left:0; min-width:150px; font-size:16px;
                           white-space:nowrap; position:sticky; left:0; background:var(--panel); z-index:1; }
.rpt-byend tr.blk th { height:28px; vertical-align:bottom; text-align:left; padding:0 0 4px;
                       font-size:12px; font-weight:700; letter-spacing:.08em;
                       text-transform:uppercase; color:var(--muted);
                       border-bottom:1px solid var(--line); }
.rpt-byend tbody tr:not(.blk) > * { border-bottom:1px solid var(--line); }
.rpt-byend td { min-width:64px; position:relative; }
.rpt-byend td.tot { background:var(--band); font-weight:700; min-width:90px; }
.rpt-byend td.tot.partial { color:var(--muted); }
.rpt-byend .zero, .rpt-byend .none, .rpt-byend td.none { color:var(--muted); }
.rpt-byend .won, .rpt-byend td.won { font-weight:700; }
.rpt-byend .rpt-noscore { text-align:left; padding:8px 0; height:auto; color:var(--muted);
                          font-size:14px; }
.rpt .ham { width:6px; height:6px; }
.rpt .ham circle { fill:var(--muted); }
.rpt-byend .ham { position:absolute; left:8px; top:50%; margin-top:-3px; }
.rpt-key { display:flex; flex-wrap:wrap; gap:6px 18px; font-size:13px; color:var(--muted);
           margin-top:12px; }
.rpt-key .ham { margin-right:6px; vertical-align:middle; }
.rpt-rule { border:0; height:1px; background:var(--line); margin:20px 0 16px; }
.rpt-notes p { margin:0 0 8px; font-size:14px; color:var(--muted); line-height:1.45; }

/* Head to head: mirrored bars on a 0-100 scale, the number outside each. */
.rpt-h2h-body { display:flex; flex-direction:column; gap:20px; }
.rpt-h2h-body > div + div { border-top:1px solid var(--line); padding-top:16px; }
.rpt-h2h-body > div + div h2 { font-size:17px; margin-bottom:8px; }
.duel-head, .duel-row { display:grid; align-items:center;
                        grid-template-columns:3.4em minmax(0,1fr) 6.2em minmax(0,1fr) 3.4em; }
.duel-head { height:28px; margin-bottom:4px; font-size:15px; }
.duel-head > :first-child { grid-column:1 / 3; justify-self:end; }
.duel-head > :last-child { grid-column:4 / 6; }
.duel-row { min-height:46px; }
.duel-row.total { border-top:2px solid var(--line); margin-top:4px; }
.duel-label { text-align:center; font-weight:600; }
.duel-row.total .duel-label { font-weight:700; }
.duel-num { font-size:18px; font-weight:500; color:var(--muted); line-height:1.15; }
.duel-num.better { font-weight:700; color:var(--ink); }
.duel-num.r { text-align:right; }
.duel-num small { display:block; font-size:12px; font-weight:400; color:var(--muted); line-height:1; }
.duel-bar { display:block; width:100%; height:14px; }
.duel-bar .track { fill:var(--soft); }
.duel-bar .red { fill:var(--red); }
.duel-bar .yellow { fill:var(--yellow); }
.rpt-cap { font-size:13px; color:var(--muted); margin:8px 0 0; }

/* Thinking time, drawn at the card's own width (Charts.jsx ReportClock). */
.rpt-think-body { display:grid; grid-template-columns:minmax(0,1fr) 260px; gap:40px; }
.rpt-clock { min-width:0; }
.rclock { display:block; height:auto; overflow:visible; }
.rclock.bars { margin-top:18px; }
.rclock text { font-size:13px; fill:var(--muted); }
.rclock .yl { text-anchor:end; }
.rclock .xl { text-anchor:middle; }
.rclock .g { stroke:var(--line); stroke-width:1; }
.rclock .b { stroke:var(--line); stroke-width:1; stroke-dasharray:3 4; }
.rclock .ln { fill:none; stroke-width:2.5; stroke-linejoin:round; }
.rclock .ln.red { stroke:var(--red); }
.rclock .ln.yellow { stroke:var(--yellow); }
.rclock .est { fill:var(--panel); stroke-width:1.5; }
.rclock .est.red { stroke:var(--red); }
.rclock .est.yellow { stroke:var(--yellow); }
.rclock .dot.red { fill:var(--red); }
.rclock .dot.yellow { fill:var(--yellow); }
.rclock .tot { fill:var(--ink); font-size:14px; font-weight:600; }
.rclock .bar { cursor:pointer; }
.rclock .bar:hover { opacity:.65; }
.rclock .bar.red { fill:var(--red); }
.rclock .bar.yellow { fill:var(--yellow); }
.rclock .bar.est { fill:none; stroke-width:1.5; pointer-events:all; }
.rclock .bar.est.red { stroke:var(--red); }
.rclock .bar.est.yellow { stroke:var(--yellow); }
.rclock .median { stroke:var(--ink); stroke-width:1; stroke-dasharray:5 4; opacity:.7; }
.rclock .mlabel, .rclock .blabel { fill:var(--ink); }
.rclock .blabel { font-size:12px; font-weight:600; text-anchor:middle; }
.rpt-clockkey { display:flex; flex-wrap:wrap; gap:6px 16px; font-size:14px; margin:8px 0; }
.rpt-clockkey span { display:inline-flex; align-items:center; gap:6px; font-weight:600; }
.rpt-clockkey.screenonly { font-weight:400; color:var(--muted); font-size:13px; }
.rpt-long h3 { margin-bottom:4px; }
.rpt-long button { all:unset; box-sizing:border-box; width:100%; cursor:pointer;
                   display:grid; grid-template-columns:auto 1fr; column-gap:12px;
                   grid-template-areas:"t who" "t where"; padding:9px 0;
                   border-bottom:1px solid var(--line); }
.rpt-long button:hover .who { text-decoration:underline; }
.rpt-long button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.rpt-long .t { grid-area:t; font-size:17px; font-weight:700; min-width:40px; }
.rpt-long .who { grid-area:who; display:inline-flex; align-items:center; gap:6px; font-weight:600; }
.rpt-long .where { grid-area:where; font-size:13px; color:var(--muted); }

/* Detail: one position-by-type table per team, the header said once. */
.rpt-detail-body { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:48px; }
.rpt-mhead { font-size:17px; margin:0 0 10px; }
.rpt-matrix { width:100%; font-size:16px; }
.rpt-matrix th, .rpt-matrix td { height:36px; padding:0 6px; text-align:center; white-space:nowrap;
                                 border-bottom:1px solid var(--line); font-size:inherit; color:var(--ink); }
.rpt-matrix thead th { height:28px; font-size:13px; font-weight:600; color:var(--muted); }
.rpt-matrix th[scope=row] { text-align:left; font-weight:400; padding-left:26px; }
.rpt-matrix tr.grp > * { background:var(--band); font-weight:700; }
.rpt-matrix tr.grp th[scope=row], .rpt-matrix tr.all th[scope=row] { padding-left:10px; font-weight:700; }
.rpt-matrix tr.all > * { border-top:2px solid var(--line); border-bottom:0; font-weight:700; }
.rpt-matrix .p { font-weight:600; }
.rpt-matrix .none { color:var(--muted); }
.rpt-matrix .n { font-size:13px; color:var(--muted); font-weight:400; margin-left:5px; }
.rpt-matrix .empty { color:var(--line); }

/* Phone and narrow windows: one column, tighter cells, counts under the
   percentage. The by-end table scrolls inside its card (.rpt-scroll) with
   the team column pinned, so a ten-end game never widens the page. */
@media (max-width: 820px) {
  .rpt-top, .rpt-think-body, .rpt-detail-body { grid-template-columns:minmax(0,1fr); }
  .rpt-top.long .rpt-h2h-body { display:flex; }
  .rpt-top.long .rpt-h2h-body > div + div { border-top:1px solid var(--line); padding-top:16px; }
  .rpt-detail-body { gap:28px; }
}
@media (max-width: 640px) {
  #report { padding:16px; }
  .rpt { gap:16px; }
  .rpt .card { padding:16px; }
  .rpt-title { font-size:28px; }
  .rpt-cover { width:100%; min-height:44px; }
  .rpt-byend { font-size:16px; }
  /* 76 + 4 x 46 + 56 fits the 324 px a phone's card holds, header cells
     included: they carried the desktop's 10 px padding and pushed it over. */
  .rpt-byend th, .rpt-byend td { padding:0 4px; }
  .rpt-byend th[scope=row] { min-width:76px; font-size:15px; }
  .rpt-byend td { min-width:46px; height:40px; }
  .rpt-byend td.tot { min-width:56px; }
  .duel-head, .duel-row { grid-template-columns:2.9em minmax(0,1fr) 4.4em minmax(0,1fr) 2.9em; }
  .duel-num { font-size:17px; }
  .rpt-matrix { font-size:15px; }
  .rpt-matrix th, .rpt-matrix td { height:46px; padding:0 2px; }
  .rpt-matrix th[scope=row] { padding-left:12px; white-space:normal; }
  .rpt-matrix .n { display:block; margin:0; line-height:1.1; }
}

/* Entered by hand: a dotted underline wherever a score shows, so a typed-in
   figure never passes for the board's. */
.rpt .entered, #score td.entered, .wsc.entered, .scorekey u.entered {
  text-decoration:underline dotted; text-decoration-thickness:1.5px; text-underline-offset:3px; }
.rpt-byend .sc-q { all:unset; box-sizing:border-box; cursor:pointer; min-width:32px; min-height:32px;
                   display:inline-flex; align-items:center; justify-content:center;
                   border-radius:6px; border:1px dashed var(--line); padding:0 6px; }
.rpt-byend .sc-q:hover { border-color:var(--muted); }
.rpt-byend .sc-q:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
/* all:unset above clears what the cell's own classes say; say it again, or
   the people who can enter scores never see one marked as entered. */
.rpt-byend .sc-q.entered { text-decoration:underline dotted; text-decoration-thickness:1.5px;
                           text-underline-offset:3px; }
.rpt-byend .sc-q.won { font-weight:700; }
.rpt-byend .sc-q.zero, .rpt-byend .sc-q.none { color:var(--muted); }
#scoreDialog { width:min(460px, calc(100vw - 32px)); padding:16px 18px; border:1px solid var(--line);
               border-radius:10px; background:var(--panel); color:var(--ink);
               font-family:"Source Sans 3",system-ui,-apple-system,"Segoe UI",sans-serif; }
#scoreDialog::backdrop { background:rgb(0 0 0 / .35); }
#scoreDialog h2 { margin:0 0 4px; font:inherit; font-size:19px; font-weight:700;
                  text-transform:none; letter-spacing:0; }
#scoreDialog .sc-why { margin:0 0 12px; font-size:14px; color:var(--muted); }
#scoreDialog .sc-blank { width:100%; min-height:44px; margin-bottom:12px; font:inherit; font-weight:600; }
#scoreDialog .sc-row { margin-bottom:12px; }
#scoreDialog .sc-row .rpt-team { margin-bottom:6px; }
#scoreDialog .sc-nums { display:flex; flex-wrap:wrap; gap:6px; }
#scoreDialog .sc-nums button { min-width:44px; min-height:44px; font:inherit; font-size:17px;
                               font-weight:600; font-variant-numeric:tabular-nums; }
#scoreDialog .sc-nums button.on { background:var(--accent); color:var(--onaccent); }
#scoreDialog .sc-error { margin:4px 0 8px; color:var(--warn); font-weight:600; }
#scoreDialog .sc-foot { display:flex; gap:8px; align-items:center; margin-top:4px; }
#scoreDialog .sc-foot button { min-height:44px; padding:0 16px; font:inherit; }

/* --- the clock chart ---------------------------------------------------- */
/* Scales uniformly with the card, so the tick labels keep their proportions
   at phone width; the cap stops it from towering on a wide screen. */
/* Scales uniformly, so the tick labels keep their proportions at any width.
   Bounded by width rather than height: capping the height letterboxes it and
   leaves a quarter of the report card empty on either side. */
.clockchart { display:block; width:100%; height:auto; max-width:820px;
              overflow:visible; }
.clockchart .ln { fill:none; stroke-width:2; vector-effect:non-scaling-stroke;
                  stroke-linejoin:round; }
.clockchart .endshade { fill:var(--accent); fill-opacity:.06; }
.clockchart .ln.red { stroke:var(--red); }
.clockchart .ln.yellow { stroke:var(--yellow); }
.clockchart .g { stroke:var(--line); stroke-width:1;
                 vector-effect:non-scaling-stroke; }
/* End boundaries sit behind the lines and must not compete with them. */
.clockchart .b { stroke:var(--line); stroke-width:1; stroke-dasharray:2 4;
                 vector-effect:non-scaling-stroke; }
.clockchart .yl { fill:var(--muted); font-size:10px; text-anchor:end; }
.clockchart .xl { fill:var(--muted); font-size:10px; text-anchor:middle; }
/* These are viewBox units, and the whole box is scaled down to phone width --
   so the labels have to be drawn larger there to come out the same size. */
@media (max-width:640px) {
  .clockchart .yl, .clockchart .xl { font-size:17px; }
  .clockchart .ln { stroke-width:1.5; }
}
/* In the aside the same 640-unit box is squeezed into a third of the width,
   so its labels need drawing larger there too. */
#clock .clockchart .yl, #clock .clockchart .xl { font-size:24px; }
#clock .clockchart, #thinkingDialog .clockchart { max-width:none; }
#clock .key, #thinkingDialog .key { display:flex; gap:12px; font-size:12px; margin-top:4px; }
#clock .key i.sw, #thinkingDialog .key i.sw { display:inline-block; width:9px; height:9px; border-radius:50%;
                   margin-right:4px; vertical-align:-1px; }
#clock .key i.sw.red, #thinkingDialog .key i.sw.red { background:var(--red); }
#clock .key i.sw.yellow, #thinkingDialog .key i.sw.yellow { background:var(--yellow); }
/* One bar per rock. Clickable, because a tall bar is only useful if it takes
   you to the rock that made it. */
.clockchart .bar { fill:var(--muted); cursor:pointer; }
.clockchart .bar.red { fill:var(--red); }
.clockchart .bar.yellow { fill:var(--yellow); }
.clockchart .bar:hover { opacity:.65; }
/* An assumed interval is drawn hollow, the way an assumed step is on the
   lines: the height is a guess and should not read as a measurement. */
/* pointer-events:all, not the default: a rect with no fill is clickable only
   on its 1.5 px outline, which made every estimated rock a target nobody
   could hit. */
.clockchart .bar.est { fill:none; stroke-width:1.5; pointer-events:all;
                       vector-effect:non-scaling-stroke; }
.clockchart .bar.est.red { stroke:var(--red); }
.clockchart .bar.est.yellow { stroke:var(--yellow); }
/* The game's own median: what "long" means here rather than in the abstract. */
.clockchart .median { stroke:var(--ink); stroke-width:1; stroke-dasharray:4 3;
                      opacity:.5; vector-effect:non-scaling-stroke; }
#clock .key .grow, #thinkingDialog .key .grow { flex:1 1 auto; }
#clock .key button.linky, #thinkingDialog .key button.linky { all:unset; cursor:pointer; color:var(--accent); }
#clock .key button.linky:hover, #thinkingDialog .key button.linky:hover { text-decoration:underline; }

/* Where the viewer is in the game. Faint: it is context for the lines, and
   must not be mistaken for one of them. */
.clockchart .you { stroke:var(--accent); stroke-width:1.5; opacity:.55;
                   vector-effect:non-scaling-stroke; }
/* Hollow, so an estimated step reads as a question rather than a data point. */
.clockchart .est { fill:var(--panel); stroke-width:1.5;
                   vector-effect:non-scaling-stroke; }
.clockchart .est.red { stroke:var(--red); }
.clockchart .est.yellow { stroke:var(--yellow); }

/* --- gathered controls -------------------------------------------------- */
/* `display:contents` lets the menu exist as a container for the phone while
   its children lay out in the header row on desktop, as they always have. */
#menu { display: contents; }
#menuBtn { display: none; }
/* Saving the house as a picture is offered where ⋯ is a menu -- the phone and
   the portrait iPad -- and not in the desktop header's row. */
#houseImgBtn { display: none; }
/* The end at a glance is the desktop's: not in the phone's ⋯ (App.jsx does
   not render it on the portrait iPad). */
@media (max-width: 640px) { #endBtn { display: none; } }
.transport { margin-top: 10px; }
/* Base is (1,0,0); the phone's open-state `margin: 0` is (1,1,1) and still
   wins, so this only takes effect once the inline style it replaces is gone. */
#playback { margin-top: 6px; }

/* --- desktop header order ----------------------------------------------- */
/* Gathering six controls into #menu restored their boxes (display:contents
   keeps them flex items of the header) but not their place in the row: in
   source order they now follow the .grow spacer, which threw the game and end
   selects to the far right and pulled `saved` left of the group. `order` puts
   the row back exactly as it was without moving a node -- the same technique
   .transport already uses. Every selector here is an id or a child of header,
   so nothing competes with it; the .grow spacer is matched as `header > .grow`
   because .grow is also used inside .transport and .tools, where every sibling
   is still at the initial `order: 0` and reordering one would move it last.
   #end .. #reportBtn cannot take the child combinator: display:contents does
   not flatten the DOM, so #menu is still their parent. */
@media (min-width: 641px) {
  header > h1        { order: 1; }
  header > #src      { order: 2; }
  header #end        { order: 4; }
  header > .grow     { order: 5; }
  header > #blanks   { order: 6; }
  header #copyLink   { order: 7; }
  header #shareLink  { order: 8; }
  header > #save     { order: 9; }
  header > #viewOnly       { order: 9; }
  header > #viewOnlySignIn { order: 9; }
  header #download   { order: 10; }
  /* Before Report -- and in the wide layout before Thinking, which shares
     its 11 and follows it in the source. */
  header #endBtn     { order: 11; }
  header #reportBtn  { order: 11; }
  header #flagBtn    { order: 12; }
  header #playedBtn  { order: 13; }
  header #teamsBtn   { order: 14; }
  header #clipBtn    { order: 15; }
}

/* --- flag dialog ---------------------------------------------------------- */
/* A modal <dialog> is in the top layer, above the phone shell and #menu, so
   it needs no z-index -- only never to be inside a hidden parent (App.jsx). */
#flagDialog { width: min(440px, calc(100vw - 32px)); padding: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); }
#flagDialog::backdrop { background: rgb(0 0 0 / .35); }
#flagDialog h2 { margin: 0 0 4px; font: 600 18px var(--display); }
#flagDialog .flagPlace { margin: 0 0 10px; color: var(--muted); }
#flagDialog textarea { display: block; width: 100%; box-sizing: border-box;
  min-height: 120px; padding: 8px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
#flagDialog .flagWho { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
#flagDialog .flagError { margin: 8px 0 0; color: var(--warn); }
#flagDialog .flagButtons { display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 12px; }
#flagDialog .flagThanks { margin: 8px 0; font-weight: 600; }

/* --- "I played…" dialog --------------------------------------------------- */
#playedDialog { width: min(460px, calc(100vw - 32px)); padding: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); }
#playedDialog::backdrop { background: rgb(0 0 0 / .35); }
#playedDialog h2 { margin: 0 0 4px; font: 600 18px var(--display); }
#playedDialog .pl-why, #playedDialog .pl-who { margin: 0 0 12px; color: var(--muted); }
#playedDialog .pl-teams, #playedDialog .pl-slots { display: grid; gap: 6px; margin-bottom: 12px; }
#playedDialog .pl-teams { grid-template-columns: 1fr 1fr; }
#playedDialog .pl-slots { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); }
#playedDialog .pl-teams button, #playedDialog .pl-slots button {
  min-height: 44px; padding: 6px 10px; font: inherit; text-align: left;
  display: flex; align-items: center; gap: 8px; }
#playedDialog .pl-slots button { flex-direction: column; align-items: flex-start; gap: 0; }
#playedDialog .pl-slots button span { font-size: 13px; color: var(--muted); }
#playedDialog button.on { background: var(--accent); color: var(--onaccent); }
#playedDialog button.on span { color: inherit; }
#playedDialog .dot { width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 1px solid rgb(0 0 0 / .25); }
#playedDialog .dot.red { background: var(--red); }
#playedDialog .dot.yellow { background: var(--yellow); }
#playedDialog .pl-note { margin: 0 0 10px; font-size: 13px; color: var(--warn); }
#playedDialog .pl-error { margin: 0 0 10px; color: var(--warn); font-weight: 600; }
#playedDialog .pl-saved { margin: 8px 0; font-weight: 600; }
#playedDialog .pl-foot { display: flex; justify-content: flex-end; gap: 8px; }
#playedDialog .pl-foot button { min-height: 44px; padding: 0 16px; font: inherit; }
#playedDialog .pl-clear { margin-right: auto; }
/* A doubles pair that switched order: the checkbox, then the game's ends, each
   saying which rocks were this player's; an end they threw the other way is
   picked out in the warning colour, the first end (who is who) dashed. */
#playedDialog .pl-switch { display: flex; align-items: center; gap: 10px; min-height: 44px;
  margin-bottom: 6px; cursor: pointer; }
#playedDialog .pl-switch input { width: 20px; height: 20px; margin: 0; }
#playedDialog .pl-hint { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
#playedDialog .pl-ends { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px; margin-bottom: 10px; }
#playedDialog .pl-ends button { min-height: 44px; padding: 6px 8px; font: inherit; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; }
#playedDialog .pl-ends button span { font-size: 13px; color: var(--muted); }
#playedDialog .pl-ends button.flip { border-color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }
#playedDialog .pl-ends button.flip span { color: var(--warn); }
#playedDialog .pl-ends button:disabled { border-style: dashed; opacity: 1; cursor: default; }

/* --- "Clip…" dialog ------------------------------------------------------ */
/* Teams…'s look. The clip is portrait (600x810), so it is held to a
   height that leaves the buttons on screen. */
#clipDialog { width: min(440px, calc(100vw - 32px)); padding: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); }
#clipDialog::backdrop { background: rgb(0 0 0 / .35); }
#clipDialog h2 { margin: 0 0 4px; font: 600 18px var(--display); }
#clipDialog .sc-what { margin: 0 0 12px; color: var(--muted); }
#clipDialog .sc-say { margin: 0 0 12px; }
#clipDialog .sc-working { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
#clipDialog .sc-spinner { flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: sc-spin .9s linear infinite; }
@keyframes sc-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  #clipDialog .sc-spinner { animation-duration: 3s; } }
#clipDialog .sc-video { display: block; width: auto; max-width: 100%;
  max-height: min(60vh, 540px); margin: 0 auto 8px; background: #000; border-radius: 6px; }
#clipDialog .sc-legend { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
#clipDialog .sc-error { margin: 0 0 10px; color: var(--warn); font-weight: 600; }
#clipDialog .sc-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
#clipDialog .sc-foot button, #clipDialog .sc-foot a { min-height: 44px; padding: 0 16px;
  font: inherit; display: inline-flex; align-items: center; }
#clipDialog .on { background: var(--accent); color: var(--onaccent); border-radius: 6px;
  text-decoration: none; }

/* --- "Teams…" dialog ------------------------------------------------------- */
/* I played…'s look. The boxes are 16px so a phone does not zoom in on them. */
#teamsDialog { width: min(420px, calc(100vw - 32px)); padding: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); }
#teamsDialog::backdrop { background: rgb(0 0 0 / .35); }
#teamsDialog h2 { margin: 0 0 4px; font: 600 18px var(--display); }
#teamsDialog .tm-why, #teamsDialog .tm-who { margin: 0 0 12px; color: var(--muted); }
#teamsDialog .tm-public { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
#teamsDialog .tm-public a { color: inherit; }
#teamsDialog .tm-team { display: grid; grid-template-columns: 12px 4.5em 1fr;
  align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; }
#teamsDialog .tm-three { display: flex; align-items: center; gap: 8px; min-height: 44px;
  margin: -8px 0 10px calc(12px + 4.5em + 16px); color: var(--muted); font-weight: 400; }
#teamsDialog .tm-three input { width: 20px; height: 20px; margin: 0;
  accent-color: var(--accent); }
#teamsDialog .tm-team input { min-height: 44px; padding: 0 10px; font: inherit;
  font-size: 16px; font-weight: 400; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; min-width: 0; }
#teamsDialog .dot { width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgb(0 0 0 / .25); }
#teamsDialog .dot.red { background: var(--red); }
#teamsDialog .dot.yellow { background: var(--yellow); }
#teamsDialog button.on { background: var(--accent); color: var(--onaccent); }
#teamsDialog .tm-error { margin: 0 0 10px; color: var(--warn); font-weight: 600; }
#teamsDialog .tm-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
#teamsDialog .tm-foot button { min-height: 44px; padding: 0 16px; font: inherit; }
/* The names the league already uses (NameBox.jsx), under the box being typed
   in: chips a thumb can hit, wrapping onto a second line rather than
   scrolling. The lit one is the one Enter takes. */
#teamsDialog .namelist { grid-column: 3; display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0; padding: 0; list-style: none; font-weight: 400; }
#teamsDialog .namelist li { min-height: 40px; padding: 0 12px; display: flex;
  align-items: center; border: 1px solid var(--line); border-radius: 20px;
  background: var(--soft); cursor: pointer; }
#teamsDialog .namelist li[aria-selected="true"] { background: var(--accent);
  color: var(--onaccent); border-color: transparent; }
@media (hover: hover) { #teamsDialog .namelist li:hover { border-color: var(--ink); } }

/* --- phone-only elements: present, wired, dormant on desktop ------------ */
#stoneChip, #sheetHandle, #orderRow, .housebar, #placeStones { display: none; }
/* Not in that group: #renumbered is a role="status" live region, and a live
   region inside `display:none` is not in the accessibility tree, so it never
   announces. The desktop chip strip is a purely visual signal -- a screen
   reader has nothing else to tell it the end just renumbered -- so the region
   stays in the tree at every width and is clipped out of sight instead, with
   the same technique .sr uses below. The phone block, which shows it as a
   toast, undoes each of these four declarations by name. */
#renumbered { position:absolute; width:1px; height:1px; overflow:hidden;
              clip-path:inset(50%); }
/* Restated: an id selector outranks the UA [hidden] rule, so once Task 4
   gives #stoneChip a display:grid inside the phone block, chip.hidden = true
   must still win. That restatement is enough for #stoneChip, whose only
   competing author rule is the bare id above, at (1,0,0) -- #stoneChip[hidden]
   at (1,1,0) beats it outright.
   #placeStones and #orderRow are not that simple: the blank-peek and
   open-sheet rules below turn them on with `body[data-peek=...][data-sheet=...]
   #id`, which is (1,2,1) (open-sheet's is (1,1,1)) -- both outrank a bare
   [hidden] override's (1,1,0), id count tied and class/attr count losing.
   So restating [hidden] here is necessary (it is still what governs the
   default, unadorned phone state) but not sufficient; those two rules also
   carry `:not([hidden])` so they do not match at all -- rather than lose a
   specificity fight -- once READ_ONLY sets `.hidden = true`. */
#stoneChip[hidden], #placeStones[hidden], #orderRow[hidden] { display: none; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }

@media print {
  header, main, .noprint { display:none !important; }
  #report { display:block !important; padding:0; font-size:12px; }
  @page { size:letter; margin:0.45in; }
  /* Paper is white whatever the device is doing. The dark tokens are set by
     :root:not([data-theme="light"]) at (0,2,0), so the list repeats that
     selector to win by order rather than lose by specificity. */
  :root, :root:not([data-theme="light"]) {
    --bg:#fff; --panel:#fff; --ink:#16130c; --muted:#5f574a; --line:#d9d2bf;
    --soft:#eee8da; --band:#f6f3ec; --warn:#7a440c; --warnbg:#f3e3c6; --accent:#16130c;
  }
  body { background:#fff; }
  .card { break-inside:avoid; border-color:#ccc; }
  .rpt { gap:8px; max-width:none; }
  .rpt .card { border:0; border-radius:0; padding:0; }
  .rpt .screenonly { display:none !important; }
  .rpt .sub { display:none; }
  .rpt h2 { font-size:12px; text-transform:uppercase; letter-spacing:.06em; margin-bottom:4px; }
  .rpt-head { padding-bottom:8px; border-bottom:2px solid var(--ink); }
  .rpt-title { font-size:22px; }
  .rpt-meta { font-size:11px; }
  .rpt-cover { background:none; padding:0; min-height:0; color:var(--muted);
               font-size:11px; font-weight:400; }
  .rpt-top { grid-template-columns:minmax(0,1fr); gap:12px; }
  .rpt-byend { font-size:12.5px; }
  .rpt-byend th, .rpt-byend td { height:22px; }
  /* Paper keeps every column: no scroller, and none of the screen's
     minimum widths, so a ten-end game still prints its Total. */
  .rpt-scroll { overflow:visible; }
  .rpt-byend th, .rpt-byend td { min-width:0; padding:0 4px; }
  .rpt-byend td.tot { min-width:0; }
  .rpt-byend th[scope=row] { min-width:0; padding:0 10px 0 0; font-size:12.5px; }
  .rpt-byend tr.blk th { height:18px; font-size:9.5px; }
  .rpt-key { font-size:10px; margin-top:6px; }
  .rpt-rule { margin:8px 0; }
  .rpt-notes p { font-size:10px; margin-bottom:3px; }
  .rpt h3 { font-size:11px; }
  /* By shot type is the detail's group rows again, side by side; on paper the
     detail says it once, and the page fits one sheet. */
  .rpt-h2h-body > div + div { display:none; }
  .rpt-h2h-body, .rpt-top.long .rpt-h2h-body { display:block; }
  .duel-head { font-size:12px; height:20px; }
  .duel-row { min-height:24px; }
  .duel-num { font-size:12.5px; }
  .duel-num small { font-size:9px; }
  .duel-bar { height:10px; }
  .rpt-cap { font-size:10px; margin-top:4px; }
  .rpt-think-body { grid-template-columns:minmax(0,1fr); }
  .rclock.lines { max-height:1.4in; width:auto; max-width:100%; }
  /* Paper is ~730 CSS px across, inside the narrow-window rule above, which
     would stack the two teams' tables; side by side they fit the sheet. */
  .rpt-detail-body { grid-template-columns:repeat(2, minmax(0,1fr)); gap:20px; }
  .rpt-matrix th, .rpt-matrix td { padding:0 3px; }
  .rpt-mhead { font-size:12px; margin-bottom:4px; }
  .rpt-matrix { font-size:11.5px; }
  .rpt-matrix th, .rpt-matrix td { height:20px; }
  .rpt-matrix .n { font-size:9.5px; }
  .rpt-matrix tr.type { display:none; }
  .rpt-byend .sc-q { border:0; padding:0; }
  #scoreDialog { display:none; }
}

/* --- view-only mode ---------------------------------------------------- */
body[data-mode="view"] .tools, body[data-mode="view"] #typeGroups,
body[data-mode="view"] #typeList, body[data-mode="view"] #scoreBtns,
body[data-mode="view"] #missReason, body[data-mode="view"] #note { pointer-events:none; opacity:.6; }
body[data-mode="view"] #house { cursor:default; }

/* Review is not a dimmed editor -- it is a different tool. A view link shows
   someone's grading, so its controls stay visible and inert; a review link has
   no grading to show, so the controls would be furniture. What is left is the
   reason to come here at all: the video, the shots, and the house. */
body[data-mode="review"] #grading,
body[data-mode="review"] #queueBox,
body[data-mode="review"] #markCharted,
body[data-mode="review"] #blanks,
body[data-mode="review"] #save,
body[data-mode="review"] #download,
body[data-mode="review"] #reportBtn,
body[data-mode="review"] #houseCard .tools,
body[data-mode="review"] .housebar { display: none; }
body[data-mode="review"] #house { cursor:default; }

/* A guarded chart this person may not edit says so where the save status
   would be (ViewOnly.jsx): the whole line on a desktop, "View only" on a
   phone, whose header is one 48px row. */
#viewOnly { white-space: normal; }
#viewOnly .short { display: none; }

/* Watch mode is a phone layout only. At every other width the read-only
   surfaces keep the desktop three-column page they have always had. */
#watch { display: none; }
/* The phone header's end picker: the phone block shows it. */
#endQuick { display: none; }

/* --- phone -------------------------------------------------------------- */
/* A fixed-height shell, not a scrolling page: the video pins at the top, the
   house takes what is left, and the chart panel becomes a sheet over both.
   Everything is placed with fixed/absolute positioning because the player
   iframe must never be reparented -- see app.js's one-player invariant. */
@media (max-width: 640px) and (min-height: 461px) {
  body { height: 100dvh; overflow: hidden; }
  /* The video's height, which the house, the flags, the open sheet and the
     watching panes all hang from. 16:9 of the full width, except on a short
     phone (below): one variable so they move together. */
  body { --vid: 56.25vw; }
  /* The sheet's height, which the house and the rock strip sit on: the
     charting buttons' 256px, or 112px folded down to its grip over the bar
     (32 + the bar's 80). One variable, as --vid is, so they move together. */
  body { --sheet: 256px; --strip: 40px; }
  body[data-sheet="min"] { --sheet: calc(112px + env(safe-area-inset-bottom)); }
  /* The shell is a fixed-height page; the report is not. It is a sibling of
     main in normal flow, taller than any phone screen, and `overflow:hidden`
     on the body would leave everything past the first screenful unreachable
     -- no scrollbar, no pan. (0,1,1) over the (0,0,1) above. */
  body.reporting { height: auto; overflow: auto; }

  header { height: 48px; padding: 0 8px 0 12px; flex-wrap: nowrap; gap: 8px; }
  header > h1, #src { display: none; }
  /* #save is the only channel that says a save is not landing -- "not saved
     -- use ⬇", or "reloaded -- someone else saved", which silently replaces
     the charter's overrides with somebody else's. A phone is the likeliest
     place to be on flaky data, so the failure states stay on screen; setSave()
     marks exactly those with .bad, and everything quieter (.ok "saved", and
     the class-less "•" and "saving…") is hidden. */
  #save:not(.bad) { display: none; }
  #menuBtn { display: grid; place-items: center; width: 44px; height: 44px;
             flex: 0 0 44px; padding: 0; border-color: transparent; }
  /* The playback settings stay in #playCard -- moving them into #menu changed
     the desktop header -- so the phone lifts both panels into one full-width
     dropdown at fixed offsets, rather than one guessing the other's height. */
  #menu, #playback { display: none; }
  body[data-menu="open"] #menu,
  body[data-menu="open"] #playback {
    /* Above the edit-mode house (z-index 8/9): the menu must still open over
       the full-screen editor, and #menuBtn stays tappable in the header
       while the editor is showing. */
    position: fixed; left: 0; right: 0; z-index: 10; margin: 0;
    background: var(--panel); padding: 10px 12px;
    border-bottom: 1px solid var(--line); }
  /* 64px, not 52: the panel is border-box with 10px of vertical padding, and
     its two labels are 44px touch targets -- 52px left them 32px and they
     overflowed into the header above and the menu's padding below. #menu's
     top follows it: 48 + 64. */
  /* 112px since the lead-in joined the two checkboxes: three controls do not
     fit one row of a phone (385 px on the iPhone Duo, 390 on most), and the
     third wrapped out of a 64px panel onto the menu's end picker, covering
     it. Two rows of 44px, 4px between, the same 10px of padding: 48 + 112. */
  body[data-menu="open"] #playback { display: flex; flex-wrap: wrap; top: 48px; height: 112px;
    align-items: center; align-content: center; gap: 4px 14px; }
  body[data-menu="open"] #menu { display: grid; top: 160px; gap: 8px;
    max-height: calc(100dvh - 160px); box-sizing: border-box; overflow-y: auto;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 6px 24px rgb(0 0 0 / .18); }
  #menu > * { width: 100%; height: 44px; }
  #houseImgBtn { display: block; }
  /* The header does not wrap here, so when #save is showing a failure the two
     pills have to share what is left of a narrow one. The failure is the
     message that matters, so it is the one that never shrinks; the charting
     count gives way and ellipsises instead. .pill's white-space:nowrap stands. */
  #blanks { min-height: 44px; min-width: 0; overflow: hidden;
            text-overflow: ellipsis; }
  #save { flex: 0 0 auto; }
  #viewOnly { flex: 0 0 auto; white-space: nowrap; }
  #viewOnly .long { display: none; }
  #viewOnly .short { display: inline; }
  #viewOnlySignIn { min-height: 44px; flex: 0 0 auto; }
  #playback label.chk { min-height: 44px; }

  #stoneChip { display: grid; place-items: center; flex: 0 0 40px;
               width: 40px; height: 40px; border-radius: 7px; font-size: 15px;
               font-weight: 650; font-variant-numeric: tabular-nums;
               border: 1px solid transparent; }
  /* The end, named beside the rock, and the picker for another (App.jsx). */
  #endQuick { display: inline-flex; align-items: center; position: relative; flex: 0 0 auto;
              min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
              font-family: var(--display); font-size: 15px; font-weight: 700; white-space: nowrap; }
  #endQuick .eq-of, #endQuick .eq-caret { font-weight: 400; color: var(--muted); }
  #endQuick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
                     font-size: 16px; cursor: pointer; }
  body[data-mode="view"] #endQuick, body[data-mode="review"] #endQuick { display: none; }
  /* ...so the menu need not carry the same picker twice. */
  #menu > #end { display: none; }
  #stoneChip.red { background: var(--red); color: #fff; }
  #stoneChip.yellow { background: var(--yellow); color: #1a1a1a; }
  #stoneChip.unknown { background: var(--panel); color: var(--warn);
                       border: 2px dashed var(--warn); }

  main { display: block; padding: 0; margin: 0;
         height: calc(100dvh - 48px); }
  main > .card { border: 0; border-radius: 0; padding: 0; background: none; }

  /* the video keeps its own box at the top; the house fills the gap down to
     the sheet, and #chart is lifted out of flow onto the bottom of the screen */
  /* The end's rocks, one tap each, in a row on top of the sheet: without it
     the only way to another rock was one step at a time. Sixteen share the
     width, so each is narrow (21px on a 385px phone) but 32px tall, and the
     arrows and the swipe are still there. Not while the form is open (it
     covers the house to the video), not in the stone editor, and not on a
     view-only page, which has its own pager. */
  #playCard .shots { display: flex; flex-wrap: nowrap; gap: 2px; position: fixed; z-index: 4;
                     left: 0; right: 0; bottom: var(--sheet); height: var(--strip);
                     box-sizing: border-box; margin: 0; padding: 4px 8px; background: var(--bg); }
  #playCard .shots .shot { flex: 1 1 0; width: auto; min-width: 0; height: 32px; font-size: 12px; }
  body[data-sheet="open"] #playCard .shots,
  body[data-house="edit"] #playCard .shots,
  body[data-mode="view"] #playCard .shots,
  body[data-mode="review"] #playCard .shots { display: none; }
  /* No min-height: with one it would be over-constrained, `bottom` would be
     dropped, and the box would grow down behind the sheet -- so the measured
     box and the visible box would differ and the crop, centred in the former,
     would hide the front of the house behind the sheet. Exactly the gap
     between the video and the sheet means the tee is centred in what the user
     actually sees. A short phone then gets a tighter crop, not a hidden one. */
  #houseCard { position: fixed; top: calc(48px + var(--vid)); bottom: calc(var(--sheet) + var(--strip));
               left: 0; right: 0; overflow: hidden; }
  #houseCard .tools { display: none; }
  #house { height: 100%; }
  #houseCard .muted { display: none; }

  /* Full-screen editing: the house band takes the whole screen between the
     header and its own toolbar, the video and chart are underneath but
     never torn down -- #houseCard's own solid background is what hides
     them, so #playCard stays in flow and its iframe stays alive. */
  /* 114px clears the swatch bar and the housebar below it; both of those are
     themselves offset by the safe area, so this must be too, or the bottom of
     the editor's house sits behind an opaque toolbar on a home-indicator phone. */
  body[data-house="edit"] #houseCard { top: 48px; z-index: 8;
                                       bottom: calc(114px + env(safe-area-inset-bottom));
                                       background: var(--bg); }
  body[data-house="edit"] #chart,
  body[data-house="edit"] .transport { display: none; }
  /* #houseCard .tools is (1,1,0) and hides the swatch bar above; matching
     that id here, not just the class, is what lets this (1,2,1) rule win. */
  body[data-house="edit"] #houseCard .tools { display: flex; flex-wrap: nowrap;
    position: fixed; z-index: 9; left: 0; right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom));
    height: 56px; margin: 0; padding: 0 12px; background: var(--panel);
    border-top: 1px solid var(--line); }
  body[data-house="edit"] .housebar { display: flex; gap: 8px; position: fixed;
    z-index: 9; left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom)); }
  body[data-house="edit"] #houseDone { flex: 1 1 auto; height: 46px;
    background: var(--accent); color: var(--onaccent); border-color: transparent; }
  body[data-house="edit"] #recolour { flex: 0 0 56px; height: 46px; }
  /* The blank-shot "place the stones" warning in #flags is exactly the
     prompt this mode exists to act on, so it must stay above the editor
     and reachable at the header's height, not the collapsed band's. */
  body[data-house="edit"] #flags { z-index: 9; top: 48px; }

  #flags { position: fixed; top: calc(48px + var(--vid)); left: 0; right: 0;
           z-index: 3; max-height: 92px; overflow-y: auto; padding: 0 10px; }
  #flags:empty { display: none; }

  #chart { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
           height: var(--sheet); border-radius: 16px 16px 0 0; border: 0;
           border-top: 1px solid var(--line); background: var(--panel);
           box-shadow: 0 -3px 14px rgb(0 0 0 / .08);
           padding: 0 12px calc(84px + env(safe-area-inset-bottom));
           overflow: hidden; }
  #chart h2, #chart h3, #chart dl, #chart details,
  #chart #autoType, #orderBox h3, #orderBox .muted { display: none; }
  /* The real <select> sits invisibly over its own label, so the tap that opens
     the native picker is a real one on the control itself: showPicker() is not
     universal (Firefox has none for <select>) and a synthetic click on a
     <select> opens nothing in any browser, so forwarding left #orderRow dead --
     and #orderRow is the promoted control on a blank, the fast path the phone
     layout is built around. The geometry is stated on #orderBox rather than
     left to #orderRow's margin, which would collapse out of an unpadded parent
     and put the overlay 12px low. It is shown by exactly the two rules that
     show #orderRow, and by nothing else, so an invisible full-width control can
     never sit over something it is not labelling. */
  #orderBox { position: relative; margin-top: 12px; }
  #orderBox #moveBefore { display: none; position: absolute; top: 0;
                          left: 0; right: 0; width: auto; height: 44px;
                          margin: 0; opacity: 0; }

  /* Floated over the house rather than placed in the sheet, so nothing
     reflows when it arrives or leaves. This is (1,0,0), tied with the base
     `#renumbered` rule that clips the live region out of sight at every other
     width, and lands later -- so it wins, and has to undo each of that rule's
     four declarations by name to do it. */
  #renumbered { display: block; position: fixed; z-index: 6;
                width: auto; height: auto; overflow: visible; clip-path: none;
                left: 12px; right: 12px; bottom: calc(var(--sheet) + var(--strip) + 12px);
                background: var(--ink); color: var(--bg); font-size: 13px;
                line-height: 1.35; border-radius: 9px; padding: 10px 12px;
                box-shadow: 0 2px 12px rgb(0 0 0 / .22); }
  /* :empty, not [hidden]: the region has to stay in the accessibility tree to
     announce at all, so renderChart() only ever changes its text. (1,1,0). */
  #renumbered:empty { display: none; }
  /* Same idiom as the peek state: the toast's bottom edge sits 12px above the
     sheet's top edge, whatever height the sheet currently has. In the open
     state that floats it over the video's lower edge, which is the only free
     space -- the video and the sheet are contiguous. */
  body[data-sheet="open"] #renumbered {
    bottom: calc(100dvh - 48px - var(--vid) + 12px);
  }

  /* #chart #sheetHandle, not #sheetHandle: the 44px touch-target rule below is
     `#chart button` at (1,0,1) and min-height beats height, so a bare id
     selector loses and the handle is silently 44px -- eating the 12px that is
     the peek's entire slack. This is (2,0,1), and the min-height is restated
     because that is the declaration actually being overridden. The grip is the
     visible target; the sheet also opens from the chips and the form below. */
  #chart #sheetHandle { display: block; width: 100%; height: 32px;
                        min-height: 32px; border: 0;
                        background: none; padding: 0; touch-action: none; }
  #sheetHandle .grip { display: block; width: 36px; height: 4px; margin: 0 auto;
                       border-radius: 2px; background: var(--line); }

  /* the transport is its own fixed layer so it can sit visually inside the
     sheet without being its child -- which is what lets it live in #playCard */
  .transport { position: fixed; left: 12px; right: 12px; z-index: 5;
               bottom: calc(24px + env(safe-area-inset-bottom));
               margin: 0; gap: 8px; flex-wrap: nowrap; }
  /* The bar's own band, opaque, from 8px above the buttons to the bottom of
     the screen and the sheet's full width, in the sheet's colour. Without it
     the bar floats over a sheet that scrolls, and whatever is scrolled under
     its gaps and margins takes the tap: the open doubles sheet put a swap
     checkbox there. Now a tap beside a button lands on the bar and does
     nothing. A child of .transport (a stacking context: fixed, z-index 5), so
     z-index -1 paints it under the buttons and still over the sheet (4), and
     it goes -- and hides -- wherever the bar does. The sheet's 84px of bottom
     padding is what lets its last row scroll clear of these 80. */
  .transport::before { content: ""; position: absolute; z-index: -1;
                       top: -8px; left: -12px; right: -12px;
                       bottom: calc(-24px - env(safe-area-inset-bottom));
                       background: var(--panel); }
  .transport button { height: 48px; flex: 0 0 56px; padding: 0; }
  .transport #label, .transport #link { display: none; }
  .transport #prev { order: 1; }
  .transport #replay { order: 2; }
  .transport #markCharted { order: 3; flex: 1 1 auto; background: var(--accent);
                            color: var(--onaccent); border-color: transparent; }
  .transport #next { order: 4; }

  /* touch targets */
  .pick button, .scorebtns button, .swatchbtn, .shot,
  #chart button, #chart select, #chart input { min-height: 44px; }
  .scorebtns button { flex: 1 1 0; width: auto; height: 48px; }
  .swatchbtn { width: 44px; height: 44px; }
  .pick { gap: 8px; }
  .pick button { padding: 0 14px; font-size: 13px; }

  /* the sheet's open state: it grows to cover the house down to the video,
     scrolls its own content, and reveals the full form */
  body[data-sheet="open"] #chart {
    height: calc(100dvh - 48px - var(--vid));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* the full form only exists in the open state. The child combinator on
     h3 matters: Score/Miss reason/Note are direct children of #chart, but
     the Order heading lives inside #orderBox -- #orderRow fronts that
     control on the phone, so its own heading must stay hidden. */
  body[data-sheet="open"] #chart > h3,
  body[data-sheet="open"] #chart #typeList,
  body[data-sheet="open"] #chart #missReason,
  body[data-sheet="open"] #chart #note { display: block; }
  /* Expanding the sheet must never take a control away, so the blank's
     "Place the stones" comes along into the open state too. */
  body[data-sheet="open"] #orderRow:not([hidden]),
  body[data-sheet="open"] #placeStones:not([hidden]) { display: flex; }
  /* #endBox too: the peek has no room for it, and what it would render into
     is the 84px of padding under the fixed transport bar -- where a tap beside
     a transport button landed on a swap label and saved a swap. */
  /* Folded down: the grip alone, over the bar. */
  body[data-sheet="min"] #chart > *:not(#sheetHandle) { display: none; }
  body[data-sheet="peek"] #chart #typeList,
  body[data-sheet="peek"] #chart #missReason,
  body[data-sheet="peek"] #chart #note,
  body[data-sheet="peek"] #chart #endBox { display: none; }

  /* No `display` here: Task 3 hides #orderRow globally at the same specificity,
     and this rule lands later, so declaring one would show it in every state.
     The open state and Task 7's blank peek each turn it on deliberately. */
  /* margin-top: 0 -- the 12px above the row is #orderBox's, so the invisible
     select over it can be positioned from a box whose top edge is the row's. */
  #orderRow { width: 100%; height: 44px; align-items: center;
              gap: 10px; margin-top: 0; text-align: left; }

  /* A rock nobody saw cannot be usefully graded, so its peek asks the two
     questions that can be answered: where was it thrown, and what was on the
     ice. The grade row comes back as soon as the sheet is opened or the house
     has been placed and the shot marked charted. */
  /* No `display` here, for the same reason as #orderRow: the global hide is the
     same specificity and lands earlier, so the blank peek turns it on instead. */
  #placeStones { width: 100%; height: 44px; align-items: center;
                 justify-content: center; margin-top: 8px; }
  body[data-peek="order"][data-sheet="peek"] #typeGroups,
  body[data-peek="order"][data-sheet="peek"] .scorebtns { display: none; }
  body[data-peek="order"][data-sheet="peek"] #orderRow:not([hidden]),
  body[data-peek="order"][data-sheet="peek"] #placeStones:not([hidden]) { display: flex; }
  /* The overlay follows #orderRow exactly: (2,2,0) beats #orderBox #moveBefore's
     (2,0,0), and :not([hidden]) means READ_ONLY's hidden row takes it with it. */
  body[data-sheet="open"] #orderRow:not([hidden]) ~ #moveBefore,
  body[data-peek="order"][data-sheet="peek"] #orderRow:not([hidden]) ~ #moveBefore {
    display: block; }
  body[data-peek="order"][data-sheet="peek"] #orderRow { border-color: var(--accent); }

  /* --- watch mode ------------------------------------------------------- */
  /* The read-only surfaces get a different instrument, not a dimmed one. The
     charting shell is a sheet built to hold a grade row; with the grading
     hidden it is an empty 256px panel, and #detail, #clockBox and #scoreBox
     were never reachable on a phone in any mode. So on /s/ and /g/ the page
     becomes the end as a list of its rocks, each carrying its own
     thinking-time bar.

     #playCard is left exactly where it is in the document and pinned by CSS.
     The player must never be reparented, so nothing here moves it -- the same
     reason the house editor hides the video behind an opaque background
     instead of unmounting it. */
  body[data-mode="view"] main > *:not(#playCard),
  body[data-mode="review"] main > *:not(#playCard) { display: none; }
  body[data-mode="view"] #watch,
  body[data-mode="review"] #watch { display: flex; }
  /* The report replaces the watching layout while it is open, as it replaces
     main: #watch is fixed over the page and would otherwise cover it. */
  body.reporting[data-mode="view"] #watch,
  body.reporting[data-mode="review"] #watch { display: none; }

  /* #playCard stays for the player's sake, but its charting furniture does
     not: the list is the transport now, and the flags are a charting prompt
     ("this rock needs placing") addressed to somebody who cannot place it. */
  body[data-mode="view"] #transport, body[data-mode="review"] #transport,
  body[data-mode="view"] #playback,  body[data-mode="review"] #playback,
  body[data-mode="view"] #flags,     body[data-mode="review"] #flags,
  body[data-mode="view"] #stoneChip, body[data-mode="review"] #stoneChip {
    display: none; }
  /* The phone hides these to buy room for the grade row. Watch mode has room,
     and a header saying nothing at all is worse than one saying where you are. */
  body[data-mode="view"] header > h1, body[data-mode="review"] header > h1,
  body[data-mode="view"] #src, body[data-mode="review"] #src { display: block; }
  /* Except on a chart this person may not edit: the view-only line and Sign
     in need that room, or they and the menu are pushed off the screen. The
     video's own title is right below, and the name ellipsises if it must. */
  body:has(#viewOnly) #src { display: none; }
  body:has(#viewOnly) header > h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  #watch { position: fixed; left: 0; right: 0; top: calc(48px + var(--vid));
           bottom: 0; z-index: 4; flex-direction: column;
           background: var(--bg); }

  /* Four tabs at the thumb. 52px, not taller: every pixel here is one the
     House tab's house does not get, and 52 still clears a 44px target. */
  .wtabs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
           height: calc(52px + env(safe-area-inset-bottom));
           padding-bottom: env(safe-area-inset-bottom);
           display: flex; background: var(--panel);
           border-top: 1px solid var(--line); }
  .wtabs button { flex: 1; border: 0; border-top: 3px solid transparent;
                  background: none; font: inherit; font-size: 13px;
                  color: var(--muted); }
  .wtabs button[aria-current] { color: var(--accent); font-weight: 700;
                                border-top-color: var(--accent); }

  /* The rock you are on, and the way to the next. */
  .wpager { height: 56px; flex: none; display: flex; align-items: center;
            padding: 0 4px; background: var(--panel);
            border-bottom: 1px solid var(--line); }
  .wpager > button { width: 44px; height: 44px; border: 0; background: none;
                     font-size: 22px; color: var(--accent); flex: none; }
  .wpager > button:disabled { color: var(--muted); opacity: .35; }
  .wpmid { flex: 1; min-width: 0; display: flex; flex-direction: column;
           align-items: center; gap: 5px; position: relative; align-self: stretch;
           justify-content: center; border-radius: 8px; }
  .wptop { display: flex; align-items: center; gap: 8px; font-size: 13px;
           font-weight: 600; min-width: 0; white-space: nowrap; }
  .wpcaret { margin-left: -4px; font-size: 11px; color: var(--accent); }
  /* The end picker: the whole middle of the pager is its tap target, and the
     select itself is invisible over it. 16px because iOS zooms the page into
     any focused control with smaller type. */
  .wpend { position: absolute; inset: 0; width: 100%; height: 100%;
           opacity: 0; font-size: 16px; cursor: pointer; }
  /* A ring for the keyboard only: after a tap the select keeps focus, and a
     ring that stayed round the pager until the next tap would look stuck. */
  .wpmid:has(.wpend:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
  .wpmid:active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .wptop .wdisc { width: 22px; height: 22px; font-size: 12px; }
  .wpdots { display: flex; gap: 3px; }
  .wpdots i { width: 5px; height: 5px; border-radius: 3px;
              background: color-mix(in srgb, var(--muted) 45%, transparent); }
  .wpdots i.on { width: 14px; background: var(--accent); }

  /* Detail: the sheet strip beside its figures. pan-y keeps the pane's own
     vertical scroll and hands horizontal drags to the swipe. */
  .wpane { flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y;
           padding: 12px 16px calc(64px + env(safe-area-inset-bottom)); }
  .dbody { display: flex; gap: 16px; align-items: flex-start; }
  .dstrip { flex: none; display: block; background: var(--ice);
            border: 1px solid var(--line); border-radius: 4px; }
  .dstrip-none { width: 150px; height: 420px; }
  /* Delivery: the chart at the pane's width, 358 px on a 390 phone. */
  .wpane .dlv { display: block; width: 100%; max-width: 358px; height: auto;
                background: var(--ice); border: 1px solid var(--line); border-radius: 4px; }
  .dfigs { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; }
  .dfig { padding: 9px 0; border-bottom: 1px solid var(--line); }
  .dfig dt { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
             color: var(--muted); font-weight: 600; }
  .dfig .dval { margin: 0; font-family: var(--display); font-size: 22px;
                font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
  .dfig .dnote { margin: 0; font-size: 11.5px; color: var(--muted);
                 display: flex; align-items: center; gap: 5px; }
  .dcap { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
  .dnone { font-size: 14px; color: var(--muted); margin: 24px 16px; text-align: center; }

  /* House: #houseCard promoted between the pager and the tabs. No caption:
     the house is the point of the tab, and where the rock stopped is on
     Detail already. */
  body[data-watch="house"] main > #houseCard { display: block; position: fixed;
    left: 0; right: 0; top: calc(48px + var(--vid) + 56px);
    bottom: calc(52px + env(safe-area-inset-bottom));
    z-index: 8; margin: 0; border: 0; border-radius: 0;
    background: var(--panel); padding: 6px 12px; }
  body[data-watch="house"] #houseCard .tools,
  body[data-watch="house"] #houseCard .housebar,
  body[data-watch="house"] #houseCard .muted { display: none; }

  /* Timing: the whole game's clock pinned above every rock, by end. */
  .tpane { flex: 1; min-height: 0; display: flex; flex-direction: column;
           padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .tchart { flex: none; padding: 8px 16px; background: var(--panel);
            border-bottom: 1px solid var(--line); }
  .tchart .wtotals { margin-top: 6px; }
  .tchart .wcaveat { margin-top: 4px; }
  .tlist { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
  .tend { position: sticky; top: 0; z-index: 1; height: 30px; display: flex;
          align-items: center; gap: 12px; padding: 0 16px;
          background: var(--bg); border-bottom: 1px solid var(--line);
          font-size: 13px; }
  .wen { font-weight: 650; }
  .wsc { display: flex; align-items: center; gap: 6px;
         font-variant-numeric: tabular-nums; }
  .wsc-none { opacity: 0.55; font-size: 12px; }
  .wham { font-size: 10px; color: var(--muted); letter-spacing: .05em; }
  .wdot { width: 11px; height: 11px; border-radius: 50%; display: inline-block;
          flex: none; }
  .wdot.red { background: var(--red); } .wdot.yellow { background: var(--yellow); }

  .wrow { height: 56px; width: 100%; display: grid; gap: 12px; padding: 0 16px;
          grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center;
          border: 0; border-bottom: 1px solid var(--line); background: none;
          font: inherit; color: inherit; text-align: left; position: relative; }
  .wrow[aria-current] { background: color-mix(in srgb, var(--accent) 7%, transparent); }
  .wrow[aria-current]::before { content: ""; position: absolute; left: 0;
                                top: 0; bottom: 0; width: 3px;
                                background: var(--accent); }
  .wdisc { width: 28px; height: 28px; border-radius: 50%; display: grid;
           place-items: center; font-size: 12px; font-weight: 650;
           font-variant-numeric: tabular-nums; }
  .wdisc.red { background: var(--red); color: #fff; }
  .wdisc.yellow { background: var(--yellow); color: #3a2d00; }
  .wmid { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
  /* The type and its long split share the row's top line. When they do not
     fit, the name ellipsises and the number stays whole: a flex child keeps
     its content width unless given min-width: 0, and flex: none holds the
     split at its own. */
  .whead { display: flex; align-items: baseline; gap: 6px; min-width: 0;
           line-height: 1.1; }
  .wname { font-size: 15px; font-weight: 650; line-height: 1.1; min-width: 0;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wsplit { flex: none; font-size: 13px; color: var(--muted);
            font-variant-numeric: tabular-nums; white-space: nowrap; }
  /* The bar is this rock's interval over the end's longest. A rock nobody
     could time gets the empty track and an em dash, never a zero-width bar --
     that would read as a rock thrown instantly. */
  .wtrack { height: 6px; border-radius: 3px; overflow: hidden;
            background: color-mix(in srgb, var(--muted) 22%, transparent); }
  .wtrack i { display: block; height: 100%; border-radius: 3px; }
  .wtrack i.red { background: color-mix(in srgb, var(--red) 62%, transparent); }
  .wtrack i.yellow { background: color-mix(in srgb, var(--yellow) 78%, transparent); }
  .wright { display: flex; flex-direction: column; align-items: flex-end;
            gap: 4px; flex: none; }
  .wsecs { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .wnow { font-size: 11px; color: var(--accent); font-weight: 600; white-space: nowrap; }

  .wback { position: absolute; left: 50%; transform: translateX(-50%);
           bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6;
           height: 36px; padding: 0 16px; border-radius: 999px;
           border: 1px solid var(--line); background: var(--panel);
           color: var(--accent); font: inherit; font-size: 13px;
           box-shadow: 0 2px 10px rgb(0 0 0 / .14); }
  .wtotals { display: flex; gap: 20px; align-items: center;
             font-size: 14px; font-variant-numeric: tabular-nums; }
  .wtotals span { display: flex; align-items: center; gap: 7px; }
  .wcaveat { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; }
  /* A bottom sheet on the phone, with thumb-sized buttons. */
  #flagDialog { width: 100vw; max-width: 100vw; margin: auto 0 0;
    border-radius: 16px 16px 0 0; }
  #flagDialog .flagButtons button { flex: 1; min-height: 44px; }
  #playedDialog { width: 100vw; max-width: 100vw; margin: auto 0 0;
    border-radius: 16px 16px 0 0; }
  /* Two to a row: four across is too tight for "5th & 6th" at a thumb's width. */
  #playedDialog .pl-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #teamsDialog { width: 100vw; max-width: 100vw; margin: auto 0 0;
    border-radius: 16px 16px 0 0; }
  #clipDialog { width: 100vw; max-width: 100vw; margin: auto 0 0;
    border-radius: 16px 16px 0 0; }
}

/* --- short screens ------------------------------------------------------ */
/* The shell needs a tall viewport. Below that the pre-existing single-column
   layout already scrolls and clips nothing, so the only thing worth adding is
   keeping the transport within reach of a thumb.
   Where "tall" starts is set by the House tab, which gets what the video,
   pager and tabs leave (about height - 380px on a 375px-wide phone): at 460
   that is an 80px house, and below it the single-column page reads better.
   It was 520, which sent a phone held upright here whenever its browser left
   under 521px of page: a report from Firefox for iOS, which keeps both an
   address bar and a toolbar on screen, saw this page as "the desktop view".
   Page zoom shrinks the page's height the same way. */
/* A short phone held upright: a folding phone closed (the iPhone Duo, 382 x
   580), a small phone, a split screen. At 16:9 of the full width the video
   leaves the house a sliver between itself and the sheet -- 60 px at 580 --
   so here the video keeps a little over half of what the header and the sheet
   leave, never under 120 px, and sits centred at that height. From about 700
   px tall the full-width video is the smaller figure and nothing changes. */
@media (max-width: 640px) and (min-height: 461px) and (max-height: 700px) {
  body { --vid: min(56.25vw, max(120px, calc((100dvh - 48px - var(--sheet) - var(--strip)) * 0.55))); }
  #playCard .video { width: calc(var(--vid) * 16 / 9); margin-inline: auto; }
}

@media (max-width: 640px) and (max-height: 460px) {
  main { margin-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .transport { position: fixed; left: 12px; right: 12px; z-index: 5;
               bottom: calc(12px + env(safe-area-inset-bottom));
               margin: 0; gap: 8px; flex-wrap: nowrap; padding: 8px; }
  /* The same opaque band the tall phone gives its bar, for the same reason:
     this page scrolls under the bar, and its 12px margins beside and below
     the card handed a near miss to whatever was there -- a swap checkbox, a
     grade button. The band is the page's colour, since there is no sheet
     here, and the card itself moves to ::after: a z-index -1 child paints
     over its parent's own background, so a card left on .transport would
     vanish under the band. Tree order puts ::after over ::before. */
  .transport::before { content: ""; position: absolute; z-index: -1;
                       top: 0; left: -12px; right: -12px;
                       bottom: calc(-12px - env(safe-area-inset-bottom));
                       background: var(--bg); }
  .transport::after { content: ""; position: absolute; z-index: -1; inset: 0;
                      background: var(--panel); border-radius: 10px;
                      box-shadow: 0 2px 12px rgb(0 0 0 / .14); }
  .transport button { height: 44px; min-width: 44px; padding: 0 10px; }
  .transport #prev, .transport #next { flex: 0 0 44px; padding: 0; }
  .transport #label, .transport #link { display: none; }
}

/* --- the desk layouts' parts (wide and tablet) ---------------------------- */
/* Rules on what only the desk layouts render -- the charting bar, the figures
   card, the header's rock name, the playback gear and the line chart -- so
   they apply in both: the wide desktop and the portrait iPad. Outside their
   media queries because the elements exist only there (App.jsx's `desk` and
   `wide` branches); each layout's block below then lays them out. */
#figCard { grid-area: figs; }
#lineCard { grid-area: line; }
#playGear { display: inline-grid; place-items: center; padding: 6px 8px; color: var(--muted); }
#playPrefs { position: absolute; right: 0; top: 100%; margin-top: 6px; z-index: 6;
             background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
             padding: 8px 12px; box-shadow: 0 8px 24px rgb(0 0 0 / .18); }
#playPrefs #playback { margin: 0; }

/* The charting bar (ChartPanel.jsx GradingBar). */
.gbar { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.gbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; row-gap: 6px; min-width: 0; }
.gbar-lbl { font-family: var(--display); font-size: 12px; font-weight: 700; text-transform: uppercase;
            letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
.gbar-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: none; }
.gbar .pick button { white-space: nowrap; }
.gbar #autoType { margin-left: auto; white-space: nowrap; font-size: 12px; }
.gbar #missReason { width: 200px; flex: none; height: 30px; }
/* A label and its control are one box that wraps whole. The note gives
   way first: it takes what the row leaves, down to a usable width. */
.gbar-pair { display: flex; align-items: center; gap: 8px; flex: none; }
.gbar-pair .pick { flex-wrap: nowrap; }
.gbar-pair.gbar-note { flex: 1 1 0; min-width: 180px; }
.gbar #note { flex: 1 1 0; width: auto; min-width: 0; min-height: 0; height: 30px; resize: none; }
.gbar #moveBefore { width: 170px; height: 30px; }
/* No rule for #renumbered: the base one clips it out of sight and out of
   the bar's grid, and keeps it in the accessibility tree, as everywhere on
   the desktop. */

/* The figures under the house: two columns, one line of note each. */
#figCard .dfigs { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
#figCard .dfig { padding: 2px 0; border-bottom: 1px solid var(--line); line-height: 1.3; min-width: 0; }
#figCard .dfig dt { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
                    color: var(--muted); font-weight: 600; }
#figCard .dval { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 700; line-height: 1.1;
                 white-space: nowrap; font-variant-numeric: tabular-nums; }
#figCard .dnote { margin: 0; font-size: 11.5px; color: var(--muted);
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#figCard .dnone { font-size: 14px; color: var(--muted); margin: 0; }
#figCard #flags:not(:empty) { margin-bottom: 10px; }
#figCard #flags .warn:first-child { margin-top: 0; }
#figCard #endBox { margin: 0 0 10px; }
#figCard #endBox h3 { margin-top: 0; }   /* the card's padding is its margin; 14 px back for the house */
#figCard .dcap, #lineCard .dcap { font-size: 11px; color: var(--muted); margin: 4px 0 0; line-height: 1.35; }

/* The line, the height of the page (Side.jsx LineCard draws to its box). */
#lineCard { height: calc(100vh - 82px); min-height: 640px; box-sizing: border-box;
            display: flex; flex-direction: column; }
/* Tall enough for Expand, so the chart starts at the same place with or
   without it. */
#lineCard .lc-head { display: flex; align-items: center; justify-content: space-between; margin: -2px 0 6px;
                     min-height: 26px; }
#lineCard .lc-head h2 { margin: 0; }
#lineExpand { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px; }
#lineCard .lc-box { flex: 1 1 0; min-height: 0; overflow: hidden; }
#lineCard .lc-box.zoom { cursor: zoom-in; }
#lineCard svg.linechart { display: block; border: 1px solid var(--line); border-radius: 6px; box-sizing: border-box; }
#lineCard .dlvnone { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
#rockName .rn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#rockName .chip { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
                  font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
#rockName .chip.red { background: var(--red); color: #fff; }
#rockName .chip.yellow { background: var(--yellow); color: #1a1a1a; }
#rockName .chip.unknown { background: var(--panel); color: var(--warn); border: 2px dashed var(--warn); }

/* --- wide desktop (spec 2026-10-15) --------------------------------------- */
/* A 1080p screen and wider, down to a 14-inch laptop's 1512 x 827 window:
   video, house, grading, the rock's figures and its line on one screen.
   React renders this layout's pieces only here (WIDE_QUERY in
   core/constants.mjs, byte-identical to this query); below it the page is
   the three-column one above, untouched. Last in the file, so at
   equal specificity it wins over the min-width:641px header order. */
@media (min-width: 1500px) {
  /* The page is the screen's height under the one-line header (54 px; it
     never wraps here, below). Column 2 shares it: the figures card takes its
     natural height -- warnings and the doubles end box included -- and the
     house card the rest, down to a floor below which the page scrolls rather
     than the cards overlap. The video and the line chart span both rows. */
  main { grid-template-columns: minmax(0,1fr) 330px 340px;
         grid-template-areas: "play house line" "play figs line";
         grid-template-rows: minmax(240px, 1fr) auto;
         height: calc(100vh - 54px); }

  /* The video gives up width before the page scrolls. K is everything in its
     column above and below it, plus the page's own padding; review has no
     bar. Measured with scripts/deskcheck.mjs. */
  body { --video-k: 243px; }
  body[data-mode="review"] { --video-k: 150px; }
  #video { width: min(100%, calc((100vh - var(--video-k)) * 16 / 9)); min-width: 640px; margin-inline: auto; }

  /* The control row: the arrows round the chips, then replay and mark
     charted; the YouTube link and the playback gear together at the right.
     One line from about 1760 px; below that it wraps rather than run past
     the card, the link and the gear moving down together. */
  #playCard .transport { gap: 6px; row-gap: 6px; }
  #playCard .transport .tp-rock { display: flex; align-items: center; gap: 6px; flex: none; }
  #playCard .transport .shots { margin: 0; flex-wrap: nowrap; }
  #playCard .transport .tp-end { display: flex; align-items: center; gap: 6px; flex: none;
                                 margin-left: auto; position: relative; }
  #playCard .transport button, #playCard .transport #link { white-space: nowrap; }

  /* The house fills what its row leaves under the tools, drawn to fit: the
     SVG letterboxes its viewBox, and the editor maps the pointer through
     getScreenCTM, so it stays exact at any size. Its hint is the card's
     tooltip. */
  #houseCard { align-self: stretch; min-height: 0; overflow: hidden;
               display: flex; flex-direction: column; }
  #houseCard .tools { flex: none; }
  #house { flex: 1 1 0; min-height: 0; height: auto; }

  /* The header: this rock beside the source, on one line at any width here.
     Everything keeps its size but the spacer and the rock's name, which
     gives way first -- its label ends in "…", the chip stays whole. */
  header { flex-wrap: nowrap; }
  header > *, header #menu > * { flex-shrink: 0; }
  header > .grow { flex-shrink: 1; min-width: 0; }
  /* The rock's name gives way first, then the source. Shrink weights cannot
     order them -- every shrinker loses a fraction of a pixel, and that is an
     ellipsis -- so the name is sized by growing instead: basis 0, nearly all
     the free space, up to its own width. Only when it is down to its chip
     does the row overflow, and then the source alone shrinks. */
  header > #src { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  header > #rockName { order: 2; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap;
                       flex: 1000 1 0; min-width: 24px; max-width: max-content; overflow: hidden; }

  /* Thinking comes just before Report; the rest move up one. */
  header #thinkBtn  { order: 11; }
  header #reportBtn { order: 12; }
  header #flagBtn   { order: 13; }
  header #playedBtn { order: 14; }
  header #teamsBtn  { order: 15; }
  header #clipBtn   { order: 16; }

  /* ⋯ is back, last in the row (2026-10-21): ⬇, I played…, Teams… and Clip…
     are behind it, which is what leaves room for Whole end at 1500 px. App
     renders #more only while it is open, under ⋯ at the header's right. */
  header > #menuBtn { display: inline-grid; place-items: center; order: 20; }
  header > #more { position: absolute; top: calc(100% + 4px); right: 12px; z-index: 6;
    display: flex; flex-direction: column; gap: 6px; min-width: 210px; padding: 8px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 6px 24px rgb(0 0 0 / .18); }
  header > #more > button { text-align: left; }
}

/* --- portrait iPad (spec 2026-10-16) -------------------------------------- */
/* A coarse pointer held upright, 700-1199 px wide. React renders this layout's
   pieces only here (TABLET_QUERY in core/constants.mjs, byte-identical to this
   query). */
@media (any-pointer: coarse) and (orientation: portrait) and (min-width: 641px) and (max-width: 1199px) {
  /* Charting a rock with no scroll and no hover: every control is a
     fingertip, 44 px or more, and nothing is only in a tooltip. Sized from
     the board "P · Portrait" (out/mockups/ipad/mock/touch.js and P.js). */
  body { font-size: 15px; }
  button, select, a, .shot, label, input, textarea { touch-action: manipulation; }

  /* The page (spec §1): the video, the chips, the house beside the figures,
     the bar. The rows share the height: the house row first gets its 320 px
     floor (or the figures card's height, if that is more) and the video row
     its 315 px (560 wide); what is left grows the video, up to the column's
     full 16:9 height, and the house row takes the rest. When the floors do
     not fit, the grid runs past main and the page scrolls: the cards never
     overlap. The video's width follows its height, and the row's cap is the
     column's 16:9 height, so it never has to give up width and lose 16:9. */
  main { grid-template-columns: minmax(0,1fr) minmax(0,1fr);
         grid-template-areas: "video video" "tp tp" "house figs" "bar bar";
         grid-template-rows: minmax(315px, calc((100vw - 28px) * 9 / 16)) auto minmax(auto, 1fr) auto;
         gap: 14px; padding: 14px; box-sizing: border-box; height: calc(100dvh - 56px); }
  /* The video, the chips and the bar are the grid's own items. */
  #playCard { display: contents; }
  #video { grid-area: video; height: 100%; width: auto; max-width: 100%; aspect-ratio: 16/9;
           justify-self: center; }

  /* The header, one line of 56 px (spec §2): the rock's name gives way
     first, as in the wide layout; the source line is hidden, and #save shows
     only its failures, as on the phone. */
  header { height: 56px; padding: 0 10px 0 16px; gap: 8px; flex-wrap: nowrap; }
  header > *, header #menu > * { flex-shrink: 0; }
  header > .grow { flex-shrink: 1; min-width: 0; }
  header > #src, #save:not(.bad) { display: none; }
  header h1 a { display: block; min-height: 44px; line-height: 44px; }
  /* After the rock's name, the charting count and the title give way, as on
     the phone (which hides the title): a save failure in #save is the message
     that must stay whole, and it is the widest thing the line ever holds. */
  header > h1, header h1 a { overflow: hidden; text-overflow: ellipsis; }
  header > h1 { flex-shrink: 1; min-width: 44px; }
  header select, header button { min-height: 44px; font-size: 15px; }
  header #end { padding: 0 10px; }
  header > #blanks { padding: 0 12px; font-size: 15px; flex-shrink: 1; min-width: 44px;
                     overflow: hidden; text-overflow: ellipsis; }
  header > #rockName { order: 2; display: inline-flex; align-items: center; gap: 8px; font-weight: 600;
                       font-size: 16px; white-space: nowrap; flex: 1000 1 0; min-width: 30px;
                       max-width: max-content; overflow: hidden; }
  #rockName .chip { width: 30px; height: 30px; font-size: 15px; }
  header #thinkBtn  { order: 11; }
  header #reportBtn { order: 12; }
  /* A guarded chart says "View only" here, as on the phone: the long line
     would push the header past the screen. */
  #viewOnly { white-space: nowrap; }
  #viewOnly .long { display: none; }
  #viewOnly .short { display: inline; }
  #menuBtn { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
             order: 30; font-size: 22px; line-height: 1; }

  /* Behind ⋯, the phone's pattern: the playback settings stay in #playCard,
     so the two panels are lifted into one dropdown at fixed offsets, the
     settings on top. #playback is not inside #menu, so tapping its number
     box does not close the menu (App's pointerdown handler spares it). In
     source order inside: Game, the links, ⬇, Flag … Clip, YouTube, track. */
  #menu, #playback { display: none; }
  body[data-menu="open"] #menu,
  body[data-menu="open"] #playback {
    position: fixed; right: 10px; width: 300px; z-index: 10; margin: 0; box-sizing: border-box;
    background: var(--panel); border: 1px solid var(--line); padding: 10px 12px; }
  body[data-menu="open"] #playback { display: flex; flex-wrap: nowrap; top: 60px; height: 64px;
    align-items: center; gap: 14px; border-bottom: 0; border-radius: 10px 10px 0 0; }
  body[data-menu="open"] #menu { display: flex; flex-direction: column; gap: 8px; top: 124px;
    max-height: calc(100dvh - 134px); overflow-y: auto;
    border-radius: 0 0 10px 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .18); }
  header #menu > * { order: 0; width: 100%; min-height: 44px; flex: none; }
  header #houseImgBtn { display: block; }
  #menu > a, #menu > label.chk { display: flex; align-items: center; font-size: 15px; }
  #playback label.chk { min-height: 44px; font-size: 15px; }
  #playback #leadin { min-height: 44px; font-size: 16px; }

  /* The rock chips and Replay (spec §3): 44 tall, as wide as the row
     leaves down to 36. The width keeps 160 px for the rest of the row:
     main's padding, the chips' 2 px gaps, the row's gap and Replay (155 px
     here), so 16 chips and Replay fit on one line from 744 px up. */
  /* `safe`: below 744 px the row can run past its box, and then it starts at
     the left edge rather than spilling past it on both sides. */
  #transport { grid-area: tp; margin: 0; gap: 6px; flex-wrap: nowrap; justify-content: center; justify-content: safe center; }
  #transport .shots { margin: 0; gap: 2px; flex-wrap: nowrap; }
  #shots .shot { width: clamp(36px, calc((100vw - 160px) / 16), 40px); height: 44px; font-size: 15px;
                 border-radius: 8px; flex: none; }
  #shots .shot.sel { outline-offset: 2px; }
  #shots .shot.graded::after { width: 6px; height: 6px; right: 3px; bottom: 3px; }
  #replay { min-height: 44px; padding: 0 12px; white-space: nowrap; }

  /* The charting bar (spec §6), its own card along the bottom: the groups
     with the auto note at the right, the group's subtypes on a line of their
     own (Hit's ten fit on it at 744 px), then the score, the sheet buttons and
     Next rock. That last row never wraps, so typing a note never changes the
     bar's height and with it the video's size: a set value grows its sheet
     button up to 180 px, and when the row runs out only the values give way,
     ending in "…". A button's name never does, so each still says what it
     opens. */
  #grading { grid-area: bar; margin: 0; padding: 12px; background: var(--panel);
             border: 1px solid var(--line); border-radius: 10px; gap: 8px; }
  .gbar-row { gap: 6px; row-gap: 8px; }
  .gbar-lbl, .gbar-sep { display: none; }
  .gbar .pick button { min-height: 44px; padding: 0 11px; font-size: 15px; }
  .gbar #typeGroups button { min-width: 70px; font-weight: 600; }
  .gbar #typeList button { min-width: 44px; padding: 0 8px; }
  .gbar .gbar-row:first-child > .gbar-pair { order: 1; }
  .gbar #autoType { order: 2; margin-left: auto; font-size: 13px; }
  .gbar #typeList { order: 3; flex: 1 0 100%; }
  .gbar #scoreBtns { gap: 5px; }
  .gbar #scoreBtns button { width: 50px; height: 48px; padding: 0; font-size: 20px; }
  .gbar .gbar-row:nth-child(2) { flex-wrap: nowrap; }
  /* The three share what the score and Next rock leave as a grid of their
     own, which hands the room out evenly: a short value ("ok") is shown whole
     before a long one takes the rest. A track's floor is its button's name. */
  .gbar-sheets { flex: 0 1 auto; display: grid; grid-auto-flow: column;
                 grid-auto-columns: minmax(min-content, max-content); gap: 6px; }
  /* A sheet button: the name, then the value. The value's track has a floor
     of 0, so the button's own min-content -- its floor -- is the name, which
     never wraps or shrinks; only the value is cut, with "…". */
  .sheetbtn { min-width: 44px; min-height: 44px; padding: 0 8px; font-size: 15px; white-space: nowrap; }
  .sheetbtn .sb { display: grid; grid-auto-flow: column; grid-template-columns: auto;
                  grid-auto-columns: minmax(0, max-content); column-gap: .3em; align-items: center;
                  justify-content: center; }
  .sheetbtn .sb-lbl { white-space: nowrap; }
  .sheetbtn .sb-val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #missBtn, #noteBtn { max-width: 180px; }
  #orderBtn { min-width: max-content; }      /* never shrinks: its value is "#N" */
  #nextRock { flex: none; margin-left: auto; min-height: 48px; padding: 0 16px; font-weight: 700;
              white-space: nowrap; background: var(--ink); color: var(--panel); border-color: transparent; }

  /* The house card (spec §4) is for reading the house: drawn to fit, with
     Charted and "open it large" over its top corners. Its drawing must not
     size the row, so its size is contained. The tools are the editor's. */
  #houseCard { grid-area: house; align-self: stretch; position: relative; contain: size; min-height: 320px;
               display: flex; flex-direction: column; }
  #house { flex: 1 1 0; min-height: 0; height: auto; }
  #houseCard .tools, #houseCard .housebar { display: none; }
  #houseCard .hc-head { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; display: flex;
                        align-items: flex-start; justify-content: space-between; pointer-events: none; }
  #houseCard .hc-head > * { pointer-events: auto; }
  #houseCard .hc-hint { display: none; }
  #markCharted { min-height: 44px; padding: 0 12px; font-size: 15px; }
  #houseOpen { width: 44px; height: 44px; padding: 0; margin-left: auto; }
  #houseOpen:not([hidden]) { display: grid; place-items: center; }
  .hc-tap { flex: none; margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

  /* The editor (spec §4): the card opens over the rows under the video, the
     house drawn large at the left and its tools in a column at the right. The
     chips, the figures and the bar are hidden, not removed, so the rows keep
     their sizes and the video does not change size when the house opens. No
     fixed positioning: nothing has to know the video's height. */
  body[data-house="edit"] #houseCard { grid-row: 2 / 5; grid-column: 1 / 3; z-index: 2; align-self: stretch;
    display: grid; grid-template-columns: auto minmax(0,1fr); grid-template-rows: auto 1fr auto;
    grid-template-areas: "svg head" "svg tools" "svg bar"; column-gap: 14px; row-gap: 10px;
    background: var(--panel); box-shadow: 0 10px 30px rgb(0 0 0 / .18); }
  body[data-house="edit"] :is(#transport, #figCard, #grading) { visibility: hidden; }
  /* The card has left its own row, which held the house row at 320 px: a spacer
     holds it there, so the video above keeps the size it had. */
  body[data-house="edit"] main::after { content: ""; grid-area: house; min-height: 320px; }
  body[data-house="edit"] #house { grid-area: svg; height: 100%; width: auto; min-height: 0; max-width: 100%;
    aspect-ratio: 5.2 / 8.6; }
  body[data-house="edit"] #houseCard .hc-head { grid-area: head; position: static; display: flex;
    flex-direction: column; align-items: stretch; gap: 8px; pointer-events: auto; }
  body[data-house="edit"] #houseCard .hc-hint { display: block; font-size: 13px; color: var(--muted); }
  body[data-house="edit"] #houseOpen:not([hidden]) { display: none; }
  body[data-house="edit"] #houseCard .tools { grid-area: tools; display: flex; flex-wrap: wrap; align-content: flex-start;
    gap: 8px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
  body[data-house="edit"] #houseCard .tools > .grow { flex: 1 0 100%; height: 0; }
  body[data-house="edit"] #houseCard .tools button { min-width: 44px; min-height: 44px; }
  body[data-house="edit"] #houseCard .tools .swatchbtn { width: 44px; height: 44px; }
  body[data-house="edit"] #houseCard .tools label.chk { min-height: 44px; display: inline-flex; align-items: center; }
  body[data-house="edit"] #houseCard .housebar { grid-area: bar; display: flex; gap: 8px; }
  body[data-house="edit"] #houseDone { flex: 1 1 auto; min-height: 48px; height: 48px; background: var(--accent);
    color: var(--onaccent); border-color: transparent; font-weight: 700; }
  body[data-house="edit"] #recolour { flex: 0 0 56px; min-height: 48px; height: 48px; }
  body[data-house="edit"] .hc-tap { display: none; }

  /* The figures (spec §5): every note wraps in full, since a finger cannot
     hover for a cut-off one's tooltip; the eighth cell opens the delivery. */
  #figCard { padding: 10px 12px; }
  #figCard .dfig { padding: 3px 0 4px; }
  #figCard .dnote { font-size: 12px; line-height: 1.25; white-space: normal; overflow: visible;
                    text-overflow: clip; }
  #figCard .dline { align-self: center; border-bottom: 0; }
  #figCard .dline dd { margin: 0; }
  #lineOpen { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center;
              gap: 8px; font-size: 15px; }

  /* Doubles (spec §5): the end's facts in one line and the swap in a sheet. */
  #figCard #endBox { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
  /* The line wraps, never ellipsises: what it says is not to be hidden. */
  #figCard #endBox .endline { flex: 1 1 0; min-width: 0; margin: 0; font-size: 13px; line-height: 1.25;
                              white-space: normal; overflow-wrap: anywhere; }
  #swapBtn { flex: 0 1 auto; max-width: 180px; padding: 0 10px; }
  /* The swap sheet's two boxes are fingertip targets; #endBox label (1,0,1) would make them 20 px. */
  #swapSheet label.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; }
  #swapSheet label.chk input { width: 20px; height: 20px; margin: 0; flex: none; }
}

/* The narrowest iPads (the mini, 744 px): the score row gives the sheet
   buttons' values more room. The score buttons go to 44 px wide, still a
   fingertip, and Next rock keeps its words with less padding. */
@media (any-pointer: coarse) and (orientation: portrait) and (min-width: 641px) and (max-width: 799px) {
  .gbar #scoreBtns { gap: 4px; }
  .gbar #scoreBtns button { width: 44px; }
  #nextRock { padding: 0 12px; }
}

/* Narrower than any iPad: a folding phone opened and held upright (669 px on
   the iPhone Duo; 641-699 otherwise had neither this layout nor the phone's).
   The site's name gives its room to the end picker and the count to chart;
   the sixteen rocks share the row with Replay, which keeps only its arrow. */
@media (any-pointer: coarse) and (orientation: portrait) and (min-width: 641px) and (max-width: 699px) {
  header > h1 { display: none; }
  #shots .shot { width: calc((100vw - 114px) / 16); }
  #replay { width: 48px; padding: 0; font-size: 0; }
  #replay::before { content: "\21BB"; font-size: 20px; }
}

/* --- the portrait iPad's sheets (spec 2026-10-16 §6) ---------------------- */
/* Sheet.jsx: Miss, Note and Order, each a small modal at the top of the
   screen, over the video, so the iPad's keyboard (up to about y = 700-770 of
   1080) never covers it and Safari has no reason to pan the page. Not inside
   the tablet's @media: only that layout renders one. The padding is the
   wrapper's, so a tap on the <dialog> element itself is the backdrop's. The
   fields keep their ids, so the bar's own rules on them reach in here and
   are outranked: dialog.sheet #id is (1,1,1) over .gbar #id's (1,1,0). Text
   is 16 px, or Safari zooms the page when a box takes the caret. */
dialog.sheet { margin: 70px auto auto; width: min(560px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink);
  box-sizing: border-box; }
dialog.sheet::backdrop { background: rgb(20 16 10 / .45); }
.sheet-body { padding: 14px 16px 16px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1 1 auto; margin: 0; font-size: 16px; }
.sheet-head form { margin: 0; }
.sheet-head button { min-height: 44px; padding: 0 18px; font-size: 15px; font-weight: 600; }
dialog.sheet .reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
dialog.sheet .reasons button { min-height: 44px; padding: 0 14px; font-size: 15px; }
dialog.sheet #missReason, dialog.sheet #moveBefore { width: 100%; height: 44px; font-size: 16px; }
dialog.sheet #note { width: 100%; height: auto; min-height: 120px; resize: vertical; font-size: 16px; }
dialog.sheet .muted { margin: 10px 0 0; font-size: 13px; }
/* On /s/ the fields are read-only rather than inert, so a long note can be
   scrolled and read in full; (1,2,2) over the view mode's (1,1,1). */
body[data-mode="view"] dialog.sheet #missReason,
body[data-mode="view"] dialog.sheet #note { pointer-events: auto; opacity: 1; }

/* --- the large dialogs: delivery and thinking (spec 2026-10-15) ----------- */
#deliveryDialog, #thinkingDialog, #endDialog { padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--ink); box-sizing: border-box; max-height: calc(100vh - 48px);
  overflow: hidden; }
/* The padding lives on the wrapper, not the <dialog>: a click on the dialog element itself is the
 * backdrop's, so every point of the visible card has to belong to a child. */
.dd-body { padding: 16px 24px 18px; box-sizing: border-box; max-height: calc(100vh - 50px); overflow: auto; }
#deliveryDialog { width: min(1560px, calc(100vw - 64px)); }
#thinkingDialog { width: min(920px, calc(100vw - 64px)); }
#endDialog { width: min(1560px, calc(100vw - 64px)); }
#deliveryDialog::backdrop, #thinkingDialog::backdrop, #endDialog::backdrop { background: rgb(20 16 10 / .55); }
.dd-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.dd-head h2 { margin: 0; font-size: 16px; }
.dd-head .grow { flex: 1 1 auto; }
.dd-head form { margin: 0; }
.dd-chip { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
           font-size: 12px; font-variant-numeric: tabular-nums; }
.dd-chip.red { background: var(--red); color: #fff; }
.dd-chip.yellow { background: var(--yellow); color: #1a1a1a; }
.dd-chip.unknown { background: var(--panel); color: var(--warn); border: 2px dashed var(--warn); }
.dd-who { font-size: 14px; font-weight: 600; }
.dd-esc { font-size: 12px; color: var(--muted); }
.dd-close { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; }
#deliveryDialog svg.dd-dlv, #deliveryDialog svg.spd { display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 6px; background: var(--ice); }
#deliveryDialog .dcap { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
#deliveryDialog .dnone, #thinkingDialog .dnone, #endDialog .dnone { color: var(--muted); margin: 12px 0 0; }
.dd-speed { display: flex; align-items: baseline; gap: 22px; margin: 16px 0 8px; }
.dd-speed h3 { margin: 0; color: var(--ink); }
.dd-num { font-size: 13px; color: var(--muted); }
.dd-num b { font-family: var(--display); font-size: 19px; color: var(--ink); margin-right: 4px;
            font-variant-numeric: tabular-nums; }

/* The end at a glance: two rows of houses, `--cols` across (App passes half
   the end's rocks, rounded up). Each house is as wide as its column, and no
   taller than half of what the screen leaves for the two rows -- the
   dialog's margins, padding and head, and each row's caption and border
   come to about 230 px -- so both fit without a scroll; past that the
   drawing letterboxes. */
#endDialog .eh-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
#endDialog .eh-rock { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 4px;
  border: 2px solid transparent; border-radius: 8px; background: none; }
#endDialog .eh-rock:hover { border-color: var(--line); }
#endDialog .eh-rock.here { border-color: var(--accent); }
#endDialog .eh-house { display: block; width: 100%; height: auto; max-height: calc((100vh - 240px) / 2); }
#endDialog .eh-cap { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
#endDialog .eh-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The large dialogs drawn for the portrait iPad (spec 2026-10-16 §7). After the
   rules above, which they override at equal weight. The delivery's drawing is
   TABLETDELIVERYBOX / TABLETSPEEDBOX wide (App passes them), so the dialog
   takes nearly the screen's width and its texts keep their size. */
@media (any-pointer: coarse) and (orientation: portrait) and (min-width: 641px) and (max-width: 1199px) {
  #deliveryDialog { width: calc(100vw - 24px); }
  .dd-body { padding: 14px 16px 16px; }
  .dd-close { width: 44px; height: 44px; }
  #thinkingDialog .key button.linky { all: unset; cursor: pointer; color: var(--accent); min-height: 44px;
    min-width: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px;
    box-sizing: border-box; font-size: 13px; }
}

/* --- a phone, or a folding phone opened, on its side ---------------------- */
/* A coarse pointer, landscape, 641 px or wider and no taller than 600: an
   iPhone on its side (844 x 390, 932 x 430) and the iPhone Duo opened on its
   side (951 x 537). None of the layouts above claims these, so they drew the
   narrow desktop page: a header wrapped onto two or three rows, mouse-sized
   buttons, and a page that scrolled the video away to reach the house.
   CSS only -- React renders the desktop's pieces here, exactly as on a narrow
   window -- so it can only place and size them:
     - the header keeps one row and scrolls sideways if it must;
     - the page itself never scrolls; the left column (video, rocks, figures,
       grading) scrolls under the header, and the house stays pinned beside it;
     - the video is held to the height that leaves the rock strip and the
       controls on the first screen;
     - every control is a fingertip tall, and the notch's side is left clear. */
@media (any-pointer: coarse) and (orientation: landscape) and (min-width: 641px) and (max-height: 600px) {
  body { height: 100dvh; overflow: hidden; --hdr: 48px; --under: 150px;
         --col: calc(100dvh - var(--hdr) - 20px); }
  button, select, a, .shot, label, input, textarea { touch-action: manipulation; }

  header { height: var(--hdr); box-sizing: border-box; flex-wrap: nowrap; gap: 8px;
           padding: 2px max(12px, env(safe-area-inset-right)) 2px max(12px, env(safe-area-inset-left));
           overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  header::-webkit-scrollbar { display: none; }
  header > * { flex-shrink: 0; }
  header > .grow { flex-shrink: 1; min-width: 0; }
  header > h1, header > #src { display: none; }
  header button, header select, header a.btn { min-height: 40px; }

  main { height: calc(100dvh - var(--hdr)); box-sizing: border-box; overflow-y: auto;
         overscroll-behavior: contain; gap: 10px;
         padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom))
                  max(10px, env(safe-area-inset-left));
         grid-template-columns: minmax(0, 1fr) clamp(230px, 34vw, 330px);
         grid-template-areas: "play house" "detail house" "chart house";
         grid-template-rows: auto auto 1fr; }
  main > .card { padding: 10px; }

  /* The house: pinned for as long as the left column scrolls, its own height
     the screen's. A sheet drawn to the hog line is taller than a phone on its
     side, so the card scrolls within itself; the rings are at its top. */
  #houseCard { position: sticky; top: 0; align-self: start; max-height: var(--col);
               box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; }
  #houseCard .muted { display: none; }
  #houseCard .tools { gap: 8px; }
  #houseCard .tools button, .swatchbtn { min-width: 40px; min-height: 40px; }

  /* Video, then the rocks, then the buttons, all on the first screen: 150 px
     is the strip, the transport row and the card's own padding. */
  #playCard { display: flex; flex-direction: column; }
  #video { width: min(100%, calc((var(--col) - var(--under)) * 16 / 9)); min-width: 0; margin-inline: auto; }
  #playCard .shots { order: 1; flex-wrap: nowrap; gap: 3px; margin-top: 8px; }
  #playCard .shots .shot { flex: 1 1 0; width: auto; min-width: 0; height: 40px; font-size: 14px; }
  #playCard .transport { order: 2; margin-top: 8px; gap: 8px; }
  #playCard .transport button { min-height: 44px; min-width: 44px; }
  #playCard #playback { order: 3; }

  /* The grading and the figures: the desktop's, a fingertip tall. */
  .pick button, .scorebtns button, #chart button, #chart select, #chart input { min-height: 44px; }
  .pick { gap: 8px; }
  label.chk { min-height: 40px; }
}
/* A phone on its side is under 450 px tall, and with both rows kept the video
   is a third of the screen: there the first screen keeps the video and the
   rocks, and the buttons are a short scroll below them. */
@media (any-pointer: coarse) and (orientation: landscape) and (min-width: 641px) and (max-height: 450px) {
  body { --under: 72px; }
}
