/* For Court's Sake Leagues: same evergreen + lime brand as the club night app; scoreboard numbers in Archivo. */
:root {
  --brand-900: #102A27; --brand-800: #163a34; --brand-700: #1F5147;
  --accent: #C7F36B; --accent-ink: #13261F; --accent-soft: #EEF9D6;
  --page: #F5F7F3; --surface: #FFFFFF; --surface-2: #EEF3EF; --text: #162421; --muted: #61716D; --border: #DEE7E2;
  --success: #237D57; --warning: #A86415; --danger: #B33D42; --info: #2767A7;
  --success-bg: #E1F1E8; --warning-bg: #F8ECDC; --danger-bg: #F7E3E4; --info-bg: #E2ECF7;
  --live: #D9363E; --on-dark: #F2F7EF; --on-dark-muted: #A9C0B8; --scrim: rgba(6, 16, 14, .5); --shadow: 0 10px 30px rgba(16, 42, 39, .14);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Archivo', 'Inter', system-ui, sans-serif;
  --r: 16px; --r-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: #24331A; --page: #0C1513; --surface: #14201D; --surface-2: #1A2925; --text: #E3ECE8; --muted: #98AAA4; --border: #273832;
    --success: #5AC592; --warning: #E5A85A; --danger: #E9787D; --info: #7DB3EC; --live: #FF6B70;
    --success-bg: #15302A; --warning-bg: #352A19; --danger-bg: #3A1F22; --info-bg: #182B3F; --scrim: rgba(0, 0, 0, .6); --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-soft: #24331A; --page: #0C1513; --surface: #14201D; --surface-2: #1A2925; --text: #E3ECE8; --muted: #98AAA4; --border: #273832;
  --success: #5AC592; --warning: #E5A85A; --danger: #E9787D; --info: #7DB3EC; --live: #FF6B70;
  --success-bg: #15302A; --warning-bg: #352A19; --danger-bg: #3A1F22; --info-bg: #182B3F; --scrim: rgba(0, 0, 0, .6); --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 70; background: var(--brand-900); }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid #6CB4FF; outline-offset: 2px; border-radius: 8px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; background: var(--brand-900); color: var(--on-dark); }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-stretch: 112%; font-weight: 800; font-size: 17px; }
.logo .mk { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none; }
.logo small { font-family: var(--font); font-weight: 600; font-size: 13px; color: var(--on-dark-muted); }
.testpill { margin-left: auto; font-size: 12px; font-weight: 700; background: rgba(199, 243, 107, .16); color: var(--accent); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.banner { background: var(--warning-bg); color: var(--text); font-size: 13px; padding-block: 8px; }

main { padding-block: 20px 60px; display: grid; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.cap { font-size: 13px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: var(--brand-900); color: var(--on-dark); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, select.input { min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); padding: 0 12px; width: 100%; }
.field { display: grid; gap: 6px; }
.field label, .lbl { font-weight: 650; font-size: 14px; }

/* headings */
.page-head { display: grid; gap: 6px; }
.page-head h1 { font-family: var(--display); font-stretch: 112%; font-weight: 850; font-size: clamp(28px, 5vw, 42px); line-height: 1.05; letter-spacing: -.01em; }
.page-head p { color: var(--muted); }
.back { font-weight: 650; text-decoration: none; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.code-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600; }
.code-chip b { letter-spacing: .12em; font-variant-numeric: tabular-nums; }

/* segmented tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 650; cursor: pointer; white-space: nowrap; }
.tabs button[aria-pressed="true"] { background: var(--brand-900); color: var(--on-dark); border-color: transparent; }
.tabs.sub button { min-height: 36px; border-radius: 10px; font-size: 14px; }
.tabs.sub button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* live */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); display: inline-block; flex: none; }
@media (prefers-reduced-motion: no-preference) { .live-dot.pulse { animation: pulse 1.6s infinite; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } } }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.live { background: var(--danger-bg); color: var(--live); }
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

