/* Components: buttons, chips, inputs, steppers, toggles, segmented, court cards, standings,
   round rows, sheets/drawer, dialog, toast, empty states. Colours only via tokens. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2); /* R4-05: every icon-label gap is 8px */
  /* R4-07: the ladder. .btn is md (56 / 17); --sm 48 / 15, --lg 64 / 19, --xl 72 / 22. The nub
     disc sits --nub-inset from the edge on every step (8 / 10 / 12). */
  --nub-size: 40px; --nub-inset: 8px;
  min-height: var(--btn-md);
  padding: 0 24px;
  border-radius: var(--radius-full);
  font-size: var(--t-btn-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  border: var(--stroke-control) solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
  position: relative;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled, .btn[disabled] {
  opacity: 1;
  color: var(--text3);
  background: repeating-linear-gradient(135deg, var(--sunken) 0 6px, transparent 6px 12px), var(--sunken);
  border-color: var(--line);
  box-shadow: none;
}
.btn-block { width: 100%; }
.btn--small, .btn--sm { min-height: var(--btn-sm); padding: 0 20px; font-size: var(--t-btn-sm); }
.btn--lg { min-height: var(--btn-lg); padding: 0 28px; font-size: var(--t-btn-lg); font-weight: 800; --nub-size: 44px; --nub-inset: 10px; }
.btn--xl { min-height: var(--btn-xl); padding: 0 32px; font-size: var(--t-btn-xl); font-weight: 800; --nub-size: 48px; --nub-inset: 12px; }

/* R2-21: one primary style. .btn-control and .btn-accent are the same lime pill with an ink
   arrow nub (Start session, Next round, Start round, Mark all done, Play again, sheet primaries).
   Cream/ink (--control) now only marks a *selected* state (segments, filters, tabs). */
.btn-control {
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: var(--accent-edge), var(--shadow-accent); /* R3-13 */
}
.btn-control:not(.btn-block):not(.no-nub):not(:disabled)::after,
.btn-accent:not(.btn-block):not(.no-nub):not(:disabled)::after {
  content: '';
  flex: none;
  width: var(--nub-size);
  height: var(--nub-size);
  margin-left: var(--space-2); /* 8px gap + 8px = 16px from label to nub */
  border-radius: 50%;
  background: var(--nub-ink) var(--icon-arrow-ur) center / 22px no-repeat;
  transition: transform var(--dur-base) var(--ease-spring);
}
.btn-control:hover:not(:disabled)::after, .btn-accent:hover:not(:disabled)::after { transform: rotate(45deg) scale(1.06); }
.btn-control:not(.btn-block):not(.no-nub):not(:disabled),
.btn-accent:not(.btn-block):not(.no-nub):not(:disabled) { padding-right: var(--nub-inset); }
.btn-control:not(.btn-block):not(.no-nub):not(.btn--lg):not(.btn--xl),
.btn-accent:not(.btn-block):not(.no-nub):not(.btn--lg):not(.btn--xl) { padding-left: 28px; }

/* Accent: lime fill, ink text. One per screen at most. */
.btn-accent {
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: var(--accent-edge), var(--shadow-accent); /* R3-13 */
}

/* Secondary: outline */
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-outline:hover:not(:disabled) { background: var(--glass-strong); }
.btn--danger { background: var(--danger); color: #fff; border-color: transparent; }
:root:not([data-theme="light"]) .btn--danger { color: var(--on-accent); }
.btn--danger-text, .btn-outline.btn--danger-text { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 50%, transparent); }
.btn--primary { }

/* R4-06: link buttons are the mono micro caps style (same as .kicker). R4-10: the 6px side
   padding keeps the 48px target but hangs outside the text, so the label lines up with the
   edges around it. R4-18: a rounded focus ring. */
.link-btn {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--touch); padding: 0 6px; margin-inline: -6px;
  border-radius: var(--radius-1);
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps);
  text-transform: uppercase; text-decoration: underline; text-decoration-color: transparent;
  text-underline-offset: 4px; transition: text-decoration-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
  color: var(--link);
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn--quiet { color: var(--text2); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass-solid); color: var(--text);
  font-weight: 700; font-size: var(--t-body-lg);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }

.count-badge {
  /* R4-21: one digit is a true 22px circle, two digits a pill. */
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--radius-full); background: var(--sunken); color: var(--text); border: 1px solid var(--line-strong); /* R2-18: neutral, not lime */
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: 0; text-transform: none;
}

/* ---------- Avatars ---------- */
.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--av, var(--av-1)); color: var(--nub-ink);
  font-size: var(--t-micro); font-weight: 800; letter-spacing: 0; line-height: 1; text-transform: uppercase;
}
.avatar--lg { width: 44px; height: 44px; font-size: var(--t-body); }

/* ---------- Fields ---------- */
.field {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  width: 100%; min-height: 56px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-2);
  background: var(--sunken); border: 1px solid var(--line); color: var(--text);
  font-size: var(--t-body); font-weight: 600;
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
input.field { padding: 0 var(--space-4); display: block; height: 56px; font-size: var(--t-body-lg); }
.field:focus-within, input.field:focus { border-color: var(--accent-line); box-shadow: var(--glow-lime); outline: none; }
.field ::placeholder, input.field::placeholder { color: var(--text3); opacity: 1; }
input, .field input { caret-color: var(--accent-fill); }
.chip-input__field {
  flex: 1; min-width: 140px; min-height: 48px; border: none; background: none; outline: none; font-size: var(--t-body-lg); font-weight: 600; padding: var(--space-1); color: var(--text); /* R1-19 */
}
.chip-input__add {
  flex: none; min-height: var(--btn-sm); padding: 0 20px; border-radius: var(--radius-full); /* R1-19, R4-07 sm */
  background: var(--raised); color: var(--text); border: var(--stroke-control) solid var(--line-strong); font-weight: 800; font-size: var(--t-btn-sm); /* R2-18 */
}
.field:has(.player-chip) { min-height: 96px; align-content: flex-start; }

