:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #121519;
  --surface-2: #171b20;
  --surface-3: #20252c;
  --text: #eceff3;
  --muted: #9aa4b2;
  --border: #2b323c;
  --accent: #3b82f6;
  --accent-2: #be123c;
  --accent-3: #f59e0b;
  --accent-4: #8b5cf6;
  --shadow: none;
  --font-sans: Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

svg,
svg text {
  font-family: var(--font-sans);
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: #0f1215;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.topbar-brand {
  margin-right: auto;
  color: var(--text) !important;
  font-weight: 800;
}

.topbar a {
  color: #b6beca;
  text-decoration: none;
  font-size: 0.84rem;
  padding: 7px 9px;
  border-radius: 6px;
}

.topbar a:hover {
  background: #171b20;
  color: var(--text);
}

.hero {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 330px);
  gap: 28px;
  align-items: center;
}

.hero h1 {
  max-width: 900px;
  margin: 0;
  color: var(--text);
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-subheading {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.05vw, 1rem);
  font-weight: 500;
  line-height: 1.35;
}

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

.hero .eyebrow {
  color: var(--accent);
}

.hero-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.hero-panel span,
.metric span,
.panel-title span,
.section-heading p,
label span {
  color: var(--muted);
}

.hero-panel span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.hero-panel strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.2;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 52px;
}

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

.metric,
.results-list,
.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 92px;
  padding: 14px 15px;
  position: relative;
  overflow: hidden;
}

.metric span {
  display: block;
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 2.1vw, 2.1rem);
  line-height: 1;
}

.workspace {
  margin-top: 28px;
  padding: 0 0 26px;
  border-bottom: 1px solid var(--border);
}

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

.section-heading h2,
.panel-title h3 {
  margin: 6px 0 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  font-weight: 800;
}

