/* Badboard: an app shell (sidebar on wide screens, tab bar on phones), clean cards, one green brand colour,
   shuttle yellow for winners. Light and dark follow the phone's setting. */
:root {
  --bg: #F5F7F8;
  --surface: #FFFFFF;
  --surface-2: #F0F3F4;
  --surface-3: #E7ECEE;
  --border: #E2E7EA;
  --border-strong: #CBD3D8;
  --text: #0E1A17;
  --text-2: #4A5A57;
  --text-3: #7D8B88;
  --brand: #0B7A55;
  --brand-hover: #09664A;
  --brand-soft: #E4F3EC;
  --brand-ink: #FFFFFF;
  --gold: #F2B705;
  --gold-soft: #FFF6D6;
  --gold-ink: #5A4300;
  --danger: #C8372D;
  --danger-soft: #FDECEA;
  --warn: #A55B00;
  --court: #1E7F57;
  --court-deep: #186B49;
  --court-line: #FFFFFF;
  --court-mark: rgba(255, 255, 255, 0.55);
  --shadow-sm: 0 1px 2px rgba(16, 24, 22, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 22, 0.05), 0 4px 16px rgba(16, 24, 22, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tight: 1.15;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C1211;
    --surface: #131B1A;
    --surface-2: #1A2422;
    --surface-3: #22302D;
    --border: #24312E;
    --border-strong: #34443F;
    --text: #E8F0EE;
    --text-2: #A7B6B2;
    --text-3: #71817D;
    --brand: #2FBF85;
    --brand-hover: #49D198;
    --brand-soft: rgba(47, 191, 133, 0.14);
    --brand-ink: #04140D;
    --gold: #F5C431;
    --gold-soft: rgba(245, 196, 49, 0.14);
    --gold-ink: #F9DB7A;
    --danger: #FF7B70;
    --danger-soft: rgba(255, 123, 112, 0.12);
    --warn: #F0A24A;
    --court: #18694A;
    --court-deep: #13573D;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
    color-scheme: dark;
  }
}
/* Sinhala letters carry marks above and below the line, so headings get more leading. */
:root[lang="si"] { --tight: 1.4; }
@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p, ol, ul, table, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
img { display: block; max-width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }
.sidebar { display: none; }
@media (min-width: 960px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); view-transition-name: sidebar; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.logo { flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.logo svg { width: 24px; height: 24px; }
.nav-list { display: grid; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px; border-radius: 9px; color: var(--text-2); font-weight: 500; }
.nav-item svg { flex: none; width: 20px; height: 20px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .count { margin-left: auto; }
.side-foot { margin-top: auto; display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.me-card { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; color: var(--text); min-width: 0; }
.me-card:hover { background: var(--surface-2); text-decoration: none; }
.me-card .me-text { min-width: 0; display: grid; line-height: 1.25; }
.me-card strong { font-weight: 600; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-card small { color: var(--text-3); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .row { justify-content: space-between; }

.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border); view-transition-name: appbar; }
.appbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appbar-title .logo { width: 32px; height: 32px; }
@media (min-width: 960px) { .appbar { padding: 12px 32px; min-height: 68px; } .appbar-title > a { display: none; } }
.appbar h1 { font-size: 1.125rem; font-weight: 700; line-height: var(--tight); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 960px) { .appbar h1 { font-size: 1.375rem; } }
.appbar .sub { color: var(--text-2); font-size: 0.8125rem; line-height: 1.3; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .sub:empty { display: none; }
.appbar-title > div { min-width: 0; }
.appbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang-toggle { min-width: 44px; }
@media (min-width: 960px) { .appbar .lang-toggle { display: none; } }

.content { width: 100%; max-width: 1180px; margin-inline: auto; padding: 16px 16px calc(92px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; align-content: start; }
@media (min-width: 700px) { .content { padding-inline: 24px; gap: 20px; } }
@media (min-width: 960px) { .content { padding: 28px 32px 56px; } }

.tabbar { position: fixed; inset: auto 0 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); view-transition-name: tabbar; }
@media (min-width: 960px) { .tabbar { display: none; } }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 2px;
  color: var(--text-3); font-size: 0.6875rem; font-weight: 500; line-height: 1.1; text-align: center; }
.tab:hover { text-decoration: none; color: var(--text-2); }
.tab svg { width: 23px; height: 23px; }
.tab[aria-current="page"] { color: var(--brand); font-weight: 600; }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.tab .count { position: absolute; top: 5px; left: calc(50% + 6px); }

/* ---------- Building blocks ---------- */
.card, .sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 14px; min-width: 0; align-content: start; }
@media (min-width: 700px) { .card, .sec { padding: 20px; } }
.sec-head, .card-head { display: flex; justify-content: space-between; align-items: center; gap: 6px 12px; flex-wrap: wrap; min-width: 0; }
.sec-head h2, .card-head h2 { font-size: 1rem; font-weight: 650; line-height: var(--tight); letter-spacing: -0.005em; }
.card-head h2 small { font-weight: 500; color: var(--text-3); margin-left: 6px; }
.meta { font-size: 0.8125rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.note { font-size: 0.8125rem; color: var(--text-2); }
.empty { color: var(--text-2); padding: 18px 12px; text-align: center; font-size: 0.9375rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.stack { display: grid; gap: 12px; min-width: 0; }
.grid-2 { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; } }
.grid-side { display: grid; gap: 16px; align-items: start; }
@media (min-width: 1000px) { .grid-side { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; } }
.cols-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; } }
.layout { display: grid; gap: 16px; }
.col { display: grid; gap: 16px; min-width: 0; align-content: start; }
@media (min-width: 1000px) { .layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: 20px; } .col { gap: 20px; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: 0.9375rem; line-height: 1; white-space: nowrap; text-decoration: none; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-line { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-line:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.875rem; border-radius: 9px; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-block { width: 100%; }
.textbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 4px; background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 0.875rem; text-decoration: none; border-radius: 6px; }
.textbtn svg { flex: none; width: 18px; height: 18px; }
.textbtn { white-space: nowrap; }
.textbtn:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 3px; }
.textbtn.quiet { color: var(--text-2); }
.textbtn.danger { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 0.8125rem; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 0.6875rem; font-weight: 600; line-height: 1.6; vertical-align: middle; white-space: nowrap; }
.badge.quiet { background: var(--surface-2); color: var(--text-2); }
.badge.gold { background: var(--gold-soft); color: var(--gold-ink); }
.badge.live { background: var(--brand-soft); color: var(--brand); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
.badge.warn { background: var(--danger-soft); color: var(--danger); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.6875rem; font-weight: 700; line-height: 1; }
@keyframes pulse { 50% { opacity: 0.35; } }

.avatar { --h: 150; flex: none; position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 45% 26%); font-weight: 650; font-size: 0.8125rem; letter-spacing: 0.01em; user-select: none; }
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 50% 82%); } }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 58%; height: 58%; }
.avatar.xs { width: 24px; height: 24px; font-size: 0.625rem; }
.avatar.sm { width: 30px; height: 30px; font-size: 0.6875rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.125rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.875rem; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
a.person:hover { text-decoration: none; }
a.person:hover .p-name { text-decoration: underline; text-underline-offset: 3px; }
.person > span:last-child { min-width: 0; }

.seg, .formats { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; }
.seg button, .formats button, .seg a { min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-weight: 500; font-size: 0.875rem; white-space: nowrap; }
.seg button:hover, .formats button:hover { color: var(--text); }
.seg [aria-pressed="true"], .formats [aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg-scroll { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg-scroll .seg { flex-wrap: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { min-height: 42px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--text-2); font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.notice { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); font-size: 0.9rem; }
.notice:empty, #reset-zone:empty { display: none; }
.notice.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.ok-note { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); }
.error { color: var(--danger); font-size: 0.8125rem; font-weight: 500; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border-strong); }
.confirm p { flex: 1 1 240px; min-width: 0; font-size: 0.9rem; }
.confirm .row { gap: 8px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
.pager span { font-size: 0.8125rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pager .btn svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; max-width: 30rem; }
.form.wide { max-width: none; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); }
.field small { font-size: 0.75rem; color: var(--text-3); }
.input, .field input, .field select, .search, .add input, .share-link, select.input {
  width: 100%; min-height: 42px; min-width: 0; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus, .field input:focus, .field select:focus, .search:focus, .add input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input:disabled { background: var(--surface-2); color: var(--text-2); }
input::placeholder { color: var(--text-3); }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 0.9rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.search { padding-left: 38px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237D8B88' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 12px center / 18px no-repeat; }

/* ---------- Lists and tables ---------- */
.list { display: grid; }
.list > li, .list-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--border); min-width: 0; }
.list > li:first-child { border-top: 0; }
.list-item .grow, .list > li .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .sub2 { font-size: 0.8125rem; color: var(--text-3); }
a.list-link { color: inherit; border-radius: 10px; }
a.list-link:hover { text-decoration: none; background: var(--surface-2); }
.list .chev { color: var(--text-3); width: 18px; height: 18px; flex: none; }

.table-wrap { overflow-x: auto; margin-inline: -4px; padding-inline: 4px; }
.roster { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.roster th { padding: 0 8px 8px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.roster th:first-child { padding-left: 0; text-align: left; }
.roster td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: right; }
.roster tbody tr:last-child td { border-bottom: 0; }
.roster td:first-child { padding-left: 0; text-align: left; }
.roster td:last-child, .roster th:last-child { padding-right: 0; }
.roster .n { width: 3.2rem; font-weight: 600; }
.roster .act { width: 1%; white-space: nowrap; }
.roster th.left, .roster td.left { text-align: left; }
.roster tr.gone td { color: var(--text-3); }
.roster td.ask { text-align: left; padding: 0 0 12px; border-bottom: 0; }
.board .rank, .big-board .rank { width: 2.25rem; font-weight: 700; color: var(--text-3); }
.board tr.first .rank, .big-board tr.first .rank { color: var(--gold); }
.big-board .n.key { color: var(--brand); }
.big-board td.n, .big-board th.n { width: auto; min-width: 3rem; }
.big-board tr.me td { background: var(--brand-soft); }
.big-board tr.me td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
@media (max-width: 560px) { .big-board .hide-sm { display: none; } }
.p-name { display: block; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.p-sub { display: block; font-size: 0.75rem; color: var(--text-3); line-height: 1.35; }
.name-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.name-line .p-name { display: inline; }
.p-state { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; line-height: 1.3; color: var(--text-3); }
.p-state i { flex: none; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--text-3); }
.p-state.on { color: var(--brand); font-weight: 600; }
.p-state.on i { background: var(--brand); border-color: var(--brand); }
.p-state.next { color: var(--gold-ink); }
.p-state.next i { background: var(--gold); border-color: var(--gold); }
.lv { display: inline-block; padding: 0 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 0.6875rem; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.lv.hi { background: var(--gold-soft); color: var(--gold-ink); }
.guest { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 6px; border: 1px dashed var(--border-strong); color: var(--text-3); font-size: 0.6875rem; line-height: 1.5; }
.bar { display: block; height: 4px; margin-top: 6px; max-width: 9rem; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bar.big { height: 8px; max-width: none; }
.streak { color: var(--warn); font-weight: 600; }

/* ---------- Court page ---------- */
.session { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.session-id { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.code { font-weight: 700; font-size: 1.125rem; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; }
.code small { font: 600 0.6875rem/1 var(--font); letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-right: 8px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8125rem; line-height: 1.3; color: var(--text-2); }
.status i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status.ok i { background: var(--brand); }
.status.busy i { background: var(--gold); }
.status.warn { color: var(--danger); }
.status.warn i { background: var(--danger); }
.status.live i { background: var(--brand); animation: pulse 2s ease-in-out infinite; }
.share { display: grid; gap: 18px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.share-part { display: grid; gap: 8px; min-width: 0; }
.share-link { font: 500 0.875rem/1 ui-monospace, "SF Mono", Consolas, monospace; text-overflow: ellipsis; background: var(--surface-2); }
.join { display: grid; gap: 8px; }
.join label { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); }
.join input { text-transform: uppercase; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.past li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 12px; border-top: 1px solid var(--border); }
.past li:first-child { border-top: 0; }
.past li span { font-size: 0.8125rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.edit-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); }

/* The session leader. */
#leaders-zone:empty { display: none; }
#leaders-zone { display: grid; gap: 10px; }
.champs { display: grid; gap: 10px; }
.champs.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.champ { position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 16px 18px;
  border-radius: var(--radius); background: linear-gradient(120deg, var(--gold-soft), var(--surface) 75%); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--border)); box-shadow: var(--shadow); }
.trophy { position: relative; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: #3B2C00; }
.trophy svg { width: 28px; height: 28px; }
.champ-body { position: relative; z-index: 1; min-width: 0; }
.champ-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gold-ink); }
.champ-name { font-weight: 750; font-size: clamp(1.375rem, 5vw, 1.875rem); line-height: var(--tight); letter-spacing: -0.015em; overflow-wrap: anywhere; margin: 2px 0 2px; }
.champ-stat { font-size: 0.875rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.champ-mark { position: absolute; right: 14px; bottom: -22px; font-weight: 800; font-size: 6.5rem; line-height: 1; color: color-mix(in srgb, var(--gold) 22%, transparent); pointer-events: none; }
.champs.two .champ { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; align-content: start; }
.champs.two .trophy { width: 40px; height: 40px; }
.champs.two .trophy svg { width: 22px; height: 22px; }
.champs.two .champ-name { font-size: clamp(1.125rem, 4.5vw, 1.5rem); }
@keyframes champ-pop { from { transform: scale(0.97); } to { transform: scale(1); } }
.champ.pop { animation: champ-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.runner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 12px; align-items: center; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.runner-rank { grid-row: span 2; font-weight: 800; font-size: 1.25rem; color: var(--text-3); width: 28px; text-align: center; }
.runner-name { font-weight: 650; overflow-wrap: anywhere; }
.runner-stat { font-size: 0.8125rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
#leaders-zone .note { padding-left: 4px; }

/* The court, seen from above: boundary, tramlines, back and short service lines, centre lines, net. */
#court-zone { display: grid; gap: 12px; }
.court {
  display: grid; grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr); min-height: 210px; border: 3px solid var(--court-line); border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--court-deep), var(--shadow);
  background:
    linear-gradient(var(--court-mark), var(--court-mark)) 0 12px / 100% 2px no-repeat,
    linear-gradient(var(--court-mark), var(--court-mark)) 0 calc(100% - 14px) / 100% 2px no-repeat,
    linear-gradient(var(--court-mark), var(--court-mark)) 12px 0 / 2px 100% no-repeat,
    linear-gradient(var(--court-mark), var(--court-mark)) calc(100% - 14px) 0 / 2px 100% no-repeat,
    linear-gradient(160deg, var(--court), var(--court-deep));
}
.net { background: repeating-linear-gradient(to bottom, var(--court-line) 0 7px, transparent 7px 11px) center / 4px 100% no-repeat; }
.side { position: relative; display: grid; grid-auto-rows: 1fr; min-width: 0; margin: 0; padding: 14px 0; background: transparent; color: #fff; border: 0; border-radius: 0; text-align: center; }
.side::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--court-mark); }
.side-a::before { right: 16%; }
.side-b::before { left: 16%; }
.name { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; padding: 12px 6px; font-weight: 750; font-size: clamp(1.125rem, 5vw, 1.75rem); line-height: var(--tight); letter-spacing: -0.01em; overflow-wrap: anywhere; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.side-a .name { padding-left: 20px; padding-right: calc(16% + 6px); }
.side-b .name { padding-right: 20px; padding-left: calc(16% + 6px); }
.name + .name::before { content: ""; position: absolute; top: -1px; height: 2px; background: var(--court-mark); }
.side-a .name + .name::before { left: 0; right: 16%; }
.side-b .name + .name::before { left: 16%; right: 0; }
button.side { transition: background 0.15s; }
button.side:hover { background: rgba(255, 255, 255, 0.1); }
button.side:active { background: var(--gold); color: #3B2C00; }
button.side:focus-visible { outline: 3px solid var(--gold); outline-offset: -6px; }
button.name { width: 100%; margin: 0; border: 0; background: none; color: inherit; }
button.name::after { content: ""; position: absolute; inset: 8px 10px; border: 2px dashed var(--court-mark); border-radius: 6px; pointer-events: none; }
.side-a button.name::after { right: calc(16% + 4px); }
.side-b button.name::after { left: calc(16% + 4px); }
button.name:hover { background: rgba(255, 255, 255, 0.1); }
button.name[aria-pressed="true"] { background: var(--gold); color: #3B2C00; text-shadow: none; }
button.name[aria-pressed="true"]::after { border-color: transparent; }
button.name:focus-visible { outline: 3px solid var(--gold); outline-offset: -6px; }
.court-empty { grid-template-columns: minmax(0, 1fr); place-items: center; }
.court-empty p { color: #fff; font-weight: 650; font-size: 1.125rem; line-height: var(--tight); text-align: center; padding: 24px; text-wrap: balance; }
.court-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.hint { font-weight: 600; color: var(--brand); font-size: 0.9375rem; }
.last { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; font-size: 0.8125rem; color: var(--text-2); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.edit { display: grid; gap: 14px; padding: 14px; border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--border)); background: var(--gold-soft); }
.edit-part { display: grid; gap: 8px; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pickbtn { display: inline-flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; line-height: 1.2; }
.pickbtn:hover { border-color: var(--brand); }
.pickbtn small { font-size: 0.75rem; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
#mode-zone { display: grid; gap: 8px; }

.fixtures li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); }
.fixtures li:first-child { border-top: 0; }
.num { font-weight: 700; font-size: 0.9375rem; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: center; }
.fixture { min-width: 0; display: grid; gap: 1px; }
.t { font-weight: 500; overflow-wrap: anywhere; }
.v { font-style: normal; font-weight: 400; color: var(--text-3); margin-right: 6px; font-size: 0.8125rem; }
.v.after { margin: 0 0 0 6px; }
.t.won { font-weight: 650; }
.t.won::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--gold); vertical-align: 1px; }
.t.lost { color: var(--text-2); font-weight: 400; }
.fixture .meta { font-size: 0.75rem; }
.when { font-size: 0.75rem; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Who played when: one row per player, one square per match. */
.seq-title { margin-top: 6px; font-size: 0.875rem; font-weight: 650; }
#results-zone { min-width: 0; display: grid; gap: 12px; }
.seq-wrap { overflow-x: auto; max-width: 100%; padding-bottom: 4px; }
.seq { border-collapse: separate; border-spacing: 3px; font-variant-numeric: tabular-nums; }
.seq th { font-size: 0.625rem; font-weight: 500; color: var(--text-3); text-align: center; padding: 0 0 2px; }
.seq th.p { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 4px 0 0 var(--surface); max-width: 7.5rem; padding: 0 8px 0 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.seq td { min-width: 24px; width: 24px; height: 24px; padding: 0; border-radius: 6px; text-align: center; font: 700 0.6875rem/1 var(--font); }
.seq td.w { background: var(--gold); color: #3B2C00; }
.seq td.l { background: var(--surface-3); color: var(--text-2); }
.seq td.r { color: var(--text-3); }
.seq td.x { background: var(--surface-2); opacity: 0.5; }
.seq tr.gone th.p { color: var(--text-3); }

.chip-groups { display: grid; gap: 10px; }
.chip-groups:empty { display: none; }
.regulars { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.regulars-label { flex-basis: 100%; font-size: 0.75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.tag { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px 0 10px; border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; font-size: 0.875rem; }
.tag::before { content: "+"; color: var(--text-3); font-weight: 600; }
.tag:hover { border-style: solid; border-color: var(--brand); color: var(--brand); }
.chip.user { border-style: solid; background: var(--surface-2); border-color: transparent; }
.chip.user:hover { background: var(--brand-soft); }
.chip small { color: var(--text-3); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }

/* Landing and empty screens. */
.welcome { display: grid; gap: 14px; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.welcome h2 { font-size: clamp(1.375rem, 4vw, 1.75rem); font-weight: 750; line-height: var(--tight); letter-spacing: -0.02em; }
.welcome p { color: var(--text-2); max-width: 40em; }
.hero { position: relative; overflow: hidden; padding: 28px 24px; background: linear-gradient(135deg, var(--court) 0%, var(--court-deep) 100%); color: #fff; border: 0; }
.hero h2 { font-size: clamp(1.625rem, 5vw, 2.375rem); }
.hero p { color: rgba(255, 255, 255, 0.86); }
.hero .btn { background: #fff; color: var(--court-deep); border-color: #fff; }
.hero .btn:hover { background: #EAF5EF; }
.hero .btn-line { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.hero .btn-line:hover { background: rgba(255, 255, 255, 0.1); }
.hero .textbtn { color: #fff; }
.hero::after { content: ""; position: absolute; right: -60px; top: -40px; width: 260px; height: 260px; border: 3px solid rgba(255, 255, 255, 0.14); border-radius: 8px; transform: rotate(18deg); pointer-events: none; }
.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.feature { display: grid; gap: 6px; }
.feature .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.feature .ico svg { width: 20px; height: 20px; }
.feature h3 { font-size: 0.9375rem; font-weight: 650; }
.feature p { font-size: 0.875rem; color: var(--text-2); }

/* Leaderboard page. */
.filters { display: grid; gap: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.filter-label { font-size: 0.6875rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.filter { display: grid; gap: 6px; min-width: 0; }
.podium { display: grid; gap: 10px; }
@media (min-width: 760px) { .podium { grid-template-columns: 1.5fr 1fr 1fr; align-items: stretch; } }
.podium .runner { grid-template-columns: auto auto minmax(0, 1fr); padding: 14px 16px; }
.podium .runner .avatar { grid-row: span 2; }
.podium .champ { grid-template-columns: auto auto minmax(0, 1fr); }
.pairs li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); }
.pairs li:first-child { border-top: 0; }
.pairs .stat { font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums; text-align: right; }
.pairs .stat small { display: block; font-weight: 400; font-size: 0.6875rem; color: var(--text-3); }
.stack-avatars { display: inline-flex; }
.stack-avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.stack-avatars .avatar + .avatar { margin-left: -8px; }

/* Profile page. */
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.profile-head .who { flex: 1 1 220px; min-width: 0; display: grid; gap: 4px; }
.profile-head h2 { font-size: clamp(1.375rem, 4vw, 1.75rem); font-weight: 750; line-height: var(--tight); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.photo-edit { position: relative; }
.photo-edit .icon-btn { position: absolute; right: -4px; bottom: -4px; width: 34px; min-width: 34px; height: 34px; border-radius: 50%; padding: 0; background: var(--surface); box-shadow: var(--shadow); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(30%, 6.5rem), 1fr)); }
.stat-tile { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 2px; }
.stat-tile b { font-size: 1.5rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-tile span { font-size: 0.75rem; color: var(--text-3); font-weight: 500; }
.level-line { display: grid; gap: 6px; }
.level-line .row { justify-content: space-between; font-size: 0.8125rem; color: var(--text-2); }
.result-dot { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; font-weight: 700; font-size: 0.75rem; }
.result-dot.w { background: var(--gold); color: #3B2C00; }
.result-dot.l { background: var(--surface-3); color: var(--text-2); }

/* Admin page. */
.admin-table td { vertical-align: top; }
.admin-table .act { text-align: right; }
.admin-table .act .textbtn { margin-left: 6px; }
.admin-table tr.editing td { background: var(--surface-2); }
.admin-table td.form-cell { text-align: left; padding: 8px 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
