:root {
    --bg-primary: #080808;
    --bg-secondary: #111113;
    --bg-card: #16161a;
    --bg-card-hover: #1c1c22;
    --border: #2a2a30;
    --border-accent: #3a3a42;
    --text-primary: #e8e8ec;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #e10600;
    --accent-glow: rgba(225, 6, 0, 0.3);
    --green: #00d27a;
    --yellow: #f5c518;
    --purple: #a855f7;
    --blue: #3b82f6;
    --cyan: #06b6d4;
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Outfit', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ── HEADER ── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    flex-shrink: 0;
}

.header-logo .dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 10px var(--accent-glow);
    }
    50% {
        opacity: 0.5;
        box-shadow: 0 0 20px var(--accent-glow);
    }
}

.header-logo span.sub {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: 0.3rem;
}

.header-selectors {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    overflow-x: auto;
}

.sel-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sel-group label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

select, button.btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

select:hover, button.btn:hover {
    border-color: var(--border-accent);
    background: var(--bg-card-hover);
}

select:focus, button.btn:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

button.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 600;
}

button.btn-accent:hover {
    background: #c40500;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
}

.status-badge .indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.live .indicator {
    background: var(--green);
    box-shadow: 0 0 8px rgba(0, 210, 122, 0.5);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-badge.error .indicator {
    background: var(--yellow);
    box-shadow: 0 0 8px rgba(245, 197, 24, 0.5);
}

/* ── MAIN LAYOUT ── */
.main {
    position: relative;
    z-index: 1;
    padding: 1rem 1.5rem 2rem;
    max-width: 1800px;
    margin: 0 auto;
}

/* ── DRIVER BAR ── */
.driver-bar {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    flex-wrap: wrap;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.team-group {
    display: flex;
    gap: 2px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.driver-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.78rem;
    border: none;
    position: relative;
}

.driver-chip:hover {
    background: var(--bg-card-hover);
}

.driver-chip.active {
    background: rgba(225, 6, 0, 0.1);
}

.driver-chip.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.driver-chip .driver-photo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-card);
    border: 2px solid var(--border);
}

.driver-chip.active .driver-photo {
    border-color: var(--accent);
}

.driver-chip .color-bar {
    width: 3px;
    height: 18px;
    border-radius: 2px;
}

.driver-chip .acronym {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.75rem;
}

.driver-chip .number {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ── TABS ── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.tab-content {
    display: none;
}

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

/* ── CHAMPIONSHIP ── */
.champ-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.champ-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.champ-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.champ-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.champ-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.champ-table .pos {
    font-weight: 700;
    color: var(--text-primary);
    width: 30px;
}

.champ-table .pts {
    font-weight: 600;
    color: var(--accent);
    text-align: right;
}

.champ-table .pts-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
    margin-top: 3px;
    opacity: 0.5;
}

.champ-table tr.driver-selected td {
    background: rgba(225, 6, 0, 0.06);
}

.champ-table tr.driver-selected td:first-child {
    color: var(--accent);
    font-weight: 800;
}

@media (max-width: 900px) {
    .champ-grid {
        grid-template-columns: 1fr;
    }
}

/* ── GRID ── */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid .full-width {
    grid-column: 1 / -1;
}

/* ── CARD ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.3s;
}

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

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

.card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title .icon {
    font-size: 0.9rem;
}

.card-body {
    padding: 1rem;
    position: relative;
    min-height: 200px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.card-body canvas {
    width: 100% !important;
}

/* ── TABLES ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.data-table .pos {
    color: var(--text-primary);
    font-weight: 600;
}

.data-table .name {
    color: var(--text-primary);
}

.data-table .gap {
    color: var(--yellow);
}

.data-table .interval {
    color: var(--cyan);
}

.data-table .fast {
    color: var(--purple);
}

.data-table tr.driver-selected td {
    background: rgba(225, 6, 0, 0.06);
}

.data-table tr.driver-selected td.name {
    color: #fff;
    font-weight: 700;
}

.data-table tr.driver-selected td.pos {
    color: var(--accent);
}

.stint-row.driver-selected {
    background: rgba(225, 6, 0, 0.06);
    border-radius: 6px;
    padding: 0.3rem 0.3rem;
}

.stint-row.driver-selected .driver-name {
    color: var(--accent);
}

.pit-entry.driver-selected {
    background: rgba(225, 6, 0, 0.06);
    border-radius: 4px;
}

.pit-entry.driver-selected .pit-driver {
    font-weight: 700 !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── STINTS ── */
