:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.8);
    --primary: #f97316; /* Orange */
    --primary-glow: rgba(249, 115, 22, 0.5);
    --secondary: #3b82f6; /* Blue */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --yellow: #fbbf24;
    --cyan: #22d3ee;
    --purple: #c084fc;
    --red: #ef4444;
    --green: #22c55e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: #1e1e24; /* fallback */
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.text-yellow { color: var(--yellow); }
.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-orange { color: var(--primary); }
.text-red { color: var(--red); }
.text-gold { color: #ffd700; }
.text-white { color: #fff; }

/* Screens */
.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    z-index: 10;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

.screen.active {
    display: flex;
}

#screen-game {
    background: #000;
}

/* Header & Stats */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header h2 {
    font-family: 'Audiowide', cursive;
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.stats-bar {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    font-size: 1.1rem;
    background: rgba(0,0,0,0.4);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Titles */
.title-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-title {
    font-family: 'Audiowide', cursive;
    font-size: 4rem;
    text-align: center;
    line-height: 1;
    text-shadow: 0 0 10px rgba(255,255,255,0.3), 0 0 20px var(--primary-glow);
    animation: float 3s ease-in-out infinite;
}

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

/* Buttons */
.btn {
    font-family: 'Audiowide', cursive;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    text-transform: uppercase;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary), #ea580c);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-secondary {
    background: linear-gradient(45deg, #475569, #334155);
    border: 1px solid rgba(255,255,255,0.1);
}

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
}

.btn-sm {
    padding: 5px 10px;
    border: none; border-radius: 4px;
    font-weight: 700; color: white; cursor: pointer;
}

.btn-upgrade { background: var(--green); }
.btn-buy { background: var(--yellow); color: #000; font-weight: bold; }
.btn-select { background: var(--secondary); }

.pulse {
    animation: pulseBtn 2s infinite;
}
@keyframes pulseBtn {
    0% { box-shadow: 0 0 0 0 var(--primary-glow); }
    70% { box-shadow: 0 0 0 15px rgba(249,115,22,0); }
    100% { box-shadow: 0 0 0 0 rgba(249,115,22,0); }
}

.main-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 30px;
    margin-bottom: 20px;
}

/* Garage */
.car-showcase {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}
.car-name {
    font-family: 'Audiowide', cursive;
    font-size: 1.5rem;
    margin-top: 10px;
    color: var(--cyan);
    text-transform: uppercase;
}
.garage-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}
.upgrades-panel {
    background: var(--bg-panel);
    padding: 20px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}
.upgrades-panel h3 { margin-bottom: 15px; font-family: 'Audiowide', cursive; text-align: center; }
.upgrade-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 600;
}
.upgrade-row span { width: 80px; }
.upgrade-bars {
    flex: 1;
    display: flex;
    gap: 4px;
}
.upg-bar {
    height: 15px; flex: 1;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}
.upg-bar.filled { background: var(--cyan); box-shadow: 0 0 5px var(--cyan); }
.upg-bar.max { background: var(--primary); box-shadow: 0 0 5px var(--primary); }

/* Stats Screen */
.stats-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}
.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: var(--bg-panel);
    border-radius: 8px;
    font-size: 1.1rem;
    border-left: 4px solid var(--primary);
}

/* Gameplay HUD */
#game-canvas {
    width: 100%; height: 100%;
    display: block;
}
.hud {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
}
.hud-top {
    display: flex;
    justify-content: space-between;
    pointer-events: auto;
}
.hud-stat {
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    text-align: center;
}
.hud-label { font-size: 0.7rem; color: var(--text-muted); font-weight: bold; }
.hud-value { font-family: 'Audiowide', cursive; font-size: 1.5rem; }

.btn-pause { background: rgba(0,0,0,0.5); }

.hud-bottom {
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}
.nitro-container {
    width: 60%;
    background: rgba(0,0,0,0.6);
    padding: 5px;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
}
.nitro-bar {
    width: 100%; height: 15px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
}
.nitro-fill {
    width: 0%; height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    box-shadow: 0 0 10px var(--cyan);
    transition: width 0.1s linear;
}
.nitro-label {
    position: absolute;
    top: -20px; left: 50%; transform: translateX(-50%);
    font-family: 'Audiowide', cursive;
    font-size: 0.8rem; color: var(--cyan);
    text-shadow: 0 0 5px var(--cyan);
}

/* Overlays */
.overlay {
    position: absolute; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center; align-items: center;
    pointer-events: auto;
    z-index: 20;
}
.overlay.active { display: flex; }
.modal {
    background: var(--bg-panel);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column; gap: 15px;
    text-align: center;
    min-width: 250px;
}
.modal h2 { font-family: 'Audiowide', cursive; margin-bottom: 10px; }

/* Results */
.title-crashed {
    font-family: 'Audiowide', cursive;
    font-size: 3rem;
    text-align: center;
    margin-top: 50px;
    text-shadow: 0 0 10px var(--red);
}
.results-card {
    background: rgba(0,0,0,0.5);
    margin: 30px;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.1);
}
.res-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.res-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.res-row span:first-child { color: var(--text-muted); }

/* Mobile Controls */
.mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 15;
}
.ctrl-left, .ctrl-right {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}
.ctrl-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: background 0.1s;
    user-select: none;
}
.ctrl-btn span {
    font-size: 2rem;
}
.ctrl-btn:active, .ctrl-btn.active {
    background: rgba(255,255,255,0.5);
}
@media (min-width: 768px) {
    .mobile-controls {
        display: none;
    }
}
