/* ════════════════ Reset ════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* iOS enlarges text on rotation to landscape unless told not to. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--fu);
  background: var(--ground);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
input, button { font: inherit; color: inherit; }
/* No double-tap zoom: tapping + twice to score two points must not zoom the page. */
button, input, select, textarea, label, .chip, .q-item { touch-action: manipulation; }
[hidden] { display: none !important; }
/* The transparent outline is drawn in forced-colours (high contrast) mode, where box-shadow is dropped. */
:focus-visible { outline: 2px solid transparent; outline-offset: 1px; box-shadow: var(--ring); border-radius: var(--rs); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ════════════════════════════════════════════════════════
   BUTTONS — one base, explicit variants, explicit sizes.
   Every button uses .btn + exactly one variant. Heights are
   locked with min-height so variants never mismatch.
   ════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border: 1.5px solid transparent;
  border-radius: var(--rs);
  font-family: var(--fu);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

/* Variants */
.btn--primary   { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--primary:hover:not(:disabled)   { background: var(--accent-hi); border-color: var(--accent-hi); }

.btn--secondary { background: var(--surface); color: var(--ink2); border-color: var(--border-firm); }
.btn--secondary:hover:not(:disabled) { background: var(--raised); color: var(--ink); border-color: var(--ink4); }

.btn--subtle    { background: transparent; color: var(--ink2); border-color: transparent; }
.btn--subtle:hover:not(:disabled)    { background: var(--raised); color: var(--ink); }

.btn--good      { background: var(--surface); color: var(--good); border-color: var(--border-firm); }
.btn--good:hover:not(:disabled)      { background: var(--good-soft); border-color: var(--good); }

.btn--danger    { background: var(--surface); color: var(--bad); border-color: var(--border-firm); }
.btn--danger:hover:not(:disabled)    { background: var(--bad-soft); border-color: var(--bad); }

.btn--onDark    { background: transparent; color: var(--hdr-ink); border-color: var(--hdr-line); }
.btn--onDark:hover:not(:disabled)    { background: var(--hdr-hover); border-color: var(--hdr-ink2); }

.btn--ball      { background: var(--ball); color: var(--on-ball); border-color: var(--ball); }
.btn--ball:hover:not(:disabled)      { filter: brightness(1.08); }

/* Sizes */
.btn--sm   { min-height: 28px; padding: 0 10px; font-size: 12px; gap: 5px; }
.btn--lg   { min-height: 40px; padding: 0 18px; font-size: 14px; }
.btn--icon { min-height: 34px; width: 34px; padding: 0; }
.btn--icon.btn--sm { min-height: 28px; width: 28px; }
.btn--block { width: 100%; }

/* ════════════════ Layout ════════════════ */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: var(--hdr-bg);
  color: var(--hdr-ink);
  padding: 0 16px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--hdr-line);
}
.brand {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
/* Header is dark in both themes, so the on-dark lockup always applies.
   28px tall keeps it above the 100px-wide minimum in BRAND.md. */
.brand-logo { display: block; height: 28px; width: auto; }

.hstats {
  display: flex; align-items: center; gap: 6px;
  flex: 1 0 auto;   /* fixed slots never shrink: on a narrow row the name gives way (ellipsis) */
}
.hstat {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 10px; line-height: 1.15;
  border-right: 1px solid var(--hdr-line);
  min-width: 68px;   /* fixed slots: a count going 9 → 10 doesn't nudge its neighbours */
}
.hstat:first-child { min-width: 82px; }   /* room for h:mm:ss, so the clock never pushes the header */
.hstat:last-child { border-right: none; }
.hstat[hidden] { display: none; }
/* The club never truncates: it wraps. It doesn't change during a night, so the header still never shifts. */
.hstat--club { flex: 0 1 auto; max-width: 16em; }
.hstat--club b { font-size: 13px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; text-wrap: balance; }
.hstat b {
  font-family: var(--fd); font-weight: 700; font-size: 15px;
  color: var(--hdr-ink); font-variant-numeric: tabular-nums;
}
.hstat span {
  font-size: 10.5px; color: var(--hdr-ink2);
  letter-spacing: .4px; text-transform: uppercase; font-weight: 500;
}

.hactions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* The signed-in account: initials, fixed width, opens Sessions. */
.acct-btn {
  border-radius: 50%; font-family: var(--fu); font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--hdr-hover); color: var(--hdr-ink); border-color: var(--hdr-ink2);
}
.acct-btn[hidden] { display: none; }

/* The session name. */
.hname { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; min-width: min(12em, 100%); flex: 0 1 auto; }

/* Session name: shown to everyone; the queue master taps it to rename. */
.sess-name {
  min-width: 0; max-width: 100%; flex: 0 1 auto;
  font-family: var(--fd); font-weight: 700; font-size: 15px; color: var(--hdr-ink);
  background: none; border: 1px solid transparent; border-radius: var(--rs); padding: 3px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.sess-name:not(:disabled) { cursor: pointer; }
.sess-name:not(:disabled):hover { background: var(--hdr-hover); }
.sess-name.is-empty { font-family: var(--fu); font-weight: 500; font-size: 12.5px; color: var(--hdr-ink2); border-color: var(--hdr-line); border-style: dashed; }
body.viewer-mode .sess-name.is-empty { display: none; }

/* Two rows below 1000px: logo + name ··· buttons, then the stats. One row
   needs logo + sync pill + stats + buttons + a usable name (~990px). */
@media (max-width: 1000px) {
  header { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .hname { order: 1; flex: 1 1 0; }   /* 0 basis: a long name shortens instead of wrapping the buttons */
  .hactions { order: 2; margin-left: auto; }
  /* flex-basis, not width: `flex: 1` sets a 0 basis, which kept the stats
     on the name's row and pushed the last one off a phone screen. */
  .hstats { order: 3; flex: 1 1 100%; justify-content: flex-start; }
  .sess-name { max-width: 100%; }
}
/* Below 760px the name gets a row of its own, under logo + buttons: beside
   them it was squeezed to a letter or two once the sync pill showed. */
@media (max-width: 760px) {
  .hactions { order: 1; }
  .hname { order: 2; flex: 1 1 100%; align-items: center; text-align: center; }   /* the name's own row: centred */
  .sess-name { text-align: center; }
}
@media (max-width: 600px) {
  /* Three rows: logo + buttons · name + sync pill · stats. The name's row is
     full width, so a long name or a long sync label shortens the name
     (ellipsis) instead of pushing the pill down a line. */
  header { padding: 8px 12px 10px; gap: 8px; }
  .brand-logo { height: 22px; }
  .hactions { gap: 5px; }
  .hactions .btn:not(.btn--icon) { padding: 0 11px; }
  .wide-only { display: none; }

  .hstats { justify-content: space-between; }
  .hstat { flex: 1; padding: 0 4px; }
  .hstat b { font-size: 14px; }
  .hstat:not(:first-child) { min-width: auto; }   /* label width, so a club slot still fits 320px */
  .hstat--club { flex: 1.5 1 0; min-width: 0; }   /* the other slots keep their labels whole; the club wraps in what's left */
  .hstat--club b { font-size: 12.5px; overflow-wrap: break-word; }
  /* Watching on a phone: let the header scroll away and give the courts the screen. */
  body.viewer-mode header { position: static; }
}

/* The narrowest phones: five slots with a club need tighter labels to fit 320px. */
@media (max-width: 360px) {
  .hstats { gap: 2px; }
  .hstat { padding: 0 2px; }
  .hstat:first-child { min-width: 64px; }
  .hstat span { font-size: 9.5px; letter-spacing: .2px; }
}

/* Paused banner */
.paused-bar {
  display: none; align-items: center; justify-content: center; gap: 8px;
  background: var(--warn-soft); color: var(--warn);
  padding: 7px 20px; font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid var(--warn-line);
}
body.session-paused .paused-bar { display: flex; }

/* Setup banner — shown until the session is started */
.setup-bar {
  display: none; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); color: var(--ink2);
  padding: 8px 20px; font-size: 12.5px; text-align: center;
  border-bottom: 1px solid var(--accent-line);
}
.setup-bar b { color: var(--accent); font-weight: 700; }
/* Setup choices: their own band under the note, scoring on the left and Start on the right. */
.setup-panel {
  display: none; align-items: center; gap: 12px 24px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
body.session-setup .setup-panel { display: flex; }
.setup-panel .btn { min-height: 44px; margin-left: auto; padding: 0 22px; }
.scoring { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.scoring-lbl { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink2); }
/* A joined segmented control, so the two read as one choice and not two actions. */
.scoring-seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--surface); border: 1px solid var(--border-firm); border-radius: calc(var(--rs) + 3px);
}
.scoring-seg button {
  min-height: 44px; min-width: 96px; padding: 0 16px; border: 0; border-radius: var(--rs); cursor: pointer;
  background: transparent; color: var(--ink2); font: inherit; font-size: 13.5px; font-weight: 600;
}
.scoring-seg button.on { background: var(--accent); color: var(--on-accent); }
.scoring-seg button:not(.on):hover { background: var(--accent-soft); color: var(--ink); }
.scoring-hint { font-size: 12.5px; color: var(--ink2); line-height: 1.35; }
@media (max-width: 600px) {
  .setup-panel { flex-direction: column; align-items: stretch; padding: 12px; }
  .scoring { justify-content: center; }
  .scoring-seg { flex: 1 1 100%; }
  .scoring-seg button { flex: 1; min-width: 0; }
  .scoring-hint { flex-basis: 100%; text-align: center; }
  .setup-panel .btn { margin-left: 0; }
}
body.session-setup .setup-bar { display: flex; }
.viewer-only { display: none; }
body.viewer-mode .viewer-only { display: inline; }
.court-setup-note { font-size: 12px; color: var(--ink3); }

.main-area {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0,1fr) 330px;
  align-items: start; align-content: start;
}
@media (max-width: 900px) {
  .main-area { grid-template-columns: 1fr; }
  .queue-panel { border-left: none !important; border-top: 1px solid var(--border); position: static !important; max-height: none !important; }
}