/* ---------- Chips ---------- */
.player-chip {
  /* the 30px avatar sits 5px (1 + 4) from the edge on every side, concentric with the pill */
  display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-1) 6px var(--space-1) var(--space-1); min-height: 40px;
  border-radius: var(--radius-full); background: var(--glass-strong); border: 1px solid var(--line);
  font-size: var(--t-body); font-weight: 700; animation: chip-pop var(--dur-base) var(--ease-spring) both;
}
.player-chip__name { padding-right: 2px; }
.player-chip__remove {
  position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text2); background: var(--line);
}
.player-chip__remove::before { content: ''; position: absolute; inset: -10px; } /* 48px hit area */
.player-chip__remove svg { width: 14px; height: 14px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.name-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; min-width: 56px; padding: var(--space-1) var(--space-4) var(--space-1) var(--space-1);
  border-radius: var(--radius-full); background: var(--glass-strong); border: 1px solid var(--line);
  font-size: var(--t-btn); font-weight: 700; color: var(--text);
}
.name-chip:not(:has(.avatar)) { justify-content: center; padding-left: var(--space-4); } /* a bare name is a centred pill */
.name-chip--button { min-height: 48px; min-width: 48px; justify-content: center; /* R2-22 */ cursor: pointer; /* R1-19 */ transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.name-chip--button:active { transform: scale(0.96); }
.name-chip--active { background: var(--control); color: var(--controltext); border-color: transparent; } /* selected = cream/ink */
@keyframes chip-pop { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.suggest-row { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--btn-sm); padding: 0 var(--space-4) 0 var(--space-3);
  border-radius: var(--radius-full); border: var(--stroke-control) dashed var(--line-strong); color: var(--text);
  background: transparent; font-weight: 700; font-size: var(--t-btn-sm);
}
.suggest-chip::before { /* R4-05: the family's plus, not a text "+" */
  content: ''; flex: none; width: 16px; height: 16px; background: var(--text2);
  -webkit-mask: var(--icon-plus-mask) center / contain no-repeat; mask: var(--icon-plus-mask) center / contain no-repeat;
}

/* ---------- Steppers ---------- */
.stepper { display: flex; align-items: center; gap: var(--space-2); }
.stepper-value { min-width: 1.5ch; text-align: center; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-size: var(--t-num-sm); }
.stepper-value--lg { font-size: var(--t-num-md); min-width: 1.3ch; }
.stepper-value--md { font-size: var(--t-num-sm); }
.stepper-value--sm { font-size: var(--t-lead); min-width: 3ch; }
/* R4-05: +/- are the family's PLUS/MINUS icons (20px in 48px steppers, 24px on the court). */
.stepper-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: var(--btn-sm); height: var(--btn-sm); border-radius: 50%; border: var(--stroke-control) solid var(--line-strong);
  background: transparent; color: var(--text); line-height: 1;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.stepper-btn:hover:not(:disabled) { background: var(--glass-strong); }
.stepper-btn:active:not(:disabled) { transform: scale(0.9); }
.stepper-btn:disabled { color: var(--text3); border-style: dashed; border-color: var(--line); opacity: 0.7; }
.stepper-btn--plus, .stepper-btn--lg:last-child { }
.stepper-btn--court { width: var(--btn-lg); height: var(--btn-lg); }
/* R2-21: "+" is a raised disc (not the primary's fill); a lime ring confirms the press. */
.stepper-btn--court.stepper-btn--plus { background: color-mix(in oklab, var(--text) 12%, var(--raised)); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.stepper-btn--court.stepper-btn--plus:active:not(:disabled) { box-shadow: 0 0 0 3px var(--accent-line); }
:root[data-theme="light"] .stepper-btn--court.stepper-btn--plus { background: var(--raised); border-color: var(--line-strong); } /* R4-15 */
.stepper-btn--court.stepper-btn--plus:disabled { background: var(--sunken); color: var(--text3); box-shadow: none; }

/* ---------- Toggle / segmented ---------- */
.toggle {
  position: relative; flex: none; width: 60px; height: 36px; border-radius: var(--radius-full);
  background: var(--sunken); border: var(--stroke-control) solid var(--line-strong);
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.toggle::before { content: ''; position: absolute; inset: -6px -2px; } /* taller hit area */
.toggle__knob {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--text2); display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur-base) var(--ease-spring), background var(--dur-base) var(--ease-out);
}
.toggle--on { background: var(--accent-fill); border-color: transparent; box-shadow: var(--accent-edge); }
.toggle--on .toggle__knob { transform: translateX(24px); background: var(--nub-ink); }
.toggle--on .toggle__knob::after {
  content: ''; width: 12px; height: 12px; background: var(--lime-400);
  -webkit-mask: var(--icon-check-mask) center / contain no-repeat; mask: var(--icon-check-mask) center / contain no-repeat;
}

.segmented {
  display: inline-flex; gap: 4px; padding: 4px; width: 100%;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-full);
}
.segmented__item {
  /* R4-07: 48px items in a 4px frame = the md 56px step. */
  flex: 1; min-height: var(--btn-sm); padding: 0 var(--space-4); border-radius: var(--radius-full);
  font-size: var(--t-btn-md); font-weight: 700; color: var(--text2);
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.segmented__item--sm { font-size: var(--t-btn-sm); } /* 48px target */
.segmented__item:active { transform: scale(0.97); }
.segmented__item--active { background: var(--control); color: var(--controltext); box-shadow: var(--shadow-control); } /* R2-18: selected = cream/ink; R4-27 */
.segmented__item--active:hover { background: var(--control); }

/* ---------- Roster (saved group) cards ---------- */
.roster-row { display: flex; gap: var(--space-3); overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px 8px; scroll-snap-type: x proximity; margin: 0 -2px; }
.roster-card {
  flex: none; display: flex; align-items: stretch; min-width: 170px; max-width: min(100%, 320px); border-radius: var(--radius-2); /* long names truncate so ⋯ stays on screen */
  overflow: hidden; scroll-snap-align: start; transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.roster-card__main { flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4); text-align: left; min-height: 64px; min-width: 0; }
.roster-pill__name { display: block; max-width: 100%; font-size: var(--t-btn); font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-pill__count { font-family: var(--font-family-mono); font-size: var(--t-label); color: var(--text2); } /* R4-14: data, so no caps */
.roster-card__edit { flex: none; width: 48px; display: flex; align-items: center; justify-content: center; color: var(--text2); }
.roster-card--selected { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: var(--glow-lime); }
.roster-card--selected .roster-pill__name { position: relative; padding-right: 20px; }
.roster-card--selected .roster-pill__name::after { /* R4-05: the family's check, not a text glyph */
  content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 12px; height: 12px; background: var(--accent);
  -webkit-mask: var(--icon-check-mask) center / contain no-repeat; mask: var(--icon-check-mask) center / contain no-repeat;
}
.roster-card--new, .roster-pill--new {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-width: 150px; min-height: 64px; padding: 0 20px; border-radius: var(--radius-2);
  border: var(--stroke-control) dashed var(--line-strong); color: var(--text2); font-weight: 700; font-size: var(--t-body);
  transition: border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.roster-card--new:hover { border-color: var(--accent-line); color: var(--text); }

/* ---------- Court card (hero component) ---------- */
.court-grid { display: grid; grid-template-columns: 1fr; gap: var(--gap-tile); }
.court-card {
  position: relative; overflow: hidden; border-radius: var(--radius-4);
  padding: var(--card-pad-y) var(--card-pad); display: flex; flex-direction: column; gap: var(--space-1);
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
/* R2-12: no ghosted court numeral - "COURT 1" already names the card. */
.court-card__header { display: flex; align-items: center; gap: 12px; min-height: 40px; position: relative; }
/* R4-06: "COURT 1" and the status tag are the mono micro caps style, like every other kicker. */
.court-card__kicker {
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); color: var(--text);
}
.court-card__status {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-3); border-radius: var(--radius-full);
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase;
  border: 1px solid var(--line); color: var(--text2); white-space: nowrap;
}
.court-card__status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; border: var(--stroke-control) solid currentColor; }
.court-card--in-progress { border-color: color-mix(in oklab, var(--live) 55%, transparent); background: linear-gradient(180deg, var(--live-soft), transparent 55%), var(--glass-solid); }
.court-card--in-progress .court-card__status { color: var(--live); border-color: color-mix(in oklab, var(--live) 55%, transparent); }
.court-card--in-progress .court-card__status::before { background: currentColor; animation: live-pulse var(--dur-pulse-slow) ease-in-out infinite; }
.court-card--completed { border-color: color-mix(in oklab, var(--success) 45%, transparent); }
.court-card--completed .court-card__status { color: var(--success); border-color: color-mix(in oklab, var(--success) 45%, transparent); }
.court-card--completed .court-card__status::before { background: currentColor; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 50% { box-shadow: 0 0 0 5px transparent; } }

/* R4-10: names share the card's left edge with "COURT 1" and Mark done; the lead bar hangs in
   the card's gutter (centred in it) instead of indenting the row. */
.court-card__team-row {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 92px; padding: var(--space-1) 0;
}
.court-card__team-row::before { /* leading marker */
  content: ''; position: absolute; left: calc(var(--card-pad) / -2 - 2px); top: 14%; bottom: 14%; width: 4px; border-radius: 4px;
  background: transparent; transition: background var(--dur-base) var(--ease-out);
}
.court-card__team-row[data-leading="true"]::before { background: var(--accent-fill); }
:root[data-theme="light"] .court-card__team-row[data-leading="true"]::before { background: var(--accent); } /* R1-06: 3:1 on cream */
/* R4-03: ellipsis per player - a partner is never hidden by a clamp. Doubles partners share one
   line: player one on the left edge, player two on the right, which keeps the card short.
   The " & " stays in the text for screen readers and copy, but is not drawn. */
.court-card__team-name {
  flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4);
  font-size: var(--t-team); font-weight: 700; letter-spacing: var(--track-tight); line-height: 1.12;
}
.court-card__player { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.court-card__player + .court-card__amp + .court-card__player { text-align: right; }
/* Every card uses the stacked row: the partners' line, then  -  score  +  spread below. A card
   that put the names beside the score left player two pressed against the - button. */
.court-card__team-row { flex-wrap: wrap; row-gap: 6px; }
.court-card__team-name { flex-basis: 100%; }
.court-card__amp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.court-card__vs {
  display: flex; align-items: center; gap: var(--space-3); height: 16px; color: var(--text3);
  font-family: var(--font-family-sans); font-size: var(--t-hint); font-weight: 600; /* R4-14: one sans lower-case "vs" (Call keeps its italic display) */
}
.court-card__vs::before, .court-card__vs::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.court-card__score { flex: none; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.court-card__score-value {
  /* R1-11: fixed two-digit width (scores cap at 99) so 9 -> 10 never shifts the - button. */
  flex: none; width: 1.22em; text-align: center; font-variant-numeric: tabular-nums; font-size: var(--t-score); font-weight: 800; letter-spacing: -0.05em; line-height: 0.9;
}
.court-card__team-row[data-leading="true"] .court-card__score-value { color: var(--accent); }
.court-card__score-value.is-tick { animation: score-tick var(--dur-base) var(--ease-out); }
@keyframes score-tick {
  0% { transform: translateY(-14%) scale(1.1); opacity: 0.4; }
  100% { transform: none; opacity: 1; }
}
.court-card.is-touched { box-shadow: var(--shadow-2), 0 0 0 var(--stroke-control) var(--accent-line), 0 0 30px var(--accent-soft); }

.court-card__done { /* R1-23: full-width, thumb-reachable bar at the bottom of the card */
  position: static; width: 100%; margin-top: var(--space-2); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--btn-md); padding: 0 var(--space-5); border-radius: var(--radius-full); /* R4-07 md */
  border: var(--stroke-control) solid var(--line-strong); font-weight: 700; font-size: var(--t-btn-md); color: var(--text);
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.court-card__done:active { transform: scale(0.98); }
/* R1-23 (UI): short Expanded viewports (iPad landscape 1180x820 / 1024x768) with 1-2 courts -
   tighten the card (72px rows, 76px score, slimmer header) so the full-width bottom "Mark done"
   bar fits and both courts stay above the command bar. */
@media (min-width: 1024px) and (max-height: 899px) {
  .court-grid--n1 .court-card { padding: var(--space-3) var(--card-pad); }
  .court-grid--n1 .court-card__header { min-height: 28px; }
  .court-grid--n1 .court-card__team-row { min-height: 72px; }
  .court-grid--n1 .court-card__score-value { font-size: var(--t-num-xl); }
  .court-grid--n1 .court-card__done { margin-top: 6px; }
}

.court-card__done--done { background: var(--success); border-color: transparent; color: var(--on-success); }
.court-card__done.is-hinted { background: var(--accent-fill); color: var(--on-accent); border-color: transparent; animation: hint-pulse var(--dur-pulse-slow) ease-in-out infinite; }
@keyframes hint-pulse { 0%, 100% { box-shadow: var(--accent-edge), 0 0 0 0 rgba(var(--breathe-rgb), .5); } 50% { box-shadow: var(--accent-edge), 0 0 0 8px rgba(var(--breathe-rgb), 0); } }
.court-card--completed .court-card__team-name { opacity: 0.92; }

/* ---------- Standings ---------- */
.standings-list { display: flex; flex-direction: column; gap: 8px; }
.standings-row {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 10px 18px 10px 12px;
  border-radius: var(--radius-2);
}
.standings-row__badge {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--sunken); color: var(--text2); border: 1px solid var(--line);
}
.standings-row__badge-text { font-family: var(--font-family-sans); font-weight: 800; font-size: var(--t-section); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.standings-row__name { flex: 1; min-width: 0; font-size: var(--t-section); font-weight: 800; letter-spacing: -0.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings-row__who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.standings-row__who .standings-row__name { flex: none; }
.standings-row__pfpa-sub, .standings-head__name-sub { display: none; } /* R3-04: Compact only (views.css) */
.standings-row__pfpa-sub { color: var(--text2); line-height: 1.2; white-space: nowrap; }
.standings-row__stats { display: grid; grid-template-columns: 76px 56px 104px; column-gap: 20px; align-items: center; justify-items: end; }
/* R2-13: one sticky column header instead of "pts" on every row. UXR-16: sentence case.
   R4-17: a rounded glass bar like the rows (was a square var(--bg) band cutting the sun glow). */
.standings-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 14px; padding: 8px 18px 8px 12px;
  border-radius: var(--radius-2); background: var(--glass-solid);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--text2); font-family: var(--font-family-sans); font-size: var(--t-hint); font-weight: 700; letter-spacing: 0; text-transform: none;
}
.standings-head__rank { flex: none; width: 48px; text-align: center; }
.standings-head__name { flex: 1; min-width: 0; }
.standings-row__points { font-size: var(--t-num-sm); font-weight: 800; letter-spacing: -0.04em; line-height: 1; min-width: 4.4ch; text-align: right; }
/* R4-06: record and PF-PA are one mono data size. */
.standings-row__record { color: var(--text2); font-size: var(--t-data); min-width: 5ch; text-align: right; }
.standings-row__pfpa { color: var(--text2); font-size: var(--t-data); min-width: 12ch; text-align: right; }
.standings-row--top { border-color: var(--accent-line); box-shadow: var(--shadow-2), var(--glow-lime); background: linear-gradient(90deg, var(--accent-soft), var(--glass-solid) 60%); }
/* R1-25: light theme - a flat soft-olive fill instead of the lime-to-cream smear. */
/* R4-17: light - a lime-washed raised row with a hairline (the olive 2px ring read as "disabled"). */
:root[data-theme="light"] .standings-row--top { background: color-mix(in oklab, var(--accent-fill) 18%, var(--raised)); border-color: var(--accent-line); box-shadow: var(--shadow-2); }
.standings-row--top .standings-row__badge { background: var(--accent-fill); color: var(--on-accent); border-color: transparent; box-shadow: var(--accent-edge); }
.standings-row--top .standings-row__name { color: var(--text); }
.standings-row--sidebar { min-height: 52px; padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2); gap: var(--space-2); border-radius: var(--radius-1); box-shadow: none; }
.standings-row__badge--sidebar { width: 36px; height: 36px; }
.standings-row__badge--sidebar .standings-row__badge-text { font-size: var(--t-body); }
.standings-row--sidebar .standings-row__name { font-size: var(--t-btn); }
.standings-row--sidebar .standings-row__points { font-size: var(--t-lead); min-width: 2ch; font-variant-numeric: tabular-nums; } /* R1-11 */
.standings-tie {
  align-self: center; margin: -14px 0; position: relative; z-index: 2; height: 24px; padding: 0 var(--space-3); display: inline-flex; align-items: center;
  border-radius: var(--radius-full); background: var(--bg); border: 1px solid var(--line-strong); color: var(--text2);
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase;
}

