:root {
  /* color: base */
  --ink: #1d2433; --muted: #5f6776; --line: #e3e5ea; --line-strong: #c9ccd3;
  --bg: #f6f5f2; --card: #fff; --surface-2: #fafaf8; --hover: #fbfaf7;
  /* color: brand */
  --brand: #1f3a5f; --on-brand-muted: #cfd8e6;
  --accent: #e8702a;        /* decoration only: ball, chart line, borders */
  --accent-strong: #c25515; /* text and filled buttons (4.5:1 with white) */
  --accent-hover: #a94a10;
  /* color: status */
  --good: #1a7a43; --good-soft: #eaf6ef; --good-line: #b9e0c8;
  --bad: #c0392b;  --bad-soft: #fdecea;  --bad-line: #f1b8b0;
  --miss-soft: #fbf1ee; --miss-line: #ecd0c7;
  --warn: #9a5b00; --warn-soft: #fff4d6; --warn-line: #ecd9a0; --warn-strong: #c98a00;
  --gold: #c9a227; --purple: #7b5ea7;
  /* type scale */
  --text-xs: .8rem; --text-sm: .875rem; --text-md: 1rem; --text-lg: 1.15rem; --text-xl: 1.6rem;
  /* corners */
  --r-sm: 6px; --r-md: 8px; --radius: 10px; --r-lg: 14px; --r-pill: 999px;
  --focus: 0 0 0 3px var(--card), 0 0 0 5px var(--accent-strong);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); }