.section-heading > p {
  max-width: 460px;
  margin: 0;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(230px, 1.7fr) minmax(145px, 0.7fr) minmax(170px, 0.9fr) minmax(190px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: #101317;
  border-radius: 8px;
  border: 1px solid var(--border);
}

label span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 7px;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  background: #0d0f12;
  border-radius: 6px;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

button {
  height: 40px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #f8fafc;
  font-weight: 750;
  padding: 0 18px;
  cursor: pointer;
}

button:hover {
  background: #60a5fa;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101317;
  padding: 13px 14px;
}

.info-card span,
.classification-card dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.info-card p {
  min-height: 0;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.km-panel {
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  position: relative;
}

.games-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.games-table {
  min-width: 0;
}

.games-table h4 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.games-row {
  width: 100%;
  height: auto;
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 7px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #101317;
  color: var(--text);
  text-align: left;
}

.games-row:hover,
.games-row:focus-visible {
  border-color: rgba(59, 130, 246, 0.58);
  background: rgba(59, 130, 246, 0.09);
  outline: none;
}

.games-row span {
  min-width: 0;
  overflow: hidden;
  color: #d4d9e0;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.games-row strong {
  color: var(--accent);
  font-size: 0.95rem;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.segmented-control button {
  height: 32px;
  border: 1px solid var(--border);
  background: #0f1215;
  color: var(--muted);
  padding: 0 11px;
}

.segmented-control button:hover,
.segmented-control button.active {
  border-color: rgba(59, 130, 246, 0.72);
  background: rgba(59, 130, 246, 0.16);
  color: #dbeafe;
}

.segmented-control.compact {
  max-width: 100%;
}

.segmented-control.compact button {
  height: 30px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.km-curve {
  width: 100%;
  min-height: 300px;
  margin-top: 4px;
}

.km-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.km-legend button {
  height: auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--legend-color) 34%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--legend-color) 10%, #101317);
  color: var(--text);
  font-size: 0.8rem;
  padding: 5px 10px;
  white-space: nowrap;
}

.km-legend button.muted {
  opacity: 0.52;
  background: #101317;
  color: var(--muted);
}

.legend-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 999px;
  background: var(--legend-color);
  box-shadow: none;
}

.km-legend button.muted .legend-dot {
  background: transparent;
  border: 1px solid var(--legend-color);
  box-shadow: none;
}

.hover-guide {
  stroke: #e2e8f0;
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
  opacity: 0.72;
  pointer-events: none;
}

.hover-point {
  fill: var(--point-color);
  stroke: #101113;
  stroke-width: 2;
  pointer-events: none;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  width: min(240px, calc(100% - 24px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(13, 15, 18, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 10px 12px;
  pointer-events: none;
  font-size: 0.82rem;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  margin-top: 4px;
  color: var(--muted);
}

.player-layout {
  margin-top: 14px;
}

.results-list {
  box-shadow: none;
}

.results-list {
  padding: 14px;
}

.player-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.player-card {
  width: 100%;
  text-align: left;
  height: auto;
  border: 1px solid var(--border);
  background: #101317;
  color: var(--text);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  font-weight: 400;
}

.player-card:hover,
.player-card.active {
  border-color: var(--accent);
  background: #111d33;
}

.player-card strong {
  font-size: 1rem;
  font-weight: 500;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 5px;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.14);
  color: #dbeafe;
  font-size: 0.78rem;
  font-weight: 700;
}

.category-chip {
  background: color-mix(in srgb, var(--cat-color) 20%, transparent);
  color: #f8fafc;
  border: 1px solid color-mix(in srgb, var(--cat-color) 55%, transparent);
}

.empty-state {
  min-height: 480px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 22px;
}

.player-dialog {
  width: min(960px, calc(100% - 28px));
  max-height: min(86vh, 980px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101317;
  color: var(--text);
  padding: 18px;
  box-shadow: var(--shadow);
}

.player-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.dialog-close {
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  width: auto;
  height: 34px;
  margin: 0 0 14px auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0d0f12;
  color: var(--text);
  padding: 0 12px;
  text-align: center;
}

.player-dialog-content {
  padding: 0;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.detail-header h3 {
  margin: 0 0 8px;
  font-size: 1.55rem;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.detail-stat {
  border: 1px solid var(--border);
  background: #121519;
  border-radius: 8px;
  padding: 12px;
}

.detail-stat span {
  color: var(--muted);
  font-size: 0.78rem;
}

.detail-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
}

.mini-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.mini-panel {
  border: 1px solid var(--border);
  background: #121519;
  border-radius: 8px;
  padding: 14px;
  min-height: 260px;
}

.player-note {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: rgba(217, 130, 59, 0.08);
  padding: 12px;
}

.player-note span {
  color: var(--muted);
  font-size: 0.9rem;
}

.category-summary {
  margin-top: 18px;
}

.category-summary h4 {
  margin: 0 0 12px;
}

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

.category-summary article {
  border: 1px solid var(--border);
  border-left: 4px solid var(--cat-color);
  border-radius: 8px;
  background: #121519;
  padding: 12px;
}

.category-summary strong,
.category-summary span,
.category-summary small {
  display: block;
}

.category-summary span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.category-summary small {
  margin-top: 8px;
  color: #cbd5e1;
  line-height: 1.35;
}

.mini-panel h4,
.injury-list h4 {
  margin: 0 0 12px;
}

.sparkline {
  width: 100%;
  height: 190px;
}

.spark-hover-label rect {
  fill: rgba(16, 17, 19, 0.94);
  stroke: var(--border);
}

.spark-hover-label text {
  fill: var(--text);
  font-size: 12px;
}

.spark-hover-label text:first-of-type {
  fill: var(--muted);
}

.injury-list {
  margin-top: 18px;
}

.injury-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-left: 4px solid var(--cat-color, transparent);
  padding-left: 10px;
}

.injury-item strong {
  display: block;
}

.injury-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.chart-panel {
  box-shadow: none;
  padding: 15px;
  min-height: 340px;
  position: relative;
  background: var(--surface);
}

.full-width-panel {
  grid-column: 1 / -1;
  min-height: auto;
}

.chart-insight {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  border: 1px solid rgba(59, 130, 246, 0.36);
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.09);
  padding: 10px 12px;
  font-size: 0.88rem;
}

.chart-insight strong {
  color: var(--text);
}

.chart-insight span {
  color: var(--muted);
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) 58px;
  gap: 10px;
  align-items: center;
  width: 100%;
  height: auto;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.bar-row:hover,
.bar-row:focus-visible {
  border-color: rgba(59, 130, 246, 0.58);
  background: rgba(59, 130, 246, 0.09);
  outline: none;
}

.bar-label {
  font-size: 0.85rem;
  color: #d4d9e0;
}

.bar-track {
  height: 10px;
  background: #2a3038;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--bar-color, var(--accent)), color-mix(in srgb, var(--bar-color, var(--accent)) 72%, white));
  border-radius: inherit;
  box-shadow: 0 0 12px color-mix(in srgb, var(--bar-color, var(--accent)) 28%, transparent);
}

.bar-fill.secondary {
  background: linear-gradient(90deg, var(--accent-2), #fb7185);
  box-shadow: 0 0 12px rgba(190, 18, 60, 0.3);
}

.bar-value {
  text-align: right;
  font-weight: 800;
  font-size: 0.84rem;
}

.line-chart {
  width: 100%;
  height: 280px;
}

.point-hit,
.spark-point {
  cursor: pointer;
}

.point-hit:focus,
.spark-point:focus {
  outline: none;
}

.point-hit:hover circle:last-child,
.point-hit:focus circle:last-child,
.spark-point:hover circle:last-child,
.spark-point:focus circle:last-child {
  filter: drop-shadow(0 0 8px currentColor);
  r: 8;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.classification-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101317;
  padding: 14px;
}

.classification-card .kicker {
  display: block;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.classification-card strong {
  font-size: 1.28rem;
}

.classification-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.classification-card dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.secondary-grid {
  margin-top: 16px;
}

.single-grid {
  grid-template-columns: minmax(0, 1fr);
}

.single-grid .chart-panel {
  min-height: auto;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 32px;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.site-footer a:hover,
.site-footer a:focus-visible {
  color: #dbeafe;
  text-decoration: underline;
  outline: none;
}

@media (max-width: 920px) {
  .hero,
  .chart-grid,
  .mini-charts {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 40px;
  }

  .section-heading,
  .panel-title {
    align-items: start;
    flex-direction: column;
  }

  .segmented-control {
    justify-content: flex-start;
  }

  .metric-grid,
  .info-grid,
  .games-grid,
  .classification-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-panel {
    grid-template-columns: 1fr 1fr;
  }

  .search-panel button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .topbar {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar a {
    font-size: 0.88rem;
    padding: 7px 8px;
  }

  main {
    width: min(100% - 20px, 1180px);
    margin-top: 12px;
  }

  .hero {
    padding: 24px 0 28px;
  }

  .hero h1 {
    font-size: clamp(1.85rem, 10vw, 2.55rem);
  }

  .hero-panel {
    padding: 16px;
  }

  .metric-grid,
  .search-panel,
  .info-grid,
  .games-grid,
  .classification-grid,
  .detail-stats,
  .category-summary > div,
  .player-results {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 96px;
  }

  .workspace,
  .km-panel,
  .games-panel,
  .results-list {
    padding: 14px;
  }

  .player-results {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .player-dialog {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    padding: 14px;
  }

  .player-dialog-content {
    padding: 0;
  }

  .classification-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 16px;
  }

  #trends.workspace {
    padding: 14px;
  }

  .chart-grid {
    gap: 12px;
  }

  .chart-panel {
    min-height: auto;
    overflow: hidden;
    padding: 14px;
  }

  .chart-panel .panel-title {
    gap: 10px;
    margin-bottom: 14px;
  }

  .chart-panel .segmented-control {
    width: 100%;
  }

  .segmented-control.compact button {
    flex: 1 1 calc(50% - 6px);
    padding: 0 7px;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 8px 0;
  }

  .bar-value {
    text-align: left;
  }

  .km-curve,
  .line-chart {
    display: block;
    height: 320px;
    min-height: 320px;
  }

  .line-chart {
    aspect-ratio: 360 / 320;
    height: auto;
    min-height: 0;
  }

  .km-legend {
    flex-wrap: wrap;
    gap: 7px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .km-legend button {
    max-width: 100%;
    min-height: 28px;
    padding: 5px 8px;
    white-space: normal;
  }

  .full-width-panel table {
    table-layout: fixed;
    font-size: 0.78rem;
  }

  .full-width-panel th,
  .full-width-panel td {
    padding: 9px 6px;
    overflow-wrap: anywhere;
  }

  .full-width-panel th:first-child,
  .full-width-panel td:first-child {
    width: 40%;
  }

  .site-footer {
    flex-direction: column;
  }
}
