:root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --border: #ece8e1;
    --text: #201f1d;
    --muted: #767267;
    --muted-2: #9c9890;
    --accent: #2f6f4f;
    --accent-soft: #eaf3ee;
    --neutral-soft: #f1efe9;
    --live-bg: #fbeae4;
    --live: #c1573c;
    --win: #2f8a5c;
    --win-bg: #eaf6ef;
    --loss: #c1573c;
    --loss-bg: #fbeae4;
    --draw: #9c9890;
    --draw-bg: #f1efe9;
    --radius: 10px;
    --radius-sm: 6px;
    --font: "Source Sans 3", system-ui, sans-serif;
    --scroll-shadow: rgba(32, 31, 29, 0.12);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --bg: #18191b;
        --surface: #212325;
        --border: #2e3033;
        --text: #ece9e3;
        --muted: #a29c90;
        --muted-2: #7c786f;
        --accent: #5fb98a;
        --accent-soft: rgba(95, 185, 138, 0.14);
        --neutral-soft: #26282b;
        --live-bg: rgba(226, 119, 90, 0.16);
        --live: #e2775a;
        --win: #5fb98a;
        --win-bg: rgba(95, 185, 138, 0.14);
        --loss: #e2775a;
        --loss-bg: rgba(226, 119, 90, 0.16);
        --draw: #948e83;
        --draw-bg: rgba(148, 142, 131, 0.14);
        --scroll-shadow: rgba(0, 0, 0, 0.4);
    }
}

html[data-theme="dark"] {
    --bg: #18191b;
    --surface: #212325;
    --border: #2e3033;
    --text: #ece9e3;
    --muted: #a29c90;
    --muted-2: #7c786f;
    --accent: #5fb98a;
    --accent-soft: rgba(95, 185, 138, 0.14);
    --neutral-soft: #26282b;
    --live-bg: rgba(226, 119, 90, 0.16);
    --live: #e2775a;
    --win: #5fb98a;
    --win-bg: rgba(95, 185, 138, 0.14);
    --loss: #e2775a;
    --loss-bg: rgba(226, 119, 90, 0.16);
    --draw: #948e83;
    --draw-bg: rgba(148, 142, 131, 0.14);
    --scroll-shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font);
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
    background: var(--bg);
    color: var(--text);
}

/* Data-dense pages (standings, leaders, box scores, rosters) get a wider
   column on desktop; card/prose sections within them opt back into the
   standard reading width via .content-narrow. Harmless on narrow
   viewports since max-width never forces extra width. */
body.wide { max-width: 1200px; }
.content-narrow { max-width: 860px; margin: 0 auto; }

a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent); }

h1 { font-size: 1.3rem; font-weight: 700; margin: 1.5rem 0 1rem; }
h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
h3 {
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--text);
}

/* Top nav */
.topnav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.4rem;
}
.topnav .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}
.topnav .brand:hover { color: var(--text); }
.brand-mark {
    width: 20px;
    height: 20px;
    flex: none;
    overflow: visible;
}
.brand-mark path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: brand-draw 0.7s ease-out 0.15s forwards;
}
.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.brand-word {
    display: inline-block;
    clip-path: inset(0 100% 0 0);
    animation: brand-wipe 0.55s cubic-bezier(.4, .6, .2, 1) 0.55s forwards;
}
@keyframes brand-draw { to { stroke-dashoffset: 0; } }
@keyframes brand-wipe { to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
    .brand-mark path { animation: none; stroke-dashoffset: 0; }
    .brand-word { animation: none; clip-path: inset(0 0 0 0); }
}
html.brand-no-anim .brand-mark path { animation: none; stroke-dashoffset: 0; }
html.brand-no-anim .brand-word { animation: none; clip-path: inset(0 0 0 0); }
.topnav-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    flex: 1;
    max-width: 260px;
}
.topnav-search svg { flex: none; opacity: 0.5; color: var(--muted); }
.topnav-search input[type="text"] {
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    width: 100%;
}
.topnav-search input::placeholder { color: var(--muted-2); }
.topnav-links { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.topnav-links a { font-weight: 600; font-size: 0.88rem; color: var(--muted); }
.topnav-links a:hover { color: var(--accent); }
.topnav-links a.active { color: var(--accent); font-weight: 700; }

.menu { position: relative; }
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }

.menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 200px;
    max-width: calc(100vw - 2.5rem);
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    box-shadow: 0 8px 24px var(--scroll-shadow);
}
.menu.open .menu-panel { display: block; }

