:root {
    --neon-cyan: #00f5ff;
    --neon-lime: #aaff00;
    --neon-pink: #ff2d78;
    --neon-blue: #0066ff;
    --road-dark: #050a14;
    --road-mid: #070f1e;
    --ui-bg: rgba(0, 10, 25, 0.75);
    --font-main: 'Orbitron', sans-serif;
    --font-body: 'Exo 2', sans-serif;
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: var(--font-body);
    touch-action: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    
    width: min(480px, 100vw);
    height: 100vh;
    background: var(--road-dark);
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(0, 245, 255, 0.1),
        0 0 60px rgba(0, 245, 255, 0.08),
        0 0 120px rgba(0, 100, 255, 0.1);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

#preloader {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, #001430 0%, #000510 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    animation: fadeIn 0.4s;
}

.loader-car,
.loader-logo {
    font-size: clamp(5rem, 10vw, 9rem);
    margin-bottom: 28px;
    animation: carBounce 1.2s ease-in-out infinite;
    filter: drop-shadow(0 0 24px var(--neon-cyan));
}

@keyframes carBounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-12px) scale(1.05);
    }
}

.loading-bar {
    width: clamp(180px, 60%, 280px);
    height: 5px;
    background: rgba(0, 245, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan), var(--neon-lime));
    width: 0%;
    transition: width 0.3s;
    box-shadow: 0 0 16px var(--neon-cyan);
}

.loading-text {
    color: rgba(0, 245, 255, 0.6);
    margin-top: 14px;
    font-family: var(--font-main);
    font-size: clamp(0.65rem, 2vw, 0.85rem);
    letter-spacing: 3px;
    text-transform: uppercase;
}

#hud {
    position: absolute;
    top: clamp(8px, 1.8vh, 16px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px;
    background: none;
    border: none;
    pointer-events: none;
    z-index: 15;
}

.hud-item {
    flex: 1;
    min-width: 0;
    font-family: var(--font-main);
    font-size: clamp(0.65rem, 3.5vw, 0.92rem);
    
    font-weight: 700;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px var(--neon-cyan);
    background: rgba(0, 8, 24, 0.82);
    border: 1px solid rgba(0, 245, 255, 0.25);
    padding: 7px 10px;
    border-radius: 50px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 12px rgba(0, 245, 255, 0.1),
        inset 0 1px 0 rgba(0, 245, 255, 0.08);
}

.hud-speed {
    color: var(--neon-lime);
    text-shadow: 0 0 8px var(--neon-lime);
    border-color: rgba(170, 255, 0, 0.25);
    background: rgba(0, 10, 2, 0.82);
    box-shadow: 0 2px 12px rgba(170, 255, 0, 0.1),
        inset 0 1px 0 rgba(170, 255, 0, 0.08);
}

.hidden {
    display: none !important;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(0, 5, 18, 0.92);
    backdrop-filter: blur(6px);
    z-index: 20;
    animation: fadeIn 0.35s ease;
    padding: clamp(20px, 5vw, 40px);
}

.overlay-inner {
    text-align: center;
    padding: clamp(28px, 6vh, 50px) clamp(24px, 8vw, 50px);
    background: rgba(0, 20, 50, 0.5);
    border: 1px solid rgba(0, 245, 255, 0.15);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 60px rgba(0, 100, 255, 0.15), inset 0 1px 0 rgba(0, 245, 255, 0.1);
    max-width: 90%;
}

.title-badge {
    font-family: var(--font-main);
    font-size: clamp(0.55rem, 2vw, 0.75rem);
    letter-spacing: 5px;
    color: var(--neon-cyan);
    background: rgba(0, 245, 255, 0.08);
    border: 1px solid rgba(0, 245, 255, 0.25);
    border-radius: 50px;
    padding: 5px 16px;
    display: inline-block;
    margin-bottom: 14px;
    text-transform: uppercase;
}

h1 {
    font-family: var(--font-main);
    font-size: clamp(2.4rem, 12vw, 4.5rem);
    font-weight: 900;
    line-height: 0.95;
    letter-spacing: 4px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, var(--neon-cyan) 0%, #5599ff 50%, var(--neon-lime) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleGlow 2.5s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(0, 245, 255, 0.4));
}

