/* ./css/arcadeStyle.css */
    
        /*
         * arcadeStyle.css
         * ----------------
         * This file contains the arcade UI styles for the main game screen,
         * setup pages, selection cards, modals, responsive rules, and mobile controls.
         *
         * Recommended future split into 3-5 logical CSS files:
         *   1) arcadeStyle.variables.css  - theme variables and global resets
         *   2) arcadeStyle.layout.css     - page layout, canvas, HUD, and board containers
         *   3) arcadeStyle.components.css - cards, buttons, menus, forms, modals
         *   4) arcadeStyle.settings.css   - settings modal, tabs, user/stats UI
         *   5) arcadeStyle.mobile.css     - responsive rules and mobile control overlays
         *
         * NOTE: No style changes were made. Only comments, headers, and split markers added.
         */
        
        /* ---------- ORIGINAL arcadeStyle.css + ENHANCED THEMES (FULLY PRESERVED) ---------- */
        :root {
            --p1-color: #4a90e2;
            --p2-color: #e74c3c;
            --p3-color: #f1c40f;
            --p4-color: #2ecc71;
            --background-dark: #1a1c2c;
            --background-glass: rgba(255, 255, 255, 0.07);
            --background-glass-heavy: rgba(0, 0, 0, 0.85);
            --border-glass: rgba(255, 255, 255, 0.15);
            --text-color: #ffffff;
            --text-muted: #bdc3c7;
            --transition-standard: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            --transition-smooth: 0.4s ease-out;
        }

        body { 
            margin: 0; 
            overflow: hidden; 
            background: var(--background-dark); 
            font-family: 'Rubik', sans-serif; 
            width: 100vw; 
            height: 100vh; 
            color: var(--text-color);
        }

        .game-container { position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
        
        /* Standard canvas styling */
        canvas { background: #111; display: block; }
        
        #gameCanvas {
            z-index: 1; /* Ensure it sits behind UI but visible */
        }
        
        .ui-layer { 
            position: absolute; 
            top: 0; left: 0; 
            width: 100%; height: 100%; 
            pointer-events: none; 
            display: flex; flex-direction: column; 
        }

        .hud { 
            display: grid; 
            grid-template-columns: 1fr auto 1fr; 
            grid-template-rows: auto auto;
            align-items: center;
            padding: 20px; 
            font-size: 24px; 
            color: var(--text-color); 
            text-shadow: 2px 2px 0 #000; 
            width: 100%; 
            box-sizing: border-box;
            z-index: 50;
        }
        .p1-score { color: var(--p1-color); font-weight: bold; text-align: left; }
        .p2-score { color: var(--p2-color); font-weight: bold; text-align: right; }
        .p3-score { color: var(--p3-color); font-weight: bold; text-align: left; }
        .p4-score { color: var(--p4-color); font-weight: bold; text-align: right; }

        #timer-display {
            grid-column: 2;
            grid-row: 1 / span 2;
            color: var(--p3-color);
            font-family: 'Secular One', sans-serif;
        }

        .setup-screen {
            position: absolute;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(0,0,0,0.95);
            display: flex; flex-direction: column;
            justify-content: center; align-items: center;
            color: var(--text-color);
            pointer-events: all;
            z-index: 100;
            overflow: hidden; 
        }
        .setup-form { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background: transparent; z-index: 1; position: relative; overflow: hidden; }

        .setup-step {
            display: none;
            flex-direction: column;
            align-items: center;
            width: 100%;
            height: 100%;
            max-width: 1400px;
            animation: fadeIn 0.4s ease-out;
            overflow-y: auto;
            overflow-x: hidden;
            scrollbar-width: thin;
            scrollbar-color: var(--p3-color) transparent;
            justify-content: flex-start;
        }
        .setup-step.active { display: flex; }
        
        /* NOTE: .setup-form h1 appears twice in this file. Merge the two declarations into one
         * place or keep the second one only if it is intended as a follow-up style override.
         */
        .setup-form h1 {
            position: sticky;
            top: 0;
            z-index: 110;       
            width: 100%;
            margin: 0;
            padding: 20px 10px;
            color: var(--p3-color);
            font-family: 'Secular One', sans-serif;
            font-size: clamp(1.5rem, 6vw, 4rem);
            letter-spacing: 2px;
            text-align: center;          
            animation: titleFloat 4s ease-in-out infinite;
        }

        .form-group { margin-bottom: 30px; text-align: center; width: 100%; }
        label { display: block; margin-bottom: 8px; font-weight: bold; font-size: 0.9rem; text-transform: uppercase; color: var(--text-muted); }
        input, select { 
            width: 100%; padding: 12px; font-size: 18px; border-radius: 12px; 
            border: 1px solid var(--border-glass); 
            background: rgba(0, 0, 0, 0.4); 
            color: var(--text-color); 
            box-sizing: border-box; 
            backdrop-filter: blur(5px);
            text-align: center;
        }
        
        button:not(.back-btn) { 
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            color: var(--text-color);
            -webkit-text-fill-color: var(--text-color);
            padding: 12px 35px; 
            font-size: clamp(14px, 4vw, 20px); 
            font-weight: bold; 
            border-radius: 30px; 
            cursor: pointer; 
            min-width: 160px; 
            transition: var(--transition-standard); 
            text-transform: uppercase; 
            letter-spacing: 1px;
            font-family: 'Secular One', sans-serif;
            box-shadow: -2px -2px 8px rgba(74, 144, 226, 0.15),
                        2px -2px 8px rgba(231, 76, 60, 0.15),
                        -2px 2px 8px rgba(241, 196, 15, 0.15),
                        2px 2px 8px rgba(46, 204, 113, 0.15);
        }

        button:not(.back-btn):hover { 
            background: rgba(255, 255, 255, 0.15);
            border-color: rgba(255, 255, 255, 0.5);
            transform: scale(1.02); 
            box-shadow: -4px -4px 15px rgba(74, 144, 226, 0.3),
                        4px -4px 15px rgba(231, 76, 60, 0.3),
                        -4px 4px 15px rgba(241, 196, 15, 0.3),
                        4px 4px 15px rgba(46, 204, 113, 0.3);
        }

        button:active { transform: scale(0.98); }
        button.secondary { background: rgba(255,255,255,0.05); }
        
        @keyframes gradientText { to { background-position: 200% center; } }
        
        .player-section { padding: 20px; margin-bottom: 20px; background: rgba(255,255,255,0.05); border-radius: 12px; width: 100%; max-width: 800px; }
        .hidden { display: none !important; }
        
        .winner-modal { 
            position: absolute; 
            top: 50%; 
            left: 50%; 
            transform: translate(-50%, -50%); 
            background: var(--background-glass-heavy); 
            color: var(--text-color); 
            padding: 40px; 
            border-radius: 12px; 
            text-align: center; 
            display: none; 
            z-index: 200; 
            box-shadow: 0 0 50px rgba(255, 215, 0, 0.8); 
            border: 1px solid var(--border-glass);
            width: 80%;
            max-width: 450px;
        }
        .winner-modal h1 { font-family: 'Secular One', sans-serif; margin: 0 0 20px; font-size: clamp(2rem, 8vw, 3rem); }
        .winner-modal.active { display: block; animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
        
        @keyframes popIn {
            from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
            to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
        }

        .leaderboard-container {
            margin: 20px 0;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            padding: 15px;
            border: 1px solid var(--border-glass);
            text-align: right;
            direction: rtl;
        }
        .leaderboard-container h3 {
            margin: 0 0 10px 0;
            font-size: 1.2rem;
            color: var(--p3-color);
            text-align: center;
        }
        .leaderboard-list {
            display: flex;
            flex-direction: column;
            gap: 5px;
            max-height: 180px;
            overflow-y: auto;
        }
        .leaderboard-entry {
            display: flex;
            justify-content: space-between;
            padding: 6px 12px;
            background: rgba(0,0,0,0.3);
            border-radius: 8px;
            font-size: 0.95rem;
        }
        .leaderboard-entry.highlight {
            background: rgba(241, 196, 15, 0.25);
            border: 1px solid var(--p3-color);
            font-weight: bold;
            animation: pulseGlow 1.5s infinite;
        }
        @keyframes pulseGlow {
            0%, 100% { box-shadow: 0 0 5px rgba(241, 196, 15, 0.2); }
            50% { box-shadow: 0 0 15px rgba(241, 196, 15, 0.5); }
        }

        #encyclopedia-ui {
            position: absolute;
            top: 50%; left: 50%; transform: translate(-50%, -50%);
            width: 90%; height: 85%; background: rgba(0,0,0,0.92);
            border: 3px solid #f1c40f; border-radius: 40px;
            padding: 40px; display: flex; flex-direction: column;
            z-index: 150; backdrop-filter: blur(25px); pointer-events: all;
            box-shadow: 0 0 100px rgba(0,0,0,0.8);
            animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            direction: rtl;
        }
        .ency-list::-webkit-scrollbar { width: 8px; }
        .ency-list::-webkit-scrollbar-thumb { background: #f1c40f; border-radius: 10px; }
        .entity-item {
            padding: 15px 20px;
            background: rgba(255,255,255,0.07);
            border: 2px solid rgba(255,255,255,0.1);
            border-radius: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: white;
        }
        .ency-filter-btn {
            padding: 10px 20px;
            background: rgba(255,255,255,0.07);
            border: 1px solid rgba(255,255,255,0.1);
            color: white !important;
            border-radius: 25px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1.1rem;
            min-width: unset !important;
            margin-top: 0 !important;
            box-shadow: none !important;
            display: flex !important;
            align-items: center;
            justify-content: center;
            -webkit-text-fill-color: white !important;
            background-image: none !important;
            animation: none !important;
        }
        .ency-filter-btn:hover { background: rgba(255,255,255,0.15); transform: scale(1.05); }
        .ency-filter-btn.active {
            background: #f1c40f !important;
            color: black !important;
            -webkit-text-fill-color: black !important;
            border-color: #f1c40f;
            font-weight: bold;
        }

        .mode-selection-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 15px;
        }
        .mode-card {
            background: rgba(0,0,0,0.2);
            border: 2px solid var(--border-glass);
            border-radius: 8px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
            min-height: 180px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .mode-card:hover {
            border-color: var(--p3-color);
            background: rgba(255,255,255,0.05);
            transform: translateY(-3px);
        }
        .mode-card.selected {
            border-color: #2ecc71;
            background: rgba(46, 204, 113, 0.15);
            box-shadow: 0 0 10px rgba(46, 204, 113, 0.2);
        }
        .mode-icon-container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100px;
            margin-bottom: 10px;
        }
        .mode-icon-preview {
            width: 96px;
            height: 96px;
            background-repeat: no-repeat;
            background-size: 384px auto;
            image-rendering: pixelated;
            margin-left: -30px;
        }
        .mode-icon-preview:first-child { margin-left: 0; }
        
        @keyframes walkDown {
            from { background-position: 0 0; }
            to { background-position: -384px 0; }
        }
        
        .mode-card .title { font-weight: bold; font-size: 1.1rem; }
        .mode-card .desc { font-size: 0.8rem; color: var(--text-muted); }

        .type-selection-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 30px;
            max-width: 1000px;
            margin: 0 auto;
        }
        .type-card {
            background: rgba(0,0,0,0.2);
            border: 2px solid var(--border-glass);
            border-radius: 12px;
            padding: 30px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }
        .type-card:hover {
            border-color: var(--p3-color);
            background: rgba(255,255,255,0.05);
            transform: translateY(-5px);
        }
        .type-card.selected {
            border-color: #f1c40f;
            background: rgba(241, 196, 15, 0.15);
            box-shadow: 0 0 20px rgba(241, 196, 15, 0.2);
        }
        .type-card h2 { margin: 0 0 10px 0; color: #fff; font-size: clamp(1.2rem, 4vw, 1.8rem); }
        .type-card p { margin: 0; color: #ccc; }

        .hero-selection-grid {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin: auto;
            width: 100%;
            flex-wrap: wrap;
        }
        .hero-frame {
            position: relative;
            width: 220px;
            height: 250px;
            background: rgba(0,0,0,0.4);
            border: 4px solid #444;
            border-radius: 15px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }
        .hero-frame h3 { margin: 0; font-size: 1.5rem; text-transform: uppercase; color: white; text-shadow: 2px 2px 0 #000; }
        .hero-frame p { margin: 5px 0 0; font-size: 0.9rem; color: #ccc; }
        
        .hero-frame.p1-active { border-color: #4a90e2; box-shadow: 0 0 15px rgba(74, 144, 226, 0.5); }
        .hero-frame.p2-active { border-color: #e74c3c; box-shadow: 0 0 15px rgba(231, 76, 60, 0.5); }
        .hero-frame.p3-active { border-color: #f1c40f; box-shadow: 0 0 15px rgba(241, 196, 15, 0.5); }
        .hero-frame.p4-active { border-color: #2ecc71; box-shadow: 0 0 15px rgba(46, 204, 113, 0.5); }
        
        .p-badge {
            position: absolute;
            padding: 5px 10px;
            border-radius: 5px;
            font-weight: bold;
            font-size: 0.9rem;
            color: white;
            display: none;
            text-shadow: 1px 1px 0 #000;
            z-index: 10;
        }
        .p1-badge { top: 10px; left: 10px; background: #4a90e2; }
        .p2-badge { top: 10px; right: 10px; background: #e74c3c; }
        .p3-badge { bottom: 10px; left: 10px; background: #f1c40f; }
        .p4-badge { bottom: 10px; right: 10px; background: #2ecc71; }
        
        .hero-frame.p1-active .p1-badge,
        .hero-frame.p2-active .p2-badge,
        .hero-frame.p3-active .p3-badge,
        .hero-frame.p4-active .p4-badge { display: block; }

        .selection-instructions {
            display: flex;
            justify-content: space-around;
            width: 100%;
            max-width: 800px;
            margin-bottom: 10px;
            font-size: 1.1rem;
            color: #ccc;
            background: rgba(0,0,0,0.5);
            padding: 10px;
            border-radius: 8px;
            flex-wrap: wrap;
        }
        .p1-instr { color: #4a90e2; font-weight: bold; }
        .p2-instr { color: #e74c3c; font-weight: bold; }
        .p3-instr { color: #f1c40f; font-weight: bold; }
        .p4-instr { color: #2ecc71; font-weight: bold; }
        .error-msg { color: #f1c40f; font-weight: bold; height: 30px; margin-top: 10px; text-shadow: 1px 1px 0 #000; font-size: 1.2rem; }

        .button-row {
            display: flex;
            justify-content: center;
            gap: 20px;
            width: 100%;
            margin-top: 30px;
            flex-wrap: wrap;
        }
        .button-row button { margin-top: 0; }

        .hero-selection-sprite {
            width: 110px;
            height: 110px;
            background-repeat: no-repeat;
            background-size: 400% auto;
            image-rendering: pixelated;
            margin-bottom: 10px;
        }
        @keyframes heroWalk {
            from { background-position: 0 0; }
            to { background-position: -512px 0; }
        }

        /* DUPLICATE SECTION ALERT
         * .setup-screen is defined earlier in this file for the setup screen container.
         * This second block is a good split point: keep layout and component styles together,
         * and move the animated setup background to a separate theme or screen-specific CSS file.
         */
        .setup-screen {
            background: linear-gradient(125deg, #1a1a1a, #2c3e50, #000000);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            perspective: 1000px;
            overflow: hidden;
        }
        
        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .parallax-layer {
            position: absolute;
            top: -10%; left: -10%; right: -10%; bottom: -10%;
            background-image: 
                radial-gradient(circle at 20% 30%, rgba(74, 144, 226, 0.15) 0%, transparent 20%),
                radial-gradient(circle at 80% 70%, rgba(231, 76, 60, 0.15) 0%, transparent 20%),
                radial-gradient(circle at 40% 80%, rgba(241, 196, 15, 0.15) 0%, transparent 20%),
                radial-gradient(circle at 70% 20%, rgba(46, 204, 113, 0.15) 0%, transparent 20%);
            z-index: 0;
            pointer-events: none;
            transition: transform 0.1s linear;
        }

        .setup-form h1 {
            font-family: 'Secular One', sans-serif;
            font-size: clamp(2rem, 8vw, 4.5rem);
            color: #f1c40f;
            text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
            margin-bottom: 40px;
            letter-spacing: 2px;
        }
        @keyframes titleFloat {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }

        /* SECTION: selection cards, mode cards, and hero cards
         * These shared card styles are a strong candidate for a combined component CSS file.
         * Consider moving the shared glass card design into a separate cards/components stylesheet.
         */
        .type-card, .mode-card, .hero-frame {
            border-radius: 30px !important;
            background: rgba(255, 255, 255, 0.05) !important;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1) !important;
            box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
            overflow: hidden;
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
            position: relative;
        }

        .type-card::after, .mode-card::after, .hero-frame::after {
            content: "";
            position: absolute;
            top: 0; left: -100%; width: 100%; height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
            transition: 0.5s;
            pointer-events: none;
            transform: skewX(-15deg);
        }
        .type-card:hover::after, .mode-card:hover::after, .hero-frame:hover::after {
            left: 100%;
            transition: 0.7s;
        }

        .type-card:hover, .mode-card:hover {
            transform: translateY(-5px) scale(1.03) !important;
            border-color: rgba(255,255,255,0.5) !important;
            box-shadow: 0 15px 35px rgba(0,0,0,0.5), inset 0 0 20px rgba(255,255,255,0.05);
        }

        .type-card.selected, .mode-card.selected {
            border: 2px solid rgba(255, 255, 255, 0.8) !important;
            background: rgba(255, 255, 255, 0.2) !important;
            box-shadow: -4px -4px 20px rgba(74, 144, 226, 0.5),
                        4px -4px 20px rgba(231, 76, 60, 0.5),
                        -4px 4px 20px rgba(241, 196, 15, 0.5),
                        4px 4px 20px rgba(46, 204, 113, 0.5) !important;
        }
        @keyframes selectedPulse {
            0% { box-shadow: 0 0 15px currentColor; }
            50% { box-shadow: 0 0 30px currentColor, 0 0 10px currentColor inset; }
            100% { box-shadow: 0 0 15px currentColor; }
        }

        .ripple {
            position: absolute; border-radius: 50%; transform: scale(0);
            animation: ripple 0.6s linear; background-color: rgba(255, 255, 255, 0.4); pointer-events: none;
        }
        @keyframes ripple { to { transform: scale(4); opacity: 0; } }

        @keyframes configGlow {
            0%, 100% { 
                box-shadow: 
                    0 0 20px rgba(74, 144, 226, 0.3),
                    0 0 20px rgba(231, 76, 60, 0.3),
                    0 0 20px rgba(241, 196, 15, 0.3),
                    0 0 20px rgba(46, 204, 113, 0.3);
            }
            25% { 
                box-shadow: 
                    0 0 30px rgba(74, 144, 226, 0.6),
                    0 0 20px rgba(231, 76, 60, 0.2),
                    0 0 20px rgba(241, 196, 15, 0.2),
                    0 0 20px rgba(46, 204, 113, 0.2);
            }
            50% { 
                box-shadow: 
                    0 0 20px rgba(74, 144, 226, 0.2),
                    0 0 30px rgba(231, 76, 60, 0.6),
                    0 0 20px rgba(241, 196, 15, 0.2),
                    0 0 20px rgba(46, 204, 113, 0.2);
            }
            75% { 
                box-shadow: 
                    0 0 20px rgba(74, 144, 226, 0.2),
                    0 0 20px rgba(231, 76, 60, 0.2),
                    0 0 30px rgba(241, 196, 15, 0.6),
                    0 0 20px rgba(46, 204, 113, 0.2);
            }
        }

        .back-btn {
            position: absolute;
            bottom: 30px;
            left: 5%;
            transform: translateX(-50%);
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.4);
            border: 2px solid rgba(255, 255, 255, 0.2);
            color: rgba(255, 255, 255, 0.8);
            font-size: 30px;
            padding: 0;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            z-index: 90;
            backdrop-filter: blur(4px);
            min-width: 0;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        }
        .back-btn:hover {
            background: rgba(231, 76, 60, 0.9);
            border-color: #c0392b;
            color: white;
            transform: translateX(-50%) scale(1.15) rotate(-10deg);
            box-shadow: 0 0 25px rgba(231, 76, 60, 0.6);
        }
        
        #p1-name, #p2-name, #p3-name, #p4-name { text-align: center; }
        #p1-name { border: 2px solid var(--p1-color); color: var(--p1-color); background: rgba(74, 144, 226, 0.1); }
        #p2-name { border: 2px solid var(--p2-color); color: var(--p2-color); background: rgba(231, 76, 60, 0.1); }
        #p3-name { border: 2px solid var(--p3-color); color: var(--p3-color); background: rgba(241, 196, 15, 0.1); }
        #p4-name { border: 2px solid var(--p4-color); color: var(--p4-color); background: rgba(46, 204, 113, 0.1); }

        #introCanvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            pointer-events: none;
        }

        .intro-layout {
            display: flex;
            width: 100%;
            max-width: 1000px;
            align-items: center;
            justify-content: center;
            gap: 40px;
            direction: rtl;
            padding: 20px;
            flex-wrap: wrap;
        }
        .hero-entrance-zone {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 260px;
        }
        .dialogue-zone {
            flex: 1.5;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        .dialogue-box {
            background: rgba(0, 0, 0, 0.8);
            border: 2px solid #f1c40f;
            border-radius: 25px;
            padding: 30px;
            min-height: 180px;
            box-shadow: 0 0 30px rgba(241, 196, 15, 0.2);
            backdrop-filter: blur(15px);
            text-align: right;
        }
        #dialogue-text {
            font-size: clamp(1.2rem, 5vw, 1.8rem);
            color: #fff;
            margin: 0;
            line-height: 1.5;
        }
        #player-name-input {
            background: rgba(255,255,255,0.05);
            border: 1px solid #f1c40f;
            color: #f1c40f;
            font-size: 1.4rem;
            padding: 10px;
            border-radius: 10px;
            width: 250px;
            text-align: center;
        }
        .choice-container { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

        .settings-btn {
            position: absolute;
            top: 30px;
            left: 5%;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.4);
            border: 2px solid rgba(255, 255, 255, 0.2);
            color: white;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            z-index: 91;
            transition: all 0.3s ease;
        }
        .settings-btn:hover { background: rgba(241, 196, 15, 0.8); transform: rotate(45deg); }
        
        /* SECTION: settings modal and tabbed settings UI
         * This block is another clear split candidate. If the CSS grows, move settings styles
         * into arcadeStyle.settings.css to keep the main arcade UI lean.
         */
        .settings-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 20px;
            padding: 30px;
            z-index: 1000;
            text-align: left;
            backdrop-filter: blur(10px);
            display: none;
            flex-direction: column;
            gap: 20px;
            box-sizing: border-box;
            width: 95%;
            max-width: 900px;
            min-height: 500px;
            direction: ltr;
            box-shadow:
                0 0 20px rgba(74, 144, 226, 0.3),
                0 0 20px rgba(231, 76, 60, 0.3),
                0 0 20px rgba(241, 196, 15, 0.3),
                0 0 20px rgba(46, 204, 113, 0.3);
            animation: configGlow 4s ease-in-out infinite;
        }
        .settings-modal.active { display: flex; animation: popIn 0.3s ease; }
        
        .close-modal-x {
            position: absolute;
            top: 20px;
            left: 20px;
            background: none !important;
            border: none !important;
            color: #f1c40f !important;
            font-size: 32px !important;
            cursor: pointer;
            padding: 0 !important;
            min-width: unset !important;
            box-shadow: none !important;
            line-height: 1;
            z-index: 10;
            transition: transform 0.2s, color 0.2s;
        }
        .close-modal-x:hover { transform: scale(1.2); color: white !important; }

        /* Settings Tabs */
        .settings-tabs {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            border-bottom: 2px solid rgba(255,255,255,0.1);
            padding-bottom: 10px;
            flex-wrap: wrap;
            justify-content: flex-start;
            direction: ltr;
        }
        .settings-tab {
            padding: 10px 16px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 8px;
            color: white;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 0.9rem;
            font-weight: bold;
            text-align: center;
            white-space: nowrap;
        }
        .settings-tab:hover {
            background: rgba(255,255,255,0.15);
        }
        .settings-tab.active {
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid white;
            font-weight: bold;
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
        }
        
        .settings-tab-content {
            display: none;
            flex-direction: column;
            gap: 15px;
            flex: 1;
            overflow-y: auto;
            text-align: left;
            direction: ltr;
        }
        .settings-tab-content.active {
            display: flex;
        }
        
        /* Tab 1: User Management */
        .user-mgmt-container {
            direction: ltr;
            text-align: left;
            color: white;
        }
        .user-mgmt-container label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #f1c40f;
        }
        .user-list-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 15px;
            background: rgba(255,255,255,0.05);
            border-radius: 10px;
            margin-bottom: 8px;
        }
        .user-list-item.current {
            border: 2px solid #f1c40f;
            background: rgba(241, 196, 15, 0.1);
        }
        .user-list-item .user-name {
            font-weight: bold;
        }
        .user-list-item .user-name.current {
            color: #f1c40f;
        }
        .user-actions {
            display: flex;
            gap: 8px;
        }
        .user-action-btn {
            padding: 5px 12px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }
        .user-action-btn.switch {
            background: #3498db;
            color: white;
        }
        .user-action-btn.delete {
            background: #e74c3c;
            color: white;
        }
        .user-action-btn:hover {
            transform: scale(1.05);
        }

        .hint-toggle-group {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            flex-wrap: wrap;
            width: 100%;
            padding: 10px 0;
        }
        .hint-switch {
            position: relative;
            display: inline-block;
            width: 62px;
            height: 34px;
            cursor: pointer;
        }
        .hint-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        .hint-switch-slider {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, #e74c3c, #c0392b);
            border-radius: 34px;
            transition: background 0.3s ease, box-shadow 0.3s ease;
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 4px 10px rgba(0,0,0,0.16);
        }
        .hint-switch-slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 4px;
            bottom: 4px;
            background: #fff;
            border-radius: 50%;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            box-shadow: 0 3px 8px rgba(0,0,0,0.25);
        }
        .hint-switch input:checked + .hint-switch-slider {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
        }
        .hint-switch input:checked + .hint-switch-slider:before {
            transform: translateX(28px);
        }
        .hint-switch-label {
            font-size: 0.95rem;
            color: #ccc;
            white-space: nowrap;
        }
        
        /* Tab 2: Stats */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
        }
        .stat-card {
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 15px;
            padding: 20px;
            text-align: center;
        }
        .stat-card .stat-value {
            font-size: 2rem;
            font-weight: bold;
            color: #f1c40f;
        }
        .stat-card .stat-label {
            color: #ccc;
            font-size: 0.9rem;
            margin-top: 5px;
        }
        
        /* Tab 3: Settings */
        .settings-option {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px;
            background: rgba(255,255,255,0.05);
            border-radius: 10px;
            margin-bottom: 10px;
        }
        .settings-option label {
            color: white;
            font-weight: bold;
        }
        
        .reset-btn { background: #e74c3c !important; color: white !important; -webkit-text-fill-color: white !important; background-image: none !important; }
        .close-settings-btn { background: #7f8c8d !important; -webkit-text-fill-color: white !important; background-image: none !important; }

        .choice-btn { 
            text-align: right !important; 
            padding: 10px 20px !important; 
            margin-top: 0 !important; 
            min-width: 200px !important;
            font-size: 1.1rem !important;
        }
        .name-inputs-container {
            flex-wrap: wrap;
            justify-content: center;
        }
        #introHeroCanvas {
            max-width: 100%;
            height: auto;
            aspect-ratio: 1/1;
        }

        /* ========== RESPONSIVE MEDIA QUERIES (ENHANCEMENT) ========== */
        @media (max-width: 1024px) {
            .type-selection-grid { gap: 20px; padding: 0 15px; }
            .mode-selection-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
            .hero-frame { width: 200px; height: 300px; }
        }
        @media (max-width: 768px) {
            .hud { padding: 12px; font-size: 18px; grid-template-columns: 1fr auto 1fr; }
            .type-selection-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; }
            .mode-selection-grid { grid-template-columns: repeat(2, 1fr); }
            .hero-selection-grid { gap: 15px; }
            .hero-frame { width: 180px; height: 280px; }
            .selection-instructions { font-size: 0.9rem; gap: 8px; justify-content: center; }
            .button-row button { min-width: 130px; padding: 10px 20px; }
            .dialogue-box { padding: 20px; min-height: 150px; }
            .intro-layout { flex-direction: column; gap: 20px; }
            .settings-btn, .back-btn { width: 50px; height: 50px; font-size: 24px; bottom: 20px; top: auto; left: 20px; }
            .settings-btn { top: 20px; bottom: auto; left: 20px; }
            .back-btn { bottom: 20px; left: 20px; }
            .setup-form h1 { margin-bottom: 20px; }
            .name-inputs-container .form-group { max-width: 200px !important; }
        }
        @media (max-width: 560px) {
            .type-selection-grid { grid-template-columns: 1fr; gap: 12px; }
            .mode-selection-grid { grid-template-columns: 1fr; }
            .hero-frame { width: 90%; max-width: 220px; height: auto; min-height: 260px; margin: 0 auto; }
            .hero-selection-grid { flex-direction: column; align-items: center; }
            .hud { display: flex; flex-direction: column; align-items: center; gap: 5px; }
            .p1-score, .p2-score, .p3-score, .p4-score { text-align: center; width: 100%; }
            #timer-display { margin: 5px 0; }
            .button-row { gap: 12px; }
            button:not(.back-btn) { min-width: 120px; font-size: 14px; padding: 8px 16px; }
            .dialogue-box { padding: 15px; }
            #dialogue-text { font-size: 1.2rem; }
            .settings-modal { padding: 25px; width: 90%; }
        }
        @media (max-width: 380px) {
            .mode-card .title { font-size: 1rem; }
            .type-card h2 { font-size: 1.2rem; }
            .hero-frame h3 { font-size: 1.2rem; }
        }
        /* Ensure canvas for game does not overflow */
        #gameCanvas {
            display: block;
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
        }

        /* ========== MOBILE CONTROLS (NEW) ========== */
        /* MOBILE split candidate: keep mobile-only overlays and controls in arcadeStyle.mobile.css */
        .mobile-controls {
            position: absolute;
            bottom: 40px;
            right: 40px;
            display: none;
            z-index: 100;
            pointer-events: auto;
        }
        .d-pad {
            display: grid;
            grid-template-columns: 70px 70px 70px;
            grid-template-rows: 70px 70px;
            gap: 15px;
        }
        .d-btn {
            width: 70px;
            height: 70px;
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 32px;
            user-select: none;
            backdrop-filter: blur(5px);
            cursor: pointer;
            transition: transform 0.1s, background 0.1s;
            -webkit-tap-highlight-color: transparent;
        }
        .d-btn:active { background: rgba(255, 255, 255, 0.4); transform: scale(0.95); }
        #btn-up { grid-column: 2; grid-row: 1; }
        #btn-left { grid-column: 1; grid-row: 2; }
        #btn-down { grid-column: 2; grid-row: 2; }
        #btn-right { grid-column: 3; grid-row: 2; }

        @media (max-width: 768px) {
            .mobile-controls { display: block; }
            /* Restrict to single player on mobile */
            .mode-card:not([data-players="1"]) {
                display: none !important;
            }
        }
        .game-container {
            overflow: hidden;
        }

/* ========== UNIFIED SETUP & HUD COMPONENTS ========== */
.type-card[data-visible="false"] {
    display: none !important;
}

#item-bars {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 6px;
    flex-wrap: wrap;
    pointer-events: none;
}

.item-bar {
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
}

.item-bar-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    margin-left: 4px;
}

.item-pip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.item-pip .pip-timer {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f4c542;
    font-size: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 700;
}

.unified-setup-container { display: flex; flex-direction: row; gap: 30px; width: 95%; max-width: 1400px; margin: 0 auto; align-items: stretch; justify-content: center; padding-bottom: 20px; flex-wrap: wrap; }
.setup-config-panel { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    background: rgba(0, 0, 0, 0.4); 
    padding: 20px; 
    border-radius: 20px; 
    border: 1px solid var(--border-glass); 
    backdrop-filter: blur(10px); 
    min-width: 320px;
    box-shadow: 
        0 0 20px rgba(74, 144, 226, 0.3),
        0 0 20px rgba(231, 76, 60, 0.3),
        0 0 20px rgba(241, 196, 15, 0.3),
        0 0 20px rgba(46, 204, 113, 0.3);
    animation: configGlow 4s ease-in-out infinite;
}
.setup-hero-panel { flex: 2; display: flex; flex-direction: column; gap: 15px; min-width: 350px; }
.config-row { display: flex; gap: 15px; width: 100%; }
.config-item { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.unified-select { width: 100%; padding: 10px; background: #222; color: white; border: 1px solid #444; border-radius: 8px; font-size: 1rem; }
.config-group { display: flex; flex-direction: column; gap: 8px; text-align: right; }
.btn-group { display: flex; gap: 8px; width: 100%; }
.group-btn { flex: 1; padding: 10px !important; min-width: 0 !important; font-size: 1rem !important; background: rgba(255,255,255,0.05) !important; border: 1px solid var(--border-glass) !important; color: white !important; -webkit-text-fill-color: white !important; cursor: pointer; transition: all 0.2s; }
.group-btn:hover { background: rgba(255,255,255,0.15) !important; }
.group-btn.selected { 
    background: rgba(255, 255, 255, 0.15) !important; 
    border: 2px solid white !important; 
    font-weight: bold; 
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2) !important;
}
.start-btn { 
    background: #27ae60 !important; 
    -webkit-text-fill-color: white !important; 
    box-shadow: 0 0 20px rgba(39, 174, 96, 0.4) !important; 
}

.player-user-dropdown {
    text-align: center;
    text-align-last: center; /* עבור דפדפני כרום/ספארי */
}