.menu-section { padding: 0.4rem 0.6rem; }
.menu-section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted-2);
    margin-bottom: 0.5rem;
}
.menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
    color: var(--text);
}
.menu-panel .menu-section + .menu-section { border-top: 1px solid var(--border); }
.menu-row.menu-link { text-decoration: none; justify-content: flex-end; }
.menu-row:has(.theme-switch) { justify-content: flex-end; }
.menu-row.menu-link:hover, .menu-row.menu-link.active { color: var(--accent); }
.menu-row.menu-link.is-disabled { color: var(--muted-2); cursor: default; pointer-events: none; }

.theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: none;
    width: 56px;
    height: 28px;
    border-radius: 999px;
    background: var(--neutral-soft);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.theme-switch-icon {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    color: var(--muted-2);
}
.theme-switch-icon .theme-icon-moon { display: none; }
.theme-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px var(--scroll-shadow);
    transition: transform 0.15s ease;
}
.theme-switch.is-dark { background: var(--accent-soft); border-color: var(--accent); }
.theme-switch.is-dark .theme-switch-thumb { transform: translateX(28px); background: var(--accent); }
.theme-switch.is-dark .theme-switch-icon { left: 8px; right: auto; color: #fff; }
.theme-switch.is-dark .theme-icon-sun { display: none; }
.theme-switch.is-dark .theme-icon-moon { display: block; }

.brand-sync { font-size: 0.6rem; color: var(--muted-2); }

.division-toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 0.6rem 0 1.25rem; }
.division-toggle-right { display: flex; align-items: center; gap: 0.6rem; }
.division-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: none;
    width: 56px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent);
    border: 1px solid var(--accent);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.division-switch-label {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
}
.division-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px var(--scroll-shadow);
    transition: transform 0.15s ease;
}
.division-switch.is-on .division-switch-thumb { transform: translateX(28px); }
.division-switch.is-off {
    background: var(--neutral-soft);
    border-color: var(--border);
}
.division-switch.is-off .division-switch-label { left: auto; right: 8px; color: var(--muted-2); }

/* Date bar */
.datebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 1.5rem 0 1.1rem;
}
.datebar-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.datebar-side:hover .arrow-btn { border-color: var(--accent); color: var(--accent); transform: scale(1.05); }
.datebar-side:hover .datebar-label { color: var(--accent); }
.arrow-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.datebar-label { font-size: 0.72rem; color: var(--muted-2); }
.datebar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    min-width: 160px;
    text-align: center;
}

.conference-filter { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-bottom: 0.8rem; }
.conference-filter select {
    padding: 0.45rem 0.75rem;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.85rem;
}

.filter-panel { width: 240px; }
.filter-form { display: flex; flex-direction: column; gap: 0.6rem; }
.filter-form select {
    width: 100%;
    padding: 0.45rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.85rem;
}

.conf-only-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
}
.conf-only-toggle input { margin: 0; accent-color: var(--accent); }

.filter-form .menu-section-label { padding: 0; margin-top: 0.2rem; }
.filter-form .menu-section-label:first-child { margin-top: 0; }

.filter-slider { display: flex; flex-direction: column; gap: 0.35rem; }
.filter-slider-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}
.filter-slider-label span:first-child { color: var(--text); font-weight: 600; }
.filter-slider input[type="range"] {
    width: 100%;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}
.filter-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}
.filter-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.filter-hint { font-size: 0.72rem; color: var(--muted-2); line-height: 1.3; margin: 0.1rem 0 0; }

.filter-actions { display: flex; gap: 0.5rem; margin-top: 0.2rem; }

.filter-apply-btn, .filter-clear-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.filter-apply-btn {
    background: var(--accent);
    color: #fff;
    border: none;
}
.filter-apply-btn:hover { opacity: 0.92; }

.filter-clear-btn {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
}
.filter-clear-btn:hover { background: var(--neutral-soft); color: var(--text); }

.filter-form select:focus,
.filter-form input:focus-visible,
.filter-apply-btn:focus-visible,
.filter-clear-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.filter-slider input[type="range"]:focus {
    outline: none;
}
.filter-slider input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-slider input[type="range"]:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-panel { max-height: calc(100vh - 90px); overflow-y: auto; }

.upset-key {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
    margin-bottom: 0.8rem;
}

/* Card rows (matches, team history) */
.card-list { display: flex; flex-direction: column; gap: 8px; margin-top: 0.5rem; }
.card-row {
    display: grid;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1.1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card-row:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(32, 31, 29, 0.06);
}
.card-row.matches {
    grid-template-columns: 30px 1fr auto 1fr;
    gap: 10px;
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
}
.card-row.history { grid-template-columns: 92px 22px 1fr 96px 40px; }

