/* ============================================================
   WC22 Player Chemistry — site styles
   Mobile-first. Tested at 360px, 768px, 1280px.
   ============================================================ */

:root {
  --bg: #0e1014;
  --bg-elev: #171a21;
  --bg-elev-2: #1f242d;
  --border: #2a313d;
  --text: #e6e9ef;
  --text-dim: #97a0b0;
  --text-mute: #6c7689;
  --accent-green: #1a8a3a;
  --accent-green-soft: rgba(26, 138, 58, 0.18);
  --accent-red: #c0392b;
  --accent-red-soft: rgba(192, 57, 43, 0.18);
  --link: #6aa8ff;
  --link-hover: #9cc3ff;
  /* Reduced drop-shadow; data-ink ratio over decoration. */
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { color: var(--link-hover); text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 1.4em 0 0.6em;
  line-height: 1.25;
  font-weight: 600;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; color: var(--text-dim); }

p { margin: 0.8em 0; }

code, pre {
  font-family: var(--mono);
  font-size: 0.9em;
}
code {
  background: var(--bg-elev-2);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8em;
  overflow-x: auto;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* ============================================================
   Header / nav
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 16, 20, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  gap: 0.8rem;
}

.site-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-title a { color: inherit; }
.site-title a:hover { text-decoration: none; }
.site-title .sub {
  display: block;
  color: var(--text-mute);
  font-size: 0.72rem;
  font-weight: 400;
}

.nav-toggle {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-elev-2); }

