* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Barlow Condensed', sans-serif;
    color: #fff;
    width: 100vw;
    height: 100vh;
}

#scene-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

#hud-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
    display: none;
}

.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    display: none;
    pointer-events: auto;
}
.screen.active { display: flex; }

/* ===== Geometric Background ===== */
.geo-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: 
        linear-gradient(135deg, rgba(30,30,30,0.95) 25%, transparent 25%) -50px 0,
        linear-gradient(225deg, rgba(30,30,30,0.95) 25%, transparent 25%) -50px 0,
        linear-gradient(315deg, rgba(35,35,35,0.9) 25%, transparent 25%),
        linear-gradient(45deg, rgba(25,25,25,0.95) 25%, transparent 25%);
    background-size: 100px 100px;
    background-color: #1a1a1a;
}

/* ===== Title Screen ===== */
#title-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.title-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.title-logo {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(3rem, 10vw, 7rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fff 40%, #FFD700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 4px 20px rgba(255,215,0,0.3));
    margin-bottom: 0.2em;
}

.title-sub {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #ccc;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 3em;
}

.title-prompt, .results-prompt {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    letter-spacing: 0.2em;
    color: #FFD700;
}

.title-prompt-mobile, .results-prompt-mobile {
    display: none;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    letter-spacing: 0.2em;
    color: #FFD700;
    margin-top: 0.5em;
}

.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== Car Select ===== */
#car-select-screen {
    z-index: 50;
    flex-direction: column;
    background: transparent;
}

.car-info {
    position: absolute;
    top: 8%;
    left: 5%;
    z-index: 5;
}

.car-maker {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: #aaa;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.car-name {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4rem);
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 0.3em;
}

.car-enter {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    color: #ddd;
}

.enter-badge {
    background: #FFD700;
    color: #000;
    padding: 2px 10px;
    font-weight: 700;
    border-radius: 3px;
    margin-right: 6px;
    font-size: 0.9rem;
}

.car-stats {
    margin-top: 1.5em;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    color: #ccc;
}

.car-stats .stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
}

.stat-bar-bg {
    width: 120px;
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: #FFD700;
    transition: width 0.4s ease;
}

.car-nav {
    position: absolute;
    bottom: 12%;
    right: 5%;
    text-align: right;
    z-index: 5;
}

.car-counter {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.nav-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 8px 18px;
    font-size: 1rem;
    cursor: pointer;
    margin: 0 2px;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.3);
}

.car-dialogue {
    position: absolute;
    bottom: 3%;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    color: #ddd;
    z-index: 5;
}

.dialogue-name {
    color: #FFD700;
    font-weight: 700;
    margin-right: 6px;
}

/* ===== Race HUD ===== */
#race-hud {
    z-index: 20;
    pointer-events: none;
    flex-direction: column;
}

.hud-top-left {
    position: absolute;
    top: 3%;
    left: 3%;
}

.hud-progress {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.hud-progress span {
    font-size: clamp(2rem, 5vw, 3.5rem);
}

.hud-time {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: #ccc;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.hud-time span {
    color: #fff;
    font-weight: 600;
    margin-left: 2em;
}

.hud-objective {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #FFD700;
    margin-top: 0.5em;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.hud-position {
    position: absolute;
    top: 3%;
    right: 3%;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #FFD700;
    text-shadow: 0 2px 15px rgba(0,0,0,0.9);
}

.hud-bottom-right {
    position: absolute;
    bottom: 3%;
    right: 3%;
    text-align: center;
}

#speedo-canvas {
    width: clamp(100px, 15vw, 180px);
    height: clamp(100px, 15vw, 180px);
}

.hud-speed {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 3.5rem);
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    line-height: 1;
    margin-top: -10px;
}

.hud-speed small {
    font-size: 0.4em;
    font-weight: 600;
    color: #ccc;
}

