:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --ink: #172026;
  --muted: #65727e;
  --line: #dce4ea;
  --line-strong: #bfccd6;
  --accent: #0f766e;
  --accent-2: #b42318;
  --accent-3: #6d5dfc;
  --shadow: 0 16px 42px rgba(18, 31, 43, 0.08);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #ecf2f5 0, #f4f7f9 340px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.noscript,
.load-error {
  margin: 24px auto;
  max-width: 960px;
  border: 1px solid #f3b7a8;
  background: #fff4f1;
  color: #8f2c1f;
  padding: 16px 18px;
  border-radius: var(--radius);
}

.load-error {
  position: fixed;
  inset: auto 24px 24px 24px;
  z-index: 20;
  box-shadow: var(--shadow);
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.top-band {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(520px, 1.15fr);
  gap: 28px;
  align-items: end;
  padding: 22px 0 28px;
}

.hero-copy h1 {
  margin: 8px 0 10px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.intro {
  max-width: 620px;
  margin: 0;
  color: #40505c;
  font-size: 1.03rem;
  line-height: 1.55;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

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

.kpi-card {
  min-height: 96px;
  padding: 15px;
  border: 1px solid rgba(191, 204, 214, 0.78);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 22px rgba(18, 31, 43, 0.06);
  backdrop-filter: blur(12px);
}

.kpi-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 9px;
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
  font-weight: 850;
  line-height: 1;
}

.kpi-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.is-loading {
  color: var(--muted);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.view-tabs {
  display: flex;
  width: min(520px, 100%);
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  padding: 6px;
  margin: 0 0 20px;
  box-shadow: 0 12px 30px rgba(18, 31, 43, 0.1);
}

.tab-button {
  flex: 1;
  min-width: 124px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #40505c;
  font-weight: 800;
}

.tab-button-feature {
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.22);
}

.tab-badge {
  color: inherit;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tab-button:hover,
.tab-button:focus-visible,
.tab-button.is-active {
  background: var(--ink);
  color: #fff;
  outline: none;
}

.tab-panel[hidden] {
  display: none;
}

.control-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
}

.panel-block,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-block {
  padding: 17px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2,
.chart-header h2 {
  margin: 4px 0 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.field-label {
  display: block;
  margin: 12px 0 7px;
  color: #394955;
  font-size: 0.82rem;
  font-weight: 750;
}

.search-input,
.number-input,
.metric-select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search-input:focus,
.number-input:focus,
.metric-select:focus,
.range-input:focus-visible,
.small-button:focus-visible,
.team-chip:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

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

.number-grid .field-label {
  margin-bottom: 0;
}

.number-input {
  display: block;
  margin-top: 7px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.small-button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: #26343f;
  font-size: 0.82rem;
  font-weight: 750;
}

.small-button:hover {
  border-color: #94a7b4;
  background: #eef4f6;
}

.team-selector,
.player-selector {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.team-chip,
.player-chip {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: #24313a;
  padding: 8px 10px;
  text-align: left;
}

.team-chip:hover,
.player-chip:hover {
  border-color: var(--line-strong);
  background: #f8fbfc;
}

.team-chip.is-selected,
.player-chip.is-selected {
  border-color: rgba(15, 118, 110, 0.38);
  background: #f0faf8;
}

.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--team-color, #8a99a6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--team-color, #8a99a6) 18%, transparent);
}

.team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 740;
}

.player-chip-main {
  display: grid;
  min-width: 0;
}

.player-chip-meta,
.player-subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-position {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
}

.range-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.control-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.goals-verdict {
  margin: 4px 20px 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: rgba(15, 118, 110, 0.07);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.5;
}

.goals-verdict strong {
  font-weight: 750;
}

.content-column {
  display: grid;
  gap: 18px;
}

.chart-panel {
  min-width: 0;
  overflow: hidden;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding: 18px 20px 0;
}

.chart-header.compact {
  padding-bottom: 4px;
}

.chart-caption {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.chart-frame {
  height: 315px;
  padding: 6px 10px 14px;
}

.chart-frame.tall {
  height: 470px;
  padding-top: 2px;
}

.chart-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

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

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 18px;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
  color: #26343f;
  font-size: 0.8rem;
  font-weight: 760;
}

.team-profile {
  display: grid;
  gap: 12px;
  padding: 14px 20px 20px;
}

.player-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px 20px 20px;
}

.history-comparison {
  display: grid;
  gap: 12px;
  padding: 14px 20px 20px;
}

.history-season-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-season-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--team-color, var(--accent));
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.history-season-card span,
.champion-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.history-season-card strong,
.champion-tile strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.15;
}

.history-season-card small,
.champion-tile small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.history-delta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-delta-row {
  border: 1px solid #e5ebef;
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.history-delta-row span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.history-delta-row strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
}

