:root {
    --primary: #ff6b6b; /* The "Hero" Coral Color */
    --bg-glass: rgba(15, 23, 42, 0.85);
    --border-glass: rgba(255, 255, 255, 0.1);
}

body { margin: 0; overflow: hidden; font-family: 'Segoe UI', sans-serif; background: #000; user-select: none; }

/* --- LOADER --- */
#loader-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.8s ease;
}
.spinner-box { display: flex; flex-direction: column; align-items: center; }
.neon-circle {
    width: 60px; height: 60px;
    border: 3px solid transparent;
    border-top: 3px solid var(--primary);
    border-right: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--primary);
}
.loader-text { margin-top: 20px; color: #fff; letter-spacing: 3px; font-size: 12px; }
.loader-subtext { color: #64748b; font-size: 10px; margin-top: 5px; }

/* --- START SCREEN --- */
#start-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 8888;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: white; transition: opacity 0.5s;
}
#start-screen h1 { font-size: 2.5rem; letter-spacing: 2px; margin-bottom: 10px; text-shadow: 0 0 20px var(--primary); text-align: center;}
#start-screen p { color: #ccc; margin-bottom: 30px; font-size: 1rem; }
#start-btn {
    padding: 12px 40px; font-size: 1rem; font-weight: bold; letter-spacing: 1px;
    color: white; background: var(--primary); border: none; border-radius: 30px;
    cursor: pointer; box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
    transition: transform 0.2s;
}
#start-btn:hover { transform: scale(1.05); }

/* --- GAME UI --- */
#ui-layer { pointer-events: none; width: 100%; height: 100%; position: fixed; top: 0; left: 0; }

#instructions {
    position: absolute; bottom: 30px; width: 100%; text-align: center;
    color: rgba(255,255,255,0.5); font-size: 12px; letter-spacing: 1px;
}

/* POPUP CARD (Glassmorphism) */
#screen-overlay {
    position: absolute; top: 50%; left: 50%; 
    transform: translate(-50%, -50%) scale(0.9);
    width: 600px; max-width: 85%; max-height: 80vh; overflow-y: auto;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 40px;
    color: white;
    opacity: 0; pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

#screen-overlay.visible {
    opacity: 1; pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

#overlay-title { margin-top: 0; color: var(--primary); font-size: 1.8rem; border-bottom: 1px solid #333; padding-bottom: 15px; }
#overlay-text { line-height: 1.6; color: #cbd5e1; }

/* --- PROJECT GRID --- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 20px; }
.project-card {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    padding: 15px; border-radius: 8px; cursor: pointer; transition: 0.2s;
}
.project-card:hover { border-color: var(--primary); background: rgba(255,255,255,0.1); transform: translateY(-3px); }
.card-title { font-weight: bold; color: #fff; margin-bottom: 5px; }
.card-desc { font-size: 0.8rem; color: #94a3b8; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: rgba(255, 107, 107, 0.15); color: var(--primary); margin-top: 8px; display: inline-block;}


@keyframes spin { 100% { transform: rotate(360deg); } }
.hidden { display: none !important; }
.fade-out { opacity: 0; pointer-events: none; }


/* --- HOLOGRAPHIC START SCREEN --- */
.hud-container {
    display: flex; flex-direction: column; align-items: center; gap: 40px;
    transform: scale(1.2); /* Make it feel grand */
}