.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: var(--gap-tile); margin-bottom: 8px; }
.podium__slot {
  position: relative; overflow: hidden; border-radius: var(--radius-3); padding: var(--card-pad-y) var(--card-pad-y); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--glass-solid); border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}
.podium__slot--1 { min-height: 250px; background: var(--tile-lime); color: var(--on-accent); border-color: transparent; justify-content: flex-end; }
.podium__slot--2 { min-height: 196px; justify-content: flex-end; }
.podium__slot--3 { min-height: 168px; justify-content: flex-end; }
.podium__rank { /* R2-13: a small rank label, not a ghost numeral that collides with names */
  position: relative; font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); opacity: 0.8; margin-bottom: 2px;
}
.podium__name { position: relative; font-size: var(--t-title-sm); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.podium__slot--1 .podium__name { font-size: var(--t-num-sm); }
.podium__points { position: relative; margin-top: var(--space-1); font-size: var(--t-num-md); font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.podium__slot--1 .podium__points { font-size: var(--t-num-lg); }
.podium__record { position: relative; opacity: 0.85; }
/* R1-15: a shared first place gets no #1 emphasis (same height as 2nd, no ball). */
.podium--tied .podium__slot--1 { min-height: 196px; }
.podium--tied .podium__slot--1::after { display: none; }
.podium__slot--1::after {
  content: ''; position: absolute; right: -24px; top: -24px; width: 110px; height: 110px;
  background: url('../assets/ball.svg') center / contain no-repeat; opacity: 0.55; transform: rotate(-20deg);
}

/* ---------- Round rows (Schedule) ---------- */
.round-list { display: flex; flex-direction: column; gap: var(--gap-tile); }
.round-row { position: relative; border-radius: var(--radius-3); overflow: hidden; transition: border-color var(--dur-base) var(--ease-out); }
.round-row[data-state="live"] { border-color: var(--accent-line); background: linear-gradient(90deg, var(--accent-soft), var(--glass-solid) 55%); }
/* the 56px thumb sits 10px (+1 border) from the top, bottom and left: concentric with the 26 radius */
.round-row__head { display: flex; align-items: center; gap: var(--space-4); padding: 10px var(--space-4) 10px 10px; min-height: 76px; }
.round-row__thumb {
  flex: none; width: var(--btn-md); height: var(--btn-md); border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: transparent; border: var(--stroke-control) solid var(--line-strong);
}
.round-row__thumb-num { font-family: var(--font-family-sans); font-weight: 800; font-size: var(--t-section); letter-spacing: -0.03em; color: var(--text2); }
.round-row[data-state="live"] .round-row__thumb { background: var(--accent-fill); border-color: transparent; }
.round-row[data-state="live"] .round-row__thumb-num { color: var(--on-accent); }
.round-row[data-state="complete"] .round-row__thumb, .round-row[data-state="skipped"] .round-row__thumb { background: var(--sunken); }
.round-row__main { flex: 1; min-width: 0; text-align: left; min-height: 56px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.round-row__title-line { display: flex; align-items: center; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.round-row__title { font-size: var(--t-section); font-weight: 800; letter-spacing: -0.03em; }
.round-row__state {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 24px; padding: 0 10px; border-radius: var(--radius-full);
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase;
  border: 1px solid currentColor;
}
.round-row[data-state="live"] .round-row__state { color: var(--accent); }
.round-row[data-state="live"] .round-row__state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--progress); animation: live-pulse var(--dur-pulse-slow) ease-in-out infinite; color: var(--progress); }
.round-row[data-state="complete"] .round-row__state { color: var(--success); }
.round-row[data-state="complete"] .round-row__state::before { /* R4-05: the family's check */
  content: ''; width: 12px; height: 12px; background: currentColor;
  -webkit-mask: var(--icon-check-mask) center / contain no-repeat; mask: var(--icon-check-mask) center / contain no-repeat;
}
.round-row[data-state="skipped"] .round-row__state, .round-row[data-state="upcoming"] .round-row__state { color: var(--text2); }
.round-row__meta { color: var(--text2); font-size: var(--t-label); } /* R4-14: data, so no caps */
/* UXR-03a: the row only toggles its preview. R4-05: expand/collapse is a chevron (the score
   +/- keep their own meaning), turned over when open - the Setup cards' grammar. */
.round-row__chevron, .setup-card__chevron {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); color: var(--text); pointer-events: none;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.round-row__chevron svg, .setup-card__chevron svg { transition: transform var(--dur-base) var(--ease-out); }
.round-row.is-expanded .round-row__chevron, .setup-card--collapsible.is-open .setup-card__chevron { background: var(--control); color: var(--controltext); border-color: transparent; }
.round-row.is-expanded .round-row__chevron svg, .setup-card--collapsible.is-open .setup-card__chevron svg { transform: rotate(180deg); }
.round-row__hairline { height: 4px; background: var(--line); margin: 0; }
.round-row__hairline-fill { height: 100%; background: var(--progress); transition: width var(--dur-slow) var(--ease-out); }
.round-row[data-state="complete"] .round-row__hairline-fill { background: var(--success); }
.round-row__games { padding: var(--space-1) var(--card-pad) var(--card-pad-y); display: flex; flex-direction: column; gap: var(--space-2); animation: fade-rise var(--dur-slow) var(--ease-out) both; }
.round-row__game { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; min-height: 40px; }
.round-row__game-court { color: var(--text3); font-weight: 700; }
.round-row__game-label { font-size: var(--t-btn); font-weight: 700; letter-spacing: -0.01em; }
.round-row__game-score { font-family: var(--font-family-sans); font-size: var(--t-section); font-weight: 800; letter-spacing: -0.03em; }
.round-row__game-score[data-done="true"] { color: var(--success); }
.round-row__sitting, .round-row__focus { padding: 0 var(--card-pad) var(--card-pad-y); color: var(--text2); }
.round-row__focus { padding-top: 0; color: var(--accent); font-weight: 600; }
.round-row__sitting { padding: 4px 0 0; }
/* UXR-03a: the one control that moves the live round - labelled, outline, never the default. */
.round-row__make-live { display: flex; padding-top: var(--space-2); }
.round-row__make-live-btn { min-height: var(--btn-sm); padding: 0 20px; font-size: var(--t-btn-sm); } /* R4-07 sm */
.player-filter { padding: var(--card-pad-y) var(--card-pad); border-radius: var(--radius-3); margin-bottom: var(--gap-tile); display: flex; flex-direction: column; gap: var(--space-3); }
.player-filter__summary { color: var(--accent); font-weight: 600; }
/* R2-14: a leading label chip instead of a kicker; one sideways-scrolling row on Compact. */
.player-filter__label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-1) 0 2px; color: var(--text2); font-size: var(--t-hint); font-weight: 700; white-space: nowrap; }
@media (max-width: 759px) {
  .player-filter { padding: var(--space-3); }
  .player-filter__chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .player-filter__chips::-webkit-scrollbar { display: none; }
  .player-filter__chips > * { flex: none; }
}