.cell-date { font-size: 0.78rem; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.cell-vs { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 0.75rem; color: var(--muted-2); text-align: center; }
.cell-result { text-align: right; }

.conf-tag {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--muted-2);
    margin-left: 4px;
    white-space: nowrap;
}
.cell-vs .conf-tag { margin-left: 0; }

.matches-list { gap: 4px; }

.featured-heading { margin-top: 1.2rem; margin-bottom: 0; }
.featured-list .card-row.matches { border-left: 3px solid var(--accent); }

.match-badge {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    padding: 0.2rem 0;
    border-radius: 5px;
    white-space: nowrap;
}
.match-badge.b-final { background: var(--neutral-soft); color: var(--muted); }
.match-badge.b-live, .match-badge.b-ht { background: var(--accent-soft); color: var(--accent); }
.match-badge.b-live { display: flex; align-items: center; justify-content: center; gap: 3px; }
.match-badge.b-live::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: live-pulse 1.6s ease-in-out infinite;
}

.match-center { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; }
.match-cardrow { display: flex; justify-content: space-between; width: 22px; height: 8px; }
.match-cardmark { width: 6px; height: 8px; border-radius: 1px; background: var(--live); opacity: 0; }
.match-cardmark.show { opacity: 1; }
.match-time { font-size: 0.78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.match-time .tz { color: var(--muted-2); font-weight: 500; font-size: 0.7rem; }

.upset-fire {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
}
.upset-fire-away { right: 100%; margin-right: 1px; }
.upset-fire-home { left: 100%; margin-left: 1px; }

.name-short { display: none; }

.team-link { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.team-link.align-left { text-align: left; }
.team-link.align-right { text-align: right; }
.team-link:hover { color: var(--accent); }

.score-link {
    position: relative;
    display: inline-block;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
    color: var(--text);
    padding: 0 4px;
}
.score-link:hover { color: var(--accent); }

.pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--muted);
    white-space: nowrap;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}
.pill.result-w { background: var(--win-bg); color: var(--win); }
.pill.result-l { background: var(--loss-bg); color: var(--loss); }
.pill.result-d { background: var(--draw-bg); color: var(--draw); }
.pill.pill-standout { background: var(--accent-soft); color: var(--accent); }
.pill.role-sub { background: var(--neutral-soft); color: var(--muted-2); font-weight: 600; }

.card-row.standout { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.standout-player {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    flex: 1 1 140px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.standout-team-group { display: flex; align-items: center; gap: 10px; flex: 1 1 160px; min-width: 0; }
.standout-team { color: var(--muted); font-size: 0.82rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standout-team-group .pill { flex: none; }
.standout-meta { color: var(--muted-2); font-size: 0.78rem; margin-left: auto; text-align: right; }

.rank-move { font-size: 0.72em; font-weight: 700; margin-right: 2px; white-space: nowrap; }
.rank-move.rank-up { color: var(--win); }
.rank-move.rank-down { color: var(--loss); }
.rank-move.rank-new { color: var(--accent); font-size: 0.55em; vertical-align: middle; }

.team-meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.team-meta a { color: var(--accent); font-weight: 600; }

/* Team header row: name + conference link */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-link { font-size: 0.78rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.section-link:hover { text-decoration: underline; }
.team-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 1.5rem 0 1.1rem; flex-wrap: wrap; }
.team-head h1 { margin: 0; }
.team-city-link:hover { text-decoration: underline; }
.conf-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}
.info-list { display: flex; flex-direction: column; }
.info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 0.82rem; color: var(--muted); }
.info-value { font-size: 0.9rem; font-weight: 600; color: var(--text); text-align: right; }
a.info-value:hover { color: var(--accent); }
.info-value-link { display: inline-flex; align-items: center; gap: 5px; }
.info-value-link svg { flex: none; }

.team-tabs { display: flex; justify-content: flex-end; gap: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; margin-bottom: 1.1rem; }
.team-tab { background: none; border: none; border-bottom: 2px solid transparent; font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--muted); padding: 0.5rem 0.1rem; margin-bottom: -1px; cursor: pointer; }
.team-tab:hover { color: var(--accent); }
.team-tab.active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }

/* Team season record + stat tiles */
.record-row { display: grid; grid-template-columns: repeat(3, 1fr); }
.record-tile { text-align: center; padding: 0 0.6rem; border-left: 1px solid var(--border); }
.record-tile:first-child { border-left: none; }
.record-tile-value { font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.record-tile-label {
    margin-top: 0.35rem;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.stat-divider { border-top: 1px solid var(--border); margin: 1rem 0; }

.stat-tiles.team-stat-tiles { grid-template-columns: repeat(4, 1fr); }
.stat-tiles.team-stat-tiles .stat-tile:nth-child(4n+1) { border-left: none; }
.stat-tiles.team-stat-tiles .stat-tile:nth-child(n+5) { border-top: 1px solid var(--border); padding-top: 0.6rem; margin-top: 0.6rem; }

/* Player header badges */
.player-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 1.5rem 0 0.35rem; }
.player-head h1 { margin: 0; }
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.22rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--neutral-soft);
    color: var(--muted);
}
.badge.pos { background: var(--accent-soft); color: var(--accent); }

/* Season stat tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(8, 1fr); }
.stat-tile { text-align: center; padding: 0 0.4rem; border-left: 1px solid var(--border); }
.stat-tile:first-child { border-left: none; }
.stat-tile-value { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-tile-label {
    margin-top: 0.35rem;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.highlight-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}
.highlight-line .hl-label { font-size: 0.72rem; font-weight: 600; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.05em; }
.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--text);
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
}
.chip b { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 0.92rem; }

.note-pills { display: flex; gap: 4px; flex-wrap: nowrap; }
.note-pill {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.16rem 0.4rem;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
}

@media (max-width: 700px) {
    .stat-tiles, .stat-tiles.team-stat-tiles { grid-template-columns: repeat(4, 1fr); }
    .stat-tile { border-left: none; border-top: 1px solid var(--border); padding-top: 0.6rem; margin-top: 0.6rem; }
    .stat-tile:nth-child(-n+4) { border-top: none; margin-top: 0; padding-top: 0; }
    .record-tile-value { font-size: 1.25rem; }
}

/* Game / box score */
.game-header { padding: 0.75rem 0 0.25rem; }
.matchup { margin: 0; }
.matchup-names {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 1.05rem;
    font-weight: 700;
}
.matchup-team.left { text-align: left; }
.matchup-team.right { text-align: right; }
.matchup-team { color: var(--text); }
.matchup-team:hover { color: var(--accent); }
.matchup-score {
    text-align: center;
    margin-top: 8px;
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.score-big { color: var(--text); }
.score-sep { color: var(--muted-2); font-weight: 400; padding: 0 6px; }
.game-meta { text-align: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }

.stats-card h2 { margin-top: 0; }
.stats-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 18px;
}
.stats-val, .stats-label { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.stats-grid > :nth-last-child(-n+3) { border-bottom: none; }
.stats-val { font-variant-numeric: tabular-nums; font-size: 0.92rem; font-weight: 600; color: var(--text); }
.stats-val.left { text-align: right; padding-right: 0.6rem; }
.stats-val.right { text-align: left; padding-left: 0.6rem; }
.stats-val.hi { font-weight: 700; }
.stats-label {
    text-align: center;
    color: var(--muted-2);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.boxscore-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.25rem;
}
.boxscore-card h2, .boxscore-card h3 { margin-top: 0; border-bottom: none; padding-bottom: 0; }

.table-scroll {
    overflow-x: auto;
    background-repeat: no-repeat;
    background-size: 32px 100%, 32px 100%, 12px 100%, 12px 100%;
    background-position: left center, right center, left center, right center;
    background-image:
        linear-gradient(to right, var(--surface) 50%, transparent),
        linear-gradient(to left, var(--surface) 50%, transparent),
        linear-gradient(to right, var(--scroll-shadow), transparent),
        linear-gradient(to left, var(--scroll-shadow), transparent);
    background-attachment: local, local, scroll, scroll;
}

/* Tables (box scores, leaders, standings, search) */
table { width: 100%; border-collapse: collapse; }
td, th { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
th {
    color: var(--muted-2);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }

table.leaders { table-layout: fixed; }
table.leaders td, table.leaders th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.leaders-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1.25rem; align-items: start; }
.leaders-grid .boxscore-card { margin-bottom: 0; }
.leaders-grid table.leaders th:nth-child(1), .leaders-grid table.leaders td:nth-child(1) { width: 6%; }
.leaders-grid table.leaders th:nth-child(2), .leaders-grid table.leaders td:nth-child(2) { width: 34%; }
.leaders-grid table.leaders th:nth-child(3), .leaders-grid table.leaders td:nth-child(3) { width: 44%; }
.leaders-grid table.leaders th:nth-child(4), .leaders-grid table.leaders td:nth-child(4) { width: 16%; white-space: normal; }

.boxscore-card:not(.expanded) tr.extra-row,
.toggle-section:not(.expanded) .card-row.extra-row { display: none; }
.leaders-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.7rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.leaders-toggle:hover { text-decoration: underline; }
.leaders-toggle-arrow { display: inline-block; transition: transform 0.15s ease; }
.leaders-toggle[aria-expanded="true"] .leaders-toggle-arrow { transform: rotate(90deg); }


table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--accent); }
table.sortable th[data-sort].sort-asc::after { content: " \25B2"; font-size: 0.7em; color: var(--accent); }
table.sortable th[data-sort].sort-desc::after { content: " \25BC"; font-size: 0.7em; color: var(--accent); }
table.sortable th[data-sort] a { color: inherit; text-decoration: none; display: block; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1.1rem; font-size: 0.85rem; color: var(--muted); }
.pagination a { font-weight: 600; color: var(--accent); }
.pagination .disabled { color: var(--muted-2); }