.tonight { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.mcard { display: grid; gap: 8px; background: var(--brand-900); color: var(--on-dark); border-radius: var(--r); padding: 14px; text-decoration: none; border: 0; text-align: left; cursor: pointer; }
.mcard .teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.mcard .tn { font-weight: 700; font-size: 15px; line-height: 1.2; }
.mcard .tn.r { text-align: right; }
.mcard .sc { font-family: var(--display); font-stretch: 110%; font-weight: 850; font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.mcard .meta { font-size: 12.5px; color: var(--on-dark-muted); display: flex; justify-content: space-between; gap: 8px; }

/* league table */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.t th { text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.t td { text-align: right; padding: 11px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.t tr:last-child td { border-bottom: 0; }
.t th.l, .t td.l { text-align: left; }
.t td.pos { font-weight: 800; width: 34px; color: var(--muted); text-align: left; padding-left: 14px; }
.t th:first-child { padding-left: 14px; } .t td:last-child, .t th:last-child { padding-right: 14px; }
.t td.team { font-weight: 700; }
.t td.team a, .t td.l a { text-decoration: none; }
.t td.team a:hover, .t td.l a:hover { text-decoration: underline; }
.t td.pts { font-family: var(--display); font-weight: 850; font-size: 17px; }
.t tr.top1 td.pos { color: var(--success); }
.t tr.flash td { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.mv { font-size: 11px; font-weight: 800; margin-left: 4px; }
.mv.up { color: var(--success); } .mv.down { color: var(--danger); }
.form { display: inline-flex; gap: 3px; }
.form i { width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center; font-style: normal; font-size: 10.5px; font-weight: 800; }
.form i.W { background: var(--success-bg); color: var(--success); } .form i.L { background: var(--danger-bg); color: var(--danger); } .form i.D { background: var(--surface-2); color: var(--muted); }
@media (max-width: 640px) { .t .hide-s { display: none; } }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand-700); }

/* fixtures */
.fx-day { display: grid; gap: 8px; }
.fx-day h3 { font-size: 13px; font-weight: 700; color: var(--muted); }
.fx { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; text-decoration: none; cursor: pointer; }
.fx:hover { border-color: var(--brand-700); }
.fx .h { font-weight: 650; } .fx .a { font-weight: 650; text-align: right; }
.fx .mid { text-align: center; display: grid; gap: 2px; justify-items: center; }
.fx .sc { font-family: var(--display); font-weight: 850; font-size: 20px; font-variant-numeric: tabular-nums; }
.fx .wn { color: var(--text); } .fx .ls { color: var(--muted); font-weight: 500; }

/* stats */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { min-width: 180px; flex: 1; }
.pct { font-weight: 800; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); width: 70px; display: inline-block; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand-700); border-radius: 3px; }

/* match */
.scoreboard { background: var(--brand-900); color: var(--on-dark); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; }
.scoreboard .teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.scoreboard .tn { font-family: var(--display); font-stretch: 108%; font-weight: 800; font-size: clamp(17px, 3vw, 24px); line-height: 1.15; }
.scoreboard .tn.r { text-align: right; }
.scoreboard .big { font-family: var(--display); font-stretch: 115%; font-weight: 900; font-size: clamp(40px, 8vw, 64px); font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: .02em; text-align: center; }
.scoreboard .sub { color: var(--on-dark-muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.roles { display: flex; gap: 6px; flex-wrap: wrap; }
.rub { display: grid; grid-template-columns: 34px 1fr auto 1fr; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rub:last-child { border-bottom: 0; }
.rub .n { font-weight: 800; color: var(--muted); }
.rub .pr { font-size: 14px; line-height: 1.3; }
.rub .pr.r { text-align: right; }
.rub .pr.win { font-weight: 750; }
.rub .pr.lose { color: var(--muted); }
.rub .gs { display: flex; gap: 6px; justify-content: center; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 650; }
.rub .gs span { background: var(--surface-2); border-radius: 8px; padding: 3px 7px; white-space: nowrap; }
.rub .gs span.cur { background: var(--danger-bg); color: var(--live); }
.rub .act { grid-column: 2 / -1; display: flex; justify-content: center; }
.rub.flash { animation: flash 2.4s ease-out; }
@media (max-width: 560px) { .rub { grid-template-columns: 26px 1fr auto 1fr; gap: 6px; padding: 10px; } .rub .pr { font-size: 13px; } .rub .gs { flex-direction: column; gap: 3px; } }
.pairs-pick { display: grid; gap: 10px; }
.pairs-pick .pp { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; align-items: center; }
.note { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; }
.note.warn { background: var(--warning-bg); }
.note.bad { background: var(--danger-bg); }
.confirm-box { display: grid; gap: 10px; }
.conf { display: flex; gap: 10px; flex-wrap: wrap; }
.conf > div { flex: 1; min-width: 200px; background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; display: grid; gap: 4px; }

/* home */
.lg-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.lg { display: grid; gap: 8px; text-decoration: none; }
.lg h3 { font-family: var(--display); font-stretch: 110%; font-weight: 800; font-size: 20px; }
.team-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.tcard { display: grid; gap: 4px; text-decoration: none; }
.tcard b { font-size: 16px; }

/* sheet + toast */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 80; display: grid; place-items: end center; }
.sheet { background: var(--surface); width: min(560px, 100%); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px)); max-height: 92vh; overflow: auto; display: grid; gap: 14px; }
@media (min-width: 700px) { .scrim { place-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { font-size: 19px; }
.games { display: grid; gap: 10px; }
.game { display: grid; grid-template-columns: 70px 1fr 18px 1fr; gap: 8px; align-items: center; }
.game .input { text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.err { color: var(--danger); font-size: 14px; min-height: 1em; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--brand-900); color: var(--on-dark); padding: 12px 16px; border-radius: 12px; font-weight: 600; z-index: 90; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
#toast:empty { display: none; }
#toast.err { background: var(--danger); }
.foot { color: var(--muted); font-size: 13px; padding-block: 20px; }
.show-s { display: none; } @media (max-width: 640px) { .show-s { display: block; } }