/* ---------- Stat + setup cards ---------- */
.setup-card { border-radius: var(--radius-3); padding: var(--card-pad); display: flex; flex-direction: column; gap: var(--space-4); }
.setup-card__title { margin-bottom: -2px; }
.setup-card__hint { color: var(--text2); font-size: var(--t-hint); font-weight: 500; line-height: 1.4; }
.setup-card--collapsible { padding: 0; gap: 0; overflow: hidden; }
.setup-card__toggle {
  width: 100%; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--card-pad); min-height: 68px; text-align: left;
}
/* R3-05: the summary may take two balanced lines instead of truncating ("Play to..."). */
.setup-card__summary { flex: 1; min-width: 0; color: var(--text2); text-transform: none; text-align: right; line-height: 1.35; text-wrap: balance; }
.setup-card__body { padding: var(--space-1) var(--card-pad) var(--card-pad); display: flex; flex-direction: column; gap: var(--space-4); animation: fade-rise var(--dur-slow) var(--ease-out) both; }
.setup-section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.setup-section-title__actions { display: flex; gap: var(--space-4); flex-wrap: wrap; } /* link buttons hang 6px outside their text */
.setup-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { min-width: 0; border-radius: var(--radius-2); padding: var(--space-4); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); background: var(--sunken); box-shadow: none; }
.stat-card__label { font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--text3); }
.fit-summary {
  display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-family-mono); font-size: var(--t-label); font-weight: 600; color: var(--text);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-1); background: var(--sunken); border: 1px solid var(--line);
}
.fit-summary::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--success); flex: none; }
.planner { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-2); background: var(--sunken); border: 1px solid var(--line); animation: fade-rise var(--dur-slow) var(--ease-out) both; }
.setup-rounds-hint { color: var(--text2); line-height: 1.5; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 60px; border-bottom: 1px solid var(--line); }
.setting-row:last-of-type { border-bottom: none; }
.setting-row__label { font-size: var(--t-btn); font-weight: 700; }
.setting-row__label--block { display: block; margin-top: var(--space-2); }
.setting-subrow { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 56px; padding-left: var(--space-4); border-left: 2px solid var(--line-strong); }
.setting-subrow__label { color: var(--text2); font-size: var(--t-body); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state {
  position: relative; overflow: hidden; border-radius: var(--radius-4); padding: 56px 28px 44px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 640px; margin: 24px auto;
}
.empty-state::before { /* court-line corner */
  content: ''; position: absolute; inset: 0; background: var(--line-strong);
  -webkit-mask: url('../assets/court-lines.svg') no-repeat right -12% bottom -30% / 75% auto; mask: url('../assets/court-lines.svg') no-repeat right -12% bottom -30% / 75% auto;
  opacity: 0.4; transform: rotate(-6deg); pointer-events: none;
}
.empty-state::after { /* ball */
  content: ''; order: -1; width: 96px; height: 96px; background: url('../assets/ball.svg') center / contain no-repeat;
  filter: drop-shadow(0 12px 14px rgba(0,0,0,.3)); animation: float var(--dur-ambient) ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.empty-state > * { position: relative; }
.empty-state__title { font-size: var(--t-title); font-weight: 800; letter-spacing: -0.03em; }
.empty-state__text { color: var(--text2); font-size: var(--t-body-lg); max-width: 42ch; }
.empty-state__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); }