.history-delta-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.champions-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  padding: 14px 20px 20px;
}

.champion-tile {
  min-height: 104px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--team-color, var(--accent));
  border-radius: var(--radius);
  background: #fff;
  padding: 11px;
}

.profile-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--team-color, var(--accent));
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 13px;
}

.player-card {
  background: #fff;
}

.profile-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-title h3 {
  margin: 0;
  font-size: 1.02rem;
}

.profile-rank {
  color: var(--muted);
  font-weight: 800;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.profile-stat {
  border: 1px solid #e5ebef;
  border-radius: var(--radius);
  background: #fff;
  padding: 9px;
}

.profile-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: uppercase;
}

.profile-stat strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(0.96rem, 1.6vw, 1.12rem);
  white-space: nowrap;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px;
}

.form-badge {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
}

.form-badge.win {
  background: #117f59;
}

.form-badge.draw {
  background: #7a8793;
}

.form-badge.loss {
  background: #c0392b;
}

.table-wrap {
  overflow: auto;
  padding: 8px 20px 20px;
}

.standings-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.standings-table th,
.standings-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: right;
  white-space: nowrap;
}

.standings-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  padding: 4px 2px;
  font-size: inherit;
  font-weight: inherit;
  text-transform: inherit;
}

.sort-button:hover,
.sort-button:focus-visible,
.sort-button.is-active {
  color: var(--ink);
  background: #eef4f6;
  outline: none;
}

.sort-arrow {
  display: inline-block;
  width: 10px;
  color: var(--accent);
  font-size: 0.62rem;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table th:nth-child(2) .sort-button {
  justify-content: flex-start;
}

.club-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.standings-table tr.is-selected {
  background: #f0faf8;
}

.player-table {
  min-width: 1120px;
}

.player-table th:first-child,
.player-table td:first-child,
.player-table th:nth-child(2),
.player-table td:nth-child(2) {
  text-align: left;
}

.player-table th:first-child .sort-button,
.player-table th:nth-child(2) .sort-button {
  justify-content: flex-start;
}

.player-table tbody tr {
  cursor: pointer;
}

.player-table tbody tr:hover {
  background: #f8fbfc;
}

.gd-positive {
  color: #0f7a55;
  font-weight: 780;
}

.gd-negative {
  color: #b42318;
  font-weight: 780;
}

.tooltip {
  position: fixed;
  z-index: 30;
  max-width: 260px;
  pointer-events: none;
  border: 1px solid rgba(31, 45, 55, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 36px rgba(18, 31, 43, 0.16);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.35;
}

.tooltip strong {
  display: block;
  margin-bottom: 3px;
}

.axis-label {
  fill: #65727e;
  font-size: 12px;
  font-weight: 700;
}

.band-label {
  fill: #53616d;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grid-line {
  stroke: #e6edf1;
  stroke-width: 1;
}

.axis-line {
  stroke: #c6d1d9;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.chart-point {
  cursor: pointer;
}

.form-heatmap {
  padding: 10px 20px 20px;
}

.heatmap-scroll {
  overflow: auto;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: minmax(124px, 168px) repeat(var(--round-count), minmax(22px, 1fr));
  gap: 3px;
  min-width: 980px;
  align-items: center;
}

.heatmap-header {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.heatmap-team {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #26343f;
  font-size: 0.78rem;
  font-weight: 800;
}

.heatmap-team span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heatmap-round {
  text-align: center;
}

.heatmap-cell {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border: 1px solid rgba(198, 209, 217, 0.66);
  border-radius: 4px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.heatmap-cell.win {
  background: #117f59;
}

.heatmap-cell.draw {
  background: #7a8793;
}

.heatmap-cell.loss {
  background: #c0392b;
}

.heatmap-cell.blank {
  background: #edf2f5;
  color: var(--muted);
}

.sparkline-cell {
  min-width: 96px;
}

.position-sparkline {
  display: block;
  width: 88px;
  height: 26px;
}

.empty-state {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 28px 0 0;
  border-top: 1px solid var(--line);
  padding: 18px 2px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

@media (max-width: 1120px) {
  .top-band,
  .dashboard-layout,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .team-selector {
    max-height: 260px;
  }

  .player-selector {
    max-height: 260px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 14px;
  }

  .season-kpis,
  .player-kpis,
  .history-kpis,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .tab-button {
    width: 100%;
  }

  .hero-copy h1 {
    font-size: clamp(2.05rem, 14vw, 3.3rem);
  }

  .chart-header {
    display: block;
  }

  .chart-caption {
    text-align: left;
  }

  .chart-frame,
  .chart-frame.tall {
    height: 340px;
  }

  .profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .history-season-cards,
  .history-delta-grid {
    grid-template-columns: 1fr;
  }
}
