:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2129;
    --bg-hover: #252c36;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --gold: #f0c040;
    --aurora-1: #56d364;
    --aurora-2: #58a6ff;
    --aurora-3: #bc8cff;
    --northern-lights-bg: linear-gradient(135deg, #1a2332 0%, #162020 50%, #1a1a2e 100%);
    --northern-lights-border: #3fb950;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none !important;
}

.logo-img { height: 36px; width: auto; border-radius: 4px; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#season-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.search-box { position: relative; }

#search-input {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    width: 160px;
    transition: width 0.3s, border-color 0.2s;
}

#search-input:focus { width: 220px; border-color: var(--accent); outline: none; }
#search-input::placeholder { color: var(--text-muted); }

.header-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 6px;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.header-link:hover { color: var(--accent); text-decoration: none; }

#refresh-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

#refresh-btn:hover { color: var(--accent); border-color: var(--accent); }
#refresh-btn.spinning { animation: spin 1s linear infinite; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

#breadcrumbs {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#breadcrumbs:empty { display: none; }
#breadcrumbs a { color: var(--text-secondary); }
#breadcrumbs span { margin: 0 6px; }

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    flex: 1;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

/* Northern Lights Highlight Card */
.northern-lights-card {
    background: var(--northern-lights-bg);
    border: 2px solid var(--northern-lights-border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.northern-lights-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(86, 211, 100, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(88, 166, 255, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 50%, rgba(188, 140, 255, 0.04) 0%, transparent 50%);
    pointer-events: none;
}

.nl-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    position: relative;
}

.nl-logo {
    height: 64px;
    width: auto;
    border-radius: 6px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

.nl-header h2 {
    color: var(--aurora-1);
    font-size: 1.4rem;
}

.nl-badge {
    background: rgba(63, 185, 80, 0.15);
    color: var(--aurora-1);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nl-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    position: relative;
}

.nl-stat {
    text-align: center;
}

.nl-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.nl-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nl-next-game {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    color: var(--text-secondary);
    position: relative;
}

.nl-next-game strong { color: var(--text-primary); }

/* Division Cards Grid */
.divisions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.division-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.division-card { cursor: pointer; }
.division-card:hover { border-color: var(--accent); }

.division-card-header {
    padding: 14px 16px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.division-card-header h3 {
    font-size: 1rem;
    color: var(--accent);
}

.division-card-header .team-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tables */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stats-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.stats-table th:hover { color: var(--accent); }
.stats-table th.sorted-asc::after { content: ' ▲'; font-size: 0.65rem; }
.stats-table th.sorted-desc::after { content: ' ▼'; font-size: 0.65rem; }

.stats-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.stats-table .team-link, .team-link {
    font-weight: 600;
    cursor: pointer;
}

.team-link.highlight { color: var(--gold) !important; }

.stats-table .num { text-align: right; font-family: var(--font-mono); font-size: 0.8rem; }
.stats-table .highlight { color: var(--gold); font-weight: 600; }

tr.is-northern-lights {
    background: rgba(63, 185, 80, 0.06) !important;
}

tr.is-northern-lights td { color: var(--aurora-1); }
tr.is-northern-lights .team-link { color: var(--aurora-1) !important; }

/* Team View */
.team-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.team-header h1 {
    font-size: 1.8rem;
}

.team-record {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.team-header.is-northern-lights h1 { color: var(--aurora-1); }

.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.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; }

/* Player View */
.player-header {
    margin-bottom: 24px;
}

.player-header h1 {
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.jersey-number {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 1rem;
}

/* Game Result Rows */
.game-result { display: flex; align-items: center; gap: 8px; }

.game-score {
    font-family: var(--font-mono);
    font-weight: 700;
}

.game-win { color: var(--green); }
.game-loss { color: var(--red); }
.game-tie { color: var(--yellow); }
.game-upcoming { color: var(--text-muted); font-style: italic; }

/* Section Headers */
.section-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title .count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Streak badges */
.streak { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.streak-w { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.streak-l { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.streak-t { background: rgba(210, 153, 34, 0.15); color: var(--yellow); }

/* Scrollable table wrapper */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.table-scroll .stats-table th:first-child,
.table-scroll .stats-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
}

/* Special Teams Card */
.special-teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.st-card h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.st-card .big-stat {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
}

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

.roster-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .header-inner { padding: 10px 14px; }
    .logo-text { display: none; }
    main { padding: 12px; }
    .divisions-grid { grid-template-columns: 1fr; }
    .nl-stats { grid-template-columns: repeat(3, 1fr); }
    .nl-stat-value { font-size: 1.2rem; }
    .nl-next-game { font-size: 0.85rem; }
    .northern-lights-card { padding: 16px; }
    .team-header h1 { font-size: 1.3rem; }
    .stats-table { font-size: 0.78rem; }
    .stats-table th, .stats-table td { padding: 6px 6px; }
    .stats-table a { padding: 2px 0; }
    .footer-inner { flex-direction: column; gap: 4px; text-align: center; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }
    .special-teams-grid { grid-template-columns: 1fr 1fr; }
    .roster-grid { grid-template-columns: 1fr; }
    .st-card .big-stat { font-size: 1.5rem; }
    .section-title { font-size: 1rem; }
    .division-card-header { padding: 12px 14px 8px; }
    #search-input { width: 120px; }
    #search-input:focus { width: 160px; }
    .header-link { font-size: 0.8rem; padding: 6px 4px; }
}

@media (max-width: 480px) {
    .nl-stats { grid-template-columns: repeat(2, 1fr); }
    .nl-header { flex-wrap: wrap; gap: 6px; }
    .nl-header h2 { font-size: 1.1rem; }
    .nl-badge { font-size: 0.65rem; padding: 2px 6px; }
    .special-teams-grid { grid-template-columns: 1fr; }
    .stats-table { font-size: 0.72rem; }
    .stats-table th, .stats-table td { padding: 5px 4px; }
    .team-header { gap: 8px; }
    .team-header h1 { font-size: 1.1rem; }
    .team-record { font-size: 0.9rem; }
    .player-header h1 { font-size: 1.2rem; }
}
