:root {
  --cream: #f6efe2;
  --ivory: #fffaf0;
  --green: #123b26;
  --green-2: #1d5b3a;
  --red: #b82523;
  --gold: #d39a27;
  --dark: #08110c;
  --ink: #17221b;
  --muted: #637168;
  --line: rgba(18, 59, 38, 0.14);
  --shadow: 0 24px 65px rgba(8, 17, 12, 0.1);
  --shell: min(1180px, calc(100% - 48px));
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.shell { width: var(--shell); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 15px;
  border-radius: 9px;
  background: var(--ivory);
  color: var(--green);
  font-weight: 900;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.live-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--dark);
  color: white;
}
.brand { display: inline-flex; width: max-content; }
.brand img { display:block; width:56px; height:56px; padding:4px; object-fit:contain; background:var(--cream); border-radius:10px; }
.header-live-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  letter-spacing: 0.16em;
}
.pulse-dot, .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #55df8d;
  box-shadow: 0 0 0 5px rgba(85, 223, 141, 0.13);
}
.pulse-dot { background:var(--gold); box-shadow:none; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.live-quick-links { display: flex; align-items: center; gap: 14px; }
.live-quick-links a { font-size: 11px; font-weight: 800; color: rgba(255, 255, 255, 0.62); white-space: nowrap; }
.live-quick-links a:hover { color: white; }
.lang-switch {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}
.lang-btn {
  min-width: 36px;
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}
.lang-btn.active { background: var(--gold); color: var(--dark); }

.live-hero {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 30%, rgba(211, 154, 39, 0.14), transparent 34%),
    linear-gradient(120deg, #0a1810 0%, #123b26 63%, #0d2d1d 100%);
  color: white;
}
.hero-serpent {
  position: absolute;
  width: min(530px, 48vw);
  right: max(-40px, calc((100vw - 1300px) / 2));
  top: 50%;
  transform: translateY(-47%) rotate(-5deg);
  opacity: 0.1;
  filter: grayscale(1) brightness(2.2);
  pointer-events: none;
}
.hero-pattern {
  position: absolute;
  inset: auto 0 0;
  height: 13px;
  background: repeating-linear-gradient(90deg, var(--red) 0 22px, var(--gold) 22px 44px, var(--cream) 44px 66px, var(--green-2) 66px 88px);
}
.hero-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  align-items: center;
  gap: clamp(36px, 7vw, 96px);
  min-height: 347px;
  padding-block: 44px 52px;
}
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  margin-bottom: 19px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.connection-pill.is-loading .status-dot { background: var(--gold); animation: pulse 1.3s ease-in-out infinite; }
.connection-pill.is-stale .status-dot,
.connection-pill.is-error .status-dot { background: #ff725f; box-shadow: 0 0 0 5px rgba(255, 114, 95, 0.14); }
.eyebrow, .section-kicker, .now-kicker {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.live-hero h1 {
  margin: 0;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(43px, 5.7vw, 76px);
  line-height: 0.9;
  letter-spacing: -0.045em;
}
.live-hero h1 span { color: var(--gold); }
.live-hero h1 .hero-title-main { color: white; }
.hero-tagline { margin: 19px 0 0; color: white; font-size: 16px; font-weight: 800; }
.hero-intro { max-width: 585px; margin: 8px 0 0; color: rgba(255, 255, 255, 0.66); font-size: 13px; line-height: 1.65; }
.now-card {
  padding: 25px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  background: rgba(8, 17, 12, 0.62);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}
.now-row { display: grid; grid-template-columns: 63px 1fr; gap: 14px; padding: 14px 0; }
.now-row + .now-row { border-top: 1px solid rgba(255, 255, 255, 0.1); }
.now-row strong { font-size: 17px; line-height: 1.3; }
.now-row small { display: block; margin-top: 4px; color: rgba(255, 255, 255, 0.5); font-size: 10px; font-weight: 700; }
.next-row { color: rgba(255, 255, 255, 0.7); font-size: 13px; }
.now-label { color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: 0.14em; }
.schedule-note { margin: 10px 0 0; color: rgba(255, 255, 255, 0.46); font-size: 10px; line-height: 1.5; }

.results-shell { padding-block: 42px 70px; }
.selectors-block { margin-bottom: 25px; }
.selector-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.selector-heading h2 { margin: 0; font-family: "Archivo Black", sans-serif; color: var(--green); font-size: clamp(26px, 4vw, 39px); text-transform: uppercase; }
.section-kicker { color: var(--red); }
.updated-label { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 600; text-align: right; }
.event-scroller {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 2px 11px;
  scrollbar-color: rgba(18, 59, 38, 0.25) transparent;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.event-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 14px 8px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.72);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.event-chip:hover { border-color: rgba(18, 59, 38, 0.35); transform: translateY(-1px); }
.event-chip[aria-selected="true"] { border-color: var(--green); background: var(--green); color: white; box-shadow: 0 7px 20px rgba(18, 59, 38, 0.18); }
.chip-glyph {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  padding-inline: 4px;
  border-radius: 8px;
  background: rgba(18, 59, 38, 0.08);
  font-size: 8px;
  font-weight: 900;
}
.event-chip[aria-selected="true"] .chip-glyph { background: rgba(255, 255, 255, 0.13); color: var(--gold); }
.chip-state {
  width: 6px;
  height: 6px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--gold);
}
.chip-state.is-live { background: #53dc88; box-shadow: 0 0 0 3px rgba(83, 220, 136, 0.14); }
.chip-state.is-completed { background: rgba(99, 113, 104, 0.6); }
.scheduled-badge { padding: 3px 5px; border-radius: 5px; background: var(--gold); color: var(--dark); font-size: 7px; font-weight: 900; letter-spacing: 0.05em; }
.chip-skeleton { flex: 0 0 155px; height: 46px; border-radius: 14px; background: linear-gradient(90deg, rgba(18, 59, 38, 0.05), rgba(255, 255, 255, 0.7), rgba(18, 59, 38, 0.05)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.round-row { display: flex; align-items: center; gap: 16px; min-height: 40px; margin-top: 7px; }
.round-title { flex: 0 0 auto; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: 0.14em; }
.round-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.round-tab { min-height: 36px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.round-tab:hover { color: var(--green); border-color: var(--green); }
.round-tab[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: var(--dark); }
.round-tab .round-state-dot { display: inline-block; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: currentColor; opacity: 0.45; vertical-align: 2px; }
.round-tab.is-live .round-state-dot { background: var(--green); opacity: 1; }

.leaderboard-card { overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: var(--ivory); box-shadow: var(--shadow); }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 25px 28px; border-bottom: 1px solid var(--line); }
.title-line { display: flex; align-items: center; gap: 15px; }
.event-glyph { display: grid; place-items: center; width: 49px; height: 49px; border-radius: 14px; background: var(--green); color: var(--gold); font-size: 10px; font-weight: 900; }
.leaderboard-heading h2 { margin: 0; color: var(--green); font-family: "Archivo Black", sans-serif; font-size: clamp(19px, 3vw, 27px); text-transform: uppercase; }
.leaderboard-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.round-facts { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; font-weight: 700; }
.actual-state { padding: 7px 10px; border-radius: 999px; background: rgba(18, 59, 38, 0.08); color: var(--green); font-size: 9px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.actual-state.is-live { background: rgba(32, 159, 86, 0.11); color: #13733a; }
.actual-state.is-completed { background: rgba(99, 113, 104, 0.1); color: var(--muted); }
.actual-state.is-loading { background: rgba(211, 154, 39, 0.13); color: #8e6310; }
.notice { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 10px 28px; border-bottom: 1px solid rgba(18, 59, 38, 0.08); background: rgba(211, 154, 39, 0.08); color: #705317; font-size: 11px; font-weight: 700; }
.notice[hidden] { display: none; }
.notice.is-error { background: rgba(184, 37, 35, 0.08); color: var(--red); }
.notice.is-stale { background: rgba(211, 154, 39, 0.12); color: #78540d; }
.notice-spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.notice:not(.is-loading) .notice-spinner { display: none; }
.retry-button { margin-left: auto; padding: 6px 10px; border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit; font-size: 9px; font-weight: 900; cursor: pointer; }
.retry-button:hover { background: rgba(255, 255, 255, 0.45); }
.table-head, .result-main {
  display: grid;
  grid-template-columns: 74px minmax(260px, 1fr) 138px 138px 42px;
  align-items: center;
}
.table-head { min-height: 43px; padding-inline: 28px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: 0.13em; }
.table-head span:nth-child(n+3) { text-align: right; }
.leaderboard { margin: 0; padding: 0; list-style: none; }
.table-skeleton { padding: 12px 28px; }
.table-skeleton span { display: block; height: 54px; margin: 8px 0; border-radius: 12px; background: linear-gradient(90deg, rgba(18, 59, 38, 0.04), rgba(255, 255, 255, 0.8), rgba(18, 59, 38, 0.04)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.table-skeleton[hidden] { display: none; }
.result-row { border-bottom: 1px solid rgba(18, 59, 38, 0.09); transition: background 0.35s ease; }
.result-row:last-child { border-bottom: 0; }
.result-row.changed { background: rgba(211, 154, 39, 0.13); }
.result-row.podium-1 { box-shadow: inset 4px 0 var(--gold); }
.result-row.podium-2 { box-shadow: inset 4px 0 #9ba7a0; }
.result-row.podium-3 { box-shadow: inset 4px 0 #af744c; }
.result-main { min-height: 77px; padding-inline: 28px; }
.rank-cell { display: flex; align-items: center; gap: 6px; }
.rank-value { color: var(--green); font-family: "Archivo Black", sans-serif; font-size: 20px; }
.rank-change { min-width: 15px; font-size: 9px; font-weight: 900; }
.rank-change.up { color: #168047; }
.rank-change.down { color: var(--red); }
.person-cell { min-width: 0; }
.person-name { display: block; overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.person-meta { display: flex; align-items: center; gap: 5px; min-height: 17px; margin-top: 5px; color: var(--muted); font-size: 10px; }
.wca-id::before { content: "·"; margin-right: 5px; color: rgba(99, 113, 104, 0.5); }
.wca-id:empty { display: none; }
.score-cell { position: relative; text-align: right; }
.score-cell > strong { color: var(--green); font-size: 15px; font-variant-numeric: tabular-nums; }
.score-cell > strong.is-dnf, .score-cell > strong.is-dns { color: var(--red); }
.score-cell > strong.is-pending { color: var(--muted); }
.record-tag { display: inline-grid; place-items: center; min-width: 24px; min-height: 17px; margin-left: 4px; padding-inline: 4px; border-radius: 5px; background: var(--red); color: white; font-size: 8px; font-weight: 900; vertical-align: 2px; }
.record-tag:empty { display: none; }
.mobile-label { display: none; }
.attempt-toggle { display: grid; place-items: center; width: 32px; height: 32px; margin-left: auto; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--green); cursor: pointer; transition: background 0.2s, transform 0.2s; }
.attempt-toggle:hover { background: rgba(18, 59, 38, 0.06); }
.attempt-toggle[aria-expanded="true"] { transform: rotate(180deg); }
.attempts-panel { padding: 5px 28px 22px 102px; }
.attempts-title { margin: 0 0 9px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: 0.12em; }
.attempts-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; padding: 0; list-style: none; }
.attempt-item { min-width: 72px; padding: 7px 9px; border-radius: 9px; background: rgba(18, 59, 38, 0.06); color: var(--green); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; }
.attempt-item small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 8px; }
.attempt-item.is-dnf, .attempt-item.is-dns { color: var(--red); }
.empty-state { padding: 64px 24px 70px; text-align: center; }
.empty-cube { display: block; margin-bottom: 13px; color: var(--gold); font-size: 44px; }
.empty-state h3 { margin: 0; color: var(--green); font-family: "Archivo Black", sans-serif; font-size: 21px; text-transform: uppercase; }
.empty-state p { max-width: 510px; margin: 10px auto 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.source-note { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 20px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 250, 240, 0.48); }
.source-note strong { color: var(--red); font-size: 9px; letter-spacing: 0.13em; }
.source-note p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.source-note a { flex: 0 0 auto; color: var(--green); font-size: 11px; font-weight: 900; }
.source-note a:hover { color: var(--red); }

.live-footer { padding: 23px 0; background: var(--dark); color: rgba(255, 255, 255, 0.48); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; }
.live-footer .shell { display: flex; justify-content: space-between; gap: 24px; }

button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.8); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1024px) {
  :root { --shell: min(100% - 40px, 940px); }
  .live-header { padding-inline: 20px; }
  .header-live-mark { justify-self: center; }
  .hero-layout { grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.8fr); gap: 36px; }
  .table-head, .result-main { grid-template-columns: 64px minmax(220px, 1fr) 120px 120px 38px; }
}

@media (max-width: 820px) {
  :root { --shell: calc(100% - 32px); }
  .live-header { grid-template-columns: 1fr auto; min-height: 68px; }
  .live-quick-links { gap: 10px; }
  .live-quick-links a { font-size: 10px; }
  .header-live-mark { display: none; }
  .brand img { width:52px; height:52px; }
  .hero-layout { grid-template-columns: 1fr; gap: 27px; padding-block: 40px 50px; }
  .live-hero { min-height: 0; }
  .hero-serpent { width: 510px; right: -170px; opacity: 0.07; }
  .now-card { max-width: 620px; }
  .table-head, .result-main { grid-template-columns: 56px minmax(180px, 1fr) 106px 106px 36px; }
  .table-head, .result-main { padding-inline: 20px; }
  .leaderboard-heading, .notice { padding-inline: 20px; }
  .attempts-panel { padding-left: 76px; }
}

@media (max-width: 768px) {
  .live-quick-links a:first-child { display: none; }
  .header-actions { gap: 10px; }
  .selector-heading { align-items: start; }
  .updated-label { max-width: 180px; }
  .leaderboard-heading { align-items: flex-start; }
  .round-facts { flex-direction: column; align-items: flex-end; gap: 6px; }
  .table-head { display: none; }
  .result-main {
    grid-template-columns: 42px minmax(0, 1fr) 90px 32px;
    grid-template-areas:
      "rank person person toggle"
      "rank best aggregate toggle";
    gap: 7px 12px;
    min-height: 98px;
    padding-block: 14px;
  }
  .rank-cell { grid-area: rank; align-self: stretch; align-items: flex-start; padding-top: 3px; }
  .person-cell { grid-area: person; }
  .best-cell { grid-area: best; text-align: left; }
  .aggregate-cell { grid-area: aggregate; text-align: left; }
  .attempt-toggle { grid-area: toggle; }
  .mobile-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
  .attempts-panel { padding: 0 20px 19px 74px; }
}

@media (max-width: 560px) {
  :root { --shell: calc(100% - 24px); }
  .live-header { padding-inline: 12px; }
  .header-actions { gap: 8px; }
  .live-hero h1 { font-size: clamp(40px, 13vw, 58px); }
  .hero-intro { font-size: 13px; }
  .now-card { padding: 19px; border-radius: 18px; }
  .now-row { grid-template-columns: 54px 1fr; }
  .results-shell { padding-block: 32px 48px; }
  .selector-heading { display: block; }
  .updated-label { max-width: none; margin-top: 9px; text-align: left; }
  .event-scroller { margin-inline: -12px; padding-inline: 12px; }
  .event-chip { min-height: 43px; padding-right: 11px; }
  .event-chip .chip-name { display: none; }
  .chip-glyph { min-width: 38px; }
  .round-row { align-items: flex-start; }
  .round-title { padding-top: 12px; }
  .round-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .round-tab { flex: 0 0 auto; }
  .leaderboard-card { border-radius: 20px; }
  .leaderboard-heading { display: block; padding: 20px 16px 17px; }
  .event-glyph { width: 43px; height: 43px; }
  .round-facts { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 15px; }
  .notice { padding-inline: 16px; }
  .table-skeleton { padding-inline: 16px; }
  .result-main { grid-template-columns: 36px minmax(0, 1fr) 77px 30px; gap: 6px 8px; padding-inline: 16px; }
  .rank-value { font-size: 17px; }
  .person-name { font-size: 13px; }
  .country-name { display: none; }
  .score-cell > strong { font-size: 13px; }
  .attempts-panel { padding-inline: 60px 16px; }
  .source-note { display: block; padding: 17px; }
  .source-note a { display: inline-block; margin-top: 13px; }
  .live-footer .shell { display: block; line-height: 1.8; }
  .live-footer .shell span { display: block; }
}

@media (max-width: 400px) {
  .brand img { width:48px; height:48px; }
  .lang-btn { min-width: 32px; }
  .live-quick-links { gap: 8px; }
  .connection-pill { margin-bottom: 15px; }
  .title-line { gap: 10px; }
  .leaderboard-heading h2 { font-size: 17px; }
  .result-main { grid-template-columns: 33px minmax(0, 1fr) 68px 28px; }
  .wca-id { display: none; }
  .record-tag { display: block; width: max-content; margin: 3px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