/* ---------- Sheet / drawer ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: transparent; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0);
  transition: background var(--dur-slow) var(--ease-out), backdrop-filter var(--dur-slow) var(--ease-out);
}
.sheet-backdrop--open { background: var(--scrim); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px calc(var(--card-pad) + 4px) calc(24px + env(safe-area-inset-bottom, 0px)); /* R4-09: card inset + 4 */
  background: var(--glass-solid); border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--radius-4) var(--radius-4) 0 0; box-shadow: var(--shadow-3);
  background-color: var(--surface);
  transform: translateY(40px); opacity: 0;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.sheet-backdrop--open .sheet { transform: none; opacity: 1; }
.sheet__handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.sheet__title { font-size: var(--t-section); font-weight: 800; letter-spacing: -0.03em; }
.sheet__close {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--glass-strong); color: var(--text);
}
.sheet__hint { color: var(--text2); margin-bottom: var(--space-4); line-height: 1.45; }
.help p { margin-bottom: var(--space-3); color: var(--text2); font-size: var(--t-btn); line-height: 1.5; }
.menu-list { display: flex; flex-direction: column; gap: var(--space-2); }
.menu-item { display: flex; align-items: center; min-height: 56px; padding: 0 var(--card-pad); border-radius: var(--radius-2); text-align: left; font-size: var(--t-btn); font-weight: 700; background: var(--glass-strong); border: 1px solid var(--line); }
.menu-item--current { border-color: var(--accent-line); background: var(--accent-soft); }
.menu-note { color: var(--text2); padding: var(--space-3) var(--space-2); font-size: var(--t-hint); }
/* R2-10: Theme row in the More menu (same Light | Dark control as Setup > Display). */
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 56px; padding: var(--space-1) var(--space-1) var(--space-1) var(--card-pad); border-radius: var(--radius-2); font-size: var(--t-btn); font-weight: 700; background: var(--glass-strong); border: 1px solid var(--line); }

