/* ===================================================================
   MLS Standings — fresh MLS identity (navy header + blue analytics accent),
   theme-aware light/dark. Distinct from the amber/mono world-cup look.
   =================================================================== */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --card: #ffffff;
  --ink: #0b0b0b;
  --ink-soft: #52514e;
  --muted: #898781;
  --line: #e5e4df;
  --hover: #f5f5f2;

  --navy: #0b2547;
  --navy-2: #123a6b;
  --accent: #2f6fed;        /* vibrant blue */
  --accent-deep: #1d52c4;
  --accent-soft: #eaf1fe;
  --shield: #c9a227;        /* Supporters' Shield gold */
  --shield-soft: #faf4df;

  /* xGD diverging poles (validated blue <-> red, gray midpoint) */
  --pos: 47, 111, 237;      /* blue  rgb */
  --neg: 227, 73, 72;       /* red   rgb */

  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
          "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --card: #1a1a19;
    --ink: #ffffff;
    --ink-soft: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --hover: #232322;
    --navy: #0a1f3d;
    --navy-2: #0f2f57;
    --accent: #4d84f5;
    --accent-deep: #6c9bf7;
    --accent-soft: #14233d;
    --shield-soft: #2a2410;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --card: #1a1a19; --ink: #ffffff; --ink-soft: #c3c2b7;
  --muted: #898781; --line: #2c2c2a; --hover: #232322;
  --navy: #0a1f3d; --navy-2: #0f2f57; --accent: #4d84f5; --accent-deep: #6c9bf7;
  --accent-soft: #14233d; --shield-soft: #2a2410; --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 24px;
  padding-left: max(24px, calc((100% - 1180px) / 2 + 24px));
  padding-right: max(24px, calc((100% - 1180px) / 2 + 24px));
}
.logo { height: 38px; width: auto; flex: none; }
.site-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* ---------- subheader (description, in the whitespace) ---------- */
.subhead {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 6px;
}
.tagline { margin: 0; color: var(--ink-soft); font-size: 14px; }
.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meta b { color: var(--ink); font-weight: 700; }

/* ---------- tabs ---------- */
.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tab {
  appearance: none; border: none; background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- panels ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px; padding-bottom: 60px; }
.panel { display: none; }
.panel.is-active { display: block; }
.panel-intro {
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 780px;
  margin: 0 0 20px;
  line-height: 1.6;
}
.panel-intro b { color: var(--ink); font-weight: 700; }