@keyframes titleGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 15px rgba(0, 245, 255, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 35px rgba(170, 255, 0, 0.5));
    }
}

.subtitle {
    font-family: var(--font-main);
    font-size: clamp(0.65rem, 2.5vw, 0.9rem);
    color: rgba(0, 245, 255, 0.6);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hint {
    font-size: clamp(0.65rem, 2vw, 0.82rem);
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 26px;
    letter-spacing: 1px;
}

.crash-title {
    font-family: var(--font-main);
    font-size: clamp(2rem, 10vw, 3.2rem);
    font-weight: 900;
    color: var(--neon-pink);
    text-shadow: 0 0 30px var(--neon-pink), 0 0 60px rgba(255, 45, 120, 0.4);
    letter-spacing: 4px;
    margin-bottom: 18px;
    animation: crashPulse 0.8s ease-in-out 3;
}

@keyframes crashPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}

.go-stat {
    font-family: var(--font-main);
    font-size: clamp(1rem, 4vw, 1.35rem);
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    margin-bottom: 8px;
}

.go-best {
    font-size: clamp(0.8rem, 3vw, 1rem);
    color: rgba(170, 255, 0, 0.7);
    margin-bottom: 24px;
    letter-spacing: 2px;
}

.btn {
    font-family: var(--font-main);
    font-size: clamp(0.85rem, 3.5vw, 1.1rem);
    font-weight: 700;
    letter-spacing: 3px;
    padding: clamp(13px, 3vh, 18px) clamp(30px, 8vw, 55px);
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 50px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.2), inset 0 0 20px rgba(0, 245, 255, 0.03);
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.15), rgba(0, 100, 255, 0.15));
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover {
    color: #fff;
    box-shadow: 0 0 40px var(--neon-cyan), 0 0 80px rgba(0, 245, 255, 0.2);
    transform: scale(1.04);
}

.btn:hover::before {
    opacity: 1;
}

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

#controls {
    position: absolute;
    bottom: clamp(20px, 5vh, 45px);
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 clamp(16px, 6%, 30px);
    z-index: 15;
    pointer-events: none;
}

.ctrl-btn {
    width: clamp(64px, 18vw, 88px);
    height: clamp(64px, 18vw, 88px);
    background: rgba(0, 245, 255, 0.06);
    border: 2px solid rgba(0, 245, 255, 0.35);
    border-radius: 50%;
    color: var(--neon-cyan);
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.15);
    pointer-events: auto;
}

.ctrl-btn svg {
    width: 50%;
    height: 50%;
    fill: var(--neon-cyan);
}

.ctrl-btn:active {
    transform: scale(0.88);
    background: rgba(0, 245, 255, 0.18);
    box-shadow: 0 0 35px var(--neon-cyan);
}

.sound-toggle {
    flex-shrink: 0;
    width: clamp(40px, 9vw, 46px);
    
    height: clamp(40px, 9vw, 46px);
    background: rgba(0, 8, 24, 0.82);
    border: 1px solid rgba(0, 245, 255, 0.25);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.25s;
    box-shadow: 0 2px 12px rgba(0, 245, 255, 0.1),
        inset 0 1px 0 rgba(0, 245, 255, 0.08);
}

.sound-toggle svg {
    width: 50%;
    height: 50%;
    fill: var(--neon-cyan);
    transition: fill 0.2s;
}

.sound-toggle:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 18px rgba(0, 245, 255, 0.35);
    background: rgba(0, 245, 255, 0.14);
}

.sound-toggle.muted svg {
    fill: rgba(255, 255, 255, 0.3);
}

.sound-toggle.muted {
    border-color: rgba(255, 255, 255, 0.15);
    opacity: 0.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@media (max-width: 768px),
(pointer: coarse) {
    .ctrl-btn {
        display: flex;
    }

    .hint {
        display: none;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    #game-container {
        width: 100vw;
        height: 100vh;
        max-width: none;
    }

    h1 {
        font-size: 2rem;
        line-height: 1;
    }

    .overlay-inner {
        padding: 16px 28px;
    }

    .btn {
        padding: 10px 32px;
    }

    #controls {
        bottom: 10px;
    }
}

@media (min-width: 768px) and (min-height: 900px) {
    #game-container {
        max-width: 520px;
    }

}