/* ════════════════ Panel chrome ════════════════ */
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
  min-height: 28px;   /* a .btn--sm: Courts and Queue titles line up across the two columns */
}
/* Two uppercase label sizes: section labels, and column or group labels. */
.panel-title, .sess-block h4, .court-empty-label {
  font-family: var(--fu); font-size: 11px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase;
}
.hist-cols span, .stand-cols span, .stand-divider, .staged-team-label, .q-section, .balance-label {
  font-family: var(--fu); font-size: 10.5px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase;
}
.panel-title { color: var(--ink3); }

/* Empty states: one size everywhere */
.empty {
  grid-column: 1 / -1; text-align: center;
  padding: 32px 20px; color: var(--ink3); font-size: 13px;
}
.empty b { color: var(--ink2); }
.empty-title { font-family: var(--fd); font-weight: 700; font-size: 15px; color: var(--ink2); margin-bottom: 5px; }
.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sunken); color: var(--ink2);
  font-size: 11px; font-weight: 700; border-radius: 99px;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 7px;
  font-variant-numeric: tabular-nums;
}
.title-row { display: flex; align-items: center; }

.courts-panel { padding: 18px; min-height: 280px; }
.courts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

/* ════════════════ Court card ════════════════ */
.court-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.court-card.is-active { border-color: var(--accent-line); box-shadow: var(--shm); }
.court-card.is-staged { border-color: var(--ball); }
.court-card.is-off { border-style: dashed; box-shadow: none; }

.court-header {
  background: var(--hdr-bg);
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 38px;
}
.court-name {
  font-family: var(--fd); font-weight: 700; font-size: 13.5px;
  color: var(--hdr-ink); letter-spacing: .1px;
  background: none; border: 1.5px solid transparent; border-radius: var(--rxs);
  padding: 2px 6px; margin-left: -6px; cursor: text; text-align: left;
  transition: background var(--tr), border-color var(--tr);
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.court-name:hover { background: var(--hdr-hover); }
body.viewer-mode .court-name { cursor: default; pointer-events: none; }

.court-name-input {
  font-family: var(--fd); font-weight: 700; font-size: 13.5px;
  background: var(--hdr-hover); border: 1.5px solid var(--hdr-ink2);
  border-radius: var(--rxs); color: var(--hdr-ink); padding: 2px 6px;
  outline: none; width: 150px;
}

.court-timer {
  font-family: var(--fd); font-weight: 700; font-size: 13px;
  color: var(--ball); font-variant-numeric: tabular-nums; letter-spacing: .4px;
  transition: color var(--tr), opacity var(--tr);
}
.court-timer.paused { color: var(--hdr-ink2); opacity: .8; }


.court-body { padding: 14px; }

.court-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 0; }
.court-empty-text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.court-empty-label { color: var(--ink3); }
.court-empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Active match */
.team-name {
  font-family: var(--fd); font-weight: 700; font-size: 13px;
  color: var(--ink); line-height: 1.3; word-break: break-word;
}
.team-score {
  font-family: var(--fd); font-weight: 800; font-size: var(--score); line-height: 1;
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -1px;
  background: none; border: 1.5px solid transparent; border-radius: var(--r);
  /* Even padding all round so the hover box sits evenly around the digits. */
  padding: 4px 8px; min-width: calc(2ch + 19px);
  text-align: center; cursor: text;
  transition: background var(--tr), border-color var(--tr);
}
.team-score:hover { background: var(--accent-soft); border-color: var(--accent-line); }
body.viewer-mode .team-score { cursor: default; pointer-events: none; }

.score-input {
  /* Same box as .team-score, so editing doesn't shift the layout. */
  font-family: var(--fd); font-weight: 800; font-size: var(--score); line-height: 1;
  width: calc(2ch + 19px); text-align: center; letter-spacing: -1px;
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: var(--r); color: var(--ink); padding: 4px 8px; outline: none;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }


.step-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 600; line-height: 1;
  border: 1.5px solid var(--border-firm); background: var(--surface);
  color: var(--ink2); cursor: pointer; flex-shrink: 0;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
  -webkit-tap-highlight-color: transparent;
}
.step-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.step-btn.minus:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }


/* Games in a longer match: the format line above the scores, and under
   each team one pip per game needed, filled for each game won. */
.court-tags { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; min-width: 0; }
.games-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 4px 8px; margin-bottom: 10px; font-size: 11.5px; color: var(--ink3);
}
.games-what { font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--ink2); }
.games-done {
  font-family: var(--fd); font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink2); background: var(--raised); border-radius: 99px; padding: 1px 8px;
}
.game-pips { display: flex; gap: 5px; justify-content: center; }
.game-pips span { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent-line); }
.game-pips span.on { background: var(--accent); border-color: var(--accent); }
.again-btn { font-size: 12px; margin: 0; max-width: 100%; text-align: center; overflow-wrap: anywhere; }

