:root {
  color-scheme: dark;
  --bg: #07080c;
  --surface: #12141a;
  --ink: #f4f6f8;
  --muted: #a7b0bb;
  --line: #2a3140;
  --heading: #f4f6f8;
  --accent: #65c900;
  --gold: #a16207;
  --silver: #475569;
  --bronze: #9a3412;
  --glow-blue: rgba(22, 158, 224, 0.38);
  --glow-pink: rgba(255, 45, 141, 0.32);
}

body.league-padel {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --ink: #102033;
  --muted: #4d6478;
  --line: #d5e3ef;
  --heading: #0e8ecb;
  --accent: #4ea300;
  --glow-blue: rgba(22, 158, 224, 0.22);
  --glow-pink: rgba(101, 201, 0, 0.16);
}

body.league-single {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #16161b;
  --ink: #f5f5f7;
  --muted: #b7b1ba;
  --line: #2e2e36;
  --heading: #ff4d9a;
  --accent: #ff2d8d;
  --glow-blue: rgba(255, 45, 141, 0.08);
  --glow-pink: rgba(255, 45, 141, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 70% 45% at 12% -10%, var(--glow-blue), transparent 60%),
    radial-gradient(ellipse 55% 40% at 100% 0%, var(--glow-pink), transparent 55%),
    var(--bg);
  color: var(--ink);
}

.page {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.4rem 1rem 3.5rem;
}

body:not(.league-padel):not(.league-single) .page {
  min-height: 100vh;
  display: flex;
  align-items: center;
}

h1, h2, h3, p { margin: 0; }

.chooser { width: 100%; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #d5dde6;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kicker i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #65c900;
  box-shadow: 0 0 0 0.35rem rgba(101, 201, 0, 0.2);
}

