/* ============================================
   TURBO RUSH - Car Racing Game Styles
   ============================================ */

/* CSS Variables */
:root {
    --primary: #00e5ff;
    --primary-dark: #0091ea;
    --accent: #ff6d00;
    --accent-glow: #ff9100;
    --danger: #ff1744;
    --success: #00e676;
    --bg-dark: #020617;
    --bg-card: rgba(10, 15, 35, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --gold: #fbbf24;
    --neon-green: #39ff14;
    --bmw-blue: #1e40af;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: var(--font-body);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* ============================================
   Screens
   ============================================ */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1;
}

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

.overlay {
    background: rgba(5, 8, 20, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
}

/* ============================================
   Start Screen
   ============================================ */
.start-bg-animation {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(30, 64, 175, 0.1) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(0, 229, 255, 0.06) 0%, transparent 60%),
        linear-gradient(180deg, #020617 0%, #0f172a 40%, #1e1b4b 100%);
    overflow: hidden;
}

.start-bg-animation::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: 
        radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.2), transparent),
        radial-gradient(2px 2px at 60% 40%, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 80% 10%, rgba(255,255,255,0.15), transparent),
        radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.25), transparent),
        radial-gradient(1px 1px at 90% 90%, rgba(255,255,255,0.15), transparent);
    animation: starfield 80s linear infinite;
}

@keyframes starfield {
    from { transform: translateY(0); }
    to { transform: translateY(50%); }
}

.start-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 20px;
}

/* Logo */
.logo-container {
    text-align: center;
}

.game-logo {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 5.5rem);
    font-weight: 900;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(0, 229, 255, 0.3));
    animation: logoPulse 3s ease-in-out infinite;
}

.game-logo span {
    background: linear-gradient(135deg, var(--accent) 0%, var(--danger) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255, 109, 0, 0.4));
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.tagline {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 3vw, 1.3rem);
    letter-spacing: 8px;
    color: var(--text-secondary);
    margin-top: 8px;
    text-transform: uppercase;
}

/* Display Car on Start Screen */
.start-car-display {
    position: relative;
    width: 120px;
    height: 200px;
    margin: 10px 0;
    animation: carFloat 2.5s ease-in-out infinite;
}

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

.start-car-img {
    width: 120px;
    height: auto;
    filter: drop-shadow(0 0 30px rgba(0,150,255,0.4));
    animation: carFloat 2.5s ease-in-out infinite;
}

/* High Score Display */
.high-score-display {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--gold);
    letter-spacing: 3px;
    padding: 8px 24px;
    border: 1px solid rgba(255, 215, 64, 0.3);
    border-radius: 30px;
    background: rgba(255, 215, 64, 0.05);
}

/* Buttons */
.btn {
    position: relative;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 16px 48px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    min-width: 240px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #000;
    box-shadow: 0 4px 25px rgba(0, 229, 255, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 40px rgba(0, 229, 255, 0.5);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid rgba(136, 146, 176, 0.3);
    box-shadow: none;
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.3rem;
}

.controls-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    margin-top: 5px;
}

/* ============================================
   Game Canvas
   ============================================ */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #020617;
}

/* ============================================
   HUD
   ============================================ */
#hud {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    padding: 12px 80px 12px 24px; /* padding-right 80px to avoid pause button */
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10;
    pointer-events: none;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-family: var(--font-display);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.hud-value {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    font-weight: 700;
    letter-spacing: 1px;
}

.hud-value small {
    font-size: 0.6em;
    opacity: 0.7;
}

.hud-score .hud-value { color: var(--primary); }
.hud-speed {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 30px;
    padding: 4px 20px;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2), inset 0 0 10px rgba(0, 229, 255, 0.1);
}
.hud-speed .hud-value { color: var(--accent); }
.hud-coins .hud-value { color: var(--gold); }
.hud-lives .hud-value { font-size: clamp(0.8rem, 2.5vw, 1rem); }

/* Speed Lines */
#speed-lines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s;
}

#speed-lines.active {
    opacity: 1;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 95%,
        rgba(255,255,255,0.03) 95%,
        rgba(255,255,255,0.03) 100%
    );
    animation: speedLinesMove 0.1s linear infinite;
    background-size: 100% 200px;
}

@keyframes speedLinesMove {
    from { background-position: 0 0; }
    to { background-position: 0 200px; }
}

/* ============================================
   Touch Controls
   ============================================ */
#touch-controls {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 20;
    pointer-events: none;
}

.touch-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.08);
    color: var(--primary);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    cursor: pointer;
    transition: all 0.15s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.touch-btn:active {
    background: rgba(0, 229, 255, 0.25);
    border-color: var(--primary);
    transform: scale(0.92);
}

/* Pause Button */
.icon-btn {
    position: fixed;
    top: 24px;
    right: 30px;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================
   Overlay Content
   ============================================ */
.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
}

.overlay-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--primary);
    text-shadow: 0 0 40px rgba(0, 229, 255, 0.3);
}

.game-over-title {
    background: linear-gradient(135deg, var(--danger) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(255, 23, 68, 0.4));
}

/* Final Stats */
.final-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
}

.stat-label {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* New Record */
.new-record {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 3px;
    animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.8; }
}

.hidden {
    display: none !important;
}

/* ============================================
   Responsive - Show Touch Controls on Mobile
   ============================================ */
@media (pointer: coarse) {
    #touch-controls {
        display: flex !important;
    }
}

@media (max-width: 480px) {
    #touch-controls {
        display: flex !important;
    }

    .hud-label {
        font-size: 0.5rem;
    }

    .btn {
        padding: 14px 36px;
        font-size: 0.95rem;
        min-width: 200px;
    }

    .icon-btn {
        top: 55px;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active .start-content > * {
    animation: fadeIn 0.6s ease-out both;
}

.screen.active .start-content > *:nth-child(1) { animation-delay: 0.1s; }
.screen.active .start-content > *:nth-child(2) { animation-delay: 0.25s; }
.screen.active .start-content > *:nth-child(3) { animation-delay: 0.4s; }
.screen.active .start-content > *:nth-child(4) { animation-delay: 0.55s; }
.screen.active .start-content > *:nth-child(5) { animation-delay: 0.7s; }

.overlay.active .overlay-content > * {
    animation: fadeIn 0.5s ease-out both;
}

.overlay.active .overlay-content > *:nth-child(1) { animation-delay: 0.1s; }
.overlay.active .overlay-content > *:nth-child(2) { animation-delay: 0.2s; }
.overlay.active .overlay-content > *:nth-child(3) { animation-delay: 0.3s; }
.overlay.active .overlay-content > *:nth-child(4) { animation-delay: 0.4s; }
.overlay.active .overlay-content > *:nth-child(5) { animation-delay: 0.5s; }

/* Score popup animation */
@keyframes scorePopup {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(1.3); opacity: 0; }
}

/* Flash effect on hit */
@keyframes hitFlash {
    0% { box-shadow: inset 0 0 0 0 rgba(255,23,68,0); }
    30% { box-shadow: inset 0 0 100px 20px rgba(255,23,68,0.4); }
    100% { box-shadow: inset 0 0 0 0 rgba(255,23,68,0); }
}

#game-canvas.hit-flash {
    animation: hitFlash 0.4s ease-out;
}
