:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-hover: #252830;
    --bg-row-alt: #13151d;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #666;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --border: #1e2130;
    --green: #4ade80;
    --red: #f87171;
    --amber: #fbbf24;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
    position: relative;
}

.super-header {
    position: absolute;
    top: 16px;
    left: 16px;
    text-decoration: none;
}

.super-logo {
    height: 64px;
    transition: opacity 0.15s;
}

.super-header:hover .super-logo {
    opacity: 0.7;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 72px;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.updated {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Landing Cards */
.landing-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.landing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 24px;
    text-decoration: none;
    color: var(--text-primary);
    text-align: center;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.landing-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.landing-card-icon {
    font-size: 2rem;
    line-height: 1;
}

.landing-card-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.landing-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
    overflow-x: auto;
}

.tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 18px;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Summary Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.chart-container.wide {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* Tables */
h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    padding: 10px 12px;
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

thead th.num {
    text-align: right;
}

thead th:hover {
    color: var(--accent);
}

thead th.sorted {
    color: var(--accent);
}

tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

tbody td.num {
    text-align: right;
}

tbody tr:nth-child(odd) {
    background: var(--bg-row-alt);
}

tbody tr:hover {
    background: var(--bg-hover);
}

.pct-high {
    color: var(--green);
}

.pct-low {
    color: var(--red);
}

/* Umpire table column widths */
#umpire-table { table-layout: fixed; }
#umpire-table .rank-col { width: 32px; }
#umpire-table th:nth-child(2) { width: 18%; }
#umpire-table th:nth-child(3),
#umpire-table th:nth-child(4),
#umpire-table th:nth-child(5),
#umpire-table th:nth-child(6),
#umpire-table th:nth-child(7),
#umpire-table th:nth-child(8) { width: 13%; }

/* Group header row */
.group-header th {
    border-bottom: 1px solid var(--border);
}

.group-label {
    text-align: center !important;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 4px !important;
}

/* Column separator */
.sep-right,
td.sep-right {
    border-right: 1px solid #2a2d3a;
}

/* Rank column */
.rank-col {
    width: 32px;
    color: var(--text-muted);
    cursor: default !important;
}

/* Team logos */
.logo-col {
    width: 32px;
    padding: 4px 6px !important;
    cursor: default !important;
}

.team-logo {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

/* Summary rows */
.total-row td {
    border-top: 2px solid var(--border);
    font-weight: 700;
    background: var(--bg-secondary) !important;
}

.avg-row td {
    font-weight: 600;
    font-style: italic;
    color: var(--accent);
}

.avg-row td.num {
    color: var(--accent);
}

/* Expandable sub-rows */
.team-row:hover {
    background: var(--bg-hover) !important;
}

.team-row.expanded {
    background: var(--bg-hover) !important;
    border-bottom-color: transparent;
}

.sub-row td {
    background: #161922 !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid #1a1d27;
}

.sub-name {
    padding-left: 12px !important;
}

.sub-role {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 4px;
}

/* Filters */
.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.search-input,
.filter-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.85rem;
}

.search-input {
    flex: 1;
    max-width: 280px;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    min-width: 120px;
}

/* Leaderboard / Loserboard */
.board-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.board-section h3 {
    margin-top: 24px;
}

.board-title {
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    padding: 12px 0;
    border-radius: 8px;
    letter-spacing: 0.02em;
}

.board-leader {
    color: var(--green);
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.board-loser {
    color: var(--red);
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.table-subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.board-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0;
}

.worst-tables-section {
    max-width: 1100px;
    margin: 0 auto;
}

.worst-tables-section h3:first-child {
    margin-top: 8px;
}

.worst-tables-section h3 {
    text-align: center;
    margin-top: 28px;
}

.worst-table {
    width: 100%;
    white-space: nowrap;
}

.worst-table td,
.worst-table th {
    padding: 8px 10px;
}

/* Tied note row */
.tied-row td {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    padding: 8px 12px !important;
    border-bottom: none !important;
    background: transparent !important;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Responsive */
/* Tablet (≤768px) */
@media (max-width: 768px) {
    .super-header {
        position: static;
        display: block;
        text-align: center;
        margin-bottom: 8px;
    }

    .super-logo {
        height: 40px;
    }

    header {
        padding-top: 0;
    }

    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .hide-mobile {
        display: none;
    }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .filter-row {
        flex-direction: column;
    }

    .search-input {
        max-width: 100%;
    }

    .landing-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .board-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .landing-card {
        padding: 24px 16px;
    }

    /* Tighter table spacing */
    table { font-size: 0.78rem; }
    thead th { padding: 6px 6px; font-size: 0.75rem; }
    tbody td { padding: 6px 6px; }
    .rank-col { width: 24px; }
    .logo-col { width: 26px; padding: 3px 4px !important; }
    .team-logo { width: 20px; height: 20px; }
    .group-label { font-size: 0.7rem; }

    /* Strike zone canvas */
    #chart-strike-zone {
        width: 100% !important;
        height: auto !important;
    }
}

/* Phone (≤480px) */
@media (max-width: 480px) {
    .container { padding: 16px 8px; }
    header h1 { font-size: 1.3rem; }
    .subtitle { font-size: 0.8rem; }

    .cards {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .card { padding: 10px 6px; }
    .card-value { font-size: 1.3rem; }
    .card-label { font-size: 0.7rem; }

    .hide-phone { display: none; }

    /* Tighter table spacing for phones */
    table { font-size: 0.75rem; }
    thead th { padding: 5px 4px; font-size: 0.7rem; }
    tbody td { padding: 5px 4px; }
    .rank-col { width: 20px; padding: 5px 2px !important; }
    .logo-col { width: 22px; padding: 3px 2px !important; }
    .team-logo { width: 18px; height: 18px; }

    /* Umpire name needs more room on phone since fewer columns */
    #umpire-table th:nth-child(2) { width: 35%; }

    /* Sub-rows */
    .sub-row td { font-size: 0.7rem; padding: 3px 4px !important; }
    .sub-role { display: none; }

    .chart-container { padding: 12px; }
}
