        :root {
            --bg: #0f0f23;
            --panel: #0a0a1a;
            --surface: #141428;
            --white: #fcfcfc;
            --green: #58d854;
            --yellow: #ffd700;
            --gray: #888;
            --border: #333;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        /* Override NES.css global resets */
        label { display: inline; margin-bottom: 0; }
        body {
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            background: var(--bg);
            color: var(--white);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            padding: 0;
        }
        #app {
            width: 100vw;
            height: 100vh;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .screen {
            display: none; position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            flex-direction: column;
            align-items: center; justify-content: center;
            padding: 20px;
            overflow-y: auto;
        }
        .screen.active { display: flex; }

        /* ===== Title ===== */
        #title-screen h1 {
            font-size: clamp(24px, 5vw, 40px);
            color: var(--green);
            text-shadow: 3px 3px 0 #1a5a1a, 6px 6px 0 rgba(0,0,0,0.4);
            margin-bottom: 12px; text-align: center;
            animation: pulse 2s ease-in-out infinite;
        }
        #title-screen .subtitle {
            font-size: clamp(8px, 1.8vw, 12px);
            color: var(--gray); margin-bottom: 40px;
        }
        @keyframes pulse {
            0%,100% { transform: scale(1); }
            50% { transform: scale(1.04); }
        }
        .title-slime-container {
            position: relative; width: 100px; height: 90px;
            margin-bottom: 30px;
        }
        .title-slime {
            width: 80px; height: 60px;
            background: var(--green);
            border-radius: 50% 50% 42% 42%;
            position: absolute; bottom: 10px; left: 10px;
            animation: slimeBounce 0.7s ease-in-out infinite;
        }
        .title-slime::before {
            content: ''; position: absolute;
            width: 12px; height: 16px;
            background: white; border-radius: 50%;
            top: 14px; left: 18px;
            box-shadow: 26px 0 0 0 white;
        }
        .title-slime::after {
            content: ''; position: absolute;
            width: 7px; height: 10px;
            background: var(--bg); border-radius: 50%;
            top: 16px; left: 22px;
            box-shadow: 26px 0 0 0 var(--bg);
        }
        .title-shadow {
            position: absolute; bottom: 0; left: 10px;
            width: 80px; height: 12px;
            background: rgba(0,0,0,0.35);
            border-radius: 50%;
            animation: shadowPulse 0.7s ease-in-out infinite;
        }
        @keyframes slimeBounce {
            0%,100% { transform: translateY(0) scaleX(1) scaleY(1); }
            20% { transform: translateY(-25px) scaleX(0.88) scaleY(1.12); }
            50% { transform: translateY(0) scaleX(1.14) scaleY(0.86); }
            70% { transform: translateY(-8px) scaleX(0.95) scaleY(1.05); }
        }
        @keyframes shadowPulse {
            0%,100% { transform: scaleX(1); opacity: 0.35; }
            20% { transform: scaleX(0.7); opacity: 0.2; }
            50% { transform: scaleX(1.1); opacity: 0.4; }
        }

        /* ===== Buttons ===== */
        .btn {
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            font-size: 12px; padding: 14px 28px;
            background: var(--panel); color: var(--white);
            border: 3px solid var(--white);
            cursor: pointer; text-transform: uppercase;
            outline: none; transition: all 0.1s;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
        }
        .btn:hover { background: var(--white); color: var(--bg); }
        .btn:active { transform: scale(0.95); }
        .btn.primary { border-color: var(--green); color: var(--green); }
        .btn.primary:hover { background: var(--green); color: var(--bg); }
        .blink { animation: blink 1s step-end infinite; }
        @keyframes blink { 50% { opacity: 0; } }

        /* ===== Setup ===== */
        #setup-screen {
            justify-content: flex-start;
            padding-top: 24px; gap: 12px;
            overflow-y: auto;
        }
        #setup-screen h2 {
            font-size: clamp(14px, 3vw, 20px);
            color: var(--yellow);
            text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
            margin-bottom: 8px;
        }
        .setup-row {
            display: flex; align-items: center;
            gap: 12px; width: 100%; max-width: 480px;
        }
        .setup-label {
            font-size: 9px; min-width: 100px; text-align: right;
        }
        .count-controls {
            display: flex; align-items: center; gap: 10px;
        }
        .count-btn {
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            font-size: 18px; width: 36px; height: 36px;
            background: var(--panel); color: var(--white);
            border: 3px solid var(--white);
            cursor: pointer; display: flex;
            align-items: center; justify-content: center;
        }
        .count-btn:hover { background: var(--white); color: var(--bg); }
        #player-count, #race-count, #time-input {
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            font-size: 16px; width: 76px; text-align: center;
            background: var(--panel); color: var(--white);
            border: 2px solid var(--border); outline: none;
            padding: 6px 2px; -moz-appearance: textfield;
        }
        #player-count::-webkit-inner-spin-button,
        #player-count::-webkit-outer-spin-button,
        #race-count::-webkit-inner-spin-button,
        #race-count::-webkit-outer-spin-button,
        #time-input::-webkit-inner-spin-button,
        #time-input::-webkit-outer-spin-button { -webkit-appearance: none; }
        #player-count:focus, #time-input:focus { border-color: var(--white); }
        .player-list {
            width: 100%; max-width: 480px;
            display: flex; flex-direction: column; gap: 6px;
        }
        .player-row {
            display: flex; align-items: center; gap: 8px;
        }
        .color-dot {
            width: 14px; height: 14px; border-radius: 50%;
            border: 2px solid rgba(255,255,255,0.5); flex-shrink: 0;
        }
        .player-num { font-size: 9px; min-width: 20px; }
        .sd-input {
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            font-size: 9px; padding: 7px 10px;
            background: #0a0a0a; color: var(--white);
            border: 2px solid #444; outline: none;
            flex: 1; max-width: 200px;
        }
        .sd-input:focus { border-color: var(--white); }
        .sd-checkbox {
            display: flex; align-items: center; gap: 10px;
            cursor: pointer; font-size: 9px; user-select: none;
        }
        .sd-checkbox input { display: none; }
        .sd-check-box {
            width: 18px; height: 18px;
            border: 3px solid #666; background: var(--panel);
            position: relative; flex-shrink: 0;
        }
        .sd-checkbox input:checked + .sd-check-box {
            border-color: var(--green);
        }
        .sd-checkbox input:checked + .sd-check-box::after {
            content: ''; position: absolute;
            top: 2px; left: 2px; right: 2px; bottom: 2px;
            background: var(--green);
        }
        .name-scroll {
            max-height: 200px; overflow-y: auto; width: 100%;
            display: flex; flex-direction: column; gap: 4px;
        }
        .name-scroll::-webkit-scrollbar { width: 6px; }
        .name-scroll::-webkit-scrollbar-track { background: var(--panel); }
        .name-scroll::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
        .unit { font-size: 9px; color: var(--gray); }
        .select-info {
            font-size: 9px; color: var(--yellow); line-height: 1.8;
            text-align: center; padding: 14px;
            border: 2px dashed var(--border);
            width: 100%; max-width: 480px;
        }

        /* ===== Draw screen ===== */
        #select-screen h2 {
            font-size: clamp(14px, 3vw, 22px);
            color: var(--yellow);
            text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
            margin-bottom: 6px;
        }
        .draw-sub { font-size: 10px; color: var(--gray); margin-bottom: 12px; }
        .draw-grid {
            display: grid; grid-template-columns: repeat(4, 1fr);
            gap: 10px; width: 100%; max-width: 460px; margin: 8px 0;
        }
        .draw-card {
            display: flex; align-items: center; gap: 8px;
            padding: 10px 12px; background: var(--panel);
            border: 3px solid; font-size: 11px;
            animation: cardPop 0.35s ease-out both;
        }
        .draw-dot {
            width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
        }
        @keyframes cardPop {
            from { transform: scale(0) rotate(-10deg); opacity: 0; }
            to { transform: scale(1) rotate(0); opacity: 1; }
        }

        /* ===== Game ===== */
        #game-screen { 
            padding: 0;
            background: #000;
            overflow: hidden;
        }
        #race-canvas {
            width: 100vw;
            height: calc(100vw * 480 / 800);
            max-height: 100vh;
            max-width: calc(100vh * 800 / 480);
            image-rendering: pixelated;
            image-rendering: crisp-edges;
            object-fit: contain;
            transition: transform 0.15s ease-out;
        }
        body:fullscreen #race-canvas,
        body:-webkit-full-screen #race-canvas,
        body:-moz-full-screen #race-canvas {
            width: 100vw;
            height: 100vh;
            max-width: 100vw;
            max-height: 100vh;
        }

        /* ===== Results ===== */
        #result-screen { gap: 16px; }
        #result-screen h2 {
            font-size: clamp(16px, 3vw, 26px);
            color: var(--yellow);
            text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
        }
        #finish-snapshot {
            max-width: 520px; width: 100%;
            border: 3px solid var(--yellow);
            border-radius: 8px; overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.5);
        }
        #finish-snapshot img {
            width: 100%; display: block;
        }
        .results-list {
            width: 100%; max-width: 520px;
            max-height: 50vh; overflow-y: auto;
            display: flex; flex-direction: column; gap: 6px;
        }
        .results-list::-webkit-scrollbar { width: 6px; }
        .results-list::-webkit-scrollbar-track { background: var(--panel); }
        .results-list::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
        .res-row {
            display: flex; align-items: center; gap: 10px;
            padding: 10px 14px; background: var(--panel);
            border: 2px solid var(--border); font-size: 10px;
        }
        .res-row.w { border-color: var(--yellow); background: rgba(255,215,0,0.06); }
        .res-row.dns { opacity: 0.4; }
        .res-rank { min-width: 36px; font-weight: bold; }
        .res-rank.g { color: #ffd700; }
        .res-rank.s { color: #c0c0c0; }
        .res-rank.b { color: #cd7f32; }
        .res-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
        .res-name { flex: 1; }
        .res-time { color: #aaa; min-width: 80px; text-align: right; }
        .res-stats {
            font-size: 8px; color: #888;
            display: flex; gap: 8px; margin-left: auto;
        }
        .res-stats span { white-space: nowrap; }
        .btn-group { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
        .btn-mobile { display: none; }
        .btn-full { display: inline; }

        /* ===== Mobile Responsive ===== */
        @media (max-width: 768px) {
            .screen { padding: 10px; }
            
            .btn-mobile { display: inline; }
            .btn-full { display: none; }
            
            #title-screen h1 {
                font-size: 32px;
            }
            .subtitle { font-size: 8px; }
            
            #setup-screen { padding-top: 10px; gap: 8px; }
            #setup-screen h2 { font-size: 14px; }
            
            .setup-row { flex-wrap: wrap; justify-content: center; }
            .setup-label { min-width: auto; text-align: center; width: 100%; font-size: 8px; }
            
            .count-btn { width: 32px; height: 32px; font-size: 16px; }
            #player-count, #time-input { font-size: 12px; padding: 8px; }
            
            .player-inputs { gap: 6px; }
            .player-row { font-size: 8px; gap: 6px; }
            .sd-input { font-size: 9px; padding: 6px; }
            
            .btn { padding: 10px 16px; font-size: 9px; }
            .btn-group { gap: 8px; }
            
            .draw-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
            .draw-card { font-size: 9px; padding: 8px; }
            
            #result-screen { gap: 12px; padding: 10px; }
            #result-screen h2 { font-size: 18px; }
            
            #finish-snapshot { max-width: 100%; }
            
            .results-list { max-width: 100%; }
            .res-row { padding: 8px 10px; font-size: 8px; gap: 6px; }
            .res-rank { min-width: 28px; font-size: 8px; }
            .res-dot { width: 10px; height: 10px; }
            .res-name { font-size: 9px; }
            .res-time { min-width: 60px; font-size: 8px; }
            .res-stats { font-size: 7px; gap: 4px; }
        }

        @media (max-width: 480px) {
            #title-screen h1 { font-size: 24px; }
            .subtitle { font-size: 7px; }
            
            .btn { padding: 8px 12px; font-size: 8px; }
            
            .setup-label { font-size: 7px; }
            .count-btn { width: 28px; height: 28px; font-size: 14px; }
            
            .draw-card { font-size: 8px; padding: 6px; }
            
            .res-row { font-size: 7px; padding: 6px 8px; }
            .res-rank { font-size: 7px; min-width: 24px; }
            .res-name { font-size: 8px; }
            .res-time { font-size: 7px; }
        }

        @media (max-height: 500px) {
            #setup-screen { padding-top: 10px; gap: 6px; }
            .btn { padding: 10px 20px; font-size: 10px; }
        }

        /* ===== Fullscreen Button ===== */
        #fullscreen-btn {
            position: fixed;
            top: 20px;
            right: 20px;
            width: 60px;
            height: 44px;
            background: var(--panel);
            border: 3px solid var(--border);
            cursor: pointer;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            font-weight: bold;
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            color: var(--white);
            transition: all 0.2s;
        }
        #fullscreen-btn:hover {
            background: var(--surface);
            border-color: var(--white);
            transform: scale(1.1);
        }
        #fullscreen-btn:active {
            transform: scale(0.95);
        }
        
        /* ===== Language Button ===== */
        #lang-btn {
            position: fixed;
            top: 20px;
            right: 90px;
            width: 50px;
            height: 44px;
            background: var(--panel);
            border: 3px solid var(--border);
            cursor: pointer;
            z-index: 1000;
            display: none; /* Hidden by default, shown only on title screen */
            align-items: center;
            justify-content: center;
            font-size: 11px;
            font-family: 'Press Start 2P', 'DungGeunMo', monospace;
            color: var(--white);
            transition: all 0.2s;
        }
        #lang-btn:hover {
            background: var(--surface);
            border-color: var(--yellow);
            color: var(--yellow);
            transform: scale(1.1);
        }
        #lang-btn:active {
            transform: scale(0.95);
        }
        
        /* Hide fullscreen button on mobile */
        @media (max-width: 768px) {
            #fullscreen-btn {
                display: none;
            }
            #lang-btn {
                right: 20px; /* Move to right when fullscreen btn is hidden */
            }
        }

        /* ===== Version Label ===== */
        .version-label {
            font-size: 9px;
            color: #444;
            letter-spacing: 1px;
            margin-top: 12px;
        }

        /* ===== Visitor Counter ===== */
        .visitor-counter {
            position: absolute;
            bottom: 20px;
            opacity: 0.7;
            transition: opacity 0.2s;
        }
        .visitor-counter:hover {
            opacity: 1;
        }
        .visitor-counter img {
            height: 20px;
            image-rendering: auto;
        }