@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--radius-4); border-bottom: 1px solid var(--line); max-width: 560px; transform: translateY(14px) scale(0.96); padding-top: var(--space-5); }
  .sheet__handle { display: none; }
}
.sheet-backdrop--drawer { align-items: stretch; justify-content: flex-end; }
.sheet-backdrop--drawer.sheet-backdrop--open { background: var(--scrim-drawer); backdrop-filter: none; -webkit-backdrop-filter: none; }
.sheet--drawer {
  width: 440px; max-width: 100%; height: calc(100% - 24px); max-height: none; margin: 12px 12px 12px 0;
  border: 1px solid var(--line); border-radius: var(--radius-4); padding-top: var(--space-5); transform: translateX(60px); opacity: 0;
}
.sheet-backdrop--open .sheet--drawer { transform: none; opacity: 1; }
.sheet--drawer .sheet__handle { display: none; }

/* ---------- Players sheet ---------- */
.players-sheet { display: flex; flex-direction: column; gap: 8px; }
.players-sheet__title { margin-top: var(--space-3); }
.qe-player-row { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); border-radius: var(--radius-2); background: var(--glass-strong); border: 1px solid var(--line); }
.qe-player-row__name { flex: 1; min-width: 0; height: 48px; background: none; border: none; font-size: var(--t-body-lg); font-weight: 700; letter-spacing: -0.02em; outline: none; }
.qe-player-row__name:focus { color: var(--accent); }
.qe-player-row--removed { border-style: dashed; background: transparent; }
.qe-player-row--removed .qe-player-row__name { text-decoration: line-through; color: var(--text3); }
.qe-player-row--removed::after { content: 'OUT'; order: 3; font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); color: var(--text3); }
.qe-player-row__remove { flex: none; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); color: var(--text); }
.qe-player-row--removed .qe-player-row__remove { order: 4; background: var(--accent-fill); color: var(--on-accent); border-color: transparent; box-shadow: var(--accent-edge); }
.players-sheet__footer { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-4) calc(-1 * (var(--card-pad) + 4px)) 0; padding: var(--space-4) calc(var(--card-pad) + 4px) var(--space-1); position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom, 0px)); background: linear-gradient(180deg, transparent, var(--surface) 22px); }
.players-sheet__impact { color: var(--live); padding: var(--space-3); border-radius: var(--radius-1); border: 1px solid var(--live); background: var(--sunken); line-height: 1.4; hyphens: manual; text-wrap: balance; } /* R3-15 */
.players-sheet__impact[hidden] { display: none; }
.players-sheet__warn { color: var(--danger); }
.players-sheet__actions { display: flex; gap: var(--space-3); justify-content: space-between; }
.players-sheet__actions .btn { flex: 1; }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--scrim); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: fade-in var(--dur-base) both;
}
.dialog {
  --dialog-pad: calc(var(--card-pad) + 4px); /* R4-09: card inset + 4 */
  position: relative; width: 100%; max-width: 480px; padding: var(--dialog-pad); border-radius: var(--radius-4); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: dialog-in var(--dur-slow) var(--ease-spring) both;
}
/* R4-05: the warn disc carries the family's WARN icon (was a text "!"). */
.dialog::before {
  content: ''; display: block; width: 48px; height: 48px; margin-bottom: var(--space-4);
  border-radius: 50%; background: var(--live-soft);
}
.dialog::after {
  content: ''; position: absolute; top: calc(var(--dialog-pad) + 12px); left: calc(var(--dialog-pad) + 12px); width: 24px; height: 24px;
  background: var(--live); -webkit-mask: var(--icon-warn-mask) center / contain no-repeat; mask: var(--icon-warn-mask) center / contain no-repeat;
}
.dialog__title { font-size: var(--t-section); font-weight: 800; letter-spacing: -0.03em; margin-bottom: var(--space-2); }
.dialog__body { color: var(--text2); font-size: var(--t-btn); line-height: 1.45; margin-bottom: var(--space-5); }
/* R4-04: buttons size to their label (never narrower than it) and the pair wraps to a stack
   when both do not fit - the label can no longer run through its own pill border. */
