@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
    --panel: rgba(8, 10, 16, 0.72);
    --line: rgba(255, 255, 255, 0.14);
    --cyan: #00d4ff;
    --text: #f4f7fb;
    --muted: rgba(244, 247, 251, 0.62);
}

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

html, body, #stage {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: #6aa34a;
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#stage {
    position: fixed;
    inset: 0;
}

#stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#loading {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #05070c;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: var(--muted);
    transition: opacity 0.45s ease;
}

#loading.hide {
    opacity: 0;
    pointer-events: none;
}

.loader-car {
    width: 72px;
    height: 28px;
    margin-bottom: 18px;
    border-radius: 16px 20px 8px 8px;
    background: linear-gradient(90deg, var(--cyan), #ff6b9d);
    animation: bounce 1.1s ease-in-out infinite;
}

@keyframes bounce {
    50% { transform: translateY(-5px); }
}

.hud-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 0;
    pointer-events: none;
}

.hud-top > * { pointer-events: auto; }

.kicker {
    font-size: 0.62rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--cyan);
    text-shadow: 0 1px 8px #000;
}

.hud-top h1 {
    font-size: 0.95rem;
    text-shadow: 0 2px 12px #000;
}

.hud-links, .car-pick {
    display: flex;
    gap: 6px;
}

.ghost, .car-pick select {
    appearance: none;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 0.72rem;
    text-decoration: none;
    backdrop-filter: blur(12px);
    user-select: auto;
    -webkit-user-select: auto;
}

.car-pick {
    position: fixed;
    top: calc(52px + env(safe-area-inset-top, 0px));
    right: 14px;
    z-index: 10;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--muted);
}

#speedo {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 10;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
    backdrop-filter: blur(12px);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
    pointer-events: none;
}

#speed-num {
    font-size: 1.35rem;
    font-weight: 700;
}

.hint, .credit {
    position: fixed;
    left: 12px;
    right: 12px;
    z-index: 10;
    text-align: center;
    color: var(--muted);
    text-shadow: 0 1px 8px #000;
    pointer-events: none;
}

.hint {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    font-size: 0.72rem;
}

.credit {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    font-size: 0.62rem;
    pointer-events: auto;
}

.credit a {
    color: #d9f8ff;
    user-select: auto;
    -webkit-user-select: auto;
}

#touch {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 calc(16px + env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
    pointer-events: none;
}

#touch[hidden] { display: none !important; }

.stick {
    position: relative;
    width: 132px;
    height: 132px;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.stick-base,
.stick-knob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.stick-base {
    inset: 0;
    border: 2px solid rgba(255, 255, 255, 0.28);
    background: rgba(8, 10, 16, 0.38);
    box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.12);
}

.stick-knob {
    top: 50%;
    left: 50%;
    width: 58px;
    height: 58px;
    margin: -29px 0 0 -29px;
    background: radial-gradient(circle at 35% 30%, #7fe9ff, #00d4ff 42%, #0a6a80);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    will-change: transform;
}

#stick-right .stick-knob {
    background: radial-gradient(circle at 35% 30%, #ffd1e0, #ff6b9d 42%, #8a2048);
}

@media (min-width: 821px) {
    #touch { display: none !important; }
    #speedo { bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
    .hint { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