.hud-gear {
    position: absolute;
    bottom: clamp(80px, 12vw, 150px);
    right: clamp(38px, 6vw, 72px);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #fff;
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
    width: clamp(30px, 4vw, 44px);
    height: clamp(30px, 4vw, 44px);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-minimap {
    position: absolute;
    bottom: 3%;
    left: 3%;
}

#minimap-canvas {
    width: clamp(80px, 12vw, 140px);
    height: clamp(80px, 12vw, 140px);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.6);
}

/* Touch controls */
#touch-controls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    pointer-events: auto;
}

.touch-left {
    position: absolute;
    left: 2%;
    bottom: 25%;
    display: flex;
    gap: 10px;
}

.touch-right {
    position: absolute;
    right: 2%;
    bottom: 15%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.touch-gas {
    background: rgba(0,200,0,0.2);
    border-color: rgba(0,200,0,0.5);
}

.touch-brake {
    background: rgba(200,0,0,0.2);
    border-color: rgba(200,0,0,0.5);
}

/* ===== Results ===== */
#results-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.results-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.results-race-name {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: #ccc;
    letter-spacing: 0.1em;
}

.results-hr {
    width: 300px;
    max-width: 80vw;
    height: 1px;
    background: rgba(255,255,255,0.3);
    margin: 0.8em auto;
}

.results-place {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(3rem, 10vw, 6rem);
    line-height: 1.1;
}

.results-place span {
    color: #FFD700;
}

.results-place sup {
    font-size: 0.4em;
    color: #FFD700;
    vertical-align: super;
}

.results-time {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #FFD700;
    margin: 0.3em 0 0.5em;
}

.results-best {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 2em;
}

#confetti-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* ===== Cinematic Overlay ===== */
#cinematic-overlay {
    z-index: 80;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    background: transparent;
}

.cinematic-letterbox {
    position: absolute;
    left: 0;
    width: 100%;
    height: 10%;
    background: #000;
    z-index: 2;
}

.cinematic-letterbox.top { top: 0; }
.cinematic-letterbox.bottom { bottom: 0; }

.cinematic-text-container {
    position: absolute;
    bottom: 16%;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 3;
    transition: opacity 0.5s ease;
}

.cinematic-main-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 4px 30px rgba(0,0,0,0.9), 0 0 60px rgba(255,215,0,0.3);
    animation: cinematicTextPulse 2s ease-in-out infinite;
}

.cinematic-sub-text {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(0.9rem, 2.5vw, 1.4rem);
    color: #FFD700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 0.3em;
    text-shadow: 0 2px 15px rgba(0,0,0,0.8);
}

@keyframes cinematicTextPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.cinematic-skip {
    position: absolute;
    bottom: 3%;
    right: 3%;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.15em;
    z-index: 3;
}

.cinematic-skip-mobile {
    display: none;
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.15em;
    z-index: 3;
}

.cinematic-mission-badge {
    position: absolute;
    top: 14%;
    left: 5%;
    z-index: 3;
    border-left: 3px solid #FFD700;
    padding-left: 12px;
}

.mission-label {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #FFD700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.mission-name {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #fff;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

@media (hover: none) and (pointer: coarse) {
    .cinematic-skip { display: none; }
    .cinematic-skip-mobile { display: block; }
}

#footer-link {
    position: fixed;
    bottom: 6px;
    right: 10px;
    z-index: 200;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.7rem;
}

#footer-link a {
    color: rgba(255,255,255,0.3);
    text-decoration: none;
}

#footer-link a:hover {
    color: rgba(255,255,255,0.6);
}

/* Mobile detection */
@media (hover: none) and (pointer: coarse) {
    #touch-controls { display: block; }
    .title-prompt { display: none; }
    .title-prompt-mobile { display: block; }
    .results-prompt { display: none; }
    .results-prompt-mobile { display: block; }
}

@media (max-width: 600px) {
    .hud-minimap { display: none; }
    .car-stats { display: none; }
}