:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20211f;
  background: #f4f4ef;
  --ink: #20211f;
  --muted: #6a6d66;
  --line: #dadbd4;
  --surface: #ffffff;
  --soft: #efefe9;
  --success: #e8f5e9;
  --warn: #fff4cf;
  --danger: #9f2d2d;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); padding: 12px max(16px, calc((100vw - 1180px)/2)); display:flex; gap:24px; align-items:center; justify-content:space-between; }
.brand { display:flex; gap:10px; align-items:center; white-space:nowrap; }
.brand-mark { display:grid; place-items:center; width:38px; height:38px; border-radius:10px; background:var(--ink); color:white; font-weight:900; }
.brand small { display:block; color:var(--muted); font-size:.75rem; }
.crumbs { display:flex; gap:6px; align-items:center; overflow:auto; font-size:.9rem; }
.crumbs button { border:0; background:none; padding:5px 7px; border-radius:7px; color:var(--muted); white-space:nowrap; }
.crumbs button:hover { background:var(--soft); color:var(--ink); }
.shell { width:min(1180px,100%); margin:auto; padding:28px 16px 72px; }
.hidden { display:none !important; }
.notice { margin-bottom:16px; padding:12px 14px; border-radius:10px; background:var(--warn); border:1px solid #e5d28a; }
.notice.error { color:var(--danger); background:#fff0f0; border-color:#e6bcbc; }
.page-head { display:flex; gap:16px; align-items:flex-start; justify-content:space-between; margin-bottom:20px; }
.page-head h1 { margin:0 0 5px; font-size:clamp(2rem,5vw,3rem); }
.page-head p { margin:0; color:var(--muted); }
.actions { display:flex; flex-wrap:wrap; gap:8px; }
button, .button { border:0; border-radius:10px; padding:11px 14px; background:var(--ink); color:white; font-weight:750; }
button.secondary { background:var(--soft); color:var(--ink); border:1px solid var(--line); }
button.danger { background:#a73434; }
button:disabled { opacity:.45; cursor:not-allowed; }
.grid { display:grid; gap:14px; }
.grid.two { grid-template-columns:repeat(2,minmax(0,1fr)); }
.grid.three { grid-template-columns:repeat(3,minmax(0,1fr)); }
.card { background:var(--surface); border:1px solid var(--line); border-radius:15px; padding:16px; box-shadow:0 1px 2px rgba(0,0,0,.03); }
.card.clickable { cursor:pointer; transition:transform .1s,border-color .1s; }
.card.clickable:hover { transform:translateY(-1px); border-color:#a8aaa2; }
.card h2,.card h3 { margin:0 0 7px; }
.meta { color:var(--muted); font-size:.88rem; }
.empty { color:var(--muted); text-align:center; padding:30px 16px; }
.status { display:inline-flex; align-items:center; padding:5px 9px; border-radius:999px; font-size:.78rem; font-weight:800; background:var(--soft); }
.status.InProgress { background:#e7f0ff; }
.status.Completed,.status.Finalized,.status.Active,.status.Ready { background:var(--success); }
.summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin:16px 0 20px; }
.metric { background:var(--surface); border:1px solid var(--line); border-radius:13px; padding:14px; }
.metric strong { display:block; font-size:1.6rem; }
.metric span { color:var(--muted); font-size:.82rem; }
.section-head { display:flex; gap:12px; justify-content:space-between; align-items:center; margin:26px 0 10px; }
.section-head h2 { margin:0; }
form.stack { display:grid; gap:11px; }
label { font-weight:700; font-size:.88rem; }
input,select { width:100%; padding:11px; border:1px solid #bfc1b9; border-radius:9px; background:white; }
.field { display:grid; gap:5px; }
.inline { display:flex; gap:8px; align-items:end; }
.inline > * { flex:1; }
.roster-row,.event-row { display:flex; gap:12px; align-items:center; justify-content:space-between; padding:11px 0; border-bottom:1px solid #eee; }
.roster-row:last-child,.event-row:last-child { border-bottom:0; }
.checkbox-row { display:flex; gap:10px; align-items:center; }
.checkbox-row input { width:auto; }
.match-list { display:grid; gap:12px; }
.match-head { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.players { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.player { border:1px solid #e1e1dc; border-radius:12px; padding:14px; }
.player h3 { margin:0 0 2px; }
.score-total { font-size:2.5rem; font-weight:900; margin:10px 0 4px; }
.controls { display:flex; flex-wrap:wrap; gap:7px; margin-top:10px; }
.controls button { min-width:52px; min-height:48px; }
.declaration { margin-top:10px; }
.tie { margin-top:14px; padding:13px; border-radius:11px; background:var(--warn); }
.progress { height:8px; border-radius:999px; background:var(--soft); overflow:hidden; margin-top:8px; }
.progress > span { display:block; height:100%; background:var(--ink); }
dialog { width:min(520px,calc(100% - 24px)); border:1px solid var(--line); border-radius:16px; padding:0; }
dialog::backdrop { background:rgba(0,0,0,.35); }
.dialog-inner { padding:20px; }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
@media (max-width:760px) {
  .topbar { align-items:flex-start; flex-direction:column; gap:6px; }
  .page-head { flex-direction:column; }
  .grid.two,.grid.three,.players { grid-template-columns:1fr; }
  .summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .inline { flex-direction:column; align-items:stretch; }
  .actions { width:100%; }
  .actions button { flex:1; min-height:48px; }
}

button.small { padding:7px 10px; min-height:34px; font-size:.82rem; }
.match-actions { margin-top:12px; align-items:center; justify-content:space-between; }
@media (min-width:761px) and (max-width:1100px) {
  .shell { padding-left:20px; padding-right:20px; }
  button, .button { min-height:48px; }
  .card { padding:18px; }
}

.event-results { margin:20px 0; }
.event-results .section-head { margin:0 0 12px; }
.results-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.results-table { width:100%; min-width:980px; border-collapse:collapse; font-size:.88rem; }
.results-table th,.results-table td { padding:10px 11px; text-align:right; border-bottom:1px solid #eee; white-space:nowrap; }
.results-table th:first-child,.results-table td:first-child { text-align:left; position:sticky; left:0; background:var(--surface); }
.results-table th { color:var(--muted); font-size:.78rem; }
.results-table tbody tr:last-child td { border-bottom:0; }

.season-standings { margin:20px 0; }
.season-standings .section-head { margin:0 0 12px; }
.season-standings-table { min-width:1500px; }
.season-standings-table th:first-child,
.season-standings-table td:first-child { min-width:190px; }

.preparation-participant{display:flex;flex-wrap:wrap;gap:12px 20px;min-width:0;border:1px solid var(--line,#dadbd4);border-radius:12px;padding:14px;margin:12px 0}.preparation-participant legend{font-weight:700;overflow-wrap:anywhere}.preparation-participant label{display:flex;align-items:center;gap:6px;min-height:44px;overflow-wrap:anywhere}.preparation-participant input{width:20px;height:20px;flex-shrink:0}.preparation-participant .meta{flex-basis:100%;margin:0}.week-numbering button{margin:4px}@media(max-width:600px){.preparation-participant label{flex-basis:100%}}

.participant-presence{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-basis:100%}.participant-presence .meta{flex-basis:auto}.participant-presence button{margin-left:auto}@media(max-width:600px){.participant-presence{align-items:flex-start;flex-direction:column}.participant-presence button{margin-left:0}}

.makeup-requirement{border-top:1px solid var(--line,#dadbd4);padding:16px 0;overflow-wrap:anywhere}.makeup-requirement h3{margin:0 0 8px}.makeup-history{margin-top:12px}.makeup-history summary{cursor:pointer;font-weight:600}.makeup-history p{font-size:.9rem;line-height:1.5}

.tournament-bracket{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr));gap:16px;margin-top:18px}.tournament-section{min-width:0}.tournament-position{border:1px solid var(--line);border-radius:10px;padding:12px;margin:12px 0;overflow-wrap:anywhere}.tournament-position p{margin:8px 0}#tournamentSeeding details{margin:14px 0}#tournamentSeeding summary{cursor:pointer;font-weight:700}

/* Tournament structure follows server-owned bracket rounds and routing. */
.tournament-bracket{display:block;min-width:0;max-width:100%;scroll-margin-top:80px}
.tournament-section{margin-top:24px;max-width:100%;min-width:0}
.tournament-rounds{display:flex;gap:18px;overflow-x:auto;max-width:100%;padding:4px 4px 16px;align-items:stretch}
.tournament-round{flex:0 0 280px;display:flex;flex-direction:column;justify-content:space-around;gap:14px}
.tournament-round h4{margin:0 auto 0 0}.tournament-position{background:var(--surface,#fff);margin:0;scroll-margin:80px 20px}
.tournament-position h5{font-size:1rem;margin:0 0 8px}.tournament-position:target{outline:3px solid #466b9e}
.bracket-winner{color:#235b2e}.bracket-routes{border-top:1px solid var(--line);display:grid;margin-top:10px;padding-top:8px}
.bracket-routes a,.bracket-participant a{display:inline-flex;align-items:center;min-height:44px}
.tournament-position[data-status="In Progress"]{border:2px solid #466b9e}
.tournament-position[data-status="Completed"]{border-left:5px solid #397747}
.tournament-position[data-status="Administrative win"]{border-left:5px solid #946b22}
.tournament-position .button{display:inline-flex;align-items:center;min-height:44px;padding:10px;text-decoration:none}
.tournament-placements{width:100%;border-collapse:collapse}.tournament-placements th,.tournament-placements td{text-align:left;padding:10px;border-bottom:1px solid var(--line);overflow-wrap:anywhere}

.account-bar { display:flex; gap:1rem; flex-wrap:wrap; align-items:center; padding:.75rem 1rem; background:#eef2f6; color:#172535; }
.account-bar span { margin-right:auto; }
#identityDialog { max-width:30rem; width:calc(100% - 2rem); }
#identityDialog label { display:block; margin:1rem 0; }
#identityDialog input { display:block; width:100%; box-sizing:border-box; }

.statistics-export{display:inline-block;margin-bottom:8px}.statistics-sort,.statistics-participant,.statistics-week{background:transparent;color:inherit;border:0;padding:8px;text-align:left;min-height:44px;cursor:pointer}.statistics-sort{font-weight:700}.statistics-sort:hover,.statistics-participant:hover,.statistics-week:hover{text-decoration:underline}.statistics-detail{margin-top:20px}.statistics-detail h4{margin-bottom:8px}.statistics-games{min-width:650px}