/* 1. THE ENGINE BUTTON */
.engine-button {
    position: relative; width: 160px; height: 160px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.engine-button:hover {
    transform: scale(1.1); /* Pop effect on hover */
}

/* Inner Text */
.label-main {
    color: #fff; font-size: 1.8rem; font-weight: 800; letter-spacing: 2px;
    text-shadow: 0 0 10px var(--primary); z-index: 2;
}
.label-sub {
    color: var(--primary); font-size: 0.7rem; font-weight: 600; letter-spacing: 4px;
    margin-top: -5px; z-index: 2;
}

/* 2. RINGS & ANIMATION */
.ring-dashed {
    position: absolute; width: 100%; height: 100%;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: rotate-slow 10s linear infinite;
}

.ring-solid {
    position: absolute; width: 85%; height: 85%;
    border: 2px solid var(--primary); /* Coral Border */
    border-radius: 50%;
    border-top-color: transparent; /* Open ring effect */
    border-left-color: transparent;
    animation: rotate-fast 2s linear infinite reverse;
    box-shadow: 0 0 15px var(--primary);
}

.glow-core {
    position: absolute; width: 60%; height: 60%;
    background: radial-gradient(circle, rgba(255, 107, 107, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse-core 2s ease-in-out infinite;
}

/* 3. THE PROMPT TEXT */
.prompt-text {
    color: #94a3b8; font-size: 0.9rem; letter-spacing: 3px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    opacity: 0.8;
}

.prompt-text .key {
    border: 1px solid #fff; padding: 2px 8px; border-radius: 4px;
    color: #fff; font-size: 0.8rem;
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* 4. ANIMATIONS */
@keyframes rotate-slow { 100% { transform: rotate(360deg); } }
@keyframes rotate-fast { 100% { transform: rotate(360deg); } }

@keyframes pulse-core {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.8; box-shadow: 0 0 30px var(--primary); }
}

/* Mobile Adjustment */
@media (max-width: 768px) {
    .hud-container { transform: scale(1); }
    .prompt-text { display: none; } /* Mobile users just tap the button */
}


/* --- 3D ENERGY SIGN PROMPT --- */
.prompt-text {
    color: #94a3b8; font-size: 0.9rem; letter-spacing: 3px; font-weight: 600;
    display: flex; align-items: center; gap: 20px; /* More space for the glow */
    margin-top: 40px;
}

/* The container holding the floating sign */
.energy-sign-container {
    position: relative;
    /* Combine floating up/down with a subtle 3D rotation */
    animation: float-and-turn 4s ease-in-out infinite;
    transform-style: preserve-3d;
    perspective: 100px;
}

/* The Symbol itself */
.energy-symbol {
    font-size: 3rem; /* Nice and big */
    font-weight: 900;
    
    /* THE 3D ENERGY TRICK: */
    color: transparent; /* Hide the flat text fill */
    /* Layer shadows to create volume and glow */
    text-shadow: 
        0 0 2px rgba(255, 255, 255, 0.8),    /* 1. Hot white core */
        3px 3px 0px var(--primary),          /* 2. Solid 3D "edge" (Coral color) */
        0 0 20px var(--primary),             /* 3. Inner glow aura */
        0 0 50px rgba(255, 107, 107, 0.6);   /* 4. Wide ambient light */
    
    display: inline-block;
    animation: pulse-energy 2s ease-in-out infinite alternate;
}

/* --- ANIMATIONS --- */

/* Rotates slightly while floating up and down */
@keyframes float-and-turn {
    0%, 100% { 
        transform: translateY(0) rotateY(-10deg); 
    }
    50% { 
        transform: translateY(-15px) rotateY(10deg); 
    }
}

/* Makes the glow breathe louder and softer */
@keyframes pulse-energy {
    0% {
        text-shadow: 
            0 0 2px rgba(255, 255, 255, 0.8),
            3px 3px 0px var(--primary),
            0 0 20px var(--primary),
            0 0 50px rgba(255, 107, 107, 0.6);
        transform: scale(1);
    }
    100% {
        text-shadow: 
            0 0 5px rgba(255, 255, 255, 1),
            3px 3px 0px var(--primary),
            0 0 40px var(--primary), /* Wider glow */
            0 0 80px rgba(255, 107, 107, 0.8); /* Intense aura */
        transform: scale(1.1); /* Slight expansion */
    }
}

/* Mobile adjustment */
@media (max-width: 768px) {
    .prompt-text { display: none; }
}

/* --- VOLUMETRIC 3D ICON --- */
.prompt-text {
    color: #94a3b8; font-size: 0.9rem; letter-spacing: 3px; font-weight: 600;
    display: flex; align-items: center; gap: 30px; /* Space for rotation */
    margin-top: 40px;
    perspective: 500px; /* Camera distance */
}

.volumetric-icon {
    position: relative;
    width: 50px; height: 50px;
    transform-style: preserve-3d;
    /* The 3D Rotation Animation */
    animation: wobble-3d 3s ease-in-out infinite; 
}

.layer {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    font-size: 3rem; font-weight: 900;
    line-height: 1;
    
    /* Calculate depth position based on index */
    transform: translateZ(calc(var(--i) * -2px));
}

/* The Front Face (Bright & Glowing) */
.layer:nth-child(1) {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px var(--primary);
    z-index: 10;
}

/* The Side/Back Layers (Darker creates depth) */
.layer:not(:nth-child(1)) {
    color: var(--primary); /* The coral color */
    filter: brightness(0.7); /* Darker to simulate shadow */
    opacity: 0.9; /* Slight transparency for glass feel */
}

/* The very last layer (Backplate) */
.layer:last-child {
    filter: brightness(0.4);
    text-shadow: 0 10px 20px rgba(0,0,0,0.5); /* Drop shadow on floor */
}

/* --- ANIMATION --- */
@keyframes wobble-3d {
    0%, 100% {
        transform: rotateY(-25deg) rotateX(10deg) translateY(0);
    }
    50% {
        transform: rotateY(25deg) rotateX(-10deg) translateY(-10px);
    }
}

/* Mobile adjustment */
@media (max-width: 768px) {
    .prompt-text { display: none; }
}

/* --- SPEEDOMETER HUD --- */
#speed-hud {
    position: absolute;
    bottom: 40px;
    right: 40px;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', sans-serif;
    pointer-events: none; /* Let clicks pass through */
}

/* The Glowing Circle */
.speed-ring {
    position: absolute;
    width: 100%; height: 100%;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary); /* Coral color */
    border-radius: 50%;
    transform: rotate(-45deg);
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.speed-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

#speed-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px var(--primary);
    line-height: 1;
}

.speed-unit {
    font-size: 0.7rem;
    color: #94a3b8;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Mobile Adjustment */
@media (max-width: 768px) {
    #speed-hud { bottom: 180px; right: 20px; transform: scale(0.8); }
}

/* --- CONTAINER --- */
#mobile-controls {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through empty areas */
    z-index: 9999;
}


/* --- CONTAINER --- */
#mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
}

