:root {
    --primary-color: #e10600;
    --secondary-color: #15151e;
    --accent-color: #ff1801;
    --text-color: #ffffff;
    --text-secondary: #b8b8b8;
    --background: #15151e;
    --card-background: #1e1e2e;
    --border-color: #2a2a3a;
    --success: #00d26a;
    --warning: #ffb800;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Навигация */
.navbar {
    background: var(--card-background);
    border-bottom: 2px solid var(--primary-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s;
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

/* Таймер обратного отсчёта */
.countdown-section {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--card-background) 0%, #252535 100%);
    border-radius: 15px;
    margin: 2rem 0;
}

.countdown-section h1 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.countdown {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.time-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--secondary-color);
    padding: 1.5rem 2rem;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    min-width: 120px;
}

.time-value {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
}

.time-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.next-race-info {
    margin-top: 2rem;
}

.next-race-info h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.next-race-info p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Последние результаты */
.latest-results {
    margin: 3rem 0;
}

.latest-results h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.race-result-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.race-header h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* Подиум */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 1rem;
    padding: 2rem 0;
}

.podium-place {
    flex: 1;
    max-width: 250px;
    background: var(--secondary-color);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: transform 0.3s;
}

.podium-place:hover {
    transform: translateY(-5px);
}

.podium-place.first {
    height: 280px;
    border-color: #ffd700;
}

.podium-place.second {
    height: 240px;
    border-color: #c0c0c0;
}

.podium-place.third {
    height: 220px;
    border-color: #cd7f32;
}

.podium-place .position {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.podium-place.first .position {
    font-size: 2.5rem;
}

.driver-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.team-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Турнирная таблица (превью) */
.standings-preview {
    margin: 3rem 0;
}

.standings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.standings-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.standings-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.standings-list {
    margin-bottom: 1rem;
}

.standing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--secondary-color);
    margin-bottom: 0.5rem;
    border-radius: 8px;
    transition: background 0.3s;
}

.standing-item:hover {
    background: #252535;
}

.driver-info-line {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.position-number {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary-color);
    min-width: 30px;
}

.driver-name-inline {
    font-weight: 500;
}

.points {
    font-weight: bold;
    color: var(--success);
}