/* Staged */
.stage-hint { font-size: 12.5px; line-height: 1.4; color: var(--ink2); margin-bottom: 10px; }
/* Staged chips are tapped: pick one (or a locked pair), then a target or someone in the tray. */
.stage-chip, .stage-in, .stage-more { color: var(--ink); text-align: left; cursor: pointer; }
.stage-chip.is-picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-line); }
.stage-chip.is-target { border-style: dashed; border-color: var(--accent); }
.stage-in { border-style: dashed; }
.stage-in .chip-av + .chip-av { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.stage-more { padding-left: 11px; color: var(--ink2); }
.stage-tray {
  border: 1.5px dashed var(--accent-line); border-radius: var(--rs);
  padding: 10px; margin: -4px 0 12px; display: flex; flex-direction: column; gap: 6px;
}
.stage-away.link-btn { align-self: flex-start; margin: 2px 0 0; padding: 6px 0; font-size: 12px; text-align: left; }
.staged-teams { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.staged-team {
  background: var(--raised); border-radius: var(--rs); padding: 8px 10px;
  border: 1.5px solid transparent; transition: border-color var(--tr), background var(--tr);
}
.staged-team.drag-over {
  border-color: var(--accent); background: var(--accent-soft);
  border-style: dashed;
}
/* While a chip is in flight, show which courts can receive it. */
.is-dragging-chip .court-card.is-staged { outline: 2px dashed var(--accent-line); outline-offset: 2px; }
.is-dragging-chip .court-card:not(.is-staged) { opacity: .5; }
.staged-team-label { color: var(--ink3); margin-bottom: 6px; }
.staged-players { display: flex; gap: 6px; flex-wrap: wrap; min-height: 30px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--border-firm);
  border-radius: 99px; padding: 4px 11px 4px 5px;
  font-family: var(--fd); font-size: 13px; font-weight: 700;
  cursor: grab; user-select: none;
  transition: border-color var(--tr), background var(--tr), opacity var(--tr);
}
.chip { max-width: 100%; min-width: 0; }
.chip-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip:active { cursor: grabbing; }
.chip.dragging { opacity: .35; }
.chip.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.chip.locked {
  border-color: var(--accent);
  background: var(--accent-soft); color: var(--accent);
}
.chip-lock { color: var(--accent); margin-left: 1px; flex-shrink: 0; }
.chip-av {
  position: relative;
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.staged-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-start { flex: 1 0 auto; }
body.viewer-mode .staged-actions, body.viewer-mode .stage-hint, body.viewer-mode .stage-tray { display: none; }
body.viewer-mode .stage-chip { pointer-events: none; }
body.viewer-mode .chip { cursor: default; }

/* Tags: one shape for every small label pill */
.pair-tag, .held-tag, .next-tag, .mix-tag, .st-tag, .div-tag, .s-prov, .s-streak span, .viewer-badge, .live-tag, .sess-tag, .lvl-tag {
  font-family: var(--fu); font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
  padding: 1px 7px; border: 1px solid transparent; border-radius: 99px; white-space: nowrap;
}
.pair-tag, .held-tag, .next-tag, .mix-tag, .st-tag, .div-tag, .viewer-badge, .live-tag, .sess-tag { text-transform: uppercase; }

/* Balance readout */
.team-rec {
  float: right; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--ink3); font-variant-numeric: tabular-nums; font-size: 10px;
}
.balance { margin: 0 0 12px; }
.balance-track {
  position: relative; height: 5px; border-radius: 3px;
  background: var(--ink4); overflow: hidden;
}
.balance-track span {
  display: block; height: 100%; background: var(--accent);
  transition: width .35s cubic-bezier(.4,0,.2,1);
}
/* centre tick marks a perfectly even match */
.balance-track::after {
  content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px;
  width: 1.5px; background: var(--surface); transform: translateX(-50%);
}
.balance-label { margin-top: 5px; color: var(--ink3); }
.balance.is-even .balance-label { color: var(--accent); }
.balance.is-unknown .balance-track span { background: var(--ink4); }

/* ════════════════ Queue panel ════════════════ */
.queue-panel {
  border-left: 1px solid var(--border);
  background: var(--sunken);
  display: flex; flex-direction: column;
  position: sticky; top: 56px;
  max-height: calc(100vh - 56px);
  overflow: hidden;
}
.queue-head { padding: 18px 14px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.queue-subrow { display: flex; gap: 6px; margin-top: 8px; }
.queue-go { margin-top: 8px; }
.queue-subrow .btn { flex: 1; }

/* Auto-queue switch */
.switch {
  display: flex; align-items: center; gap: 9px; margin-top: 8px;
  padding: 8px 10px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; user-select: none;
  transition: border-color var(--tr), background var(--tr);
}
.switch:hover { border-color: var(--border-firm); }
.switch:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; flex-shrink: 0;
  width: 34px; height: 19px; border-radius: 99px;
  background: var(--ink4); transition: background var(--tr);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch-thumb {
  position: absolute; top: 2.5px; left: 2.5px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform var(--tr);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .switch-track .switch-thumb { transform: translateX(15px); }
.switch-text {
  font-size: 12.5px; font-weight: 600; color: var(--ink2);
  display: flex; align-items: baseline; gap: 6px;
}
.switch-text b {
  font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--ink3);
}
.switch:has(input:checked) .switch-text { color: var(--ink); }
.switch:has(input:checked) .switch-text b { color: var(--accent); }

.queue-list { flex: 1; overflow-y: auto; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.queue-blank {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--ink3); font-size: 13px; text-align: center; padding: 32px 20px;
}
.queue-blank .mark { color: var(--ink4); margin-bottom: 4px; }

.q-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--rs);
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 22px minmax(0,1fr) auto;
  gap: 9px; align-items: center;
  cursor: grab; user-select: none;
  transition: border-color var(--tr), box-shadow var(--tr), opacity var(--tr);
}
.q-item:active { cursor: grabbing; }
.q-item.is-dragging { opacity: .35; }
.q-item.drag-over { border-color: var(--accent); box-shadow: var(--ring); }
.q-item.next-up { border-color: var(--accent-line); background: var(--accent-soft); }
.q-item.held { background: transparent; cursor: default; border-style: dashed; }   /* no opacity: it took the text below 4.5:1 */
.q-item.held .q-names { color: var(--ink2); }
.held-tag { color: var(--ink3); border-color: var(--border); }
/* The four on the Up next card (queue master's list), and who mixing passed over. */
.next-tag { color: var(--accent); border-color: var(--accent-line); background: var(--surface); }
.mix-tag  { color: var(--ink2); border-color: var(--border); border-style: dashed; }
/* Up next (nextCard): a court card that previews the next match. */
.next-card { border-color: var(--ball); flex-shrink: 0; margin-bottom: 4px; }
.next-card .court-header { min-height: 34px; }
.next-card-title { font-family: var(--fu); font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--ball); }
.next-card-where { font-family: var(--fd); font-weight: 700; font-size: 13.5px; color: var(--hdr-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-card .court-body { padding: 10px 12px 12px; }
.next-card .staged-teams { margin-bottom: 10px; }
.next-card .chip { cursor: default; }
/* The queue master swaps the Up next teams by tapping two chips (or dragging one onto another). */
.next-chip { color: var(--ink); text-align: left; }
.next-card .next-chip { cursor: grab; }
.next-chip.is-picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-line); }
.next-chip.dragging { opacity: .35; }
body.viewer-mode .next-chip { pointer-events: none; cursor: default; }
.next-card-how { font-size: 11.5px; color: var(--ink3); margin: -2px 0 10px; }
.next-card-how .link-btn, .games-line .link-btn, .again-btn, .stage-away {
  background: none; border: none; padding: 0; margin-left: 4px; cursor: pointer;
  font: inherit; font-weight: 650; color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.next-card-note { font-size: 11.5px; color: var(--ink2); margin: -2px 0 10px; }
.next-card .balance:last-child, body.viewer-mode .next-card .staged-teams:last-child { margin-bottom: 0; }
body.viewer-mode .next-card .staged-teams { margin-bottom: 0; }
.q-meta .wl, .q-meta .wait { white-space: nowrap; flex-shrink: 0; }
.q-meta .next-tag, .q-meta .mix-tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.q-pos {
  font-family: var(--fd); font-weight: 800; font-size: 15px;
  color: var(--ink3); text-align: center; font-variant-numeric: tabular-nums;
}
.q-item.next-up .q-pos { color: var(--accent); }

.q-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
/* Viewers see each player's avatar before the names (a pair overlaps a little). */
.q-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.q-line .q-names { min-width: 0; }
.q-avs { display: none; flex-shrink: 0; }
body.viewer-mode .q-avs { display: flex; }
.q-avs .chip-av + .chip-av { margin-left: -2px; box-shadow: 0 0 0 2px var(--surface); }
.q-names {
  font-family: var(--fd); font-weight: 700; font-size: 13.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pair-tag {
  display: inline-block; vertical-align: middle; margin-left: 5px;
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line);
}
.q-meta { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.q-meta .wl { color: var(--ink2); font-weight: 600; }
.q-meta .wait { color: var(--warn); font-weight: 600; }

.fair-track { height: 3px; border-radius: 2px; background: var(--sunken); overflow: hidden; margin-top: 2px; }
.fair-fill  { height: 100%; border-radius: 2px; background: var(--accent); transition: width .4s ease; }

.q-mini {
  width: 22px; height: 18px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--rxs); background: var(--surface);
  color: var(--ink3); cursor: pointer; font-size: 9px; line-height: 1;
  transition: background var(--tr), color var(--tr), border-color var(--tr);
}
.q-mini:hover:not(:disabled) { background: var(--raised); color: var(--ink); border-color: var(--border-firm); }
.q-mini:disabled { opacity: .3; cursor: not-allowed; }
.q-mini.rm:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
body.viewer-mode .q-item { cursor: default; }

/* ════════════════ Collapsible sections ════════════════ */
.foot-panel { border-top: 1px solid var(--border); background: var(--surface); }
.foot-head {
  padding: 12px 18px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; transition: background var(--tr);
}
.foot-head:hover { background: var(--raised); }
/* A collapsed section docks at the bottom of the screen, so it's one tap
   away from anywhere on the page; it settles back into place at the end of
   the page. dockFeet() stacks the docked bars (each one's bottom offset). */
.foot-panel.docked { position: sticky; z-index: 80; }
.foot-panel.foot-first { margin-top: auto; }   /* #app is a full-height column */
.chev {
  color: var(--ink3); transition: transform var(--tr); display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin: -6px -6px -6px 0; border: none; background: none; border-radius: var(--rs); cursor: pointer;
}
.chev.closed { transform: rotate(-90deg); }
.head-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* Sync pill and live count share one height (22px) and one centre line;
   #liveTag is a wrapper span, so it has to be a flex box too. */
#liveTag { display: flex; }
#liveTag:empty { display: none; }
.head-tools .sync-pill, .head-tools .live-tag {
  height: 22px; min-height: 0; padding-top: 0; padding-bottom: 0; display: inline-flex; align-items: center; gap: 5px;
}
/* ＋ Court / ＋ Player sit right after their section's title and count. */
.title-row .btn--add { margin-left: 12px; padding: 0 12px; font-size: 12.5px; font-weight: 600; }

.players-grid {
  padding: 14px 18px 18px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px;
  max-height: 380px; overflow-y: auto;
}
#playersBody { container-type: inline-size; }
/* Locked partners: one box spanning two columns, stacked when only one fits. */
.p-pair {
  grid-column: span 2; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px;
  border: 1.5px dashed var(--accent-line); border-radius: var(--r);
}
@container (max-width: 465px) { .p-pair { grid-column: auto; grid-template-columns: 1fr; } }

/* Player card */
.p-card {
  background: var(--raised); border: 1.5px solid var(--border);
  border-radius: var(--rs); padding: 11px;
  display: flex; flex-direction: column; gap: 9px;
  transition: border-color var(--tr), background var(--tr);
}
.p-card.st-playing { border-color: var(--accent); background: var(--accent-soft); }
.p-card.st-queued  { border-color: var(--warn-line); background: var(--warn-soft); }
.p-card.st-staged  { border-color: var(--ball); }
.p-card.linkable:hover { border-color: var(--accent); background: var(--accent-soft); cursor: pointer; }

.p-top { display: flex; align-items: flex-start; gap: 9px; }
.p-av {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--sunken); color: var(--ink2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fd); font-weight: 800; font-size: 12px;
}

/* Avatar art (avArt): each player's own little pattern inside the circle —
   a ground colour and one shape in a second colour — under the initials. */
.chip-av, .p-av {
  overflow: hidden; isolation: isolate; color: var(--av-ink);
  outline: 1px solid var(--border); outline-offset: -1px;   /* a crisp edge over the art, on any card */
  font-weight: 800; letter-spacing: -.2px;
}
.p-av.st-playing { box-shadow: 0 0 0 2px var(--accent); }
.p-av.st-queued  { box-shadow: 0 0 0 2px var(--warn-line); }
.av-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.ab0 { fill: var(--av0); } .af0 { fill: var(--av0-hi); }
.ab1 { fill: var(--av1); } .af1 { fill: var(--av1-hi); }
.ab2 { fill: var(--av2); } .af2 { fill: var(--av2-hi); }
.ab3 { fill: var(--av3); } .af3 { fill: var(--av3-hi); }
.ab4 { fill: var(--av4); } .af4 { fill: var(--av4-hi); }
.ab5 { fill: var(--av5); } .af5 { fill: var(--av5-hi); }
.ab6 { fill: var(--av6); } .af6 { fill: var(--av6-hi); }
.ab7 { fill: var(--av7); } .af7 { fill: var(--av7-hi); }
.p-col { flex: 1; min-width: 0; }
.p-name {
  font-family: var(--fd); font-weight: 700; font-size: 14px; color: var(--ink);
  background: none; border: 1.5px solid transparent; border-radius: var(--rxs);
  padding: 1px 5px; margin-left: -5px; cursor: text; text-align: left;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block; transition: background var(--tr);
}
.p-name:hover { background: var(--surface); }
body.viewer-mode .p-name { cursor: default; pointer-events: none; }
.p-name-input {
  font-family: var(--fd); font-weight: 700; font-size: 14px;
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: var(--rxs); color: var(--ink); padding: 1px 5px; margin-left: -5px;
  outline: none; width: calc(100% + 10px);
}

.st-tag { display: inline-block; margin-top: 3px; }
.p-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 3px; }
.p-tags .st-tag { margin-top: 0; }