.site-nav {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem 0.8rem;
  gap: 0.1rem;
}
.site-nav.open { display: flex; }
.site-nav a {
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.site-nav a:hover { background: var(--bg-elev-2); text-decoration: none; }
.site-nav a.active {
  background: var(--accent-green-soft);
  color: var(--text);
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .site-nav {
    display: flex !important;
    flex-direction: row;
    position: static;
    background: transparent;
    border: none;
    padding: 0;
    gap: 0.2rem;
  }
  .site-nav a { padding: 0.4rem 0.7rem; font-size: 0.9rem; }
}

/* ============================================================
   Layout
   ============================================================ */

main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 1rem;
  color: var(--text-mute);
  font-size: 0.82rem;
  text-align: center;
}

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.8rem 0;
  box-shadow: var(--shadow);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.grid-stat {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
@media (min-width: 600px) {
  .grid-stat { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .grid-stat { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
}
.stat .label {
  font-size: 0.75rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat .value {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.2rem;
}
.stat .sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* Chips / badges */
.chip {
  display: inline-block;
  font-size: 0.74rem;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip.green { background: var(--accent-green-soft); color: #6dd58c; border-color: transparent; }
.chip.red { background: var(--accent-red-soft); color: #e98074; border-color: transparent; }

.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 3px;
  margin-right: 0.35em;
  vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.flag {
  display: inline-block;
  width: 1.1em;
  height: 0.825em;
  margin-right: 0.4em;
  vertical-align: -1px;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  image-rendering: -webkit-optimize-contrast;
}
.flag.lg { width: 1.6em; height: 1.2em; vertical-align: -3px; }

.pos-chip {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 0.4em;
  vertical-align: 1px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-transform: uppercase;
  white-space: nowrap;
}
.pos-chip.gk  { background: rgba(255, 200, 80, 0.16); color: #ffd47a; border-color: transparent; }
.pos-chip.def { background: rgba(120, 170, 255, 0.16); color: #a3c1ff; border-color: transparent; }
.pos-chip.mid { background: rgba(170, 200, 255, 0.10); color: #c6d5ff; border-color: transparent; }
.pos-chip.fwd { background: rgba(255, 110, 90, 0.18); color: #ffa190; border-color: transparent; }

.flag-bg-wrap {
  position: relative;
  isolation: isolate;
}
.flag-bg-wrap > .flag-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0.18;
  filter: saturate(1.05) brightness(0.95);
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
}
.flag-bg-wrap > * { position: relative; z-index: 1; }
.flag-bg-wrap > .flag-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 16, 20, 0.55) 0%, rgba(14, 16, 20, 0.85) 100%);
}

details.code-toggle {
  margin: 0.5rem 0 1.25rem 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
}
details.code-toggle > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  user-select: none;
  list-style: none;
}
details.code-toggle > summary::before {
  content: "▸ ";
  color: var(--text-dim);
}
details.code-toggle[open] > summary::before { content: "▾ "; }
details.code-toggle pre {
  margin: 0.5rem 0 0 0;
  background: #0a0c10;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.5;
}
details.code-toggle code { color: #d1d8e6; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ============================================================
   Interactive Plays — SVG-rendered pitch + P-chart
   ============================================================ */

.iplay .iplay-stage {
  width: 100%;
  background: #0b1220;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.iplay .iplay-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: #0b1220;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.iplay .iplay-titlebar .iplay-title {
  color: var(--text);
  font-weight: 600;
  flex: 1;
  text-align: center;
  padding: 0 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iplay .iplay-titlebar .iplay-team {
  font-weight: 700;
  letter-spacing: 0.03em;
}
.iplay .iplay-pitch {
  width: 100%;
  height: auto;
  display: block;
  /* Cap the pitch height so the whole card stays roughly within one
     screen — the chart + meta below need vertical space too. */
  max-height: 58vh;
  object-fit: contain;
}
@media (min-width: 1100px) {
  .iplay .iplay-pitch { max-height: 60vh; }
}
@media (max-width: 700px) {
  .iplay .iplay-pitch { max-height: 72vh; }
}
.iplay .iplay-pitch text { user-select: none; pointer-events: none; }
.iplay .iplay-label rect { stroke: rgba(255,255,255,0.08); stroke-width: 0.6; }

/* P-chart under the slider */
.iplay-chart {
  background: #0b1220;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-top: -0.2rem;
}
.iplay-chart .chart-title {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.iplay-chart .chart-title .dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.3em;
}
.iplay-chart .chart-svg {
  display: block;
  width: 100%;
  height: 110px;
  border-radius: 4px;
}

/* Event-strip flash when an event lands */
.event-strip.flash {
  animation: iplay-flash 0.35s ease-out;
}
@keyframes iplay-flash {
  0%   { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.35); }
  60%  { box-shadow: 0 0 0 10px rgba(255, 209, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); }
}

.clip-viewer { display: flex; flex-direction: column; gap: 0.6rem; }
.clip-controls {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  background: var(--bg-elev);
  padding: 0.5rem 0.75rem; border-radius: 6px;
}
.clip-controls input[type=range] { accent-color: var(--accent-green); min-width: 120px; }
.clip-controls .btn.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.clip-meta {
  padding: 0.6rem 0.85rem;
  background: var(--bg-elev);
  border-radius: 6px;
  line-height: 1.5;
}
.clip-meta .chip { margin: 0 0.1rem; }

/* Scrub bar markers (goal + event ticks below the slider) */
.scrub-wrap { display: flex; flex-direction: column; }
.scrub-markers {
  position: relative;
  height: 10px;
  margin-top: 2px;
}
.scrub-markers .marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 10px;
  transform: translateX(-1px);
}
.scrub-markers .marker.event {
  background: var(--text-dim, #7f8896);
  opacity: 0.55;
}
.scrub-markers .marker.goal {
  background: #ffd166;
  width: 4px;
  height: 12px;
  transform: translateX(-2px);
  box-shadow: 0 0 6px rgba(255, 209, 102, 0.7);
}

/* Per-frame event strip */
.event-strip {
  padding: 0.5rem 0.85rem;
  background: var(--bg-elev);
  border-left: 3px solid var(--text-dim, #7f8896);
  border-radius: 4px;
  font-size: 0.9rem;
  min-height: 1.4em;
  line-height: 1.4;
}
.event-strip.muted {
  color: var(--text-dim, #7f8896);
  border-left-color: transparent;
  background: transparent;
  padding-left: 0;
}
.event-strip.goal {
  background: rgba(255, 209, 102, 0.12);
  border-left-color: #ffd166;
  color: #ffd166;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

/* Top-attended row inside clip-meta */
.top-attn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.top-attn-row .chip {
  font-size: 0.82rem;
  padding: 0.18rem 0.5rem;
}

@media (max-width: 600px) {
  .clip-controls { gap: 0.3rem; }
  .clip-controls input[type=range] { min-width: 100%; order: 2; }
  .scrub-wrap { width: 100%; order: 2; }
}

/* Buttons */
.btn {
  display: inline-block;
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn.primary {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}
.btn.primary:hover { background: #1ea247; }

/* Form controls */
input[type="text"],
input[type="search"],
input[type="number"],
select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-family: var(--font);
  width: 100%;
  max-width: 100%;
}
input[type="range"] { width: 100%; }
input:focus, select:focus {
  outline: 2px solid var(--accent-green);
  outline-offset: -1px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  margin-bottom: 1rem;
}
@media (min-width: 600px) {
  .controls { grid-template-columns: 2fr 1fr 1fr; }
}

/* A "primary control" — used by Team Maps to make the team-focus dropdown
   read as a first-class entry point. Bigger font, accent border on focus,
   subtle highlight at rest so it visibly leads the row. */
.controls .primary-control select,
.controls .primary-control input {
  font-size: 1rem;
  font-weight: 500;
  border-color: var(--accent-green-soft);
  background: linear-gradient(180deg,
    rgba(26, 138, 58, 0.06) 0%,
    var(--bg-elev-2) 100%);
}
.controls .primary-control label {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Tables (with mobile card fallback)
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table th {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.data-table th:hover { color: var(--text); }
table.data-table th .sort-ind {
  color: var(--text-mute);
  font-size: 0.7em;
  margin-left: 0.3em;
}
table.data-table tbody tr:hover { background: var(--bg-elev-2); }
table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table th.num { text-align: right; }

/* Card layout for narrow screens */
@media (max-width: 599px) {
  table.data-table thead { display: none; }
  table.data-table,
  table.data-table tbody,
  table.data-table tr,
  table.data-table td {
    display: block;
    width: 100%;
  }
  table.data-table tr {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.2rem;
  }
  table.data-table tr:hover { background: var(--bg-elev); }
  table.data-table td {
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.7rem;
    gap: 0.8rem;
  }
  table.data-table td.num { text-align: right; }
  table.data-table td::before {
    content: attr(data-label);
    color: var(--text-mute);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
  }
}

/* ============================================================
   Team Maps page
   ============================================================ */

.team-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.team-card h3 { margin: 0.1rem 0 0.5rem; display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; }
.team-card .meta { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 0.7rem; }
.team-figs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}
@media (min-width: 768px) {
  .team-figs { grid-template-columns: 1fr 1fr; }
}
.team-fig {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
}
.team-fig .fig-label {
  font-size: 0.75rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.team-fig img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  background: var(--bg);
}
.team-fig .placeholder {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  font-size: 0.85rem;
  background: var(--bg);
  border-radius: 3px;
  border: 1px dashed var(--border);
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 1024px) {
  .team-grid { grid-template-columns: 1fr 1fr; }
}
/* Focused single-team view: maximize the maps. */
.team-grid.focused { grid-template-columns: 1fr; max-width: 920px; margin: 0 auto; }
.team-grid.focused .team-figs { grid-template-columns: 1fr; }

/* ============================================================
   Team Builder (formation pitch)
   ============================================================ */

.pitch {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  max-width: 380px;
  margin: 1rem auto;
  background: linear-gradient(180deg, #143b22 0%, #0e2916 100%);
  border: 2px solid #224a32;
  border-radius: 8px;
  overflow: hidden;
}
.pitch::before {
  content: "";
  position: absolute;
  left: 5%;
  right: 5%;
  top: 50%;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}
.pitch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% - 36px);
  width: 72px;
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  transform: translateX(-50%);
}

/* HTML-only formation-card dot (builder.js / lineup cards). Scoped to
   `div.player-dot` so it can't bleed onto SVG `<circle class="player-dot">`
   elements used by the whiteboard / interactive-plays renderers — applying
   `position: absolute; transform: translate(-50%, -50%)` to SVG circles
   resolves the percentages against the SVG viewport and shoves the dots off
   the pitch entirely. */
div.player-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 76px;
}
div.player-dot .ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-green);
  margin: 0 auto;
  border: 2px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
div.player-dot .name {
  font-size: 0.72rem;
  color: white;
  margin-top: 0.15rem;
  background: rgba(0, 0, 0, 0.55);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  display: inline-block;
  white-space: nowrap;
}
div.player-dot .role {
  font-size: 0.6rem;
  color: var(--text-mute);
  margin-top: 0.1rem;
}

/* ============================================================
   Methodology
   ============================================================ */

.formula {
  background: var(--bg-elev-2);
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--accent-green);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  overflow-x: auto;
}

.grid-5x5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  max-width: 320px;
  margin: 1rem 0;
  background: var(--border);
  padding: 2px;
  border-radius: 4px;
}
.grid-5x5 .cell {
  aspect-ratio: 1 / 1;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border-radius: 2px;
}
.grid-5x5 .cell.def { background: rgba(192, 57, 43, 0.25); color: #e98074; }
.grid-5x5 .cell.mid { background: rgba(245, 158, 11, 0.2); color: #f5c780; }
.grid-5x5 .cell.fwd { background: rgba(26, 138, 58, 0.28); color: #6dd58c; }

/* ============================================================
   Misc
   ============================================================ */

.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 0.85rem; }
.tabular { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.hidden { display: none !important; }

.empty-state {
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-mute);
}
.empty-state strong { color: var(--text-dim); display: block; margin-bottom: 0.3em; }

.tab-bar {
  display: flex;
  gap: 0.3rem;
  margin: 0.8rem 0;
  flex-wrap: wrap;
}
.tab-bar button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab-bar button.active {
  background: var(--accent-green-soft);
  color: #6dd58c;
  border-color: transparent;
}
.tab-bar button:hover { color: var(--text); }

/* FIFA Mode */
.fifa-view { margin-top: 1rem; }
.fifa-table { margin-top: 0.5rem; overflow-x: auto; }
.fifa-data-table th,
.fifa-data-table td { padding: 0.45rem 0.55rem; font-size: 0.88rem; }
.fifa-data-table .team-cell { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.fifa-data-table .chip { padding: 0.1rem 0.45rem; font-size: 0.78rem; }
/* Category chip used in the transformer-chemistry leaderboard */
.cat-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid;
  white-space: nowrap;
}
.attn-tabs button { font-size: 0.85rem; }
.attn-tabs button[data-cat="off"].active   { border-color: #d4793a; color: #d4793a; }
.attn-tabs button[data-cat="def"].active   { border-color: #3b6ea0; color: #3b6ea0; }
.attn-tabs button[data-cat="cross"].active { border-color: #7a4f9a; color: #7a4f9a; }

/* Banner used on the deprecated pages pointing to the unified leaderboard */
.moved-banner {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-green);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 1.2em;
}
.moved-banner a { color: var(--text); }

/* Inline checkbox row used by the leaderboards */
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.toggle-row input { accent-color: var(--accent-green); }

/* Mode bar — bigger, more visible than the inner tab bars */
.mode-bar {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0 1.2rem;
  flex-wrap: wrap;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.mode-bar button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.mode-bar button:hover { color: var(--text); background: var(--bg-elev-2); }
.mode-bar button.active {
  background: var(--accent-green-soft);
  color: #6dd58c;
  border-color: transparent;
}
.mode-section { display: none; }
.mode-section.active { display: block; }

/* Disagreement-mode delta column */
.delta-pos { color: #6dd58c; }
.delta-neg { color: #e98074; }

/* Tufte: chart sits directly on the page. No box, no fill. The data is the
   foreground, the page is the ground. */
.fifa-scatter {
  margin-top: 0.5rem;
}
.fifa-scatter-svg {
  display: block;
  width: 100%;
  height: auto;
}
.scatter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  padding: 0.4rem 0.5rem 0.5rem;
  align-items: center;
}
.scatter-legend .dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.story-card {
  background: var(--bg-elev);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--text-dim, #7f8896);
}
.story-card.over { border-left-color: #54c875; }
.story-card.under { border-left-color: #e07474; }
.story-card header { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.story-card .story-heading { font-size: 0.92rem; margin: 0.3rem 0; }
.story-card.over .story-heading { color: #54c875; }
.story-card.under .story-heading { color: #e07474; }
.story-card p { margin: 0; opacity: 0.85; line-height: 1.45; }

/* Club-vs-national story cards (paired-bar layout) */
#story-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin: 0.5rem 0 1rem;
}
@media (min-width: 720px) {
  #story-cards { grid-template-columns: 1fr 1fr; }
}
#story-cards .story-card { padding: 0.75rem 0.9rem; border-left: 3px solid #6aa3ff; }
#story-cards .story-card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.story-card-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0.9rem;
  align-items: start;
}
@media (max-width: 540px) {
  .story-card-body { grid-template-columns: 1fr; }
  .story-chart { max-width: 320px; }
}
.story-chart { background: rgba(255,255,255,0.02); border-radius: 4px; padding: 0.25rem; }
.story-meta .meta { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.35rem; flex-wrap: wrap; }
.story-numbers { list-style: none; padding: 0; margin: 0 0 0.4rem; font-size: 0.85rem; }
.story-numbers li { padding: 0.18rem 0; }
.story-numbers strong { color: var(--text); }

/* Open-questions chart blocks */
#stages-chart, #mean-scatter {
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  margin: 0.5rem 0;
  overflow-x: auto;
}

.download-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.download-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.download-list li:last-child { border-bottom: none; }
.download-list .file-name { font-family: var(--mono); font-size: 0.85rem; }
.download-list .file-desc { color: var(--text-mute); font-size: 0.8rem; flex: 1; min-width: 0; }

/* ============================================================
   Tufte-style page elements (lede, callout, drawer, sparkline)
   ============================================================ */

.lede {
  font-size: 1.05rem;
  color: var(--text-dim);
  margin: 0.2em 0 1.2em;
  max-width: 60ch;
  line-height: 1.45;
}

.callout {
  border-left: 2px solid var(--text-mute);
  padding: 0.1rem 0 0.1rem 0.9rem;
  margin: 0.4em 0 1em;
  max-width: 64ch;
}
.callout h4 {
  margin: 0.4em 0 0.2em;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.callout p { margin: 0.3em 0 0.6em; color: var(--text-dim); font-size: 0.92rem; }
.callout strong { color: var(--text); }

.method-drawer {
  margin: 2em 0 1em;
  border-top: 1px solid var(--border);
  padding-top: 0.6em;
}
.method-drawer > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.95rem;
  padding: 0.3em 0;
  list-style: none;
}
.method-drawer > summary::-webkit-details-marker { display: none; }
.method-drawer > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-mute);
}
.method-drawer[open] > summary::before { content: "▾ "; }
.method-drawer p { color: var(--text-dim); max-width: 70ch; }
.method-drawer pre { margin-top: 0.6em; }

.bookend {
  margin-top: 2.4em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.95rem;
  max-width: 64ch;
}

.pairs-with-spark {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}
@media (min-width: 760px) {
  .pairs-with-spark {
    grid-template-columns: 320px 1fr;
  }
}

.spark-panel {
  color: var(--text-dim);
  font-size: 0.85rem;
  min-width: 0;
}
.spark-title {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 0.3em;
}
.spark-svg {
  display: block;
  width: 100%;
  max-width: 320px;
  color: var(--text);
}
.spark-caption {
  color: var(--text-mute);
  font-size: 0.78rem;
  margin-top: 0.2em;
  line-height: 1.35;
  max-width: 320px;
}

/* ============================================================
   Overview: inline interactive (attention preview)
   ============================================================ */

.overview-attn-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Attention-pitch PNGs render on a cream/off-white background that clashes
   with the dark theme. We can't re-render them server-side here, so we
   invert + re-hue them: invert lightens dark and darkens light; hue-rotate
   180 brings the colour edges back to where they were. The result is a
   dark pitch with the rust / steel / violet palette intact. Hover restores
   the original image for users who want to read player names crisply. */
.team-card-grid img,
.overview-attn-img {
  filter: invert(1) hue-rotate(180deg) saturate(1.15) brightness(0.95);
  background: var(--bg);
  border-radius: var(--radius-sm);
  transition: filter 0.15s ease;
}
.team-card-grid img:hover,
.overview-attn-img:hover {
  filter: none;
}

/* ============================================================
   "Next" card panel at bottom of page
   ============================================================ */

.next-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 1rem;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-green);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 2rem 0 1rem;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.next-card:hover {
  background: var(--bg-elev-2);
  border-left-color: #6dd58c;
  text-decoration: none;
  transform: translateX(2px);
}
.next-card-thumb {
  width: 96px;
  height: 72px;
  background: linear-gradient(180deg, #143b22 0%, #0e2916 100%);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #224a32;
}
.next-card-thumb-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.next-card-thumb-rows .row {
  display: block;
  height: 6px;
  border-radius: 2px;
  background: rgba(109, 213, 140, 0.85);
}
.next-card-thumb-rows .row.r1 { width: 92%; }
.next-card-thumb-rows .row.r2 { width: 78%; background: rgba(109, 213, 140, 0.65); }
.next-card-thumb-rows .row.r3 { width: 62%; background: rgba(109, 213, 140, 0.55); }
.next-card-thumb-rows .row.r4 { width: 48%; background: rgba(109, 213, 140, 0.45); }
.next-card-thumb-rows .row.r5 { width: 34%; background: rgba(109, 213, 140, 0.35); }
.next-card-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 0.2rem;
}
.next-card-title {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.next-card-blurb {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.45;
}
@media (max-width: 520px) {
  .next-card { grid-template-columns: 72px 1fr; padding: 0.85rem 0.9rem; gap: 0.8rem; }
  .next-card-thumb { width: 72px; height: 56px; padding: 0.4rem; }
  .next-card-thumb-rows .row { height: 5px; }
}

/* ============================================================
   Nucleus networks (Tufte-style chemistry star graph)
   ============================================================ */
.nucleus-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.4fr);
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .nucleus-layout { grid-template-columns: 1fr; }
}
.nucleus-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 720px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.nucleus-row {
  display: grid;
  grid-template-columns: 28px 24px minmax(0, 1fr) auto 72px;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  align-self: stretch;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.nucleus-row .nuc-name,
.nucleus-row .nuc-team {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nucleus-row:hover { background: var(--bg-elev); border-color: rgba(255, 209, 102, 0.25); }
.nucleus-row.active {
  background: var(--bg-elev);
  border-color: #f1ad7a;
  box-shadow: 0 0 0 1px rgba(241, 173, 122, 0.4);
}
.nucleus-row .nuc-rank {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: right;
}
.nucleus-row .nuc-flag img,
.nucleus-row .nuc-flag svg { width: 22px; height: 16px; vertical-align: middle; }
.nucleus-row .nuc-name { font-weight: 600; }
.nucleus-row .nuc-pos {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-left: 0.4rem;
}
.nucleus-row .nuc-team { font-size: 0.85rem; color: var(--text-dim); }
.nucleus-row .nuc-val { font-family: var(--mono); text-align: right; }

.nucleus-detail {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  min-height: 460px;
  display: flex;
  flex-direction: column;
}
.nucleus-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.nucleus-hd-name { font-size: 1.05rem; }
.nucleus-hd-stats {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.nucleus-hd-stats > span { display: inline-flex; align-items: baseline; gap: 0.35rem; }

.nucleus-svg {
  width: 100%;
  height: auto;
  max-width: 600px;
  max-height: 480px;
  display: block;
  margin: 0 auto;
}
/* Font sizes are in SVG user units (viewBox is 560 wide). Calibrated so
   labels read at roughly 11-12px when the SVG renders at typical desktop
   widths. */
.nuc-label {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  fill: var(--text);
}
.nuc-pos-small {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-mute);
  font-weight: 400;
}
.nuc-edge-val {
  font-family: var(--mono);
  font-size: 12px;
  fill: var(--text-dim);
}
.nuc-center-name {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  fill: var(--text);
}
.nuc-center-pos {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-dim);
}

/* ============================================================
   Team networks — atom view (full pair graph per team)
   ============================================================ */
.team-network-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (min-width: 1100px) {
  .team-network-layout {
    grid-template-columns: minmax(360px, 1fr) minmax(420px, 1.5fr);
  }
}
.team-table-pane { min-width: 0; overflow-x: auto; }
.team-atom-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.team-pick-btn {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0 0.2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radius-sm);
  text-decoration: underline dotted var(--text-mute);
  text-underline-offset: 3px;
}
.team-pick-btn:hover { color: #f1ad7a; }
.team-pick-btn.active { color: #f1ad7a; text-decoration: underline solid #f1ad7a; }
.atom-svg {
  width: 100%;
  height: auto;
  max-height: 420px;
  display: block;
}
.atom-label {
  font-family: var(--mono);
  font-size: 2.2px;     /* SVG user units; viewBox 100 wide. Larger so the names actually read at typical rendered sizes. */
  fill: #f1f5f9;
  paint-order: stroke;
  stroke: #0b1220;
  stroke-width: 0.32px;  /* Tighter stroke so labels read sharp, not chunky. */
  stroke-linejoin: round;
}
.atom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.94rem;
  flex-wrap: wrap;
}
.atom-legend { display: flex; gap: 0.8rem; font-family: var(--mono); }
.atom-legend .dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

/* Network-view toggle (Tab 4 case studies) */
.net-view-toggle .net-view-btn {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 0;
  border-right: 1px solid var(--border);
  padding: 0.25rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.net-view-toggle .net-view-btn:last-child { border-right: 0; }
.net-view-toggle .net-view-btn:hover { opacity: 0.95; }
.net-view-toggle .net-view-btn.active {
  background: var(--bg-elev-3, #1a2333);
  color: var(--text);
  opacity: 1;
  font-weight: 600;
}
