* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a12;
    overflow: hidden;
    font-family: 'Orbitron', monospace;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---- HUD ---- */
#hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    pointer-events: none;
    z-index: 10;
}

#hud-distance {
    position: absolute;
    top: 16px; left: 20px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(0,255,204,0.3);
    border-radius: 8px;
    padding: 10px 18px;
}

.hud-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 3px;
}

#distance-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 28px;
    color: #00FFCC;
    text-shadow: 0 0 12px rgba(0,255,204,0.5);
}

#hud-speed {
    position: absolute;
    top: 16px; right: 20px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(0,255,204,0.3);
    border-radius: 8px;
    padding: 10px 18px;
    text-align: center;
    min-width: 120px;
}

#speed-value {
    font-size: 42px;
    font-weight: 900;
    color: #00ff66;
    text-shadow: 0 0 20px rgba(0,255,102,0.6);
    transition: color 0.3s, text-shadow 0.3s;
    line-height: 1;
}

#speed-value.warning {
    color: #ff6600;
    text-shadow: 0 0 20px rgba(255,102,0,0.8);
}

#speed-value.danger {
    color: #ff2200;
    text-shadow: 0 0 25px rgba(255,34,0,0.9);
    animation: pulse-danger 0.4s infinite alternate;
}

@keyframes pulse-danger {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

#speed-unit {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 2px;
}

#speed-bar-container {
    margin-top: 6px;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

#speed-bar {
    height: 100%;
    width: 100%;
    background: #00ff66;
    border-radius: 2px;
    transition: width 0.2s, background 0.3s;
}

#hud-lane {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.lane-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
}

.lane-dot.active {
    background: #FFD700;
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255,215,0,0.6);
}

#near-miss {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: #00FFCC;
    text-shadow: 0 0 20px rgba(0,255,204,0.8);
    pointer-events: none;
    animation: near-miss-anim 0.8s ease-out forwards;
}

@keyframes near-miss-anim {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    30% { transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* ---- Start Screen ---- */
#start-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

#start-content {
    text-align: center;
}

#game-title {
    font-size: clamp(40px, 10vw, 80px);
    font-weight: 900;
    color: #FFD700;
    text-shadow: 
        0 0 20px rgba(255,215,0,0.6),
        0 0 60px rgba(255,215,0,0.3),
        2px 2px 0 #b8860b;
    letter-spacing: 8px;
    line-height: 1;
}

#game-subtitle {
    font-size: clamp(16px, 4vw, 32px);
    font-weight: 400;
    color: #00FFCC;
    text-shadow: 0 0 15px rgba(0,255,204,0.5);
    letter-spacing: 12px;
    margin-top: 4px;
}

#game-tagline {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    font-style: italic;
    margin-top: 16px;
}

#high-score-display {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: #00FFCC;
    margin-top: 24px;
}

#start-btn {
    display: inline-block;
    margin-top: 32px;
    padding: 14px 64px;
    font-family: 'Orbitron', monospace;
    font-size: 20px;
    font-weight: 700;
    color: #0a0a12;
    background: #FFD700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 4px;
    animation: pulse-btn 1.5s ease-in-out infinite;
    transition: transform 0.1s;
    pointer-events: all;
}

#start-btn:hover {
    transform: scale(1.05);
}

#start-btn:active {
    transform: scale(0.97);
}

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 20px rgba(255,215,0,0.4); }
    50% { box-shadow: 0 0 40px rgba(255,215,0,0.8); }
}

#controls-guide {
    margin-top: 24px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    line-height: 1.8;
}

/* ---- Game Over ---- */
#gameover-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(6px);
}

#gameover-content {
    text-align: center;
    animation: gameover-in 0.6s ease-out;
}

@keyframes gameover-in {
    0% { transform: scale(3); opacity: 0; }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

#gameover-title {
    font-size: clamp(36px, 9vw, 72px);
    font-weight: 900;
    color: #E74C3C;
    text-shadow: 0 0 30px rgba(231,76,60,0.7), 2px 2px 0 #8b0000;
    letter-spacing: 6px;
}

#gameover-reason {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-top: 12px;
}

#gameover-distance {
    font-size: 36px;
    font-weight: 700;
    color: #00FFCC;
    text-shadow: 0 0 15px rgba(0,255,204,0.5);
    margin-top: 20px;
}

#new-highscore {
    font-size: 20px;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255,215,0,0.6);
    margin-top: 12px;
    animation: hs-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes hs-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

#gameover-buttons {
    margin-top: 28px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

#gameover-buttons button {
    padding: 12px 32px;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: 700;
    border: 2px solid;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform 0.1s, box-shadow 0.2s;
}

#retry-btn {
    color: #0a0a12;
    background: #00FFCC;
    border-color: #00FFCC;
}

#menu-btn {
    color: #FFD700;
    background: transparent;
    border-color: #FFD700;
}

#gameover-buttons button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
}

/* ---- Center Message ---- */
#center-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(40px, 10vw, 80px);
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 0 30px rgba(255,215,0,0.7);
    z-index: 15;
    pointer-events: none;
    animation: msg-pop 0.5s ease-out;
}

@keyframes msg-pop {
    0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---- Mobile Controls ---- */
#mobile-controls {
    position: absolute;
    bottom: 50px;
    left: 0; right: 0;
    z-index: 12;
    pointer-events: none;
}

#mobile-controls > div {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: rgba(255,255,255,0.6);
    pointer-events: all;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#mobile-controls > div:active {
    background: rgba(255,215,0,0.3);
    border-color: #FFD700;
}

#mobile-left { left: 20px; bottom: 40px; }
#mobile-right { left: 100px; bottom: 40px; }
#mobile-up { right: 20px; bottom: 100px; }
#mobile-down { right: 20px; bottom: 20px; }

/* ---- Footer ---- */
#app-footer {
    position: fixed;
    bottom: 4px;
    right: 10px;
    z-index: 5;
}

#app-footer a {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: rgba(255,255,255,0.2);
    text-decoration: none;
}

#app-footer a:hover {
    color: rgba(255,255,255,0.5);
}

@media (min-width: 769px) {
    #mobile-controls { display: none !important; }
}