/* ── Floodlit: dark stadium palette, geometric sans, glass panels ── */
:root {
  --bg: #0b0f1a;
  --bg-2: #111827;
  --panel: rgba(17, 24, 39, 0.72);
  --panel-solid: #111827;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --fg: #f3f4f6;
  --fg-soft: #c7cbd6;
  --muted: #8b93a7;
  --accent: #ff4d5e;
  --lil: #ff4d5e;
  --gal: #ffb703;
  --font: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  --sidebar-w: 17rem;
  --compare-w: min(31rem, 44vw);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
::selection { background: var(--accent); color: var(--bg); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Canvas + light ────────────────────────────────────────────── */
.canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; cursor: grab; }
.canvas:active { cursor: grabbing; }
.canvas.over-node { cursor: pointer; }
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse 70% 55% at 50% 48%, rgba(120, 140, 200, 0.08), transparent 70%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.55) 110%);
}
.grain { display: none; }

/* ── Masthead ──────────────────────────────────────────────────── */
.masthead { position: fixed; top: 1.6rem; left: 1.8rem; z-index: 4; max-width: min(52vw, 40rem); pointer-events: none; }
.masthead > * { pointer-events: auto; }
.brand {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.28rem 0.7rem 0.28rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 999px;
  text-decoration: none; color: var(--fg); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.brand-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: background 0.4s ease, box-shadow 0.4s ease; }
.back-button {
  display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.6rem; padding: 0.28rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--panel); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer; vertical-align: middle;
}
.back-button:hover { border-color: var(--fg); }
.masthead-team {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.55rem; margin: 0.7rem 0 0;
  font-weight: 700; font-size: clamp(1.6rem, 3vw, 2.5rem); line-height: 1; letter-spacing: -0.03em; text-transform: uppercase;
}
.masthead-crest { width: 1.05em; height: 1.05em; object-fit: contain; filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.15)); }
.masthead-x { color: var(--muted); font-weight: 300; }
.masthead-sub { margin: 0.55rem 0 0; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); line-height: 1.7; }