.glossary { color: var(--muted-2); font-size: 0.82rem; margin-top: 0.75rem; }

.empty { color: var(--muted-2); padding: 1.5rem 0; }

.pill-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill.active { background: var(--accent-soft); color: var(--accent); }

/* Rank history chart */
.rank-chart { position: relative; }
.rank-chart svg { display: block; width: 100%; height: auto; }
.rank-chart-axis { stroke: var(--border); stroke-width: 1; }
.rank-chart-axis-text { fill: var(--muted-2); font-size: 10px; }
.rank-line { fill: none; stroke-width: 2; transition: stroke-width 0.1s ease, opacity 0.1s ease; }
.rank-line.is-dimmed { opacity: 0.15; }
.rank-line.is-active { stroke-width: 3.5; }
.rank-line-point.is-dimmed { opacity: 0.15; }
.rank-line-point.is-active { r: 4.5; }
.rank-line-hit { cursor: pointer; }
.rank-chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 2px 8px var(--scroll-shadow);
    white-space: nowrap;
    z-index: 5;
}
.rank-chart-tooltip[hidden] { display: none; }

@media (max-width: 700px) {
    .rank-chart-tooltip { max-width: 70vw; white-space: normal; }
}

/* Rank history table */
.rank-history-table td:first-child,
.rank-history-table th:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
}
.rank-history-table tr.is-active { background: var(--accent-soft); }
.rank-history-swatch {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.muted-cell { color: var(--muted-2); }

@media (max-width: 560px) {
    .card-row.matches { grid-template-columns: 26px 1fr auto 1fr; gap: 8px; padding: 0.5rem 0.7rem; }
    .match-time .tz { display: none; }
    .card-row.history { grid-template-columns: 76px 20px 1fr 40px; }
    .card-row.history .score-link { display: none; }
    .team-link { overflow-wrap: break-word; }
    .name-full { display: none; }
    .name-short { display: inline; }
    .player-page .team-state { display: none; }

    .topnav { flex-wrap: wrap; row-gap: 12px; position: relative; }
    .topnav-search { order: 3; flex: 1 1 100%; max-width: none; }
    .topnav-links { gap: 14px; margin-left: auto; }
    .topnav .menu { position: static; }

    .datebar { gap: 16px; }
    .datebar-title { min-width: 0; }

    .conference-filter { flex-direction: column; align-items: stretch; }
    .conference-filter select { width: 100%; }

    .standings td:nth-child(6), .standings th:nth-child(6),
    .standings td:nth-last-child(-n+3), .standings th:nth-last-child(-n+3) {
        display: none;
    }
    .standings {
        table-layout: fixed;
    }
    .standings td, .standings th { padding-left: 0.3rem; padding-right: 0.3rem; }
    .standings td:nth-child(1), .standings th:nth-child(1) { width: 13%; }
    .standings td:nth-child(2), .standings th:nth-child(2) { width: 24%; }
    .standings td:nth-child(3), .standings th:nth-child(3) { width: 15%; }
    .standings td:nth-child(4), .standings th:nth-child(4) { width: 15%; }
    .standings td:nth-child(5), .standings th:nth-child(5) { width: 8%; }
    .standings td:nth-child(7), .standings th:nth-child(7) { width: 25%; }
    .standings td:nth-child(1), .standings td:nth-child(2), .standings td:nth-child(3),
    .standings th:nth-child(1), .standings th:nth-child(2), .standings th:nth-child(3) {
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    .matchup-names { font-size: 0.95rem; }
}
