:root {
  color-scheme: light;
  --ink: #18201c;
  --muted: #66706a;
  --subtle: #8b948f;
  --line: #d8ded8;
  --surface: #f7f8f4;
  --panel: #ffffff;
  --accent: #0f7a5f;
  --accent-dark: #095844;
  --gold: #c69b35;
  --danger: #b85c3b;
  --draw: #8e7b62;
  --shadow: 0 18px 50px rgba(27, 44, 35, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(15, 122, 95, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 122, 95, 0.05) 1px, transparent 1px),
    var(--surface);
  background-size: 44px 44px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.workspace-header,
.section-heading,
.insight-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.topbar {
  min-height: 120px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2.2rem, 6vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.2vw, 2.2rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 18px;
  font-size: 1rem;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.summary-strip span,
.race-pill,
.code-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.summary-strip span {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-strip strong {
  color: var(--ink);
}

.insight-row {
  align-items: stretch;
  margin: 24px 0 34px;
}

.insight-row article {
  flex: 1;
  border-top: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.72);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.insight-row span,
.section-heading p,
.team-code,
.metric-label,
.match-meta,
.scoreline-prob,
.controls span {
  color: var(--muted);
  font-size: 0.82rem;
}

.insight-row strong {
  display: block;
  margin-top: 7px;
  font-size: 1.05rem;
}

.overview-section,
.outrights-section,
.review-section {
  margin-bottom: 34px;
}

.section-heading {
  align-items: end;
  margin-bottom: 18px;
}

.section-heading p {
  max-width: 420px;
  margin-bottom: 0;
  line-height: 1.45;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading.compact h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.group-card:hover,
.group-card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.group-card.tight {
  border-color: rgba(184, 92, 59, 0.65);
}

.group-card-header,
.team-line,
.match-heading,
.scoreline-row,
.table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group-label {
  font-size: 1.1rem;
  font-weight: 900;
}

.race-pill {
  padding: 5px 8px;
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 800;
}

.team-stack {
  display: grid;
  gap: 8px;
  margin: 16px 0 14px;
}

.team-line {
  justify-content: flex-start;
  min-width: 0;
}

.rank {
  width: 1.4rem;
  color: var(--subtle);
  font-weight: 800;
}

.flag {
  width: 1.6rem;
  text-align: center;
  font-size: 1.28rem;
  line-height: 1;
}

.team-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.group-card-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.metric-label {
  display: block;
}

.metric-value {
  font-weight: 850;
}

.workspace {
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.workspace-header {
  align-items: center;
  margin-bottom: 18px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.controls label {
  display: grid;
  gap: 6px;
}

.controls select {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
}

.standings-panel,
.matches-panel,
.champion-panel,
.scorers-panel,
.performance-panel,
.attempt-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 18px;
  box-shadow: var(--shadow);
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.outrights-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: start;
}

.champion-card {
  display: grid;
  gap: 14px;
}

.champion-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.champion-main strong,
.leaderboard-player strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.champion-main span,
.leaderboard-player span {
  color: var(--muted);
  font-size: 0.84rem;
}

.champion-prob {
  color: var(--accent-dark);
  font-size: 1.8rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
}

.performance-list,
.attempt-list {
  display: grid;
  gap: 10px;
}

.performance-row {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid rgba(216, 222, 216, 0.78);
  padding: 0 0 12px;
}

.performance-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.performance-row.active {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.performance-row > div:first-child {
  display: grid;
  gap: 3px;
}

.performance-row span,
.attempt-pickline,
.attempt-summary {
  color: var(--muted);
  font-size: 0.82rem;
}

.rating-badge,
.round-pill,
.change-pill {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 122, 95, 0.06);
  padding: 4px 8px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 850;
}

.performance-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.performance-metrics span {
  border-top: 1px solid rgba(216, 222, 216, 0.9);
  padding-top: 7px;
}

.performance-metrics strong,
.attempt-summary strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.attempt-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attempt-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 7px 10px;
}

.attempt-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px;
}

.attempt-row.changed {
  border-color: rgba(184, 92, 59, 0.58);
}

.attempt-row.changed .change-pill {
  border-color: rgba(184, 92, 59, 0.34);
  background: rgba(184, 92, 59, 0.08);
  color: #8d3f28;
}

.attempt-heading {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.attempt-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attempt-pickline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 4.4rem;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(216, 222, 216, 0.78);
  padding: 8px 0;
}

.leaderboard-row:last-child {
  border-bottom: 0;
}

.standings-table {
  display: grid;
  gap: 6px;
}

.table-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 4.8rem 4.8rem 4.8rem;
  min-height: 46px;
  border-bottom: 1px solid rgba(216, 222, 216, 0.78);
  padding: 6px 0;
}

.table-row.header {
  min-height: 28px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.table-row.qualifier .rank {
  color: var(--accent-dark);
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.matches-list {
  display: grid;
  gap: 12px;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.match-toggle {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.match-toggle:hover {
  background: rgba(15, 122, 95, 0.045);
}

.match-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.match-heading {
  justify-content: flex-start;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  width: 100%;
}

.match-score {
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 900;
}

.code-pill {
  padding: 4px 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.probability-block {
  display: grid;
  gap: 7px;
  min-width: 260px;
}

.probability-bar {
  display: grid;
  grid-template-columns: var(--home) var(--draw) var(--away);
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.probability-bar span:nth-child(1) {
  background: var(--accent);
}

.probability-bar span:nth-child(2) {
  background: var(--draw);
}

.probability-bar span:nth-child(3) {
  background: var(--gold);
}

.probability-labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.probability-labels span:last-child {
  text-align: right;
}

.match-details {
  display: none;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.match-card.open .match-details {
  display: grid;
  gap: 14px;
}

.scorelines {
  display: grid;
  gap: 8px;
}

.scoreline-row {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 3.5rem;
  gap: 10px;
}

.scoreline-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(216, 222, 216, 0.85);
}

.scoreline-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.explanation {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.error {
  border: 1px solid rgba(184, 92, 59, 0.45);
  border-radius: 8px;
  background: #fff8f3;
  padding: 16px;
  color: #7d321f;
}

@media (max-width: 1100px) {
  .group-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .outrights-grid {
    grid-template-columns: 1fr;
  }

  .review-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .workspace-header,
  .section-heading,
  .insight-row {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip {
    justify-content: flex-start;
  }

  .group-grid {
    grid-template-columns: 1fr;
  }

  .controls,
  .controls label,
  .controls select {
    width: 100%;
  }

  .table-row {
    grid-template-columns: 1.6rem minmax(0, 1fr) 3.4rem 3.4rem 3.4rem;
    font-size: 0.9rem;
  }

  .match-toggle {
    grid-template-columns: 1fr;
  }

  .match-heading {
    grid-template-columns: auto 1fr auto;
    gap: 5px 10px;
  }

  .match-heading .code-pill {
    grid-column: 1;
    grid-row: 1;
  }

  .match-heading .match-score {
    grid-column: 3;
    grid-row: 1;
  }

  .match-heading .team-name:nth-child(2) {
    grid-column: 1 / 4;
    grid-row: 2;
  }

  .match-heading .team-name:nth-child(4) {
    grid-column: 1 / 4;
    grid-row: 3;
  }

  .probability-block {
    min-width: 0;
  }

  .attempt-heading {
    grid-template-columns: auto auto 1fr;
  }

  .attempt-heading strong {
    grid-column: 1 / 4;
    white-space: normal;
  }

  .attempt-heading .change-pill {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .performance-metrics {
    grid-template-columns: 1fr;
  }
}
