/* ============================================================
   WZA 3D Racing
   ============================================================ */
:root {
    --race-ink: #eef5f7;    --race-muted: #9cadb7;
    --race-dim: #667a86;
    --race-panel: rgba(8, 16, 24, 0.78);
    --race-panel-solid: #0b151f;
    --race-line: rgba(179, 220, 231, 0.2);
    --race-cyan: #71e5ea;
    --race-orange: #ffb35c;
    --race-red: #ff6f61;
    --race-green: #9de28d;
    --race-font: "Trebuchet MS", "Microsoft YaHei", "PingFang SC", sans-serif;
    --race-mono: Consolas, "SFMono-Regular", monospace;
}

[hidden] { display: none !important; }

body.racing-page {
    margin: 0;
    color: var(--race-ink);
    background:
        radial-gradient(circle at 16% 0%, rgba(44, 100, 117, 0.35), transparent 38%),
        radial-gradient(circle at 86% 12%, rgba(139, 62, 35, 0.23), transparent 34%),
        #050a10;
    font-family: var(--race-font);
    overflow-x: hidden;
}

.racing-page #nav-placeholder { position: relative; z-index: 20; }
.racing-page #footer-placeholder { position: relative; z-index: 2; }

.race-main {
    width: 100%;
    max-width: 1540px;
    margin: 0 auto;
    padding: 86px 18px 30px;
}

.race-stage {
    position: relative;
    min-height: 620px;
    height: min(880px, calc(100svh - 120px));
    overflow: hidden;
    isolation: isolate;
    background: #05090e;
    border: 1px solid rgba(156, 217, 224, 0.28);
    border-radius: 18px;
    box-shadow:
        0 24px 90px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.035) inset,
        0 0 80px rgba(51, 137, 151, 0.14);
}

#raceCanvas {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}
#raceCanvas:active { cursor: grabbing; }

.race-grade,
.race-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.race-grade {
    background: linear-gradient(180deg, rgba(2, 7, 12, 0.18), transparent 30%, transparent 62%, rgba(2, 7, 12, 0.58));
    mix-blend-mode: multiply;
}
.race-vignette {
    box-shadow: inset 0 0 140px 24px rgba(0, 0, 0, 0.58);
}

/* ---------- shared type / buttons ---------- */
.race-kicker {
    margin: 0 0 6px;
    color: var(--race-cyan);
    font-family: var(--race-mono);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}
.race-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 15px;
    color: var(--race-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.03em;
}
.race-back:hover { color: var(--race-cyan); }

