/* ========================================
   CRT Racing Analytics - Premium Styles
   ======================================== */

/* CSS Variables - CRT Team Colors */
:root {
    /* Primary Colors */
    --color-red-primary: #DC2626;
    --color-red-bright: #EF4444;
    --color-red-soft: #FCA5A5;
    --color-black-deep: #0A0A0A;
    --color-black-dark: #1A1A1A;
    --color-black-medium: #2A2A2A;

    /* Secondary Colors */
    --color-white: #FFFFFF;
    --color-blue: #3B82F6;
    --color-blue-dark: #1E40AF;

    /* Accent Colors */
    --color-green-up: #10B981;
    --color-red-down: #EF4444;
    --color-gold: #F59E0B;
    --color-purple: #9333EA;
    --color-orange: #F97316;
    --color-yellow: #FBBF24;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--color-red-primary) 0%, var(--color-black-dark) 100%);
    --gradient-card: linear-gradient(135deg, rgba(220, 38, 38, 0.1) 0%, rgba(26, 26, 26, 0.8) 100%);

    /* Typography */
    --font-display: 'Rajdhani', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-red: 0 0 20px rgba(220, 38, 38, 0.5);
    --shadow-glow-gold: 0 0 20px rgba(245, 158, 11, 0.6);
}

/* Global Scroll Base */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    overflow-x: hidden;
    overflow-y: auto !important;
    /* Ensure scrolling is ALWAYS available */
}

/* Fullscreen Button Styles */
.fullscreen-btn {
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid #444;
    color: #eee;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-display);
    margin-right: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.fullscreen-btn:hover {
    background: var(--color-red-primary);
    border-color: var(--color-red-bright);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

@media (max-width: 850px) {
    .fullscreen-btn {
        display: none !important;
        /* Hide on mobile to save space */
    }
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

body {
    font-family: var(--font-body);
    background: var(--color-black-deep);
    color: var(--color-white);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(220, 38, 38, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(25px);
    border-bottom: 2px solid var(--color-red-primary);
    padding: var(--spacing-sm) var(--spacing-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 120px;
    gap: 12px;
}

/* header-top-row never expands to full width as a flex child */
.header-top-row {
    flex-shrink: 0;
}

.logo-container {
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Creating a soft aura/glow behind the logo to prevent the 'sticker' effect */
.logo-container::after {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(220, 38, 38, 0.3) 0%, transparent 70%);
    z-index: -1;
    filter: blur(15px);
    pointer-events: none;
}

.logo {
    height: 88px;
    /* Reduced by 20% from 110px */
    width: auto;
    /* Soften edges and integrate with multiple shadows */
    filter: drop-shadow(0 0 15px rgba(220, 38, 38, 0.4)) drop-shadow(0 0 30px rgba(0, 0, 0, 0.8));
    transition: all 0.3s ease;
}

.logo:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 0 25px rgba(220, 38, 38, 0.6));
}

.header-center {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* View Selector */
.view-selector {
    display: flex;
    gap: 10px;
    margin: 5px 0;
}

.view-btn {
    background: var(--color-black-medium);
    border: 1px solid var(--color-red-primary);
    color: var(--color-white);
    padding: 6px 15px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.view-btn:hover {
    background: var(--color-red-primary);
}

.view-btn.active {
    background: var(--color-red-primary);
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.4);
}

.header-race-name {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--color-red-soft);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: -5px;
}

.title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    /* Reduced size */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, var(--color-red-bright) 0%, var(--color-white) 50%, var(--color-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    min-width: 400px;
    /* Increased to fit giant clock comfortably */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.digital-clock {
    font-family: var(--font-display);
    font-size: 6rem;
    /* Slightly reduced to avoid edge overflow */
    font-weight: 800;
    color: var(--color-red-bright);
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    letter-spacing: 2px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    /* Critical: locks number width */
    width: 400px;
    /* Fixed width matching the container */
    text-align: right;
}

/* Main Content */
.main-content {
    padding: 0;
    max-width: 100%;
    margin: 0;
}

/* Slideshow Container */
.slideshow-container {
    position: relative;
    overflow: hidden;
    height: calc(100vh - 140px);
    /* Fill remaining space below header */
    display: flex;
    justify-content: center;
}

.slide {
    display: none;
    animation: fadeIn 0.8s ease-in-out;
}

.slide.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pilot Cards Grid */
.pilots-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 5), 1fr);
    gap: 8px;
    /* Compact gap */
    padding: 10px;
    transform-origin: top center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

@media (max-width: 1600px) {
    .pilots-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1300px) {
    .pilots-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .pilots-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .pilots-grid {
        grid-template-columns: 1fr;
    }
}

/* Pilot Card */
.pilot-card {
    background: #000000;
    border-radius: var(--radius-md);
    padding: 12px;
    border: 2px solid #0a0a0a;
    box-shadow: none;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}


.pilot-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    /* Slightly thinner */
    background: #111;
    /* Very dark grey, almost black */
}

.pilot-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-red-bright);
}

