/* Pickleball Rotation — court blue for Side A, clay for Side B, optic yellow marks the serve */
:root {
  --bg: #F2F5F4; --surface: #FFFFFF; --surface-2: #E8EEEC; --ink: #14232B; --muted: #5A6A70; --line: #D3DCDA;
  --side-a: #1D5E8A; --side-a-soft: #DCE9F2; --side-b: #B44E28; --side-b-soft: #F5E2D9;
  --ball: #C9D20F; --ball-ink: #1B2400; --good: #2C7A52; --warn: #9A6A00; --warn-soft: #F7ECD0;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E161B; --surface: #16212A; --surface-2: #1D2B35; --ink: #E5EDEF; --muted: #93A3AA; --line: #273741;
    --side-a: #64ADDD; --side-a-soft: #18324A; --side-b: #EA8A62; --side-b-soft: #3D2318;
    --ball: #DCE34A; --good: #5BC28C; --warn: #E2B341; --warn-soft: #3A2F12;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 0px); }
a { color: var(--side-a); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 4px 16px; padding-block: 10px 0; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 25px; line-height: 1; display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; padding-bottom: 10px; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ball); }
.tabs { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; }
.tab { padding: 8px 10px 10px; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--side-a); }
@media (max-width: 520px) { .tabs { margin-left: 0; width: 100%; } .tab { flex: 1; text-align: center; font-size: 15px; letter-spacing: .02em; padding-inline: 4px; } }