.race-primary-btn,
.race-secondary-btn,
.race-ghost-btn,
.race-text-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 9px;
    padding: 9px 16px;
    font-family: var(--race-font);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.race-primary-btn {
    color: #041014;
    background: linear-gradient(135deg, #8cf1ef, #4ecbd8);
    border: 1px solid rgba(192, 255, 252, 0.7);
    box-shadow: 0 8px 24px rgba(57, 207, 215, 0.22), 0 1px 0 rgba(255, 255, 255, 0.28) inset;
}
.race-primary-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(57, 207, 215, 0.3); }
.race-secondary-btn {
    color: var(--race-ink);
    background: rgba(173, 218, 226, 0.08);
    border: 1px solid rgba(173, 218, 226, 0.36);
}
.race-secondary-btn:hover { background: rgba(173, 218, 226, 0.16); border-color: var(--race-cyan); }
.race-ghost-btn {
    min-height: 36px;
    padding: 6px 11px;
    color: var(--race-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 0.66rem;
}
.race-ghost-btn:hover { color: var(--race-ink); border-color: rgba(113, 229, 234, 0.45); }
.race-text-btn {
    min-height: 32px;
    padding: 4px 8px;
    color: var(--race-muted);
    background: transparent;
    border: 0;
    font-size: 0.68rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.race-text-btn:hover { color: var(--race-cyan); }
.race-primary-btn:disabled,
.race-secondary-btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }

.race-wallet {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 4px 10px;
    color: #ffe2ad;
    background: rgba(255, 190, 90, 0.1);
    border: 1px solid rgba(255, 195, 102, 0.36);
    border-radius: 9px;
    font-family: var(--race-mono);
    font-size: 0.8rem;
    font-weight: 800;
}
.race-coin {
    display: inline-grid;
    place-items: center;
    width: 19px;
    height: 19px;
    color: #4a2c08;
    background: linear-gradient(145deg, #ffe39e, #d99842);
    border: 1px solid #ffeac0;
    border-radius: 50%;
    font-family: var(--race-font);
    font-size: 0.6rem;
    font-weight: 900;
}
.race-wallet small { color: #b99b6b; font-family: var(--race-font); font-size: 0.6rem; }

/* ---------- menu ---------- */
.race-menu-layer {
    position: absolute;
    inset: 0;
    z-index: 8;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        linear-gradient(90deg, rgba(4, 10, 16, 0.89) 0%, rgba(5, 12, 17, 0.72) 44%, rgba(5, 11, 16, 0.34) 100%),
        linear-gradient(180deg, rgba(4, 9, 14, 0.3), rgba(4, 9, 14, 0.8));
    backdrop-filter: blur(2px);
}
.race-menu-shell {
    width: min(1320px, calc(100% - 42px));
    min-height: 100%;
    margin: 0 auto;
    padding: 24px 0 28px;
}
.race-menu-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(179, 220, 231, 0.14);
}
.race-menu-head h1 {
    margin: 0;
    color: #f1f8f8;
    font-size: clamp(2rem, 4.2vw, 4rem);
    line-height: 0.98;
    letter-spacing: -0.06em;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.48);
}
.race-menu-head h1 span {
    display: block;
    margin-top: 6px;
    color: transparent;
    background: linear-gradient(90deg, #8cf1ef, #ffd18b 70%);
    background-clip: text;
    -webkit-background-clip: text;
    font-size: 0.56em;
    letter-spacing: -0.03em;
}
.race-lead {
    max-width: 590px;
    margin: 12px 0 0;
    color: #aebfc6;
    font-size: 0.82rem;
    line-height: 1.65;
}
.race-wallet-block {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-top: 21px;
    flex: 0 0 auto;
}
.race-menu-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 370px;
    gap: 20px;
    padding-top: 19px;
}

.race-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.race-section-head h2 {
    margin: 0;
    font-size: 1.22rem;
    letter-spacing: -0.03em;
}
.race-section-meta {
    color: var(--race-dim);
    font-family: var(--race-mono);
    font-size: 0.6rem;
    white-space: nowrap;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}
.map-card {
    position: relative;
    min-height: 152px;
    padding: 10px;
    overflow: hidden;
    text-align: left;
    color: var(--race-ink);
    background: linear-gradient(145deg, var(--map-a, #254b56), var(--map-b, #0c1820));
    border: 1px solid rgba(221, 244, 248, 0.14);
    border-radius: 11px;
    cursor: pointer;
    isolation: isolate;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.map-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 70% 20%, var(--map-glow, rgba(255, 210, 130, 0.52)), transparent 40%),
        linear-gradient(155deg, transparent 35%, rgba(0, 0, 0, 0.42));
}
.map-card::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 42px;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-22deg);
}
.map-card:hover { transform: translateY(-3px); border-color: rgba(179, 250, 248, 0.55); }
.map-card.is-selected {
    border-color: var(--race-cyan);
    box-shadow: 0 0 0 1px var(--race-cyan), 0 10px 28px rgba(0, 0, 0, 0.36), 0 0 30px rgba(93, 227, 231, 0.14);
}
.map-card-icon {
    display: block;
    margin-bottom: 22px;
    font-size: 1.25rem;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}
.map-card strong { display: block; font-size: 0.78rem; line-height: 1.25; letter-spacing: -0.02em; }
.map-card small {
    display: block;
    margin-top: 4px;
    color: rgba(232, 247, 249, 0.62);
    font-family: var(--race-mono);
    font-size: 0.54rem;
    letter-spacing: 0.04em;
}
.map-card .map-card-best {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    color: rgba(255, 255, 255, 0.82);
    font-family: var(--race-mono);
    font-size: 0.53rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.map-card .map-card-arrow {
    position: absolute;
    top: 9px;
    right: 9px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.62rem;
}

.race-brief {
    align-self: stretch;
    padding: 17px;
    background: linear-gradient(160deg, rgba(15, 31, 40, 0.9), rgba(4, 10, 15, 0.84));
    border: 1px solid rgba(150, 220, 228, 0.19);
    border-radius: 13px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.26);
}
.race-brief-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.race-map-tag {
    color: var(--race-orange);
    font-family: var(--race-mono);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}
