:root {
    --bg: #0f1420;
    --panel: #171d2b;
    --panel-border: #262d40;
    --text: #e7ebf3;
    --muted: #94a0b8;
    --accent: #4f8dfd;
    --gold: #f5c542;
    --high: #1f9d55;
    --low: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topnav {
    background: var(--panel);
    border-bottom: 1px solid var(--panel-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-wrap: wrap;
    row-gap: 8px;
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.nav-links { display: flex; align-items: center; flex-wrap: wrap; }
.nav-group { display: flex; align-items: center; }
.nav-group-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 18px;
    margin-right: 4px;
    opacity: 0.7;
}
.nav-divider {
    width: 1px;
    height: 16px;
    background: var(--panel-border);
    margin-left: 18px;
}
.nav-links a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 14px;
    font-size: 0.95rem;
}
.nav-links a:hover { color: var(--accent); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

h1, h2, h3 { font-weight: 700; }
h1 { font-size: 1.6rem; margin-bottom: 4px; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 24px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}

.week-extremes-line { margin-top: -10px; margin-bottom: 20px; }

.week-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.week-nav select, .week-nav a.btn {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    text-decoration: none;
}
.week-nav a.btn:hover { border-color: var(--accent); }

table.bonus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
table.bonus-table th, table.bonus-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--panel-border);
}
table.bonus-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
table.bonus-table td.score-cell {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    border-radius: 4px;
    padding: 8px 12px;
}
tr.winner-row td { font-weight: 700; }

/* Sortable column headings (player leaderboard). The caret only appears on
   the column actually in use, so the header row stays quiet by default. */
table.sortable-table th.sort-col {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
table.sortable-table th.sort-col:hover { color: var(--text); }
table.sortable-table th.sort-col::after {
    content: "";
    margin-left: 6px;
    opacity: 0.55;
}
table.sortable-table th.sort-col.sorted.desc::after { content: "\25BC"; }
table.sortable-table th.sort-col.sorted.asc::after { content: "\25B2"; }
table.sortable-table th.sort-col.sorted { color: var(--text); }
table.sortable-table td { font-variant-numeric: tabular-nums; }
.trophy, .poop { margin-left: 6px; }
.team-name-cell { display: flex; align-items: center; gap: 8px; }
.team-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}
.player-thumb {
    width: 24px;
    height: 18px;
    object-fit: cover;
    object-position: top;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    background: var(--panel-border);
}
.leaderboard-rank {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    width: 2em;
    display: inline-block;
}
.tie-badge {
    display: inline-block;
    background: var(--gold);
    color: #241a00;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.badge-position {
    display: inline-block;
    background: rgba(79, 141, 253, 0.15);
    color: var(--accent);
    border: 1px solid rgba(79, 141, 253, 0.4);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.error-box {
    background: rgba(192, 57, 43, 0.12);
    border: 1px solid rgba(192, 57, 43, 0.4);
    color: #ff9c8f;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.chart-wrap { max-width: 100%; margin-top: 10px; }

form.inline { display: inline; }
input, select, button {
    font-family: inherit;
    font-size: 0.9rem;
}
button, .button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
button:hover, .button:hover { opacity: 0.9; }
button.secondary { background: var(--panel-border); }
input[type=text], input[type=number], input[type=password] {
    background: #0f1420;
    border: 1px solid var(--panel-border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 6px;
}

.schedule-table td, .schedule-table th { padding: 8px 12px; }
.schedule-table select { padding: 5px 8px; }

.login-box {
    max-width: 360px;
    margin: 80px auto;
}

.year-pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.year-pill {
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid var(--panel-border);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
}
.year-pill.active { background: var(--accent); color: white; border-color: var(--accent); }

.muted { color: var(--muted); font-size: 0.85rem; }

/* "In progress" marker for a week whose games are still being played. */
.live-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    border-radius: 10px;
    background: rgba(79, 141, 253, 0.18);
    border: 1px solid rgba(79, 141, 253, 0.45);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.notice-box {
    padding: 12px 16px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: rgba(79, 141, 253, 0.08);
    border: 1px solid rgba(79, 141, 253, 0.3);
    color: var(--muted);
    font-size: 0.9rem;
}
.flex-row { display: flex; gap: 20px; flex-wrap: wrap; }
.flex-row > div { flex: 1; min-width: 260px; }
/* The player leaderboard carries five columns against the team table's
   three, so give it proportionally more of the row instead of squeezing
   both to the same width. Below ~900px .flex-row wraps and they stack, at
   which point each is full width and the ratio stops applying. */
.flex-row > .panel-wide { flex: 1.7; min-width: 340px; }
/* Long team names shouldn't be able to force a panel wider than its share;
   let the table scroll inside the panel instead of overflowing the page. */
.panel table.bonus-table { width: 100%; }
.panel-scroll { overflow-x: auto; }

/* ---- Per-player game state in the weekly bonus table -------------------
   ESPN reports 0.00 for a player who hasn't kicked off, which on its own
   is indistinguishable from a player who finished with nothing. A player
   still to come shows his game time in place of that score, so the two
   can't be confused; one mid-game gets his live score plus a pulsing dot. */
.contrib { white-space: nowrap; }
.contrib-note { font-style: italic; }
.contrib-upcoming { opacity: 0.55; }
.contrib-bye { opacity: 0.55; }
.contrib-in_progress { color: var(--text); }
.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
    animation: live-dot-pulse 1.8s ease-in-out infinite;
}
@keyframes live-dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
}

/* A team with players still to come can't be compared against one that's
   finished, so its score drops the high/low heat wash rather than claiming
   a rank it hasn't earned, and says what's still outstanding. */
table.bonus-table td.score-cell.score-pending {
    background-color: rgba(148, 160, 184, 0.08);
}
.to-play {
    display: block;
    margin-top: 2px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
}

/* Gap to the week's leader. Measured against the top score rather than the
   winner flag, which is deliberately cleared mid-week - "how far back am I
   right now" is exactly the question worth answering while a week is live. */
table.bonus-table td.behind-cell {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
}
.behind-leader { color: var(--gold); font-weight: 700; }
/* A gap that can still move - either this team or the leader has players
   left to play - is worth showing anyway, but shouldn't read as settled. */
table.bonus-table td.behind-cell.behind-provisional {
    font-style: italic;
    opacity: 0.75;
}
