/* ============================================================
   BoxBoxF1Fantasy — Styles
   Dark F1-themed design with team color accents
   ============================================================ */

/* Loading Spinner for lazy tab rendering */
.tab-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.spinner-ring {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

:root {
    /* Base palette */
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1f2e;
    --bg-card-hover: #232738;
    --bg-input: #1c1f2e;
    --border: #2a2d3e;
    --border-light: #363a4f;

    /* Text */
    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-muted: #6b7394;
    --text-accent: #e10600;

    /* Accent */
    --accent: #e10600;
    --accent-glow: rgba(225, 6, 0, 0.3);
    --accent-soft: rgba(225, 6, 0, 0.15);

    /* Status */
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;

    /* Team colors */
    --team-red-bull: #3671C6;
    --team-ferrari: #E80020;
    --team-mercedes: #27F4D2;
    --team-mclaren: #FF8000;
    --team-aston-martin: #229971;
    --team-alpine: #FF87BC;
    --team-williams: #64C4FF;
    --team-racing-bulls: #6692FF;
    --team-audi: #00E701;
    --team-haas: #B6BABD;
    --team-cadillac: #FFD700;

    /* Sizing */
    --container: 1280px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(225,6,0,0.03) 0%, transparent 70%);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---- Dev Banner ---- */
.dev-banner {
    background: linear-gradient(to right, var(--accent), #1c1f2e);
    font-size: 12px;
    text-align: center;
    padding: 6px 12px;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    letter-spacing: 0.03em;
}

.dev-banner-icon {
    margin: 0 6px;
}

/* ---- Header ---- */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
}

.logo-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.logo-text .accent {
    color: var(--accent);
}

.logo-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.race-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.race-flag {
    font-size: 24px;
}

.race-name {
    font-weight: 600;
    font-size: 14px;
}

.race-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.countdown-badge {
    background: var(--bg-card);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    text-align: center;
    min-width: 160px;
}

.countdown-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.countdown-timer {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.countdown-timer.urgent {
    color: var(--accent);
    animation: pulse-urgent 1s ease-in-out infinite;
}

@keyframes pulse-urgent {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.countdown-race {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
}

.countdown-badge.past-deadline .countdown-timer {
    color: var(--text-muted);
    font-size: 13px;
}

/* ---- Tabs ---- */
.tabs {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 99;
}

.tab-list {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    overflow-x: auto;
}

.tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.tab.active {
    color: var(--text-primary);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
}

/* ---- Controls ---- */
.controls {
    display: flex;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input[type="number"] {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    min-width: 160px;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.view-btn {
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

.view-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.view-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---- Main ---- */
.main {
    padding: 28px 0 60px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* ---- Driver Cards ---- */
.driver-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.driver-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.driver-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--team-color, var(--border));
}

.driver-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px var(--border-light);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.driver-info h3 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.driver-team {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.driver-number {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-muted);
    opacity: 0.4;
    line-height: 1;
}

.points-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 18px;
}

.points-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.confidence-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conf-track {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.conf-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.risk-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.risk-low {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
}

.risk-medium {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
}

.risk-high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.price-tag {
    color: var(--text-secondary);
    font-weight: 500;
}

.value-tag {
    color: var(--green);
    font-weight: 600;
}

/* Points breakdown bar */
.points-breakdown {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin: 12px 0;
    gap: 2px;
}

.pb-quali {
    background: #7c3aed;
    border-radius: 3px;
}

.pb-race {
    background: var(--accent);
    border-radius: 3px;
}

.pb-sprint-quali {
    background: #06b6d4;
    border-radius: 3px;
}

.pb-sprint-race {
    background: #f59e0b;
    border-radius: 3px;
}

.points-legend {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ---- Data Table ---- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th.num {
    text-align: right;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table tr:hover {
    background: var(--bg-card-hover);
}

.data-table .team-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* ---- Constructor Cards ---- */
.constructor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}

.constructor-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.constructor-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--team-color, var(--border));
}

.constructor-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.constructor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.constructor-drivers {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.mini-driver {
    background: var(--bg-primary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ---- Optimizer ---- */
.optimizer-header {
    margin-bottom: 24px;
}

.optimizer-header h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.optimizer-header p {
    color: var(--text-secondary);
}

/* Optimizer mode toggle */
.optimizer-mode-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 4px;
    width: fit-content;
}
.mode-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-btn.active {
    background: var(--red);
    color: #fff;
    font-weight: 600;
}
.mode-btn:hover:not(.active) {
    color: var(--text);
}
.optimizer-mode.hidden { display: none; }

/* My Team section */
.my-team-section { margin-bottom: 24px; }
.my-team-section h3 { font-size: 16px; margin-bottom: 8px; }
.my-team-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.my-team-slot {
    position: relative;
    width: 120px;
    padding: 12px 10px;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--border);
    background: var(--bg-secondary);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.my-team-slot.filled {
    border-style: solid;
    border-color: var(--team-color, var(--border));
}
.my-team-slot:hover { border-color: var(--accent); }
.my-team-slot .slot-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.my-team-slot .slot-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.my-team-slot .slot-price {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.my-team-slot .slot-remove {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.my-team-slot:hover .slot-remove { opacity: 1; }

/* Slot picker dropdown */
.slot-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.slot-picker {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    min-width: 280px;
    max-width: 360px;
}
.slot-picker h4 { margin-bottom: 12px; font-size: 14px; }
.slot-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.15s;
}
.slot-picker-item:hover { background: var(--bg-secondary); }
.slot-picker-item .sp-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.slot-picker-item .sp-name { font-weight: 500; font-size: 0.85rem; flex: 1; }
.slot-picker-item .sp-price { color: var(--text-secondary); font-size: 0.8rem; }
.slot-picker-item.disabled { opacity: 0.35; pointer-events: none; }

.my-team-controls {
    display: flex;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}

/* Transfer result cards */
.transfer-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.transfer-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.transfer-card-header h4 { margin: 0; font-size: 14px; }
.transfer-swap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.transfer-out { color: var(--red, #ef4444); }
.transfer-in { color: var(--green); }
.transfer-arrow { color: var(--text-secondary); font-size: 1.2rem; }
.transfer-pick-name { font-weight: 600; font-size: 0.9rem; }
.transfer-pick-detail { font-size: 0.8rem; color: var(--text-secondary); }
.chip-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    margin-left: 8px;
}

/* Multi-week planner styles */
.chip-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.chip-check input:checked + span,
.chip-check:has(input:checked) { color: var(--text-primary); }

.mw-timeline {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 12px 0;
    margin-bottom: 20px;
}
.mw-round-col {
    flex: 1;
    min-width: 160px;
    max-width: 240px;
    padding: 12px;
    border-right: 1px solid var(--border);
    position: relative;
}
.mw-round-col:last-child { border-right: none; }
.mw-round-col.active-round { background: rgba(232, 6, 6, 0.05); }
.mw-round-header {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.mw-round-circuit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.mw-round-sprint {
    display: inline-block;
    font-size: 0.65rem;
    background: var(--accent);
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}
.mw-round-action {
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    margin-top: 8px;
}
.mw-action-hold {
    background: rgba(100, 100, 100, 0.15);
    color: var(--text-secondary);
}
.mw-action-swap {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.mw-action-chip {
    background: rgba(232, 6, 6, 0.1);
    border: 1px solid rgba(232, 6, 6, 0.3);
}
.mw-round-pts {
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 8px;
}
.mw-round-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.mw-plan-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.mw-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.mw-plan-rank {
    font-weight: 700;
    font-size: 1.1rem;
}
.mw-plan-total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--green);
}
.mw-plan-stats {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mw-heatmap {
    overflow-x: auto;
    margin-top: 16px;
}
.mw-heatmap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.mw-heatmap th, .mw-heatmap td {
    padding: 4px 8px;
    text-align: center;
    border: 1px solid var(--border);
}
.mw-heatmap th { font-weight: 600; font-size: 0.75rem; }
.mw-heat-high { background: rgba(34, 197, 94, 0.25); }
.mw-heat-mid { background: rgba(234, 179, 8, 0.15); }
.mw-heat-low { background: rgba(239, 68, 68, 0.15); }

.optimizer-controls {
    display: flex;
    gap: 16px;
    align-items: end;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #c10500);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.optimizer-constraints {
    margin-bottom: 32px;
}

.optimizer-constraints h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 13px;
}

.lock-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lock-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.lock-chip:hover {
    border-color: var(--border-light);
}

.lock-chip.locked {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.lock-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.lock-icon {
    font-size: 11px;
}

.lock-chip.excluded {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--red, #ef4444);
    color: var(--red, #ef4444);
    opacity: 0.7;
    text-decoration: line-through;
}

.lock-chip.constructor-chip {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.lock-grid-separator {
    width: 100%;
    height: 0;
    border-top: 1px dashed var(--border);
    margin: 4px 0;
}

/* Lineup blocks */
.lineup-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
}

.lineup-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.lineup-block.expanded .lineup-details {
    max-height: 2000px;
}

.lineup-expand-icon {
    transition: transform 0.25s ease;
    display: inline-block;
    font-size: 12px;
    margin-right: 6px;
}

.lineup-block.expanded .lineup-expand-icon {
    transform: rotate(180deg);
}

.lineup-block:first-child {
    border-color: var(--accent);
    border-width: 2px;
}

.lineup-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.lineup-block-header h4 {
    font-size: 14px;
    margin: 0;
}

.lineup-block-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lineup-picks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

/* PPM rating badges */
.ppm-rating {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
}

.rating-great { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.rating-good { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
.rating-poor { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.rating-terrible { background: rgba(239, 68, 68, 0.15); color: var(--red, #ef4444); }

.constructor-pick .pick-type,
.constructor-pick .pick-name {
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Monte Carlo range on driver cards */
.mc-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    margin-top: 6px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: help;
}

.mc-range .mc-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.65rem;
}

.mc-range .mc-values {
    color: var(--text);
    font-weight: 500;
}

/* -- Price change brackets section -- */
.price-change-section {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    border: 1px solid var(--border);
}
.price-change-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.price-change-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.price-change-predicted {
    font-size: 0.85rem;
    font-weight: 700;
}
.price-change-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    gap: 8px;
}
.bracket-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}
.bracket-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.02);
    border-left: 2px solid var(--bracket-color, var(--text-muted));
}
.bracket-row.bracket-active {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    font-weight: 600;
}
.bracket-change {
    font-weight: 600;
    color: var(--bracket-color);
    min-width: 42px;
}
.bracket-pts {
    text-align: right;
    font-size: 0.65rem;
}

/* -- Collapsible sections -- */
.collapsible .collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.collapsible .collapsible-header:hover {
    color: var(--accent);
}
.collapse-icon {
    font-size: 0.7em;
    transition: transform 0.2s;
    color: var(--text-muted);
}
.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}
.collapsible.collapsed .collapsible-content {
    display: none;
}

/* -- Sprint divider -- */
.sprint-divider {
    text-align: center;
    margin: 32px 0 20px;
    position: relative;
}
.sprint-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.sprint-divider span {
    background: var(--bg);
    padding: 0 16px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    position: relative;
    z-index: 1;
}

/* -- Sortable table headers -- */
table.sortable th {
    cursor: pointer;
    user-select: none;
    position: relative;
}
table.sortable th:hover {
    color: var(--accent);
}
table.sortable th.sort-asc::after {
    content: ' ▲';
    font-size: 0.65em;
    color: var(--green);
}
table.sortable th.sort-desc::after {
    content: ' ▼';
    font-size: 0.65em;
    color: var(--accent);
}

.optimizer-result h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.lineup-summary {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lineup-stat {
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-align: center;
}

.lineup-stat .big-num {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
}

.lineup-stat .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.lineup-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Horizontal lineup picks row */
.lineup-picks-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.lineup-pick-h {
    flex: 1;
    min-width: 120px;
    max-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}

.lineup-pick-h::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--team-color, var(--border));
}

.lineup-pick-h.boosted {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(225, 6, 0, 0.2);
}

.pick-h-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 2px;
}

.pick-h-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.boost-badge {
    background: var(--accent);
    color: white;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}

.pick-h-team {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pick-h-pts {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.pick-h-pts .pick-h-pts-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.pick-h-meta {
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.pick-h-price-change {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.constructor-pick-h .pick-h-name {
    font-weight: 800;
    letter-spacing: 0.5px;
    font-size: 11px;
}

/* Old vertical lineup-pick kept for backward compat but hidden by default */
.lineup-pick { display: none; }
.lineup-picks-grid { display: none; }

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .lineup-picks-row {
        flex-wrap: wrap;
    }
    .lineup-pick-h {
        min-width: calc(33% - 6px);
        max-width: none;
        flex: 1 1 calc(33% - 6px);
    }
}

/* ---- About ---- */
.about-content {
    max-width: 900px;
}

.about-content h2 {
    font-size: 28px;
    margin-bottom: 24px;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.about-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.about-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.about-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.about-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.about-section {
    margin-bottom: 32px;
}

.about-section h3 {
    font-size: 18px;
    margin-bottom: 12px;
}

.about-section ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.about-section li {
    color: var(--text-secondary);
    padding-left: 20px;
    position: relative;
    font-size: 14px;
}

.about-section li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}

.about-section p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.about-footer {
    border-top: 1px solid var(--border);
    padding-top: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.generated-at {
    margin-top: 4px;
    font-size: 12px;
}

/* ---- Analysis ---- */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.analysis-header h2 {
    font-size: 24px;
}

.analysis-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.analysis-btn {
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    padding: 8px 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.analysis-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.analysis-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.analysis-panel {
    display: none;
}

.analysis-panel.active {
    display: block;
}

.analysis-race-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.analysis-block {
    margin-bottom: 32px;
}

.analysis-block h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.no-data {
    color: var(--text-muted);
    padding: 40px 0;
    text-align: center;
}

.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }

/* Compound badges */
.compound-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin: 2px;
}

.compound-badge.soft { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.compound-badge.medium { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.compound-badge.hard { background: rgba(156, 163, 184, 0.2); color: #9ca3b8; }
.compound-badge.intermediate { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.compound-badge.wet { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
.compound-badge.unknown { background: rgba(107, 115, 148, 0.2); color: #6b7394; }

/* Degradation rates */
.deg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.deg-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.deg-driver {
    font-weight: 700;
    margin-bottom: 8px;
}

.deg-compound {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.deg-rate {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.deg-good { color: var(--green); }
.deg-ok { color: var(--yellow); }
.deg-bad { color: var(--red); }

/* Management score */
.mgmt-score {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.score-good { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.score-ok { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.score-bad { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* ---- Season ---- */
.season-header {
    margin-bottom: 24px;
}

.season-header h2 {
    font-size: 24px;
}

.season-sections {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.season-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.status-done {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.status-predicted {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.status-upcoming {
    background: rgba(107, 115, 148, 0.15);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.trend-up { color: var(--green); font-weight: 700; }
.trend-down { color: var(--red); font-weight: 700; }
.trend-stable { color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
    }

    .race-badge {
        width: 100%;
    }

    .countdown-badge {
        width: 100%;
    }

    .controls {
        flex-direction: column;
    }

    select, input[type="number"] {
        width: 100%;
    }

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

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

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

    .analysis-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

@media (max-width: 480px) {
    .logo-text {
        font-size: 18px;
    }

    .tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .lineup-cards {
        grid-template-columns: 1fr;
    }
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.driver-card, .constructor-card {
    animation: fadeIn 0.3s ease-out;
    animation-fill-mode: both;
}

.driver-card:nth-child(n) { animation-delay: calc(0.03s * var(--i, 0)); }

/* Value score tooltip */
.value-tag .value-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 260px;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.4;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
}
.value-tag:hover .value-tooltip {
    display: block;
}

/* Post-race driver cards */
.postrace-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.postrace-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    border-left: 3px solid var(--team-color, var(--border));
    transition: background 0.15s;
}
.postrace-card:hover {
    background: var(--bg-card-hover);
}
.postrace-card .pr-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.postrace-card .pr-driver {
    font-weight: 700;
    font-size: 1rem;
}
.postrace-card .pr-team {
    font-size: 0.8rem;
    color: var(--team-color, var(--text-secondary));
}
.postrace-card .pr-position {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.postrace-card .pr-position.dnf {
    color: var(--orange);
    font-size: 1rem;
}
.postrace-card .pr-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.postrace-card .pr-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}
.postrace-card .pr-change {
    font-weight: 700;
    font-size: 0.85rem;
}
.postrace-card .pr-change.positive { color: var(--green); }
.postrace-card .pr-change.negative { color: var(--accent); }
.postrace-card .pr-change.neutral { color: var(--text-muted); }
.postrace-card .pr-points {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

/* -- Predicted vs Actual Comparison -- */
.cmp-green { color: var(--green); font-weight: 700; }
.cmp-yellow { color: var(--yellow); font-weight: 700; }
.cmp-red { color: var(--accent); font-weight: 700; }

.accuracy-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.accuracy-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
.accuracy-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.accuracy-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Clickable rows in season calendar */
.clickable-row:hover {
    background: var(--bg-card-hover);
    transition: background 0.15s;
}

/* ============================================================
   Head-to-Head Tab
   ============================================================ */

.h2h-header {
    margin-bottom: 24px;
}
.h2h-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 6px;
}
.h2h-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.h2h-selectors {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    justify-content: center;
}
.h2h-selector-group {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}
.h2h-selector-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.h2h-selector-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}
.h2h-vs {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-muted);
    padding-top: 20px;
    letter-spacing: 2px;
}

.h2h-comparison {
    max-width: 700px;
    margin: 0 auto;
}

.h2h-drivers-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.h2h-driver-name {
    font-size: 1.2rem;
    font-weight: 700;
}
.h2h-driver-team {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

.h2h-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.h2h-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.h2h-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.h2h-stat-row:last-of-type {
    border-bottom: none;
}
.h2h-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    flex: 1;
}
.h2h-stat-val {
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 100px;
}
.h2h-stat-val:first-child {
    text-align: left;
}
.h2h-stat-val:last-child {
    text-align: right;
}
.h2h-better {
    opacity: 1;
}
.h2h-worse {
    opacity: 0.5;
}

.h2h-win-bar-container {
    margin-top: 16px;
}
.h2h-win-bar-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}
.h2h-win-bar {
    display: flex;
    height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.h2h-win-bar-a,
.h2h-win-bar-b {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    transition: width 0.4s ease;
}

.h2h-record {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.h2h-record-sep {
    color: var(--text-muted);
    margin: 0 8px;
}
.h2h-averages {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.h2h-history-table tbody tr.h2h-winner-a td:nth-child(3) {
    font-weight: 700;
}
.h2h-history-table tbody tr.h2h-winner-b td:nth-child(4) {
    font-weight: 700;
}

.h2h-recommendation {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
}
.h2h-rec-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 8px;
}
.h2h-rec-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ============================================================
   Accuracy Dashboard Tab
   ============================================================ */

.accuracy-header {
    margin-bottom: 24px;
}
.accuracy-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 6px;
}
.accuracy-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.accuracy-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.accuracy-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
}
.accuracy-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.accuracy-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.accuracy-section {
    margin-bottom: 28px;
}
.accuracy-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.scatter-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}
.scatter-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.bias-over {
    color: var(--orange) !important;
}
.bias-under {
    color: #22d3ee !important;
}

.ci-bar-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 28px;
}
.ci-bar-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.ci-bar {
    height: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: visible;
}
.ci-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}
.ci-bar-target {
    position: absolute;
    top: -6px;
    bottom: -6px;
    width: 2px;
    background: var(--text-primary);
}
.ci-bar-target span {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.accuracy-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.accuracy-filter-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}
.accuracy-filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.accuracy-filter-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.accuracy-filter-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}
.accuracy-filter-btn.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    font-weight: 600;
}

.accuracy-round-table,
.accuracy-driver-table {
    width: 100%;
}

/* Responsive adjustments for H2H */
@media (max-width: 600px) {
    .h2h-selectors {
        flex-direction: column;
        align-items: stretch;
    }
    .h2h-selector-group {
        max-width: none;
    }
    .h2h-vs {
        padding-top: 0;
        text-align: center;
    }
    .h2h-stat-val {
        min-width: 70px;
        font-size: 0.85rem;
    }
}

/* ============================================================
   Hero Section
   ============================================================ */

.hero {
    position: relative;
    margin: -28px -20px 28px;
    padding: 40px 20px 36px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(225,6,0,0.08) 0%, transparent 50%, rgba(54,113,198,0.06) 100%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    max-width: var(--container);
    margin: 0 auto;
}

.hero-title-area {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.hero-flag {
    font-size: 48px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.hero-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.hero-picks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--team-color);
}

.hero-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: var(--team-color);
}

.hero-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.hero-card-driver {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 2px;
}

.hero-card-team {
    font-size: 13px;
    color: var(--team-color);
    font-weight: 500;
    margin-bottom: 12px;
}

.hero-card-pts {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.hero-card-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Optimizer summary gradient */
.lineup-summary {
    background: linear-gradient(135deg, rgba(225,6,0,0.04) 0%, transparent 100%);
    border-radius: var(--radius);
    padding: 16px;
}

@media (max-width: 768px) {
    .hero-picks {
        grid-template-columns: 1fr;
    }
    .hero-title {
        font-size: 24px;
    }
    .hero-flag {
        font-size: 36px;
    }
}

/* ============================================================
   Weather Widget
   ============================================================ */
.weather-widget {
    margin: 20px 0 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
    overflow: hidden;
}
.weather-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.weather-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.weather-title-icon {
    font-size: 1.3rem;
}
.weather-overall-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 20px;
    color: #fff;
    text-transform: uppercase;
}
.weather-update-info {
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.7;
}
.weather-sessions-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.weather-day-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.weather-day-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding-left: 4px;
}
.weather-session {
    background: var(--risk-bg, rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 12px 14px;
    min-width: 120px;
    transition: transform 0.15s, border-color 0.15s;
}
.weather-session:hover {
    transform: translateY(-2px);
    border-color: var(--risk-color, var(--border));
}
.weather-session.weather-rain {
    border-color: var(--risk-color, #f39c12);
    box-shadow: 0 0 12px rgba(243,156,18,0.08);
}
.weather-session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.weather-session-name {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text);
}
.weather-session-icon {
    font-size: 1.2rem;
}
.weather-rain-bar {
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.weather-rain-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}
.weather-rain-pct {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.weather-session-details {
    display: flex;
    gap: 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.weather-session-desc {
    font-size: 0.68rem;
    color: var(--text-secondary);
    opacity: 0.7;
}
.weather-source {
    margin-top: 12px;
    font-size: 0.62rem;
    color: var(--text-secondary);
    opacity: 0.5;
    text-align: right;
}

/* Weather responsive */
@media (max-width: 768px) {
    .weather-sessions-grid {
        flex-direction: column;
    }
    .weather-day-group {
        flex-direction: row;
        overflow-x: auto;
    }
    .weather-session {
        min-width: 130px;
    }
    .weather-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---- Race Deep Dive Tab ---- */
.deepdive-header { margin-bottom: 24px; }
.deepdive-header h2 { margin-bottom: 8px; }
.deepdive-header p { color: var(--text-secondary); margin-bottom: 16px; }
.deepdive-race-title { font-size: 1.3rem; color: var(--accent); margin-bottom: 20px; }

/* Collapsible sections */
.collapsible-section { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.collapsible-section .section-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; cursor: pointer; user-select: none; background: var(--bg-card); transition: background 0.2s; }
.collapsible-section .section-header:hover { opacity: 0.85; }
.collapsible-section .section-header h3 { margin: 0; font-size: 1rem; }
.collapsible-section .toggle-icon { font-size: 0.8rem; color: var(--text-secondary); transition: transform 0.2s; }
.collapsible-section .section-body { max-height: 0; overflow: hidden; padding: 0 16px; }
.collapsible-section.open .section-body { max-height: none; padding: 12px 16px 16px; overflow: visible; }
.collapsible-section.open .toggle-icon { transform: rotate(180deg); }

.chart-container { position: relative; height: 400px; margin: 16px 0; background: var(--bg-card); border-radius: 10px; padding: 12px; }
.chart-container.chart-tall { height: 550px; }

.chart-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.chart-controls label { color: var(--text-secondary); font-size: 0.85rem; }
.btn-small { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.btn-small:hover { background: var(--accent); color: #000; }
.btn-small.active { background: var(--accent); color: #000; font-weight: 600; }

.compound-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.compound-soft { background: #FF333344; color: #FF3333; border: 1px solid #FF3333; }
.compound-medium { background: #FFD70044; color: #FFD700; border: 1px solid #FFD700; }
.compound-hard { background: #FFFFFF22; color: #FFFFFF; border: 1px solid #888; }

.highlight-purple { color: #b366ff; font-weight: 700; }

.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.badge-red { background: #E8002033; color: #FF4444; border: 1px solid #E80020; }

.analysis-note { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 12px; font-style: italic; }

.round-selector { display: flex; align-items: center; gap: 10px; }
.round-selector label { color: var(--text-secondary); font-weight: 500; }
.round-selector select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; }

.team-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Driver multi-select for charts */
.dd-driver-select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 0.8rem;
    min-width: 200px;
    max-width: 400px;
    height: auto;
    max-height: 120px;
    overflow-y: auto;
}
.dd-driver-select option {
    padding: 2px 6px;
}
.dd-driver-select option:checked {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}

/* ---- Articles Tab ---- */
.articles-header { margin-bottom: 24px; }
.articles-header h2 { margin-bottom: 8px; }
.articles-header p { color: var(--text-secondary); margin-bottom: 16px; }

.articles-list { display: flex; flex-direction: column; gap: 0; }
.article-card { margin-bottom: 16px; }
.article-header-content { flex: 1; min-width: 0; }
.article-header-content h3 { margin: 0 0 6px 0; font-size: 1.1rem; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.article-round { background: var(--accent); color: #000; padding: 2px 10px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; }
.article-tag { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); padding: 2px 8px; border-radius: 4px; font-size: 0.72rem; }
.article-date { color: var(--text-secondary); font-size: 0.8rem; }
.article-body { color: var(--text); line-height: 1.7; font-size: 0.95rem; }
.article-body h2 { font-size: 1.15rem; margin: 20px 0 10px; color: var(--accent); }
.article-body h3 { font-size: 1.05rem; margin: 16px 0 8px; }
.article-body p { margin-bottom: 12px; }
.article-body ul, .article-body ol { margin: 8px 0 12px 20px; }
.article-body li { margin-bottom: 4px; }
.article-body strong { color: var(--text); }
.article-body em { color: var(--text-secondary); }
.article-body blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 8px 16px; background: var(--bg-card); border-radius: 0 8px 8px 0; }

/* ---- Videos Tab ---- */
.videos-header { margin-bottom: 24px; }
.videos-header h2 { margin-bottom: 8px; }
.videos-header p { color: var(--text-secondary); margin-bottom: 16px; }
.btn-yt-subscribe {
    display: inline-flex; align-items: center; gap: 6px;
    background: #ff0000; color: #fff; padding: 8px 18px; border-radius: 6px;
    font-size: 0.85rem; font-weight: 600; text-decoration: none; transition: opacity 0.2s;
}
.btn-yt-subscribe:hover { opacity: 0.85; }
.videos-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px;
}
.video-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; transition: transform 0.2s, border-color 0.2s;
}
.video-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.video-card a { text-decoration: none; color: inherit; }
.video-thumb { position: relative; width: 100%; padding-top: 56.25%; background: #000; overflow: hidden; }
.video-thumb img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 52px; height: 36px; background: rgba(225,6,0,0.9); border-radius: 8px;
    display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s;
}
.video-card:hover .video-play-icon { opacity: 1; }
.video-play-icon::after { content: ''; border-left: 16px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent; margin-left: 3px; }
.video-info { padding: 12px 14px; }
.video-info h3 { font-size: 0.9rem; margin: 0 0 6px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-date { font-size: 0.75rem; color: var(--text-secondary); }

/* ---- Footer ---- */
.site-footer {
    margin-top: 60px; padding: 30px 0; border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.footer-social {
    display: flex; justify-content: center; gap: 20px; margin-bottom: 20px;
}
.social-link {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; background: var(--bg-card);
    border: 1px solid var(--border); color: var(--text-secondary);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.social-link:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.footer-disclaimer {
    color: var(--text-muted); font-size: 0.7rem; line-height: 1.6;
    text-align: center; max-width: 800px; margin: 0 auto;
}

/* Tool explainer */
.tool-explainer {
    margin: 0 0 16px 0;
    font-size: 0.85rem;
}
.tool-explainer summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    padding: 8px 0;
}
.tool-explainer p, .tool-explainer li {
    color: var(--text-secondary);
    line-height: 1.5;
}
.tool-explainer ul {
    padding-left: 20px;
    margin-top: 8px;
}

/* Target team */
.mw-target-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

/* Team evolution */
.mw-team-evolution {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}
.mw-team-evolution summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 0;
}
.mw-team-round {
    margin: 8px 0;
    padding: 8px;
    background: var(--bg-secondary, var(--bg));
    border-radius: 6px;
}
.mw-team-round-header {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.mw-team-round-roster {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mw-team-member {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--card);
    border-left: 3px solid var(--team-color, #666);
}
.mw-team-member.new {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--green, #22c55e);
}
.mw-team-member.constructor {
    font-weight: 700;
    font-size: 0.7rem;
}
.mw-member-pts {
    color: var(--text-secondary);
    font-size: 0.65rem;
}

/* About intro */
.about-intro { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.95rem; line-height: 1.6; }