.pilot-card.titular {
    border-color: #ff85a1;
    /* Brighter Pink */
    box-shadow: 0 0 25px rgba(255, 133, 161, 0.25);
    background: #050505;
    /* Slightly lighter than pure black to distinguish */
}

.pilot-card.titular::before {
    background: linear-gradient(90deg, #ffccd5 0%, #ff4d6d 100%);
    /* Much clearer/brighter pink to white */
    height: 4px;
}

/* Pilot Header */
.pilot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    /* Reduced margin */
    position: relative;
}

.pilot-photo {
    width: 60px;
    /* Smaller photo */
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}

.pilot-photo.placeholder {
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    border: 2px solid transparent;
}

.pilot-info {
    flex-grow: 1;
    min-height: 2.8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Removed global padding-right to allow details to overlap badge */
}

.pilot-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    padding-right: 95px;
    /* Protected area for badge */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.1;
}

.pilot-details {
    display: flex;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: var(--color-red-soft);
    /* No padding-right here, allowed to overlap with badge's bottom area if needed */
}

.pilot-dorsal {
    font-weight: 600;
}

/* Position Badge */
.position-badge {
    position: absolute;
    right: 0;
    top: 0;
    background: var(--gradient-primary);
    padding: 10px 20px;
    border-radius: 0 0 0 var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 2.8rem;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    line-height: 1;
}

.position-badge.dnf {
    background: #333;
    color: #888;
    border: 1px solid #444;
}

.position-badge.pos-purple {
    background: var(--color-purple);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.4);
}

.position-badge.pos-green {
    background: var(--color-green-up);
}

.position-badge.pos-orange {
    background: var(--color-orange);
}

.position-arrow {
    font-size: 1.5rem;
    animation: bounce 1s infinite;
}

.position-arrow.up {
    color: var(--color-green-up);
}

.position-arrow.down {
    color: var(--color-red-down);
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Time Gaps & ESP Status Layout */
.gaps-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 6px;
    /* Reduced gap */
    margin-top: var(--spacing-xs);
}

.gap-item {
    background: rgba(42, 42, 42, 0.6);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    /* More compact */
    border-left: 4px solid var(--color-blue);
    transition: border-color 0.3s ease;
    min-height: 48px;
    /* Reduced height */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Individual slots */
.gap-target {
    grid-area: 1 / 1 / 2 / 2;
}

.esp-summary-slot {
    grid-area: 1 / 2 / 2 / 3;
}

.gap-ahead {
    grid-area: 2 / 1 / 3 / 2;
}

.gap-behind {
    grid-area: 2 / 2 / 3 / 3;
}

/* Threshold Colors */
.border-purple {
    border-left-color: var(--color-purple);
    animation: alert-shake 5s linear infinite;
}

.border-green {
    border-left-color: var(--color-green-up);
}

.border-yellow {
    border-left-color: var(--color-yellow);
}

.border-red {
    border-left-color: var(--color-red-down);
    animation: alert-shake 5s linear infinite;
}

.border-orange {
    border-left-color: var(--color-orange);
}

@keyframes alert-shake {

    /* 0% to 60% (3 seconds in a 5s cycle) - Fast vibration with 3px range */
    0%,
    60%,
    100% {
        transform: translateX(0);
    }

    2%,
    6%,
    10%,
    14%,
    18%,
    22%,
    26%,
    30%,
    34%,
    38%,
    42%,
    46%,
    50%,
    54%,
    58% {
        transform: translateX(-3px);
    }

    4%,
    8%,
    12%,
    16%,
    20%,
    24%,
    28%,
    32%,
    36%,
    40%,
    44%,
    48%,
    52%,
    56%,
    60% {
        transform: translateX(3px);
    }
}

.border-transparent {
    border-left-color: transparent;
}

@keyframes card-vibration {

    0%,
    97% {
        transform: translate(0, 0);
    }

    97.5% {
        transform: translate(1px, 1.5px);
    }

    98.5% {
        transform: translate(-1.5px, -1px);
    }

    99% {
        transform: translate(1.5px, -1.5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.esp-summary-slot {
    grid-area: 1 / 2 / 2 / 3;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.esp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-white);
}

.esp-label {
    font-weight: 600;
    color: var(--color-red-soft);
}

.gap-label {
    font-size: 0.8rem;
    color: var(--color-red-soft);
    margin-bottom: 0.25rem;
}

.gap-value {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-white);
}

/* Team Standings */
.team-standings {
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    border: 2px solid var(--color-red-primary);
    box-shadow: var(--shadow-lg);
}

.standings-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.category-stat {
    background: rgba(42, 42, 42, 0.6);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--color-blue);
}

.category-name {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-red-bright);
    margin-bottom: var(--spacing-sm);
}

