/* ============================================
   F1 DATA ANALYTICS - PORTFOLIO STYLES
   Premium dark theme with racing aesthetics
   ============================================ */

/* CSS Variables */
:root {
    /* Surfaces.
       Previously the page, the cards and the rendered figures were all within a
       few points of #0a0a0f, so nothing had an edge and the whole page read as
       one flat void. The ramp below is lifted and cooled — a slight blue cast
       reads as instrumentation rather than as an absence of light — and each
       step is far enough from the last to be legible as a separate layer. */
    --bg-primary: #12141a;      /* page */
    --bg-secondary: #171a22;    /* alternating sections */
    --bg-card: #1e222b;         /* cards — clearly above the page */
    --bg-raised: #252a35;       /* hover / raised card */
    --bg-tertiary: #272c37;     /* inset controls: slider tracks, buttons */

    /* Media wells. Kept at the figure background exactly, so a chart sits
       flush in its well while the lighter card frames it like a bezel. This
       is what gives the graphs contrast against the page. */
    --bg-screen: #0a0a0f;

    /* Hairlines as alpha, so they sit correctly on any surface above. */
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);

    /* Accent Colors */
    --accent-primary: #e10600;    /* F1 Red */
    --accent-secondary: #00d2be;  /* Mercedes Teal */
    --accent-tertiary: #ff8700;   /* McLaren Orange */
    --accent-yellow: #fff200;

    /* Text Colors */
    --text-primary: #f5f7fa;
    --text-secondary: #adb6c4;
    --text-muted: #868f9e;

    /* A lighter tint of the brand red, for small text sitting on red-tinted
       chips. Pure #e10600 at 0.75rem on those backgrounds measures about
       3.0:1; this measures about 5.9:1 and still reads as the same red. */
    --accent-soft: #ff7a70;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #e10600 0%, #ff4444 100%);
    --gradient-secondary: linear-gradient(135deg, #00d2be 0%, #00ffcc 100%);
    --gradient-dark: linear-gradient(180deg, #12141a 0%, #1a1e26 100%);

    /* Shadows. Deeper and softer than before: on a lifted base a card needs a
       real shadow to read as raised, and a top highlight to catch the light. */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.48);
    --shadow-glow: 0 0 32px rgba(225, 6, 0, 0.28);
    --edge-light: inset 0 1px 0 rgba(255, 255, 255, 0.06);

    /* Spacing */
    --section-padding: 110px 5%;
    --card-padding: 24px;
    --border-radius: 14px;
    --radius-sm: 8px;

    /* Transitions */
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Racing Lines Background */
.racing-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.03;
    background: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 100px,
            var(--accent-primary) 100px,
            var(--accent-primary) 102px
        );
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    background: rgba(18, 20, 26, 0.72);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--line);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
}

.brand-icon {
    font-size: 1.5rem;
}

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

.nav-links {
    display: flex;
    gap: 32px;
    list-style: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition-fast);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}

.nav-toggle span {
    width: 25px;
    height: 2px;
    background: var(--text-primary);
    transition: var(--transition-fast);
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 120px 5% 80px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60%;
    height: 100%;
    background: radial-gradient(ellipse at 70% 50%, rgba(225, 6, 0, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

.hero-content {
    max-width: 700px;
    z-index: 1;
}

.hero-badge {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(225, 6, 0, 0.15);
    border: 1px solid rgba(225, 6, 0, 0.3);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 24px;
}

.hero-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 24px;
}

.hero-title .line1 {
    display: block;
    font-size: 0.5em;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 2px;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 550px;
}

.hero-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 40px;
}

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

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

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

.hero-cta {
    display: flex;
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition-medium);
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 40px rgba(225, 6, 0, 0.5);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.github-icon {
    width: 18px;
    height: 18px;
}

.hero-visual {
    position: relative;
    z-index: 1;
}

.speed-indicator {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.speed-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(225, 6, 0, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 2s linear infinite;
}

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

.speed-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.speed-unit {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.scroll-arrow {
    width: 24px;
    height: 24px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0) rotate(45deg); }
    40% { transform: translateY(10px) rotate(45deg); }
    60% { transform: translateY(5px) rotate(45deg); }
}

/* Sections */
.section {
    padding: var(--section-padding);
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: var(--accent-primary);
    letter-spacing: 2px;
    display: block;
    margin-bottom: 16px;
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    margin-bottom: 16px;
}

.section-title .accent {
    color: var(--accent-primary);
}

.section-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Telemetry Section */
.telemetry-section {
    background: var(--bg-secondary);
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.analysis-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition-medium);
    cursor: pointer;
}

.analysis-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(225, 6, 0, 0.3);
}

.analysis-card.featured {
    grid-column: span 2;
}

.card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-medium);
}

.analysis-card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: var(--card-padding);
}

.card-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 10px;
    background: rgba(225, 6, 0, 0.15);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-primary);
}

/* G-Force Section */
.gforce-section {
    background: var(--gradient-dark);
}

.gforce-showcase {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 60px;
}

.gforce-main {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.gforce-main img {
    width: 100%;
    height: auto;
    display: block;
}

.gforce-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    gap: 40px;
}

.gforce-stat .value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.gforce-stat .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.gforce-gallery {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gallery-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    transition: var(--transition-medium);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    font-size: 0.75rem;
}