main { max-width: 760px; margin: 0 auto; padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.view { display: grid; gap: 18px; }
.narrow { max-width: 420px; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.1; margin: 0; text-wrap: balance; }
h3 { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: .05em; text-transform: uppercase; margin: 0; color: var(--muted); }
p { margin: 0; }
.sub { color: var(--muted); max-width: 62ch; margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.flash { background: color-mix(in srgb, var(--good) 14%, var(--surface)); border: 1px solid var(--good); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; }
.error { color: var(--side-b); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; align-items: flex-start; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 14px; font-weight: 600; color: var(--ink); text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--side-a); border-color: var(--side-a); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--side-b); color: var(--side-b); background: var(--surface); }
.btn.ghost { color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .listrow input, .copyrow input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.preview { font-size: 14px; color: var(--muted); }
.banner { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }

.list { display: grid; gap: 8px; }
.listrow { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; color: var(--ink); text-decoration: none; flex-wrap: wrap; }
a.listrow:hover { border-color: var(--side-a); }
.listrow.retired { opacity: .55; }
.lr-main { display: grid; min-width: 0; }
.lr-side { font-family: var(--font-display); font-weight: 600; font-size: 17px; color: var(--muted); font-variant-numeric: tabular-nums; }
form.inline { display: flex; gap: 8px; align-items: center; }
form.inline.grow { flex: 1; min-width: 200px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .ord { font-family: var(--font-display); font-weight: 700; color: var(--ball); }
.chip .ord:empty { display: none; }

.share { grid-template-columns: 1fr auto; align-items: center; }
.share-text { display: grid; gap: 8px; min-width: 0; }
.copyrow { display: flex; gap: 8px; }
.qr { background: #FFFFFF; padding: 8px; border-radius: 8px; line-height: 0; }
.qr img, .qr canvas { width: 132px; height: 132px; }
@media (max-width: 520px) { .share { grid-template-columns: 1fr; } .qr { justify-self: start; } }

.half-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.half-head .note { font-size: 13px; color: var(--muted); }
.games { display: grid; gap: 8px; }
.game { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: grid; grid-template-columns: 52px 1fr auto; overflow: hidden; scroll-margin-top: 90px; }
.game.dim { opacity: .45; }
.game.final .gno { background: var(--surface-2); }
.game.live { border-color: var(--ball); box-shadow: 0 0 0 1px var(--ball); }
.gno { display: grid; place-content: center; text-align: center; border-right: 1px solid var(--line); font-family: var(--font-display); }
.gno b { font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.gno span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gbody { padding: 10px 12px; display: grid; gap: 4px; min-width: 0; }
.team { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.tag { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; flex: none; }
.tag.a { background: var(--side-a-soft); color: var(--side-a); }
.tag.b { background: var(--side-b-soft); color: var(--side-b); }
.tnames { font-weight: 600; overflow-wrap: anywhere; }
.pn.me { text-decoration: underline; text-decoration-color: var(--ball); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.sits { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.game.sitting .sits { color: var(--warn); font-weight: 600; }
.gside { display: grid; align-content: center; justify-items: end; gap: 6px; padding: 10px 12px 10px 0; }
.final { font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.final .w { color: var(--good); }
.livetag { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--ball); color: var(--ball-ink); border-radius: 4px; padding: 1px 6px; }
.mark { margin: 2px 0; padding: 6px 12px; border-left: 3px solid var(--ball); font-size: 13px; font-weight: 600; color: var(--good); }

.nowcard { border-color: var(--ball); }
.nowscore { display: grid; gap: 6px; }
.ns { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.ns b { font-family: var(--font-display); font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }

.call { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; letter-spacing: .04em; font-variant-numeric: tabular-nums; text-align: center; }
.call small { display: block; font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.winline { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--good); }
.court { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side { border: 2px solid var(--line); border-radius: 12px; padding: 14px 12px 16px; background: var(--surface); text-align: center; display: grid; gap: 6px; justify-items: center; align-content: center; min-height: 230px; position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.side.a { border-color: var(--side-a); }
.side.b { border-color: var(--side-b); }
.side:active { transform: scale(.985); }
.side:disabled { cursor: default; }
.side .label { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; }
.side.a .label { color: var(--side-a); }
.side.b .label { color: var(--side-b); }
.side .names { font-weight: 600; overflow-wrap: anywhere; }
.side .pts { font-family: var(--font-display); font-weight: 700; font-size: 96px; line-height: .9; font-variant-numeric: tabular-nums; }
.side .hint { font-size: 12px; color: var(--muted); min-height: 1em; }
.side.won { background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.side { padding-top: 40px; }
.serve { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--ball-ink); background: var(--ball); border-radius: 999px; padding: 2px 9px; }
.manual { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.manual .field input { width: 80px; }
@media (max-width: 520px) { .side { min-height: 200px; } .side .pts { font-size: 80px; } .call { font-size: 38px; } }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
thead th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); font-weight: 600; }
tbody tr + tr td { border-top: 1px solid var(--line); }
td.rank { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--muted); width: 36px; }
tbody tr:first-child td.rank span { background: var(--ball); color: var(--ball-ink); border-radius: 50%; display: inline-grid; place-content: center; width: 28px; height: 28px; }
.pos { color: var(--good); } .neg { color: var(--side-b); }
.empty { color: var(--muted); padding: 12px; text-align: center; }
details.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.danger-zone[open] { gap: 12px; }
@media (prefers-reduced-motion: reduce) { .side:active { transform: none; } }

/* System area */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtabs a { padding: 8px 12px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.subtabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--side-a); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 4px; padding: 2px 7px; flex: none; text-align: center; min-width: 52px; }
.pill.pass { background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.fail { background: var(--side-b-soft); color: var(--side-b); }
.status-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.status-head.pass { border-color: var(--good); } .status-head.warn { border-color: var(--warn); } .status-head.fail { border-color: var(--side-b); }
.status-head .pill { font-size: 13px; padding: 4px 10px; }
.checks ul { list-style: none; margin: 0; padding: 0; display: grid; }
.checks li { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: baseline; padding: 9px 0; }
.checks li + li { border-top: 1px solid var(--line); }
.ck-label { font-weight: 600; }
.ck-detail { grid-column: 2; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.upgroup { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.upfolder { background: var(--surface-2); padding: 8px 12px; }
.upgroup ul { list-style: none; margin: 0; padding: 4px 12px 8px; display: grid; gap: 6px; }
.upgroup li { display: flex; gap: 10px; align-items: center; }
ul.notes { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.bklist { display: grid; }
.bkrow { display: flex; gap: 8px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; }
.bkrow + .bkrow { border-top: 1px solid var(--line); }
.bk-main { display: grid; min-width: 0; }
.bk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.foot { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.copybox { width: 100%; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 10px 12px; border: 1px solid var(--line, #cfd8dc); border-radius: 8px; background: var(--surface-2, #f4f7f8); color: inherit; resize: vertical; }
.ck-ok { display: flex; gap: 10px; align-items: center; margin: 8px 0 14px; }