/* Show on Mobile */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls { display: block; }
}

/* --- STEERING WHEEL ZONE --- */
.wheel-zone {
    position: absolute;
    bottom: 40px; /* Moved up slightly to avoid edge clicks */
    left: 30px;
    width: 160px;
    height: 160px;
    pointer-events: auto; /* Important for touch */
    display: flex;
    justify-content: center;
    align-items: center;
}



/* --- THE WHEEL --- */
#steering-wheel {
    width: 100%;
    height: 100%;
    transform-origin: center center;
    border: none;
    box-shadow: none;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.8)); /* Heavy shadow for 3D float */
}

/* 1. THE RIM (Thick Black Grip) */
.wheel-rim {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 18px solid #222; /* Dark Rubber/Leather Color */
    box-sizing: border-box;
    /* 3D Tube Effect */
    box-shadow: 
        inset 5px 5px 10px rgba(255,255,255,0.1), /* Top-left reflection */
        inset -5px -5px 10px rgba(0,0,0,0.8);    /* Bottom-right shadow */
}

/* 2. THE SPOKES (T-Shape Metal) */
.wheel-spoke {
    position: absolute;
    background: linear-gradient(to bottom, #555, #333); /* Gunmetal Grey */
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.left-spoke {
    top: 50%; left: 0;
    width: 50%; height: 12px;
    transform: translateY(-50%);
}

.right-spoke {
    top: 50%; right: 0;
    width: 50%; height: 12px;
    transform: translateY(-50%);
}

.bottom-spoke {
    bottom: 0; left: 50%;
    width: 12px; height: 50%;
    transform: translateX(-50%);
}

/* 3. THE CENTER CAP (Horn Button) */
.wheel-cap {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #444, #111);
    border: 2px solid #666;
    z-index: 2;
    /* Simulates a bolt/logo in the center */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fake Logo dot */
.wheel-cap::after {
    content: '';
    width: 8px; height: 8px;
    background: #ffcc00; /* Gold Logo */
    border-radius: 50%;
    box-shadow: 0 0 5px #ffcc00;
}

/* 4. THE RED MARKER (Top Center) */
.wheel-marker {
    position: absolute;
    top: -5px; left: 50%;
    transform: translateX(-50%);
    width: 10px; height: 25px;
    background: #ff0000;
    z-index: 3;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(255,0,0,0.5);
}

/* --- PEDALS (Right Side) --- */
.pedal-zone {
    position: absolute;
    bottom: 40px;
    right: 30px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    pointer-events: auto;
}

.pedal-row {
    display: flex;
    gap: 20px;
    align-items: center;
}

.pedal {
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: bold;
    font-family: sans-serif;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    text-shadow: 0 1px 2px black;
    box-shadow: 0 4px 0 rgba(0,0,0,0.5); /* 3D Button Depth */
    transition: all 0.1s;
}

.pedal:active {
    transform: translateY(4px); /* Press down effect */
    box-shadow: 0 0 0 rgba(0,0,0,0.5);
}

/* Gas: Tall Vertical Pedal */
.gas {
    width: 60px; height: 110px;
    background: linear-gradient(to bottom, #2ecc71, #27ae60);
    border-radius: 10px 10px 4px 4px;
}

/* Brake: Wide Horizontal Pedal */
.brake {
    width: 80px; height: 50px;
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
}

/* Reverse: Small Square */
.rev {
    width: 50px; height: 50px;
    background: linear-gradient(to bottom, #95a5a6, #7f8c8d);
    font-size: 0.7rem;
}

/* --- MOBILE HUD FIX --- */
@media (max-width: 900px) {
    
    /* Force Speedometer to Top-Right & Bring to Front */
    #speedometer, .speedometer, .speed-box, #speed-hud {
        /* Position: Top Right (Safe Zone) */
        top: 20px !important;
        right: 20px !important;
        
        /* Reset any Bottom/Left positioning */
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        
        /* Layer: Higher than mobile controls (10000) */
        z-index: 20000 !important; 
        
        /* Optional: Make it smaller on mobile if needed */
        transform: scale(0.8) !important;
        transform-origin: top right !important;
    }

    /* Move the "Reset Zone" prompt up too, so it's not hidden by the wheel */
    #reset-zone-ui {
        bottom: 50% !important;
        z-index: 20000 !important;
    }
}


iframe {
    pointer-events: auto !important;
}

body > div:first-child { 
    z-index: 0 !important;
}
canvas {
    z-index: 1 !important;
}

.css3d-container {
    z-index: 0 !important;
}

#ui-layer, #screen-overlay, #mobile-controls, #speed-hud, #reset-zone-ui {
    z-index: 10000 !important; 
}
