/* StumpVision scorer app: shell + screens. Mobile-first (min-width queries at 600 / 768 / 1024 / 1440).
   All colours, spacing, radii, z-index and motion come from tokens.css (linked first), which owns the
   light / dark / sun themes. Only component-level helpers are defined here.
   OUTDOOR RULES: score and pad text >= 7:1, solid fills, strong borders (--line, 2px in Sunlight), state never by colour alone. */

/* text colour on solid brand fills (blue/purple/red): white on the dark light-theme fills, dark on the bright dark-theme fills */
:root { --on-solid: #ffffff; --rail-w: 0px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]), :root[data-theme="auto"] { --on-solid: #0b1220; } }
:root[data-theme="dark"] { --on-solid: #0b1220; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 20px; line-height: 1.25; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:root[data-theme="sun"] :focus-visible { outline-width: 4px; }
.skip-link { position: absolute; left: var(--s-3); top: -80px; z-index: var(--z-toast); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 700; text-decoration: none; }
.skip-link:focus { top: var(--s-3); }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd { font-family: var(--font-mono); font-size: 12px; font-weight: 700; padding: 1px 6px; border: var(--border-w) solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--ink); }

/* ---------- shell ---------- */
/* The shell is pinned to the visible viewport (position: fixed; inset: 0) instead of height: 100dvh.
   Some mobile browsers report a 100dvh taller than the visible area, which pushed the bottom tab bar off screen. */
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; position: fixed; inset: 0; background: var(--bg); }
.topbar {
  grid-row: 1; display: flex; align-items: center; gap: var(--s-2); min-height: 56px;
  padding: calc(var(--s-2) + var(--safe-t)) calc(var(--gutter) + var(--safe-r)) var(--s-2) calc(var(--gutter) + var(--safe-l));
  background: var(--surface); border-bottom: var(--border-w) solid var(--line);
}
.top-mark { color: var(--accent); width: 28px; height: 28px; }
.top-title { flex: 1; min-width: 0; font-weight: 800; font-size: 19px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-back { margin-left: calc(-1 * var(--s-2)); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--danger); color: var(--on-solid); font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; letter-spacing: .08em; }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sync-chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 99px; border: var(--border-w) solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 700; }
.sync-chip svg.ic { width: 18px; height: 18px; }
.sync-chip[data-state="synced"] { color: var(--success); }
.sync-chip[data-state="offline"], .sync-chip[data-state="saving"] { color: var(--warn); }
.sync-chip[data-state="error"] { color: var(--danger); border-color: var(--danger); }
.sync-chip .sync-label { color: var(--ink); }
:root[data-theme="sun"] .sync-chip { color: #000; }
.sun-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.main { grid-row: 2; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; outline: none; scroll-padding: 16px; }
.page { max-width: calc(var(--content-max) + 2 * var(--gutter)); margin: 0 auto; padding: var(--s-4) var(--gutter) var(--s-5); }
.page > * + * { margin-top: var(--s-4); }
.pad-wrap { grid-row: 3; background: var(--surface); border-top: var(--border-w) solid var(--line); padding: var(--s-2) calc(var(--s-3) + var(--safe-r)) var(--s-2) calc(var(--s-3) + var(--safe-l)); }
.app:not(.has-tabs) .pad-wrap { padding-bottom: calc(var(--s-2) + var(--safe-b)); }

/* bottom tab bar (phones) */
.tabbar { grid-row: 4; display: none; background: var(--surface); border-top: var(--border-w) solid var(--line); padding-bottom: var(--safe-b); }
.app.has-tabs .tabbar { display: block; }
.tab-list { display: grid; grid-template-columns: repeat(4, 1fr); }
.tab.tab-home, .tab.tab-site, .tab-sep, .rail-brand, .rail-foot { display: none; }
a.tab { text-decoration: none; }
.tab {
  min-height: 58px; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 700; position: relative; padding: var(--s-1);
}
.tab svg.ic { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 800; }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 4px; background: var(--accent); border-radius: 0 0 4px 4px; }
:root[data-theme="sun"] .tab[aria-current="page"] { color: #000; background: var(--surface-2); }
.tab:active { background: var(--surface-2); }

/* ---------- primitives ---------- */
.card { background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--radius); padding: var(--s-4); box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card > * + * { margin-top: var(--s-3); }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); line-height: 1.3; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 40px; }
.eyebrow { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.card-title { font-size: 20px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--s-3); }
.center { text-align: center; }

.btn {
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); text-align: center; text-decoration: none; line-height: 1.2;
  transition: transform 100ms var(--ease-out), background-color var(--t-fast), border-color var(--t-fast);
}
.btn:active, .icon-btn:active, .bat:active, .bowl-line:active, .pick:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-solid); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.btn.danger-outline { color: var(--danger); border: 2px solid var(--danger); background: transparent; }
.btn.big { min-height: 60px; font-size: 18px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 6px 14px; font-size: 15px; }
.btn[disabled] { opacity: .5; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; padding: 0; transition: transform 100ms var(--ease-out), background-color var(--t-fast); }
.icon-btn.plain { border-color: transparent; background: transparent; }
@media (hover: hover) {
  .btn:hover { background: var(--surface-2); }
  .btn.primary:hover { background: var(--accent); filter: brightness(1.1); }
  .btn.danger:hover { background: var(--danger); filter: brightness(1.08); }
  .btn.soft:hover { filter: brightness(.96); }
  .btn.ghost:hover, .icon-btn:hover { background: var(--surface-2); }
  .tab:hover, .rail-btn:hover { background: var(--surface-2); }
  .bat:hover, .bowl-line:hover, .pick:hover { border-color: var(--ink); }
  .pad button:hover:not([disabled]) { filter: brightness(1.08); }
}

