:root {
  color-scheme: dark;
  --bg: #11101d; --surface:#1b1a2c; --raised:#232237; --line:#333149;
  --text:#f6f4ff; --muted:#b4aec9; --lime:#d7fa52; --ink:#191d08;
  --purple:#b4a0ff; --amber:#ffc678;
  font-family: Inter, Roboto, system-ui, sans-serif;
}
* { box-sizing:border-box }
body { margin:0; background:var(--bg); color:var(--text) }
button,input,select { font:inherit }
button { cursor:pointer; -webkit-tap-highlight-color:transparent }
input,select,button { touch-action:manipulation }
:focus-visible { outline:2px solid var(--purple); outline-offset:3px }
h1:focus { outline:none }
[hidden] { display:none !important }
h1,h2,p { margin:0 }
svg { flex:none; vertical-align:middle }
.shell { max-width:680px; margin:auto; min-height:100dvh }
.top { height:72px; padding:0 20px; display:flex; justify-content:space-between; align-items:center }
.brand { display:flex; text-align:left; align-items:center; gap:10px; background:none; border:0; padding:0; color:var(--text); font-weight:950; font-size:19px; line-height:.94; letter-spacing:-.05em; font-style:italic }
.sound { display:grid; place-items:center; height:44px; width:44px; border-radius:15px; background:var(--surface); border:1px solid var(--line); color:var(--muted) }
main { padding:4px 17px 110px }
nav { position:fixed; z-index:3; inset:auto 0 0; max-width:680px; margin:auto; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; padding:8px 12px max(10px,env(safe-area-inset-bottom)); background:#141322; border-top:1px solid var(--line) }
nav button { border:0; border-radius:15px; background:none; color:var(--muted); display:grid; place-items:center; gap:4px; padding:7px 3px; font-size:11px; min-height:53px; font-weight:740 }
nav [aria-current] { color:var(--lime); background:#303528 }
.hero { border-radius:25px; min-height:258px; overflow:hidden; isolation:isolate; position:relative; border:1px solid #554283;
  background:linear-gradient(90deg,#160d2fec 4%,#1d103a38 80%),url(hero.webp) 62% center / cover, radial-gradient(at 90% 0,#7750cf,#18132d 70%) }
.hero-inner { padding:27px 20px 24px; position:relative }
.hero-label { display:flex; align-items:center; gap:8px; font-size:10px; letter-spacing:.17em; font-weight:850; color:#eee8ff }
.hero-label i { width:8px; height:8px; border-radius:50%; background:var(--lime); box-shadow:0 0 12px var(--lime) }
.hero h1 { margin:14px 0 11px; font-family: 'Barlow Condensed', Impact, 'Roboto Condensed', system-ui, sans-serif; font-size:clamp(48px,13vw,78px); line-height:.88; letter-spacing:-.028em; font-weight:900; font-style:italic }
.hero h1 em { color:var(--lime) }
.hero p { font-size:13px; max-width:205px; color:#f2ecff; line-height:1.45 }
.section-label { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:23px 1px 11px }
.section-label h2,.history h2 { font-size:17px; letter-spacing:-.025em }
.card { background:var(--surface); border:1px solid var(--line); border-radius:20px }
.event-card,.start-card,.form-card,.empty { padding:17px }
.start-card { display:grid; grid-template-columns:44px minmax(0,1fr); gap:13px; align-items:center }
.start-card h2,.event-card h2 { font-size:21px; overflow-wrap:anywhere }
.start-card p { color:var(--muted); font-size:13px; margin-top:4px }
.start-card .primary { grid-column:1/-1 }
.start-icon { display:grid; place-items:center; border-radius:12px; height:44px; color:var(--purple); background:#302a47 }
.primary,.secondary { display:flex; justify-content:space-between; align-items:center; gap:10px; border:0; border-radius:14px; padding:0 15px; min-height:50px; width:100%; text-align:left; font-weight:850; color:var(--ink); background:var(--lime); font-size:14px }
.primary:active,.secondary:active,.quick button:active { transform:scale(.985) }
.secondary { border:1px solid var(--purple); color:var(--text); background:var(--raised) }
.text-button { border:0; background:none; color:var(--purple); padding:0 5px; min-height:44px; font-weight:740; font-size:13px; text-align:left }
.event-top { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:10px }
.tag,.mode,.match-state { background:#343a28; color:var(--lime); padding:5px 8px; border-radius:8px; font-weight:820; font-size:10px }
.mode { color:var(--purple); background:#33294c }
.event-meta { display:flex; flex-wrap:wrap; gap:8px 14px; color:var(--muted); font-size:12px; margin-top:6px; overflow-wrap:anywhere }
.event-meta svg { width:15px; height:15px }
.event-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); margin:14px 0; border-block:1px solid var(--line); padding:10px 0 }
.event-stats div { display:grid; gap:2px; text-align:center }
.event-stats div + div { border-left:1px solid var(--line) }
.event-stats strong { font-size:21px; line-height:1.1 }
.event-stats span,.muted { font-size:12px; color:var(--muted) }
.history { display:grid; gap:9px; margin-top:22px }
.history-row { display:flex; width:100%; align-items:center; justify-content:space-between; gap:10px; text-align:left; padding:13px; color:var(--text); overflow-wrap:anywhere }
.history-row small { display:block; color:var(--muted); margin-top:3px }
.heading { margin:7px 2px 17px }
.heading h1 { font-size:clamp(27px,7vw,35px); line-height:1.1; letter-spacing:-.055em; overflow-wrap:anywhere }
.heading p { color:var(--muted); font-size:14px; margin-top:6px; line-height:1.5; overflow-wrap:anywhere }
.form-card { display:grid; gap:15px }
label { display:grid; gap:6px; color:var(--muted); font-size:13px; font-weight:700; min-width:0 }
input,select { background:#141322; color:var(--text); border:1px solid var(--line); border-radius:11px; width:100%; min-width:0; min-height:46px; font-size:16px; padding:9px 10px }
input::placeholder { color:#a49bb7 }
.fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px }
.helper,.note,.empty-inline { color:var(--muted); font-size:13px; line-height:1.5 }
.empty-inline { border:1px dashed var(--line); border-radius:16px; text-align:center; padding:16px }
.empty>svg { height:32px; width:32px; color:var(--purple); margin-bottom:8px }
.player-form { display:grid; grid-template-columns:minmax(0,1fr) 48px; align-items:end; padding:12px; gap:8px }
.add { display:grid; place-items:center; height:46px; border-radius:11px; background:var(--lime); border:0; color:var(--ink) }
.roster,.matches { display:grid; gap:10px }
.person { padding:12px }
.person-top { display:flex; align-items:center; gap:10px; min-height:41px; overflow-wrap:anywhere }
.avatar { height:34px; width:34px; flex:0 0 34px; display:grid; place-items:center; border-radius:10px; color:#24134a; font-size:11px; font-weight:900; background:#c8b7ff }
.hue-1 { color:#343c10; background:#d7fa70 }
.hue-2 { color:#452015; background:#ffb898 }
.hue-3 { color:#193341; background:#9bdcf1 }
.remove { margin-left:auto; border:0; border-radius:11px; background:#2b263e; color:var(--muted); min-height:44px; min-width:44px; font-size:22px }
.presence { margin-top:8px; display:grid; grid-template-columns:repeat(auto-fit,minmax(115px,1fr)); gap:8px }
.presence select { font-size:14px }
.flow-action { margin-top:14px }
.progress { padding:12px; display:grid; gap:8px }
.progress div { display:flex; flex-wrap:wrap; gap:4px 12px; justify-content:space-between; font-size:12px }
.progress span { color:var(--muted) }
progress { width:100%; height:8px; color:var(--lime); accent-color:var(--lime); border:0; border-radius:7px; overflow:hidden; background:var(--raised) }
progress::-webkit-progress-bar { background:var(--raised) }
progress::-webkit-progress-value { background:var(--lime) }
.rounds { display:flex; gap:7px; overflow-x:auto; margin:13px 0 10px; padding:3px 2px 5px; scrollbar-width:thin }
.rounds button { white-space:nowrap; color:var(--muted); padding:0 12px; min-height:44px; border:1px solid var(--line); border-radius:11px; background:var(--surface); font-size:13px; font-weight:770 }
.rounds [aria-pressed=true] { background:#453871; border-color:#8d75d9; color:#fff }
.match { padding:12px; overflow:hidden }
.match header { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:6px; font-size:13px; font-weight:800 }
.match header svg { height:18px; width:18px; color:var(--purple); margin-right:5px }
.match-state { color:var(--muted); background:#2b2940 }
.match-state.recorded { color:var(--lime); background:#343a28 }
.match-state.held { color:var(--amber); background:#40312d }
.matchup { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); gap:6px; align-items:center; text-align:center }
.matchup { margin:14px 0 9px }
.matchup small { display:block; color:var(--purple); font-size:10px; letter-spacing:.1em; margin-bottom:4px }
.matchup strong { font-size:14px; line-height:1.35; overflow-wrap:anywhere }
.matchup>span { color:var(--muted); font-size:11px; font-weight:850 }
.quick { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:5px; margin-top:8px }
.quick button { min-height:44px; padding:0 1px; border:1px solid var(--line); border-radius:10px; background:var(--raised); color:var(--text); font-size:12px; font-weight:820 }
.feedback { color:var(--muted); font-size:12px; margin-top:8px; line-height:1.4; min-height:17px }
.match .note { margin-top:10px }
.matches+.note { padding:9px 3px 0 }
.champion { position:relative; text-align:center; padding:22px 14px; overflow:hidden; border-radius:24px; border:1px solid #aa8cff; background:radial-gradient(ellipse at top, #6946a9, #2b1c49 75%); box-shadow:0 12px 35px #08061275 }
.trophy { position:relative; display:grid; place-items:center; width:66px; height:66px; margin:0 auto 10px; color:var(--ink); background:var(--lime); transform:rotate(-7deg); border-radius:22px; box-shadow:0 0 36px #d7fa5260 }
.trophy svg { width:36px; height:36px; stroke-width:1.7 }
.champion p { font-size:10px; font-weight:850; letter-spacing:.17em; color:#e1d4ff }
.champion h2 { overflow-wrap:anywhere; margin:5px 0 12px; font-size:clamp(27px,7vw,42px); line-height:1.03; letter-spacing:-.045em }
.champion h2 span { color:var(--lime) }
.listen { min-height:44px; border:1px solid #a68ddc; border-radius:12px; background:#261a44; color:var(--text); padding:0 12px; font-weight:750; font-size:13px }
.listen svg { width:17px; height:17px; margin-right:3px }
.board { overflow:hidden }
.board-head,.board-row { display:grid; grid-template-columns:21px minmax(0,1fr) 36px 57px; gap:6px; padding:10px; align-items:center; text-align:center; font-size:12px }
.board-head { color:var(--muted); background:#222139; font-weight:780 }
.board-head>span:nth-child(2) { text-align:left }
.board-row { border-top:1px solid var(--line); min-height:56px }
.board-row>div { display:flex; gap:7px; align-items:center; min-width:0; text-align:left; overflow-wrap:anywhere }
.board-row small { display:block; font-size:10px; color:var(--muted); margin-top:2px }
.board-row.first { background:#2a2e23 }
.board-row.first>span:first-child,.board-row.first>strong:last-child { color:var(--lime); font-weight:900 }
.rules { margin-top:10px; padding:13px; color:var(--muted); font-size:13px }
.rules summary { font-weight:780; cursor:pointer }
.rules p { margin-top:8px; line-height:1.5 }
.toast { position:fixed; z-index:4; left:50%; bottom:80px; transform:translateX(-50%); width:max-content; max-width:calc(100% - 26px); padding:12px 14px; border:1px solid var(--line); background:#322850; border-radius:13px; box-shadow:0 8px 24px #0006; font-size:13px }
@media (min-width:590px) { .roster,.matches { grid-template-columns:repeat(2,minmax(0,1fr)) } }
@media (prefers-reduced-motion:no-preference) {
 .trophy { animation:arrive .45s ease-out }
 @keyframes arrive { from { opacity:.4; transform:scale(.72) rotate(-15deg) } to { opacity:1; transform:scale(1) rotate(-7deg) } }
}

@font-face {font-family:"Barlow Condensed"; src:url(arena-headline.ttf) format("truetype"); font-style:italic; font-weight:800 900; font-display:swap}

.milestones { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin-top:8px }
.milestones>div { display:grid; gap:3px; align-content:start; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:8px; font-size:12px }
.milestones small { color:var(--muted); font-size:11px; line-height:1.35 }
.milestones .achieved { color:var(--lime); border-color:#728748; background:#282e24 }
.matchup>span { min-width:41px; color:var(--lime); font-variant-numeric:tabular-nums; font-size:clamp(15px,4vw,20px) }
.score-toggle { display:flex; align-items:center; justify-content:space-between; width:100%; min-height:46px; padding:0 11px; border:0; border-radius:11px; background:var(--lime); color:var(--ink); font-size:14px; font-weight:850; scroll-margin-top:12px }
.score-toggle svg { width:18px; height:18px }
.score-toggle.scored,.score-toggle[aria-expanded=true] { background:var(--raised); color:var(--purple); border:1px solid var(--line) }
.picker { margin-top:8px }
.picker p { color:var(--muted); font-size:12px }
.quick { grid-template-columns:repeat(auto-fit,minmax(45px,1fr)) }
.quick button { min-height:46px; font-size:14px; font-variant-numeric:tabular-nums }
.quick button[aria-pressed=true] { color:var(--lime); border-color:#8d9a50; background:#343a28 }
.pair-panel { display:grid; gap:8px; padding:12px; overflow-wrap:anywhere }
.pair-row { display:flex; justify-content:space-between; align-items:center; gap:6px; min-height:29px }
.pair-row + .pair-row { border-top:1px solid var(--line); padding-top:6px }
#pair-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px }
#pair-form button { grid-column:1/-1 }
.club-logo { width:103px; height:57px; object-fit:contain; object-position:center; border-radius:8px }
.arena-label { color:var(--muted); font-size:10px; letter-spacing:.18em; font-style:normal }
.set-tabs,.set-summary { display:flex; flex-wrap:wrap; gap:5px; margin:8px 0 }
.set-tabs button,.deuce button { min-height:44px; min-width:44px; padding:0 8px; border:1px solid var(--line); border-radius:9px; background:var(--raised); color:var(--text); font-size:13px; font-weight:800 }
.set-tabs [aria-pressed=true] { border-color:var(--purple); color:var(--purple) }
.set-summary span { background:var(--raised); color:var(--muted); border-radius:9px; padding:5px 8px; font-size:12px }
.set-summary strong { color:var(--lime) }
.deuce { display:flex; gap:7px; align-items:center; flex-wrap:wrap; margin-top:7px; color:var(--muted); font-size:12px }
.deuce button:disabled { opacity:.45 }
.replay-score svg { width:16px; height:16px; margin-right:4px }

.ranking-controls,.flyer-actions { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); align-items:end; gap:8px; margin-bottom:10px }
.ranking-controls .mode { align-self:center; width:max-content }
.rank-scroll { overflow:auto }
.rank-table { border-collapse:separate; border-spacing:0; width:max-content; min-width:100%; font-size:12px; text-align:right }
.rank-table th,.rank-table td { border-bottom:1px solid var(--line); padding:11px 9px; min-width:45px; white-space:nowrap }
.rank-table thead th { color:var(--muted); background:var(--raised); vertical-align:bottom }
.rank-table tr>*:nth-child(2) { position:sticky; left:0; text-align:left; min-width:103px; max-width:154px; white-space:normal; overflow-wrap:anywhere; background:var(--surface) }
.rank-table thead tr>*:nth-child(2) { background:var(--raised) }
.rank-table tr.first>* { background:#292e24 }
.rank-table small { display:block; color:var(--muted); margin-top:4px; font-size:10px }
.rank-table .primary-stat { color:var(--lime); font-weight:850 }
.podium-place { display:grid; grid-template-columns:64px minmax(0,1fr); gap:6px; text-align:left; align-items:center; margin:5px 0; background:#16133288; padding:7px 10px; border-radius:8px }
.podium-place strong { color:#eed7a7; font-size:12px }
.podium-place span { overflow-wrap:anywhere }
.champion .listen { margin-top:8px }
.court-editor form,.flyer-controls { display:grid; gap:10px; padding:11px 0 0 }
.flyer-controls { padding:12px }
.flyer-controls input[type=range] { accent-color:var(--lime); padding:0 8px }
.flyer-controls input[type=file] { font-size:13px; overflow:hidden }
.flyer-frame { margin:12px auto; border:1px solid var(--line); background:#080e19; border-radius:13px; padding:6px; text-align:center }
#flyer-canvas { width:auto; max-width:100%; max-height:78vh; height:auto; object-fit:contain; display:block; margin:auto }
.court-editor input { font-size:14px }

.top-actions { display:flex; gap:8px }
button:disabled { opacity:.55; cursor:default }
.portrait-controls { display:grid; gap:10px; margin-top:10px }
:root[data-theme="light"] {
  color-scheme:light;
  --bg:#f2f5fa; --surface:#fff; --raised:#edf0f8; --line:#ccd5e5;
  --text:#192439; --muted:#495a73; --lime:#c7ed46; --ink:#1b2609;
  --purple:#5536a0; --amber:#714600;
}
:root[data-theme="light"] nav { background:#faffff }
:root[data-theme="light"] nav [aria-current] { background:#e6f2ca; color:#35500b }
:root[data-theme="light"] input,:root[data-theme="light"] select { background:#f8faff }
:root[data-theme="light"] input::placeholder { color:#61708b }
:root[data-theme="light"] .start-icon,:root[data-theme="light"] .mode { background:#eee6fb }
:root[data-theme="light"] .tag,:root[data-theme="light"] .match-state.recorded { color:#35500b; background:#e8f3d0 }
:root[data-theme="light"] .match-state,:root[data-theme="light"] .remove { color:#435474; background:#e8edf7 }
:root[data-theme="light"] .match-state.held { color:#83541c; background:#fdf0d9 }
:root[data-theme="light"] .rounds [aria-pressed="true"] { color:#402e82; background:#e8ddfe; border-color:#8873c6 }
:root[data-theme="light"] .matchup>span,:root[data-theme="light"] .set-summary strong,:root[data-theme="light"] .primary-stat { color:#365415 }
:root[data-theme="light"] .milestones .achieved,:root[data-theme="light"] .quick button[aria-pressed="true"] { color:#38580d; background:#edf6df }
:root[data-theme="light"] .rank-table tr.first>* { background:#e8f2d8 }
:root[data-theme="light"] .toast { background:#f5ebff }
:root[data-theme="light"] .hero,:root[data-theme="light"] .champion { color:#f9f5ff }
:root[data-theme="light"] .champion .listen { color:#f9f5ff }
:root[data-theme="light"] .club-logo { background:#071222; padding:4px 6px; object-fit:contain }

.install-hint { margin-top:18px }
.install-hint summary { min-height:32px; display:list-item; padding-top:5px }
#offline-status { font-weight:700 }
