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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

#game-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 14px;
    z-index: 10;
    pointer-events: none;
    animation: hudSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes hudSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(30px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#hud > div {
    background: rgba(8, 8, 24, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    padding: 14px 22px;
    color: #fff;
    text-align: center;
    min-width: 90px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Speed */
#speed-display { min-width: 120px; }

#speed-value {
    display: block;
    font-size: 52px;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: font-size 0.15s ease;
}

#speed-unit {
    display: block;
    font-size: 11px;
    font-weight: 300;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 4px;
}

/* Score */
#score-display {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#score-label {
    display: block;
    font-size: 10px;
    font-weight: 300;
    opacity: 0.45;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#score-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    margin-top: 2px;
}

/* Time of day */
#time-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

#time-icon { font-size: 20px; }

#time-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    opacity: 0.85;
}

/* ===== START SCREEN ===== */
#start-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 40%, rgba(20, 0, 40, 0.75) 0%, rgba(0, 0, 0, 0.92) 100%);
    z-index: 100;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.start-content {
    text-align: center;
    color: #fff;
}

.start-content h1 {
    font-size: clamp(48px, 12vw, 100px);
    font-weight: 900;
    letter-spacing: 14px;
    background: linear-gradient(135deg, #e63946, #ff6b6b, #feca57, #ff6b6b);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShimmer 4s ease-in-out infinite;
    filter: drop-shadow(0 0 40px rgba(230, 57, 70, 0.25));
}

@keyframes titleShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.subtitle {
    font-size: clamp(12px, 2.5vw, 18px);
    font-weight: 300;
    letter-spacing: 8px;
    text-transform: uppercase;
    opacity: 0.5;
    margin-top: 6px;
}

.controls-info {
    margin-top: 44px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    opacity: 0.75;
}

.key-row span {
    min-width: 100px;
    text-align: left;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    transition: background 0.2s;
}

#start-btn, #restart-btn {
    margin-top: 44px;
    padding: 15px 52px;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, #e63946 0%, #c1121f 100%);
    border: none;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 6px 24px rgba(230, 57, 70, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

#start-btn:hover, #restart-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 10px 36px rgba(230, 57, 70, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#start-btn:active, #restart-btn:active {
    transform: translateY(0) scale(0.98);
}

/* ===== GAME OVER ===== */
#gameover-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 40%, rgba(60, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.95) 100%);
    z-index: 100;
    animation: fadeIn 0.4s ease;
}

.gameover-content {
    text-align: center;
    color: #fff;
    animation: shakeIn 0.5s ease;
}

@keyframes shakeIn {
    0%   { transform: scale(0.8) rotate(-2deg); opacity: 0; }
    40%  { transform: scale(1.05) rotate(1deg); opacity: 1; }
    70%  { transform: scale(0.97) rotate(-0.5deg); }
    100% { transform: scale(1) rotate(0); }
}

.gameover-content h1 {
    font-size: clamp(40px, 10vw, 76px);
    font-weight: 900;
    letter-spacing: 6px;
    color: #ff4444;
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.4);
}

#final-score, #final-speed {
    font-size: 20px;
    font-weight: 400;
    margin-top: 10px;
    opacity: 0.75;
}

/* ===== MOBILE TOUCH CONTROLS ===== */
#mobile-controls {
    position: fixed;
    bottom: 24px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 15;
    pointer-events: none;
}

.mobile-side {
    display: flex;
    gap: 14px;
    pointer-events: auto;
}

.mobile-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.mobile-btn:active,
.mobile-btn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(0.93);
}

.mobile-btn span {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-top: 1px;
    opacity: 0.7;
}

.gas-btn {
    background: rgba(76, 175, 80, 0.18);
    border-color: rgba(76, 175, 80, 0.35);
}
.gas-btn:active, .gas-btn.active {
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.6);
}

.brake-btn {
    background: rgba(244, 67, 54, 0.18);
    border-color: rgba(244, 67, 54, 0.35);
}
.brake-btn:active, .brake-btn.active {
    background: rgba(244, 67, 54, 0.4);
    border-color: rgba(244, 67, 54, 0.6);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    #hud { gap: 8px; bottom: 110px; }
    #hud > div { padding: 8px 12px; border-radius: 12px; min-width: 64px; }
    #speed-value { font-size: 32px; }
    #score-value { font-size: 16px; }
    #time-label { font-size: 11px; }
    #time-icon { font-size: 16px; }
    .controls-info { margin-top: 28px; gap: 6px; }
    .key-row { font-size: 12px; }
    kbd { min-width: 28px; height: 26px; font-size: 11px; }
    .mobile-btn { width: 64px; height: 64px; font-size: 20px; }
}

@media (max-width: 380px) {
    .mobile-btn { width: 56px; height: 56px; font-size: 18px; }
    .mobile-side { gap: 10px; }
    #mobile-controls { padding: 0 12px; }
}