.race-difficulty { color: #ffd08b; font-size: 0.64rem; letter-spacing: 2px; }
.race-brief h2 {
    margin: 7px 0 6px;
    font-size: 1.75rem;
    line-height: 1.1;
    letter-spacing: -0.05em;
}
.race-brief p { margin: 0; color: var(--race-muted); font-size: 0.72rem; line-height: 1.65; }
.race-map-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 14px 0;
    padding: 9px 0;
    border-top: 1px solid rgba(159, 219, 227, 0.12);
    border-bottom: 1px solid rgba(159, 219, 227, 0.12);
}
.race-map-stats span { min-width: 0; }
.race-map-stats small { display: block; color: var(--race-dim); font-size: 0.54rem; }
.race-map-stats strong { display: block; margin-top: 3px; color: #dff4f5; font-family: var(--race-mono); font-size: 0.67rem; white-space: nowrap; }
.race-current-car {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
}
.race-current-car strong { display: block; margin-top: 2px; font-size: 0.78rem; }
.race-current-car small { display: block; margin-top: 3px; color: var(--race-dim); font-family: var(--race-mono); font-size: 0.55rem; }
.race-car-silhouette {
    position: relative;
    flex: 0 0 84px;
    width: 84px;
    height: 42px;
    transform: perspective(80px) rotateY(-11deg);
}
.silhouette-body {
    position: absolute;
    left: 3px;
    right: 1px;
    bottom: 8px;
    height: 18px;
    background: linear-gradient(180deg, var(--car-top, #78e1df), var(--car-bottom, #17636f));
    border-radius: 14px 20px 5px 6px;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
}
.silhouette-cabin {
    position: absolute;
    left: 25px;
    bottom: 23px;
    width: 39px;
    height: 12px;
    background: linear-gradient(135deg, #d7ffff, #2a6d7a);
    border-radius: 8px 8px 2px 2px;
    transform: skewX(-12deg);
}
.silhouette-wheel { position: absolute; bottom: 2px; width: 13px; height: 13px; background: #121c21; border: 2px solid #52646b; border-radius: 50%; }
.silhouette-wheel--a { left: 12px; }
.silhouette-wheel--b { right: 9px; }
.race-brief-actions { display: grid; gap: 7px; margin-top: 13px; }
.race-brief-actions .race-primary-btn { width: 100%; min-height: 46px; font-size: 0.84rem; }
.race-brief-actions .race-secondary-btn { width: 100%; min-height: 38px; font-size: 0.7rem; }
.race-hint {
    margin-top: 11px !important;
    color: var(--race-dim) !important;
    font-family: var(--race-mono);
    font-size: 0.54rem !important;
    line-height: 1.7 !important;
}
kbd {
    display: inline-block;
    padding: 1px 4px;
    color: #dff7f8;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    font-family: var(--race-mono);
    font-size: 0.52rem;
}

/* ---------- HUD ---------- */
.race-hud {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 6;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 12px;
    color: #edf8f9;
    pointer-events: none;
}
.race-hud > * { pointer-events: auto; }
.race-hud-left,
.race-hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.race-hud-right { justify-content: flex-end; }
.race-hud-map {
    padding: 6px 8px;
    color: #b8d4d7;
    background: rgba(3, 10, 14, 0.48);
    border: 1px solid rgba(183, 235, 238, 0.18);
    border-radius: 6px;
    font-family: var(--race-mono);
    font-size: 0.57rem;
    backdrop-filter: blur(8px);
}
#hudLap {
    color: #fff3d1;
    font-family: var(--race-mono);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.race-hud-center { text-align: center; min-width: 155px; }
.race-timer {
    display: block;
    color: #f8fbfa;
    font-family: var(--race-mono);
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.68);
}
.race-hud-status { display: block; margin-top: 3px; color: #b3c9cb; font-size: 0.56rem; letter-spacing: 0.06em; }
.race-nitro { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 6px; color: #9ff7ff; font-family: var(--race-mono); font-size: 0.45rem; }
.race-nitro-track { width: 74px; height: 4px; overflow: hidden; background: rgba(157, 224, 231, 0.18); border-radius: 99px; }
#nitroFill { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #59d7ff, #b8fff4); border-radius: inherit; transition: width 0.12s linear; }
.race-nitro small { min-width: 28px; color: #8db8bc; font-size: 0.43rem; }
.race-countdown {
    position: fixed;
    left: 50%;
    top: 45%;
    z-index: 15;
    transform: translate(-50%, -50%);
    color: #fff4ce;
    font-family: var(--race-mono);
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 0 32px rgba(255, 206, 116, 0.55), 0 5px 0 rgba(0, 0, 0, 0.35);
    animation: countPulse 0.36s ease both;
}
.race-speed {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 89px;
    padding: 6px 8px;
    text-align: right;
    background: rgba(3, 10, 14, 0.48);
    border: 1px solid rgba(183, 235, 238, 0.18);
    border-radius: 7px;
    backdrop-filter: blur(8px);
}
.race-speed strong { color: #f3fffe; font-family: var(--race-mono); font-size: 1.2rem; line-height: 1; }
.race-speed span { color: #9fb8bb; font-family: var(--race-mono); font-size: 0.46rem; }
.race-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: #e9f8f8;
    background: rgba(4, 12, 17, 0.55);
    border: 1px solid rgba(183, 235, 238, 0.24);
    border-radius: 7px;
    cursor: pointer;
    backdrop-filter: blur(8px);
}
.race-icon-btn:hover { background: rgba(113, 229, 234, 0.18); }
.race-icon-btn.is-muted { color: #7e969b; }

/* ---------- touch controls ---------- */
.race-touch-controls {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: max(15px, env(safe-area-inset-bottom));
    z-index: 7;
    display: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}
.touch-steer,
.touch-pedals { display: flex; align-items: flex-end; gap: 9px; pointer-events: auto; }
.touch-btn {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    color: rgba(238, 255, 255, 0.84);
    background: rgba(5, 16, 22, 0.33);
    border: 1px solid rgba(199, 250, 252, 0.35);
    border-radius: 50%;
    font-family: var(--race-font);
    font-size: 0.58rem;
    font-weight: 800;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16), inset 0 0 20px rgba(141, 235, 239, 0.06);
    backdrop-filter: blur(7px);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.touch-btn i { font-size: 1.05rem; }
.touch-btn.is-pressed { background: rgba(113, 229, 234, 0.28); border-color: rgba(195, 255, 255, 0.75); }
.touch-btn--throttle {
    width: 68px;
    height: 68px;
    color: #fff2cf;
    border-color: rgba(255, 201, 118, 0.48);
}
.touch-btn--brake { color: #ffd2c9; border-color: rgba(255, 145, 126, 0.35); }
.touch-aux { position: absolute; right: 0; bottom: 78px; display: flex; gap: 6px; pointer-events: auto; }
.touch-btn--aux { width: 44px; height: 44px; font-size: 0.48rem; border-radius: 11px; }
.touch-btn--nitro { color: #a9fcff; border-color: rgba(103, 237, 255, 0.48); background: rgba(12, 55, 67, 0.38); }
.lap-toast {
    position: absolute;
    left: 50%;
    top: 28%;
    z-index: 9;
    transform: translate(-50%, -50%);
    color: #fff1c0;
    font-family: var(--race-mono);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
    pointer-events: none;
    animation: lapToast 1.4s ease both;
}

/* ---------- modal layers ---------- */
.race-modal-layer {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2, 7, 11, 0.66);
    backdrop-filter: blur(8px);
    overflow-y: auto;
}
.race-modal {
    width: min(460px, 100%);
    padding: 23px;
    color: var(--race-ink);
    background: linear-gradient(160deg, rgba(18, 35, 43, 0.98), rgba(6, 13, 19, 0.98));
    border: 1px solid rgba(158, 225, 230, 0.28);
    border-radius: 15px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    text-align: center;
}
.race-modal--small { width: min(370px, 100%); }
.race-modal h2 { margin: 0; font-size: 2rem; letter-spacing: -0.05em; }
.race-modal p { margin: 7px 0 16px; color: var(--race-muted); font-size: 0.76rem; line-height: 1.6; }
.race-modal .race-primary-btn,
.race-modal .race-secondary-btn { width: 100%; margin-top: 7px; }
.race-modal .race-text-btn { margin-top: 8px; }
.race-result-modal { width: min(530px, 100%); text-align: left; }
.result-badge {
    display: inline-block;
    margin-bottom: 9px;
    padding: 3px 8px;
    color: #112327;
    background: linear-gradient(135deg, #9af4ee, #ffd188);
    border-radius: 4px;
    font-family: var(--race-mono);
    font-size: 0.56rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}
.race-result-modal h2 { font-size: 2.25rem; }
.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    margin: 17px 0;
    overflow: hidden;
    background: rgba(189, 235, 238, 0.13);
    border: 1px solid rgba(189, 235, 238, 0.13);
    border-radius: 8px;
}
.result-grid span { padding: 9px 10px; background: rgba(5, 14, 19, 0.8); }
.result-grid small { display: block; color: var(--race-dim); font-size: 0.54rem; }
.result-grid strong { display: block; margin-top: 2px; color: #eaffff; font-family: var(--race-mono); font-size: 0.82rem; }
.result-coins {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0 0 10px;
    color: #ffdda3;
    font-family: var(--race-mono);
    font-size: 1rem;
}
.result-coins small { color: var(--race-dim); font-family: var(--race-font); font-size: 0.6rem; }
.result-coins strong { font-size: 1.25rem; }

/* ---------- garage ---------- */
.race-garage-layer { align-items: start; padding-top: 25px; }
.race-garage-modal {
    width: min(980px, 100%);
    max-height: calc(100svh - 50px);
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(160deg, rgba(17, 33, 41, 0.98), rgba(5, 12, 18, 0.99));
    border: 1px solid rgba(158, 225, 230, 0.28);
    border-radius: 15px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}
.race-garage-head { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.race-garage-head > div:first-child { flex: 1; }
.race-garage-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.04em; }
.garage-list { display: grid; gap: 8px; }
.garage-car {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
}
.garage-car.is-selected { border-color: rgba(113, 229, 234, 0.64); background: rgba(113, 229, 234, 0.07); }
.garage-car.is-locked { opacity: 0.68; }
.garage-car-art {
    position: relative;
    width: 58px;
    height: 35px;
    overflow: hidden;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--car-a), var(--car-b));
}
.garage-car-art::before {
    content: "";
    position: absolute;
    left: 9px;
    right: 8px;
    bottom: 8px;
    height: 14px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 9px 13px 3px 3px;
}
.garage-car-art::after {
    content: "";
    position: absolute;
    left: 18px;
    bottom: 2px;
    width: 18px;
    height: 18px;
    background: rgba(5, 12, 16, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-shadow: 25px 0 0 -2px rgba(5, 12, 16, 0.8), 25px 0 0 0 rgba(255, 255, 255, 0.3);
}
.garage-car-copy { min-width: 0; }
.garage-car-copy strong { display: block; font-size: 0.8rem; }
.garage-car-copy small { display: block; margin-top: 2px; color: var(--race-dim); font-family: var(--race-mono); font-size: 0.54rem; }
.garage-stats { display: flex; gap: 8px; margin-top: 5px; }
.garage-stats span { color: #bad0d3; font-family: var(--race-mono); font-size: 0.51rem; }
.garage-upgrades { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.upgrade-btn {
    min-height: 25px;
    padding: 3px 6px;
    color: #dceff0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(173, 228, 233, 0.2);
    border-radius: 5px;
    font-family: var(--race-mono);
    font-size: 0.48rem;
    cursor: pointer;
}
.upgrade-btn:hover { border-color: var(--race-cyan); }
.upgrade-btn:disabled { opacity: 0.4; cursor: default; }
.garage-car-actions { display: flex; flex-direction: column; gap: 5px; align-items: stretch; min-width: 84px; }
.garage-car-actions .race-primary-btn,
.garage-car-actions .race-secondary-btn { min-height: 30px; padding: 4px 8px; font-size: 0.58rem; }
.garage-car-actions .race-text-btn { font-size: 0.56rem; }
.garage-note { margin: 11px 0 0; color: var(--race-dim); font-size: 0.58rem; line-height: 1.6; }

/* ---------- flash / loading ---------- */
.race-flash {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}
.race-flash.is-active { animation: raceFlash 0.55s ease-out both; }
.race-loading {
    position: absolute;
    inset: 0;
    z-index: 14;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 13px;
    color: #cee8e9;
    background: rgba(3, 8, 12, 0.92);
    font-family: var(--race-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}
.race-loading[hidden] { display: none !important; }
.loading-ring {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(113, 229, 234, 0.2);
    border-top-color: var(--race-cyan);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes countPulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(1.45); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes lapToast {
    0% { opacity: 0; transform: translate(-50%, -30%); }
    16%, 70% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -70%); }
}
@keyframes raceFlash {
    0% { opacity: 0; }
    16% { opacity: 0.24; }
    100% { opacity: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 1120px) {
    .race-menu-shell { width: min(100% - 32px, 1000px); }
    .race-menu-body { grid-template-columns: minmax(0, 1fr) 335px; }
    .map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px), (pointer: coarse) {
    body.race-live .race-touch-controls { display: flex; }
    .race-hint { display: none; }
}

@media (max-width: 820px) {
    .race-main { padding: 76px 10px 10px; }
    .race-stage { height: calc(100svh - 108px); min-height: 590px; border-radius: 13px; }
    .race-menu-layer { background: linear-gradient(180deg, rgba(4, 10, 15, 0.86), rgba(4, 10, 15, 0.94)); }
    .race-menu-shell { width: calc(100% - 24px); padding-top: 15px; }
    .race-menu-head { flex-direction: column; gap: 13px; padding-bottom: 13px; }
    .race-menu-head h1 { font-size: clamp(2.1rem, 9vw, 3.2rem); }
    .race-wallet-block { width: 100%; padding-top: 0; justify-content: space-between; }
    .race-menu-body { grid-template-columns: 1fr; gap: 13px; }
    .map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .race-brief { padding: 13px; }
    .race-brief h2 { font-size: 1.45rem; }
    .race-hud { top: 9px; left: 9px; right: 9px; gap: 5px; }
    .race-hud-map { display: none; }
    .race-hud-center { min-width: 124px; }
    .race-timer { font-size: 1rem; }
    .race-hud-right { gap: 4px; }
    .race-speed { min-width: 70px; padding: 5px 6px; }
    .race-speed strong { font-size: 1rem; }
    .race-icon-btn { width: 29px; height: 29px; }
    .race-garage-modal { padding: 14px; }
    .garage-car { grid-template-columns: 46px minmax(0, 1fr); gap: 8px; }
    .garage-car-art { width: 46px; height: 30px; }
    .garage-car-actions { grid-column: 1 / -1; flex-direction: row; }
    .garage-car-actions > * { flex: 1 1 0; }
}

@media (max-width: 600px) {
    .race-main { padding-top: 70px; }
    .race-stage { min-height: 560px; height: calc(100svh - 94px); }
    .race-menu-shell { width: calc(100% - 18px); }
    .race-lead { font-size: 0.72rem; }
    .race-wallet-block { flex-wrap: wrap; gap: 6px; }
    .race-wallet { min-height: 34px; font-size: 0.72rem; }
    .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
    .map-card { min-height: 128px; }
    .map-card-icon { margin-bottom: 14px; }
    .map-card strong { font-size: 0.72rem; }
    .race-brief { padding: 12px; }
    .race-brief h2 { font-size: 1.35rem; }
    .race-map-stats { margin: 11px 0; }
    .race-current-car { padding: 8px; }
    .race-touch-controls { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); }
    .touch-btn { width: 56px; height: 56px; }
    .touch-btn--throttle { width: 61px; height: 61px; }
    .touch-btn--aux { width: 42px; height: 42px; }
    .touch-aux { bottom: 72px; }
    .race-modal { padding: 18px; }
    .race-result-modal h2 { font-size: 1.8rem; }
}

@media (max-width: 390px) {
    .race-menu-head h1 { font-size: 2rem; }
    .race-menu-head h1 span { font-size: 0.58em; }
    .map-card { min-height: 119px; padding: 8px; }
    .map-card strong { font-size: 0.67rem; }
    .race-brief-actions .race-primary-btn { min-height: 42px; }
    .race-hud-left { max-width: 88px; }
    #hudLap { font-size: 0.6rem; }
    .race-hud-center { min-width: 105px; }
    .race-timer { font-size: 0.85rem; }
    .race-nitro { margin-top: 3px; }
    .race-nitro-track { width: 58px; }
    .race-speed { min-width: 62px; }
    .race-speed strong { font-size: 0.9rem; }
    .race-speed span { font-size: 0.38rem; }
}

@media (prefers-reduced-motion: reduce) {
    .race-countdown,
    .lap-toast,
    .race-flash.is-active,
    .loading-ring { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