/* Club level (levelTag()): words and bars, never color alone */
.lvl-tag {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  background: var(--sunken); color: var(--ink2); border-color: var(--border);
}
.lvl-tag.lvl0 { background: var(--surface); color: var(--ink3); border-color: var(--border-firm); }   /* solid: dashed is Sitting out */
.lvl-bars { width: 13px; height: 10px; fill: currentColor; }
.lvl-bars .off { opacity: .28; }
.lvl-short { display: none; }
@media (max-width: 600px) {
  .lvl-full { display: none; } .lvl-short { display: inline; }
  /* Standings rows are tight on a phone: the name keeps the room, the bars carry the level. */
  .s-name .lvl-tag:not(.lvl0) { padding: 0; background: none; border: 0; color: var(--ink3); }
  .s-name .lvl-tag:not(.lvl0) .lvl-short { display: none; }
}
@media (max-width: 360px) { .s-name .lvl-tag { display: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.st-tag.playing { background: var(--accent); color: var(--on-accent); }
.st-tag.queued  { background: var(--surface); color: var(--warn); border-color: var(--warn-line); }
.st-tag.staged  { background: var(--ball); color: var(--on-ball); }
.st-tag.idle    { background: var(--sunken); color: var(--ink3); border-color: var(--border); }
.st-tag.expected { background: transparent; color: var(--ink3); border: 1px dashed var(--border); }
.p-card.st-expected .p-av { opacity: .6; }
.st-tag.sitting { background: var(--surface); color: var(--ink3); border-color: var(--ink4); border-style: dashed; }
.p-card.sitting { border-style: dashed; }

/* Four equal columns, one line each: value on a shared baseline, label
   never wraps (a wrapped label pushed its column out of line). */
.p-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr); gap: 4px; }  /* last column fits "1h 25m" */
.p-stat { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.p-stat b {
  font-family: var(--fd); font-weight: 700; font-size: 15px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.p-stat b.w { color: var(--good); }
.p-stat b.l { color: var(--bad); }
.p-stat b.t { color: var(--ink2); white-space: nowrap; }
.p-stat span { font-size: 10px; color: var(--ink3); letter-spacing: .3px; text-transform: uppercase; margin-top: 4px; white-space: nowrap; }

.partner-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink3);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--rs); padding: 4px 7px;
}
.partner-row b { font-weight: 600; color: var(--ink); flex: 1; font-size: 11.5px; }
.p-actions { display: flex; gap: 5px; }
.p-actions .btn { flex: 1; padding: 0 8px; }
body.viewer-mode .p-actions, body.viewer-mode .partner-row button { display: none; }

/* ════════════════ History ════════════════
   Four sizes, each with one job; scores use tabular figures so they
   line up row to row.
   ═══════════════════════════════════════════ */
.hist-wrap { padding: 0 18px 16px; max-height: 400px; overflow-y: auto; }

.hist-cols, .hrow {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 104px 70px;
  gap: 14px;
  align-items: center;
}
.hist-cols {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  padding: 9px 0 7px;
  border-bottom: 1.5px solid var(--border);
}
.hist-cols span { color: var(--ink3); }
.hist-cols .c-match { text-align: center; }
.hrow {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--tr);
}
.hrow:last-child { border-bottom: none; }
.hrow:hover { background: var(--raised); }

/* Court name, then the match's division (Mixed when it spanned two)
   whenever there is more than one division. */
.hrow-court {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-width: 0; font-size: 11.5px; font-weight: 600; color: var(--ink3);
}
.hrow-cname, .hrow-court .div-tag {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hrow-court .div-tag { display: block; }

/* Three-column match block gives the scores a vertical spine
   that lines up all the way down the list. */
.hrow-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px; align-items: center;
}
.hrow-team {
  font-size: 13.5px; font-weight: 500; color: var(--ink2);
  line-height: 1.35; word-break: break-word;
}
.hrow-team.l { text-align: right; }
.hrow-team.won { color: var(--ink); font-weight: 650; }

.hrow-nums { display: flex; align-items: center; gap: 2px; }
.hs.is-games, .hs.is-wl { cursor: default; }
.hs.is-games:hover, .hs.is-wl:hover { background: none; border-color: transparent; }
/* A longer match lists its games under the score, each one editable. */
.hrow-games { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; margin-top: -4px; }
.hrow-game { display: inline-flex; align-items: center; gap: 1px; }
.hrow-gn { font-size: 10.5px; font-weight: 700; color: var(--ink3); margin-right: 2px; }
.hrow-games .hs { font-size: 12.5px; min-width: 28px; padding: 1px 5px; }
.hs {
  font-family: var(--fu); font-weight: 650; font-size: 15px;
  color: var(--ink3); font-variant-numeric: tabular-nums;
  background: none; border: 1.5px solid transparent; border-radius: var(--rxs);
  padding: 2px 7px; cursor: text; min-width: 34px; text-align: center;
  transition: background var(--tr), border-color var(--tr), color var(--tr);
}
.hs.won { color: var(--good); font-weight: 700; }
.hs:hover { background: var(--accent-soft); border-color: var(--accent-line); }
body.viewer-mode .hs { cursor: default; pointer-events: none; }
.hs-sep { color: var(--ink4); font-size: 13px; }
.hs-input {
  font-family: var(--fu); font-weight: 700; font-size: 15px; width: 46px;
  text-align: center; background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: var(--rxs); color: var(--ink); padding: 2px 4px; outline: none;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.hs-input::-webkit-outer-spin-button,
.hs-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.hrow-when {
  font-size: 12px; color: var(--ink3); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hrow-ops { display: flex; gap: 4px; justify-content: flex-end; }
body.viewer-mode .hrow-ops { display: none; }
body.viewer-mode .hist-cols, body.viewer-mode .hrow {
  grid-template-columns: 92px minmax(0, 1fr) 104px;
}

@media (max-width: 680px) {
  .hist-cols { display: none; }
  .hrow, body.viewer-mode .hrow {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px; padding: 12px 0;
  }
  .hrow-match { grid-column: 1; grid-row: 2; }
  .hrow-court { grid-column: 1; grid-row: 1; flex-direction: row; align-items: center; gap: 8px; }
  .hrow-when { grid-column: 1; grid-row: 3; }
  .hrow-ops  { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
}

/* ════════════════ Standings ════════════════ */
.stand-wrap { padding: 0 18px 16px; max-height: 400px; overflow-y: auto; }
.stand-cols, .srow {
  display: grid;
  grid-template-columns: 34px minmax(0,1fr) 92px 52px 62px 46px 50px 54px;
  gap: 12px; align-items: center;
}
.stand-cols {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  padding: 9px 0 7px; border-bottom: 1.5px solid var(--border);
}
.stand-cols span { color: var(--ink3); }
.stand-cols .r { text-align: right; }
.srow {
  padding: 8px 0; border-bottom: 1px solid var(--border);
  transition: background var(--tr);
}
.srow:last-child { border-bottom: none; }
.srow:hover { background: var(--raised); }
.srow.lead { background: var(--accent-soft); }
.srow.lead:hover { background: var(--accent-soft); }

.s-rank {
  font-family: var(--fd); font-weight: 800; font-size: 15px;
  color: var(--ink3); text-align: center; font-variant-numeric: tabular-nums;
}
.srow.lead .s-rank { color: var(--accent); }

.s-name {
  display: flex; align-items: center; gap: 7px; min-width: 0;
}
.s-name b {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-live {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
}
.s-live.q { background: var(--warn); }

.s-bar {
  height: 6px; border-radius: 3px; background: var(--sunken);
  overflow: hidden; position: relative;
}
.s-bar span {
  display: block; height: 100%; border-radius: 3px;
  background: var(--accent); transition: width .4s cubic-bezier(.4,0,.2,1);
}
.s-pct {
  font-size: 13.5px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; text-align: right;
}
.s-wl {
  font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums;
  text-align: right;
}
.s-wl b { color: var(--good); font-weight: 650; }
.s-wl i { color: var(--ink3); font-style: normal; }
.s-diff {
  font-size: 13px; font-weight: 650; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--ink3);
}
.s-diff.up { color: var(--good); }
.s-diff.dn { color: var(--bad); }
.s-pts { text-align: right; font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.s-pts .u { display: none; font-size: 11px; color: var(--ink3); }
.s-streak { text-align: right; }
.s-streak span { display: inline-block; font-variant-numeric: tabular-nums; }
.s-streak .w { background: var(--good-soft); color: var(--good); }
.s-streak .l { background: var(--bad-soft); color: var(--bad); }
.s-streak .none { color: var(--ink4); }
.stand-note {
  font-size: 11.5px; color: var(--ink3); padding: 10px 0 0;
  border-top: 1px solid var(--border); margin-top: 4px;
}

/* Below the qualification threshold: still listed, rank withheld. */
.stand-divider {
  color: var(--ink3);
  padding: 13px 0 6px; margin-top: 4px;
  border-top: 1px dashed var(--border-firm);
}
.srow.prov .s-name b { color: var(--ink2); font-weight: 500; }
.srow.prov .s-bar span { background: var(--ink4); }
.s-rank.none { color: var(--ink4); font-weight: 600; }
.s-pct.dim { color: var(--ink3); font-weight: 500; }
.s-prov { flex-shrink: 0; color: var(--ink3); border: 1px dashed var(--border-firm); }

@media (max-width: 760px) {
  .stand-cols { display: none; }
  .srow {
    grid-template-columns: 30px minmax(0,1fr) 44px 54px 50px;
    gap: 6px 10px; padding: 10px 0;
  }
  .s-wl     { grid-column: 4 / span 2; }
  .s-bar    { grid-column: 2; grid-row: 2; }
  .s-diff   { grid-column: 3; grid-row: 2; }
  .s-pts    { grid-column: 4; grid-row: 2; }
  .s-pts .u { display: inline; }   /* no column headings on a phone */
  .s-streak { grid-column: 5; grid-row: 2; }
}

/* ════════════════ Modals ════════════════ */
.overlay { position: fixed; inset: 0; background: rgba(10,16,12,.5); z-index: 200; backdrop-filter: blur(3px); }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--rlg); padding: 22px; z-index: 210;
  width: min(420px, calc(100vw - 28px)); box-shadow: var(--shm);
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto;
  overscroll-behavior: contain;
}
.modal h3 { font-family: var(--fd); font-weight: 800; font-size: 18px; margin-bottom: 6px; }
.modal .sub { font-size: 13px; color: var(--ink3); margin-bottom: 16px; line-height: 1.5; }
.modal-in {
  width: 100%; padding: 10px 12px; border-radius: var(--rs);
  border: 1.5px solid var(--border-firm); background: var(--raised);
  color: var(--ink); font-size: 15px; margin-bottom: 16px;
  outline: none; transition: border-color var(--tr);
}
.modal-in:focus { border-color: var(--accent); box-shadow: var(--ring); }
.modal-row { display: flex; gap: 8px; justify-content: flex-end; }
.modal-body { margin-bottom: 18px; font-size: 13.5px; color: var(--ink2); line-height: 1.6; }
.modal-body b { color: var(--ink); font-weight: 600; }

.reset-opt {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 14px; border-radius: var(--rs); border: 1.5px solid var(--border-firm);
  background: var(--surface); cursor: pointer; width: 100%;
  transition: border-color var(--tr), background var(--tr);
}
.reset-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.reset-opt.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.reset-opt b { font-family: var(--fd); font-weight: 700; font-size: 14px; color: var(--ink); }
.reset-opt span { font-size: 12px; color: var(--ink3); line-height: 1.45; }

.pick-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--rs); border: 1.5px solid var(--border);
  background: var(--raised); cursor: pointer; transition: border-color var(--tr), background var(--tr);
}
.pick-row:hover { border-color: var(--border-firm); }
.pick-row.on { border-color: var(--accent); background: var(--accent-soft); }
.pick-row input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.pick-row .nm { font-family: var(--fd); font-weight: 700; font-size: 13.5px; }
.pick-row .rc { font-size: 11px; color: var(--ink3); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Change players: the two teams as tap-to-swap chips, then who can come in. */
.lineup-teams { margin-bottom: 12px; }
.lineup-teams .next-chip { cursor: pointer; }
.lineup-in { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; margin-bottom: 14px; }
.lineup-in:empty { display: none; }
.lineup-in-head { font-size: 12px; font-weight: 700; color: var(--ink2); }
.lineup-in .pick-row { font: inherit; color: var(--ink); text-align: left; width: 100%; flex-shrink: 0; }
.lineup-over {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding-top: 12px; margin-bottom: 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--ink3);
}