.view-all {
    display: inline-block;
    margin-top: 1rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.view-all:hover {
    text-decoration: underline;
}

/* Статистика сезона */
.season-stats {
    margin: 3rem 0;
}

.season-stats h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Заголовок страницы */
.page-header {
    text-align: center;
    padding: 3rem 0;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.page-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Календарь */
.schedule-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.filter-btn {
    background: var(--card-background);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.filter-btn:hover {
    border-color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.schedule-item {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid var(--border-color);
    display: grid;
    grid-template-columns: 100px 1fr 200px;
    gap: 2rem;
    align-items: center;
    transition: all 0.3s;
}

.schedule-item:hover {
    border-left-color: var(--primary-color);
    transform: translateX(5px);
}

.schedule-item.upcoming {
    border-left-color: var(--success);
}

.schedule-item.completed {
    opacity: 0.7;
}

.race-round {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.race-details h3 {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.race-details p {
    color: var(--text-secondary);
}

.race-date {
    text-align: right;
    color: var(--text-secondary);
}

/* Турнирная таблица */
.standings-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.tab-btn {
    background: var(--card-background);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 1rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.3s;
}

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

.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

.standings-table-container {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    overflow-x: auto;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
}

.standings-table th {
    background: var(--secondary-color);
    padding: 1rem;
    text-align: left;
    color: var(--primary-color);
    font-weight: 600;
}

.standings-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.standings-table tbody tr:hover {
    background: var(--secondary-color);
}

.standings-table .position-cell {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* Команды */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.team-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    transition: transform 0.3s;
}

.team-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.team-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.team-drivers {
    margin-top: 1rem;
}

.driver-item {
    background: var(--secondary-color);
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

/* Пилоты */
.drivers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.driver-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.3s;
}

.driver-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.driver-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.driver-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.driver-card .team-name {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Состав пилотов, сгруппированный по командам */
.driver-roster { display: grid; gap: 3rem; }
.driver-roster-section { display: grid; gap: 1.25rem; }
.driver-roster-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.driver-roster-heading h2 { margin: 0; color: var(--primary-color); }
.driver-roster-heading p { margin: 0; color: var(--text-secondary); }
.driver-team-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 1.25rem; }
.driver-team-group {
    min-width: 0;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-top: 2px solid color-mix(in srgb, var(--team-accent) 80%, transparent);
    border-radius: 16px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--team-accent) 8%, #171920), #12141a 70%);
}
.driver-team-heading { display: flex; align-items: center; gap: .8rem; min-width: 0; margin-bottom: 1rem; }
.driver-team-heading .team-logo-wrap { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 12px; }
.driver-team-heading h3 { min-width: 0; margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.driver-team-heading > .country-flag { flex: 0 0 auto; }
.driver-team-count { margin-left: auto; color: var(--text-secondary); font-size: .8rem; white-space: nowrap; }
.driver-group-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: .85rem; }
.driver-team-group .driver-card { min-width: 0; padding: 1.1rem; border-radius: 12px; }
.driver-team-group .driver-card h3 { font-size: 1.12rem; overflow-wrap: anywhere; }
.driver-team-group .driver-card .team-name { margin-bottom: .65rem; }
.driver-team-group .driver-card .nationality-line { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .4rem; color: var(--text-secondary); font-size: .85rem; }
.driver-team-group .driver-card .country-flag { width: 24px; height: auto; border-radius: 3px; }
.reserve-driver-card { text-align: left; }
.reserve-driver-card .driver-card-heading { min-height: 38px; }
.reserve-driver-card .driver-role-pill { padding: .35rem .55rem; border: 1px solid color-mix(in srgb, var(--team-accent) 55%, transparent); border-radius: 999px; color: var(--team-accent); font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.reserve-driver-card .reserve-driver-number { font-size: .75rem; color: var(--text-secondary); }
.reserve-roster-note { margin: 0; color: var(--text-secondary); }

.driver-roster .driver-stats { margin-top: 1rem; padding-top: 1rem; }
.driver-roster .driver-stat-value { font-size: 1.2rem; }
.driver-roster .driver-stat-label { font-size: .72rem; }

.driver-roster-section .loading { grid-column: 1 / -1; }

@media (max-width: 560px) {
    .driver-roster { gap: 2rem; }
    .driver-team-group { padding: .85rem; }
    .driver-team-heading { gap: .55rem; }
    .driver-team-count { font-size: .7rem; }
}

.driver-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

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

.driver-stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.driver-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Результаты */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.result-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.result-card h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th {
    background: var(--secondary-color);
    padding: 0.8rem;
    text-align: left;
    color: var(--primary-color);
}

.results-table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.results-table .p1 { color: #ffd700; font-weight: bold; }
.results-table .p2 { color: #c0c0c0; font-weight: bold; }
.results-table .p3 { color: #cd7f32; font-weight: bold; }

/* Footer */
footer {
    background: var(--card-background);
    border-top: 2px solid var(--primary-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

footer p {
    color: var(--text-secondary);
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .countdown {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .time-block {
        min-width: 80px;
        padding: 1rem;
    }

    .time-value {
        font-size: 2rem;
    }

    .podium {
        flex-direction: column;
        align-items: center;
    }

    .podium-place {
        max-width: 100%;
        height: auto !important;
    }

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

    .schedule-item {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .race-date {
        text-align: left;
    }
}

.driver-card, .team-card {
    position: relative;
    overflow: hidden;
    border-top: 2px solid color-mix(in srgb, var(--team-accent, var(--primary-color)) 80%, transparent);
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--team-accent, #171920) 11%, #171920),
        #12141a 68%);
}
.driver-card::before, .team-card::before {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    top: -94px;
    right: -72px;
    border: 1px solid color-mix(in srgb, var(--team-accent, #fff) 32%, transparent);
    border-radius: 50%;
    box-shadow: 0 0 0 16px color-mix(in srgb, var(--team-accent, #fff) 6%, transparent);
    pointer-events: none;
}
.driver-card:hover, .team-card:hover {
    border-color: color-mix(in srgb, var(--team-accent, var(--primary-color)) 70%, #343844);
    box-shadow: 0 16px 36px color-mix(in srgb, var(--team-accent, #000) 14%, transparent);
}
.driver-card-heading, .team-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    margin-bottom: .75rem;
}
.driver-card .driver-number {
    margin: 0;
    color: var(--team-accent, var(--primary-color));
    font-size: 2.4rem;
    line-height: 1;
}
.team-color-chip {
    display: block;
    width: 30px;
    height: 30px;
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 50%;
    background: var(--team-accent, var(--primary-color));
    box-shadow: 0 0 24px color-mix(in srgb, var(--team-accent, #fff) 40%, transparent);
}
.team-logo-wrap {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--team-accent, #fff) 45%, #282b35);
    border-radius: 14px;
    background: #f4f4f5;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--team-accent, #000) 18%, transparent);
}
.team-logo {
    width: 100%;
    height: 100%;
    padding: 5px;
    object-fit: contain;
}
.team-logo-fallback {
    color: #15161b;
    font-size: .9rem;
    font-weight: 900;
    letter-spacing: -.06em;
}
.team-accent-label {
    color: var(--team-accent, var(--text-secondary));
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .2em;
}
.team-card h3 { color: var(--text-color); }

/* Home dashboard identity */
.podium-place {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: .55rem;
    background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #30333d) 20%, transparent), #111319 72%);
}
.podium-place::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: var(--team-accent, var(--primary-color));
}
.podium-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    min-height: 46px;
}
.podium-team-logo {
    display: grid;
    width: 44px;
    height: 38px;
    place-items: center;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--team-accent, #777) 38%, #fff);
    border-radius: 9px;
    background: #f5f5f5;
    color: #15161b;
    font-size: .72rem;
    font-weight: 900;
}
.podium-team-logo img { width: 100%; height: 100%; padding: 3px; object-fit: contain; }
.podium-flag { width: 25px; height: 18px; }
.podium-place .position { position: relative; z-index: 1; margin: .15rem 0 .4rem; }
.podium-place.first .position { font-size: 2.25rem; }
.podium-place .driver-info { margin-top: auto; }
.podium-place .driver-name { font-size: clamp(.95rem, 1.5vw, 1.12rem); }
.podium-place .team-name { color: color-mix(in srgb, var(--team-accent, var(--text-secondary)) 78%, white); }

.standing-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 36px;
    gap: .6rem;
    border-left: 2px solid color-mix(in srgb, var(--team-accent, var(--primary-color)) 78%, transparent);
    background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #101218) 12%, #101218), #101218 48%);
}
.standing-item:hover {
    background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #191b23) 19%, #191b23), #191b23 48%);
}

/* Theme switch */
.theme-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 40px;
    padding: .5rem .8rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--secondary-color);
    color: var(--text-color);
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, border-color .2s, transform .2s;
}
.theme-toggle:hover { border-color: var(--primary-color); transform: translateY(-1px); }
.theme-toggle-icon { color: var(--primary-color); font-size: 1.05rem; line-height: 1; }

html[data-theme="light"] {
    color-scheme: light;
    --primary-color: #c92520;
    --secondary-color: #edf0f4;
    --accent-color: #c92520;
    --text-color: #20242c;
    --text-secondary: #626a76;
    --background: #f2f4f7;
    --card-background: #ffffff;
    --border-color: #d9dee6;
    --success: #087d4b;
    --warning: #a66b00;
}
html[data-theme="light"] body { background: radial-gradient(ellipse at 50% -30%, #fff 0, var(--background) 48rem); }
html[data-theme="light"] .navbar { background: rgb(255 255 255 / 94%); box-shadow: 0 5px 22px rgb(30 40 55 / 7%); }
html[data-theme="light"] .countdown-section { background: linear-gradient(135deg, #fff, #e9edf3); }
html[data-theme="light"] .time-block,
html[data-theme="light"] .race-result-card,
html[data-theme="light"] .result-card,
html[data-theme="light"] .standings-card,
html[data-theme="light"] .driver-card,
html[data-theme="light"] .team-card,
html[data-theme="light"] .driver-team-group {
    background: linear-gradient(145deg, #fff, #f4f6f9 78%);
    color: var(--text-color);
    border-color: var(--border-color);
}
html[data-theme="light"] .podium-place { background: #fff; color: var(--text-color); }
html[data-theme="light"] .podium-place .team-name,
html[data-theme="light"] .result-card h3,
html[data-theme="light"] .race-header h3,
html[data-theme="light"] .standings-card h2,
html[data-theme="light"] .page-header h1 { color: var(--primary-color); }
html[data-theme="light"] .standing-item,
html[data-theme="light"] .results-table tbody tr.result-driver-row,
html[data-theme="light"] .results-table tbody tr:not(.result-driver-row) {
    background: color-mix(in srgb, var(--team-accent, #fff) 7%, #fff);
    color: var(--text-color);
    border-color: var(--border-color);
}
html[data-theme="light"] .standing-item:hover,
html[data-theme="light"] .results-table tbody tr.result-driver-row:hover,
html[data-theme="light"] .results-table tbody tr:not(.result-driver-row):hover {
    background: color-mix(in srgb, var(--team-accent, #edf0f4) 14%, #fff);
}
html[data-theme="light"] .standings-table th,
html[data-theme="light"] .results-table th { background: #e9edf3; color: var(--primary-color); }
html[data-theme="light"] .schedule-item { background: #fff; border-color: var(--border-color); }
html[data-theme="light"] .podium-tooltip { background: #fff; color: var(--text-color); border-color: var(--border-color); box-shadow: 0 16px 42px rgb(25 32 44 / 18%); }
html[data-theme="light"] .podium-tooltip-row { border-color: var(--border-color); }
html[data-theme="light"] .podium-tooltip-driver { color: #805e00; }
html[data-theme="light"] .podium-count { background: #fff; }
html[data-theme="light"] .sprint-panel { background: linear-gradient(100deg, #fff3f1, #fff 70%); }
html[data-theme="light"] .sprint-countdown-wrap { border-color: var(--border-color); }
html[data-theme="light"] #sprintCountdown { color: var(--text-color); }
html[data-theme="light"] .session-time { color: var(--text-secondary) !important; }
html[data-theme="light"] .team-card h3,
html[data-theme="light"] .driver-card h3 { color: var(--text-color); }
html[data-theme="light"] .driver-card .driver-number { color: var(--team-accent, var(--primary-color)); }
html[data-theme="light"] .team-logo-wrap,
html[data-theme="light"] .podium-team-logo,
html[data-theme="light"] .standing-team-mark,
html[data-theme="light"] .standings-logo,
html[data-theme="light"] .result-team-logo { background: #fff; }
html[data-theme="light"] footer { background: #fff; }

@media (max-width: 768px) {
    .navbar .container { flex-wrap: wrap; }
    .theme-toggle { margin-left: auto; }
}

/* Championship tables and race classifications */
.standings-table tbody tr.driver-standings-row,
.standings-table tbody tr.constructor-standings-row {
    background: linear-gradient(90deg, color-mix(in srgb, var(--team-accent, #14161d) 12%, #14161d), #14161d 72%);
    transition: background .18s ease;
}
.standings-table tbody tr.driver-standings-row:hover,
.standings-table tbody tr.constructor-standings-row:hover {
    background: linear-gradient(90deg, color-mix(in srgb, var(--team-accent, #20232b) 23%, #20232b), #20232b 72%);
}
.standings-table tbody tr.driver-standings-row td:first-child,
.standings-table tbody tr.constructor-standings-row td:first-child {
    border-left: 3px solid var(--team-accent, var(--primary-color));
}
.standings-driver-content, .standings-constructor-content {
    display: flex;
    align-items: center;
    gap: .8rem;
}
.standings-driver-content { min-width: 0; }
.standings-driver-content strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings-driver-content .country-flag { flex: 0 0 auto; }
.standings-constructor-content > span:last-child { min-width: 0; }
.standings-constructor-cell small {
    display: block;
    margin-top: .12rem;
    color: var(--text-secondary);
    font-size: .78rem;
}
.standings-logo, .result-team-logo {
    display: inline-grid;
    flex: 0 0 auto;
    width: 38px;
    height: 32px;
    place-items: center;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--team-accent, #888) 42%, #fff);
    border-radius: 7px;
    background: #f2f2f3;
    color: #15161b;
    font-size: .58rem;
    font-weight: 900;
}
.standings-logo img, .result-team-logo img {
    width: 100%;
    height: 100%;
    padding: 3px;
    object-fit: contain;
}
.result-card {
    border-left: 3px solid var(--team-accent, var(--primary-color));
    background: linear-gradient(140deg, color-mix(in srgb, var(--team-accent, #171920) 8%, #171920), #12141a 38%);
}
.result-card h3 { color: color-mix(in srgb, var(--team-accent, var(--primary-color)) 72%, white); }
.result-race-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .8rem;
    color: var(--text-secondary);
    font-size: .84rem;
}
.race-winner-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .25rem .6rem .25rem .3rem;
    border: 1px solid color-mix(in srgb, var(--team-accent, #777) 35%, var(--border-color));
    border-radius: 999px;
    background: color-mix(in srgb, var(--team-accent, #171920) 13%, #111319);
    color: var(--text-color);
    white-space: nowrap;
}
.winner-logo { width: 27px; height: 24px; border-radius: 50%; }
.results-table-wrap { overflow-x: auto; border-radius: 9px; }
.results-table { min-width: 690px; }
.qualifying-results-table { min-width: 810px; }
.qualifying-time-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.qualifying-best-time {
    color: #ffe08a;
    font-weight: 800;
    text-decoration: underline;
    text-decoration-color: rgb(233 189 85 / 55%);
    text-decoration-thickness: 1px;
    text-underline-offset: .22rem;
    white-space: nowrap;
}
.qualifying-best-icon { margin-right: .22rem; color: #e9bd55; font-size: .7rem; }
.qualifying-circuit { margin-bottom: 1rem; color: var(--text-secondary); }
.qualifying-more { margin-top: 1rem; text-align: center; color: var(--text-secondary); }
.results-table tbody tr.result-driver-row {
    background: linear-gradient(90deg, color-mix(in srgb, var(--team-accent, #14161d) 14%, #14161d), #14161d 70%);
    transition: background .18s ease;
}
.results-table tbody tr.result-driver-row:hover {
    background: linear-gradient(90deg, color-mix(in srgb, var(--team-accent, #20232b) 25%, #20232b), #20232b 70%);
}
.results-table tbody tr.result-driver-row td:first-child { border-left: 3px solid var(--team-accent, var(--primary-color)); }
.result-driver-cell, .result-team-cell { white-space: nowrap; }
.finish-position { font-variant-numeric: tabular-nums; font-weight: 700; }
.position-change {
    display: inline-flex;
    align-items: center;
    margin-left: .45rem;
    font-size: .78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    vertical-align: .04em;
}
.position-change-up { color: #31c982; }
.position-change-down { color: #ff716d; }
.position-change-steady { color: var(--text-secondary); }
.result-driver-cell .country-flag { margin-right: .6rem; vertical-align: middle; }
.result-team-cell { white-space: nowrap; }
.result-team-brand { display: inline-flex; align-items: center; gap: .55rem; }

@media (max-width: 768px) {
    .standings-table-container { padding: .6rem; }
    .standings-table td, .standings-table th { padding: .7rem .65rem; }
    .standings-constructor-content { gap: .5rem; }
    .standings-logo { width: 32px; height: 28px; }
    .race-header { align-items: flex-start; }
    .result-race-meta { justify-content: flex-start; align-items: flex-start; flex-direction: column; }
}

#driversTable { min-width: 880px; table-layout: fixed; }
#driversTable th:nth-child(1), #driversTable td:nth-child(1) { width: 72px; }
#driversTable th:nth-child(2), #driversTable td:nth-child(2) { width: 250px; }
#driversTable th:nth-child(3), #driversTable td:nth-child(3) { width: 190px; }
#driversTable th:nth-child(n + 4), #driversTable td:nth-child(n + 4) { width: 92px; }
#constructorsTable { min-width: 710px; table-layout: fixed; }
#constructorsTable th:nth-child(1), #constructorsTable td:nth-child(1) { width: 72px; }
#constructorsTable th:nth-child(2), #constructorsTable td:nth-child(2) { width: 300px; }
#constructorsTable th:nth-child(n + 3), #constructorsTable td:nth-child(n + 3) { width: 110px; }

/* Keep team tint and accents strictly inside table cells. */
.standings-table {
    border-collapse: separate;
    border-spacing: 0 3px;
}
.standings-table th,
.standings-table td {
    vertical-align: middle;
}
.standings-table tbody tr.driver-standings-row,
.standings-table tbody tr.constructor-standings-row,
.standings-table tbody tr.driver-standings-row:hover,
.standings-table tbody tr.constructor-standings-row:hover {
    background: transparent;
}
.standings-table tbody tr.driver-standings-row td,
.standings-table tbody tr.constructor-standings-row td {
    background: color-mix(in srgb, var(--team-accent, #14161d) 12%, #14161d);
}
.standings-table tbody tr.driver-standings-row:hover td,
.standings-table tbody tr.constructor-standings-row:hover td {
    background: color-mix(in srgb, var(--team-accent, #20232b) 23%, #20232b);
}
.standings-table tbody tr.driver-standings-row td:first-child,
.standings-table tbody tr.constructor-standings-row td:first-child {
    border-left: 0;
    box-shadow: inset 3px 0 var(--team-accent, var(--primary-color));
}
.results-table tbody tr.result-driver-row,
.results-table tbody tr.result-driver-row:hover { background: transparent; }
.results-table tbody tr.result-driver-row td {
    background: color-mix(in srgb, var(--team-accent, #14161d) 12%, #14161d);
    vertical-align: middle;
}
.results-table tbody tr.result-driver-row:hover td {
    background: color-mix(in srgb, var(--team-accent, #20232b) 23%, #20232b);
}
.results-table tbody tr.result-driver-row td:first-child {
    border-left: 0;
    box-shadow: inset 3px 0 var(--team-accent, var(--primary-color));
}
.podium-count-cell { text-align: center; }
.podium-count-trigger {
    padding: .25rem .55rem;
    border: 1px solid rgb(255 255 255 / 12%);
    border-radius: 7px;
    background: rgb(255 255 255 / 4%);
    color: var(--text-color);
    font: inherit;
    font-weight: 800;
    cursor: help;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.podium-count-trigger:hover, .podium-count-trigger:focus-visible {
    border-color: #e9bd55;
    background: rgb(233 189 85 / 12%);
    color: #ffe39a;
    outline: none;
}
.pole-count-trigger { border-color: color-mix(in srgb, #e9bd55 48%, transparent); }
.pole-count-trigger:hover, .pole-count-trigger:focus-visible { border-color: #e9bd55; }
.podium-count-zero { color: var(--text-secondary); }
.podium-tooltip {
    position: fixed;
    z-index: 3000;
    width: min(360px, calc(100vw - 24px));
    max-height: min(55vh, 420px);
    overflow: auto;
    padding: .8rem;
    border: 1px solid #393d48;
    border-radius: 12px;
    background: #171920;
    box-shadow: 0 18px 48px rgb(0 0 0 / 55%);
    color: var(--text-color);
    pointer-events: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #777b86 #20222a;
}
.podium-tooltip[hidden] { display: none; }
.podium-tooltip:focus-visible { outline: 2px solid #e9bd55; outline-offset: 2px; }
.podium-tooltip-title {
    display: block;
    padding: .15rem .25rem .65rem;
    border-bottom: 1px solid var(--border-color);
    color: #f4d37b;
    font-size: .9rem;
}
.podium-tooltip-row {
    display: grid;
    grid-template-columns: 27px minmax(0, 1fr) auto;
    align-items: center;
    gap: .45rem;
    padding: .55rem .25rem;
    border-bottom: 1px solid rgb(255 255 255 / 6%);
    font-size: .8rem;
}
.podium-tooltip-row:last-child { border-bottom: 0; }
.podium-medal { font-size: 1rem; }
.podium-tooltip-details { display: flex; min-width: 0; flex-direction: column; gap: .2rem; }
.podium-tooltip-race { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-tooltip-driver { color: #f0d27f; font-size: .76rem; }
.podium-tooltip-place { color: var(--text-secondary); white-space: nowrap; }
.standing-item .driver-info-line { min-width: 0; gap: .65rem; }
.standing-item .position-number { min-width: 22px; font-size: 1.05rem; }
.driver-name-inline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing-item .points { white-space: nowrap; font-size: .82rem; }
.standing-team-mark {
    display: grid;
    width: 34px;
    height: 30px;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: #f1f1f2;
    color: #15161b;
    font-size: .58rem;
    font-weight: 900;
}
.standing-team-mark img { width: 100%; height: 100%; padding: 3px; object-fit: contain; }

@media (max-width: 768px) {
    .standing-item { grid-template-columns: minmax(0, 1fr) auto 30px; gap: .35rem; padding: .8rem .55rem; }
    .standing-item .points { font-size: .73rem; }
    .standing-team-mark { width: 29px; height: 27px; }
}

.session-time {
    color: #c1c4cd !important;
    font-size: .9rem !important;
}
.sprint-panel[hidden] { display: none; }
.sprint-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 760px;
    margin-top: 1.5rem;
    padding: 1rem 1.15rem;
    border: 1px solid rgb(255 88 80 / 28%);
    border-left: 3px solid #ff625c;
    border-radius: 12px;
    background: linear-gradient(100deg, rgb(255 72 65 / 9%), rgb(18 19 25 / 76%) 65%);
}
.sprint-badge {
    display: inline-block;
    margin-bottom: .55rem;
    color: #ff827b;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .16em;
}
.sprint-panel-details p {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .6rem;
    margin: .2rem 0;
    color: var(--text-secondary);
    font-size: .84rem;
}
.sprint-panel-details strong { color: var(--text-color); }
.sprint-countdown-wrap {
    display: flex;
    min-width: 145px;
    flex-direction: column;
    align-items: flex-end;
    gap: .25rem;
    padding-left: 1rem;
    border-left: 1px solid rgb(255 255 255 / 10%);
}
.sprint-countdown-label {
    color: var(--text-secondary);
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}
#sprintCountdown {
    color: #fff;
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}
.race-details .session-time { margin-top: .45rem; font-size: .84rem !important; }
.race-date-label {
    margin-bottom: .35rem;
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.race-date strong { color: var(--text-color); font-size: .9rem; }

.practice-disclosure { max-width: 560px; margin-top: .85rem; }
.practice-disclosure[hidden] { display: none; }
.practice-disclosure summary {
    display: flex;
    width: fit-content;
    min-width: 160px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: color-mix(in srgb, var(--card-background) 82%, transparent);
    color: var(--text-color);
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.practice-disclosure summary::-webkit-details-marker { display: none; }
.practice-disclosure summary::after { color: var(--primary-color); content: "+"; font-size: 1.1rem; line-height: 1; }
.practice-disclosure[open] summary::after { content: "−"; }
.practice-count { margin-left: auto; color: var(--text-secondary); font-size: .74rem; font-weight: 500; }
.practice-sessions { display: grid; gap: .45rem; margin-top: .6rem; }
.practice-session {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem .75rem;
    border-left: 2px solid color-mix(in srgb, var(--primary-color) 65%, transparent);
    border-radius: 0 8px 8px 0;
    background: color-mix(in srgb, var(--card-background) 72%, transparent);
    font-size: .82rem;
}
.practice-session strong { color: var(--text-color); font-weight: 600; }
.practice-session span { color: var(--text-secondary); text-align: right; }
html[data-theme="light"] .practice-disclosure summary,
html[data-theme="light"] .practice-session { background: rgb(255 255 255 / 78%); }

@media (max-width: 768px) {
    .sprint-panel { align-items: flex-start; flex-direction: column; gap: .9rem; }
    .practice-session { align-items: flex-start; flex-direction: column; gap: .15rem; }
    .practice-session span { text-align: left; }
    .sprint-countdown-wrap {
        align-items: flex-start;
        padding: .7rem 0 0;
        border-top: 1px solid rgb(255 255 255 / 10%);
        border-left: 0;
    }
}
.nationality-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    margin: .8rem 0 1rem;
    color: var(--text-secondary);
    font-size: .9rem;
}
.team-card .nationality-line { justify-content: flex-start; margin-bottom: 0; }
.country-flag {
    display: inline-block;
    width: 21px;
    height: 15px;
    border: 1px solid rgb(255 255 255 / 16%);
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}
.nationality-dot { color: #666b76; }
.card-link {
    display: inline-block;
    margin-top: 1.1rem;
    color: color-mix(in srgb, var(--team-accent, var(--primary-color)) 78%, white);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}
.card-link:hover { text-decoration: underline; }

/* F1 Tracker refresh */
:root {
    --primary-color: #ff2d2d;
    --secondary-color: #101116;
    --accent-color: #ff4b44;
    --text-color: #f5f5f6;
    --text-secondary: #a3a5ae;
    --background: #0b0c10;
    --card-background: #14161d;
    --border-color: #282b35;
    --success: #5be0a0;
}

body {
    background: radial-gradient(ellipse at 50% -30%, #2a1518 0, var(--background) 48rem);
    font-family: Inter, "Segoe UI", sans-serif;
}

.container { max-width: 1240px; }
.navbar {
    background: rgb(12 13 17 / 88%);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
}
.logo { color: var(--text-color); letter-spacing: -.04em; }
.logo::first-letter { color: var(--primary-color); }
.nav-links { gap: clamp(.7rem, 2vw, 1.7rem); }
.nav-links a { font-size: .92rem; }
.nav-links a:hover, .nav-links a.active { color: #ff6a63; }

.countdown-section {
    position: relative;
    overflow: hidden;
    text-align: left;
    padding: clamp(2rem, 6vw, 4.5rem);
    margin: 2.25rem 0;
    border: 1px solid #34303a;
    border-radius: 20px;
    background: linear-gradient(110deg, rgb(24 25 31 / 97%) 10%, rgb(35 17 21 / 95%) 100%);
    box-shadow: 0 24px 80px rgb(0 0 0 / 26%);
}
.countdown-section::after {
    content: "";
    position: absolute;
    width: 22rem;
    height: 22rem;
    right: -7rem;
    top: -13rem;
    border: 1px solid rgb(255 65 59 / 20%);
    border-radius: 50%;
    box-shadow: 0 0 0 2rem rgb(255 65 59 / 4%), 0 0 0 4rem rgb(255 65 59 / 3%);
    pointer-events: none;
}
.countdown-section h1 {
    position: relative;
    z-index: 1;
    color: var(--text-secondary);
    font-size: .85rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    margin-bottom: 1.4rem;
}
.countdown { position: relative; z-index: 1; justify-content: flex-start; gap: .7rem; margin: 0; }
.time-block {
    min-width: clamp(68px, 10vw, 112px);
    padding: .85rem .75rem;
    border: 1px solid #35343d;
    border-radius: 12px;
    background: rgb(9 10 14 / 58%);
}
.time-value { font-size: clamp(1.75rem, 4vw, 3rem); line-height: 1.15; color: #fff; font-variant-numeric: tabular-nums; }
.time-label { margin-top: .35rem; font-size: .68rem; letter-spacing: .12em; }
.next-race-info { position: relative; z-index: 1; margin-top: 1.65rem; }
.next-race-info h2 { margin-bottom: .35rem; font-size: clamp(1.45rem, 3vw, 2.1rem); }
.next-race-info p { font-size: .98rem; }

.latest-results, .standings-preview, .season-stats { margin: 3.5rem 0; }
.latest-results h2, .season-stats h2 { font-size: 1.65rem; letter-spacing: -.025em; }
.race-result-card, .standings-card, .stat-card, .standings-table-container,
.team-card, .driver-card, .result-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: linear-gradient(145deg, #171920, #12141a);
    box-shadow: 0 10px 32px rgb(0 0 0 / 12%);
}
.race-result-card { padding: clamp(1.1rem, 4vw, 2rem); }
.race-header { border-bottom: 1px solid var(--border-color); }
.race-header h3, .standings-card h2, .page-header h1 { color: #ff625c; }
.podium-place { border-radius: 12px; background: #111319; }
.standing-item { background: #101218; border: 1px solid transparent; }
.standing-item:hover { background: #191b23; border-color: var(--border-color); }
.position-number { color: #ff625c; }
.points { color: var(--success); font-variant-numeric: tabular-nums; }
.stat-card { padding: 1.5rem; }
.stat-value { font-size: 2.5rem; }
.page-header { padding: 3.5rem 0 2.25rem; }
.page-header h1 { font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: -.04em; }
.page-header p { font-size: 1rem; }
.schedule-item { border: 1px solid var(--border-color); border-left: 3px solid #3a3d47; border-radius: 12px; background: #14161d; }
.schedule-item.upcoming { border-left-color: var(--success); }
.schedule-item.completed { opacity: .78; }
.filter-btn, .tab-btn { border-width: 1px; border-radius: 999px; }
.filter-btn.active, .tab-btn.active { background: #e32620; border-color: #e32620; }
.standings-table th { position: sticky; top: 0; background: #1b1d25; }
.standings-table td, .standings-table th { padding: .95rem 1rem; }
.team-card, .driver-card, .result-card { padding: clamp(1.2rem, 3vw, 2rem); }
footer { border-top: 1px solid var(--border-color); }

@media (max-width: 768px) {
    .navbar .container { align-items: flex-start; flex-direction: column; gap: .85rem; }
    .nav-links { flex-direction: row; width: 100%; gap: .4rem .95rem; flex-wrap: wrap; }
    .nav-links a { font-size: .82rem; }
    .countdown-section { padding: 1.5rem 1.1rem; }
    .countdown { gap: .45rem; }
    .time-block { flex: 1 1 65px; padding: .7rem .4rem; }
    .standings-grid, .teams-grid, .drivers-grid { grid-template-columns: 1fr; }
    .schedule-filters, .standings-tabs { gap: .5rem; flex-wrap: wrap; }
    .filter-btn, .tab-btn { padding: .7rem 1rem; font-size: .9rem; }
    .standings-table-container { padding: .75rem; }
    .standings-table { min-width: 590px; }
    .race-header { align-items: flex-start; gap: .75rem; flex-direction: column; }
}

/* Driver and constructor identity */
.driver-card, .team-card {
    border-top: 2px solid color-mix(in srgb, var(--team-accent, var(--primary-color)) 80%, transparent);
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--team-accent, #171920) 11%, #171920),
        #12141a 68%);
}
.driver-card:hover, .team-card:hover {
    border-color: color-mix(in srgb, var(--team-accent, var(--primary-color)) 70%, #343844);
    box-shadow: 0 16px 36px color-mix(in srgb, var(--team-accent, #000) 14%, transparent);
}
.team-card h3 { color: var(--text-color); }

/* Final dashboard accents */
.podium-place {
    background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #30333d) 20%, transparent), #111319 72%);
}
.standing-item {
    border-left: 2px solid color-mix(in srgb, var(--team-accent, var(--primary-color)) 78%, transparent);
    background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #101218) 12%, #101218), #101218 48%);
}
.standing-item:hover {
    background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #191b23) 19%, #191b23), #191b23 48%);
}

/* Theme overrides after final component styles */
html[data-theme="light"] .stat-card,
html[data-theme="light"] .standings-table-container { background: #fff; color: var(--text-color); border-color: var(--border-color); }
html[data-theme="light"] .time-block { background: rgb(255 255 255 / 82%); border-color: var(--border-color); }
html[data-theme="light"] .time-value { color: var(--primary-color); }
html[data-theme="light"] .podium-place { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #fff) 12%, transparent), #fff 72%); }
html[data-theme="light"] .standing-item { background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #fff) 8%, #fff), #fff 55%); }
html[data-theme="light"] .standing-item:hover { background: linear-gradient(100deg, color-mix(in srgb, var(--team-accent, #fff) 15%, #fff), #f6f8fb 55%); }
html[data-theme="light"] .schedule-item { background: #fff; }
html[data-theme="light"] .standings-table th { background: #e9edf3; }
html[data-theme="light"] .nav-links a:hover,
html[data-theme="light"] .nav-links a.active { color: var(--primary-color); }
html[data-theme="light"] .theme-toggle { background: #fff; }
html[data-theme="light"] .standings-table tbody tr.driver-standings-row td,
html[data-theme="light"] .standings-table tbody tr.constructor-standings-row td {
    background: color-mix(in srgb, var(--team-accent, #fff) 9%, #fff);
    color: #252a33;
}
html[data-theme="light"] .standings-table tbody tr.driver-standings-row:hover td,
html[data-theme="light"] .standings-table tbody tr.constructor-standings-row:hover td {
    background: color-mix(in srgb, var(--team-accent, #fff) 16%, #fff);
}
html[data-theme="light"] .standings-table .standings-driver-content strong,
html[data-theme="light"] .standings-table .standings-constructor-content strong { color: #20242c; }
html[data-theme="light"] .standings-table .standings-constructor-cell small { color: #626a76; }
html[data-theme="light"] .standings-table .position-cell { color: #bf211c; }
html[data-theme="light"] .standings-table .podium-count-trigger {
    border-color: color-mix(in srgb, var(--team-accent, #888) 36%, #fff);
    background: rgb(255 255 255 / 72%);
    color: #252a33;
}
html[data-theme="light"] .standings-table .podium-count-zero { color: #626a76; }
html[data-theme="light"] .standings-table .pole-count-trigger { border-color: #bd8d1d; }
html[data-theme="light"] .standings-table .podium-count-trigger:hover,
html[data-theme="light"] .standings-table .podium-count-trigger:focus-visible {
    border-color: #8c6600;
    background: #fff2c7;
    color: #503b00;
}
html[data-theme="light"] .results-table tbody tr.result-driver-row td {
    background: color-mix(in srgb, var(--team-accent, #fff) 9%, #fff);
    color: #252a33;
}
html[data-theme="light"] .results-table tbody tr.result-driver-row:hover td {
    background: color-mix(in srgb, var(--team-accent, #fff) 16%, #fff);
}
html[data-theme="light"] .results-table tbody tr.result-driver-row .p1 { color: #8a6500; }
html[data-theme="light"] .results-table tbody tr.result-driver-row .p2 { color: #59616d; }
html[data-theme="light"] .results-table tbody tr.result-driver-row .p3 { color: #8d4b16; }
html[data-theme="light"] .results-table .position-change-up { color: #087d4b; }
html[data-theme="light"] .results-table .position-change-down { color: #b42318; }

html[data-theme="light"] .qualifying-best-time {
    color: #503b00;
    text-decoration-color: #bd8d1d;
}
html[data-theme="light"] .qualifying-best-icon { color: #9b6b00; }
html[data-theme="light"] .race-winner-chip {
    background: color-mix(in srgb, var(--team-accent, #fff) 9%, #fff);
    color: #252a33;
}

/* Motorsport typography system */
:root {
    --font-body: "Inter", "Segoe UI", sans-serif;
    --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
}
body, button, input, select, textarea { font-family: var(--font-body); }
h1, h2, h3, .logo, .driver-number, .time-value, .stat-value,
.driver-stat-value, .position-number, .position-cell, .standings-table th,
.results-table th, .podium-count-trigger, .standing-item .points {
    font-family: var(--font-display);
    font-stretch: condensed;
    font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-weight: 700; }
.logo { font-size: 1.7rem; font-weight: 800; letter-spacing: -.025em; }
.nav-links a { font-weight: 600; letter-spacing: -.015em; }
.page-header { padding: 3.75rem 0 2.6rem; }
.page-header h1 {
    font-size: clamp(2.6rem, 5vw, 3.65rem);
    line-height: .98;
    letter-spacing: .005em;
    font-weight: 800;
}
.page-header h1::after {
    display: block;
    width: 42px;
    height: 3px;
    margin: .85rem auto 0;
    border-radius: 99px;
    background: var(--primary-color);
    content: "";
}
.page-header p { font-size: .95rem; letter-spacing: .015em; }
.countdown-section h1 {
    font-family: var(--font-display);
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.time-value { font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 700; letter-spacing: -.025em; }
.next-race-info h2 { font-size: clamp(1.9rem, 4vw, 2.65rem); font-weight: 700; letter-spacing: -.015em; }
.race-header h3, .result-card h3, .team-card h3, .standings-card h2,
.latest-results h2, .season-stats h2, .driver-roster-heading h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: .005em;
}
.driver-card h3, .driver-team-heading h3 { font-family: var(--font-body); font-weight: 700; letter-spacing: -.025em; }
.driver-number { font-weight: 700; letter-spacing: -.04em; }
.driver-stat-value, .stat-value { font-weight: 700; letter-spacing: -.025em; }
.standings-table th, .results-table th {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .045em;
    text-transform: uppercase;
}
.position-cell, .position-number, .points, .podium-count-trigger { font-weight: 700; }
.tab-btn, .filter-btn, .theme-toggle { font-weight: 700; letter-spacing: .015em; }
.time-label, .driver-stat-label, .stat-label {
    font-family: var(--font-display);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.result-race-meta, .race-date strong, .schedule-item { font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
    .page-header { padding: 2.8rem 0 2rem; }
    .page-header h1 { font-size: clamp(2.35rem, 11vw, 3rem); }
    .race-header h3, .result-card h3, .team-card h3,
    .standings-card h2, .latest-results h2, .season-stats h2 { font-size: 1.55rem; }
}

/* Transparent 2026 team logos across all pages. */
.team-logo-wrap,
.standings-logo,
.result-team-logo,
.standing-team-mark {
    border: 0;
    background: transparent;
    color: var(--team-accent, var(--primary-color));
    box-shadow: none;
}
.team-logo-wrap { padding: 0; }
.team-logo-wrap img,
.standings-logo img,
.result-team-logo img,
.standing-team-mark img {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    object-fit: contain;
}
.team-logo-fallback,
.standings-logo > span,
.result-team-logo > span,
.standing-team-mark > span {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: var(--team-accent, var(--primary-color));
    font-family: var(--font-display);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1;
}
.team-logo-fallback { font-size: .95rem; }
.standing-team-mark { border-radius: 8px; }
html[data-theme="light"] .team-logo-wrap,
html[data-theme="light"] .standings-logo,
html[data-theme="light"] .result-team-logo,
html[data-theme="light"] .standing-team-mark {
    background: transparent;
    color: var(--team-accent, var(--primary-color));
}

/* Latest race summary */
.race-highlights:empty { display: none; }
.race-highlights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .7rem;
    max-width: 920px;
    margin: .2rem auto .1rem;
}
.race-highlight {
    display: flex;
    min-width: 0;
    min-height: 68px;
    flex-direction: column;
    justify-content: center;
    gap: .12rem;
    padding: .65rem .9rem;
    border: 1px solid var(--border-color);
    border-left: 2px solid var(--primary-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary-color) 5%, var(--card-background));
}
.race-highlight-label {
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.race-highlight strong {
    overflow: hidden;
    color: var(--text-color);
    font-size: .9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.race-highlight > span:last-child:not(.race-highlight-label) { color: var(--text-secondary); font-size: .75rem; }
.fastest-lap-highlight { border-left-color: #d7a524; }
.podium-place { min-height: 260px; }
.podium-place.first { min-height: 320px; }
.podium-place.second { min-height: 280px; }
.podium-place.third { min-height: 260px; }
.podium-place.first::after {
    position: absolute;
    z-index: 0;
    right: -2.3rem;
    bottom: .5rem;
    width: min(72%, 220px);
    height: 190px;
    background-image: var(--team-logo-image);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    content: "";
    opacity: .075;
    pointer-events: none;
}
.podium-place::before { z-index: 2; }
.podium-place > * { position: relative; z-index: 1; }
.podium-place .driver-info { z-index: 1; }
.podium-place.first .driver-name { font-size: 1.12rem; }
.podium-start-position {
    margin-top: .6rem;
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
}
html[data-theme="light"] .race-highlight { background: color-mix(in srgb, var(--primary-color) 4%, #fff); }
html[data-theme="light"] .podium-place.first::after { opacity: .09; }

@media (max-width: 768px) {
    .race-highlights { grid-template-columns: 1fr; gap: .45rem; }
    .race-highlight { min-height: 58px; }
    .podium-place.first::after { right: -1rem; width: 58%; height: 130px; }
}

/* Mercedes' black star needs a light edge against the dark surfaces. */
html[data-theme="dark"] img[src*="/mercedes/"] {
    filter: brightness(0) invert(1)
        drop-shadow(0 0 1px rgb(255 255 255 / 88%))
        drop-shadow(0 0 4px rgb(0 210 190 / 48%));
}
html[data-theme="dark"] .podium-place[style*="/mercedes/"]::after {
    filter: brightness(0) invert(1) drop-shadow(0 0 5px rgb(0 210 190 / 55%));
    opacity: .14;
}

/* Track outlines in the race calendar */
.schedule-item { grid-template-columns: 100px minmax(0, 1fr) 150px 200px; }
.race-track-thumb { display: grid; place-items: center; min-height: 88px; }
.race-track-thumb img { display: block; width: 138px; height: 88px; object-fit: contain; filter: drop-shadow(0 3px 8px rgb(0 0 0 / 12%)); }
.race-track-thumb span { color: var(--text-secondary); font-size: .68rem; text-align: center; }
html[data-theme="dark"] .race-track-thumb img { filter: invert(1) drop-shadow(0 3px 8px rgb(0 0 0 / 22%)); }
@media (max-width: 900px) { .schedule-item { grid-template-columns: 72px minmax(0, 1fr) 125px 175px; gap: 1rem; } }
@media (max-width: 768px) { .schedule-item { grid-template-columns: 1fr; } .race-track-thumb { justify-content: start; min-height: 55px; } .race-track-thumb img { width: 120px; height: 70px; } }

/* Refined latest-race podium and supporting stats */
.latest-results .race-result-card {
    position: relative;
    overflow: hidden;
    padding: clamp(1.15rem, 3vw, 2rem);
    background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--primary-color) 7%, transparent), transparent 56%), var(--card-background);
}
.latest-results .race-header { margin-bottom: .35rem; padding-bottom: .9rem; border-bottom-width: 1px; }
.latest-results .race-header h3 { font: 700 clamp(1.35rem, 2vw, 1.8rem)/1.1 var(--font-display); }
.latest-results .podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(.55rem, 1.5vw, 1rem); max-width: 880px; margin: .2rem auto 0; padding: .5rem .25rem 1.15rem; }
.latest-results .podium-place {
    position: relative;
    isolation: isolate;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    max-width: 270px;
    padding: 1rem .75rem 1.15rem;
    border: 1px solid color-mix(in srgb, var(--team-accent, var(--border-color)) 62%, var(--border-color));
    border-radius: 14px;
    background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #333) 17%, transparent), transparent 68%), color-mix(in srgb, var(--background) 60%, var(--card-background));
    box-shadow: 0 12px 28px rgb(0 0 0 / 12%);
}
.latest-results .podium-place.second { order: 1; height: 268px; }
.latest-results .podium-place.first { order: 2; height: 314px; border-color: color-mix(in srgb, #ffd447 68%, var(--team-accent)); background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #333) 24%, transparent), transparent 68%), color-mix(in srgb, var(--background) 52%, var(--card-background)); }
.latest-results .podium-place.third { order: 3; height: 252px; }
.latest-results .podium-place::before { height: 3px; border-radius: 14px 14px 0 0; }
.latest-results .podium-rank { position: relative; z-index: 1; display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; justify-content: center; column-gap: .45rem; margin-bottom: .45rem; }
.latest-results .podium-rank-icon { grid-row: 1 / 3; font-size: 1.3rem; }
.latest-results .podium-rank .position { margin: 0; color: var(--text-color); font: 800 1.85rem/1 var(--font-display); }
.latest-results .podium-place.first .podium-rank .position { font-size: 2.15rem; }
.latest-results .podium-rank-label { color: var(--text-secondary); font-size: .55rem; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.latest-results .podium-brand { min-height: 36px; margin: .15rem 0 .25rem; }
.latest-results .podium-flag { width: 25px; height: 17px; border-radius: 3px; box-shadow: 0 2px 5px rgb(0 0 0 / 18%); }
.latest-results .podium-place .driver-info { margin-top: auto; }
.latest-results .podium-place .driver-name { margin-bottom: .3rem; font-size: clamp(.88rem, 1.3vw, 1.08rem); line-height: 1.2; }
.latest-results .podium-place .team-name { font-size: .83rem; font-weight: 700; }
.latest-results .podium-start-position { display: inline-block; margin-top: .65rem; padding: .28rem .55rem; border: 1px solid var(--border-color); border-radius: 999px; background: color-mix(in srgb, var(--card-background) 75%, transparent); font-size: .65rem; letter-spacing: .02em; }
.latest-results .podium-place.first::after { right: -1.25rem; bottom: .15rem; width: 64%; height: 145px; opacity: .045; }
.latest-results .race-highlights { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; max-width: 880px; margin: .15rem auto 0; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.latest-results .race-highlight { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto auto auto; align-content: center; column-gap: .7rem; min-height: 76px; padding: .7rem .8rem; border: 1px solid var(--border-color); border-left: 2px solid var(--primary-color); border-radius: 11px; background: color-mix(in srgb, var(--team-accent, var(--primary-color)) 6%, var(--card-background)); }
.latest-results .race-highlight-icon { grid-column: 1; grid-row: 1 / 4; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--primary-color) 12%, transparent); font-size: 1rem; }
.latest-results .race-highlight-label { grid-column: 2; grid-row: 1; font-size: .6rem; letter-spacing: .1em; }
.latest-results .race-highlight strong { grid-column: 2; grid-row: 2; font-size: .84rem; }
.latest-results .race-highlight > span:last-child:not(.race-highlight-label):not(.race-highlight-icon) { grid-column: 2; grid-row: 3; font-variant-numeric: tabular-nums; }
.latest-results .fastest-lap-highlight { border-left-color: #d7a524; }
html[data-theme="light"] .latest-results .race-result-card { background: radial-gradient(ellipse at 50% 0%, #e106000a, transparent 56%), #fff; }
html[data-theme="light"] .latest-results .podium-place { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #333) 10%, transparent), transparent 68%), #fff; }
html[data-theme="light"] .latest-results .podium-place.first { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--team-accent, #333) 14%, transparent), transparent 68%), #fff; }
html[data-theme="light"] .latest-results .podium-start-position { background: #fff; }
@media (max-width: 768px) {
    .latest-results .podium { display: grid; grid-template-columns: 1fr; max-width: 440px; gap: .65rem; }
    .latest-results .podium-place.second, .latest-results .podium-place.first, .latest-results .podium-place.third { order: initial; width: 100%; max-width: none; height: auto; min-height: 205px; }
    .latest-results .podium-place.first { order: -1; }
    .latest-results .podium-rank { grid-template-columns: auto auto auto; grid-template-rows: 1fr; gap: .45rem; }
    .latest-results .podium-rank-icon { grid-row: auto; }
    .latest-results .podium-rank-label { align-self: center; }
    .latest-results .podium-place .driver-info { margin-top: .2rem; }
    .latest-results .race-highlights { grid-template-columns: 1fr; }
    .latest-results .race-highlight { min-height: 64px; }
}

/* Center podium positions independently of medal icons. */
.latest-results .podium-place { justify-content: center; gap: .28rem; }
.latest-results .podium-rank { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .12rem; margin: 0; }
.latest-results .podium-rank-icon { display: none; }
.latest-results .podium-rank .position,
.latest-results .podium-place.first .podium-rank .position { margin: 0; font-size: 1.75rem; line-height: 1; text-align: center; }
.latest-results .podium-rank-label { line-height: 1.1; text-align: center; }
.latest-results .podium-brand { min-height: 26px; margin: .05rem 0 0; }
.latest-results .podium-place .driver-info { margin-top: .18rem; }
.latest-results .podium-place .driver-name { margin-bottom: .12rem; }
.latest-results .podium-start-position { margin-top: .42rem; }

/* Medal colors and team identity on every podium card */
.latest-results .podium-place.second { --podium-medal-color: #b9c2ce; border-color: var(--podium-medal-color); }
.latest-results .podium-place.first { --podium-medal-color: #e0b83e; border-color: var(--podium-medal-color); box-shadow: 0 12px 32px rgb(224 184 62 / 13%), inset 0 0 0 1px rgb(224 184 62 / 16%); }
.latest-results .podium-place.third { --podium-medal-color: #bd8052; border-color: var(--podium-medal-color); }
.latest-results .podium-place.second::before,
.latest-results .podium-place.first::before,
.latest-results .podium-place.third::before { background: var(--podium-medal-color); }
.latest-results .podium-place.second .podium-rank .position { color: #c7d0dc; }
.latest-results .podium-place.first .podium-rank .position { color: #f0ca57; }
.latest-results .podium-place.third .podium-rank .position { color: #d69a6c; }
.latest-results .podium-place.first .podium-rank .position { position: relative; }
.latest-results .podium-place.first .podium-rank .position::before,
.latest-results .podium-place.first .podium-rank .position::after { position: absolute; top: 50%; color: #d9ad38; font: 700 1.05rem/1 serif; content: "❧"; }
.latest-results .podium-place.first .podium-rank .position::before { right: calc(100% + .28rem); transform: translateY(-50%) rotate(-42deg); }
.latest-results .podium-place.first .podium-rank .position::after { left: calc(100% + .28rem); transform: translateY(-50%) scaleX(-1) rotate(-42deg); }
.latest-results .podium-place.second::after,
.latest-results .podium-place.third::after,
.latest-results .podium-place.first::after {
    position: absolute;
    z-index: 0;
    right: -.8rem;
    bottom: .35rem;
    width: 58%;
    height: 132px;
    background-image: var(--team-logo-image);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    content: "";
    opacity: .075;
    pointer-events: none;
}
.latest-results .podium-place.first::after { right: -1rem; width: 66%; height: 158px; opacity: .09; }
html[data-theme="light"] .latest-results .podium-place.second::after,
html[data-theme="light"] .latest-results .podium-place.third::after { opacity: .065; }
html[data-theme="light"] .latest-results .podium-place.first::after { opacity: .1; }
.latest-results .podium-place { padding-bottom: 2.8rem; }
.latest-results .podium-place .driver-info { display: block; flex: none; width: 100%; margin-top: .18rem; }
.latest-results .podium-start-position { position: absolute; right: .5rem; bottom: .85rem; left: .5rem; width: fit-content; margin: 0 auto; }
.latest-results .podium-place { display: grid; grid-template-rows: auto 26px 1fr auto; align-content: stretch; justify-items: center; padding-bottom: 1.15rem; }
.latest-results .podium-place .driver-info { align-self: center; margin-top: 0; }
.latest-results .podium-start-position { position: static; align-self: end; justify-self: center; width: fit-content; margin: 0 auto; transform: none; }
@media (max-width: 768px) {
    .latest-results .podium-place.second,
    .latest-results .podium-place.first,
    .latest-results .podium-place.third { grid-template-rows: auto 26px 1fr auto; }
}