.pilot-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.pilot-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs);
    background: rgba(26, 26, 26, 0.5);
    border-radius: var(--radius-sm);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    width: 400px;
    height: 400px;
    object-fit: contain;
    border-radius: 50%;
    opacity: 0.8;
    margin-bottom: var(--spacing-lg);
    animation: pulseRotate 2s linear infinite;
    /* Faster and linear for constant spin */
    filter: drop-shadow(0 0 40px rgba(220, 38, 38, 0.7));
    background: rgba(0, 0, 0, 0.2);
    /* Sutil backing for the circle */
}

@keyframes pulseRotate {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.05) rotate(180deg);
        opacity: 0.9;
    }

    100% {
        transform: scale(1) rotate(360deg);
        opacity: 0.7;
    }
}

.loading-overlay p {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-red-soft);
}

/* Team Rankings Styles */
.team-rankings-section {
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 5), 1fr);
    /* 5 Columns for maximum horizontal fill */
    gap: 8px;
    padding: 8px;
    width: 100%;
    transform-origin: top center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1400px) {
    .team-rankings-section {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .team-rankings-section {
        grid-template-columns: repeat(2, 1fr);
    }
}

.team-card {
    background: #000000;
    border-radius: var(--radius-md);
    padding: 8px;
    /* Minimal padding */
    border: 3px solid #0a0a0a;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.team-card.titular-team {
    border-color: #ffccd5;
    /* Brighter pink for ours */
    box-shadow: 0 0 30px rgba(255, 133, 161, 0.15);
}

.team-card.titular-team::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #ffccd5 0%, #ff4d6d 100%);
}

.team-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.team-logo {
    width: 55px;
    /* Enlarged logo as requested */
    height: 55px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: #111;
    padding: 3px;
}

.team-info {
    flex-grow: 1;
}

.team-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    /* Reduced font for 5 cols */
    font-weight: 700;
    color: var(--color-white);
    text-transform: uppercase;
    line-height: 1;
}

.team-score-badge {
    background: var(--gradient-primary);
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 90px;
}

.team-position-value {
    font-size: 1.5rem;
    /* Smaller badge font */
    font-weight: 800;
    color: var(--color-white);
    line-height: 1;
    margin-bottom: 2px;
}

.score-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-display);
    line-height: 1;
    color: var(--color-red-soft);
}

.score-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--color-white);
    opacity: 0.8;
}

.team-pilots-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    height: 100px;
    /* Minimal height to forced massive Auto-Zoom */
    overflow-y: hidden;
    position: relative;
    scrollbar-width: none;
}

.team-pilots-list::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar for Chrome/Safari/Edge */
}

.team-pilot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    /* More compact rows */
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
}

.team-pilot-row.points-high {
    border-left-color: var(--color-green-up);
}

.team-pilot-row.points-med {
    border-left-color: var(--color-yellow);
}

.team-pilot-name {
    font-weight: 600;
    font-size: 1rem;
}

.team-pilot-meta {
    font-size: 0.8rem;
    color: var(--color-red-soft);
}

.team-pilot-score {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-white);
}

.position-tag {
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 8px;
}

/* ====================================================
   RESPONSIVE: TV / Medium screens (851px – 1400px)
   ==================================================== */
@media (min-width: 851px) and (max-width: 1400px) {
    .header {
        height: auto !important;
        min-height: 80px;
        padding: 8px 20px !important;
    }

    .digital-clock {
        font-size: 3.2rem !important;
        width: auto !important;
        letter-spacing: 1px !important;
    }

    .header-right {
        min-width: auto !important;
        gap: 8px !important;
    }

    .title {
        font-size: 1.4rem !important;
    }

    .view-btn {
        padding: 5px 10px !important;
        font-size: 0.82rem !important;
    }

    .slideshow-container {
        height: calc(100vh - 100px) !important;
    }
}