/* ── Stats (top-right) ─────────────────────────────────────────── */
.stats { position: fixed; top: 1.7rem; right: 1.8rem; z-index: 4; display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(10px); }
.stat { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem 1.1rem; border-left: 1px solid var(--line); min-width: 7rem; }
.stat:first-child { border-left: 0; }
.stat-label { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.stat-value { font-size: 1.45rem; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }

/* ── Rail ──────────────────────────────────────────────────────── */
.rail { position: fixed; left: 1.8rem; bottom: 1.5rem; z-index: 4; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.9rem; max-width: min(66vw, calc(100vw - 3.6rem)); }
.control-label { display: block; font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.3rem 0.2rem; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); backdrop-filter: blur(10px); }
.segmented button {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border: 0; border-radius: 999px; background: none;
  font-size: 0.8rem; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background 0.15s ease, color 0.15s ease;
}
.segmented button img { width: 16px; height: 16px; object-fit: contain; }
.segmented button:hover { color: var(--fg); }
.segmented button.current { background: var(--fg); color: var(--bg); }
.segmented button.current img { filter: none; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 1.8rem; top: 9rem; z-index: 4; width: var(--sidebar-w); max-height: calc(100vh - 17rem); overflow-y: auto;
  padding: 1rem 1.05rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(14px); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.sidebar-content { transition: opacity 0.15s ease; }
.sidebar-content.fading { opacity: 0; }
.sidebar-section-header { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.45rem; }
.sidebar-section-context { color: var(--fg); letter-spacing: -0.01em; text-transform: none; font-family: var(--font); font-size: 0.95rem; font-weight: 600; }
.team-head { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.45rem; }
.team-head img { width: 36px; height: 36px; object-fit: contain; }
.team-head-name { font-weight: 700; font-size: 1.15rem; line-height: 1.1; letter-spacing: -0.02em; }
.team-head-sub { font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.form-strip { display: flex; gap: 3px; margin: 0.5rem 0 0.7rem; }
.form-chip {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0.3rem 0 0.25rem; border-radius: 6px;
  background: rgba(255, 255, 255, 0.04); font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.04em; color: var(--muted); cursor: default;
}
.form-chip b { font-family: var(--font); font-size: 0.9rem; color: var(--fg); }
.form-chip.W { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.form-chip.W b { color: var(--accent); }
.form-chip.L { opacity: 0.5; }
.form-chip.ucl { box-shadow: inset 0 0 0 1px var(--line-strong); }
.metric-card { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.metric-head { display: flex; align-items: center; justify-content: space-between; }
.metric-label { font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.metric-info { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; padding: 0 0.1rem; }
.metric-info:hover { color: var(--fg); }
.metric-value { font-size: 1.55rem; font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; margin: 0.12rem 0 0.25rem; }
.metric-value small { font-size: 0.72rem; font-weight: 400; color: var(--muted); margin-left: 0.25rem; letter-spacing: 0; }
.metric-range { display: flex; align-items: center; gap: 0.45rem; margin: 0.15rem 0 0.2rem; font-family: var(--mono); font-size: 0.52rem; color: var(--muted); }
.metric-range-track { position: relative; flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.metric-range-dot { position: absolute; top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); transform: translate(-50%, -50%); }
.metric-sub { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.03em; color: var(--muted); line-height: 1.5; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.6rem; font-size: 0.8rem; margin: 0.2rem 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 0.68rem; text-align: right; color: var(--fg-soft); }
.kv dd b { font-family: var(--font); font-size: 0.95rem; font-weight: 600; color: var(--fg); }
.bars { display: grid; gap: 5px; margin-top: 0.35rem; }
.bar { display: grid; grid-template-columns: 5.4rem 1fr auto; align-items: center; gap: 0.45rem; font-family: var(--mono); font-size: 0.56rem; color: var(--muted); }
.bar-track { height: 5px; background: rgba(255, 255, 255, 0.07); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }
.list { display: grid; gap: 1px; margin-top: 0.25rem; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; font-size: 0.78rem; padding: 0.22rem 0; border-top: 1px solid var(--line); }
.list-row span:last-child { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover span:first-child { color: var(--accent); }
.sidebar-toggle { display: none; }

/* ── Compare panel ─────────────────────────────────────────────── */
.compare-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 6; width: var(--compare-w); display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: rgba(11, 15, 26, 0.86); backdrop-filter: blur(18px); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.compare-panel.open { transform: translateX(0); }
.compare-panel-header { padding: 1.5rem 1.6rem 0.9rem; border-bottom: 1px solid var(--line); }
.compare-panel-title { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.compare-panel-sub { margin: 0.35rem 0 0; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.compare-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin-top: 0.6rem; font-family: var(--mono); font-size: 0.56rem; color: var(--muted); }
.compare-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.compare-legend-note { flex-basis: 100%; letter-spacing: 0.02em; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-lil { background: var(--lil); box-shadow: 0 0 8px var(--lil); }
.dot-gal { background: var(--gal); box-shadow: 0 0 8px var(--gal); }
.compare-panel-list { flex: 1; overflow-y: auto; padding: 0.5rem 1.6rem 1.6rem; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.compare-group { margin: 1rem 0 0.4rem; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.compare-row { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.6rem; padding: 0.5rem 0; border-top: 1px solid var(--line); align-items: center; }
.compare-row-label { font-size: 0.84rem; }
.compare-row-tag { font-family: var(--mono); font-size: 0.5rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 0.12rem 0.45rem; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); }
.compare-row-tag.contrast { border-color: var(--fg); color: var(--fg); }
.compare-row-tag.overlap { background: rgba(255, 255, 255, 0.06); }
.compare-track { grid-column: 1 / -1; position: relative; height: 18px; margin-top: 0.15rem; }
.compare-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.compare-track::after { content: ""; position: absolute; left: 50%; top: 3px; bottom: 3px; width: 1px; background: var(--line-strong); }
.compare-dot { position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--bg); }
.compare-dot.lil { background: var(--lil); box-shadow: 0 0 10px var(--lil); }
.compare-dot.gal { background: var(--gal); box-shadow: 0 0 10px var(--gal); }
.compare-vals { grid-column: 1 / -1; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.compare-vals b { color: var(--fg); font-weight: 500; }
body.compare-open .stats, body.compare-open .legend { display: none; }
body.compare-open .meta { right: calc(var(--compare-w) + 1.8rem); }

/* ── Labels, tooltip, legend ───────────────────────────────────── */
.label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, 0); display: flex; flex-direction: column; align-items: center;
  pointer-events: auto; cursor: pointer; white-space: nowrap; transition: opacity 0.25s ease; will-change: transform;
}
.label-name { font-weight: 600; font-size: 0.74rem; letter-spacing: -0.01em; color: var(--fg); text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.9); }
.label-stat { font-family: var(--mono); font-size: 0.5rem; letter-spacing: 0.08em; color: var(--muted); text-shadow: 0 0 6px rgba(0, 0, 0, 0.9); }
.label.dimmed { opacity: 0.2; }
.label.hidden { opacity: 0; pointer-events: none; }
.label.pinned .label-name { color: var(--accent); text-shadow: 0 0 12px var(--accent); }
.label.hover .label-name { text-decoration: underline; text-underline-offset: 3px; }
.tooltip {
  position: fixed; z-index: 7; pointer-events: none; max-width: 17rem; padding: 0.5rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--panel-solid); box-shadow: var(--shadow); font-size: 0.8rem; line-height: 1.35;
}
.tooltip small { display: block; font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.06em; color: var(--muted); margin-top: 0.2rem; }
.legend {
  position: fixed; right: 1.8rem; top: 6rem; z-index: 4; display: flex; gap: 1rem; padding: 0.4rem 0.9rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); backdrop-filter: blur(10px); font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.legend:empty { display: none; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; vertical-align: 0; box-shadow: 0 0 6px currentColor; }

/* ── Hint, error, modal, footer ───────────────────────────────── */
.hint {
  position: fixed; left: 50%; bottom: 5rem; z-index: 5; transform: translate(-50%, 8px); max-width: 26rem; padding: 0.6rem 1rem;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel-solid); box-shadow: var(--shadow);
  font-size: 0.8rem; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.4s ease, transform 0.4s ease;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.load-error { position: fixed; inset: 0; z-index: 8; display: none; place-items: center; background: rgba(11, 15, 26, 0.8); }
.load-error.visible { display: grid; }
.load-error-retry { padding: 0.5rem 1rem; border: 1px solid var(--fg); border-radius: 999px; background: var(--bg); cursor: pointer; }
.info-modal { width: min(28rem, calc(100vw - 2rem)); padding: 1.6rem 1.7rem 1.5rem; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--panel-solid); color: var(--fg); box-shadow: var(--shadow); }
.info-modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); }
.info-modal-close { position: absolute; top: 0.7rem; right: 0.8rem; border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.info-modal-title { margin: 0 0 0.6rem; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.info-modal-def, .info-modal-basketball { margin: 0; line-height: 1.55; font-size: 0.9rem; color: var(--fg-soft); }
.info-modal-divider { margin: 1.1rem 0 0.5rem; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.meta { position: fixed; right: 1.8rem; bottom: 1.5rem; z-index: 4; max-width: 28vw; text-align: right; font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); line-height: 1.7; }

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root { --compare-w: 100vw; }
  .masthead { left: 1rem; top: 1rem; max-width: 82vw; }
  .masthead-team { font-size: 1.35rem; }
  .masthead-sub { font-size: 0.52rem; }
  .stats { top: auto; bottom: 9.8rem; left: 1rem; right: 1rem; justify-content: space-between; }
  .stat { min-width: 0; padding: 0.5rem 0.7rem; flex: 1; }
  .stat-value { font-size: 1.05rem; }
  .rail { left: 1rem; right: 1rem; bottom: 1rem; gap: 0.45rem 0.6rem; max-width: none; }
  .segmented button { padding: 0.34rem 0.6rem; font-size: 0.72rem; }
  .segmented button img { width: 14px; height: 14px; }
  .meta, .legend { display: none; }
  .sidebar { left: 1rem; right: 1rem; width: auto; top: auto !important; bottom: 9.6rem; max-height: 46vh; display: none; }
  body.sidebar-open .sidebar { display: block; }
  .sidebar-toggle {
    display: block; position: fixed; right: 1rem; bottom: 6.9rem; z-index: 5; padding: 0.45rem 0.85rem; border: 1px solid var(--line-strong); border-radius: 999px;
    background: var(--panel-solid); font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  }
  .compare-panel { top: auto; height: 62vh; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 18px 18px 0 0; transform: translateY(100%); }
  .compare-panel.open { transform: translateY(0); }
  .compare-panel-header { padding: 0.9rem 1rem 0.6rem; }
  .compare-panel-list { padding: 0.3rem 1rem 1rem; }
  body.compare-open .rail, body.compare-open .sidebar, body.compare-open .sidebar-toggle, body.compare-open .stats { display: none; }
  .compare-panel-close { display: inline-flex; }
  .hint { bottom: auto; top: 7rem; max-width: calc(100vw - 2rem); }
}
.compare-panel-close {
  display: none; align-items: center; gap: 0.3rem; margin-bottom: 0.5rem; padding: 0.25rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--panel-solid); font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
@media (prefers-reduced-motion: reduce) { .compare-panel, .hint, .label, .sidebar-content { transition: none; } }
