:root {
  --bg: #f3f1f6; --surface: #ffffff; --fg: #1c1a22; --muted: #6d6878; --line: #cfcad8;
  --old: #7a2e3a; --new: #1f6b5c; --win: #b8860b; --win-bg: #fbf3dc; --err: #b3261e;
  --display: "Russo One", "Arial Black", system-ui, sans-serif;
  --body: "PT Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #15131a; --surface: #211e28; --fg: #ece9f2; --muted: #9d97aa; --line: #3a3544;
  --old: #e07d8c; --new: #5fc8b1; --win: #f0c14b; --win-bg: #3a3120; --err: #f2b8b5; color-scheme: dark } }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; }
.wrap { max-width: 1240px; margin: 0 auto; padding-block: 32px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(28px, 5vw, 44px); margin: 0; line-height: 1.1; text-wrap: balance; }
h1 .o, .o { color: var(--old); } h1 .n, .n { color: var(--new); }
h3 { font-family: var(--display); font-weight: 400; font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 8px 0 28px; }
.notice { background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 24px; }
.scroll { overflow-x: auto; padding-bottom: 8px; }
.bracket { display: grid; grid-template-columns: repeat(2, minmax(230px, 1fr)) minmax(180px, .8fr); gap: 0 28px; min-width: 700px; max-width: 900px; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 32px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.group h2, .stage { font-family: var(--display); font-weight: 400; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.stage { font-size: 15px; color: var(--fg); margin: 0 0 14px; }
.group table { width: 100%; border-collapse: collapse; }
.group th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 400; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.group td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.group tr:last-child td { border-bottom: 0; }
.group .rk { width: 24px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group .c { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.group td.c:nth-child(4) { font-weight: 700; }
.group .tbl { overflow-x: auto; }
.group h4 { font-size: 13px; color: var(--muted); font-weight: 700; margin: 16px 0 6px; }
.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.games .tour { font-size: 12px; color: var(--muted); margin-top: 6px; }
.games .gm { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.games .side { min-width: 0; font-size: 14px; opacity: .75; }
.games .side.w { opacity: 1; }
.games .side.w .a, .games .side.w .b { text-decoration: underline; text-decoration-color: var(--win); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.games .side.r { text-align: right; }
.games .side .a, .games .side .b { font-weight: 700; } .games .side .a { color: var(--old); } .games .side .b { color: var(--new); }
.games .side .x { color: var(--muted); margin: 0 3px; }
.score { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.score.ro { min-width: 54px; justify-content: center; }
.score.none { color: var(--muted); font-weight: 400; }
.score input { width: 44px; text-align: center; padding: 4px 2px; }
.team .g { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.match .edit { border-top: 1px solid var(--line); padding: 8px 12px; display: flex; justify-content: center; }
.group .nm .a, .group .nm .b { font-weight: 700; } .group .nm .a { color: var(--old); } .group .nm .b { color: var(--new); }
.group .nm .x { color: var(--muted); margin: 0 4px; }
.group tr.through td { background: var(--win-bg); }
.group tr.through .rk { color: var(--win); font-weight: 700; }
.group .msg { margin: 10px 0 0; }
input.pts { width: 80px; text-align: right; padding: 5px 8px; }
.round { display: flex; flex-direction: column; }
.round h2 { font-family: var(--display); font-weight: 400; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.slots { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 16px; }
.match { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.match .no { position: absolute; right: 8px; top: 4px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.team { padding: 9px 12px; min-height: 52px; display: flex; align-items: center; width: 100%; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; }
.team + .team { border-top: 1px solid var(--line); }
button.team { cursor: pointer; }
button.team:hover { background: color-mix(in srgb, var(--win) 10%, transparent); }
.team .a { font-weight: 700; color: var(--old); } .team .b { font-weight: 700; color: var(--new); }
.team .x { color: var(--muted); margin: 0 4px; }
.team.tbd { color: var(--muted); font-style: italic; }
.team.won { background: var(--win-bg); box-shadow: inset 3px 0 0 var(--win); }
.team.lost { opacity: .45; }
.cup { border: 2px solid var(--win); border-radius: 10px; background: var(--win-bg); padding: 18px 16px; text-align: center; }
.cup .lbl { font-family: var(--display); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--win); }
.cup .who { margin-top: 8px; font-size: 18px; line-height: 1.35; }
.cup .who.empty { color: var(--muted); font-size: 15px; }
.champ .slots { justify-content: center; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; color: var(--muted); font-size: 14px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 24px; }
.rows { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px 10px; align-items: center; max-width: 640px; }
.rows .hd { font-size: 13px; font-weight: 700; }
.rows .num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rows .fixed { padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px; font-weight: 700; }
input { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--win); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.btn { font: inherit; font-weight: 700; border-radius: 6px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.warn { border-color: var(--err); color: var(--err); }
.msg { font-size: 14px; color: var(--muted); }
.msg.err { color: var(--err); }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 640px; }
.lists label { display: flex; flex-direction: column; gap: 6px; }
.lists .hd { font-weight: 700; }
textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; resize: vertical; line-height: 1.5; }
textarea:focus-visible { outline: 2px solid var(--win); outline-offset: 2px; }
.pairlist { margin-top: 16px; }
.pairlist ol { margin: 0; padding-left: 22px; columns: 2 220px; }
.standings { margin-top: 28px; max-width: 560px; }
.places { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.places li { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.places .pos { font-family: var(--display); font-size: 20px; width: 28px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.places .pl1 { border-color: var(--win); background: var(--win-bg); }
.places .pl1 .pos { color: var(--win); }
.places .who { flex: 1; min-width: 0; }
select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
select:focus-visible { outline: 2px solid var(--win); outline-offset: 2px; }
.keyrow { display: flex; flex-wrap: wrap; gap: 10px; max-width: 520px; }
.keyrow input { flex: 1 1 220px; }