.stint-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.stint-row .driver-name {
    width: 45px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.stint-bar-container {
    flex: 1;
    display: flex;
    gap: 2px;
    height: 22px;
}

.stint-bar {
    height: 100%;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.7);
    min-width: 20px;
    position: relative;
}

.stint-bar.SOFT {
    background: #e10600;
    color: #fff;
}

.stint-bar.MEDIUM {
    background: #f5c518;
}

.stint-bar.HARD {
    background: #e8e8ec;
}

.stint-bar.INTERMEDIATE {
    background: #00d27a;
}

.stint-bar.WET {
    background: #3b82f6;
    color: #fff;
}

/* ── WEATHER ── */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.weather-item {
    text-align: center;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.weather-item .value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.weather-item .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── RACE CONTROL FEED ── */
.rc-feed {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.rc-message {
    display: flex;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
}

.rc-message .rc-time {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    width: 55px;
}

.rc-message .rc-flag {
    width: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.rc-flag.GREEN {
    background: var(--green);
}

.rc-flag.YELLOW, .rc-flag.DOUBLE-YELLOW {
    background: var(--yellow);
}

.rc-flag.RED {
    background: var(--accent);
}

.rc-flag.CHEQUERED {
    background: var(--text-primary);
}

.rc-flag.BLACK-AND-WHITE {
    background: linear-gradient(180deg, #fff 50%, #000 50%);
}

.rc-flag.BLUE {
    background: var(--blue);
}

.rc-flag.default {
    background: var(--text-muted);
}

.rc-message .rc-text {
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── PIT STOPS ── */
.pit-list {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.pit-entry {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.pit-entry .pit-lap {
    color: var(--text-muted);
    font-size: 0.65rem;
    width: 45px;
}

.pit-entry .pit-driver {
    font-weight: 600;
    color: var(--text-primary);
    width: 45px;
}

.pit-entry .pit-duration {
    color: var(--yellow);
}

.pit-entry .pit-total {
    color: var(--text-muted);
    font-size: 0.68rem;
}

/* ── LOADING / EMPTY ── */
.loading, .empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.6rem;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

/* ── LOADER OVERLAY (canvas / charts) ── */
.loader-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: rgba(8, 8, 8, 0.55);
    backdrop-filter: blur(2px);
    z-index: 5;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.loader-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.loader-overlay .spinner {
    margin-right: 0;
    width: 28px;
    height: 28px;
}

.loader-overlay .loader-label {
    text-transform: uppercase;
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Position relative on parents that host overlays */
.card-body {
    position: relative;
}

.circuit-map-wrapper {
    position: relative;
}

/* ── SKELETON SHIMMER ── */
.skeleton {
    background: linear-gradient(
            90deg,
            var(--bg-card) 0%,
            var(--bg-card-hover) 50%,
            var(--bg-card) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
}

.skeleton-row {
    height: 26px;
    border-radius: 4px;
}

.skeleton-row:nth-child(1) {
    width: 92%;
}

.skeleton-row:nth-child(2) {
    width: 78%;
}

.skeleton-row:nth-child(3) {
    width: 85%;
}

.skeleton-row:nth-child(4) {
    width: 70%;
}

.skeleton-row:nth-child(5) {
    width: 88%;
}

/* ── TEAM RADIOS ── */
.radio-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.radio-entry {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
}

.radio-entry:last-child {
    border-bottom: none;
}

.radio-entry.driver-selected {
    background: rgba(225, 6, 0, 0.06);
    border-radius: 4px;
}

.radio-entry .radio-time {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.68rem;
    width: 58px;
    flex-shrink: 0;
}

.radio-entry .radio-driver-bar {
    width: 4px;
    align-self: stretch;
    border-radius: 2px;
    flex-shrink: 0;
    background: var(--text-muted);
}

.radio-entry .radio-driver {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.74rem;
    width: 42px;
    flex-shrink: 0;
}

.radio-entry .radio-team {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.radio-play-btn {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
    font-size: 0.7rem;
}

.radio-play-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.radio-play-btn.playing {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.radio-play-btn.is-loading {
    border-color: var(--accent);
    color: transparent;
    cursor: wait;
    position: relative;
}

.radio-play-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── LOADING PROGRESS (status badge) ── */
.load-progress {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.load-progress-bar {
    width: 60px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.load-progress-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.25s ease;
}

/* ── FIREWORKS OVERLAY ── */
#fireworks-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    pointer-events: none;
}

#fireworks-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 10000;
    pointer-events: none;
    text-align: center;
    font-family: var(--font-display);
    animation: banner-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#fireworks-banner .flag {
    font-size: 4rem;
}

#fireworks-banner .text {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent-glow);
    margin-top: 0.3rem;
}

@keyframes banner-pop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ── PODIUM / FINAL CLASSIFICATION OVERLAY ── */
#podium-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
    background: rgba(6, 6, 10, 0.92);
    backdrop-filter: blur(12px);
    overflow-y: auto;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#podium-overlay .podium-close {
    position: fixed;
    top: 1.2rem;
    right: 1.5rem;
    z-index: 10002;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#podium-overlay .podium-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.podium-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
}

.podium-header {
    text-align: center;
    margin-bottom: 2rem;
}

.podium-header .flag-icon {
    font-size: 2.5rem;
    margin-bottom: 0.3rem;
}

.podium-header h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.03em;
    margin: 0;
}

.podium-header .sub {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ── Podium blocks (P1 / P2 / P3) ── */
.podium-blocks {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.podium-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 12px;
    padding: 1rem 0.8rem 0.8rem;
    position: relative;
    transition: transform 0.3s;
    animation: podium-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.podium-block:nth-child(1) {
    animation-delay: 0.5s;
}

.podium-block:nth-child(2) {
    animation-delay: 0.2s;
}

.podium-block:nth-child(3) {
    animation-delay: 0.7s;
}

@keyframes podium-rise {
    from {
        transform: translateY(40px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.podium-block.p1 {
    flex: 1.2;
    min-height: 200px;
    background: linear-gradient(170deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.03));
    border: 1px solid rgba(255, 215, 0, 0.25);
}

.podium-block.p2 {
    flex: 1;
    min-height: 160px;
    background: linear-gradient(170deg, rgba(192, 192, 192, 0.10), rgba(192, 192, 192, 0.02));
    border: 1px solid rgba(192, 192, 192, 0.2);
    order: -1;
}

.podium-block.p3 {
    flex: 1;
    min-height: 130px;
    background: linear-gradient(170deg, rgba(205, 127, 50, 0.10), rgba(205, 127, 50, 0.02));
    border: 1px solid rgba(205, 127, 50, 0.2);
}

.podium-pos {
    font-family: var(--font-display);
    font-weight: 900;
    line-height: 1;
    margin-bottom: 0.4rem;
}

.podium-block.p1 .podium-pos {
    font-size: 2.8rem;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.podium-block.p2 .podium-pos {
    font-size: 2.2rem;
    color: #c0c0c0;
}

.podium-block.p3 .podium-pos {
    font-size: 2rem;
    color: #cd7f32;
}

.podium-driver-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    text-align: center;
    margin-bottom: 0.15rem;
}

.podium-team {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.5rem;
}

.podium-color-bar {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    margin-bottom: 0.5rem;
}

.podium-time {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ── Full classification list ── */
.classification-list {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.classification-list h3 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.7rem;
}

.classif-row {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    gap: 0.6rem;
    transition: background 0.15s;
}

.classif-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.classif-row .pos {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    width: 28px;
    text-align: right;
}

.classif-row .team-bar {
    width: 3px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
}

.classif-row .driver-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
}

.classif-row .driver-team {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    width: 100px;
    text-align: right;
}

.classif-row .driver-time {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    width: 90px;
    text-align: right;
}

.classif-row.top3 .pos {
    color: #ffd700;
}

.classif-row.top3 .driver-name {
    color: #fff;
}

@media (max-width: 600px) {
    .classif-row .driver-team {
        display: none;
    }
}

/* ── LAP SELECTOR ── */
.lap-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lap-selector input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.lap-selector input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.lap-selector span {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── CIRCUIT MAP ── */
.circuit-map-wrapper {
    position: relative;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    min-height: 300px;
    cursor: grab;
    overflow: hidden;
}

.circuit-map-wrapper.grabbing {
    cursor: grabbing;
}

.circuit-map-wrapper canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.zoom-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 5;
}

.zoom-controls button {
    width: 30px;
    height: 30px;
    background: rgba(22, 22, 26, 0.9);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.zoom-controls button:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
}

.map-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-controls .live-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.map-controls .live-btn.active {
    background: rgba(0, 210, 122, 0.1);
    border-color: var(--green);
    color: var(--green);
}

.map-controls .live-btn .live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.map-controls .live-btn.active .live-dot {
    background: var(--green);
    box-shadow: 0 0 8px rgba(0, 210, 122, 0.5);
    animation: pulse-dot 1s ease-in-out infinite;
}

/* Replay slider */
#replay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-glow);
}

#replay-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px var(--accent-glow);
}

#replay-slider:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#replay-slider:disabled::-webkit-slider-thumb {
    background: var(--text-muted);
    box-shadow: none;
}

#replay-slider:disabled::-moz-range-thumb {
    background: var(--text-muted);
    box-shadow: none;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.5rem 1rem 0.8rem;
    border-top: 1px solid var(--border);
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.map-legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .grid .full-width {
        grid-column: 1;
    }
}

/* ══════════════════════════════════════════════
   TABLET (≤ 768px)
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem 0.8rem;
        gap: 0.5rem;
        flex-wrap: wrap;
        height: auto;
    }

    .header-logo {
        font-size: 0.85rem;
    }

    .header-selectors {
        order: 3;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .sel-group {
        flex: 1;
        min-width: 0;
    }

    .sel-group label {
        font-size: 0.6rem;
    }

    .sel-group select {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.45rem 0.4rem;
    }

    #btn-load {
        width: 100%;
        padding: 0.55rem;
        font-size: 0.85rem;
        margin-top: 0.2rem;
    }

    .header-status {
        order: 2;
    }

    .main {
        padding: 0.6rem;
    }

    /* Driver bar: horizontal scroll, no wrap */
    .driver-bar {
        flex-wrap: nowrap;
        gap: 0.25rem;
        padding-bottom: 0.6rem;
    }

    .team-group {
        flex-shrink: 0;
    }

    .driver-chip {
        padding: 0.35rem 0.45rem;
        font-size: 0.72rem;
    }

    .driver-chip .driver-photo {
        width: 20px;
        height: 20px;
    }

    .driver-chip .number {
        display: none;
    }

    /* Tabs: full width */
    .tab-bar {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tab-bar::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 0.55rem 0.8rem;
        font-size: 0.72rem;
        white-space: nowrap;
    }

    /* Card spacing */
    .card-header {
        padding: 0.6rem 0.7rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .card-title {
        font-size: 0.68rem;
    }

    .card-body {
        padding: 0.6rem;
    }

    /* Map controls: wrap */
    .map-controls {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .map-controls .btn,
    .map-controls select,
    .map-controls .live-btn {
        min-height: 36px;
        font-size: 0.72rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    /* Replay bar */
    #replay-bar {
        padding: 0.4rem 0.5rem !important;
        gap: 0.4rem !important;
    }

    #replay-time, #replay-time-end {
        font-size: 0.6rem !important;
        min-width: 48px !important;
    }

    #replay-info {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
        padding: 0 0.5rem 0.4rem !important;
    }

    #replay-info .btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 0.75rem !important;
    }

    /* Map legend: scrollable */
    .map-legend {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        padding: 0.4rem 0.6rem;
    }

    .map-legend::-webkit-scrollbar {
        display: none;
    }

    /* Zoom buttons: bigger touch targets */
    .zoom-controls button {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    /* Tables: scrollable */
    .data-table {
        font-size: 0.68rem;
    }

    .data-table th, .data-table td {
        padding: 0.35rem 0.4rem;
    }

    /* Weather grid */
    .weather-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stint bars */
    .stint-row {
        font-size: 0.65rem;
    }

    .stint-row .driver-name {
        width: 36px;
        font-size: 0.65rem;
    }

    /* Championship */
    .champ-grid {
        grid-template-columns: 1fr;
    }

    /* Chart height */
    .card-body canvas {
        max-height: 220px;
    }

    /* Podium */
    .podium-container {
        padding: 1.5rem 1rem 2rem;
    }

    .podium-header h2 {
        font-size: 1.2rem;
    }

    .podium-blocks {
        gap: 0.4rem;
    }

    .podium-block {
        padding: 0.7rem 0.5rem 0.6rem;
    }

    .podium-block.p1 .podium-pos {
        font-size: 2.2rem;
    }

    .podium-block.p2 .podium-pos {
        font-size: 1.8rem;
    }

    .podium-block.p3 .podium-pos {
        font-size: 1.6rem;
    }

    .podium-driver-name {
        font-size: 0.9rem;
    }

    .classif-row {
        padding: 0.4rem 0.4rem;
        gap: 0.4rem;
    }

    .classif-row .driver-team {
        display: none;
    }
}

/* ══════════════════════════════════════════════
   MOBILE (≤ 480px)
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .header {
        padding: 0.4rem 0.5rem;
        gap: 0.3rem;
    }

    .header-logo {
        font-size: 0.78rem;
        width: 100%;
        justify-content: center;
    }

    .header-selectors {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.3rem;
    }

    .sel-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
    }

    .sel-group label {
        font-size: 0.55rem;
    }

    .sel-group select {
        font-size: 0.72rem;
        padding: 0.5rem 0.35rem;
        min-height: 40px;
    }

    #btn-load {
        grid-column: 1 / -1;
        min-height: 44px;
        font-size: 0.9rem;
    }

    .header-status {
        width: 100%;
        justify-content: space-between;
    }

    .main {
        padding: 0.4rem;
    }

    .grid {
        gap: 0.5rem;
    }

    /* Driver bar: compact */
    .driver-bar {
        gap: 0.2rem;
        margin-bottom: 0.6rem;
    }

    .driver-chip {
        padding: 0.3rem 0.4rem;
        font-size: 0.68rem;
        min-height: 36px;
    }

    .driver-chip .driver-photo {
        display: none;
    }

    .driver-chip .color-bar {
        width: 3px;
        height: 14px;
    }

    .driver-chip .acronym {
        font-size: 0.68rem;
    }

    /* Tab bar */
    .tab-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.68rem;
    }

    /* Card */
    .card-header {
        padding: 0.5rem 0.6rem;
    }

    .card-title {
        font-size: 0.62rem;
        gap: 0.3rem;
    }

    .card-title .icon {
        font-size: 0.75rem;
    }

    .card-body {
        padding: 0.4rem;
    }

    /* Circuit map */
    .circuit-map-wrapper {
        min-height: 220px;
        max-height: 400px;
    }

    .zoom-controls {
        bottom: 6px;
        left: 6px;
    }

    .zoom-controls button {
        width: 34px;
        height: 34px;
    }

    /* Map controls: vertical stack */
    .map-controls {
        width: 100%;
        justify-content: space-between;
    }

    /* Replay: compact */
    #replay-bar {
        padding: 0.3rem 0.4rem !important;
    }

    #replay-time, #replay-time-end {
        font-size: 0.55rem !important;
        min-width: 42px !important;
    }

    #replay-slider {
        height: 6px !important;
    }

    #replay-info {
        font-size: 0.6rem !important;
        gap: 0.3rem !important;
        padding: 0 0.4rem 0.3rem !important;
    }

    #replay-info .btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.85rem !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sync checkbox label shorter */
    #replay-info label span {
        font-size: 0.58rem !important;
    }

    /* Map legend */
    .map-legend {
        padding: 0.3rem 0.4rem;
        gap: 0.2rem;
    }

    .map-legend-item {
        font-size: 0.55rem;
    }

    .map-legend-item .dot {
        width: 6px;
        height: 6px;
    }

    /* Tables */
    .data-table {
        font-size: 0.62rem;
    }

    .data-table th, .data-table td {
        padding: 0.3rem 0.3rem;
    }

    .data-table th {
        font-size: 0.55rem;
    }

    /* Weather */
    .weather-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    .weather-item {
        padding: 0.4rem;
    }

    .weather-item .value {
        font-size: 1rem;
    }

    .weather-item .label {
        font-size: 0.55rem;
    }

    /* Stints */
    .stint-row {
        gap: 0.3rem;
        font-size: 0.6rem;
    }

    .stint-row .driver-name {
        width: 30px;
        font-size: 0.6rem;
    }

    .stint-bar-container {
        height: 18px;
    }

    .stint-bar {
        font-size: 0.5rem;
        min-width: 14px;
    }

    /* Pit table */
    .pit-table td, .pit-table th {
        padding: 0.3rem;
        font-size: 0.6rem;
    }

    /* Race control */
    .rc-msg {
        font-size: 0.62rem;
        padding: 0.3rem 0.4rem;
    }

    /* Chart canvases */
    .card-body canvas {
        max-height: 180px;
    }

    /* Championship */
    .champ-table {
        font-size: 0.68rem;
    }

    .champ-table th, .champ-table td {
        padding: 0.35rem 0.3rem;
    }

    /* Podium overlay */
    .podium-container {
        padding: 1rem 0.7rem 2rem;
    }

    .podium-header .flag-icon {
        font-size: 2rem;
    }

    .podium-header h2 {
        font-size: 1rem;
    }

    .podium-header .sub {
        font-size: 0.65rem;
    }

    .podium-blocks {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .podium-block.p2 {
        order: 0;
    }

    .podium-block {
        flex: none !important;
        min-height: auto !important;
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 0.6rem 0.8rem;
    }

    .podium-block .podium-pos {
        margin-bottom: 0;
        font-size: 1.5rem !important;
    }

    .podium-block .podium-color-bar {
        width: 4px;
        height: 30px;
        margin-bottom: 0;
    }

    .podium-block .podium-driver-name {
        text-align: left;
        font-size: 0.85rem;
        flex: 1;
    }

    .podium-block .podium-driver-name br {
        display: none;
    }

    .podium-block .podium-team {
        display: none;
    }

    .podium-block .podium-time {
        font-size: 0.7rem;
    }

    .classification-list h3 {
        font-size: 0.65rem;
    }

    .classif-row {
        padding: 0.35rem 0.3rem;
        gap: 0.3rem;
        font-size: 0.75rem;
    }

    .classif-row .pos {
        width: 22px;
        font-size: 0.75rem;
    }

    .classif-row .driver-name {
        font-size: 0.75rem;
    }

    .classif-row .driver-time {
        font-size: 0.68rem;
        width: 75px;
    }

    .classif-row .driver-team {
        display: none;
    }

    /* Podium close button bigger */
    #podium-overlay .podium-close {
        width: 44px;
        height: 44px;
        top: 0.8rem;
        right: 0.8rem;
    }

    /* Auth modal */
    .modal-content {
        width: 95vw !important;
        padding: 1.5rem !important;
    }

    /* Fireworks banner */
    #fireworks-banner .flag {
        font-size: 3rem;
    }

    #fireworks-banner .text {
        font-size: 1.2rem;
    }
}

/* ── COMPARISON SELECTOR ── */
.compare-selectors {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.compare-selectors select {
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.driver-chip .pos-badge {
    background: #1a1a22;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 3px;
    margin-right: 4px;
}