/* ====================================================
   RESPONSIVE: Mobile (≤ 850px)
   ==================================================== */
@media (max-width: 850px) {

    /* Ensure scrolling is possible and scrollbars are visible on mobile */
    html,
    body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        scrollbar-width: thin !important;
    }

    html::-webkit-scrollbar,
    body::-webkit-scrollbar {
        display: block !important;
        width: 6px !important;
    }

    .header {
        height: auto !important;
        padding: 8px 15px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 5px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: rgba(0, 0, 0, 0.98) !important;
        z-index: 9999 !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8) !important;
    }

    /* Container for Logo + Title */
    .logo-container {
        display: inline-flex !important;
        align-items: center !important;
        gap: 10px !important;
        margin: 0 !important;
        width: 100% !important;
        justify-content: center !important;
    }

    .logo {
        height: 35px !important;
        width: auto !important;
    }

    .title {
        display: inline-block !important;
        font-size: 1.2rem !important;
        margin: 0 !important;
        text-align: left !important;
        width: auto !important;
        white-space: nowrap !important;
    }

    .digital-clock,
    .fullscreen-btn,
    .header-race-name {
        display: none !important;
    }

    .header-right {
        display: flex !important;
        width: 100% !important;
        justify-content: center !important;
        margin-top: 2px !important;
    }

    .search-container {
        width: 100% !important;
        max-width: 280px !important;
        margin: 0 auto !important;
    }

    .search-container input {
        width: 100% !important;
        height: 28px !important;
        font-size: 0.85rem !important;
        padding: 4px 10px !important;
    }

    .header-center {
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .view-selector {
        margin: 2px 0 !important;
        width: 100% !important;
        justify-content: center !important;
        gap: 8px !important;
        display: flex !important;
    }

    .view-btn {
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
        flex: 0 1 auto !important;
        min-width: 100px !important;
        text-align: center !important;
        background: #1a1a1a !important;
        border: 2px solid var(--color-red-primary) !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .view-btn[data-view="auto"] {
        display: none !important;
    }

    /* All other view buttons visible and wrapped */
    .view-selector {
        flex-wrap: wrap !important;
        gap: 5px !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .view-btn {
        padding: 5px 10px !important;
        font-size: 0.78rem !important;
        min-width: 72px !important;
        height: 30px !important;
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .slideshow-container {
        height: auto !important;
        min-height: calc(100vh - 130px) !important;
        margin-top: 0 !important;
        padding-bottom: 40px !important;
        overflow-y: visible !important;
        display: block !important;
    }

    /* main-content provides the top offset for all children */
    .main-content {
        overflow-y: visible !important;
        margin-top: 130px !important;
        padding-bottom: 20px !important;
    }

    /* Analysis container mobile */
    #analysisContainer {
        display: block;
        padding: 10px !important;
        min-height: calc(100vh - 130px) !important;
        overflow-x: hidden !important;
    }

    .pilots-grid,
    .team-rankings-section {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 15px !important;
        transform: none !important;
        width: 100% !important;
    }

    .pilot-card,
    .team-card {
        width: 100% !important;
        margin-bottom: 15px !important;
        border: 2px solid #222 !important;
    }

    /* Pilot Dashboard Responsive */
    .pilot-profile-row {
        flex-direction: column !important;
        text-align: center !important;
        gap: 1rem !important;
    }

    .pilot-profile-photo {
        width: 150px !important;
        height: 150px !important;
        margin: 0 auto !important;
    }

    .pilot-profile-name {
        font-size: 2.2rem !important;
    }

    .pilot-profile-meta {
        font-size: 1.1rem !important;
        flex-direction: column !important;
        display: flex !important;
        gap: 5px !important;
    }

    .pilot-profile-pos-box {
        text-align: center !important;
        width: 100% !important;
        margin-top: 1rem !important;
    }

    .pilot-profile-pos-val {
        font-size: 4rem !important;
    }

    .pilot-kpis-grid {
        grid-template-columns: 1fr !important;
    }

    .competitors-section {
        padding: 10px !important;
    }

    .competitors-table th:nth-child(4),
    .competitors-table td:nth-child(4),
    .competitors-table th:nth-child(5),
    .competitors-table td:nth-child(5),
    .competitors-table th:nth-child(6),
    .competitors-table td:nth-child(6) {
        display: none !important;
    }

    /* ---- Analysis table: mobile ---- */
    .analysis-section {
        padding: 0 !important;
    }

    .analysis-wrapper {
        gap: 0.4rem !important;
    }

    .analysis-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 0 0.25rem 0.25rem !important;
        gap: 0.25rem !important;
    }

    .analysis-title {
        font-size: 1rem !important;
    }

    /* Hide legend — too wide on mobile */
    .analysis-legend {
        display: none !important;
    }

    /* Disable sticky cols on mobile — iOS Safari breaks with them */
    .analysis-th-sticky,
    .analysis-sticky {
        position: relative !important;
        z-index: 1 !important;
        min-width: 130px !important;
        background: var(--color-black-medium) !important;
    }

    .analysis-table-scroll {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 8px !important;
    }

    .analysis-th {
        padding: 6px 7px !important;
        font-size: 0.62rem !important;
        white-space: nowrap !important;
    }

    .analysis-td,
    .analysis-td-center {
        padding: 7px 6px !important;
    }

    .analysis-pilot-cell {
        gap: 7px !important;
    }

    .analysis-pilot-photo,
    .analysis-pilot-photo.placeholder {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.6rem !important;
    }

    .analysis-pilot-name {
        font-size: 0.78rem !important;
        line-height: 1.2 !important;
    }

    .analysis-pilot-meta {
        font-size: 0.62rem !important;
    }

    .analysis-pos-badge {
        font-size: 0.72rem !important;
        padding: 2px 6px !important;
    }

    .analysis-esp-badge {
        font-size: 0.68rem !important;
        padding: 2px 5px !important;
        min-width: 28px !important;
    }

    .analysis-perlap-badge {
        font-size: 0.72rem !important;
        padding: 2px 5px !important;
        min-width: 36px !important;
    }

    .analysis-footer {
        font-size: 0.62rem !important;
        padding: 0.3rem !important;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

.category-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--color-red-bright);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Mini Spinner */
.mini-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(220, 38, 38, 0.3);
    border-radius: 50%;
    border-top-color: var(--color-red-bright);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   ANÁLISIS DE PILOTOS
   ============================================= */

.analysis-section {
    padding: 1rem 1.5rem;
    min-height: calc(100vh - 120px);
}

.analysis-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.analysis-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.analysis-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-white);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.analysis-legend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #bbb;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-sep {
    color: #444;
    font-size: 1rem;
    margin: 0 4px;
}