.dialog__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.dialog__actions .btn { flex: 1 1 auto; min-width: max-content; padding: 0 var(--space-5); }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: none; } }
/* R1-20: Compact - confirms are bottom sheets (ux 3.2 / ui 9.8), actions stacked full width,
   destructive last, clear of the home indicator. */
@media (max-width: 759px) {
  .dialog-backdrop { align-items: flex-end; padding: 0; }
  .dialog {
    max-width: none; border-radius: var(--radius-4) var(--radius-4) 0 0; border-bottom: 0; padding: var(--dialog-pad) var(--dialog-pad) calc(var(--dialog-pad) + env(safe-area-inset-bottom, 0px));
    animation: sheet-up var(--dur-slow) var(--ease-out) both;
  }
  .dialog__actions { flex-direction: column; gap: var(--space-3); }
  .dialog__actions .btn { flex: none; width: 100%; min-width: 0; min-height: 56px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; left: 0; right: 0; z-index: 70; display: flex; justify-content: center; pointer-events: none;
  bottom: calc(var(--toast-bottom, 110px) + env(safe-area-inset-bottom, 0px)); padding: 0 16px;
}
.toast {
  position: relative; overflow: hidden; pointer-events: auto; display: flex; align-items: center; gap: var(--space-3);
  min-height: 56px; max-width: min(560px, 100%); padding: var(--space-1) var(--space-1) var(--space-1) 20px; border-radius: var(--radius-full);
  background: var(--glass-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); background-color: var(--surface);
  animation: toast-in var(--dur-base) var(--ease-out) both;
}
.toast::before { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--progress); margin-left: -6px; }
.toast__message { font-size: var(--t-body); font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; padding: 4px 0; }
.toast__action {
  flex: none; min-height: 48px; min-width: 64px; padding: 3px var(--space-4) 0; border-radius: var(--radius-full); background: var(--accent-fill); color: var(--on-accent); box-shadow: var(--accent-edge); /* R2-22, R3-13 */
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase;
  /* R4-11: the 3px top pad puts UNDO on the message baseline */
}
.toast::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--progress); transform-origin: left; animation: toast-drain var(--toast-dur, 6000ms) linear forwards; }
.toast--persist::after { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Screen head / typography blocks ---------- */
.screen-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.screen-title { font-size: var(--t-title); font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; }
.screen-meta { color: var(--text2); margin-top: var(--space-2); font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; text-transform: uppercase; letter-spacing: var(--track-caps); }

.standings-row__pts-unit { font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; color: var(--text2); margin-left: 2px; } /* R4-14: "pts" lower-case everywhere */
.podium__slot--1 .standings-row__pts-unit { color: inherit; opacity: 0.8; }

/* =====================================================================
   Persona "Do now" (UXR-04 / 08 / 14 / 15 / 16 / 05)
   ===================================================================== */
/* UXR-04: the chip input is the field plus its duplicate-name hint. */
.chip-input { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.chip-input__hint {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-1); background: var(--live-soft); border: 1px solid color-mix(in oklab, var(--live) 45%, transparent);
  color: var(--text); font-size: var(--t-hint); font-weight: 600; line-height: 1.4;
}
.chip-input__hint[hidden] { display: none; }

/* UXR-14: a pre-session chip name is a button that turns into a text field in place. */
.player-chip__name--edit {
  position: relative; font: inherit; color: inherit; padding: 0 2px; border-radius: 6px; cursor: text;
  text-decoration: underline dotted var(--line-strong); text-underline-offset: 4px;
}
.player-chip__name--edit::before { content: ''; position: absolute; inset: -6px -4px; } /* 48px-tall hit area */
.player-chip.is-editing { padding-right: 6px; border-color: var(--accent-line); box-shadow: var(--glow-lime); }
.player-chip__edit {
  height: 32px; min-width: 6ch; max-width: 60vw; padding: 0 var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--line-strong);
  background: var(--raised); color: var(--text); font: inherit; outline: none;
}