/* ════════════════ Viewer mode ════════════════ */
body.viewer-mode .admin-only { display: none !important; }
.viewer-badge {
  display: none; align-items: center; gap: 5px;
  background: var(--ball); color: var(--on-ball);
}
body.viewer-mode .viewer-badge { display: inline-flex; }

/* Viewer on a phone: someone courtside checking scores and when they're up. */
@media (max-width: 600px) {
  .courts-panel { padding: 14px 12px; min-height: 0; }
  .courts-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  /* One 12px side gutter on a phone, matching the header. */
  .foot-head { padding: 12px; }
  .players-grid { padding: 12px 12px 14px; }
  .stand-wrap, .hist-wrap { padding: 0 12px 14px; max-height: none; }
  .queue-head { padding: 14px 12px 10px; }
  .queue-list { padding: 8px 12px 14px; }
  body.viewer-mode .court-body { padding: 12px 14px; }
  body.viewer-mode .court-empty { padding: 6px 0; }
  body.viewer-mode .staged-teams { margin-bottom: 0; }
}

/* ════════════════ Divisions ════════════════ */
.s0 { --dc: var(--div1); --dcs: var(--div1-soft); }
.s1 { --dc: var(--div2); --dcs: var(--div2-soft); }
.s2 { --dc: var(--div3); --dcs: var(--div3-soft); }
.mixed { --dc: var(--ink3); --dcs: var(--sunken); }
.div-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--dc); flex-shrink: 0; vertical-align: middle;
}
.div-tag {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--dc); background: var(--dcs); border-color: var(--dc);
}
.court-card.has-div .court-header { box-shadow: inset 0 -3px 0 var(--dc); }
.court-div { margin-bottom: 10px; }
.q-section {
  display: flex; align-items: center; gap: 7px;
  color: var(--dc); padding: 8px 2px 2px;
}
.q-section:first-child { padding-top: 0; }
.q-section .count-pill { margin-left: 0; }
.q-item.has-div { box-shadow: inset 3px 0 0 var(--dc); }
/* Division picker: a dropdown showing the player's division, with the
   division's colour as a left rail. The list is our own popover (#divMenu),
   not the native one, so it matches the theme on every platform. */
.p-div {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 30px;
  padding: 0 10px; min-width: 0;
  border: 1.5px solid var(--border-firm); border-left: 4px solid var(--dc, var(--border-firm));
  border-radius: var(--rs); background: var(--surface);
  color: var(--ink); font-family: var(--fu); font-size: 12.5px; font-weight: 600; text-align: left;
  cursor: pointer; transition: border-color var(--tr), background-color var(--tr);
}
.p-div-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-div svg { color: var(--ink3); flex-shrink: 0; }
.p-div[aria-expanded="true"] svg { transform: rotate(180deg); }
.p-div:hover:not(:disabled), .p-div[aria-expanded="true"] { background: var(--raised); border-color: var(--ink4); border-left-color: var(--dc, var(--ink4)); }
.p-div:focus-visible { outline: none; box-shadow: var(--ring); }
.p-div:disabled { opacity: .55; cursor: not-allowed; }
body.viewer-mode .p-div { display: none; }

.div-menu {
  position: fixed; z-index: 130; padding: 5px;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--r); box-shadow: var(--shm);
  display: flex; flex-direction: column; gap: 2px;
}
.div-menu[hidden] { display: none; }
.div-opt {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px;
  padding: 0 10px; border: none; border-radius: var(--rs); background: none;
  color: var(--ink); font-family: var(--fu); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.div-opt span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.div-opt .div-dot { width: 10px; height: 10px; }
.div-opt svg { color: var(--dc); flex-shrink: 0; visibility: hidden; }
.div-opt[aria-selected="true"] { background: var(--dcs); color: var(--dc); }
.div-opt[aria-selected="true"] svg { visibility: visible; }
.div-opt:hover:not([aria-selected="true"]), .div-opt:focus-visible:not([aria-selected="true"]) { background: var(--raised); }
.div-opt:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-line); }
.stand-group {
  display: flex; align-items: center; gap: 8px; padding: 16px 0 4px;
  font-family: var(--fd); font-weight: 700; font-size: 14px; color: var(--ink);
}
.stand-group:first-child { padding-top: 10px; }
.seg { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-height: 34px; border-radius: var(--rs); cursor: pointer;
  border: 1.5px solid var(--border-firm); background: var(--surface);
  color: var(--ink2); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button.on { border-color: var(--dc); background: var(--dcs); color: var(--dc); }
.div-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.div-row .modal-in { margin: 0; flex: 1; padding: 8px 10px; font-size: 14px; }
.div-row .meta { font-size: 11px; color: var(--ink3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pick-warn {
  font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft);
  border: 1.5px solid var(--warn-line); border-radius: var(--rs); padding: 7px 10px; margin-bottom: 12px;
}

/* Check-in: One / Several */
.modal-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.modal-titlebar h3 { margin: 0; }
.mode-toggle {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 99px;
  background: var(--sunken); border: 1px solid var(--border);
}
.mode-toggle button {
  border: none; background: transparent; color: var(--ink3); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 99px;
  transition: background var(--tr), color var(--tr);
}
.mode-toggle button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh); }
.bulk-in { resize: vertical; min-height: 120px; line-height: 1.5; font-family: var(--fu); margin-bottom: 8px; }
.bulk-sum { font-size: 12px; color: var(--ink3); margin-bottom: 14px; }
.bulk-sum b { color: var(--accent); }

/* Check-in from a club's roster: tap players to pick them, then check them all in */
.roster-pick .modal-in { margin-bottom: 8px; }
.roster-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px;
  max-height: min(46vh, 340px); overflow-y: auto; padding: 2px; margin-bottom: 12px;
}
.roster-chip {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px;
  border: 1.5px solid var(--border-firm); border-radius: var(--rs); background: var(--surface);
  color: var(--ink2); font: 600 14px/1.25 var(--fu); text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.roster-chip .tick {
  flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-firm);
  display: grid; place-items: center; font-size: 11px; line-height: 1; color: transparent;
}
.roster-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.roster-chip[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.roster-chip.is-new { border-style: dashed; }
.roster-empty { grid-column: 1 / -1; font-size: 13px; color: var(--ink3); padding: 6px 2px; }

/* Sync status (only with ?s=<code>), in the Courts heading */
.sync-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0;
  font-family: var(--fu); font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
  color: var(--ink2); border: 1px solid var(--border-firm); border-radius: 99px; padding: 2px 9px;
  white-space: nowrap;
  min-width: 104px;   /* Synced ⇄ Pending · 12 flips on every change; the heading mustn't shift with it */
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink3); flex-shrink: 0; }
.sync-pill.is-synced .sync-dot { background: var(--good); }
.sync-pill.is-pending .sync-dot { background: var(--ball); }
.sync-pill.is-offline { color: var(--bad); border-color: var(--bad); }
.sync-pill.is-offline .sync-dot { background: var(--bad); }