/* Table scroll wrapper */
.analysis-table-scroll {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(26, 26, 26, 0.6);
    backdrop-filter: blur(10px);
}

/* Main table — MUST be separate (not collapse) for position:sticky to work */
.analysis-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}

/* Manual borders to replace collapsed ones */
.analysis-table th,
.analysis-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.analysis-table thead tr:first-child th {
    border-bottom: 2px solid rgba(220, 38, 38, 0.3);
}

/* thead sticky so headers scroll with the table but stay visible */
.analysis-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.analysis-table thead tr:first-child {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.2) 0%, rgba(42, 42, 42, 0.9) 100%);
}

.analysis-subheader {
    background: rgba(42, 42, 42, 0.7);
}

.analysis-th {
    padding: 10px 14px;
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.07em;
    color: var(--color-red-soft);
    font-weight: 700;
    white-space: nowrap;
    border-bottom: 2px solid rgba(220, 38, 38, 0.3);
    vertical-align: bottom;
}

.analysis-th-sticky {
    position: sticky;
    left: 0;
    background: rgba(15, 15, 15, 0.98);
    z-index: 3;
    min-width: 200px;
    border-right: 1px solid rgba(220, 38, 38, 0.2);
}

.analysis-th-center {
    text-align: center;
}

.analysis-th-esp {
    text-align: center;
    padding: 8px 10px;
    font-size: 0.72rem;
    color: #ccc;
}

.analysis-th-bc {
    background: rgba(147, 51, 234, 0.08);
    border-left: 1px solid rgba(147, 51, 234, 0.2);
    border-right: 1px solid rgba(147, 51, 234, 0.2);
}