.field { display: block; }
.field > .label { display: block; font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field > .hint { display: block; margin-top: 6px; font-size: 14px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 16px;
}
.input::placeholder { color: var(--muted); opacity: 1; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.form-error { margin-top: var(--s-2); padding: 10px 12px; border-radius: var(--radius-sm); border: 2px solid var(--danger); background: var(--danger-soft); color: var(--ink); font-weight: 700; font-size: 15px; }
.seg { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.seg button {
  flex: 1 1 0; min-width: 56px; min-height: 48px; padding: 8px 12px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line);
  background: var(--surface); font-weight: 700;
}
.seg button[aria-pressed="true"], .seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.switch { display: flex; align-items: flex-start; gap: var(--s-3); padding: 10px 0; }
.switch .txt { flex: 1; }
.switch .txt b { display: block; }
.switch .txt .small { color: var(--muted); }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 99px; background: var(--surface-2); border: 2px solid var(--line); position: relative; margin: 2px 0 0; transition: background-color var(--t-fast); cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform var(--t-fast) var(--ease-out); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(20px); background: var(--accent-ink); }
.stepper { display: flex; align-items: center; gap: var(--s-2); }
.stepper .val { min-width: 56px; text-align: center; font-size: 28px; font-weight: 800; }
.stepper button { width: 52px; height: 52px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink); border: var(--border-w) solid var(--line); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.badge svg.ic { width: 14px; height: 14px; }
.badge.accent { background: var(--accent-soft); border-color: var(--accent); }
.badge.danger { background: var(--danger-soft); border-color: var(--danger); }

/* player chips */
.pchips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pchip { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 4px 0 12px; border-radius: 99px; background: var(--surface-2); border: var(--border-w) solid var(--line); font-weight: 700; font-size: 15px; max-width: 100%; }
.pchip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; background: transparent; padding: 0 2px; min-height: 44px; font-weight: 700; color: var(--ink); }
.pchip-x { flex: none; border: 0; background: transparent; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); padding: 0; }
.pchip-v { display: inline-grid; color: var(--success); }
.pchip-v svg.ic { width: 16px; height: 16px; }
.pchip-team { flex: none; border: var(--border-w) solid var(--accent); background: var(--surface); width: 44px; height: 44px; border-radius: 50%; font-weight: 800; margin-left: 2px; padding: 0; }
.sugg { max-width: 100%; display: flex; gap: var(--s-2); overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.sugg button { flex: none; min-height: 44px; padding: 6px 14px; border-radius: 99px; border: 2px dashed var(--line); background: transparent; font-size: 15px; font-weight: 600; }
.label-inline { font-size: 14px; font-weight: 700; }
.count-pill { font-size: 13px; font-weight: 800; color: var(--muted); }

/* ---------- ball chips ---------- */
.chip {
  display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 99px; font-weight: 800; font-size: 16px;
  background: var(--surface-2); color: var(--ink); border: var(--border-w) solid var(--line); font-family: var(--font-num); line-height: 1;
}
.chip.dot { color: var(--muted); }
.chip.run { background: var(--surface); }
.chip.four { background: var(--c-four); color: var(--on-solid); border-color: var(--c-four); }
.chip.six { background: var(--c-six); color: var(--on-solid); border-color: var(--c-six); }
.chip.wicket { background: var(--c-wicket); color: var(--on-solid); border-color: var(--c-wicket); }
.chip.dead { background: var(--surface); color: var(--muted); border: 2px dotted var(--muted); }
.chip.wide, .chip.noball, .chip.bye, .chip.legbye { background: var(--surface); color: var(--ink); border: 2px solid var(--c-extra); }
:root[data-theme="sun"] .chip.four { border-radius: 6px; }
:root[data-theme="sun"] .chip.six { border-radius: 6px; outline: 2px solid var(--c-six); outline-offset: 2px; }
:root[data-theme="sun"] .chip.wide, :root[data-theme="sun"] .chip.noball, :root[data-theme="sun"] .chip.bye, :root[data-theme="sun"] .chip.legbye { border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ---------- home ---------- */
.resume { display: flex; flex-direction: column; gap: var(--s-3); background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.resume > * + * { margin-top: 0; }
.resume-title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.resume-score { font-size: 20px; font-weight: 800; }
.resume .btn { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }
:root[data-theme="sun"] .resume { border-width: 3px; }
.home-hero { display: grid; gap: var(--s-4); }
.hero-title { font-size: 28px; font-weight: 900; letter-spacing: -.02em; }
.home-cta { display: grid; gap: var(--s-3); }
.home-grid { display: grid; gap: var(--s-5); }
.up-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.up-card { display: flex; flex-direction: column; gap: var(--s-3); }
.up-card > * + * { margin-top: 0; }
.up-card .when { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; color: var(--ink); }
.up-card .when svg.ic { width: 18px; height: 18px; color: var(--accent); }
:root[data-theme="sun"] .up-card .when svg.ic { color: #000; }
.up-info { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; color: inherit; flex: 1; }
.up-card .teams { font-weight: 800; font-size: 19px; line-height: 1.25; }
.up-actions { margin-top: auto; }
/* shared match card (Active, Upcoming, Previous) */
.up-grid > * { min-width: 0; }
.mcard { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.mcard > * + * { margin-top: 0; }
.mcard .when { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; color: var(--ink); }
.mcard .when svg.ic { width: 18px; height: 18px; flex: none; color: var(--accent); }
:root[data-theme="sun"] .mcard .when svg.ic { color: #000; }
.mcard-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; min-width: 0; }
.mcard-info { min-width: 0; overflow-wrap: anywhere; }
.mcard-title { font-weight: 800; font-size: 19px; line-height: 1.25; }
.mcard-sides { display: grid; gap: var(--s-1); margin-top: var(--s-2); }
.mcard-side { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); min-width: 0; color: var(--muted); font-size: 16px; }
.mcard-team { min-width: 0; overflow-wrap: anywhere; }
.mcard-score { flex: none; font-weight: 700; }
.mcard-side.win { color: var(--ink); font-weight: 800; }
.mcard-sub { margin-top: var(--s-2); }
.mcard-result { margin-top: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); border: var(--border-w) solid var(--accent); font-weight: 800; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.mcard-note { display: block; }
.mcard-lock { display: inline-flex; align-items: center; gap: 4px; }
.mcard-actions { min-width: 0; margin-top: auto; }
.mcard-actions > .btn { min-width: 0; min-height: 44px; text-decoration: none; justify-content: center; }
.mcard-active { border-color: var(--accent); }
.list-card { padding: 0 var(--s-4); }
.list-item { display: flex; align-items: center; gap: var(--s-3); padding: 10px 0; border-top: var(--border-w) solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-main { flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: left; background: none; border: 0; padding: 0; color: inherit; }
.li-title { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: var(--s-4); }
.home-tools { justify-content: flex-start; }
.top-menu { display: none; }
.app[data-route="home"] .top-menu { display: grid; }
.home-version { margin: var(--s-5) 0 0; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
@media (min-width: 768px) { .home-version { display: none; } }
.menu-list { display: flex; flex-direction: column; gap: var(--s-2); }
.menu-list .btn { justify-content: flex-start; width: 100%; min-height: 48px; }
.clear-row { justify-content: flex-start; }
.soon-badge { display: inline-block; margin-left: var(--s-1); padding: 1px 6px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; line-height: 1.4; }
.tab .soon-badge { position: absolute; top: 4px; right: 4px; margin: 0; }
/* Narrow tablet rail (92px): a corner badge would cover the icon, so it sits under the label instead. */
@media (min-width: 768px) and (max-width: 1023.98px) { .tab .soon-badge { position: static; font-size: 10px; padding: 0 5px; } }
.soon-card { max-width: 520px; }


/* ---------- setup wizard / editor ---------- */
.wiz-head { padding-bottom: var(--s-1); }
.stepper-h { list-style: none; margin: 0; padding: 0; display: flex; }
.stepper-h li { flex: 1; display: flex; align-items: center; gap: var(--s-2); position: relative; font-weight: 700; color: var(--muted); min-width: 0; }
.stepper-h .bubble { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface); border: 2px solid var(--line); color: var(--ink); font-size: 15px; }
.stepper-h .bubble svg.ic { width: 18px; height: 18px; }
.stepper-h li.cur { color: var(--ink); }
.stepper-h li.cur .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stepper-h li.done .bubble { background: var(--accent-soft); border-color: var(--accent); }
.stepper-h li:not(:last-child)::after { content: ""; flex: 1; height: 3px; min-width: 8px; margin: 0 var(--s-2); background: var(--line); border-radius: 2px; }
.stepper-h li.done:not(:last-child)::after { background: var(--accent); }
@media (max-width: 479px) { .stepper-h li { flex: 1 1 0; } .stepper-h li:not(:last-child)::after { display: none; } .stepper-h .step-label { font-size: 14px; } .stepper-h li:not(.cur) .step-label { overflow: hidden; text-overflow: ellipsis; } }
.stepper-h .step-label { white-space: nowrap; }
.teams-grid, .rules-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
.teams-grid > *, .rules-grid > * { margin-top: 0 !important; min-width: 0; }
.pool-card summary { font-weight: 800; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); cursor: pointer; list-style: none; }
.pool-card summary::-webkit-details-marker { display: none; }
/* display:flex removes the browser's disclosure arrow, so draw one: a chevron that flips when open. */
.pool-card summary::after { content: ''; flex: none; width: 10px; height: 10px; margin: -4px 4px 0 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.pool-card[open] summary::after { margin-top: 4px; transform: rotate(-135deg); }
.setup-foot {
  display: flex; gap: var(--s-3); position: sticky; bottom: 0; z-index: 2;
  margin: var(--s-4) calc(-1 * var(--gutter)) calc(-1 * var(--s-5)); padding: var(--s-3) var(--gutter) calc(var(--s-3) + var(--safe-b));
  background: var(--bg); border-top: var(--border-w) solid var(--line); flex-wrap: wrap;
}
.setup-foot .btn { flex: 1 1 140px; }
.setup-foot .btn.ghost { flex: 0 1 120px; border-color: var(--line); }
.setup-foot .del { flex-basis: 100%; }
.editor .row.two > .grow { flex: 1 1 0; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); width: 100%; min-height: 56px; padding: 10px 14px; text-align: left; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); background: var(--surface); color: var(--ink); }
.pick + .pick { margin-top: var(--s-2); }
.pick[disabled] { opacity: .55; }
.pick .sub { font-size: 14px; color: var(--muted); font-weight: 600; }
.pick .nm { font-weight: 800; }
.pick.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.banner { display: flex; align-items: center; gap: var(--s-3); background: var(--accent-soft); border: var(--border-w) solid var(--accent); padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 700; color: var(--ink); }

/* ---------- score ---------- */
.score-main { padding: 0; overflow: hidden; }
.sb { padding: var(--s-3) var(--s-4) var(--s-3); background: var(--surface); }
.sb > * + * { margin-top: 2px; }
.sb .team { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sb .big { font-size: clamp(44px, 9vw, 72px); line-height: 1.05; font-weight: 900; letter-spacing: -.02em; color: var(--ink); }
.sb .meta { color: var(--ink); font-weight: 700; font-size: 16px; display: flex; gap: var(--s-4); flex-wrap: wrap; }
.sb .chase { margin-top: var(--s-2); padding: 6px 10px; border-radius: var(--radius-sm); background: var(--accent-soft); border: var(--border-w) solid var(--accent); font-weight: 800; color: var(--ink); font-size: 16px; }
.freehit { display: flex; align-items: center; justify-content: center; gap: var(--s-2); margin-top: var(--s-2); padding: 8px 12px; background: var(--danger); color: var(--on-solid); font-weight: 900; letter-spacing: .12em; border-radius: var(--radius-sm); border: 3px double var(--on-solid); outline: 2px solid var(--danger); }
.batters { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.bat { text-align: left; background: var(--surface); color: var(--ink); border: var(--border-w) solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-height: 84px; min-width: 0; display: block; }
.bat.on-strike { border: 3px solid var(--accent); padding: 8px 10px; background: var(--accent-soft); }
.bat .nm { font-weight: 800; display: flex; align-items: center; gap: 6px; min-width: 0; }
.bat .nm-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strike-mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); flex: none; }
.strike-mark svg.ic { width: 11px; height: 11px; fill: currentColor; stroke-width: 3; }
.bat .st { font-size: 28px; font-weight: 800; line-height: 1.15; }
.bat .st small { font-size: 15px; color: var(--muted); font-weight: 700; }
.bat .role { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.bowl-line { width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 10px 14px; background: var(--surface); color: var(--ink); border: var(--border-w) solid var(--line); border-radius: var(--radius); min-height: 56px; }
.bowl-line .nm { font-weight: 800; }
.bowl-line .fig { font-weight: 800; font-size: 20px; }
.bowl-change { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.bowl-change svg.ic { width: 18px; height: 18px; }
.over-box { padding: var(--s-3) var(--s-4); }
.over-box .chips { min-height: 38px; }
.summary-cols { display: grid; gap: var(--s-4); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.mini-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 4px 6px; border-bottom: var(--border-w) solid var(--line); }
.mini-table td { padding: 6px 4px; border-bottom: var(--border-w) solid var(--line); }
.mini-table .n { text-align: right; width: 2.6em; }
.mini-table tr.live td { font-weight: 800; }
.kbd-note { text-transform: none; letter-spacing: 0; font-weight: 700; }

/* scoring pad */
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); max-width: 640px; margin: 0 auto; }
.pad button {
  position: relative; min-height: 58px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 28px; font-weight: 800;
  font-family: var(--font-num); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0;
  transition: transform 100ms var(--ease-out), filter 100ms;
}
.pad button:active:not([disabled]) { transform: scale(.95); filter: brightness(.9); }
.pad button.k4 { background: var(--c-four); color: var(--on-solid); border-color: var(--c-four); }
.pad button.k6 { background: var(--c-six); color: var(--on-solid); border-color: var(--c-six); }
.pad button.kx { color: var(--ink); border: 3px solid var(--c-extra); background: var(--surface); font-size: 22px; }
.pad button.kw { background: var(--c-wicket); color: var(--on-solid); border-color: var(--c-wicket); font-size: 22px; letter-spacing: .04em; }
.pad button.ku { font-size: 18px; background: var(--surface); font-family: var(--font); }
.pad button.kb { font-size: 20px; }
.pad button.wide2 { grid-column: span 2; min-height: 48px; }
.pad button svg.ic { width: 20px; height: 20px; }
.pad button[disabled] { opacity: .5; }
.pad .kh { display: none; position: absolute; top: 5px; right: 6px; font-size: 11px; padding: 0 5px; line-height: 16px; background: var(--surface); color: var(--ink); border-color: var(--line); }
:root[data-theme="sun"] .pad button.k4 { border-radius: 6px; }
:root[data-theme="sun"] .pad button.k6 { border-radius: 6px; outline: 3px solid var(--c-six); outline-offset: -8px; }
:root[data-theme="sun"] .pad button.kx { border-style: dashed; }
@media (max-height: 760px) { .pad button { min-height: 52px; } .pad button.wide2 { min-height: 44px; } .sb .big { font-size: clamp(44px, 9vw, 60px); } }

/* ---------- sheets (phone) / centred dialogs (>= 768) ---------- */
#sheet-root { position: relative; z-index: var(--z-modal); }
.backdrop { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: var(--z-modal); animation: fade var(--t-fast) var(--ease-out); }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: rise var(--t-base) var(--ease-out);
  border: var(--border-w) solid var(--line); border-bottom: 0;
}
.sheet.tall { min-height: 60vh; min-height: 60dvh; }
/* Prompt sheets (new batter / next bowler): compact, no scrim, so the score header stays visible. */
.backdrop.peek { background: transparent; align-items: flex-end; padding: 0; }
.backdrop.peek .sheet { max-height: 52vh; max-height: 52dvh; box-shadow: 0 -6px 24px rgba(0,0,0,.28); border-radius: 22px 22px 0 0; border-bottom: 0; }
.sheet .grab { width: 40px; height: 5px; background: var(--line); border-radius: 3px; margin: 8px auto 0; flex: none; }
.sheet header { display: flex; align-items: center; gap: var(--s-2); padding: 10px var(--s-4) 6px; }
.sheet header h2 { flex: 1; font-size: 20px; font-weight: 800; }
.sheet .body { overflow-y: auto; padding: var(--s-2) var(--s-4) calc(var(--s-4) + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet .body > * + * { margin-top: var(--s-4); }
.sheet .grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.sheet .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.sheet .grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
.sheet .grid4 .btn, .sheet .grid3 .btn, .sheet .grid2 .btn { min-height: 56px; font-size: 18px; padding: 8px 4px; }
.sheet .lbl { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s-2); }
.warn-box { background: var(--danger-soft); border: var(--border-w) solid var(--danger); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--ink); font-size: 15px; }
.dialog-wrap { align-items: center; padding: var(--s-4); z-index: calc(var(--z-modal) + 1); }
.dialog { background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: var(--s-5); width: 100%; max-width: 440px; border: var(--border-w) solid var(--line); box-shadow: var(--shadow-lg); animation: pop var(--t-base) var(--ease-out); }
.dialog h2 { margin-bottom: var(--s-2); }
.dialog .btns { display: flex; gap: var(--s-3); margin-top: var(--s-5); }
.dialog .btns .btn { flex: 1; }
@keyframes rise { from { transform: translateY(32px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast-root { position: fixed; left: 0; right: 0; top: calc(64px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); pointer-events: none; z-index: var(--z-toast); padding: 0 var(--s-4); }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: var(--s-3); max-width: 520px; box-shadow: var(--shadow-lg); animation: rise var(--t-base) var(--ease-out); border: 2px solid var(--ink); }
.toast svg.ic { width: 20px; height: 20px; }
.toast.err { background: var(--danger); border-color: var(--danger); color: var(--on-solid); }
.toast.good { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toast .toast-act { background: transparent; border: 0; color: inherit; font-weight: 800; text-decoration: underline; padding: 8px; min-height: 40px; font-size: 15px; }
:root[data-theme="sun"] .toast { outline: 2px solid #fff; outline-offset: -5px; }

/* ---------- match tab / result / scorecards ---------- */
.match-grid { display: grid; gap: var(--s-4); }
.match-grid > .col > * + * { margin-top: var(--s-4); }
.kv { display: flex; justify-content: space-between; gap: var(--s-3); padding: 10px 0; border-top: var(--border-w) solid var(--line); }
.kv b { text-align: right; }
.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 8px var(--s-4); margin: 0; align-items: center; }
.keys-list dt, .keys-list dd { margin: 0; }
.danger-zone { border: 2px solid var(--danger); }
.danger-title { color: var(--danger); }
.big-num { font-size: 56px; font-weight: 900; line-height: 1; letter-spacing: -.03em; }
.result-hero { text-align: center; padding: var(--s-5) var(--s-4); background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); border: var(--border-w) solid var(--accent); }
.result-text { font-size: 26px; font-weight: 900; line-height: 1.15; margin-top: 4px; }
:root[data-theme="sun"] .result-hero { border-width: 4px; }
.cols-2 { display: grid; gap: var(--s-4); align-items: start; }
.cols-2 > * { margin-top: 0 !important; }
.perf { display: flex; justify-content: space-between; gap: var(--s-2); padding: 8px 0; border-top: var(--border-w) solid var(--line); }
.perf:first-of-type { border-top: 0; }
.tabs-seg { display: flex; gap: var(--s-2); }
.tabs-seg button { flex: 1; min-height: 48px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); background: var(--surface); font-weight: 800; padding: 0 8px; }
.tabs-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.linkbtn { background: none; border: 0; color: var(--ink); font-weight: 700; padding: 10px 0; text-decoration: underline; min-height: 44px; }
.url-box { word-break: break-all; font-family: var(--font-mono); font-size: 14px; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); }
.url-box.pre { white-space: pre-wrap; margin: 0; font-family: var(--font); font-size: 15px; word-break: normal; }
.scroll-x { overflow-x: auto; }
.scorecard { max-width: 100%; overflow-x: auto; }

/* ---------- tablet: left navigation rail, centred dialogs, two-column forms ---------- */
@media (min-width: 600px) {
  .home-cta { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .sheet .grid4 .btn { font-size: 20px; }
}
@media (min-width: 768px) {
  :root { --rail-w: 92px; }
  .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .topbar, .main, .pad-wrap { grid-column: 2; }
  .topbar { min-height: 68px; padding-top: var(--s-2); }
  .top-title { font-size: 22px; }
  .top-mark, .topbar .sun-btn, .topbar .sync-chip, .top-back.is-home { display: none; }
  .app[data-route="home"] .top-menu { display: none; }
  .tabbar, .app.has-tabs .tabbar { grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; border-top: 0; border-right: var(--border-w) solid var(--line); padding: calc(var(--s-4) + var(--safe-t)) var(--s-2) calc(var(--s-4) + var(--safe-b)); gap: var(--s-4); overflow-y: auto; }
  .rail-brand, .rail-foot { display: flex; }
  .rail-brand { align-items: center; justify-content: center; gap: var(--s-2); color: var(--accent); font-weight: 900; font-size: 18px; letter-spacing: -.02em; }
  .rail-brand svg.ic { width: 34px; height: 34px; }
  .rail-brand .rail-name { display: none; color: var(--ink); }
  .rail-brand b { color: var(--accent); }
  .tab-list { display: flex; flex-direction: column; gap: var(--s-1); }
  .tab.tab-home, .tab.tab-site { display: flex; }
  .tab-sep { display: block; border: 0; border-top: var(--border-w) solid var(--line); margin: var(--s-2) var(--s-2); width: auto; }
  .tab-sep[hidden] { display: none; }
  .tab { min-height: 68px; border-radius: var(--radius-sm); font-size: 13px; width: 100%; }
  .tab[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
  .tab[aria-current="page"]::before { left: 0; right: auto; top: 14px; bottom: 14px; width: 4px; height: auto; border-radius: 0 4px 4px 0; }
  .tab[aria-current="page"] svg.ic { color: var(--accent); }
  :root[data-theme="sun"] .tab[aria-current="page"] svg.ic { color: #000; }
  .rail-foot { margin-top: auto; flex-direction: column; gap: var(--s-2); align-items: stretch; }
  .rail-sync { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; padding: 6px 0; color: var(--ink); }
  .rail-sync[data-state="synced"] svg.ic { color: var(--success); }
  .rail-sync[data-state="offline"] svg.ic, .rail-sync[data-state="saving"] svg.ic { color: var(--warn); }
  .rail-sync[data-state="error"] svg.ic { color: var(--danger); }
  :root[data-theme="sun"] .rail-sync svg.ic { color: #000; }
  .rail-btn { min-height: 60px; border: var(--border-w) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 700; padding: 4px; }
  .rail-btn svg.ic { width: 22px; height: 22px; }
  .rail-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .rail-version { margin: var(--s-1) 0 0; text-align: center; font-size: 11px; color: var(--muted); }
  .toast-root { top: calc(76px + var(--safe-t)); left: var(--rail-w); }

  .page { padding-top: var(--s-5); padding-bottom: var(--s-6); }
  .page > * + * { margin-top: var(--s-5); }
  .pad-wrap { padding: var(--s-3) var(--gutter); }
  .pad button { min-height: 68px; font-size: 30px; }
  .pad button.kx, .pad button.kw { font-size: 24px; }
  .pad button.wide2 { min-height: 56px; }

  .backdrop { align-items: center; padding: var(--s-5); }
  .sheet { max-width: 560px; max-height: min(86vh, 780px); max-height: min(86dvh, 780px); border-radius: var(--radius); border-bottom: var(--border-w) solid var(--line); animation: pop var(--t-base) var(--ease-out); }
  .sheet.tall { min-height: 0; }
  .sheet .grab { display: none; }
  .sheet header { padding: var(--s-4) var(--s-5) var(--s-2); }
  .sheet .body { padding: var(--s-2) var(--s-5) var(--s-5); }

  .teams-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .teams-grid .pool-card { grid-column: 1 / -1; }
  .rules-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .setup-foot { position: static; margin: var(--s-5) 0 0; padding: var(--s-4) 0 0; justify-content: flex-end; background: transparent; }
  .setup-foot .btn { flex: 0 0 auto; min-width: 160px; }
  .setup-foot .btn.ghost { flex: 0 0 auto; min-width: 120px; }
  .setup-foot .del { flex-basis: auto; margin-right: auto; }
  .setup-foot.solo { justify-content: flex-start; }
  .stepper-h { max-width: 640px; }

  .home-hero { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .home-cta { grid-template-columns: none; grid-auto-flow: column; }
  .resume { flex-direction: row; align-items: center; justify-content: space-between; }
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .match-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .batters { gap: var(--s-3); }
}

/* ---------- desktop: sidebar, two-column score dashboard ---------- */
@media (min-width: 1024px) {
  :root { --rail-w: 220px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: var(--s-3); min-height: 52px; padding: 0 var(--s-4); font-size: 16px; }
  .tab[aria-current="page"]::before { top: 10px; bottom: 10px; }
  .rail-brand { justify-content: flex-start; padding: 0 var(--s-3); font-size: 22px; }
  .rail-brand .rail-name { display: inline; }
  .rail-foot { gap: var(--s-2); }
  .rail-sync { flex-direction: row; justify-content: flex-start; gap: var(--s-3); font-size: 14px; padding: 8px var(--s-3); }
  .rail-version { text-align: left; padding: 0 var(--s-3); }
  .rail-btn { flex-direction: row; justify-content: flex-start; gap: var(--s-3); min-height: 48px; padding: 0 var(--s-4); font-size: 15px; }
  .toast-root { top: calc(80px + var(--safe-t)); }

  .score-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 34vw, 440px); gap: var(--s-5); align-items: start; }
  .score-left > * + * { margin-top: var(--s-4); }
  .pad-panel { position: sticky; top: 0; align-self: start; padding: var(--s-4); }
  .pad-panel > * + * { margin-top: var(--s-3); }
  .pad-panel .pad { gap: var(--s-3); }
  .pad-panel .pad button { min-height: 76px; font-size: 32px; }
  .pad-panel .pad button.kx, .pad-panel .pad button.kw { font-size: 26px; }
  .pad-panel .pad button.ku { font-size: clamp(16px, 1.4vw, 20px); }
  .pad-panel .pad button.wide2 { min-height: 60px; }
  .pad .kh { display: inline-block; }
  .sb { padding: var(--s-5); }
  .sb .big { font-size: clamp(64px, 6vw, 96px); }
  .sb .meta { font-size: 18px; }
  .sb .chase { font-size: 18px; }
  .bat .st { font-size: 34px; }
  .summary-cols { grid-template-columns: 1fr 1fr; }
  .home-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .card-cols { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 34px; }
  /* Prompt sheets sit over the scoring pad column (the pad is locked while they are open), so the scoreboard stays readable. */
  .backdrop.peek { left: var(--rail-w); justify-content: flex-end; padding: 0 max(var(--gutter), calc((100vw - var(--rail-w) - var(--content-max)) / 2)) 0 0; }
  .backdrop.peek .sheet { max-width: clamp(340px, 34vw, 440px); }
}
@media (min-width: 1280px) {
  :root { --rail-w: 248px; }
}
@media (min-width: 1440px) {
  .page { padding-top: var(--s-6); }
}

/* ---------- retired hurt, share image ---------- */
.hurt-line { margin-top: var(--s-2); padding: 6px 10px; border-radius: var(--radius-sm); border: var(--border-w) dashed var(--line); background: var(--surface-2); color: var(--ink); font-weight: 600; }
.hurt-line b { font-weight: 800; }
.retire-note { margin-top: var(--s-2); }
.btn.retire-out { justify-self: start; min-height: 44px; font-size: 14px; font-weight: 600; border-width: 1px; width: auto; }
.share-image > * + * { margin-top: var(--s-3); }
.card-preview { display: flex; justify-content: center; min-height: 120px; padding: var(--s-3); background: var(--surface-2); border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); }
.card-preview canvas { display: block; max-width: 320px; width: 100%; height: auto; border-radius: 8px; }

/* ---------- reduced motion (global) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .btn:active, .icon-btn:active, .bat:active, .bowl-line:active, .pick:active, .pad button:active:not([disabled]) { transform: none; }
}

/* ---------- phone in landscape: scoreboard left, scoring pad right (~50%), bottom tabs, 44px+ buttons ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --rail-w: 0px; }
  .app, .app.has-tabs { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .topbar, .main, .pad-wrap, .tabbar, .app.has-tabs .tabbar { grid-column: 1; }
  .topbar { grid-row: 1; min-height: 44px; padding-top: calc(var(--s-1) + var(--safe-t)); padding-bottom: var(--s-1); }
  .top-title { font-size: 18px; }
  .top-mark, .topbar .sun-btn, .topbar .sync-chip { display: inline-flex; }
  .topbar .sun-btn { display: grid; }
  .top-back.is-home { display: grid; }
  .main { grid-row: 2; }
  .page { padding-top: var(--s-3); padding-bottom: var(--s-3); }
  .page > * + * { margin-top: var(--s-3); }
  .pad-wrap { grid-row: 3; }
  .tabbar { display: none; grid-row: 4; }
  .app.has-tabs .tabbar { display: block; grid-row: 4; flex-direction: row; border-right: 0; border-top: var(--border-w) solid var(--line); padding: 0 0 var(--safe-b); overflow: visible; gap: 0; }
  .tab-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
  .tab.tab-home, .tab.tab-site, .tab-sep, .rail-brand, .rail-foot { display: none; }
  .tab { min-height: 44px; flex-direction: row; justify-content: center; gap: var(--s-2); font-size: 14px; padding: 0 var(--s-2); border-radius: 0; width: auto; }
  .tab svg.ic { width: 20px; height: 20px; }
  .tab[aria-current="page"] { background: transparent; }
  .tab[aria-current="page"]::before { top: 0; bottom: auto; left: 20%; right: 20%; width: auto; height: 3px; border-radius: 0 0 4px 4px; }
  .toast-root { left: 0; top: calc(52px + var(--safe-t)); }

  /* score screen with the pad: two columns, pad takes the right half */
  .app.has-pad, .app.has-pad.has-tabs { grid-template-columns: minmax(0, 1fr) minmax(0, 50%); grid-template-rows: auto minmax(0, 1fr) auto; }
  .app.has-pad .topbar { grid-column: 1 / -1; }
  .app.has-pad .main { grid-column: 1; grid-row: 2; }
  .app.has-pad .pad-wrap { grid-column: 2; grid-row: 2; border-top: 0; border-left: var(--border-w) solid var(--line); overflow-y: auto; display: flex; align-items: stretch; padding: var(--s-2) calc(var(--s-2) + var(--safe-r)) var(--s-2) var(--s-2); }
  .app.has-pad .tabbar, .app.has-pad.has-tabs .tabbar { grid-column: 1 / -1; grid-row: 3; }
  .app.has-pad .pad { width: 100%; max-width: none; margin: 0; grid-auto-rows: minmax(44px, 1fr); gap: var(--s-2); }
  .pad button, .pad button.wide2 { min-height: 44px; font-size: 22px; }
  .pad button.kx, .pad button.kw { font-size: 19px; }
  .pad button.ku { font-size: 16px; }
  .sb { padding: var(--s-2) var(--s-3); }
  .sb .big { font-size: clamp(36px, 9vh, 52px); }
  .sb .meta, .sb .chase { font-size: 14px; }
  .bat { min-height: 64px; padding: 6px 10px; }
  .bat.on-strike { padding: 4px 8px; }
  .bat .st { font-size: 22px; }
  .bowl-line { min-height: 48px; padding: 6px 12px; }
  .over-box { padding: var(--s-2) var(--s-3); }
  .btn, .seg button, .pick, .icon-btn { min-height: 44px; }
  .backdrop { padding: var(--s-2); align-items: center; }
  .sheet { max-height: 96vh; max-height: 96dvh; }
  .sheet .grid4 .btn, .sheet .grid3 .btn, .sheet .grid2 .btn { min-height: 48px; font-size: 17px; }
  .pad-panel .pad button { min-height: 44px; font-size: 22px; }
}

/* Live-link QR code (Match tab). The SVG carries its own white backing so it scans in dark and sunlight themes. */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.qr-box svg { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: var(--border-w) solid var(--line); }

@media print {
  .topbar, .tabbar, .toast, .sheet, .scrim, .sheet-scrim, #topbar, #tabbar, .btn, .row .btn, [data-testid="card-preview"] { display: none !important; }
  html, body, .app { background: #fff !important; color: #000 !important; height: auto !important; overflow: visible !important; }
  .app, main, #main { display: block !important; position: static !important; }
  .card { box-shadow: none !important; border: 1px solid var(--line) !important; break-inside: avoid; background: #fff !important; }
  table { break-inside: avoid; }
  * { animation: none !important; transition: none !important; }
}

/* Quick extras row and fix-last-ball sheet (More sheet) */
.sheet .grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); }
.sheet .grid5 .btn { min-height: 48px; font-size: 16px; padding: 8px 2px; }

/* Scorer handover */
.handover-code { font-size: 2rem; font-weight: 800; letter-spacing: .12em; text-align: center; padding: var(--s-3) 0; }
.handover-banner { margin-bottom: var(--s-3); }
.handover-wait .center { text-align: center; }

/* Gloves mode (Match > Settings; body.gloves set by app.js applyPrefs). Bigger pad, no key hints, full-width Undo. */
body.gloves .pad button { min-height: 72px; font-size: 28px; }
body.gloves .pad button.wide2 { min-height: 72px; }
body.gloves .pad button[data-k="u"] { grid-column: 1 / -1; }
body.gloves .pad .kh { display: none !important; }

/* ---- guided openers (setup.js renderOpeners) ---- */
.openers-progress { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.openers-step { font-weight: 800; }
.openers-dots { display: flex; gap: 6px; }
.openers-dots .dot { width: 28px; height: 6px; border-radius: 3px; background: var(--line); }
.openers-dots .dot.on { background: var(--accent); }
.openers-steps .btn { min-height: 44px; }

/* ---- Legal footer (Privacy / Terms): only at the end of the Home screen, never between the score and the pad ---- */
.app:not([data-route="home"]) .sv-legal { display: none; }
.sv-legal { max-width: calc(var(--content-max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter) var(--s-4); }
.sv-legal-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-1) var(--s-2); font-size: .85rem; color: var(--muted); }
.sv-legal-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 var(--s-3); color: var(--muted); text-decoration: none; }
.sv-legal-link:hover { color: var(--ink); text-decoration: underline; }
.sv-legal-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
@media print { .sv-legal { display: none; } }