/* UXR-08: a player taken out of today's games (live Setup). Not a delete target. */
.player-chip--out { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--text2); padding-right: 10px; }
.player-chip--out .player-chip__name { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.player-chip--out .avatar { opacity: 0.55; }
.player-chip__tag {
  font-family: var(--font-family-mono); font-size: var(--t-micro); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase;
  padding: 2px var(--space-2); border-radius: var(--radius-full); border: 1px solid var(--line-strong); color: var(--text2);
}

/* UXR-15d / UXR-05: destructive text links read as danger and sit apart from safe actions. */
.link-btn--danger { color: var(--danger); }
.link-btn--apart { margin-left: var(--space-5); }

/* UXR-07: "Minutes per game" spans the courts/rounds row, label left and stepper right. */
.stat-card--wide { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); }

/* UXR-14: the Players sheet says names are editable. */
.players-sheet__title-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.players-sheet__title-row .players-sheet__title { margin-top: 0; }
.players-sheet__rename-hint { color: var(--text2); font-size: var(--t-hint); font-weight: 600; }
.qe-player-row__field { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-2); cursor: text; }
.qe-player-row__pencil { flex: none; display: flex; color: var(--text2); }
.qe-player-row__field:focus-within .qe-player-row__pencil { color: var(--accent); }

/* UXR-16: plain standings. Sentence-case headers, a tap-for-detail row and a tie note. */
.standings-row--tappable { flex-wrap: wrap; cursor: pointer; }
.standings-row--tappable:active { transform: scale(0.995); }
.standings-row__detail { flex: 1 0 100%; padding: 2px 0 var(--space-1) 62px; color: var(--text2); font-size: var(--t-hint); font-weight: 600; line-height: 1.4; }
.standings-row__detail[hidden] { display: none; }
.standings-row.is-open { border-color: var(--line-strong); }
.standings-note { padding: 2px var(--space-3) var(--space-1); color: var(--text2); font-size: var(--t-hint); font-weight: 600; line-height: 1.4; }
.standings-row__pfpa-sub { font-family: var(--font-family-sans); font-size: var(--t-hint); font-weight: 600; }
.podium__record { font-size: var(--t-hint); font-weight: 600; }
