:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #14202b; --muted: #5d6b78; --line: #dde3e9;
  --brand: #0f3d5e; --home: #1f6fb2; --away: #c2410c; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --chip: #eef2f6; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e141a; --card: #17212b; --ink: #e8eef4; --muted: #9aa8b5; --line: #2a3643;
          --brand: #7fb8e6; --home: #6aaef0; --away: #f08a5d; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --chip: #22303d; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: baseline;
  padding: 12px 16px; background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .topbar { background: #0b2438; } }
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; }
#crumb { opacity: .85; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#who { color: #fff; font-size: 14px; opacity: .9; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 280px; }  /* room for the dock on the live screen */
h1 { font-size: 22px; margin: 4px 0 12px; } h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #0e141a; } }
button.home { background: var(--home); color: #fff; border-color: var(--home); }
button.away { background: var(--away); color: #fff; border-color: var(--away); }
button:disabled { opacity: .5; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; width: 100%; min-height: 44px; }
textarea { min-height: 120px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.list a.card { display: block; color: inherit; text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--chip); border-radius: 8px; padding: 6px 10px; font: 600 14px ui-monospace, Menlo, Consolas, monospace;
  border: 2px solid transparent; }
.chip.flag { border-color: var(--warn); }
.chip.event { font-weight: 500; opacity: .85; }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 8px; }
.players button { flex-direction: column; padding: 6px; min-height: 56px; font-size: 13px; }
.players button b { font-size: 18px; }
.players button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.players .pos { font-size: 11px; opacity: .9; }

/* live screen */
.score { position: sticky; top: 48px; z-index: 4; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.score .team { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .team.away { text-align: right; }
.score .pts { font: 700 34px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.serve::after { content: " ●"; color: var(--ok); }
.courts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.court { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.court div { background: var(--chip); border-radius: 6px; text-align: center; padding: 6px 0; font-weight: 600;
  font-variant-numeric: tabular-nums; }
.court div.setter { outline: 2px solid var(--brand); }
.court-title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.dock-inner { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.dock .buttons { display: grid; grid-template-columns: 1fr 72px 1fr; gap: 8px; align-items: center; }
.mic { width: 72px; height: 72px; border-radius: 50%; font-size: 28px; background: var(--brand); color: #fff; border: 0; }
.mic.on { background: var(--bad); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(185,28,28,.5); } 70% { box-shadow: 0 0 0 14px rgba(185,28,28,0); } 100% { box-shadow: 0 0 0 0 rgba(185,28,28,0); } }
.net { font-size: 14px; color: var(--warn); font-weight: 600; }
.heard { min-height: 22px; font-size: 15px; color: var(--muted); font-style: italic; }
.pending { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.rally { position: relative; }
.rally .who { font-weight: 700; font-variant-numeric: tabular-nums; }
.rally .who.home { color: var(--home); } .rally .who.away { color: var(--away); }
.rally .said { margin-top: 4px; }
.rally.review { border-left: 4px solid var(--warn); }
.rally.dropped { opacity: .55; }
.flags { margin: 8px 0 0; padding-left: 18px; font-size: 14px; color: var(--warn); }
.notes { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.banner { background: var(--ok); color: #fff; border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
#toast { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 14px;
  border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 10; }
#toast.show { opacity: .92; }