.gforce-explanation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.explanation-card {
    background: var(--bg-card);
    padding: var(--card-padding);
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.explanation-card .icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.explanation-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.explanation-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.explanation-card code {
    display: block;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-secondary);
}

/* Aerodynamics Section */
.aero-section {
    background: var(--bg-secondary);
}

.aero-dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 60px;
}

.aero-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.aero-card img {
    width: 100%;
    height: auto;
}

.aero-info {
    padding: var(--card-padding);
}

.aero-info h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.aero-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.aero-metrics {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.metric-icon {
    font-size: 1.2rem;
}

.metric-title {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.metric-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
}

.metric-value span {
    font-size: 1rem;
    color: var(--text-muted);
}

.metric-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.metric-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.metric-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--progress);
    background: var(--gradient-primary);
    border-radius: 2px;
}

.subsection-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 32px;
}

.atr-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 40px;
    align-items: center;
}

.atr-visual img {
    width: 100%;
    border-radius: var(--border-radius);
}

.atr-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.atr-table {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.atr-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.atr-row.header {
    background: rgba(225, 6, 0, 0.15);
    font-weight: 600;
    color: var(--accent-primary);
}

.atr-row:last-child {
    border-bottom: none;
}

/* Strategy Section */
.strategy-section {
    background: var(--gradient-dark);
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.strategy-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.strategy-card img {
    width: 100%;
    height: auto;
}

.strategy-info {
    padding: var(--card-padding);
}

.strategy-info h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.strategy-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.compound-legend {
    grid-column: span 2;
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 32px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    margin-top: 16px;
}

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

.compound-ring {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid;
}

.compound.soft .compound-ring {
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.3);
}

.compound.medium .compound-ring {
    border-color: #ffff00;
    background: rgba(255, 255, 0, 0.3);
}

.compound.hard .compound-ring {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.3);
}

.compound-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.compound-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Engines Section */
.engines-section {
    background: var(--bg-secondary);
}

.engine-showcase {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 40px;
}

.spec-block {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 24px;
}