/* Sessions dialog */
.sync-pill { cursor: default; background: none; }
.sync-pill.is-blocked { cursor: pointer; color: var(--ink); border-color: var(--ball); }
.sync-pill.is-blocked .sync-dot { background: var(--ball); }
.sync-pill.is-ended { border-color: var(--border); color: var(--ink3); }
.sess-block { border-top: 1px solid var(--border); padding: 14px 0; }
.sess-block:first-child { border-top: none; padding-top: 4px; }
.sess-block h4 { color: var(--ink3); margin-bottom: 10px; }
.sess-who { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink2); }
.sess-who b { color: var(--ink); font-weight: 650; }
.sess-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sess-form { display: flex; flex-direction: column; gap: 8px; }
.sess-club { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.sess-club .modal-in { margin: 0; flex: 1; min-width: 0; }
.sess-form .modal-in { margin: 0; }
.sess-err { font-size: 12.5px; color: var(--bad); min-height: 1em; }
.end-warn { margin: 10px 0 0; color: var(--bad); }
.end-warn b { color: inherit; }
.sess-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.sess-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--rs); background: var(--raised);
}
.sess-row.is-here { border-color: var(--accent); background: var(--accent-soft); }
.sess-label { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.sess-title { font-family: var(--fd); font-weight: 700; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-title.is-untitled { font-weight: 500; color: var(--ink2); }
.sess-label .sess-code { font-size: 11.5px; letter-spacing: 1px; color: var(--ink2); }
.sess-code { font-weight: 800; letter-spacing: 1.5px; font-variant-numeric: tabular-nums; color: var(--ink); }
.sess-meta { font-size: 12px; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A row: name and code, Open, and ⋯ for the rest (End, Archive/Restore) in a strip below. */
.sess-row > .sess-actions { flex-wrap: nowrap; align-items: center; gap: 4px; }
.sess-row a.btn { text-decoration: none; }
.sess-more { color: var(--ink3); }
.sess-row.is-open .sess-more { background: var(--surface); color: var(--ink); }
.sess-row-more {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.sess-title-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sess-title-line .sess-title { min-width: 0; }
.sess-tag { flex-shrink: 0; color: var(--ink3); border-color: var(--border); }
.sess-tag.is-here { color: var(--accent); border-color: var(--accent-line); background: var(--surface); }
.sess-shelf-toggle {
  display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 4px 0;
  background: none; border: none; cursor: pointer;
  font-family: var(--fu); font-size: 12.5px; font-weight: 650; color: var(--ink2);
}
.sess-shelf-toggle:hover { color: var(--ink); }
.sess-shelf-toggle + .sess-list { margin-top: 6px; }
.sess-code-in { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.sess-note { font-size: 12.5px; color: var(--ink3); line-height: 1.5; }
.sess-row-more .sess-why { align-self: center; }

/* Lock screen: a synced session this device isn't allowed to show */
.lock-screen {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: var(--hdr-bg); color: var(--hdr-ink);
  align-items: center; justify-content: center; padding: 24px;
}
body.session-locked #lockScreen { display: flex; }
.lock-card { max-width: 360px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.lock-card p { font-size: 15px; line-height: 1.5; color: var(--hdr-ink2); }
.lock-card p b { color: var(--hdr-ink); letter-spacing: 1px; }
.lock-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Start screen: an empty local slot asks online or local first */
body.start-open .start-screen { display: flex; }
.start-screen .lock-card { width: 100%; max-width: 320px; }
.start-title { font-family: var(--fd); font-weight: 800; font-size: 22px; line-height: 1.2; color: var(--hdr-ink); margin: 0; }
.start-opt { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.start-opt .btn { min-height: 44px; }
.start-sub { font-size: 13px; line-height: 1.4; color: var(--hdr-ink2); }

/* Closed session: read-only, can't be restarted */
.closed-bar {
  display: none; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: var(--sunken); color: var(--ink2); border-bottom: 1px solid var(--border-firm);
  padding: 8px 20px; font-size: 12.5px; text-align: center;
}
.closed-bar b { color: var(--ink); }
body.session-closed .closed-bar { display: flex; }
body.session-closed .paused-bar, body.session-closed .setup-bar, body.session-closed .setup-panel { display: none; }
body.session-closed #viewBtn { display: none !important; }   /* can't leave the read-only view */
body.session-closed #sessionsBtn { display: flex !important; }   /* the way to a new session */

/* Final results: an ended session swaps the courts and queue for a podium
   per division and a few highlights. Standings and History stay below. */
.results { display: none; padding: 26px 18px 30px; border-bottom: 1px solid var(--border); }
body.session-ended .results { display: block; }
body.session-ended .main-area { display: none; }
.res-head { text-align: center; margin-bottom: 22px; }
.res-kicker { color: var(--accent); margin-bottom: 4px; }
.res-title {
  font-family: var(--fd); font-weight: 800; font-size: 28px; line-height: 1.15; color: var(--ink);
  overflow-wrap: anywhere;
}
.res-meta { margin-top: 6px; font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.res-divs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px;
  max-width: 1080px; margin: 0 auto;
}
.res-divs.one { max-width: 560px; }
.res-div {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--rlg);
  padding: 16px 16px 0; box-shadow: var(--sh); display: flex; flex-direction: column; min-width: 0;
}
.res-div .stand-group { padding: 0 0 12px; }
.res-none { padding: 18px 4px 22px; text-align: center; font-size: 13px; color: var(--ink3); }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; margin-top: auto; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; text-align: center; }
.pod.r1 { order: 2; } .pod.r2 { order: 1; } .pod.r3 { order: 3; }
.pod-medal {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--fd); font-weight: 800; font-size: 19px; color: var(--on-medal);
  background: var(--mc); box-shadow: inset 0 0 0 3px rgba(255,255,255,.28), var(--sh); margin-bottom: 2px;
}
.pod.r1 .pod-medal { width: 48px; height: 48px; font-size: 23px; }
.pod.r1 { --mc: var(--gold); } .pod.r2 { --mc: var(--silver); } .pod.r3 { --mc: var(--bronze); }
.pod-names { display: flex; flex-direction: column; width: 100%; min-width: 0; }
.pod-names b {
  font-family: var(--fd); font-weight: 700; font-size: 15px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pod.r1 .pod-names b { font-size: 17px; font-weight: 800; }
.pod-more { font-size: 12px; color: var(--ink3); }
.pod-stat { font-size: 12px; color: var(--ink3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pod-stat .up { color: var(--good); font-weight: 700; }
.pod-block {
  width: 100%; margin-top: 6px; border-radius: var(--rs) var(--rs) 0 0;
  background: var(--raised); border: 1.5px solid var(--border); border-bottom: none;
  border-top: 4px solid var(--mc);
}
.pod.r1 .pod-block { height: 74px; background: var(--accent-soft); }
.pod.r2 .pod-block { height: 50px; }
.pod.r3 .pod-block { height: 34px; }
.pod.empty-step .pod-block { border-top-color: var(--border); }

.res-highs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px;
  max-width: 1080px; margin: 18px auto 0;
}
/* Highlights: cards like the podium's, each with its own colour (--hc). */
.res-high {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r);
  border-left: 4px solid var(--hc); padding: 12px 14px; box-shadow: var(--sh);
}
.res-high.h-games  { --hc: var(--accent); --hc-soft: var(--accent-soft); }
.res-high.h-streak { --hc: var(--div2);   --hc-soft: var(--div2-soft); }
.res-high.h-big    { --hc: var(--warn);   --hc-soft: var(--warn-soft); }
.res-high-ico {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--hc); background: var(--hc-soft);
}
.res-high-txt { min-width: 0; flex: 1; }
.res-high-txt span { display: block; color: var(--ink3); margin-bottom: 2px; }
.res-high b {
  display: block; font-family: var(--fd); font-weight: 700; font-size: 15px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.res-high i { font-style: normal; font-size: 13px; font-weight: 700; color: var(--hc); font-variant-numeric: tabular-nums; }
.res-kicker, .res-high-txt span {
  font-family: var(--fu); font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
}
/* Share results: the card's preview dialog. */
.res-share { display: flex; justify-content: center; margin-top: 14px; }
.btn--share { position: relative; background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn--share::after { content: ''; position: absolute; inset: -7px 0; }   /* a 44px+ tap area around a 34px button */
.btn--share svg { width: 16px; height: 16px; }
@media (hover: hover) { .btn--share:hover { border-color: var(--accent); } }
.card-prev { display: flex; align-items: center; justify-content: center; min-height: 200px; margin-bottom: 14px; }
.card-prev img {
  display: block; max-width: 100%; max-height: min(52vh, 520px); max-height: min(52dvh, 520px);
  border-radius: var(--rs); box-shadow: var(--shm);
}
.card-wait { font-size: 13px; color: var(--ink3); }
.card-size { --dc: var(--accent); --dcs: var(--accent-soft); }
.card-size button, #cardModal .modal-row .btn { min-height: 44px; }
#cardModal .modal-row { flex-wrap: wrap; }
@media (max-width: 600px) {
  .results { padding: 20px 12px 24px; }
  .res-title { font-size: 23px; }
  .res-divs { grid-template-columns: 1fr; }
  .res-div { padding: 14px 10px 0; }
  .pod-names b { font-size: 14px; }
  .pod.r1 .pod-names b { font-size: 15px; }
}

/* A short burst when the results appear. Decorative; skipped with reduced motion. */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 120; }
.confetti i {
  position: absolute; top: -14px; left: var(--x); width: 8px; height: var(--h, 13px); border-radius: var(--br, 2px);
  background: var(--c); opacity: 0;
  animation: confetti-fall var(--d) cubic-bezier(.25,.6,.45,1) var(--w) forwards;
}
@keyframes confetti-fall {
  0%   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--dx), 105vh, 0) rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* Header menu: everything that isn't needed mid-play */
.hmenu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 120;
  min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--r); box-shadow: var(--shm);
  display: flex; flex-direction: column; gap: 2px;
  max-height: calc(100dvh - 90px); overflow-y: auto; overscroll-behavior: contain;   /* a phone held sideways */
}
.menu-panel[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; border-radius: var(--rs); background: none;
  color: var(--ink); font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.menu-item svg { color: var(--ink3); flex-shrink: 0; }
.menu-lbl { display: grid; min-width: 0; }
.menu-sub { color: var(--ink2); font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.menu-sub[hidden] { display: none; }
/* Below 380px the account button takes the theme toggle's place in the header; the toggle moves here. */
.narrow-only { display: none; }
@media (max-width: 380px) {
  body:not(.viewer-mode):has(#acctBtn:not([hidden])) .menu-item.narrow-only { display: flex; }
  body:not(.viewer-mode):has(#acctBtn:not([hidden])) #themeBtn { display: none; }
}
.menu-item:hover, .menu-item:focus-visible { background: var(--raised); }
.menu-item[hidden] { display: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
body.viewer-mode .menu-sep { display: none; }
body.share-viewer .hmenu { display: none; }   /* a viewer link: nothing in the menu applies */

/* Sessions dialog: the viewer link */
.share-qr { width: 168px; margin: 0 auto 12px; border-radius: var(--rs); overflow: hidden; }
.share-qr svg, .watch-qr svg { display: block; width: 100%; height: auto; }
.share-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.share-url { flex: 1; min-width: 0; margin: 0; padding: 8px 10px; font-size: 12.5px; color: var(--ink2); }

/* Set-aside (quarantined) copies */
.menu-count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--accent);
              color: var(--on-accent); font-size: 11.5px; font-weight: 700; text-align: center; }
.aside-item { border: 1.5px solid var(--border); border-radius: var(--rs); padding: 12px; margin-bottom: 10px; }
.aside-when { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.aside-item .sess-note { margin-bottom: 10px; }

/* Shared screen: "watch on your phone", in viewer mode on the queue master's device */
.watch-card {
  position: fixed; right: 16px; bottom: calc(16px + var(--dock-h, 0px)); z-index: 90; width: 176px; padding: 12px;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shm); text-align: center;
}
.watch-card[hidden] { display: none; }
.watch-qr { border-radius: var(--rs); overflow: hidden; margin-bottom: 8px; }
.watch-card b { display: block; font-family: var(--fd); font-weight: 800; font-size: 14px; }
.watch-card span { font-size: 12px; color: var(--ink3); }
.watch-x { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: none; background: none;
           color: var(--ink3); font-size: 18px; line-height: 1; cursor: pointer; border-radius: var(--rs); }
.watch-x:hover, .watch-x:focus-visible { background: var(--raised); color: var(--ink); }
@media (max-width: 600px) { .watch-card { display: none; } }   /* a phone isn't the shared screen */

/* "Tell me when I'm up" (Notify): a viewer-link player taps their name. */
.notify-btn { margin-left: auto; gap: 6px; max-width: 55%; }
.notify-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.notify-btn[hidden] { display: none; }
body.share-viewer .q-item, body.share-viewer .next-card .chip { cursor: pointer; }
body.share-viewer .next-chip { pointer-events: auto; }
.q-item.is-me { border-color: var(--ball); box-shadow: 0 0 0 1.5px var(--ball); }
.chip.is-me { border-color: var(--ball); box-shadow: 0 0 0 2px var(--ball); }
.notify-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 12px; padding: 2px; }
.notify-pick { cursor: pointer; color: var(--ink); }
.notify-pick.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 2px var(--accent-line); }
.notify-note { font-size: 12.5px; color: var(--ink3); line-height: 1.5; margin-bottom: 14px; }
.notify-note:empty { display: none; }
#notifyOff[hidden] { display: none; }
/* The alert itself: pinned to the top until it's dismissed or the turn moves on. */
.up-alert {
  position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  z-index: 480; width: min(520px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px;
  background: var(--hdr-bg); color: var(--hdr-ink); border: 2px solid var(--ball);
  border-radius: var(--r); box-shadow: var(--shm);
}
.up-alert[hidden] { display: none; }
.up-alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.up-alert-text b { font-family: var(--fd); font-weight: 800; font-size: 16px; color: var(--ball); }
.up-alert-text span { font-size: 13px; color: var(--hdr-ink2); }
.up-alert[data-kind="staged"] { animation: up-pulse 1.4s ease-in-out 3; }
@keyframes up-pulse { 50% { box-shadow: 0 0 0 6px var(--ball); } }
@media (prefers-reduced-motion: reduce) { .up-alert[data-kind="staged"] { animation: none; } }

/* ════════════════ Queue rail and court cards (F004) ════════════════
   Every queue-master control here is at least 44px for any pointer, and
   the one main action on a card is 48px. */
.courts-panel .btn, .queue-panel .btn { min-height: 44px; font-size: 13.5px; }
.btn.next-go, .btn.stage-start, .btn.finish-btn { min-height: 48px; font-size: 14.5px; font-weight: 700; }

/* Court bar: name, tags, clock, Pause, Options. The card can't clip the menu. */
.court-card { overflow: visible; position: relative; }
.court-card > .court-header { border-radius: calc(var(--r) - 1.5px) calc(var(--r) - 1.5px) 0 0; min-height: 52px; padding: 4px 6px 4px 14px; }
.court-name { min-height: 40px; }
.court-bar-btn { padding: 0 10px; flex-shrink: 0; }
.court-card > .court-header { gap: 6px; }
.court-card .court-name { flex-shrink: 1; min-width: 0; }
.court-bar-btn.is-paused { color: var(--ball); border-color: var(--ball); }
.fmt-tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 99px;
  border: 1px solid var(--hdr-line); color: var(--hdr-ink2); font-size: 11px; font-weight: 600;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmenu {
  position: absolute; right: 6px; top: 50px; z-index: 30; width: 230px;
  background: var(--surface); border: 1.5px solid var(--border-firm); border-radius: var(--r);
  box-shadow: var(--shm); padding: 6px; display: flex; flex-direction: column;
}
.cmenu[hidden] { display: none; }
.cmenu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 0 12px; border: none; border-radius: var(--rs); background: none;
  font-family: var(--fu); font-size: 14px; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer;
}
.cmenu-item:hover, .cmenu-item:focus-visible { background: var(--raised); }
.cmenu-item.is-bad { color: var(--bad); }
.cmenu-val { font-size: 12.5px; color: var(--ink3); font-weight: 600; }

/* Live court: one row per team, − score + on the right. */
.team-rows { --score: 34px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.team-row { display: flex; align-items: center; gap: 8px; }
.team-row-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.team-row-name .game-pips { justify-content: flex-start; }
.team-row-score { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.team-row .step-btn { width: 44px; height: 44px; font-size: 21px; }
.winner-row { padding-top: 12px; border-top: 1px solid var(--border); }
.finish-btn {
  width: 100%; white-space: normal; height: auto; padding: 8px 12px; line-height: 1.25;
  text-align: center; overflow-wrap: anywhere;
}
.finish-btn:disabled { opacity: 1; background: var(--raised); border-color: var(--border); color: var(--ink2); font-weight: 600; font-size: 13px; }
.winner-row.is-wl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@container (max-width: 260px) { .winner-row.is-wl { grid-template-columns: 1fr; } }
body.viewer-mode .team-rows { --score: 44px; margin-bottom: 0; }

/* Staged court: teams side by side, Clear and Balance, then Start. */
.court-card { container-type: inline-size; }
/* container-type makes each card its own stacking context: lift the one whose menu is open over the next card. */
.court-card:has(.cmenu:not([hidden])) { z-index: 40; }
/* Side by side only when a half still fits a full name; narrower cards stack the teams. */
@container (min-width: 380px) {
  .court-body .staged-teams { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .court-body .staged-players { flex-direction: column; align-items: stretch; }
}
.nw { white-space: nowrap; }
.staged-players .chip { min-height: 44px; }
.court-card .team-rec { float: none; display: block; margin-top: 2px; }
.staged-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.staged-actions .stage-start { grid-column: 1 / -1; }
.court-empty-actions { flex-direction: column; align-self: stretch; }
.court-empty-actions .btn { width: 100%; }
.again-btn, .games-line .link-btn, .next-card-how .link-btn { min-height: 44px; }

/* Why-notes: mixing changed the four, or the split rotates partners. */
.why { font-size: 12.5px; line-height: 1.4; font-weight: 600; border-radius: var(--rs); padding: 8px 10px; margin: 0 0 10px; }
.why--rotate, .why--winners { background: var(--accent-soft); color: var(--accent); }
.why--mix, .why--repeat { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.next-card .why { margin-top: -2px; }

/* Queue column: Rules folds the switches; rows open an action strip. */
.rules-btn { width: 100%; margin-top: 10px; justify-content: space-between; }
.rules-btn::after { content: ''; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform var(--tr); }
.rules-btn[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-2px); }
.rules-btn span { color: var(--accent); font-weight: 700; margin-left: 4px; margin-right: auto; }
.rules-panel { margin-top: 2px; }
.rules-panel[hidden] { display: none; }
.rules-panel .switch { min-height: 44px; box-sizing: border-box; }
.queue-subrow .btn { min-height: 44px; }

.q-item { display: flex; flex-direction: column; padding: 0; gap: 0; }
.q-main {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: center;
  width: 100%; min-height: 60px; padding: 8px 12px; border: none; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: inherit;
}
div.q-main { cursor: default; }
.q-main .fair-track, .q-main .fair-fill { display: block; }
.q-main .q-names { display: block; font-size: 14.5px; }
.q-row { display: flex; align-items: stretch; align-self: stretch; }
.q-row .q-main { flex: 1; min-width: 0; }
/* Drag starts here: some browsers won't start a drag from inside a button. Mouse only:
   touch has the action strip. */
.q-grip {
  width: 22px; flex-shrink: 0; cursor: grab; margin-left: 4px; border-radius: var(--rxs);
  background: radial-gradient(circle, var(--ink4) 1.4px, transparent 1.6px) center / 8px 8px repeat-y;
  background-size: 8px 7px; background-position: center 50%;
  -webkit-mask: linear-gradient(transparent 30%, #000 30%, #000 70%, transparent 70%);
          mask: linear-gradient(transparent 30%, #000 30%, #000 70%, transparent 70%);
}
@media (hover: none), (pointer: coarse) { .q-grip { display: none; } }
.court-bar-btn.court-opts { width: 44px; padding: 0; }
.q-item.is-open { border-color: var(--accent); box-shadow: var(--ring); }
.q-item.passed { border-style: dashed; border-color: var(--warn-line); }
.q-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 8px;
  background: var(--accent-soft); border-top: 1.5px solid var(--accent-line);
  border-radius: 0 0 calc(var(--rs) - 1.5px) calc(var(--rs) - 1.5px);
}
.q-act {
  min-height: 44px; border-radius: var(--rs); border: 1.5px solid var(--accent-line); background: var(--surface);
  font-family: var(--fu); font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer; padding: 0 4px;
}
.q-act:hover:not(:disabled) { border-color: var(--accent); }
.q-act:disabled { color: var(--ink3); border-color: var(--border); cursor: not-allowed; }
.q-act.is-bad { color: var(--bad); }
.q-act.is-bad:hover { background: var(--bad-soft); border-color: var(--bad); }
.q-held { font-size: 12.5px; color: var(--ink3); text-align: center; padding: 6px 0 2px; }
.q-meta .next-tag, .q-meta .mix-tag { font-size: 11px; padding: 2px 8px; }
.mix-tag { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
@media (min-width: 1100px) { .main-area { grid-template-columns: minmax(0,1fr) 360px; } }
.courts-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

/* Birthday mode (F006). The palette is in tokens.css; these are the marks. */
.bday-bar { position: relative; z-index: 1; }
.bunting { display: block; width: 100%; height: 16px; background: var(--hdr-bg); }
.bunting .fl-line { stroke: var(--hdr-ink2); stroke-width: 1; fill: none; opacity: .6; }
.bunting .fl0 { fill: var(--bday-pop); } .bunting .fl1 { fill: var(--gold); }
.bunting .fl2 { fill: var(--hdr-ink); }  .bunting .fl3 { fill: var(--ball); }
.bday-msg {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px 16px 13px; min-width: 0;
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--accent-hi), var(--accent) 50%, var(--accent-hi));
  font-family: var(--fd); font-weight: 800; font-size: 21px; line-height: 1.25; letter-spacing: -.2px;
  text-shadow: 0 1px 0 var(--accent-hi);
}
.bday-msg > span { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bday-msg > svg:not(.sprinkles) { position: relative; flex-shrink: 0; width: 22px; height: 22px; }
.bday-words { display: flex; flex-direction: column; align-items: center; }
.bday-words > * { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bday-words > small { font-family: var(--fu); font-size: 14px; font-weight: 600; letter-spacing: 0; opacity: .92; }
.bday-words > small[hidden] { display: none; }
.bday-photo { position: relative; flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--on-accent); background: var(--accent-hi); }
.sprinkles { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .6; pointer-events: none; }
.sprinkles .sp0 { fill: var(--gold); } .sprinkles .sp1 { fill: var(--bday-pop); } .sprinkles .sp2 { fill: var(--hdr-ink); }
.sprinkles .sp3 { fill: var(--ball); } .sprinkles .sp4 { fill: var(--div3-soft); }
.bday-msg .flame { fill: var(--gold); stroke: var(--gold); transform-box: fill-box; transform-origin: 50% 100%;
  animation: flicker 1.6s ease-in-out infinite alternate; }
@keyframes flicker { 0% { transform: scale(1) rotate(-4deg); } 50% { transform: scale(1.15, .9) rotate(3deg); } 100% { transform: scale(.92, 1.1) rotate(-2deg); } }
/* A slow sheen across the strip. */
.bday-msg::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, var(--bday-sheen) 50%, transparent 60%);
  transform: translateX(-100%); animation: sheen 7s ease-in-out 1s infinite;
}
@keyframes sheen { 0%, 70% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
/* Frosting: scallops along the bottom edge. */
.bday-bar::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 7px; pointer-events: none;
  background: radial-gradient(circle at 9px 0, var(--accent) 7px, transparent 7.5px) 0 0 / 18px 7px repeat-x;
}
.bday-bar { margin-bottom: 7px; }
.bday-bar.cheer .bday-msg { animation: bday-pop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes bday-pop { 0% { transform: scale(.94); } 100% { transform: scale(1); } }
@media (max-width: 600px) {
  .bday-msg { font-size: 17px; gap: 8px; padding: 10px 12px 11px; }
  .bday-msg > svg:not(.sprinkles) { width: 18px; height: 18px; }
  .bday-words > small { font-size: 13px; }
  .bday-photo { width: 38px; height: 38px; }
  .bday-photo:not([hidden]) ~ svg:last-child { display: none; }   /* room for the name at 320 px */
}
@media (prefers-reduced-motion: reduce) { .bday-msg .flame, .bday-msg::after { animation: none; } .bday-msg::after { display: none; } }

/* Sprinkles on the page ground only; cards keep their plain surfaces. */
:root[data-occasion="birthday"] body {
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--bday-pop) 40%, transparent) 1.6px, transparent 2.2px),
    radial-gradient(circle, color-mix(in srgb, var(--gold) 40%, transparent) 1.6px, transparent 2.2px);
  background-size: 46px 46px, 62px 62px;
  background-position: 0 0, 23px 31px;
}
.p-card:has(.av-bday) {
  position: relative; overflow: hidden;
  background-image: linear-gradient(135deg, var(--bday-card), transparent 60%);
}
.p-card:has(.av-bday)::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, var(--bday-shine) 50%, transparent 62%);
  transform: translateX(-100%); animation: sheen 7s ease-in-out 3s infinite;
}
@media (prefers-reduced-motion: reduce) { .p-card:has(.av-bday)::after { animation: none; display: none; } }
.q-names .cake { margin: 0 2px 0 4px; }

/* Balloons (birthday mode): decorative, skipped with reduced motion. */
.balloons { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 119; }
.balloons i {
  position: absolute; bottom: -90px; left: var(--x); width: 44px; height: 54px;
  border-radius: 50% 50% 48% 52% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 32% 28%, var(--bday-shine) 0 6px, transparent 7px), var(--c);
  opacity: 0; transform: scale(var(--s));
  animation: balloon-rise var(--d) ease-in var(--w) forwards;
}
.balloons i::after {
  content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 46px;
  background: var(--ink3); opacity: .5;
}
@keyframes balloon-rise {
  0%   { opacity: .95; transform: translate3d(0, 0, 0) scale(var(--s)); }
  50%  { transform: translate3d(14px, -55vh, 0) scale(var(--s)) rotate(4deg); }
  90%  { opacity: .95; }
  100% { opacity: 0; transform: translate3d(-10px, -115vh, 0) scale(var(--s)) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) { .balloons { display: none; } .bday-bar.cheer .bday-msg { animation: none; } }
.p-nm-row { display: flex; align-items: center; min-width: 0; }
.p-nm-row .p-name { min-width: 0; }
.cake { width: 14px; height: 14px; flex-shrink: 0; color: var(--accent); vertical-align: -2px; margin-left: 5px; }
.chip-av:has(.av-bday) { outline: 2px solid var(--accent); outline-offset: 1px; }
.p-av:has(.av-bday)    { outline: 2px solid var(--accent); outline-offset: 2px; }
.av-bday { display: none; }
.res-bday {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--fd); font-weight: 800; font-size: 16px;
  max-width: 100%;
}
.res-bday span { overflow-wrap: anywhere; }
.res-bday .cake { width: 18px; height: 18px; margin: 0; }
.res-bday:has(.res-bday-photo) { padding-left: 6px; }
.res-bday-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--accent); }
.bday-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink2); margin-bottom: 8px; }
.bday-who { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; max-height: 40vh; overflow-y: auto; }
.bday-pick { min-height: 44px; cursor: pointer; }
.bday-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.bday-empty { font-size: 13px; color: var(--ink3); line-height: 1.5; }
.bday-themes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.bday-theme { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border: 1.5px solid var(--border-firm); border-radius: 99px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.bday-theme[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.bday-swatch { display: inline-flex; border-radius: 99px; overflow: hidden; outline: 1px solid var(--border-firm); }
.bday-swatch i { width: 12px; height: 24px; }
.bday-swatch i:nth-child(1) { background: var(--hdr-bg); }
.bday-swatch i:nth-child(2) { background: var(--accent); }
.bday-swatch i:nth-child(3) { background: var(--bday-pop); }
.bday-age { width: 120px; margin-bottom: 6px; }
.bday-note { font-size: 12px; color: var(--ink3); margin-bottom: 16px; }
.bday-off { margin-right: auto; }
#bdayModal .modal-row .btn, #bdayPhotoModal .modal-row .btn { min-height: 44px; }
.bday-msg-in { margin-bottom: 6px; }
.bday-photo-btn { min-height: 44px; margin-bottom: 16px; }
.bday-photo-prev { display: block; width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin: 0 auto 16px;
  border: 3px solid var(--accent); }
.bday-photo-pick { position: relative; cursor: pointer; }
.bday-photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.bday-photo-pick:focus-within { box-shadow: var(--ring); }

/* ════════════════ Touch ════════════════
   Fingers, not a mouse: 16px inputs (iOS zooms the page into anything
   smaller), bigger small controls, and no hover state left stuck on
   the last button tapped.
   ═══════════════════════════════════════ */
@media (pointer: coarse) {
  .modal-in, .court-name-input, .p-name-input, .hs-input { font-size: 16px; }
  .btn--sm, .panel-head { min-height: 34px; }
  .btn--icon.btn--sm { min-height: 34px; width: 34px; }
  .q-mini { width: 32px; height: 26px; font-size: 10px; }
  .p-div { height: 36px; }
  .div-opt { min-height: 44px; }
  .sync-pill { min-height: 28px; padding: 0 11px; }   /* tappable when it asks you to sign in */
  .head-tools .sync-pill, .head-tools .live-tag { min-height: 0; }   /* status tags, not buttons: they stay 22px */
  .watch-x { width: 36px; height: 36px; }
  .mode-toggle button { padding: 7px 14px; }
  .stage-chip, .stage-in, .stage-more { min-height: 44px; }
  .toast-undo { min-height: 44px; }
}
@media (hover: none) {
  .step-btn:hover, .step-btn.minus:hover { background: var(--surface); border-color: var(--border-firm); color: var(--ink2); }
  .step-btn:active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .step-btn.minus:active { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
  .team-score:hover, .hs:hover { background: none; border-color: transparent; }
  .p-div:hover:not(:disabled):not([aria-expanded="true"]) { background: var(--surface); border-color: var(--border-firm); border-left-color: var(--dc, var(--border-firm)); }
  .div-opt:hover:not([aria-selected="true"]):not(:focus-visible) { background: none; }
  .foot-head:hover, .hrow:hover, .srow:not(.lead):hover { background: none; }
  .q-act:hover:not(:disabled), .q-act.is-bad:hover { background: var(--surface); border-color: var(--accent-line); }
  .cmenu-item:hover:not(:focus-visible) { background: none; }
  .scoring-seg button:not(.on):hover { background: transparent; color: var(--ink2); }
}
/* A phone on its side: the header (three rows on a phone) would cover half the screen if it stuck. */
@media (max-height: 500px) and (orientation: landscape) {
  header { position: static; }
  .queue-panel { top: 0; max-height: 100vh; }
}

/* ════════════════ Toast ════════════════ */
.toast {
  position: fixed; bottom: calc(22px + var(--dock-h, 0px) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--ground);
  padding: 10px 18px; border-radius: 20px; font-size: 13px; font-weight: 500;
  z-index: 500; opacity: 0; transition: opacity var(--tr), transform var(--tr);
  pointer-events: none; box-shadow: var(--shm);
  width: max-content; max-width: min(560px, calc(100vw - 32px)); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.has-undo { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 18px; text-align: left; }
.toast-undo {
  background: none; border: 0; padding: 0 10px; min-height: 36px; border-radius: 14px; flex-shrink: 0;
  color: inherit; font-family: var(--fu); font-size: 13px; font-weight: 800; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.toast-undo:hover { background: color-mix(in srgb, currentColor 14%, transparent); }

.live-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--ball); color: var(--on-ball);
}
.live-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--on-ball); }
