:root {
  color-scheme: light;
  --navy: #071a35;
  --ink: #0b2245;
  --muted: #4c6280;
  --line: #d5e2f1;
  --ice: #edf5ff;
  --yellow: #ffeb00;
  --blue: #086fd3;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f3f7fc;
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #0875d9; outline-offset: 4px; }
.arena :focus-visible { outline-color: var(--yellow); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.masthead {
  border-top: 8px solid #031021;
  background: linear-gradient(105deg, #e5effe, #fbfdff 55%, #ebf3fc);
  position: relative;
}
.masthead::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: clamp(15px, 7vw, 116px);
  background: linear-gradient(125deg, transparent 20%, #078cf0 21% 31%, var(--yellow) 32% 36%, #041831 37%);
  pointer-events: none;
}
.header-inner {
  max-width: 1240px;
  min-height: 82px;
  margin: auto;
  padding: 6px clamp(20px, 7vw, 105px) 6px clamp(14px, 4vw, 55px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand { display: flex; align-items: center; flex: none; gap: 14px; }
.brand img { display: block; width: clamp(40px, 6vw, 61px); height: clamp(40px, 6vw, 61px); object-fit: contain; }
.brand span {
  padding-left: 14px;
  border-left: 1px solid #91a3bc;
  color: #051731;
  font-size: clamp(26px, 4vw, 54px);
  font-style: italic;
  font-weight: 950;
  line-height: .99;
  letter-spacing: -.066em;
  text-transform: uppercase;
  white-space: nowrap;
}
.page-nav { display: flex; align-items: center; gap: 6px; }
.page-nav a {
  display: grid;
  place-items: center;
  min-height: 45px;
  padding: 6px clamp(11px, 2.6vw, 35px);
  isolation: isolate;
  position: relative;
  font-size: clamp(14px, 2.1vw, 25px);
  font-weight: 850;
  font-style: italic;
}
.page-nav a::before { content: ""; position: absolute; inset: 0; transform: skewX(-17deg); z-index: -1; }
.page-nav a[aria-current="page"]::before { background: var(--yellow); }
.page-nav a:hover:not([aria-current])::before { background: #d9ebfc; }

.arena {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 26px clamp(14px, 3vw, 38px) 16px;
  min-height: 240px;
  background: #041832;
  background-image: linear-gradient(180deg, #020d20a6, #051b3000 42%, #0045ac18 80%, #01132a9c), url("assets/night-court.jpg");
  background-size: cover;
  background-position: center 53%;
  color: white;
}
.league-nav {
  display: flex;
  justify-content: stretch;
  width: min(100%, 740px);
  margin: 0 auto;
  transform: skewX(-16deg);
  border-radius: 9px;
  background: #f5faff;
  box-shadow: 0 4px 16px #0005;
}
.league-nav a {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  place-items: center;
  min-height: 53px;
  color: var(--ink);
  font-size: clamp(13px, 2vw, 21px);
  font-weight: 830;
  font-style: italic;
  padding: 7px 10px;
  text-align: center;
}
.league-nav a:first-child { flex-grow: 1.65; border-radius: 9px 0 0 9px; }
.league-nav a:last-child { border-radius: 0 9px 9px 0; }
.league-nav a + a { border-left: 1px solid #a9bbd1; }
.league-nav a[aria-current] { background: var(--yellow); }
.league-nav a:hover:not([aria-current]) { background: #d9eaff; }
.league-nav span { display: block; transform: skewX(16deg); overflow-wrap: anywhere; }
.podium-stage {
  max-width: 1100px;
  margin: auto;
  min-height: clamp(310px, 39vw, 515px);
  padding: clamp(34px, 7vw, 107px) 12px 21px;
  display: grid;
  align-items: end;
}
.podium {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: .97fr 1.11fr .97fr;
  grid-template-areas: "second first third";
  align-items: end;
  gap: clamp(7px, 1.5vw, 19px);
}
.podium-place {
  min-width: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  min-height: clamp(155px, 22vw, 320px);
  padding: 10px 9px 17px;
  text-align: center;
  color: #072247;
}
.podium-place::before {
  position: absolute;
  z-index: -1;
  content: "";
  inset: 0;
  transform: skewX(-11deg);
  border-radius: 9px 7px 5px 5px;
  border: 1px solid #e8f6ff;
  background: linear-gradient(145deg, #0478d6 0 4%, #ffec12 4% 8%, #fff 8%, #d9eafa 88%, #c8dcf2 100%);
  box-shadow: inset 0 1px 5px #fff, inset 0 -10px #abc5e1, 0 2px 4px #fff, 0 13px 19px #07132aa8, 0 6px 27px #28a9ff9f;
}
.podium-place[data-position="1"] { grid-area: first; z-index: 1; min-height: clamp(190px, 28vw, 398px); }
.podium-place[data-position="1"]::before {
  background: linear-gradient(150deg, #fff84c, #ffec00 63%, #f9d800);
  border-color: #fff69e;
  box-shadow: inset 0 2px 7px #fff8a1, inset 0 -12px #bfa100, 0 2px 4px #fff196, 0 13px 20px #07132aa8, 0 7px 22px #ffe6327f;
}
.podium-place[data-position="2"] { grid-area: second; }
.podium-place[data-position="3"] { grid-area: third; min-height: clamp(140px, 19vw, 280px); }
.podium-rank {
  font-size: clamp(58px, 12vw, 169px);
  font-weight: 950;
  font-style: italic;
  letter-spacing: -.105em;
  padding-right: .1em;
  line-height: .83;
}
.podium-place[data-position="1"] .podium-rank { font-size: clamp(77px, 16vw, 222px); }
.podium-pair {
  max-width: 100%;
  font-size: clamp(13px, 2.8vw, 38px);
  font-weight: 900;
  font-style: italic;
  line-height: 1.08;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.podium-points {
  padding: 5px 8px 0;
  border-top: 2px solid #e5d000;
  font-size: clamp(13px, 2.1vw, 27px);
  font-weight: 840;
  font-style: italic;
  font-variant-numeric: tabular-nums;
}
.podium-place[data-position="1"] .podium-points { border-color: var(--ink); }
.arena-message { margin: auto; max-width: 36ch; padding: 12px 18px; background: #04172ae5; font-weight: 700; text-align: center; }
body[data-view="matches"] .arena {
  min-height: 0;
  padding-bottom: 13px;
  background-position: center 32%;
}

.content { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 42px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.overline { color: #1c568c; margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.section-title h1, .section-title h2 {
  margin: 0;
  font-size: clamp(27px, 4.4vw, 46px);
  font-weight: 920;
  font-style: italic;
  letter-spacing: -.055em;
  line-height: 1.05;
}
.section-link { font-size: 14px; font-weight: 750; white-space: nowrap; }
.section-link:hover { text-decoration: underline; }
.table-shell, .match-group { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.standings-table, .set-table { width: 100%; border-collapse: collapse; }
.standings-table th, .standings-table td { padding: 11px 14px; text-align: center; }
.standings-table thead th { background: #dfedfc; color: #284567; font-size: 12px; text-transform: uppercase; }
.standings-table thead th:nth-child(2), .standings-table tbody th { text-align: left; }
.standings-table td, .standings-table tbody th { border-top: 1px solid #e0ebf6; }
.standings-table td:first-child { width: 8%; font-weight: 830; font-variant-numeric: tabular-nums; }
.standings-table td:last-child { font-weight: 850; }
.standings-table .leader { background: #fff8bd; }
.match-count { color: var(--muted); margin: 0; font-size: 13px; font-weight: 650; }
.match-group + .match-group { margin-top: 14px; }
.round-heading {
  margin: 0;
  padding: 8px 16px;
  background: #deedfc;
  color: #234d7b;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.match + .match { border-top: 1px solid var(--line); }
.match summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 16px;
  min-height: 75px;
  padding: 10px 18px;
  list-style: none;
  cursor: pointer;
}
.match summary::-webkit-details-marker { display: none; }
.match summary:hover, .match[open] > summary { background: #f4f9ff; }
.match summary:focus-visible { outline-offset: -4px; }
.match-pairs { display: grid; gap: 4px; padding-left: 11px; border-left: 3px solid #e5cf00; font-weight: 780; overflow-wrap: anywhere; }
.match-pairs span:last-child { color: var(--muted); }
.total {
  min-width: 64px;
  padding: 3px 9px;
  background: var(--yellow);
  color: var(--ink);
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  font-style: italic;
  font-variant-numeric: tabular-nums;
}
.pending .total { background: #e9eff6; color: var(--muted); }
.chevron { width: 8px; height: 8px; border: solid #426387; border-width: 0 2px 2px 0; transform: rotate(45deg); justify-self: center; }
.match[open] .chevron { transform: rotate(225deg); }
.set-detail { padding: 0 17px 12px; background: #f4f9ff; }
.set-table { table-layout: fixed; border: 1px solid #c9dff5; background: white; }
.set-table th, .set-table td { border: 1px solid #d7e7f7; padding: 7px 5px; text-align: center; }
.set-table thead { background: #dceffd; color: #284f75; font-size: 12px; }
.set-table th:first-child { text-align: left; padding-left: 10px; overflow-wrap: anywhere; }
.set-table thead th:not(:first-child) { width: clamp(38px, 13vw, 125px); }
.set-table tbody th { font-size: 13px; }
.set-table td { font-size: 17px; font-weight: 730; }
.set-table .set-winner { background: #fff2a0; font-weight: 900; }
.empty-state { background: white; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); padding: 15px 18px; }
.pending-note { margin: 0; color: var(--muted); font-size: 14px; }
.site-footer { display: flex; justify-content: space-between; gap: 10px; width: min(1120px, calc(100% - 40px)); margin: auto; padding: 15px 0 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 640px) {
  .header-inner { min-height: 60px; gap: 9px; padding: 6px 18px 6px 10px; }
  .brand { gap: 6px; }
  .brand span { padding-left: 6px; }
  .masthead::after { width: 16px; }
  .page-nav { gap: 1px; }
  .page-nav a { padding-inline: 8px; }
  .arena { padding: 15px 13px 12px; background-position: center; }
  .league-nav a { min-height: 46px; padding: 5px 7px; }
  .podium-stage { min-height: 272px; padding: 35px 6px 13px; }
  .podium { gap: 6px; }
  .podium-place { padding: 8px 4px 13px; gap: 6px; }
  .podium-place::before { transform: skewX(-6deg); }
  .content, .site-footer { width: calc(100% - 24px); }
  .content { padding: 22px 0 30px; }
  .standings-table th, .standings-table td { padding: 9px 5px; }
  .match summary { gap: 8px; padding: 8px 10px; }
  .set-detail { padding-inline: 8px; }
  .total { min-width: 50px; font-size: 20px; }
}
@media (max-width: 350px) {
  .brand span { font-size: 22px; }
  .brand img { width: 33px; height: 33px; }
  .header-inner { gap: 4px; }
  .page-nav a { padding-inline: 5px; }
  .section-title { align-items: start; flex-wrap: wrap; }
}

/* Competition pages */
:root { color-scheme: dark; background: #06162b; color: #edf5ff; --line: #264365; --muted: #b3c9e1; }
.masthead { color-scheme: light; color: #0b2245; }
.header-inner { max-width: 1430px; gap: 12px; }
.brand span { font-size: clamp(21px, 3.55vw, 48px); }
.brand img { border-radius: 8px; object-fit: contain; }
.page-nav a { padding-inline: clamp(9px, 1.45vw, 24px); font-size: clamp(12px, 1.65vw, 21px); }
.league-nav a:first-child, .league-nav a:nth-child(2) { flex-grow: 1.2; }
body:not([data-view="standings"]) .arena { min-height: 0; padding-block: 14px; background-position: center 28%; }
.podium-pairs { display: grid; gap: 6px; justify-items: center; max-width: 100%; }
.podium-place[data-shared] .podium-pair { font-size: clamp(11px, 2.35vw, 31px); }
.site-footer .source-label { color: var(--muted); }
.site-footer .source-label[data-state="offline"] { color: #ffe769; }
.overline { color: #85c5ff; }
.section-title { align-items: center; }
.section-title .minor-title { font-size: clamp(25px, 3.4vw, 39px); }
.section-link, .text-link { color: #b7dcff; font-weight: 720; }
.text-link:hover, .site-footer a:hover { text-decoration: underline; }
.group-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.group-tabs a, .action-link, .action-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 6px;
  background: #102743; color: #edf5ff; font: inherit; font-weight: 730; text-align: center;
}
.group-tabs [aria-current], .action-button.primary { border-color: var(--yellow); background: var(--yellow); color: #071a35; }
.action-button { cursor: pointer; }
.action-button:disabled { cursor: wait; opacity: .6; }
.action-button.danger { color: #ffbfbc; border-color: #844a50; }
.group-tabs a:hover:not([aria-current]), .action-link:hover, .action-button:hover:not(.primary) { background: #1a3b60; }
.table-shell { overflow: auto; }
.table-shell, .match-group, .panel-box, .group-card { border: 1px solid var(--line); background: #0d2340; border-radius: 8px; }
.standings-table { min-width: 580px; }
.standings-table thead th, .round-heading { background: #153354; color: #d0e6fc; }
.standings-table td, .standings-table tbody th { border-color: #223f5e; }
.standings-table .leader { background: #183958; }
.standings-table .leader td:first-child { color: var(--yellow); }
.standings-table td:last-child { font-weight: 650; }
.standings-table td.points { color: var(--yellow); font-weight: 900; }
.standings-table .provisional { color: #b3c9e1; font-size: 12px; }
.match-group { overflow: hidden; }
.round-heading { display: flex; justify-content: space-between; gap: 10px; border-left: 4px solid var(--round-colour, #41ded6); }
.match summary:hover, .match[open] > summary, .set-detail { background: #122d4e; }
.match-pairs { border-color: var(--round-colour, #e5cf00); }
.pending .total { background: #254663; color: #d2e7fb; }
.chevron { border-color: #93b5d9; }
.set-table { border-color: #33587c; background: #0d2340; color: #eef6ff; }
.set-table th, .set-table td { border-color: #33587c; }
.set-table thead { background: #1a4166; color: #e0f0ff; }
.set-table .set-winner { color: #102543; background: #fff087; }
.match-meta, .empty-state, .hint { color: #b3c9e1; }
.match-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 8px 0; font-size: 13px; }
.empty-state { background: #0d2340; }
.overview-progress { margin-top: 26px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { padding: 12px 14px; border-left: 3px solid #328ce3; background: #102844; }
.metric b { display: block; color: var(--yellow); font-size: clamp(21px, 3.5vw, 38px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.group-grid, .team-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 28px; }
.group-card, .panel-box { padding: 15px 16px; }
.group-card h3, .group-card p { margin: 0 0 8px; }
.group-card h3 { font-size: 17px; }
.group-card p { font-size: 14px; color: var(--muted); }
.group-card p strong { color: #fff; }
.inline-links, .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-links a { margin-right: 8px; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.field { display: grid; min-width: 0; align-content: start; gap: 5px; color: #d4e6f8; font-size: 13px; font-weight: 720; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%; min-height: 43px; padding: 8px 9px; border: 1px solid #3b628b; border-radius: 5px;
  background: #071a30; color: #f0f7ff; font: inherit; font-size: 16px;
}
.field input[type="checkbox"] { accent-color: var(--yellow); }
.field textarea { min-height: 75px; resize: vertical; }
.team-grid .team-card { display: grid; align-content: start; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #102844; }
.team-grid .team-card span { color: var(--muted); font-size: 13px; }
.team-grid .team-card:hover { background: #1a3b60; }
.stat-section { margin-top: 24px; }
.stat-section h2, .panel-box h2 { margin-top: 0; }
.draw-figure { margin: 0; }
.draw-figure img { display: block; width: 100%; max-height: 860px; object-fit: contain; border: 1px solid var(--line); }
.draw-figure figcaption { padding-top: 8px; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; gap: 14px; }
.admin-form { display: grid; gap: 12px; }
.admin-form .field.checkbox { display: flex; align-items: center; }
.admin-form .field.checkbox input { width: 17px; height: 17px; }
.admin-form fieldset { border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; padding: 8px; min-width: 0; }
.set-entry { display: grid; grid-template-columns: 46px repeat(2, minmax(0, 1fr)); gap: 8px; align-items: center; }
.set-entry > b { font-size: 13px; }
.result-editor { max-width: 680px; display: grid; gap: 14px; }
.result-editor h2 { margin-bottom: 0; }
.result-pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.result-editor select { text-overflow: ellipsis; }
.score-columns strong { text-align: center; font-size: 13px; overflow-wrap: anywhere; }
.score-input { width: 100%; min-height: 47px; border: 1px solid #4c7096; border-radius: 6px; background: #071a30; color: #f0f7ff; font: inherit; font-size: 22px; text-align: center; }
.score-hint, .result-feedback, .local-edit-note { margin: 0; }
.result-feedback { color: #ffbcb8; }
.local-edit-note { margin-bottom: 10px; }
.match-options { margin: 0; }
.match-options > .admin-form { margin-top: 10px; }
.results-back { display: inline-block; margin-top: 12px; }
.admin-more { margin-top: 16px; }
.admin-note { padding: 9px 0; min-height: 34px; color: #a3daff; }
.admin-note.error { color: #ffbcb8; }
.admin-auth { max-width: 500px; }
.admin-details { margin: 10px 0; padding: 10px; background: #102844; }
.admin-details summary { cursor: pointer; }
.admin-details pre { overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }

@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; }
  .page-nav { width: 100%; }
  .page-nav a { flex: 1 1 0; min-height: 40px; }
  .group-grid, .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 470px) {
  .arena { padding-inline: 12px; }
  .league-nav a { font-size: 12px; }
  .group-tabs { gap: 5px; }
  .group-tabs a { padding-inline: 7px; font-size: 13px; }
  .group-grid, .filters { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .section-title { flex-wrap: wrap; }
  .brand span { font-size: 27px; }
  .match-meta { font-size: 12px; }
}
