 /* Custom Styles & Animations */
        @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Roboto:wght@300;400;700&display=swap');

        :root {
            --neon-blue: #00f3ff;
            --neon-pink: #ff00ff;
            --neon-green: #00ff9d;
            --lane-height: 60px;
        }

        body {
            font-family: 'Roboto', sans-serif;
            background-color: #0f172a;
            color: #e2e8f0;
            overflow-x: hidden;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
        }

        h1, h2, .digital-font {
            font-family: 'Orbitron', sans-serif;
        }

        /* Track Styles */
        .track-container {
            background: repeating-linear-gradient(
                90deg,
                #1e293b,
                #1e293b 40px,
                #253349 40px,
                #253349 80px
            );
            position: relative;
            overflow: hidden;
            /* 终点线不常驻屏内:冲刺段由 .finish-flag 滑入 */
            box-shadow: inset 0 0 20px #000;
        }

        .lane {
            height: var(--lane-height);
            border-bottom: 2px dashed #475569;
            position: relative;
            display: flex;
            align-items: center;
        }

        .lane:last-child {
            border-bottom: none;
        }

        /* Car Element */
        .car {
            position: absolute;
            left: 0;
            transition: transform 0.1s linear; 
            filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.5));
            z-index: 10;
            width: 104px;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .finish-flag {
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            width: 20px;
            background-image: linear-gradient(45deg, #000 25%, transparent 25%), 
                              linear-gradient(-45deg, #000 25%, transparent 25%), 
                              linear-gradient(45deg, transparent 75%, #000 75%), 
                              linear-gradient(-45deg, transparent 75%, #000 75%);
            background-size: 20px 20px;
            background-color: #fff;
            opacity: 0.3;
            z-index: 1;
        }

        .chip-btn {
            transition: all 0.2s;
            user-select: none;
        }
        .chip-btn:active {
            transform: scale(0.95);
        }

        .winner-glow {
            animation: pulse-gold 1s infinite;
        }

        @keyframes pulse-gold {
            0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
            100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
        }

        .modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.85);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 50;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }
        .modal-overlay.active {
            opacity: 1;
            pointer-events: all;
        }

        #confetti-canvas {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            pointer-events: none;
            z-index: 60;
        }

        /* --- NEW ANIMATIONS FOR MENU --- */
        @keyframes float-car {
            0%, 100% { transform: translateY(0px) rotate(0deg); }
            50% { transform: translateY(-8px) rotate(1deg); }
        }
        .animate-float {
            animation: float-car 3s ease-in-out infinite;
        }

        /* Nitro Button Animation */
        @keyframes nitro-shake {
            0% { transform: translate(1px, 1px) rotate(0deg) scale(1.05); }
            10% { transform: translate(-1px, -2px) rotate(-1deg) scale(1.05); }
            20% { transform: translate(-3px, 0px) rotate(1deg) scale(1.05); }
            30% { transform: translate(3px, 2px) rotate(0deg) scale(1.05); }
            40% { transform: translate(1px, -1px) rotate(1deg) scale(1.05); }
            50% { transform: translate(-1px, 2px) rotate(-1deg) scale(1.05); }
            60% { transform: translate(-3px, 1px) rotate(0deg) scale(1.05); }
            70% { transform: translate(3px, 1px) rotate(-1deg) scale(1.05); }
            80% { transform: translate(-1px, -1px) rotate(1deg) scale(1.05); }
            90% { transform: translate(1px, 2px) rotate(0deg) scale(1.05); }
            100% { transform: translate(1px, -2px) rotate(-1deg) scale(1.05); }
        }

        .nitro-btn {
            position: relative;
            background: linear-gradient(135deg, #ff4d00, #ff0055);
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.3);
            text-shadow: 1px 1px 0px rgba(0,0,0,0.3);
            overflow: visible;
        }

        .nitro-btn::before {
            content: '';
            position: absolute;
            top: -5px; left: -5px; right: -5px; bottom: -5px;
            background: linear-gradient(45deg, #ff0000, #ffae00, #ffff00, #ff0000);
            background-size: 400%;
            z-index: -1;
            filter: blur(15px);
            opacity: 0;
            transition: opacity 0.3s ease;
            border-radius: 9999px;
            animation: glowing 20s linear infinite;
        }

        .nitro-btn:hover {
            animation: nitro-shake 0.5s infinite;
            background: linear-gradient(135deg, #ff6a00, #ff0055);
            letter-spacing: 0.1em;
        }

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

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

        /* 镜头跟车:比赛时赛道背景向后飞驰(路很长很长,终点冲刺才入镜) */
        .track-container.scrolling { animation: trackScroll .45s linear infinite; }
        @keyframes trackScroll { from { background-position: 0 0; } to { background-position: -80px 0; } }

        /* --- 发车红绿灯(倒计时最后5秒) --- */
        #race-lights { position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
        #race-lights.hidden { display: none; }
        .rl-box { display: flex; gap: 12px; background: #0b0f1a; border: 2px solid #334155; border-radius: 14px; padding: 10px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.65); }
        .rl-lamp { width: 32px; height: 32px; border-radius: 50%; background: #1e293b; transition: all .15s; }
        .rl-lamp.red { background: #ef4444; box-shadow: 0 0 18px #ef4444; }
        .rl-lamp.yellow { background: #eab308; box-shadow: 0 0 18px #eab308; }
        .rl-lamp.green { background: #22c55e; box-shadow: 0 0 22px #22c55e; }
        #rl-num { font-family: 'Orbitron', sans-serif; font-size: 36px; font-weight: 900; color: #fff; text-shadow: 0 0 14px rgba(255,255,255,.6); }
        #rl-num.go { color: #22c55e; text-shadow: 0 0 20px #22c55e; }

        /* --- 车载视角 FPV(强纵深 + 三幕:phase-launch / phase-mid / phase-sprint) --- */
        #fpv { --vp: 30%; --rs: 1.4s; position: absolute; inset: 0; z-index: 25; overflow: hidden; background: #0e0f14; }
        #fpv.hidden { display: none; }
        .fpv-sky { position: absolute; top: 0; left: 0; right: 0; height: var(--vp); background: linear-gradient(#070b1c 0%, #14204a 66%, #45356e 100%); }
        .fpv-city { position: absolute; bottom: 0; left: 0; right: 0; height: 36%;
            background: radial-gradient(48% 100% at 50% 100%, rgba(255,170,80,.35), transparent 70%),
                        repeating-linear-gradient(90deg, rgba(10,14,30,.9) 0 14px, rgba(20,26,52,.9) 14px 22px, rgba(10,14,30,.9) 22px 40px); }
        /* 透视地面:深透视让跑道扎向地平线(很长很长) */
        .fpv-persp { position: absolute; top: var(--vp); left: -55%; width: 210%; height: 320%;
            transform-origin: top center; transform: perspective(105px) rotateX(78deg);
            background: linear-gradient(90deg, #10361f 0 34.5%, #2c2c35 34.5% 65.5%, #10361f 65.5% 100%); }
        .fpv-line { position: absolute; top: 0; bottom: 0; animation: roadFlow var(--rs) linear infinite; }
        .fpv-line.mid { left: 49.55%; width: 0.9%; background: repeating-linear-gradient(to bottom, #f8fafc 0 46px, transparent 46px 120px); }
        .fpv-line.el { left: 34%; width: 1.1%; background: repeating-linear-gradient(to bottom, #f59e0b 0 60px, #fff 60px 120px); }
        .fpv-line.er { right: 34%; width: 1.1%; background: repeating-linear-gradient(to bottom, #f59e0b 0 60px, #fff 60px 120px); }
        @keyframes roadFlow { from { background-position: 0 0; } to { background-position: 0 120px; } }
        /* 速度分幕:待机慢 → 起步中速 → 拉扯快 → 冲刺极速 */
        #fpv.phase-launch { --rs: .5s; }
        #fpv.phase-mid { --rs: .26s; }
        #fpv.phase-sprint { --rs: .13s; }
        /* 我的车 */
        #fpv-car { position: absolute; bottom: 4%; left: 50%; width: 120px; animation: fpvsway 1.1s ease-in-out infinite; filter: drop-shadow(0 10px 18px rgba(0,0,0,.7)); }
        #fpv-car img { transform: rotate(-90deg); }
        @keyframes fpvsway { 0%,100% { transform: translateX(-56%) rotate(-1.4deg); } 50% { transform: translateX(-44%) rotate(1.4deg); } }
        /* 第一幕:弹射起步 —— 下蹲弹起 + 尾焰 + 镜头狂震 */
        #fpv.phase-launch { animation: camShake .11s linear 10; }
        @keyframes camShake { 0%,100% { transform: translate(0,0); } 25% { transform: translate(2px,-2px); } 75% { transform: translate(-2px,2px); } }
        #fpv.phase-launch #fpv-car { animation: fpvsway 1.1s ease-in-out infinite, launchKick .9s cubic-bezier(.2,.8,.3,1) 1; }
        @keyframes launchKick { 0% { margin-bottom: -14px; } 35% { margin-bottom: 16px; } 100% { margin-bottom: 0; } }
        .fpv-flame { position: absolute; bottom: -16px; left: 50%; width: 26px; height: 34px; transform: translateX(-50%); border-radius: 50% 50% 60% 60%;
            background: radial-gradient(closest-side, #fff, #ffd166 45%, #ff6b1a 78%, transparent); filter: blur(1px); opacity: 0; }
        #fpv.phase-launch .fpv-flame { opacity: .95; animation: flameJet .09s linear infinite alternate; }
        @keyframes flameJet { from { transform: translateX(-50%) scaleY(.75); } to { transform: translateX(-50%) scaleY(1.3); } }
        /* 第二幕:对手车拉扯 —— 前方忽远忽近、左右缠斗,分不清胜负 */
        .fpv-rival { position: absolute; bottom: 30%; left: 50%; width: 110px; opacity: 0; filter: drop-shadow(0 6px 12px rgba(0,0,0,.65)); }
        .fpv-rival img { transform: rotate(-90deg); }
        #fpv.phase-mid .fpv-rival, #fpv.phase-sprint .fpv-rival { opacity: 1; animation: rivalTug 2.6s ease-in-out infinite; }
        @keyframes rivalTug {
            0%   { transform: translate(-88%, 6%)  scale(.44); }
            22%  { transform: translate(-140%, -26%) scale(.3); }
            45%  { transform: translate(-62%, 14%) scale(.56); }
            68%  { transform: translate(-128%, -18%) scale(.34); }
            100% { transform: translate(-88%, 6%)  scale(.44); }
        }
        #fpv.phase-sprint .fpv-rival { animation: rivalDrop 1.6s ease-in forwards; }
        @keyframes rivalDrop { from { transform: translate(-120%, -20%) scale(.34); opacity: 1; } to { transform: translate(-260%, 40%) scale(.7); opacity: 0; } }
        /* 第三幕:格子旗门从消失点冲到脸上 + 提亮 */
        .fpv-gate { position: absolute; top: calc(var(--vp) + 1%); left: 50%; width: 210px; height: 60px; opacity: 0;
            transform: translateX(-50%) scale(.03);
            background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0 / 15px 15px; border: 3px solid #e2e8f0; border-radius: 4px;
            box-shadow: 0 0 18px rgba(255,255,255,.35); }
        #fpv.phase-sprint .fpv-gate { opacity: 1; animation: gateRush 1.55s cubic-bezier(.55,0,.9,.45) forwards; }
        @keyframes gateRush { from { transform: translateX(-50%) scale(.03) translateY(0); } to { transform: translateX(-50%) scale(4) translateY(150%); opacity: 1; } }
        #fpv.phase-sprint .fpv-persp { filter: brightness(1.18); }
        /* 侧向速度线(冲刺增强) */
        .fpv-speedlines { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
        .fpv-speedlines::before, .fpv-speedlines::after { content: ""; position: absolute; top: 0; bottom: 0; width: 18%;
            background: repeating-linear-gradient(to bottom, rgba(255,255,255,.28) 0 26px, transparent 26px 90px); animation: roadFlow .1s linear infinite; }
        .fpv-speedlines::before { left: 0; transform: skewY(24deg); }
        .fpv-speedlines::after { right: 0; transform: skewY(-24deg); }
        #fpv.phase-sprint .fpv-speedlines { opacity: .7; }
        #fpv.phase-launch .fpv-speedlines { opacity: .4; }
        .fpv-hud { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-family: 'Orbitron', sans-serif; font-size: 12px; letter-spacing: 3px; color: #93c5fd; text-shadow: 0 0 8px rgba(59,130,246,.7); z-index: 2; }
        #fpv.finish::after { content: ""; position: absolute; inset: 0; background: #fff; animation: fpvflash .35s ease-out forwards; }
        @keyframes fpvflash { from { opacity: .95; } to { opacity: 0; } }
        #fpv.fadeout { animation: fpvOut .4s ease forwards; }   /* 冲刺切回第三人称 */
        @keyframes fpvOut { to { opacity: 0; } }

        @media (max-width: 768px) {
            :root { --lane-height: 50px; }
            .car { width: 82px; }
            /* 修复:body h-screen+overflow-hidden 锁死滚动,矮视口下投注按钮被推出屏幕够不着 → 手机整页自然滚动 */
            body { height: auto !important; min-height: 100vh; overflow-y: auto !important; }
            #main-game-ui { height: auto !important; min-height: 100vh; }
            #main-game-ui main { overflow: visible !important; }
        }