  :root {
    --felt: #143026;
    --felt-2: #1a3a2d;
    --chalk: #e9ece2;
    --chalk-dim: #a6b3a9;
    --brass: #cc9f42;
    --brass-dim: #8a6c2c;
    --up: #57b57c;
    --up-bg: rgba(87, 181, 124, 0.12);
    --down: #d17662;
    --down-bg: rgba(209, 118, 98, 0.12);
    --line: rgba(233, 236, 226, 0.13);
    --card: rgba(255, 255, 255, 0.035);
    --card-hi: rgba(255, 255, 255, 0.06);
    --shadow: rgba(0, 0, 0, 0.4);

    --display: Rockwell, "Roboto Slab", Georgia, serif;
    --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  }

  @media (prefers-color-scheme: light) {
    :root {
      --felt: #eef1e7;
      --felt-2: #e2e8da;
      --chalk: #172319;
      --chalk-dim: #55665a;
      --brass: #96712a;
      --brass-dim: #b28f42;
      --up: #2c7a4d;
      --up-bg: rgba(44, 122, 77, 0.10);
      --down: #a34430;
      --down-bg: rgba(163, 68, 48, 0.10);
      --line: rgba(23, 35, 25, 0.12);
      --card: rgba(20, 30, 20, 0.03);
      --card-hi: rgba(20, 30, 20, 0.06);
      --shadow: rgba(30, 40, 30, 0.12);
    }
  }

  :root[data-theme="dark"] {
    --felt: #143026; --felt-2: #1a3a2d; --chalk: #e9ece2; --chalk-dim: #a6b3a9;
    --brass: #cc9f42; --brass-dim: #8a6c2c;
    --up: #57b57c; --up-bg: rgba(87, 181, 124, 0.12);
    --down: #d17662; --down-bg: rgba(209, 118, 98, 0.12);
    --line: rgba(233, 236, 226, 0.13); --card: rgba(255, 255, 255, 0.035);
    --card-hi: rgba(255, 255, 255, 0.06); --shadow: rgba(0, 0, 0, 0.4);
  }
  :root[data-theme="light"] {
    --felt: #eef1e7; --felt-2: #e2e8da; --chalk: #172319; --chalk-dim: #55665a;
    --brass: #96712a; --brass-dim: #b28f42;
    --up: #2c7a4d; --up-bg: rgba(44, 122, 77, 0.10);
    --down: #a34430; --down-bg: rgba(163, 68, 48, 0.10);
    --line: rgba(23, 35, 25, 0.12); --card: rgba(20, 30, 20, 0.03);
    --card-hi: rgba(20, 30, 20, 0.06); --shadow: rgba(30, 40, 30, 0.12);
  }

  * { box-sizing: border-box; }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

  html, body { margin: 0; background: var(--felt); color: var(--chalk); font-family: var(--body); line-height: 1.5; }

  a { color: inherit; }

  /* ---------------- app shell ---------------- */
  .app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

  .sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 200px;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sidebar-home {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--brass);
    background: none;
    border: none;
    border-bottom: 2px solid var(--brass-dim);
    padding: 4px 8px 12px;
    margin-bottom: 10px;
    cursor: pointer;
    text-align: left;
  }
  .sidebar-home:hover { color: var(--chalk); }
  .sidebar-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--chalk-dim);
    padding: 8px 8px 2px;
  }
  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    color: var(--chalk-dim);
    font-family: var(--body);
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
  }
  .sidebar-link-icon {
    flex: none;
    width: 1.2em;
    text-align: center;
    font-size: 0.95em;
  }
  .sidebar-link-icon svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
  }
  .sidebar-link:hover { color: var(--chalk); background: var(--card); }
  .sidebar-link.active { color: var(--chalk); background: var(--card-hi); border-left-color: var(--brass); font-weight: 600; }
  .sidebar-link { cursor: grab; -webkit-user-select: none; user-select: none; }
  .sidebar-link.dragging { opacity: 0.4; cursor: grabbing; }
  .sidebar-link:focus-visible, .sidebar-home:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }

  .main-content { flex: 1 1 auto; min-width: 0; padding: clamp(20px, 3.5vw, 48px); }
  .wrap { max-width: 980px; margin: 0 auto; }

  .view { display: none; }
  .view.active { display: block; }
  .boot-loading {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--chalk-dim);
    padding: 60px 0;
    text-align: center;
  }
  .boot-loading.hidden { display: none; }

  @media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
    .sidebar-home { border-bottom: none; margin-bottom: 0; padding: 4px 8px; }
    .sidebar-label { display: none; }
  }

  /* ---------------- shared header / stats ---------------- */
  header.page {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    border-bottom: 2px solid var(--brass-dim);
    padding-bottom: 20px;
    margin-bottom: 28px;
  }
  .eyebrow {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brass);
    margin: 0 0 8px;
  }
  h1 {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(1.7rem, 3.4vw, 2.4rem);
    margin: 0;
    text-wrap: balance;
    letter-spacing: 0.01em;
  }
  h2.section-title {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.4rem;
    margin: 0 0 6px;
  }
  p.section-sub { color: var(--chalk-dim); font-size: 0.9rem; margin: 0 0 24px; max-width: 62ch; }
  .page-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--chalk-dim);
    text-align: right;
    line-height: 1.6;
  }
  .page-stats b { color: var(--chalk); font-variant-numeric: tabular-nums; }

  .refresh-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: var(--card); border: 1px solid var(--brass-dim); border-radius: 8px;
    padding: 6px 14px; cursor: pointer; color: var(--brass);
  }
  .refresh-btn:hover { background: var(--card-hi); border-color: var(--brass); }
  .refresh-btn:disabled { cursor: not-allowed; opacity: 0.75; }
  .refresh-icon { width: 18px; height: 18px; }
  .refresh-btn.refresh-running .refresh-icon { animation: refresh-spin 1s linear infinite; }
  @keyframes refresh-spin { to { transform: rotate(360deg); } }
  .refresh-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
  .refresh-btn.refresh-success { border-color: var(--up); color: var(--up); }
  .refresh-btn.refresh-failure { border-color: var(--down); color: var(--down); }

  section.block { margin-bottom: 32px; }

  /* ---------------- home nav cards ---------------- */
  .nav-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 36px; }
  .nav-card {
    display: block;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: 4px;
    padding: 20px;
    cursor: pointer;
    font-family: var(--body);
    color: var(--chalk);
  }
  .nav-card:hover { background: var(--card-hi); border-left-color: var(--chalk); }
  .nav-card:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
  .nav-card { cursor: grab; -webkit-user-select: none; user-select: none; }
  .nav-card.dragging { opacity: 0.4; cursor: grabbing; }
  .nav-card h3 { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 1.15rem; margin: 0 0 6px; color: var(--brass); }
  .nav-card p { margin: 0; font-size: 0.85rem; color: var(--chalk-dim); line-height: 1.5; }
  .nav-card-icon { flex: none; width: 1.1em; text-align: center; }
  .nav-card-icon svg { width: 1em; height: 1em; vertical-align: -0.15em; }

  /* ---------------- standing card ---------------- */
  .standing {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brass);
    border-radius: 4px;
    padding: 18px 20px;
    display: grid;
    gap: 14px;
  }
  .standing h2 { font-family: var(--display); font-size: 1rem; margin: 0; color: var(--brass); font-weight: 700; }
  .standing-rows { display: flex; flex-wrap: wrap; gap: 12px; }
  .standing-card {
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--card-hi);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 10px 14px;
  }
  .standing-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .standing-name-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 3px;
  }
  .standing-name-link:hover .gt { color: var(--brass); }
  .standing-name-link:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
  .standing-card .gt { font-size: 0.85rem; color: var(--chalk); }
  .standing-card .stale-note { display: block; font-size: 0.72rem; color: var(--chalk-dim); margin-top: 2px; }
  /* APA Lifetime Stats cards on the profile: label left, value right, like
     the right-hand section of APA's own STATS tab. */
  .apa-stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; margin: 4px 0 2px; font-size: 0.82rem; }
  .apa-stats dt { color: var(--chalk-dim); }
  .apa-stats dd { margin: 0; text-align: right; font-family: var(--mono); color: var(--chalk); }
  .standing-score-wrap {
    display: block;
    text-align: right;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 3px;
  }
  .standing-score-wrap:hover { background: var(--card); }
  .standing-score-wrap:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
  .standing-score-label {
    display: block;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: 2px;
  }
  .standing-score { font-family: var(--mono); font-weight: 600; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
  .standing-score.pos { color: var(--up); }
  .standing-score.neg { color: var(--down); }
  .standing-rankchange {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--chalk-dim);
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid var(--line);
    padding-top: 6px;
  }
  .standing-rankchange .val { color: var(--chalk); font-weight: 600; }

  /* ---------------- filters ---------------- */
  .filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
  .filter-field { display: flex; flex-direction: column; gap: 4px; }
  .filter-field label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--chalk-dim); }
  .filter-field select, input[type="search"] {
    font-family: var(--body);
    font-size: 0.86rem;
    background: var(--card-hi);
    color: var(--chalk);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
  }
  .filter-field select { cursor: pointer; appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--brass) 50%), linear-gradient(135deg, var(--brass) 50%, transparent 50%);
    background-position: calc(100% - 16px) center, calc(100% - 11px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
  }
  .filter-field select:hover { border-color: var(--brass-dim); }
  .filter-field select:focus-visible, input[type="search"]:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
  .filter-field select option { background: var(--felt-2); color: var(--chalk); }
  .filter-field .combo-input {
    font-family: var(--body);
    font-size: 0.86rem;
    background: var(--card-hi);
    color: var(--chalk);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 22px 8px 10px;
    width: 100%;
    cursor: text;
  }
  .filter-field .combo-input:hover { border-color: var(--brass-dim); }
  .filter-field .combo-input:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
  .filter-field .combo-input.filter-active { color: var(--brass); border-color: var(--brass-dim); }
  .filter-summary { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); margin-bottom: 20px; }
  .filter-summary button { font-family: var(--mono); font-size: 0.72rem; background: none; border: none; color: var(--brass); cursor: pointer; text-decoration: underline; padding: 0; margin-left: 8px; }
  .filter-summary button:hover { color: var(--chalk); }

  /* ---------------- rank-changes board ---------------- */
  .board { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  @media (max-width: 680px) { .board { grid-template-columns: 1fr; } }
  .col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .col-head h3 { font-family: var(--display); font-size: 1.05rem; margin: 0; letter-spacing: 0.01em; }
  .col-up .col-head h3 { color: var(--up); }
  .col-down .col-head h3 { color: var(--down); }
  .col-head span { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); }
  .row {
    display: grid;
    grid-template-columns: 1.6em 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 9px 4px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
  }
  .row:last-child { border-bottom: none; }
  .row:hover { background: var(--card); }
  .row:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
  .rank-num { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); text-align: right; }
  .row-name { font-size: 0.92rem; }
  .row-meta { grid-column: 2 / 3; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
  /* Fill grows out from the baseline tick (the scoring formula's 0.5069
     neutral point, see the leaderboard footer) toward the dot marking the
     player's actual point share -- left+red below baseline, right+green
     above it -- rather than always filling from the container's edge, so
     the bar reads as a deviation the same way the score itself is one.
     overflow:visible (not hidden) so the dot, taller than the 5px track,
     isn't clipped. */
  .meter { position: relative; flex: 1 1 auto; height: 5px; background: var(--line); border-radius: 3px; overflow: visible; min-width: 60px; }
  .meter .fill { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
  .col-up .meter .fill { background: var(--up); }
  .col-down .meter .fill { background: var(--down); }
  .meter .baseline { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--brass); opacity: 0.7; }
  .meter .dot {
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1.5px solid var(--felt);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  }
  .col-up .meter .dot { background: var(--up); }
  .col-down .meter .dot { background: var(--down); }
  .row-conf { font-family: var(--mono); font-size: 0.65rem; color: var(--chalk-dim); white-space: nowrap; }
  .row-rank { font-family: var(--mono); font-size: 0.66rem; color: var(--brass); white-space: nowrap; border: 1px solid var(--brass-dim); border-radius: 3px; padding: 1px 5px; }
  .locked-floor { font-family: var(--mono); font-size: 0.66rem; color: var(--brass); white-space: nowrap; border: 1px solid var(--brass-dim); border-radius: 3px; padding: 1px 5px; margin-left: 4px; background: rgba(204, 159, 66, 0.12); }
  .locked-floor a { color: inherit; text-decoration: underline dotted; cursor: pointer; }
  .locked-floor a:hover { color: var(--chalk); text-decoration-style: solid; }
  /* width/height: 1em (overriding the SVG's own 15x15 attributes -- CSS
     wins over presentation attributes for properties that are also CSS
     properties) so the ball scales with whatever text size it sits next
     to, from a table cell up to a giant h1, instead of staying a fixed
     15px everywhere. vertical-align in em for the same reason -- a fixed
     -2px nudge tuned for ~15px text looks barely-adjusted next to a much
     bigger heading. */
  .ball-icon { width: 1em; height: 1em; vertical-align: -0.15em; flex: none; }
  .meta-label { color: var(--chalk-dim); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.6rem; }
  .row-rankchange { grid-column: 2 / 3; font-family: var(--mono); font-size: 0.66rem; color: var(--chalk-dim); margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
  .row-rankchange .val { color: var(--chalk); font-weight: 600; }
  .row-score { font-family: var(--mono); font-weight: 600; font-size: 1rem; font-variant-numeric: tabular-nums; text-align: right; }
  .col-up .row-score { color: var(--up); }
  .col-down .row-score { color: var(--down); }
  .row-score-pending { color: var(--chalk-dim); }
  .row-pending { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); font-style: italic; flex: 1 1 auto; }
  .empty { font-size: 0.85rem; color: var(--chalk-dim); font-style: italic; padding: 20px 4px; }

  /* ---------------- player profiles search ---------------- */
  .search-box { margin-bottom: 20px; }
  .search-box input { width: 100%; max-width: 420px; }
  .search-box-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; }
  .search-box-row input[type="search"] { flex: 1 1 auto; }
  .search-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--chalk-dim);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
  }
  .search-toggle:hover { color: var(--chalk); }
  .toggle-switch { position: relative; display: inline-block; flex: none; width: 34px; height: 19px; }
  .toggle-switch input[type="checkbox"] {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
  }
  .toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--card-hi);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--chalk-dim);
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .toggle-switch input[type="checkbox"]:checked + .toggle-slider { background: var(--up-bg); border-color: var(--up); }
  .toggle-switch input[type="checkbox"]:checked + .toggle-slider::before { transform: translateX(15px); background: var(--up); }
  .toggle-switch input[type="checkbox"]:focus-visible + .toggle-slider { outline: 2px solid var(--brass); outline-offset: 2px; }
  .search-toggle:hover .toggle-slider { border-color: var(--brass-dim); }
  .search-count { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); margin-bottom: 14px; }
  .team-status { font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; white-space: nowrap; vertical-align: middle; }
  .team-status.current { color: var(--up); border: 1px solid var(--up); background: var(--up-bg); }
  .team-status.past { color: var(--chalk-dim); border: 1px solid var(--line); }
  .team-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
  .team-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    min-width: 140px;
  }
  .team-stat-label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chalk-dim); }
  .team-stat-value { font-family: var(--mono); font-size: 1.1rem; font-weight: 600; color: var(--chalk); font-variant-numeric: tabular-nums; }
  .team-stat-sub { font-size: 0.7rem; font-weight: 400; color: var(--chalk-dim); }
  .team-stat-link { text-decoration: none; cursor: pointer; transition: border-color 0.15s ease; }
  .team-stat-link:hover { border-color: var(--brass); }
  .team-stat-link:hover .team-stat-label { color: var(--brass); }
  .profile-results { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
  .profile-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
  }
  .profile-result:hover { background: var(--card); }
  .profile-result .name { font-size: 0.94rem; }
  .profile-result .teams { font-family: var(--mono); font-size: 0.7rem; color: var(--chalk-dim); text-align: right; }

  /* ---------------- profile detail ---------------- */
  .profile-back { display: inline-block; font-family: var(--mono); font-size: 0.76rem; color: var(--brass); text-decoration: none; margin-bottom: 16px; cursor: pointer; background: none; border: none; padding: 0; }
  .profile-back:hover { text-decoration: underline; }
  .profile-header { border-bottom: 2px solid var(--brass-dim); padding-bottom: 18px; margin-bottom: 24px; }
  .profile-header h1 { margin-bottom: 4px; }
  .profile-header .sub { font-family: var(--mono); font-size: 0.78rem; color: var(--chalk-dim); margin-top: 4px; }
  .sub a { color: var(--brass); text-decoration: none; border-bottom: 1px dotted var(--brass-dim); cursor: pointer; }
  .sub a:hover { color: var(--chalk); border-bottom-style: solid; }
  .profile-teams-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0 0 0 18px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--chalk-dim);
  }
  .profile-teams-list li { margin-top: 3px; }
  .profile-teams-list a { color: var(--brass); text-decoration: none; border-bottom: 1px dotted var(--brass-dim); cursor: pointer; }
  .profile-teams-list a:hover { color: var(--chalk); border-bottom-style: solid; }
  .profile-teams-list li.roster-left { color: var(--chalk-dim); font-style: italic; }
  .profile-teams-list li.roster-left a { color: var(--chalk-dim); border-bottom-color: var(--line); }
  .profile-teams-list li.roster-left a:hover { color: var(--chalk); border-bottom-color: var(--brass-dim); }
  .team-history-btn { font: inherit; color: var(--brass); background: none; border: none; border-bottom: 1px dotted var(--brass-dim); padding: 0; cursor: pointer; }
  .team-history-btn:hover { color: var(--chalk); border-bottom-style: solid; }
  .profile-summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 32px; }

  /* ---------------- running win/loss chart ---------------- */
  .wl-trend { margin-bottom: 32px; }
  .wl-head { display: flex; align-items: center; justify-content: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
  .wl-head h2 { margin: 0; }
  .wl-current-wrap { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
  .wl-current-label { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass); }
  .wl-current { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
  .wl-current.pos { color: var(--up); }
  .wl-current.neg { color: var(--down); }
  .wl-current.zero { color: var(--chalk-dim); }
  #wl-gametype {
    font-family: var(--body);
    font-size: 0.82rem;
    background: var(--card-hi);
    color: var(--chalk);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 5px 8px;
    cursor: pointer;
  }
  #wl-gametype option { background: var(--felt-2); color: var(--chalk); }
  .wl-canvas-wrap {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 10px;
  }
  #wl-canvas { display: block; width: 100%; height: 200px; cursor: grab; }
  .wl-tooltip {
    position: absolute;
    display: none;
    background: var(--felt-2);
    border: 1px solid var(--brass-dim);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--chalk);
    white-space: nowrap;
    z-index: 5;
    box-shadow: 0 3px 10px var(--shadow);
    pointer-events: auto;
  }
  .wl-tooltip .wl-tt-date { display: block; color: var(--chalk-dim); margin-bottom: 4px; }
  .wl-tooltip .wl-tt-row { display: block; margin-top: 2px; }
  .wl-tooltip .wl-tt-row:first-of-type { margin-top: 0; }
  .wl-tooltip a { color: var(--brass); text-decoration: underline; cursor: pointer; }
  .wl-tooltip a:hover { color: var(--chalk); }
  .wl-tooltip .wl-tt-delta.pos { color: var(--up); }
  .wl-tooltip .wl-tt-delta.neg { color: var(--down); }
  .wl-zoom-controls {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--felt-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 3px 6px;
  }
  .wl-zoom-btn {
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    background: none;
    border: 1px solid var(--brass-dim);
    border-radius: 3px;
    color: var(--brass);
    font-family: var(--mono);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
  }
  .wl-zoom-btn:hover:not(:disabled) { background: var(--brass); color: var(--felt); }
  .wl-zoom-btn:disabled { opacity: 0.35; cursor: not-allowed; }
  .wl-zoom-btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
  .wl-zoom-count { font-family: var(--mono); font-size: 0.66rem; color: var(--chalk-dim); white-space: nowrap; min-width: 62px; text-align: center; }
  .wl-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 8px; }
  .wl-legend-item { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.7rem; color: var(--chalk-dim); }
  .wl-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
  .wl-range-label { font-family: var(--mono); font-size: 0.7rem; color: var(--chalk-dim); text-align: center; margin-top: 6px; }
  .wl-controls { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
  .wl-control-row { display: grid; grid-template-columns: 52px 1fr 84px; align-items: center; gap: 10px; }
  .wl-control-row label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chalk-dim); }
  .wl-control-row span.wl-value { font-family: var(--mono); font-size: 0.68rem; color: var(--chalk-dim); text-align: right; }
  .wl-control-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    cursor: pointer;
  }
  .wl-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brass);
    cursor: pointer;
    border: 2px solid var(--felt);
  }
  .wl-control-row input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brass);
    cursor: pointer;
    border: 2px solid var(--felt);
  }
  .wl-control-row input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }
  .wl-control-row input[type="range"]:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
  .history-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
  table.history-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; min-width: 760px; table-layout: fixed; }
  /* Column widths sized to actual content -- rank columns hold one digit, not
     a full "SL 5" label at header width, so they don't need as much room as
     the auto-layout default gave them. */
  table.history-table col.col-date       { width: 92px; }
  table.history-table col.col-gametype   { width: 108px; }
  /* Result/Score/Rank widened from their original 64/60/72px -- the label
     now sits beside its sort button instead of stacked above it, so each
     needs enough room for "RESULT ⇅" etc. on one line instead of just the
     word alone, or it wraps mid-word ("RESU"/"LT") instead of cleanly. */
  table.history-table col.col-result     { width: 92px; }
  table.history-table col.col-score      { width: 82px; }
  table.history-table col.col-rank       { width: 80px; }
  table.history-table col.col-opprank    { width: 92px; }
  table.history-table col.col-change     { width: 84px; }
  table.history-table col.col-date-mid   { width: 110px; }
  table.history-table col.col-status     { width: 92px; }
  table.history-table col.col-sim        { width: 108px; }
  table.history-table col.col-diff       { width: 88px; }
  table.history-table col.col-team,
  table.history-table col.col-division,
  table.history-table col.col-opponent,
  table.history-table col.col-oppteam    { width: auto; }
  /* Anomalies-specific column widths, scoped so they don't also widen
     Match History's narrower Result column, which is fine as-is. Now that
     header labels wrap onto a row of their own (see .th-label-row) instead
     of needing to fit alongside a select on one line, these columns only
     need to be as wide as their actual data -- Opp Rank in particular no
     longer needs extra room just to avoid truncating "Opp Rank" and can
     use the same narrow width Match History's own rank columns use. */
  #anomalies-table col.col-result        { width: 108px; } /* carries the score too, e.g. "Loss 6–14" */
  #anomalies-table col.col-change        { width: 76px; }
  /* Possible Manual Adjustments: everything fixed-width except Why It
     Stands Out, which takes whatever is left. */
  #manual-adj-table col.col-team         { width: 132px; }
  #manual-adj-table col.col-gametype     { width: 84px; }
  #manual-adj-table col.col-change       { width: 84px; }
  #manual-adj-table col.col-status       { width: 120px; }
  #manual-adj-table col.col-reason       { width: auto; }
  #manual-adj-table col.col-chance       { width: 96px; }
  #manual-adj-table col.col-context      { width: 132px; }
  #manual-adj-table col.col-when         { width: 172px; }
  #manual-adj-table .muted, #name-changes-table .muted { color: var(--chalk-dim); }
  #name-changes-table col.col-date-mid   { width: 140px; }
  #name-changes-table col.col-status     { width: 150px; }
  #team-history-table col.col-date-mid   { width: 120px; }
  #team-history-table col.col-rank       { width: 84px; }
  #team-history-table col.col-result     { width: 84px; }
  #team-history-table col.col-status     { width: 108px; }
  .confidence-badge {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; border: 1px solid currentColor;
  }
  .confidence-high { color: var(--down); background: var(--down-bg); }
  .confidence-medium { color: var(--brass); }
  .confidence-low { color: var(--chalk-dim); }
  table.history-table td.wrap-cell { white-space: normal; word-break: break-word; }
  #hf-rank, #hf-opprank { max-width: 54px; }
  #hf-result, #hf-gametype { max-width: 78px; }
  table.history-table th {
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--chalk-dim);
    text-align: center;
    /* Columns without a filter select (Date, Score) have one line less
       content than the ones with "ALL ⌄" underneath -- table cells default
       to vertical-align:middle, which centers each cell's content within
       the row's shared height (set by the tallest cell), so the shorter
       columns' labels sat lower than the taller columns'. Top-anchor every
       header instead so labels line up regardless of how many rows a
       given column's content has. */
    vertical-align: top;
    padding: 8px;
    border-bottom: 1px solid var(--brass-dim);
    background: var(--card);
    position: sticky;
    top: 0;
    /* table-layout:fixed locks each column to its <col> width regardless of
       header content, but that alone doesn't clip anything -- overflow is
       visible by default, so a header wider than its column bleeds into the
       neighboring <th> and the two headers render on top of each other.
       This is the actual clip boundary; text-overflow below turns that into
       a clean ellipsis instead of a hard cut mid-glyph. */
    overflow: hidden;
    /* NOT display:flex here -- confirmed live this breaks a <th> out of the
       table's column layout entirely (its default is display:table-cell;
       overriding that to flex stops it participating in the table's row/
       column algorithm, so every header just stacks vertically down the
       page instead of sitting side by side as columns). The label/button/
       select stacking-and-centering look doesn't actually need the <th>
       itself to be a flex container: .th-label-row and .th-control are
       already block-level flex boxes that span the full cell width, so
       they stack via ordinary block flow as siblings, and each centers its
       own contents internally (see their own rules below). */
  }
  /* Drag handle at a column's right edge -- th's position:sticky already
     establishes a containing block for this, no extra positioning needed
     on the th itself. Sits fully inside the header cell's own box so the
     th's overflow:hidden above doesn't clip it. */
  .col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 2;
  }
  .col-resize-handle:hover, body.col-resizing .col-resize-handle {
    background: var(--brass-dim);
  }
  body.col-resizing { cursor: col-resize; user-select: none; }
  .th-control {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    width: 100%;
    /* Flex items don't shrink below their content's intrinsic width by
       default (min-width:auto) even with max-width set on a child -- that
       intrinsic width is what was overflowing the column. min-width:0
       overrides it so the width constraints above actually apply. */
    min-width: 0;
  }
  /* Field name beside its sort button (centered as a pair), with the
     filter select on its own row underneath -- "ALL" reads naturally below
     a field name, right next to its own sort button felt redundant/
     cramped as a third stacked row. The label still wraps onto a second
     line rather than truncating if a column is narrow. */
  .th-label-row { display: flex; flex-direction: row; align-items: flex-start; justify-content: center; gap: 6px; margin-bottom: 3px; }
  .th-label-row .th-sort { flex: none; }
  .th-label { white-space: normal; overflow-wrap: break-word; min-width: 0; text-align: center; font-weight: 700; color: var(--chalk); }
  .th-control select {
    background: none;
    border: none;
    color: var(--chalk-dim);
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    padding: 0;
    max-width: 96px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .th-control select.filter-active { color: var(--brass); font-weight: 700; }
  .th-control select:hover { color: var(--chalk); }
  .th-control select:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
  .th-control select option { background: var(--felt-2); color: var(--chalk); text-transform: none; font-size: 0.8rem; letter-spacing: normal; }

  /* Type-to-filter combobox -- see enhanceFilterSelect() in app.js. The
     <select> stays in the DOM (hidden) as the real source of truth; this is
     just its visible stand-in. combo-wrap carries the dropdown caret that a
     plain <select> would otherwise render natively -- an <input> has no
     equivalent of its own. */
  select.combo-native { display: none; }
  .combo-wrap { position: relative; display: inline-block; width: 100%; }
  .th-control .combo-wrap { max-width: 96px; }
  .combo-wrap::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--brass-dim);
    transform: translateY(-30%);
    pointer-events: none;
  }
  .combo-wrap:focus-within::after, .combo-wrap:has(.combo-input.filter-active)::after { border-top-color: var(--brass); }
  .th-control .combo-input {
    background: none;
    border: none;
    border-bottom: 1px dotted var(--line);
    color: var(--chalk-dim);
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    cursor: text;
    padding: 0 12px 1px 0;
    max-width: 96px;
    min-width: 0;
    width: 100%;
  }
  .th-control .combo-input::placeholder { color: var(--chalk-dim); opacity: 0.55; text-transform: none; letter-spacing: normal; }
  .th-control .combo-input.filter-active { color: var(--brass); font-weight: 700; border-bottom-color: var(--brass); }
  .th-control .combo-input:hover { color: var(--chalk); border-bottom-color: var(--brass-dim); }
  .th-control .combo-input:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }

  /* Shared floating option list -- one element reused by every combobox on
     the page, positioned under whichever input is focused (see
     positionComboList in app.js). Lives outside the table so a header's
     overflow:hidden (needed for sticky/resizable columns) can't clip it. */
  .combo-list {
    position: fixed;
    z-index: 500;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--felt-2);
    border: 1px solid var(--brass-dim);
    border-radius: 4px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  }
  .combo-list.open { display: block; }
  .combo-list li {
    padding: 5px 12px;
    font-family: var(--body);
    font-size: 0.82rem;
    color: var(--chalk);
    white-space: nowrap;
    cursor: pointer;
  }
  .combo-list li:hover, .combo-list li.active { background: var(--brass); color: var(--felt); }
  .combo-list li.current { color: var(--brass); font-weight: 700; }
  .combo-list li.active.current { color: var(--felt); }
  .combo-list li.combo-empty { color: var(--chalk-dim); font-style: italic; cursor: default; }
  .combo-list li.combo-empty:hover { background: none; }
  .th-sort {
    background: none;
    border: none;
    color: var(--chalk-dim);
    cursor: pointer;
    font-size: 0.72rem;
    padding: 1px 2px;
    line-height: 1;
    flex-shrink: 0;
  }
  .th-sort:hover { color: var(--brass); }
  .th-sort.active { color: var(--brass); }
  .th-sort:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
  table.history-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: center; vertical-align: middle; }
  table.history-table tr:last-child td { border-bottom: none; }
  /* Column separators -- gold in the header (matching its own brass-dim
     bottom border), but the same quiet --line color as the data rows'
     own horizontal separators once you're into the data area, not brass.
     No border after the last column: the wrap's own outer border already
     closes off the right edge, and a second line there would double up. */
  table.history-table th:not(:last-child) {
    border-right: 1px solid var(--brass-dim);
  }
  table.history-table td:not(:last-child) {
    border-right: 1px solid var(--line);
  }
  table.history-table td.result-win { color: var(--up); font-weight: 600; }
  table.history-table td.result-loss { color: var(--down); font-weight: 600; }
  table.history-table td.result-tie { color: var(--brass); font-weight: 600; }
  table.history-table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  /* Same brass dotted-underline treatment as .profile-teams-list a, so a
     clickable name/date reads the same way everywhere in the app. */
  table.history-table td a { color: var(--brass); text-decoration: none; border-bottom: 1px dotted var(--brass-dim); cursor: pointer; }
  table.history-table td a:hover { color: var(--chalk); border-bottom-style: solid; }
  /* A win/loss-colored score cell (e.g. Match History's Score column) that's
     also a link out to the real match page -- inherit the win/loss color
     instead of the usual brass, so it stays green/red at a glance, still
     with the same dotted-underline-that-solidifies-on-hover link affordance. */
  table.history-table td.result-win a, table.history-table td.result-loss a, table.history-table td.result-tie a {
    color: inherit; border-bottom-color: currentColor;
  }
  table.history-table td.result-win a:hover, table.history-table td.result-loss a:hover, table.history-table td.result-tie a:hover {
    color: var(--chalk);
  }
  .history-note { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); margin-top: 10px; }

  /* ---------------- reusable collapsible section ---------------- */
  .collapsible-section { margin-bottom: 32px; }
  .collapsible-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    cursor: pointer;
    user-select: none;
  }
  .collapsible-header:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
  .collapsible-title { display: flex; align-items: baseline; gap: 10px; }
  .collapsible-arrow {
    display: inline-block;
    /* Was 0.75em, sized relative to an inherited ambient font-size that
       didn't match its h2 sibling's own 1.1rem override (em on a sibling
       is relative to their shared parent, not to the h2 itself) -- reading
       noticeably smaller than "Match History" beside it. Match the h2's
       size directly instead. */
    font-size: 1.1rem;
    color: var(--brass);
    transition: transform 0.15s ease;
    transform: rotate(0deg);
  }
  .collapsible-section.collapsed .collapsible-arrow { transform: rotate(-90deg); }
  .collapsible-section.collapsed .collapsible-body { display: none; }

  footer.app-footer { border-top: 1px solid var(--line); padding-top: 18px; font-size: 0.78rem; color: var(--chalk-dim); line-height: 1.7; margin-top: 32px; }

  /* ---- Signed-in account (sidebar) and the sign-in pages ---- */
  .account-box { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); }
  .account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
  .account-signout { font: inherit; color: var(--brass); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }
  .account-signout:hover { color: var(--chalk); }
  .login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; box-sizing: border-box; }
  .login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 28px 26px; }
  .login-card h1 { margin: 0 0 14px; }
  .login-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
  .login-form label { font-family: var(--mono); font-size: 0.72rem; color: var(--chalk-dim); text-transform: uppercase; letter-spacing: 0.05em; }
  .login-form input { font: inherit; color: var(--chalk); background: var(--felt); border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; }
  .login-form input:focus { outline: 2px solid var(--brass-dim); outline-offset: 1px; }
  .login-form button { font: inherit; font-weight: 600; color: var(--felt); background: var(--brass); border: none; border-radius: 4px; padding: 10px 12px; cursor: pointer; margin-top: 6px; }
  .login-form button:disabled { opacity: 0.6; cursor: default; }
  .login-message { font-size: 0.85rem; color: var(--chalk-dim); min-height: 1.2em; margin: 14px 0 0; }
  .login-error { font-size: 0.85rem; color: var(--down); margin: 0 0 8px; }

  /* ---- Accounts page and grant dialog ---- */
  .account-add-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 4px; }
  .account-add-form input[type="email"], .account-add-form input[type="text"] {
    font: inherit; font-size: 0.85rem; color: var(--chalk); background: var(--felt);
    border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; min-width: 200px;
  }
  .account-admin-label { font-family: var(--mono); font-size: 0.75rem; color: var(--chalk-dim); display: flex; align-items: center; gap: 5px; }
  .account-add-form button, .grant-submit {
    font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--felt); background: var(--brass);
    border: none; border-radius: 4px; padding: 7px 14px; cursor: pointer;
  }
  .accounts-message { font-size: 0.82rem; color: var(--chalk-dim); min-height: 1.2em; margin: 6px 0 10px; }
  .accounts-message.accounts-error { color: var(--down); }
  .link-btn { font: inherit; font-size: 0.78rem; color: var(--brass); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }
  .link-btn:hover { color: var(--chalk); }
  .link-btn:disabled { color: var(--chalk-dim); cursor: default; text-decoration: none; }
  .account-actions { white-space: nowrap; }
  .account-actions .link-btn + .link-btn { margin-left: 10px; }
  .grant-chip {
    display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 2px 0; padding: 1px 4px 1px 8px;
    font-size: 0.78rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  }
  .grant-chip-remove { font: inherit; color: var(--chalk-dim); background: none; border: none; cursor: pointer; padding: 0 4px; line-height: 1; }
  .grant-chip-remove:hover { color: var(--down); }
  #accounts-table col.col-rank    { width: 90px; }
  #accounts-table col.col-access  { width: auto; }
  #accounts-table col.col-status  { width: 100px; }
  #accounts-table col.col-date-mid { width: 150px; }
  #accounts-table col.col-actions { width: 140px; }
  .grant-sheet { max-width: 520px; }
  .grant-kind { display: flex; gap: 18px; margin: 4px 0 12px; font-size: 0.88rem; }
  .grant-kind label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
  .grant-pick { margin-bottom: 14px; }
  .grant-pick .combo-input { width: 100%; box-sizing: border-box; }
  .my-access-list { padding-left: 0; font-size: 0.85rem; }

  /* ---------------- match simulation: column + sheet ---------------- */
  .sim-legend-sample { color: var(--down); font-weight: 600; }
  /* Colored to match the real Result/Score columns on the same row's
     predicted outcome (green/red/brass via .result-win/-loss/-tie, applied
     by JS) rather than a flat color -- the P* marker alone carries "this
     isn't real yet". border-bottom uses currentColor so the dotted-
     underline-that-solidifies-on-hover link affordance (same idiom as
     every other in-table link, table.history-table td a above) always
     matches whichever result color is active without a separate override
     per class. */
  .sim-score-link {
    background: none; border: none; padding: 2px 4px; border-radius: 3px;
    font-family: var(--mono); font-weight: 600; font-size: 0.86rem; cursor: pointer;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px dotted currentColor;
  }
  .sim-score-link.result-win { color: var(--up); }
  .sim-score-link.result-loss { color: var(--down); }
  .sim-score-link.result-tie { color: var(--brass); }
  .sim-score-link:hover { background: var(--card-hi); color: var(--chalk); border-bottom-style: solid; border-bottom-color: var(--chalk-dim); }
  .sim-p-star { font-size: 0.7em; vertical-align: super; }
  .sim-score-na, .sim-score-loading { color: var(--chalk-dim); font-family: var(--mono); font-size: 0.82rem; }
  .sim-running-diff { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
  .sim-running-diff.pos { color: var(--up); }
  .sim-running-diff.neg { color: var(--down); }

  .sim-overlay {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, 0.55);
    align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow-y: auto;
  }
  .sim-overlay.open { display: flex; }
  .sim-sheet {
    position: relative; background: var(--felt); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 12px 40px var(--shadow);
    max-width: 900px; width: 100%; padding: 28px 28px 24px;
  }
  .sim-close {
    position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
    border-radius: 50%; border: 1px solid var(--line); background: var(--card);
    color: var(--chalk-dim); font-size: 1.2rem; line-height: 1; cursor: pointer;
  }
  .sim-close:hover { color: var(--chalk); background: var(--card-hi); }
  .sim-sheet-title { font-family: var(--display); font-size: 1.3rem; margin: 0 0 4px; padding-right: 30px; }
  .sim-sheet-title .sim-vs { color: var(--brass); font-weight: 400; }
  .sim-sheet-sub { font-size: 0.78rem; color: var(--chalk-dim); margin-bottom: 20px; }

  .sim-score-banner { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 24px; }
  .sim-score-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .sim-score-label { font-family: var(--mono); font-size: 0.68rem; color: var(--chalk-dim); text-align: center; max-width: 160px; }
  .sim-score-big { font-family: var(--mono); font-weight: 700; font-size: 2rem; font-variant-numeric: tabular-nums; }
  .sim-score-big.sim-score-projected { color: var(--down); }
  .sim-score-sep { font-family: var(--mono); font-size: 1.4rem; color: var(--chalk-dim); }

  .sim-rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 8px; }
  .sim-roster-head { font-family: var(--display); font-size: 0.92rem; color: var(--brass); border-bottom: 2px solid var(--brass-dim); padding-bottom: 6px; margin-bottom: 6px; }
  .sim-player-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 2px; font-size: 0.82rem; }
  .sim-player-row + .sim-player-row { border-top: 1px solid var(--line); }
  .sim-player-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sim-player-row.sim-prelim .sim-player-name { color: var(--chalk-dim); font-style: italic; }
  .sim-player-sl { font-family: var(--mono); font-size: 0.66rem; color: var(--chalk-dim); flex: none; }
  .sim-player-share { font-family: var(--mono); font-weight: 600; font-size: 0.8rem; flex: none; min-width: 38px; text-align: right; }

  @media (max-width: 600px) {
    .sim-rosters { grid-template-columns: 1fr; }
    .sim-sheet { padding: 22px 16px 18px; }
  }

  /* table-layout:fixed + width:100% so the grid always fits the sheet's
     own width -- no horizontal scrollbar regardless of roster size -- with
     the row-header column getting a fixed share and every data column
     splitting the remainder evenly (the fixed layout algorithm sizes
     columns off this first row, not off any cell's natural content width;
     long names wrap onto multiple lines instead, which just grows the
     row's height rather than any column's width). */
  .heatmap-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--card); padding: 12px; margin-bottom: 10px; }
  table.heatmap { table-layout: fixed; width: 100%; border-collapse: separate; border-spacing: 2px; font-family: var(--mono); }
  .hm-corner { background: transparent; width: 92px; }
  .hm-col-head, .hm-row-head { text-align: left; font-weight: 400; padding: 4px 4px; vertical-align: bottom; }
  .hm-row-head { width: 92px; }
  .hm-col-head { text-align: center; }
  .hm-name { display: block; font-family: var(--body); font-size: 0.72rem; color: var(--chalk); white-space: normal; overflow-wrap: break-word; line-height: 1.2; }
  .hm-sl { display: block; font-size: 0.58rem; color: var(--chalk-dim); letter-spacing: 0.04em; }
  td.hm-cell { text-align: center; font-weight: 600; font-size: 0.78rem; font-variant-numeric: tabular-nums; border-radius: 4px; padding: 8px 3px; overflow: hidden; }
  td.hm-cell[data-lock-i] { cursor: pointer; }
  td.hm-cell[data-lock-i]:hover { box-shadow: inset 0 0 0 2px var(--brass); }
  td.hm-cell.hm-cell-locked { box-shadow: inset 0 0 0 3px var(--brass); }
  td.hm-cell.hm-cell-unavailable { opacity: 0.32; }
  .hm-cell-pts { display: block; font-weight: 400; font-size: 0.62rem; opacity: 0.75; margin-top: 2px; }

  .heatmap-legend { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 0.64rem; color: var(--chalk-dim); margin-bottom: 8px; }

  .mp-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
  .mp-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    font-size: 0.82rem; background: var(--card);
  }
  .mp-row + .mp-row { border-top: 1px solid var(--line); }
  .mp-pair { flex: 1 1 auto; min-width: 0; }
  .mp-sl { font-family: var(--mono); font-size: 0.66rem; color: var(--chalk-dim); }
  .mp-prob { font-family: var(--mono); font-weight: 600; font-size: 0.8rem; flex: none; width: 42px; text-align: right; color: var(--chalk-dim); }
  .mp-pts { font-family: var(--mono); font-weight: 600; font-size: 0.82rem; flex: none; width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
  .mp-lock-btn {
    flex: none; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase;
    background: none; border: 1px solid var(--brass-dim); color: var(--brass); border-radius: 3px;
    padding: 4px 8px; cursor: pointer;
  }
  .mp-lock-btn:hover { background: var(--brass); color: var(--felt); border-color: var(--brass); }
  .mp-locked-summary { font-family: var(--mono); font-size: 0.76rem; color: var(--chalk-dim); margin-bottom: 6px; }
  .mp-locked-summary b { color: var(--brass); }
  .mp-row.mp-locked { background: var(--card-hi); box-shadow: inset 3px 0 0 var(--brass); border-radius: 4px; margin-bottom: 3px; }
  .mp-unlock-btn {
    flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--card); color: var(--chalk-dim); cursor: pointer; font-size: 0.95rem; line-height: 1;
  }
  .mp-unlock-btn:hover { color: var(--chalk); background: var(--card-hi); }
  .lc-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 12px; font-size: 0.8rem; background: var(--card); line-height: 1.5; }
  .lc-row + .lc-row { border-top: 1px solid var(--line); }
  .lc-pairs { flex: 1 1 auto; min-width: 0; color: var(--chalk); }
  .lc-total { font-family: var(--mono); font-weight: 600; font-size: 0.82rem; flex: none; text-align: right; font-variant-numeric: tabular-nums; color: var(--brass); }
  .sim-points-under-odds { font-family: var(--mono); font-size: 0.8rem; color: var(--chalk-dim); margin-bottom: 8px; }
  .sim-points-under-odds b { color: var(--chalk); }

  .avp-table-wrap { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
  table.avp-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
  table.avp-table th {
    text-align: left; font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--chalk-dim); padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--card-hi);
  }
  table.avp-table th.num { text-align: right; }
  table.avp-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
  table.avp-table tr:last-child td { border-bottom: none; }
  table.avp-table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
  table.avp-table td.wrap-cell { white-space: normal; word-break: break-word; }
  .legend-bar { flex: 1 1 auto; max-width: 240px; height: 10px; border-radius: 5px; background: linear-gradient(to right, rgb(168,48,45), rgb(238,232,220), rgb(40,84,160)); border: 1px solid var(--line); }
  footer.app-footer strong { color: var(--chalk); }