.chooser h1 {
  margin-top: 0.7rem;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.chooser .lead {
  max-width: 28rem;
  margin-top: 0.9rem;
  color: #c5ced8;
  font-size: 1.15rem;
  line-height: 1.45;
}

.home-row { margin-top: 1.1rem; }

.home-row a {
  color: #d5dde6;
  text-decoration: none;
}

.home-row a:hover { color: #fff; }

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.choices button {
  font: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 1.4rem;
  padding: 1.15rem 1.25rem;
  min-height: 11rem;
  display: grid;
  grid-template-columns: 6.75rem 1fr;
  grid-template-rows: 1fr auto;
  column-gap: 0.85rem;
  align-items: center;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.choices button img {
  grid-row: 1 / span 2;
  width: 6.75rem;
  height: 6.75rem;
  object-fit: contain;
}

.choices button:hover { transform: translateY(-2px); }

.choices button strong {
  display: block;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  font-weight: 800;
}

.choice-copy span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.98rem;
  font-weight: 550;
  line-height: 1.35;
}

.choices button em {
  justify-self: end;
  font-style: normal;
  font-weight: 750;
  font-size: 0.92rem;
}

.choices button[data-league="padel"] {
  background: linear-gradient(165deg, #ffffff, #e7f6ff);
  color: #0e8ecb;
  box-shadow: 0 18px 40px rgba(14, 142, 203, 0.18);
}

.choices button[data-league="padel"] strong { color: #0e8ecb; }
.choices button[data-league="padel"] .choice-copy span { color: #3d7a12; }
.choices button[data-league="padel"] em { color: #0e8ecb; }

.choices button[data-league="single"] {
  background: linear-gradient(165deg, #1b1b22, #0b0b0d);
  color: #ff4d9a;
  border-color: rgba(255, 45, 141, 0.45);
  box-shadow: 0 18px 40px rgba(255, 45, 141, 0.16);
}

.choices button[data-league="single"] strong { color: #ff4d9a; }
.choices button[data-league="single"] .choice-copy span { color: #f5f5f7; }
.choices button[data-league="single"] em { color: #ff8abf; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 1rem;
}

.back, .retry {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  color: var(--heading);
  border: 1px solid color-mix(in srgb, var(--heading) 45%, transparent);
  background: transparent;
}

.updated {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.hero {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 1.3rem;
  padding: 1.15rem 1.2rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.hero.league-hero {
  border-top: 4px solid var(--heading);
}

.league-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.league-head > div { min-width: 0; }

.league-head img {
  width: 4.75rem;
  height: 4.75rem;
  object-fit: contain;
  flex: none;
}

.league-head .cycle-line,
.league-head p { margin-top: 0.45rem; }

.hero h1 {
  color: var(--heading);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero h2 {
  color: var(--heading);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hero p, .cycle-line { color: var(--muted); line-height: 1.45; }
.hero p { margin-top: 0.4rem; }
.cycle-line {
  margin-top: 0.85rem;
  color: var(--ink);
  font-weight: 750;
}

.banner {
  position: relative;
  margin: 0 0 0.4rem;
  aspect-ratio: 4 / 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  overflow: hidden;
}

.banner a {
  display: block;
  width: 100%;
  height: 100%;
}

.banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.ad-label {
  position: absolute;
  top: 6px;
  left: 6px;
  margin: 0;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  pointer-events: none;
}

.section { margin-top: 1.5rem; }

.tier {
  margin: 1rem 0 0.7rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tier span:last-child { font-size: 0.82rem; font-weight: 500; }

.tier.Gold { color: var(--gold); background: #fef3c7; }
.tier.Silver { color: var(--silver); background: #e2e8f0; }
.tier.Bronze { color: var(--bronze); background: #ffedd5; }
.tier.Numbered, .tier.Other {
  color: var(--heading);
  background: color-mix(in srgb, var(--heading) 12%, var(--surface));
}

.card, .empty, .status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.05rem;
  margin-bottom: 0.7rem;
}

.card summary, .cycle summary {
  cursor: pointer;
  padding: 0.95rem 2.4rem 0.95rem 1rem;
  font-weight: 550;
  list-style: none;
  position: relative;
}

.card summary::-webkit-details-marker,
.cycle summary::-webkit-details-marker { display: none; }

.card summary::after, .cycle summary::after {
  content: "";
  position: absolute;
  right: 1.05rem;
  top: 1.25rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}

details[open] > summary::after { transform: translateY(0.15rem) rotate(225deg); }

.summary-row, .cycle-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.hint { color: var(--muted); font-size: 0.82rem; font-weight: 650; white-space: nowrap; }

.pills { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.pill {
  background: color-mix(in srgb, var(--heading) 12%, var(--surface));
  color: var(--ink);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.panel { padding: 0.2rem 1rem 1rem; }
.panel h3 {
  margin: 0.7rem 0 0.55rem;
  color: var(--heading);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
  padding: 0.55rem 0.45rem;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th:nth-child(2), td:nth-child(2) { text-align: left; }
th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--heading) 6%, var(--surface));
}
tbody tr + tr td { border-top: 1px solid var(--line); }
tr.leader td { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
tr.leader td:nth-child(2) { font-weight: 800; color: var(--accent); }

.match { border-top: 1px solid var(--line); padding: 0.8rem 0 0.7rem; }
.match-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.3rem;
}
.scores {
  display: flex;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.set-score {
  flex: 0 0 2.5rem;
  width: 2.5rem;
  min-width: 2.5rem;
  max-width: 2.5rem;
  text-align: center;
}
.winner { font-weight: 800; color: var(--accent); }
.note { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.badge {
  display: inline-block;
  margin-top: 0.4rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 750;
  background: color-mix(in srgb, var(--muted) 16%, var(--surface));
  color: var(--muted);
}
.badge[data-status="confirmed"] {
  background: color-mix(in srgb, #16a34a 16%, var(--surface));
  color: #15803d;
}
.badge[data-status="result_pending_confirmation"] {
  background: color-mix(in srgb, #d97706 18%, var(--surface));
  color: #b45309;
}
.badge[data-status="disputed"] {
  background: color-mix(in srgb, #dc2626 16%, var(--surface));
  color: #b91c1c;
}
body.league-single .badge[data-status="confirmed"] { color: #86efac; }
body.league-single .badge[data-status="result_pending_confirmation"] { color: #fdba74; }
body.league-single .badge[data-status="disputed"] { color: #fca5a5; }

.rules { color: var(--muted); font-size: 0.88rem; line-height: 1.45; margin-top: 0.85rem; }
.empty, .loading, .status { padding: 1rem 1.05rem; font-weight: 650; }
.empty, .loading { color: var(--muted); }
.status { color: #f87171; }

@media (max-width: 720px) {
  .choices { grid-template-columns: 1fr; }
  .summary-row { align-items: flex-start; flex-direction: column; }
  .hint { white-space: normal; }
  .updated { text-align: left; }
}