.spec-title {
    padding: 16px 20px;
    background: rgba(225, 6, 0, 0.15);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.spec-details {
    padding: 20px;
}

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.spec-row:last-child {
    border-bottom: none;
}

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

.spec-value {
    font-weight: 600;
}

.spec-value.highlight {
    color: var(--accent-primary);
}

.manufacturers-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mfr-card {
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.mfr-card.ferrari {
    background: linear-gradient(135deg, rgba(220, 0, 0, 0.2), rgba(220, 0, 0, 0.05));
    border: 1px solid rgba(220, 0, 0, 0.3);
}

.mfr-card.mercedes {
    background: linear-gradient(135deg, rgba(0, 210, 190, 0.2), rgba(0, 210, 190, 0.05));
    border: 1px solid rgba(0, 210, 190, 0.3);
}

.mfr-card.honda {
    background: linear-gradient(135deg, rgba(6, 0, 239, 0.2), rgba(6, 0, 239, 0.05));
    border: 1px solid rgba(6, 0, 239, 0.3);
}

.mfr-card.renault {
    background: linear-gradient(135deg, rgba(255, 245, 0, 0.2), rgba(255, 245, 0, 0.05));
    border: 1px solid rgba(255, 245, 0, 0.3);
}

.mfr-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.mfr-engine {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.engine-visuals {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.engine-visuals img {
    width: 100%;
    border-radius: var(--border-radius);
}

/* About Section */
.about-section {
    background: var(--gradient-dark);
}

.about-content {
    max-width: 900px;
    margin: 0 auto;
}

.tech-stack {
    margin-bottom: 48px;
}

.tech-stack h3,
.project-stats h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    margin-bottom: 24px;
    text-align: center;
}

.tech-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.tech-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tech-icon {
    font-size: 1.5rem;
}

.tech-name {
    font-weight: 500;
}

.project-stats {
    margin-bottom: 48px;
}

.stats-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.stats-list li {
    padding: 16px;
    background: var(--bg-card);
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-list li strong {
    color: var(--accent-primary);
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    display: block;
    margin-bottom: 4px;
}

.cta-section {
    text-align: center;
}

.btn-large {
    padding: 18px 40px;
    font-size: 1.1rem;
}

/* Footer */
.footer {
    padding: 60px 5%;
    background: var(--bg-primary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.footer-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 40px;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-bottom p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--accent-primary);
}

.modal-content {
    max-width: 90%;
    max-height: 85%;
    object-fit: contain;
    border-radius: var(--border-radius);
}

.modal-caption {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
}

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

/* Responsive */
@media (max-width: 1024px) {
    .hero {
        flex-direction: column;
        text-align: center;
        gap: 40px;
    }
    
    .hero-content {
        max-width: 100%;
    }
    
    .hero-subtitle {
        margin: 0 auto 40px;
    }
    
    .hero-stats {
        justify-content: center;
    }
    
    .hero-cta {
        justify-content: center;
    }
    
    .analysis-card.featured {
        grid-column: span 1;
    }
    
    .gforce-showcase {
        grid-template-columns: 1fr;
    }
    
    .gforce-gallery {
        flex-direction: row;
    }
    
    .gforce-explanation {
        grid-template-columns: 1fr;
    }
    
    .aero-dashboard {
        grid-template-columns: 1fr;
    }
    
    .atr-grid {
        grid-template-columns: 1fr;
    }
    
    .engine-showcase {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .hero-stats {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .stat-card {
        flex: 1 1 calc(50% - 12px);
    }
    
    .hero-cta {
        flex-direction: column;
    }
    
    .compound-legend {
        flex-direction: column;
        gap: 16px;
    }
    
    .stats-list {
        grid-template-columns: 1fr;
    }
    
    .strategy-grid {
        grid-template-columns: 1fr;
    }
    
    .compound-legend {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    :root {
        --section-padding: 60px 4%;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: 1.8rem;
    }
    
    .speed-indicator {
        width: 200px;
        height: 200px;
    }
    
    .speed-value {
        font-size: 3rem;
    }
}

/* ============================================
   SHARED MEDIA CARD (CFD + SIMULATION)
   ============================================ */

.media-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition-medium);
    display: flex;
    flex-direction: column;
    margin: 0;
}

.media-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(225, 6, 0, 0.3);
}

.media-card img {
    width: 100%;
    height: auto;
    display: block;
    background: var(--bg-tertiary);
    cursor: pointer;
}

.media-card figcaption {
    padding: var(--card-padding);
}

.media-card figcaption h3 {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.media-card figcaption p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   CFD SECTION
   ============================================ */

.cfd-section {
    background: var(--bg-secondary);
}

.cfd-feature {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
    margin-bottom: 60px;
}

.cfd-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.anim-grid,
.cfd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.anim-grid {
    margin-bottom: 60px;
}

.anim-card {
    position: relative;
}

.anim-card::before {
    content: 'ANIMATED';
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 4px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 1px;
    color: var(--text-primary);
    background: rgba(225, 6, 0, 0.85);
    border-radius: 4px;
}

/* ============================================
   RACE SIMULATION SECTION
   ============================================ */

.simulation-section {
    background: var(--gradient-dark);
}

.sim-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
}

.sim-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 28px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sim-tab span {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
}

.sim-tab:hover {
    border-color: rgba(225, 6, 0, 0.4);
    color: var(--text-primary);
}

.sim-tab.active {
    background: rgba(225, 6, 0, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.sim-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.sim-panel[hidden] {
    display: none;
}

.sim-compare {
    margin-top: 24px;
}

/* ============================================
   FIXES & RESPONSIVE POLISH
   ============================================ */

.atr-row {
    gap: 8px;
    font-size: 0.92rem;
}

/* The nav has nine links now - keep it on one line, and collapse it earlier */
.nav-brand,
.nav-links a {
    white-space: nowrap;
}

.nav-links {
    gap: 22px;
}

@media (max-width: 1300px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-toggle {
        display: flex;
    }
}

@media (max-width: 1024px) {
    .cfd-feature {
        grid-template-columns: 1fr;
    }

    .cfd-side {
        flex-direction: row;
    }

    .cfd-side .media-card {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .cfd-side {
        flex-direction: column;
    }

    .sim-panel {
        grid-template-columns: 1fr;
    }

    .calc-presets {
        grid-template-columns: 1fr;
    }

    .atr-row {
        font-size: 0.82rem;
        padding: 12px 10px;
    }

    .gforce-gallery {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .sim-tabs {
        flex-direction: column;
    }

    .sim-tab {
        width: 100%;
    }

    .calc-coeffs {
        grid-template-columns: 1fr;
    }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================
   INTERACTIVE WIND TUNNEL
   ============================================ */

.wt {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.wt-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wt-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 3.4 / 1;
    min-height: 250px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background:
        radial-gradient(120% 160% at 50% 100%, #14141d 0%, #08080c 70%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
}

.wt-canvas {
    position: absolute;
    inset: 0;
    display: block;
}

.wt-field {
    z-index: 1;
}

.wt-flow {
    z-index: 2;
}

.wt-car {
    z-index: 3;
}

.wt-modes {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(8, 8, 12, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}

.wt-mode {
    padding: 6px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.wt-mode:hover {
    color: var(--text-primary);
}

.wt-mode.active {
    background: var(--accent-primary);
    color: #fff;
}

.wt-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: rgba(8, 8, 12, 0.72);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
}

.wt-legend-label {
    font-size: 0.66rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.wt-legend-ramp {
    width: 96px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #00d2be 0%, #ebf5eb 50%, #ff0a0a 100%);
}

.wt-stage[data-mode="pressure"] .wt-legend-ramp {
    background: linear-gradient(90deg, #00eabf 0%, #1e3c5a 50%, #e81628 100%);
}

.wt-stage[data-mode="pressure"] .wt-legend-label:first-child::after {
    content: ' (suction)';
}

.wt-warning {
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    padding: 0 14px;
    font-size: 0.85rem;
    color: var(--accent-yellow);
    background: rgba(255, 242, 0, 0.07);
    border-left: 3px solid var(--accent-yellow);
    border-radius: 4px;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.wt-warning.active {
    max-height: 80px;
    padding: 10px 14px;
    opacity: 1;
}

/* ---- hero readouts ---- */

.wt-hero-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.wt-hero {
    position: relative;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.wt-hero::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: var(--gradient-primary);
}

.wt-hero-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.wt-hero-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.wt-hero-unit {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-left: 4px;
}

.wt-hero-sub {
    display: block;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.wt-hero-sub b {
    color: var(--accent-secondary);
    font-weight: 600;
}

/* ---- control panel ---- */

.wt-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 92px;
}

.wt-block {
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

.wt-block-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.78rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.wt-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 20px;
}

.wt-preset {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 6px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.wt-preset span {
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem;
    font-weight: 400;
    color: var(--text-muted);
}

.wt-preset:hover {
    border-color: rgba(225, 6, 0, 0.45);
    color: var(--text-primary);
}

.wt-preset.active {
    background: rgba(225, 6, 0, 0.16);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.wt-control {
    margin-bottom: 16px;
}

.wt-control label {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.wt-control output {
    margin-left: auto;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
}

.wt-unit {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
}

.wt-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.wt-hint b {
    color: var(--accent-secondary);
}

.wt-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(225, 6, 0, 0.5), rgba(255, 255, 255, 0.09));
    cursor: pointer;
}

.wt-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease;
}

.wt-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.wt-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.wt-slider:focus-visible,
.wt-mode:focus-visible,
.wt-preset:focus-visible,
.wt-drs:focus-visible,
.atr-bar:focus-visible,
.wt-method summary:focus-visible {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 3px;
}

.wt-drs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.wt-drs-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-fast);
}

.wt-drs.active {
    color: #fff;
    background: rgba(0, 210, 190, 0.16);
    border-color: var(--accent-secondary);
}

.wt-drs.active .wt-drs-dot {
    background: var(--accent-secondary);
    box-shadow: 0 0 12px var(--accent-secondary);
}

/* ---- component breakdown ---- */

.wt-comp {
    display: grid;
    grid-template-columns: 80px 1fr 62px;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.78rem;
}

.wt-comp-name {
    color: var(--text-secondary);
}

.wt-comp-bar {
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.wt-comp-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: var(--gradient-secondary);
    transition: width 0.25s ease;
}

.wt-comp-value {
    text-align: right;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.wt-balance {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wt-balance-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.wt-balance-value {
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
}

.wt-balance-track {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.wt-balance-fill {
    height: 100%;
    width: 44%;
    background: var(--gradient-primary);
    transition: width 0.25s ease;
}

.wt-balance-target {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 44%;
    width: 2%;
    background: rgba(255, 255, 255, 0.55);
}

/* ---- coefficients ---- */

.wt-coeffs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.wt-coeff {
    text-align: center;
}

.wt-coeff.wide {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.wt-coeff-key {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.wt-coeff.wide .wt-coeff-key {
    margin-bottom: 0;
}

.wt-coeff-val {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-secondary);
    font-variant-numeric: tabular-nums;
}

.wt-coeff.wide .wt-coeff-val {
    display: inline;
    margin-left: auto;
    color: var(--text-primary);
}

.wt-coeff-unit {
    display: block;
    font-size: 0.62rem;
    color: var(--text-muted);
}

.wt-coeff.wide .wt-coeff-unit {
    display: inline;
    margin-left: 5px;
}

/* ---- methodology ---- */

.wt-method {
    margin-top: 28px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.wt-method summary {
    padding: 16px 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.82rem;
    letter-spacing: 1px;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wt-method summary::-webkit-details-marker {
    display: none;
}

.wt-method summary::before {
    content: '+';
    font-size: 1.1rem;
    color: var(--accent-primary);
}

.wt-method[open] summary::before {
    content: '\2212';
}

.wt-method summary:hover {
    color: var(--text-primary);
}

.wt-method-body {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wt-method-body p {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-secondary);
    max-width: 90ch;
}

.wt-method-body strong {
    color: var(--text-primary);
}

.wt-method-body code {
    padding: 2px 6px;
    font-size: 0.85em;
    color: var(--accent-secondary);
    background: rgba(0, 210, 190, 0.08);
    border-radius: 4px;
}

/* ============================================
   ATR EXPLORER
   ============================================ */

.atr-section {
    margin-top: 80px;
}

.atr-intro {
    max-width: 640px;
    margin: -16px auto 32px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

.atr-explorer {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 32px;
    align-items: stretch;
    margin-bottom: 48px;
}

.atr-chart {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    align-items: end;
    min-height: 220px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

.atr-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

.atr-bar-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    flex: 1;
}

.atr-bar-fill {
    width: 100%;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, rgba(0, 210, 190, 0.55), rgba(0, 210, 190, 0.12));
    border-top: 2px solid var(--accent-secondary);
    transition: var(--transition-fast);
}

.atr-bar:hover .atr-bar-fill,
.atr-bar.active .atr-bar-fill {
    background: linear-gradient(180deg, rgba(225, 6, 0, 0.65), rgba(225, 6, 0, 0.14));
    border-top-color: var(--accent-primary);
}

.atr-bar-pos {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.atr-bar.active .atr-bar-pos {
    color: var(--accent-primary);
}

.atr-detail {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

.atr-detail-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.atr-detail-pos {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.atr-detail-team {
    font-size: 1rem;
    color: var(--text-secondary);
}

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

.atr-k {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.atr-v {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.atr-detail-note {
    font-size: 0.86rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

/* ============================================
   WIND TUNNEL - RESPONSIVE
   ============================================ */

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

    .wt-panel {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        align-items: start;
    }

    .wt-coeffs {
        grid-column: 1 / -1;
    }

    .atr-explorer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .wt-hero-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .wt-stage {
        aspect-ratio: 2.4 / 1;
        min-height: 150px;
    }

    .wt-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .wt-hero-metrics {
        grid-template-columns: 1fr;
    }

    .wt-hero-value {
        font-size: 1.6rem;
    }

    .wt-modes {
        top: 8px;
        right: 8px;
    }

    .wt-mode {
        padding: 5px 8px;
        font-size: 0.6rem;
    }

    .wt-legend {
        display: none;
    }

    .wt-presets {
        grid-template-columns: 1fr;
    }

    .atr-chart {
        gap: 3px;
        padding: 14px 10px;
    }

    .atr-bar-pos {
        font-size: 0.58rem;
    }
}

/* Accessibility: keyboard skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 12px 20px;
    background: var(--accent-primary);
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 0;
}

/* About CTA */
.cta-lead {
    max-width: 560px;
    margin: 0 auto 24px;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.cta-lead strong {
    color: var(--text-primary);
}

.cta-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
}


/* ============================================
   VIDEO FIGURES
   ============================================ */

/* MP4 replaced the GIF renders: 50-60 fps and 1080p at a fraction of the
   bytes. The <img> inside each <video> is the fallback for anything that
   cannot play it, and doubles as the poster. */
.media-video {
    display: block;
    width: 100%;
    height: auto;
    background: var(--bg-tertiary);
}

.media-video img {
    display: block;
    width: 100%;
    height: auto;
}

.media-card.film {
    overflow: hidden;
}

.cfd-films {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 60px;
}

.sim-panel .media-card.film {
    grid-column: 1 / -1;
}

/* Reduced motion is handled in script.js, not here: the fallback <img> lives
   INSIDE the <video>, so hiding the video would hide the fallback with it.
   The script pauses the clips and exposes controls instead. */

.media-video[controls] {
    background: #000;
}


/* ============================================================
   ELEVATION AND FINISH
   ------------------------------------------------------------
   The palette above lifts the page off pure black. This layer does
   the rest of the work: it frames every figure as an inset screen,
   gives cards real elevation, and tightens the typography.
   ============================================================ */

/* ---- page depth -------------------------------------------------------- */

body {
    background:
        radial-gradient(1200px 620px at 50% -8%, rgba(225, 6, 0, 0.055), transparent 70%),
        radial-gradient(900px 500px at 92% 8%, rgba(0, 210, 190, 0.035), transparent 68%),
        var(--bg-primary);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.racing-lines {
    opacity: 0.022;
}

.navbar.scrolled {
    background: rgba(18, 20, 26, 0.88);
    border-bottom-color: var(--line-strong);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.34);
}

/* ---- media wells ------------------------------------------------------- */

/* Figures are rendered on --bg-screen. Giving their container that exact
   colour lets the artwork sit flush in a well, while the lighter card around
   it acts as a bezel. That frame is what the graphs were missing. */
.card-image,
.media-card .media-video,
.media-card > img,
.strategy-card > img,
.engine-visuals img,
.atr-visual img,
.gforce-main img,
.gallery-item img,
.aero-card img {
    background: var(--bg-screen);
}

.media-card > img,
.media-card .media-video,
.strategy-card > img,
.atr-visual img,
.engine-visuals img {
    display: block;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px var(--line);
}

/* Inset the artwork so the card colour reads as a frame around it. */
.media-card.film,
.media-card {
    padding: 10px;
}

.media-card figcaption {
    padding: 12px 14px 16px;
}

.strategy-card > img,
.engine-visuals img {
    margin-bottom: 0;
}

.card-image {
    margin: 10px 10px 0;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px var(--line);
    overflow: hidden;
}

.analysis-card .card-content,
.strategy-info {
    padding: 16px 18px 18px;
}

/* ---- cards ------------------------------------------------------------- */

.analysis-card,
.media-card,
.strategy-card,
.explanation-card,
.spec-block,
.metric-card,
.wt-block,
.atr-detail,
.atr-chart,
.coeff,
.wt-hero,
.mfr-card,
.tech-item {
    background: var(--bg-card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md), var(--edge-light);
}

.analysis-card:hover,
.media-card:hover,
.strategy-card:hover {
    background: var(--bg-raised);
    border-color: rgba(225, 6, 0, 0.42);
    box-shadow: var(--shadow-lg), var(--edge-light);
}

/* ---- typography -------------------------------------------------------- */

.section-title,
.hero-title {
    letter-spacing: -0.015em;
}

.section-number {
    letter-spacing: 3px;
    opacity: 0.9;
}

.section-desc {
    max-width: 62ch;
    line-height: 1.7;
    font-size: 1.05rem;
}

.section-header {
    margin-bottom: 68px;
}

.subsection-title {
    letter-spacing: 0.5px;
    margin-bottom: 28px;
}

/* Numbers should never reflow as they animate or update. */
.stat-value,
.wt-hero-value,
.metric-value,
.atr-v,
.spec-value,
.wt-coeff-val,
.wt-comp-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ---- hero -------------------------------------------------------------- */

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm), var(--edge-light);
    transition: var(--transition-fast);
}

.stat-card:hover {
    border-color: rgba(225, 6, 0, 0.35);
    transform: translateY(-2px);
}

/* ---- controls ---------------------------------------------------------- */

.btn-primary {
    box-shadow: 0 6px 20px rgba(225, 6, 0, 0.30);
}

.btn-primary:hover {
    box-shadow: 0 10px 30px rgba(225, 6, 0, 0.42);
}

.wt-stage {
    background: var(--bg-screen);
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.75), var(--edge-light);
    border-color: var(--line);
}

/* ---- footer ------------------------------------------------------------ */

.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--line);
}

/* ---- scrollbar --------------------------------------------------------- */

* {
    scrollbar-color: #333a47 transparent;
    scrollbar-width: thin;
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: #333a47;
    border: 3px solid var(--bg-primary);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: #454e5f;
}

::selection {
    background: rgba(225, 6, 0, 0.32);
    color: #fff;
}

/* ---- figures must never be cropped ------------------------------------- */

/* These are complete compositions with titles, legends and source lines.
   object-fit: cover centre-cropped them to the card's 16/9 box, which on a
   portrait figure like the Monaco track map showed nothing but empty
   background. Contain shows the whole figure; the well behind it is the
   screen colour, so the letterboxing reads as part of the frame. */
.card-image {
    aspect-ratio: 16 / 10;
    padding: 6px;
}

.card-image img,
.gallery-item img,
.aero-card img {
    object-fit: contain;
    object-position: center;
}

.analysis-card:hover .card-image img {
    transform: none;
}

.gallery-item img {
    height: 130px;
    background: var(--bg-screen);
    border-radius: 6px;
}

/* Small red text on red-tinted chips needs the lighter tint to stay legible. */
.tag,
.hero-badge {
    color: var(--accent-soft);
}

.tag {
    background: rgba(225, 6, 0, 0.13);
    border: 1px solid rgba(225, 6, 0, 0.22);
    font-weight: 500;
    letter-spacing: 0.02em;
}


/* ============================================================
   INTERACTIVES: RUN A LAP · HEAD-TO-HEAD · READ THE TRACE
   Shared vocabulary: a raised card, an inset screen well, an
   Orbitron kicker, tabular numerals for anything that moves.
   ============================================================ */

.ls-kicker,
.quiz-kicker,
.duel-gap-label,
.duel-swings-label,
.ls-lap-unit,
.ls-delta-unit,
.duel-stat-unit {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.ls-title,
.quiz-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    margin: 6px 0 8px;
    letter-spacing: -0.01em;
}

.ls-desc,
.quiz-desc {
    max-width: 62ch;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.65;
}

/* ---- run a lap --------------------------------------------------------- */

.ls {
    margin-top: 32px;
    padding: 26px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md), var(--edge-light);
}

.ls-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 22px;
}

.ls-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.ls-legend-ramp {
    width: 88px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #12124a, #1b4a8f, #00a0c0, #00d2be, #c8f5ee, #fff);
}

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

.ls-card {
    position: relative;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: var(--transition-medium);
}

.ls-card.optimal {
    border-color: rgba(0, 210, 190, 0.45);
    box-shadow: 0 0 0 1px rgba(0, 210, 190, 0.18), 0 12px 32px rgba(0, 210, 190, 0.08);
}

.ls-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ls-circuit {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
}

.ls-badge {
    padding: 3px 9px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 1.5px;
    color: var(--bg-primary);
    background: var(--accent-secondary);
    border-radius: 4px;
}

.ls-well {
    background: var(--bg-screen);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px var(--line), inset 0 0 40px rgba(0, 0, 0, 0.5);
    padding: 6px;
    margin-bottom: 12px;
}

.ls-map {
    display: block;
    width: 100%;
}

.ls-readout {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.ls-lap-value {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.55rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
}

.ls-delta-value {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-soft);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.ls-delta-value.good {
    color: var(--accent-secondary);
}

.ls-lap-unit,
.ls-delta-unit {
    display: block;
    margin-top: 4px;
    font-size: 0.6rem;
    letter-spacing: 1.2px;
}

.ls-sectors {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.ls-sector {
    display: grid;
    grid-template-columns: 22px 1fr 52px;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.ls-sector-bar {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.ls-sector-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent-secondary);
    border-radius: 3px;
    transition: width 0.25s ease;
}

.ls-sector.bad .ls-sector-fill {
    background: var(--accent-primary);
}

.ls-sector-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.ls-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.ls-pole {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.ls-opt {
    padding: 8px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.66rem;
    letter-spacing: 0.8px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.ls-opt:hover {
    border-color: var(--accent-primary);
    background: rgba(225, 6, 0, 0.14);
}

.ls-opt:focus-visible,
.duel-play:focus-visible,
.duel-chip:focus-visible,
.duel-rate button:focus-visible,
.quiz-option:focus-visible,
.quiz-next:focus-visible,
.quiz-restart:focus-visible,
.duel-stage:focus-visible {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 3px;
}

.ls-insight {
    margin: 20px 0 0;
    padding: 14px 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-screen);
    border-left: 3px solid var(--accent-primary);
    border-radius: 6px;
    min-height: 1.6em;
}

.ls-insight b {
    color: var(--text-primary);
    font-weight: 600;
}

/* slider flash when a setup is applied from outside */
@keyframes wtFlash {
    0% { box-shadow: 0 0 0 0 rgba(0, 210, 190, 0.55); }
    100% { box-shadow: 0 0 0 10px rgba(0, 210, 190, 0); }
}

.wt-slider.wt-flash {
    animation: wtFlash 0.7s ease-out;
    border-radius: 4px;
}

/* ---- head-to-head player ---------------------------------------------- */

.duel {
    display: grid;
    gap: 14px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md), var(--edge-light);
}

.duel-stage {
    position: relative;
    background: var(--bg-screen);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line), inset 0 0 80px rgba(0, 0, 0, 0.6);
    padding: 8px;
    cursor: pointer;
}

.duel-map,
.duel-traces {
    display: block;
    width: 100%;
}

.duel-gap {
    position: absolute;
    top: 16px;
    right: 18px;
    text-align: right;
    pointer-events: none;
}

.duel-gap-value {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-top: 2px;
}

.duel-gap-who {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.duel-hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    padding: 6px 12px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    background: rgba(18, 20, 26, 0.85);
    border: 1px solid var(--line);
    border-radius: 20px;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.duel-hint.gone {
    opacity: 0;
}

.duel-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.duel-tile {
    position: relative;
    padding: 12px 14px 12px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.duel-tile::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--drv);
}

.duel-tile-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.duel-abbr {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
}

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

.duel-time {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.duel-tile-body {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 14px;
}

.duel-stat-value {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.duel-stat-unit {
    display: block;
    margin-top: 3px;
    font-size: 0.56rem;
}

.duel-pedals {
    display: flex;
    align-items: center;
    gap: 8px;
}

.duel-thr {
    flex: 1;
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.duel-thr-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent-secondary);
    border-radius: 4px;
    transition: width 0.08s linear;
}

.duel-brk {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line-strong);
    transition: var(--transition-fast);
}

.duel-brk.on {
    background: var(--accent-primary);
    box-shadow: 0 0 10px rgba(225, 6, 0, 0.8);
    border-color: var(--accent-primary);
}

.duel-traces {
    background: var(--bg-screen);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line);
}

.duel-controls {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 14px;
}

.duel-play {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: var(--bg-tertiary);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition-fast);
}

.duel-play:hover {
    border-color: var(--accent-primary);
    background: rgba(225, 6, 0, 0.16);
}

.duel-play-icon {
    width: 0;
    height: 0;
    border-left: 12px solid var(--text-primary);
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    margin-left: 3px;
}

.duel-play.playing .duel-play-icon {
    width: 12px;
    height: 14px;
    margin-left: 0;
    border: 0;
    background: linear-gradient(90deg, var(--text-primary) 0 35%, transparent 35% 65%, var(--text-primary) 65%);
}

.duel-scrub {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(0, 210, 190, 0.6), rgba(255, 255, 255, 0.10));
    cursor: pointer;
}

.duel-scrub::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.duel-scrub::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-secondary);
}

.duel-clock {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    white-space: nowrap;
}

.duel-clock-sep {
    margin: 0 6px;
    color: var(--text-muted);
}

.duel-rate {
    display: flex;
    gap: 3px;
    padding: 3px;
    background: var(--bg-tertiary);
    border: 1px solid var(--line);
    border-radius: 7px;
}

.duel-rate button {
    padding: 5px 9px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.66rem;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
}

.duel-rate button.active {
    background: var(--accent-primary);
    color: #fff;
}

.duel-swings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.duel-swings-label {
    margin-right: 6px;
}

.duel-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--line);
    border-left: 3px solid var(--drv);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.duel-chip:hover {
    background: var(--bg-tertiary);
    border-color: var(--line-strong);
    border-left-color: var(--drv);
    color: var(--text-primary);
}

.duel-chip-ms {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.62rem;
    color: var(--text-muted);
}

.duel-chip-who {
    font-weight: 700;
    color: var(--text-primary);
}

.duel-chip-val {
    font-variant-numeric: tabular-nums;
    color: var(--drv);
}

/* ---- read the trace ---------------------------------------------------- */

.quiz {
    margin-top: 56px;
    padding: 26px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md), var(--edge-light);
}

.quiz-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 20px;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quiz-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid var(--line-strong);
}

.quiz-dot.now {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.quiz-dot.right {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.quiz-dot.wrong {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.quiz-count {
    margin-left: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.quiz-body {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
    gap: 18px;
    align-items: start;
}

.quiz-stage {
    position: relative;
    background: var(--bg-screen);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line), inset 0 0 60px rgba(0, 0, 0, 0.5);
    padding: 10px;
}

.quiz-canvas {
    display: block;
    width: 100%;
}

.quiz-legend {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.quiz-legend-item i {
    display: inline-block;
    width: 14px;
    height: 3px;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 2px;
}

.quiz-panel {
    display: grid;
    gap: 12px;
    padding: 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--line);
    border-radius: 10px;
    min-height: 100%;
}

.quiz-prompt {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.45;
}

.quiz-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    min-height: 1em;
}

.quiz-options {
    display: grid;
    gap: 8px;
}

.quiz-option {
    padding: 11px 14px;
    text-align: left;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.quiz-option:hover:not(:disabled) {
    border-color: var(--accent-secondary);
    background: rgba(0, 210, 190, 0.10);
}

.quiz-option:disabled {
    cursor: default;
    opacity: 0.75;
}

.quiz-option.right {
    border-color: var(--accent-secondary);
    background: rgba(0, 210, 190, 0.16);
    opacity: 1;
}

.quiz-option.wrong {
    border-color: var(--accent-primary);
    background: rgba(225, 6, 0, 0.14);
    opacity: 1;
}

.quiz-verdict {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.quiz-verdict.right {
    color: var(--accent-secondary);
}

.quiz-verdict.wrong {
    color: var(--accent-soft);
}

.quiz-explain {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.quiz-explain b {
    color: var(--text-primary);
}

.quiz-next,
.quiz-restart {
    justify-self: start;
    padding: 10px 16px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: #fff;
    background: var(--accent-primary);
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(225, 6, 0, 0.28);
    transition: var(--transition-fast);
}

.quiz-next:hover,
.quiz-restart:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(225, 6, 0, 0.38);
}

.quiz-summary {
    display: grid;
    gap: 6px;
}

.quiz-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.quiz-tier {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-secondary);
}

.quiz-summary-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ---- responsive -------------------------------------------------------- */

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

    .ls-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 18px;
        align-items: center;
    }

    .ls-card-head,
    .ls-foot {
        grid-column: 1 / -1;
    }

    .ls-well {
        grid-row: 2 / span 2;
        margin-bottom: 0;
    }
}

@media (max-width: 820px) {
    .ls-head,
    .quiz-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .ls-card {
        grid-template-columns: 1fr;
    }

    .ls-well {
        grid-row: auto;
        margin-bottom: 12px;
    }

    .quiz-body {
        grid-template-columns: 1fr;
    }

    .duel-tiles {
        grid-template-columns: 1fr;
    }

    .duel-controls {
        grid-template-columns: auto 1fr;
    }

    .duel-clock,
    .duel-rate {
        grid-column: 2;
        justify-self: end;
    }

    .duel-gap-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 520px) {
    .ls,
    .quiz,
    .duel {
        padding: 14px;
    }

    .ls-foot {
        flex-direction: column;
        align-items: stretch;
    }

    .ls-opt {
        text-align: center;
    }

    .duel-hint {
        display: none;
    }
}

/* The hidden attribute has to beat display rules like .quiz-summary { display: grid }.
   Without this the quiz summary stayed on screen under the next question. */
[hidden] {
    display: none !important;
}

/* ---- Read the race: v2 additions ---------------------------------------- */

.quiz-stage-col {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.quiz-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.quiz-badge {
    --cat: var(--accent-secondary);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--cat);
    background: color-mix(in srgb, var(--cat) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--cat) 40%, transparent);
    border-radius: 999px;
}

.quiz-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cat);
    box-shadow: 0 0 8px var(--cat);
}

.quiz-level {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.quiz-level-name {
    margin-right: 4px;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 1.4px;
}

.quiz-level i {
    display: inline-block;
    width: 12px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.12);
}

.quiz-level i.on {
    background: var(--accent-primary);
    box-shadow: 0 0 6px rgba(225, 6, 0, 0.6);
}

.quiz-pts {
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
}

.quiz-dot {
    --dot: var(--text-primary);
}

.quiz-dot.now {
    background: var(--dot);
    border-color: var(--dot);
    box-shadow: 0 0 8px var(--dot);
}

.quiz-verdict {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.quiz-verdict-pts {
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.quiz-evidence {
    padding: 12px 14px 14px;
    background: var(--bg-screen);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line), inset 0 0 60px rgba(0, 0, 0, 0.5);
    border-left: 3px solid var(--accent-primary);
}

/* Animate in from transparent; the resting state is fully visible, so the
   panel still shows when animations never run (reduced motion, embedded renderers). */
.quiz-evidence.in {
    animation: quizEvidenceIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes quizEvidenceIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.quiz-evidence-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.quiz-evidence-kicker {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-primary);
}

.quiz-evidence-cat {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.4px;
}

.quiz-evidence-canvas {
    display: block;
    width: 100%;
}

.quiz-evidence-cap {
    margin-top: 10px;
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.quiz-explain i {
    color: var(--text-primary);
    font-style: italic;
}

.quiz-takeaways {
    display: grid;
    gap: 8px;
}

.quiz-takeaway {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.quiz-takeaway span {
    display: block;
    margin-bottom: 4px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.56rem;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--accent-secondary);
}

.quiz-takeaway p {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.quiz-takeaway i {
    color: var(--text-primary);
}

.quiz-link {
    justify-self: start;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition-fast);
}

.quiz-link:hover {
    border-bottom-color: var(--accent-secondary);
}

.quiz-summary-top {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.quiz-breakdown {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
}

.quiz-bd-row {
    display: grid;
    grid-template-columns: 110px 1fr 44px;
    align-items: center;
    gap: 10px;
    font-size: 0.74rem;
}

.quiz-bd-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.58rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.quiz-bd-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.quiz-bd-bar i {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.quiz-bd-val {
    text-align: right;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 520px) {
    .quiz-bd-row {
        grid-template-columns: 90px 1fr 40px;
    }

    .quiz-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}
