/* Kourt: broadcast-grade tournament UI. Display = Barlow Condensed, UI = Inter. */
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url(../fonts/barlow-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-display: swap; src: url(../fonts/barlow-condensed-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url(../fonts/inter-latin-700-normal.woff2) format('woff2'); }

:root {
  --navy-950: #060B1A; --navy-900: #0A1430; --navy-800: #111E45; --navy-700: #1A2B5E; --navy-600: #253A78;
  --ball: #DFFF4F; --ball-2: #C8EB2E; --ball-ink: #0A1430;
  --live: #FF3355; --ok: #17B26A; --warn: #F5A524; --info: #2E9BFF;
  --bg: #E2E6EE; --card: #FFFFFF; --card-2: #F3F5F9; --ink: #0A1430; --ink-2: #47527A; --ink-3: #8991AD;
  --line: rgba(10, 20, 48, 0.09); --line-2: rgba(10, 20, 48, 0.16);
  --r: 8px; --r-lg: 12px;
  --disp: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --ui: 'Inter', system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(10, 20, 48, 0.06), 0 4px 16px rgba(10, 20, 48, 0.06);
  /* theme tokens (light is the default) */
  --sunken: #EDF0F5;            /* inputs and inner boxes */
  --accent-ink: var(--navy-900); /* emphasis text: navy on light, ball-yellow on dark */
  --accent-soft: rgba(10, 20, 48, 0.05);
  --primary-bg: var(--navy-900); --primary-ink: #fff;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #060B1A; --card: #0D1838; --card-2: #132150; --ink: #F2F5FB; --ink-2: rgba(242, 245, 251, 0.7); --ink-3: rgba(242, 245, 251, 0.48);
  --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sunken: #111E45; --accent-ink: var(--ball); --accent-soft: rgba(223, 255, 79, 0.06);
  --primary-bg: #fff; --primary-ink: var(--navy-950);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--ui); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, .tab { font-variant-numeric: tabular-nums; }
.disp { font-family: var(--disp); text-transform: uppercase; letter-spacing: 0.01em; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); }
.hide { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- top bar */
.topbar { background: var(--navy-900); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--disp); font-weight: 800; font-size: 22px; letter-spacing: 0.04em; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 50%; background: var(--ball); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 2px solid var(--navy-900); clip-path: inset(0 55% 0 0); }
.brand-mark::after { clip-path: inset(0 0 0 55%); }
.topbar .tname { font-family: var(--disp); font-weight: 600; font-size: 18px; text-transform: uppercase; color: rgba(255,255,255,.75); }
.topbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.1); color: #fff; white-space: nowrap; }
.chip.code { font-family: var(--disp); font-size: 15px; letter-spacing: 0.12em; background: var(--ball); color: var(--ball-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
.dot.off { background: var(--warn); } .dot.bad { background: var(--live); }
.clock { font-family: var(--disp); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

/* ---------- pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 4px; font-family: var(--disp); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--card-2); color: var(--ink-2); white-space: nowrap; }
.pill.live { background: var(--live); color: #fff; }
.pill.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.2s ease-in-out infinite; }
.pill.called { background: var(--ball); color: var(--ball-ink); }
.pill.done { background: #E6EBFF; color: var(--navy-700); }
.pill.final { background: var(--primary-bg); color: var(--primary-ink); }
.pill.disputed, .pill.bad { background: #FFE3E8; color: #B4123A; }
.pill.warn { background: #FFF2D6; color: #8A5800; }
.pill.ok { background: #DDF7EA; color: #0B7A45; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--card); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-ink); }
.btn.primary:hover { opacity: .88; }
.btn.ball { background: var(--ball); border-color: var(--ball-2); color: var(--ball-ink); }
.btn.danger { color: #B4123A; border-color: #F3B6C3; }
.btn.danger.solid { background: var(--live); border-color: var(--live); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn.xl { height: 64px; font-size: 18px; font-family: var(--disp); text-transform: uppercase; letter-spacing: .04em; }
.btn.block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.input, select.input, textarea.input { min-width: 0; height: 38px; padding: 0 11px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--card); outline: none; width: 100%; }
textarea.input { height: auto; padding: 10px 11px; min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(37,58,120,.12); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 0 14px; height: 36px; font-weight: 600; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary-bg); color: var(--primary-ink); }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); border: 0; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--ok); } .switch.on::after { left: 19px; }

/* ---------- cards */
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h3, .h3 { margin: 0; font-family: var(--disp); font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: .03em; }
.card-b { padding: 14px 16px; }
.h1 { font-family: var(--disp); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 1; margin: 0; letter-spacing: .01em; }
.h2 { font-family: var(--disp); font-weight: 700; font-size: 24px; text-transform: uppercase; margin: 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.banner { padding: 10px 14px; border-radius: var(--r); background: #FFF2D6; color: #6B4500; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.banner.info { background: #E3F0FF; color: #0D4C8C; } .banner.bad { background: #FFE3E8; color: #8E0F2E; } .banner.ok { background: #DDF7EA; color: #075E35; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* ---------- avatar & team */
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--disp); font-weight: 700; font-size: 14px; flex: none; overflow: hidden; background-size: cover; background-position: center; border: 2px solid var(--card); }
.av.sm { width: 24px; height: 24px; font-size: 11px; border-width: 1.5px; }
.av.lg { width: 56px; height: 56px; font-size: 22px; } .av.xl { width: 96px; height: 96px; font-size: 36px; border-width: 3px; }
.avs { display: inline-flex; } .avs .av + .av { margin-left: -8px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team .tn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.win .tn { font-weight: 800; }
.tbd { color: var(--ink-3); font-style: italic; }

/* ---------- scoreboard rows (shared look) */
.sb { display: grid; grid-template-columns: 1fr auto; gap: 0; font-variant-numeric: tabular-nums; }
.sb-row { display: grid; grid-template-columns: 14px 1fr repeat(var(--sets, 1), 30px) 44px; align-items: center; gap: 6px; padding: 6px 0; }
.sb-row + .sb-row { border-top: 1px solid var(--line); }
.serve { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.serve.on { background: var(--ball-2); box-shadow: 0 0 0 2px rgba(200,235,46,.35); }
.g { font-family: var(--disp); font-weight: 700; font-size: 20px; text-align: center; color: var(--ink-2); }
.g.won { color: var(--ink); }
.pt { font-family: var(--disp); font-weight: 800; font-size: 20px; text-align: center; background: var(--navy-900); color: var(--ball); border-radius: 4px; height: 28px; line-height: 28px; }

/* ---------- tables */
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t td.c, table.t th.c { text-align: center; }
table.t tr.q td { background: rgba(223,255,79,.18); }
table.t tr.q td:first-child { box-shadow: inset 3px 0 0 var(--ball-2); }
.rank { font-family: var(--disp); font-weight: 800; font-size: 16px; width: 22px; }

/* ---------- schedule grid */
.grid-sched { display: grid; gap: 6px; align-items: stretch; }
.gs-h { font-family: var(--disp); font-weight: 700; text-transform: uppercase; font-size: 14px; color: var(--ink-2); padding: 4px 6px; letter-spacing: .04em; }
.gs-t { font-family: var(--disp); font-weight: 700; font-size: 16px; padding: 8px 6px; color: var(--ink); font-variant-numeric: tabular-nums; }
.mc { border-radius: 6px; background: var(--card); border: 1px solid var(--line); padding: 6px 8px; font-size: 12px; min-height: 52px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border-left: 3px solid var(--line-2); }
.mc:hover { border-color: var(--ink-3); }
.mc .ml { display: flex; justify-content: space-between; font-family: var(--disp); font-weight: 700; font-size: 12px; letter-spacing: .05em; color: var(--ink-3); text-transform: uppercase; }
.mc .mt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc.s-live { border-left-color: var(--live); } .mc.s-called { border-left-color: var(--ball-2); } .mc.s-final { border-left-color: var(--navy-900); background: var(--card-2); }
.mc.s-done, .mc.s-disputed { border-left-color: var(--warn); } .mc.st-ko { background: linear-gradient(90deg, rgba(37,58,120,.06), transparent); }
.mc.empty-cell { background: transparent; border: 1px dashed var(--line); cursor: default; }

/* ---------- bracket */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding-bottom: 6px; }
.br-col { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; min-width: 200px; flex: 1; }
.br-col h4 { margin: 0 0 4px; font-family: var(--disp); font-weight: 700; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.br-m { background: var(--card); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; font-size: 13px; }
.br-t { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.br-t + .br-t { border-top: 1px solid var(--line); }
.br-t .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.br-t.w .n { font-weight: 800; } .br-t.l { color: var(--ink-3); }
.br-t .s { font-family: var(--disp); font-weight: 700; font-size: 15px; }
.br-meta { font-size: 11px; color: var(--ink-3); padding: 3px 8px; background: var(--card-2); display: flex; justify-content: space-between; }

/* ---------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(6,11,26,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fade .15s ease; }
.modal { background: var(--card); color: var(--ink); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal.wide { max-width: 1280px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-b { padding: 18px 20px; } .modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

.note { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 80; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 92vw; }
.note.bad { background: var(--live); }

.qr svg { width: 100%; height: auto; display: block; }
.qr { background: #fff; padding: 10px; border-radius: 8px; }

/* iOS draws date fields at their own width unless appearance is reset */
input[type=datetime-local].input, input[type=date].input, input[type=time].input { -webkit-appearance: none; appearance: none; display: block; line-height: 36px; }
.field.span-all { grid-column: 1 / -1; }

@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; min-width: 0; }
  .topbar > * { flex-shrink: 0; }
  .topbar .tname, .topbar .clock { display: none; }
}
@media (max-width: 420px) {
  .topbar .chip:not(.code) { padding: 0 8px; }
}

/* ---------- theme toggle */
.theme-btn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; padding: 0; }
.theme-btn:hover { background: rgba(255,255,255,.18); }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn.on-light { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }

/* dark-mode touch-ups for light-first components */
[data-theme="dark"] .pill { background: var(--card-2); color: var(--ink-2); }
[data-theme="dark"] .pill.live { background: var(--live); color: #fff; }
[data-theme="dark"] .pill.called { background: var(--ball); color: var(--ball-ink); }
[data-theme="dark"] .pill.done { background: rgba(46,155,255,.18); color: #9CCBFF; }
[data-theme="dark"] .pill.disputed, [data-theme="dark"] .pill.bad { background: rgba(255,51,85,.18); color: #FF9DB0; }
[data-theme="dark"] .pill.warn { background: rgba(245,165,36,.18); color: #FFD08A; }
[data-theme="dark"] .pill.ok { background: rgba(23,178,106,.18); color: #7BE3B0; }
[data-theme="dark"] .banner { background: rgba(245,165,36,.14); color: #FFD08A; }
[data-theme="dark"] .banner.info { background: rgba(46,155,255,.14); color: #A9D3FF; }
[data-theme="dark"] .banner.bad { background: rgba(255,51,85,.14); color: #FF9DB0; }
[data-theme="dark"] .banner.ok { background: rgba(23,178,106,.14); color: #7BE3B0; }
[data-theme="dark"] .mc.s-final { background: var(--card-2); }
[data-theme="dark"] table.t tr.q td { background: rgba(223,255,79,.07); }