/* Rows */
.analysis-row {
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.analysis-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.analysis-row:hover .analysis-sticky {
    background: rgba(25, 25, 25, 0.98);
}

.analysis-td {
    padding: 10px 14px;
    vertical-align: middle;
}

.analysis-td-center {
    padding: 10px 10px;
    vertical-align: middle;
    text-align: center;
}

.analysis-td-bc {
    background: rgba(147, 51, 234, 0.05);
    border-left: 1px solid rgba(147, 51, 234, 0.15);
    border-right: 1px solid rgba(147, 51, 234, 0.15);
}

.analysis-sticky {
    position: sticky;
    left: 0;
    background: rgba(20, 20, 20, 0.98);
    z-index: 2;
    border-right: 1px solid rgba(220, 38, 38, 0.15);
}

/* Pilot cell inside sticky column */
.analysis-pilot-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analysis-pilot-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-red-primary);
    flex-shrink: 0;
}

.analysis-pilot-photo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-black-medium);
    color: var(--color-red-soft);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
}

.analysis-pilot-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.analysis-pilot-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-white);
    line-height: 1.2;
}

.analysis-pilot-meta {
    font-size: 0.72rem;
    color: #888;
    line-height: 1.2;
}

/* Position badges for analysis table */
.analysis-pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.analysis-pos-badge.pos-gold    { background: rgba(245, 158, 11, 0.25); color: var(--color-gold); border: 1px solid rgba(245,158,11,0.4); }
.analysis-pos-badge.pos-purple  { background: rgba(147, 51, 234, 0.25); color: #c084fc; border: 1px solid rgba(147,51,234,0.4); }
.analysis-pos-badge.pos-green   { background: rgba(16, 185, 129, 0.2);  color: var(--color-green-up); border: 1px solid rgba(16,185,129,0.35); }
.analysis-pos-badge.pos-orange  { background: rgba(249, 115, 22, 0.2);  color: var(--color-orange); border: 1px solid rgba(249,115,22,0.35); }
.analysis-pos-badge.pos-gray    { background: rgba(100,100,100,0.15);   color: #999; border: 1px solid rgba(100,100,100,0.25); }
.analysis-pos-badge.dnf         { background: rgba(239, 68, 68, 0.15);  color: var(--color-red-bright); border: 1px solid rgba(239,68,68,0.3); }

/* ESP position badges (smaller) */
.analysis-esp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 3px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 32px;
}

.analysis-esp-badge.pos-gold    { background: rgba(245,158,11,0.22);   color: var(--color-gold);      border: 1px solid rgba(245,158,11,0.35); }
.analysis-esp-badge.pos-purple  { background: rgba(147,51,234,0.22);   color: #c084fc;                border: 1px solid rgba(147,51,234,0.35); }
.analysis-esp-badge.pos-green   { background: rgba(16,185,129,0.18);   color: var(--color-green-up);  border: 1px solid rgba(16,185,129,0.3); }
.analysis-esp-badge.pos-orange  { background: rgba(249,115,22,0.18);   color: var(--color-orange);    border: 1px solid rgba(249,115,22,0.3); }
.analysis-esp-badge.pos-gray    { background: rgba(100,100,100,0.1);   color: #777;                   border: 1px solid rgba(100,100,100,0.2); }

/* Per-lap improvement badges */
.analysis-perlap-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 800;
    min-width: 44px;
}

.perlap-leader { background: rgba(16,185,129,0.18); color: var(--color-green-up); border: 1px solid rgba(16,185,129,0.35); }
.perlap-great  { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.perlap-good   { background: rgba(251,191,36,0.15); color: var(--color-yellow); border: 1px solid rgba(251,191,36,0.3); }
.perlap-warn   { background: rgba(249,115,22,0.18); color: var(--color-orange); border: 1px solid rgba(249,115,22,0.3); }
.perlap-hard   { background: rgba(239,68,68,0.18);  color: var(--color-red-bright); border: 1px solid rgba(239,68,68,0.3); }

/* Best-consistency delta */
.bc-delta {
    display: inline-block;
    font-size: 0.72rem;
    font-family: var(--font-display);
    font-weight: 700;
    margin-left: 4px;
}
.bc-up   { color: var(--color-green-up); }
.bc-down { color: var(--color-red-bright); }
.bc-same { color: #666; }

/* Footer note */
.analysis-footer {
    font-size: 0.72rem;
    color: #555;
    text-align: center;
    padding: 0.5rem 0;
    font-family: var(--font-body);
}

/* Empty state */
.analysis-empty {
    text-align: center;
    padding: 3rem;
    color: #666;
    font-family: var(--font-body);
}
}