/* ---------- action bar ---------- */
.panel-actions {
  display: flex; gap: 8px; align-items: center;
  margin: 0 0 16px; flex-wrap: wrap;
}
.dl-btn {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.dl-btn:hover { color: var(--accent-deep); border-color: var(--accent); background: var(--accent-soft); }
.dl-btn:disabled { opacity: .55; cursor: default; }
.legend {
  display: flex; gap: 14px; margin-left: auto; align-items: center;
  font-size: 11px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw-pos { background: rgb(var(--pos)); }
.sw-neg { background: rgb(var(--neg)); }

/* ---------- standings table ---------- */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.std-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.std-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 12px 9px;
  text-align: right;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.std-table thead th.col-rank,
.std-table thead th.col-team { text-align: left; }
.std-table thead th.sorted { color: var(--accent); }
.std-table thead th .arrow { font-size: 9px; margin-left: 2px; }

.std-table tbody td {
  padding: 9px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.std-table tbody tr:last-child td { border-bottom: none; }
.std-table tbody tr:hover td { background: var(--hover); }

td.col-rank { color: var(--muted); font-weight: 600; width: 34px; text-align: left; }
td.col-team { text-align: left; }
.cell-team { display: flex; align-items: center; gap: 10px; }
.cell-team .crest { width: 26px; height: 26px; object-fit: contain; flex: none; }
.cell-team .nm { font-weight: 700; color: var(--ink); }
.cell-team .conf-chip {
  font-size: 10px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
  text-transform: uppercase; letter-spacing: .03em;
}
.col-pts { font-weight: 800; color: var(--ink); }
.col-sub { color: var(--ink-soft); }
.gd-pos { color: #0b7a37; }
.gd-neg { color: #b4322f; }
:root[data-theme="dark"] .gd-pos, :root:where(:not([data-theme="light"])) .gd-pos { color: #37c46b; }
:root[data-theme="dark"] .gd-neg, :root:where(:not([data-theme="light"])) .gd-neg { color: #f0706d; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .gd-pos { color: #37c46b; }
  :root:where(:not([data-theme="light"])) .gd-neg { color: #f0706d; }
}

/* xGD diverging cell */
td.col-xgd { font-weight: 700; color: var(--ink); border-radius: 0; }

/* simulation probability cells */
th.col-pct, td.col-pct { min-width: 74px; }
td.col-pct { font-weight: 700; color: var(--ink); }
td.col-pct.pct-zero { color: #c7c7c7; font-weight: 400; }
:root[data-theme="dark"] td.col-pct.pct-zero,
:root:where(:not([data-theme="light"])) td.col-pct.pct-zero { color: #5a5a58; }

/* shield leader + playoff line */
tr.shield-leader td { background: var(--shield-soft) !important; }
tr.shield-leader td.col-team .nm::after {
  content: "◆"; color: var(--shield); font-size: 10px; margin-left: 7px;
  vertical-align: middle;
}
tr.playoff-line td { border-bottom: 1px solid var(--ink); }
tr.playoff-caption td {
  padding: 4px 9px; text-align: left;
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink);
  background: var(--hover); border-bottom: 1px solid var(--line);
}

/* ---------- matches ---------- */
.match-legend {
  display: flex; gap: 16px; align-items: center;
  font-size: 11px; color: var(--muted); margin: 0 0 8px;
}
.match-legend span { display: inline-flex; align-items: center; gap: 6px; }
.match-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.match-section {
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin: 26px 0 10px;
}
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-date {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin: 16px 0 4px;
}
.match-date:first-child { margin-top: 0; }
.match-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 11px 16px;
}
.match-card.is-played { background: var(--hover); }
.match {
  display: grid; grid-template-columns: 1fr minmax(140px, 280px) 1fr;
  align-items: center; gap: 14px;
}
.m-team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-team-a { justify-content: flex-end; text-align: right; }
.m-team-b { justify-content: flex-start; text-align: left; }
.m-team .crest { width: 30px; height: 30px; object-fit: contain; flex: none; }
.m-name-wrap { display: flex; flex-direction: column; min-width: 0; }
.m-team-a .m-name-wrap { align-items: flex-end; }
.m-team-b .m-name-wrap { align-items: flex-start; }
.m-name {
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.match-card.is-played .m-team:not(.win) .m-name { color: var(--ink-soft); }
.m-xg {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--muted);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.m-bar {
  display: flex; height: 22px; border-radius: 5px;
  overflow: hidden; background: var(--line);
}
.seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums; overflow: hidden;
  white-space: nowrap; min-width: 0;
}
.seg-home { background: rgb(var(--pos)); }
.seg-draw { background: #b8b6ad; color: #3a382f; }
.seg-away { background: rgb(var(--neg)); }
.m-score {
  text-align: center; font-size: 19px; font-weight: 800;
  letter-spacing: 0.03em; font-variant-numeric: tabular-nums; color: var(--ink);
}
@media (max-width: 560px) {
  .match { grid-template-columns: 1fr; gap: 8px; }
  .m-team-a, .m-team-b { justify-content: flex-start; text-align: left; }
  .m-team-a .m-name-wrap { align-items: flex-start; }
}

/* ---------- how this works ---------- */
.explainer { max-width: 720px; font-size: 15px; line-height: 1.7; color: var(--ink-soft); }
.explainer .lead {
  font-size: 17px; line-height: 1.6; color: var(--ink);
  border-left: 3px solid var(--accent); padding-left: 16px; margin: 0 0 28px;
}
.explainer h2 {
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--accent-deep); margin: 26px 0 8px;
}
.explainer p { margin: 0 0 14px; }
.explainer b { color: var(--ink); font-weight: 700; }

/* ---------- footer ---------- */
.site-footer {
  max-width: 1180px; margin: 0 auto;
  padding: 20px 24px 48px;
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
}
.site-footer .footer-text { line-height: 1.6; }
.site-footer strong { color: var(--ink-soft); }
.btp-badge { flex: none; line-height: 0; }
.btp-badge img {
  height: 52px; width: auto; border-radius: 10px;
  transition: transform .15s, box-shadow .15s;
}
.btp-badge:hover img { transform: translateY(-1px); box-shadow: var(--shadow); }

@media (max-width: 620px) {
  .site-footer { flex-direction: column; align-items: flex-start; }
  .legend { width: 100%; margin-left: 0; }
}