h1 { font-size: var(--text-xl); margin: .2rem 0; }
h2 { font-size: var(--text-lg); margin: 1.8rem 0 .6rem; }
h3 { font-size: var(--text-md); margin: 1.2rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); font-weight: 400; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: var(--brand); color: #fff; }
.topbar a { color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: .3rem; flex: 1; }
.topbar nav a { padding: .35rem .75rem; border-radius: var(--r-sm); opacity: .85; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.topbar .who { font-size: var(--text-sm); opacity: .9; }
.topbar .link { color: #fff; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; }
.brand.big { font-size: 1.5rem; color: var(--brand); justify-content: center; }
.ball { width: 1.1em; height: 1.1em; border-radius: 50%; background: var(--accent); position: relative; display: inline-block; flex: none;
  background-image: linear-gradient(transparent 46%, #7a3410 46% 54%, transparent 54%), linear-gradient(90deg, transparent 46%, #7a3410 46% 54%, transparent 54%); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* buttons & forms */
button, .button { font: inherit; padding: .5rem 1rem; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--line-strong); }
.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.danger { color: var(--bad); }
.link { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; }
.wide { width: 100%; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: var(--text-sm); color: var(--muted); }
label.check { flex-direction: row; align-items: center; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-strong); outline-offset: -1px; border-color: transparent; }
a:focus-visible, button:focus-visible, .button:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
.topbar a:focus-visible, .topbar button:focus-visible { box-shadow: 0 0 0 2px var(--brand), 0 0 0 4px #fff; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .shot-grid button:active, .stat-grid button:active { transform: none; } }
textarea { width: 100%; resize: vertical; }
.num { width: 5rem; }
.error { color: var(--bad); min-height: 1.2em; margin: .3rem 0; font-size: var(--text-sm); }
.warn { color: var(--warn); min-height: 1.2em; font-size: var(--text-sm); }
.inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-top: .75rem; }
.grow { flex: 1; min-width: 12rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1rem; }

/* auth */
.auth { min-height: 80vh; display: grid; place-items: center; }
.auth-card { background: var(--card); padding: 2rem; border-radius: var(--r-lg); width: min(380px, 100%); box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: center; }
.auth-card form { display: grid; gap: .8rem; text-align: left; margin-top: 1rem; }

/* page layout */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.back { font-size: var(--text-sm); text-decoration: none; }
.empty { text-align: center; padding: 4rem 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; }
.tile-label { font-size: var(--text-xs); color: var(--muted); }
.tile strong { font-size: 1.35rem; }
.tile .muted { font-size: var(--text-xs); }
.small-tiles strong { font-size: 1.2rem; }
.cards { display: grid; gap: 1rem; margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; }
.card h2 { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 1.5rem; margin-top: 1rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; gap: .5rem; } }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
.stats th, .stats td, .entry th, .entry td { padding: .45rem .55rem; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats th, .entry th { font-size: var(--text-xs); color: var(--muted); font-weight: 600; background: var(--surface-2); }
th.left, td.left { text-align: left; }
tbody tr:hover { background: var(--hover); }
tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
tr.dnp td { color: var(--muted); }
.stats a { text-decoration: none; font-weight: 600; }
.entry td { padding: .25rem; }
.entry input[type=number] { width: 3.2rem; text-align: center; padding: .4rem .2rem; -moz-appearance: textfield; }
.entry input::-webkit-outer-spin-button, .entry input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.entry input.bad { border-color: var(--bad); background: var(--bad-soft); }
.entry input.unsure { border-color: var(--warn-strong); background: var(--warn-soft); }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
#scanBtn { position: relative; }
#scanBtn.busy { opacity: .6; pointer-events: none; }
.scan-note.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.scan-note { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: .6rem .8rem; font-size: var(--text-sm); }
.entry tr.dnp input[type=number] { opacity: .35; }
.entry input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.pts-cell { font-weight: 700; min-width: 2.5rem; }
.game-info { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.roster td { padding: .3rem .4rem .3rem 0; border-bottom: 1px solid var(--line); }
.imp td.up { color: var(--good); } .imp td.down { color: var(--bad); }

/* games list */
.games { display: grid; gap: .4rem; }
.game-row { display: grid; grid-template-columns: 5rem 1fr auto; gap: 1rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: .65rem 1rem; text-decoration: none; color: var(--ink); }
.game-row:hover { border-color: var(--accent); }
.date { color: var(--muted); font-size: var(--text-sm); }
.res { display: inline-block; width: 1.5rem; text-align: center; border-radius: var(--r-sm); color: #fff; font-size: var(--text-xs); }
.res-W { background: var(--good); } .res-L { background: var(--bad); } .res-T { background: var(--muted); }
.notes { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: .75rem 1rem; }

/* chart */
.chart { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.chart figcaption { font-weight: 600; font-size: var(--text-sm); display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.chart .trend { stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 5 4; }
.legend { font-weight: 400; font-size: var(--text-xs); color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--accent); }
.legend i.lg-trend { border-top: 1.5px dashed var(--brand); margin-left: .5rem; }
.chart-pick { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip { padding: .25rem .7rem; border-radius: var(--r-pill); font-size: var(--text-sm); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.2rem; border-radius: var(--r-md); z-index: 10; }
.toast.bad { background: var(--bad); }

/* report */
.report-page { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.report-title { display: flex; align-items: center; gap: .9rem; border-bottom: 3px solid var(--accent); padding-bottom: .75rem; margin-bottom: 1rem; }
.report-title .ball { font-size: 2.2rem; }
.report-title h1 { margin: 0; }
.report-title p { margin: 0; color: var(--muted); }

/* print */
@media print {
  @page { margin: 0.5in; }
  :root { background: var(--card); font-size: 12px; }
  .no-print, .topbar, .toast, select, button { display: none !important; }
  main { padding: 0; max-width: none; }
  .report-page { border: 0; padding: 0; margin: 0; break-after: page; }
  .report-page:last-child { break-after: auto; }
  .table-wrap, .tile, .chart, .card { border-color: #ccc; break-inside: avoid; }
  tr { break-inside: avoid; }
  .two-col { grid-template-columns: 3fr 2fr; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.date small { display: block; font-size: var(--text-xs); }
.tag { font-size: var(--text-sm); color: var(--accent-strong); font-weight: 600; }
form.card.inline { margin: 0 0 .6rem; padding: .8rem 1rem; }

/* attendance pickers */
.roster-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.pick { padding: .8rem .9rem; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); text-align: left; font-weight: 600; color: var(--muted); display: block; }
.pick.on { border-color: var(--good); background: var(--good-soft); color: var(--ink); }
.pick.on::before { content: "✓ "; color: var(--good); }

/* badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.badge { display: flex; gap: .6rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .75rem; break-inside: avoid; }
.badge b { display: block; font-size: var(--text-sm); }
.badge small { color: var(--muted); font-size: var(--text-xs); }
.medal { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 3px rgba(255,255,255,.55); }
.badge-first .medal { background: var(--accent); }
.badge-high .medal { background: var(--good); }
.badge-big .medal { background: var(--gold); }
.badge-total .medal { background: var(--brand); }
.badge-team .medal { background: var(--purple); }

/* live phone entry */
.live { max-width: 560px; margin: 0 auto; }
.live-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.live-status { font-size: var(--text-xs); color: var(--muted); }
.live-status.ok { color: var(--good); }
.live-status.bad { color: var(--bad); font-weight: 600; }
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; background: var(--brand); color: #fff; border-radius: var(--radius); padding: .7rem .9rem; }
.scoreboard .side span { display: block; font-size: var(--text-xs); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scoreboard .side b { font-size: 2rem; line-height: 1.1; }
.opp-btns { display: flex; gap: .3rem; margin-top: .3rem; }
.opp-btns button { padding: .25rem .5rem; font-size: var(--text-xs); background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.chips-row { display: flex; gap: .4rem; overflow-x: auto; padding: .7rem 0; -webkit-overflow-scrolling: touch; }
.pchip { flex: none; display: flex; flex-direction: column; align-items: flex-start; padding: .45rem .75rem; border-radius: var(--radius); font-size: var(--text-sm); }
.pchip small { color: var(--muted); font-size: var(--text-xs); }
.pchip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pchip.on small { color: var(--on-brand-muted); }
.live-player h2 { margin: .3rem 0 .1rem; }
.live-player .line { margin: 0 0 .7rem; color: var(--muted); font-size: var(--text-sm); }
.live-player .line b { color: var(--ink); }
.shot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .5rem; }
.shot-grid button, .stat-grid button { min-height: 64px; font-size: 1.05rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: manipulation; }
.shot-grid small, .stat-grid small { font-weight: 500; font-size: var(--text-xs); color: var(--muted); }
.shot-grid .made { background: var(--good-soft); border-color: var(--good-line); }
.shot-grid .made small { color: var(--good); }
.shot-grid .miss { background: var(--miss-soft); border-color: var(--miss-line); }
.shot-grid button:active, .stat-grid button:active { transform: scale(.97); }
.live-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.live-actions #undo { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) { main { padding: 1rem .75rem; } .topbar .who { display: none; } }

/* parent logins */
.kid-pick { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .4rem 0 .6rem; }
.kids-edit { display: inline-block; margin-right: .75rem; }
.kids-edit summary { display: inline; cursor: pointer; }
.kids-edit[open] { display: block; padding: .5rem 0; }
a.tile.kid { text-decoration: none; color: var(--ink); }
a.tile.kid:hover { border-color: var(--accent); }

/* demo */
.demo-bar { background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); color: var(--ink); font-size: var(--text-sm); padding: .5rem 1.5rem; text-align: center; }
.demo-bar .link { margin-left: .5rem; }
.demo-cta { margin: 1.2rem 0 0; font-size: var(--text-sm); color: var(--muted); }

/* screen readers & keyboard */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: .5rem; top: -3rem; z-index: 20; background: var(--card); color: var(--brand); padding: .5rem .9rem; border-radius: var(--r-md); }
.skip:focus { top: .5rem; box-shadow: var(--focus); }
main:focus, h1:focus { outline: none; }
