        :root {
            /* Refined Onyx Palette */
            --obsidian: #0a0b0d;
            --charcoal: #151619;
            --slate-dark: #1c1e23;
            --slate: #252831;
            --slate-light: #2f3440;
            
            /* Burnished Copper Accents */
            --copper: #c9965b;
            --copper-bright: #ddb070;
            --copper-dark: #a67840;
            --copper-glow: rgba(201, 150, 91, 0.25);
            --copper-glow-strong: rgba(201, 150, 91, 0.5);
            
            /* Legacy Variables (mapped for compatibility) */
            --felt: #35654d;
            --gold: #c9965b;
            --wood: #0a0b0d;
            --card-red: #dc3545;
            --alert: #dc2626;
            
            /* Glass Effects */
            --glass: rgba(28, 30, 35, 0.75);
            --glass-light: rgba(37, 40, 49, 0.85);
            --glass-border: rgba(255, 255, 255, 0.08);
            --glass-border-bright: rgba(201, 150, 91, 0.3);
            
            /* Text Hierarchy */
            --text-primary: #f8f9fa;
            --text-secondary: #adb5bd;
            --text-tertiary: #6c757d;
            
            /* Shadows */
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
            --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
            --shadow-copper: 0 4px 24px var(--copper-glow);
            
            /* Border Radius */
            --radius-sm: 10px;
            --radius-md: 16px;
            --radius-lg: 24px;
            --radius-xl: 32px;
            
            /* Responsive scaling variables */
            --card-width: 60px;
            --card-height: 84px;
            --card-font: 0.9rem;
            --avatar-size: 2.5rem;
            --seat-width: 80px;
            --button-font: 1rem;
            --spacing-unit: 10px;
        }

        /* iOS RESET & LAYOUT */
        html { -webkit-text-size-adjust: 100%; height: 100%; overscroll-behavior: none; }
        
        body { 
            background: var(--obsidian);
            color: var(--text-primary); 
            font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; 
            font-weight: 500;
            display: flex; align-items: center; justify-content: center; 
            margin: 0; overflow: hidden; 
            user-select: none; -webkit-user-select: none; 
            height: 100vh; height: 100dvh; 
            width: 100vw;
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
            box-sizing: border-box;
        }

        * { -webkit-tap-highlight-color: transparent; }
        button, .card, .avatar-option, .nav-btn, input { touch-action: manipulation; }

        /* --- SCREENS (navigable views) --- */
        .screen {
            position: fixed; inset: 0;
            background: rgba(10, 11, 13, 0.95);
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
            display: none; flex-direction: column;
            align-items: center; justify-content: center; z-index: 5000;
            padding: 20px;
            padding-top: calc(20px + env(safe-area-inset-top));
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
        }

        .screen.active {
            display: flex;
        }

        /* --- OVERLAYS (modal interrupts during gameplay) --- */
        #game-over-overlay, #wild-picker, #demo-complete-overlay, #pause-overlay, #level-up-overlay, #suit-picker {
            position: fixed; inset: 0;
            background: rgba(10, 11, 13, 0.92);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            display: flex; flex-direction: column;
            align-items: center; justify-content: center; z-index: 5000;
            padding: 20px;
            padding-top: calc(20px + env(safe-area-inset-top));
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
        }

        #game-over-overlay, #pause-overlay, #level-up-overlay, #suit-picker, #wild-picker {
            background: rgba(10, 11, 13, 0.95);
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
        }

        #pause-overlay {
            cursor: pointer;
        }
        
        .setup-box, .pause-box {
            cursor: default;
        }

        #suit-picker, #wild-picker { 
            background: rgba(10, 11, 13, 0.1) !important; 
            backdrop-filter: blur(0px);
            -webkit-backdrop-filter: blur(0px);
            justify-content: flex-start;
            padding-top: 80px;
            cursor: default;
        }

        #suit-picker, #wild-picker, #game-over-overlay, #demo-complete-overlay, #pause-overlay, #level-up-overlay { display: none; }

        .setup-box { 
            border: 0.5px solid var(--glass-border);
            padding: 24px;
            border-radius: var(--radius-xl); 
            text-align: center; width: 90%; max-width: 450px; 
            background: var(--glass-light);
            box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.03); 
            max-height: 85vh; overflow-y: auto; 
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
            touch-action: pan-y;
        }
        
        .name-input {
            width: 80%; padding: 14px; margin: 10px 0 20px 0;
            border-radius: var(--radius-md);
            border: 1px solid var(--glass-border);
            background: var(--glass);
            color: var(--text-primary);
            font-size: 1.2rem; text-align: center;
            font-weight: 600; outline: none; -webkit-appearance: none;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .name-input::placeholder { color: var(--text-tertiary); font-weight: 400; }
        .name-input:focus { 
            background: var(--slate-dark);
            border-color: var(--copper);
            box-shadow: 0 0 0 3px var(--copper-glow);
        }

        .avatar-grid { 
            display: grid; grid-template-columns: repeat(4, 1fr); 
            gap: 12px; margin: 12px 0 20px 0; 
            width: 100%; box-sizing: border-box;
        }
        
        .avatar-option { 
			aspect-ratio: 1;
			font-size: 2rem; padding: 10px;
			border: 2px solid transparent;
			border-radius: var(--radius-md);
			cursor: pointer;
			transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
			background: linear-gradient(145deg, var(--slate), var(--slate-dark));
			display: flex; align-items: center; justify-content: center;
			position: relative;
			box-shadow: 
			0 4px 8px rgba(0, 0, 0, 0.4),
			inset 0 1px 0 rgba(255, 255, 255, 0.1),
			inset 0 -1px 0 rgba(0, 0, 0, 0.3);
        }
        .avatar-option img {
            width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
        }
        .avatar-option:hover {
			transform: scale(1.05) translateY(-2px);
			background: linear-gradient(145deg, var(--slate-light), var(--slate));
			box-shadow: 
			0 6px 12px rgba(0, 0, 0, 0.5),
			inset 0 1px 0 rgba(255, 255, 255, 0.15),
			inset 0 -1px 0 rgba(0, 0, 0, 0.3);
		 }
        .avatar-option.selected { 
            border-color: var(--copper);
            background: rgba(201, 150, 91, 0.1);
            box-shadow: 0 0 0 3px var(--copper-glow);
            transform: scale(1.05);
        }
        .avatar-option.locked {
   			display: none !important;
   			opacity: 0.3;
    		cursor: not-allowed;
    		filter: grayscale(100%);
		}
        .avatar-option.locked::after {
            content: '🔒';
            position: absolute;
            bottom: 4px;
            right: 4px;
            font-size: 0.8rem;
        }
        .avatar-option.premium::before {
            content: '⭐';
            position: absolute;
            top: 4px;
            right: 4px;
            font-size: 0.7rem;
        }

        .opp-select-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; width: 100%; }
        .btn-opp { 
            flex: 1; padding: 12px;
            background: var(--slate-dark);
            border: 1px solid var(--glass-border);
            color: var(--obsidian)
            cursor: pointer;
            border-radius: var(--radius-sm);
            font-weight: 700;
            font-size: 0.9rem;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .btn-opp:hover {
            background: var(--slate);
            border-color: var(--glass-border-bright);
        }
        .btn-opp.selected { 
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            color: var(--obsidian);
            border-color: var(--copper);
            box-shadow: var(--shadow-copper);
        }

        /* SHOP STYLES */
        .shop-container { display: flex; flex-direction: column; gap: 10px; width: 100%; }
        .shop-item { 
            display: flex; align-items: center; justify-content: space-between; 
            background: var(--slate-dark);
            border: 1px solid var(--glass-border); 
            padding: 16px;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .shop-item:hover {
            background: var(--slate);
            border-color: var(--glass-border-bright);
            transform: translateX(4px);
        }
        .shop-item:active { transform: scale(0.98); }
        .shop-item.owned {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .shop-item.owned:hover {
            transform: none;
        }
        .btn-price { 
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            color: var(--obsidian);
            border: none; 
            padding: 8px 16px;
            border-radius: 20px;
            font-weight: 800;
            pointer-events: none;
            box-shadow: var(--shadow-sm);
            letter-spacing: 0.05em;
        }

        /* --- GAME TABLE --- */
        .game-wrapper { 
            display: none; width: 100%; height: 100%; 
            align-items: center; justify-content: center; 
            flex-direction: column; box-sizing: border-box; 
        }
        
        .table-container { 
            width: 100%; height: 100%; max-width: 1200px;
            background: radial-gradient(ellipse 80% 60% at 50% 40%, var(--slate) 0%, transparent 100%),
                        radial-gradient(circle at 20% 80%, rgba(201, 150, 91, 0.03) 0%, transparent 50%),
                        radial-gradient(circle at 80% 20%, rgba(201, 150, 91, 0.03) 0%, transparent 50%),
                        linear-gradient(180deg, var(--charcoal) 0%, var(--obsidian) 100%);
            position: relative; display: flex; flex-direction: column; 
            border-radius: 0;
            box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.8); 
        }
        
        @media (min-width: 768px) {
            .table-container { 
                border-radius: 20px;
                border: 1px solid var(--glass-border-bright);
                height: 95%; margin: 20px;
            }
        }
        
        /* ========================================
           RESPONSIVE DESIGN - AUTO DEVICE DETECTION
           ======================================== */
        
        /* Small phones (portrait) - 320px to 480px */
        @media (max-width: 480px) and (orientation: portrait) {
            .card { width: 42px; height: 59px; padding: 3px; font-size: 0.7rem; }
            .opponent-seat { width: 70px; font-size: 0.65rem; }
            .opponent-seat > div:first-child { font-size: 2rem !important; }
            .btn-ui { font-size: 0.9rem; padding: 10px 20px; }
            .setup-box { padding: 20px; font-size: 0.9rem; }
            .setup-box h1 { font-size: 1.8rem; }
            .toast { font-size: 1rem; min-width: 200px; padding: 12px 20px; }
            .spotlight-text { font-size: 1.2rem; }
            .spotlight-card { width: 80px; height: 112px; font-size: 1rem; }
        }
        
        /* Medium phones (portrait) - 481px to 767px */
        @media (min-width: 481px) and (max-width: 767px) and (orientation: portrait) {
            .card { width: 50px; height: 70px; padding: 4px; font-size: 0.8rem; }
            .opponent-seat { width: 75px; }
            .opponent-seat > div:first-child { font-size: 2.2rem !important; }
        }
        
        /* Phones (landscape) */
        @media (max-height: 500px) and (orientation: landscape) {
            .opponents-row { height: 80px; padding-top: 5px; }
            .opponent-seat { width: 65px; }
            .opponent-seat > div:first-child { font-size: 1.8rem !important; }
            .card { width: 45px; height: 63px; padding: 3px; font-size: 0.7rem; }
            .player-info { font-size: 0.8rem; }
            .setup-box { max-height: 80vh; padding: 16px; }
            .setup-box h1 { font-size: 1.5rem; margin: 5px 0; }
            .btn-ui { padding: 8px 16px; font-size: 0.85rem; }
            .toast { font-size: 0.9rem; padding: 10px 20px; }
            .nav-controls { top: 5px; left: 5px; }
            .nav-controls button { width: 35px; height: 35px; font-size: 1.2rem; }
        }
        
        /* Tablets (portrait) */
        @media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
            .card { width: 70px; height: 98px; padding: 6px; font-size: 0.95rem; }
            .opponent-seat { width: 95px; }
            .opponent-seat > div:first-child { font-size: 2.8rem !important; }
            .spotlight-card { width: 110px; height: 154px; }
        }
        
        /* Tablets & Desktop (landscape) */
        @media (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
            .card { width: 70px; height: 98px; padding: 7px; font-size: 0.95rem; }
            .opponent-seat { width: 95px; }
            .opponents-row { height: 130px; }
        }
        
        /* Large tablets & Desktop */
        @media (min-width: 1024px) {
            .card { width: 75px; height: 105px; padding: 8px; font-size: 1rem; }
            .opponent-seat { width: 100px; transform: scale(0.9); }
            .opponent-seat > div:first-child { font-size: 3rem !important; }
            .opponents-row { height: 140px; }
        }
        
        /* Large Desktop */
        @media (min-width: 1920px) {
            .card { width: 85px; height: 119px; padding: 9px; font-size: 1.1rem; }
            .opponent-seat { width: 110px; }
            .opponent-seat > div:first-child { font-size: 3.5rem !important; }
            .table-container { max-width: 1600px; }
            .setup-box { max-width: 550px}
            .spotlight-card { width: 120px; height: 168px; }
        }
        
        /* Ultra-wide Desktop */
        @media (min-width: 2560px) {
            .card { width: 100px; height: 140px; padding: 10px; font-size: 1.3rem; }
            .opponent-seat { width: 130px; }
            .opponent-seat > div:first-child { font-size: 4rem !important; }
            .table-container { max-width: 2000px; }
            .setup-box { max-width: 650px; font-size: 1.4rem; }
            .btn-ui { font-size: 1.1rem; padding: 14px 28px; }
            .toast { font-size: 1.4rem; }
        }
        
        .felt-surface { 
            flex: 1; margin: 20px;
            background-color: var(--felt);
            background-image: url("https://www.transparenttextures.com/patterns/felt.png");
			border-radius: 15px;
            transition: background-color 1.5s ease;
            position: relative; display: flex; flex-direction: column; 
            overflow: hidden; 
        }
        
        /* Subtle texture overlay */
        .felt-surface::before {
            content: '';
            position: absolute;
            inset: 0;
            background-image: 
                repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.03) 2px, rgba(0, 0, 0, 0.03) 4px),
                repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 0, 0, 0.03) 2px, rgba(0, 0, 0, 0.03) 4px);
            pointer-events: none;
            opacity: 0.3;
        }
        
        .opponents-row {
            display: flex; width: 100%; height: 120px; padding-top: 10px;
            justify-content: center; align-items: flex-start; gap: 2px;
            box-sizing: border-box;
        }
        
        .opponent-seat {
            text-align: center;
            opacity: 0.5;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            transform: scale(0.85); 
            width: 80px; flex-shrink: 1; position: relative;
        }
        .opponent-seat.active-turn { 
            opacity: 1;
            transform: scale(1.0);
            filter: drop-shadow(0 0 20px var(--copper-glow-strong));
        }
        .opponent-seat.finished { opacity: 0.3; }
        .opponent-seat.finished::after {
            content: '✓';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 3rem;
            color: var(--copper);
            text-shadow: 0 0 10px rgba(0,0,0,0.8);
        }
        
        .card { 
            width: 60px; height: 84px; 
            background: white;
            border-radius: 8px;
            display: flex; flex-direction: column; 
            justify-content: space-between;
            padding: 5px;
            color: black; 
            font-weight: bold;
            box-shadow: var(--shadow-md); 
            cursor: pointer;
            position: relative;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); 
            font-size: 0.9rem;
            flex-shrink: 0;
            border: 1px solid rgba(0, 0, 0, 0.1);
        }
        @media (min-width: 768px) {
            .card { width: 75px; height: 105px; padding: 8px; font-size: 1rem; }
            .opponent-seat { width: 100px; transform: scale(0.9); }
        }

        .card span:nth-child(2) { align-self: flex-end; transform: rotate(180deg); }
        
        .card:hover {
            transform: translateY(-12px);
            box-shadow: var(--shadow-lg);
            z-index: 150;
            margin: 0 10px !important;
        }
        .card.selected {
            transform: translateY(-30px) scale(1.1);
            border: 2px solid var(--copper);
            box-shadow: 0 8px 32px var(--copper-glow-strong);
            z-index: 200;
            margin: 0 10px !important;
        }
        .card.hint { 
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.6);
        }
        .card.red { color: var(--card-red); }

        /* --- CARD FAN HAND --- */
        .hand-area {
            width: 100%;
            height: 190px;
            background: rgba(0,0,0,0.3);
            display: flex;
            justify-content: center;
            align-items: flex-end;
            padding-top: 50px;
            padding-bottom: 15px;
            margin-top: -70px;
            position: relative;
            z-index: 100;
            box-sizing: border-box;
        }

        .hand-area .card {
            flex-shrink: 0;
            margin: 0 -8px;
            transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.2s ease;
        }

        /* UI UTILS */
        .toast { 
            position: fixed;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            color: var(--obsidian);
            padding: 15px 30px;
            border-radius: 50px;
            font-weight: 900;
            font-size: 1.2rem;
            display: none;
            z-index: 7000;
            border: 3px solid white;
            box-shadow: var(--shadow-xl);
            text-align: center;
            min-width: 250px;
            pointer-events: none;
        }
        
        .penalty-msg { 
            position: fixed;
            top: 15%;
            left: 50%;
            transform: translateX(-50%);
            background: var(--alert);
            color: white;
            padding: 10px 25px; 
            border-radius: 50px;
            font-weight: 900;
            font-size: 1.5rem;
            z-index: 4500;
            box-shadow: 0 4px 24px rgba(220, 38, 38, 0.5);
            border: 3px solid white;
            animation: pulse-alert 1s infinite;
            display: none;
            text-shadow: 0 2px 4px rgba(0,0,0,0.5);
            pointer-events: none;
        }
        @keyframes pulse-alert {
            0% { transform: translateX(-50%) scale(1); }
            50% { transform: translateX(-50%) scale(1.05); }
            100% { transform: translateX(-50%) scale(1); }
        }

        .btn-ui { 
			width: 100%; 
			padding: 16px; 
			margin: 8px 0; 
			border-radius: var(--radius-md); 
			border: none; 
			font-weight: 800; 
			cursor: pointer; 
			font-size: 1rem; 
			text-transform: uppercase; 
			letter-spacing: 0.05em;
			box-shadow: 
				0 4px 8px rgba(0, 0, 0, 0.4),
				inset 0 1px 0 rgba(255, 255, 255, 0.15),
				inset 0 -2px 0 rgba(0, 0, 0, 0.3);
			transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); 
		}
		.btn-ui:active { 
			transform: translateY(2px); 
			box-shadow: 
			0 2px 4px rgba(0, 0, 0, 0.4),
			inset 0 1px 0 rgba(0, 0, 0, 0.2),
			inset 0 -1px 0 rgba(255, 255, 255, 0.1);
		}
		.btn-ui:hover {
			transform: translateY(-2px);
			box-shadow: 
			0 6px 12px rgba(0, 0, 0, 0.5),
			inset 0 1px 0 rgba(255, 255, 255, 0.2),
			inset 0 -2px 0 rgba(0, 0, 0, 0.3);
		}

        .btn-demo { 
			background: linear-gradient(145deg, #4a90f7, #3b82f6);
			color: white;
		}
		.btn-easy { 
			background: linear-gradient(145deg, var(--slate-light), var(--slate));
			color: var(--text-primary);
		}
		.btn-hard, .btn-gold { 
			background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
			color: var(--obsidian);
		}
		.btn-share { 
			background: linear-gradient(145deg, #fff, #e5e5e5);
			color: #000;
		}
		.btn-rules { 
			background: linear-gradient(145deg, var(--slate-light), var(--slate-dark));
			color: var(--text-primary);
		}
        .btn-ui:disabled { opacity: 0.4; cursor: not-allowed; }

        .nav-controls {
            position: absolute;
            top: 10px;
            left: 10px;
            z-index: 2000;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .nav-btn { 
            width: 44px;
            height: 44px;
            border-radius: 30%;
            border: 2px solid var(--copper);
            background: var(--glass);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            color: var(--copper);
            font-size: 1.2rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: var(--shadow-sm);
        }
        .nav-btn:hover {
            background: var(--slate-light);
            transform: scale(1.05);
        }

        .banner-win { 
            border: 4px solid var(--copper);
            box-shadow: 0 0 100px var(--copper-glow-strong);
            background: radial-gradient(circle, rgba(60,60,20,1) 0%, rgba(0,0,0,1) 100%);
        }
        .banner-loss { 
            border: 4px solid var(--card-red);
            box-shadow: 0 0 100px rgba(220, 38, 38, 0.5);
            background: radial-gradient(circle, rgba(60,0,0,1) 0%, rgba(0,0,0,1) 100%);
        }

        .btn-rank { 
            padding: 12px;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: pointer;
            border: 2px solid var(--glass-border);
            background: var(--slate-dark);
            color: var(--text-primary);
            border-radius: var(--radius-sm);
            min-width: 44px;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .btn-rank:hover {
            background: var(--slate);
        }
        .btn-rank.selected { 
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            color: var(--obsidian);
            border-color: var(--copper);
            transform: scale(1.1);
            box-shadow: var(--shadow-copper);
        }
        
        .btn-suit { 
            font-size: 2.5rem;
            padding: 5px 20px;
            background: #fff;
            border-radius: var(--radius-sm);
            cursor: pointer;
            border: 2px solid #ccc;
            width: 70px;
            height: 70px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: var(--shadow-md);
        }
        .btn-suit:hover {
            transform: translateY(-4px) scale(1.05);
            border-color: var(--copper);
            box-shadow: var(--shadow-lg);
        }
        .btn-suit.selected { 
            border: 3px solid var(--copper) !important;
            transform: scale(1.1);
            box-shadow: 0 0 0 3px var(--copper-glow);
        }

        #timer-container { 
            position: absolute;
            top: 60px;
            right: 15px;
            width: 12px; 
            height: 120px;
            background: rgba(0, 0, 0, 0.6); 
            border: 2px solid var(--glass-border); 
            border-radius: 10px; 
            overflow: hidden; 
            display: none; 
            box-shadow: var(--shadow-sm);
            z-index: 2000;
        }
        #timer-bar { 
            width: 100%; 
            height: 100%; 
            background: var(--copper);
            transition: height 1s linear;
            position: absolute;
            bottom: 0;
        }
        
        .pile-label { 
            color: var(--text-tertiary);
            font-size: 0.6rem;
            letter-spacing: 2px;
            font-weight: 700;
            margin-bottom: 8px;
            text-transform: uppercase;
        }

        .rules-list { 
            text-align: left;
            list-style: none;
            padding: 0;
            margin-bottom: 20px;
            font-size: 0.9rem;
        }
        .rules-list li { 
            display: flex;
            justify-content: space-between;
            border-bottom: 1px solid var(--glass-border);
            padding: 12px 0;
        }
        .rules-list li:last-child {
            border-bottom: none;
        }
        .rules-list li span:first-child {
            color: var(--copper);
            font-weight: 700;
        }
        .rules-list li span:last-child {
            color: var(--text-secondary);
            text-align: right;
        }
        
        #friendOptions { 
            display: none;
            margin-top: 20px;
            padding: 15px;
            background: var(--slate-dark);
            border-radius: var(--radius-md);
            animation: slideDown 0.4s ease forwards;
        }
        @keyframes slideDown {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .room-input { 
            width: 80%;
            padding: 12px;
            margin-bottom: 10px;
            border-radius: var(--radius-sm);
            border: 2px solid var(--copper);
            background: var(--obsidian);
            color: var(--text-primary);
            font-size: 1.2rem;
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 2px;
            -webkit-appearance: none;
        }

        .music-wrapper { 
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 10px;
            width: 100%;
        }
        .music-row { 
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            justify-content: center;
            margin-top: 5px;
        }
        .music-btn { 
			background: linear-gradient(145deg, var(--slate), var(--slate-dark));
			border: 2px solid var(--copper);
			color: var(--copper);
			border-radius: 50%;
			width: 44px;
			height: 44px;
			font-size: 1.2rem;
			cursor: pointer;
			display: flex;
			align-items: center;
			justify-content: center;
			transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
			box-shadow: 
			0 2px 6px rgba(0, 0, 0, 0.3),
			inset 0 1px 0 rgba(255, 255, 255, 0.1);
		}
		.music-btn:hover {
			background: linear-gradient(135deg, var(--copper-bright), var(--copper));
			color: var(--obsidian);
			transform: translateY(-1px);
			box-shadow: 
			0 4px 10px var(--copper-glow),
			inset 0 1px 0 rgba(255, 255, 255, 0.3);
			}
        input[type=range] { 
            flex: 1;
            accent-color: var(--copper);
            max-width: 120px;
            height: 20px;
        }
        
        .game-music-control { 
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 2000; 
            display: flex;
            gap: 10px;
            align-items: center; 
            background: var(--glass);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            padding: 8px 12px;
            border-radius: 30px;
            border: 1px solid var(--glass-border);
            box-shadow: var(--shadow-sm);
        }

        .flying-star {
            position: absolute;
            font-size: 3rem;
            animation: fly 2s ease-out forwards;
            pointer-events: none;
            z-index: 6000;
        }
        @keyframes fly {
            0% { transform: translateY(0) scale(0.5); opacity: 0; }
            20% { opacity: 1; transform: translateY(-50px) scale(1.2) rotate(45deg); }
            100% { opacity: 0; transform: translateY(-300px) scale(0.5) rotate(180deg); }
        }
        
        /* CONFETTI ANIMATION */
        .confetti {
            position: fixed;
            width: 10px;
            height: 10px;
            background: var(--copper);
            position: absolute;
            animation: confetti-fall 3s ease-out forwards;
            pointer-events: none;
            z-index: 6000;
        }
        @keyframes confetti-fall {
            0% { transform: translateY(0) rotateZ(0deg); opacity: 1; }
            100% { transform: translateY(100vh) rotateZ(720deg); opacity: 0; }
        }
        
        /* SCREEN SHAKE */
        @keyframes shake {
            0%, 100% { transform: translate(0, 0); }
            10%, 30%, 50%, 70%, 90% { transform: translate(-5px, 0); }
            20%, 40%, 60%, 80% { transform: translate(5px, 0); }
        }
        .shake {
            animation: shake 0.5s ease-in-out;
        }
        
        /* VICTORY BOUNCE */
        @keyframes victory-bounce {
            0%, 100% { transform: scale(1); }
            25% { transform: scale(1.2) rotate(-5deg); }
            50% { transform: scale(1.1) rotate(5deg); }
            75% { transform: scale(1.15) rotate(-3deg); }
        }
        .victory-bounce {
            animation: victory-bounce 0.6s ease-in-out;
        }
        
        /* SLOW MOTION CARD */
        .winning-card-spotlight {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0);
            z-index: 7500;
            animation: winning-card-reveal 2s ease-out forwards;
            pointer-events: none;
        }
        @keyframes winning-card-reveal {
            0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
            30% { transform: translate(-50%, -50%) scale(1.5) rotate(360deg); opacity: 1; }
            70% { transform: translate(-50%, -50%) scale(1.5) rotate(360deg); opacity: 1; }
            100% { transform: translate(-50%, -50%) scale(0) rotate(720deg); opacity: 0; }
        }
        
        .rank-badge { 
            font-size: 0.7rem;
            color: var(--copper);
            font-weight: 800;
            margin-top: 4px;
            letter-spacing: 1px;
            text-shadow: 0 0 5px rgba(0,0,0,0.8);
        }
        .rank-badge.all-star {
            background: linear-gradient(90deg, #FF1744, #F50057, #FF1744);
            background-size: 200% 100%;
            animation: rank-shimmer 2s linear infinite;
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-size: 0.8rem;
        }
        @keyframes rank-shimmer {
            0% { background-position: 0% 50%; }
            100% { background-position: 200% 50%; }
        }

        /* ACHIEVEMENT BADGES */
        .achievement-popup {
            position: fixed;
            top: 15%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0);
            background: linear-gradient(135deg, var(--slate-dark) 0%, var(--slate) 100%);
            padding: 20px 30px;
            border-radius: var(--radius-lg);
            border: 2px solid var(--copper);
            box-shadow: var(--shadow-xl);
            z-index: 10000;
            animation: achievement-pop 3s ease-out forwards;
            pointer-events: none;
            text-align: center;
        }
        @keyframes achievement-pop {
            0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
            10% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
            20% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
            80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
            100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
        }
        .achievement-title {
            color: var(--copper);
            font-size: 1.2rem;
            font-weight: 900;
            text-transform: uppercase;
            margin-bottom: 5px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.5);
        }
        .achievement-desc {
            color: var(--text-primary);
            font-size: 0.9rem;
            font-weight: 600;
        }
        .achievement-icon {
            font-size: 3rem;
            margin-bottom: 10px;
        }

        /* SPIN WHEEL */
        #spin-wheel-overlay {
            position: fixed;
            inset: 0;
            background: rgba(10, 11, 13, 0.95);
            backdrop-filter: blur(24px);
            -webkit-backdrop-filter: blur(24px);
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            z-index: 8000;
        }
        .wheel-container {
            position: relative;
            width: 320px;
            height: 320px;
            margin: 20px auto;
        }
        .wheel {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            border: 6px solid var(--copper);
            position: relative;
            background: conic-gradient(
                from 0deg,
                #ff6b6b 0deg 60deg,
                #4ecdc4 60deg 120deg,
                #45b7d1 120deg 180deg,
                #f9ca24 180deg 240deg,
                #6c5ce7 240deg 300deg,
                #fd79a8 300deg 360deg
            );
            box-shadow: 0 0 30px var(--copper-glow), inset 0 0 50px rgba(0,0,0,0.3);
            transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
        }
        .wheel-pointer {
            position: absolute;
            top: -30px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 18px solid transparent;
            border-right: 18px solid transparent;
            border-top: 36px solid var(--copper);
            filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
            z-index: 10;
        }
        .wheel-center {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 80px;
            height: 80px;
            background: linear-gradient(135deg, var(--copper-bright), var(--copper));
            border-radius: 50%;
            border: 5px solid white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 900;
            font-size: 1.2rem;
            color: var(--obsidian);
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
            z-index: 5;
        }
        .wheel-segment-label {
            position: absolute;
            top: 50%;
            left: 50%;
            transform-origin: center;
            font-weight: 900;
            font-size: 0.9rem;
            color: white;
            text-shadow: 0 2px 4px rgba(0,0,0,0.8);
            width: 140px;
            text-align: center;
        }
        #spin-button {
            margin-top: 30px;
            padding: 15px 40px;
            font-size: 1.3rem;
            font-weight: 900;
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            border: none;
            border-radius: 50px;
            cursor: pointer;
            box-shadow: var(--shadow-copper);
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            color: var(--obsidian);
        }
        #spin-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 32px var(--copper-glow-strong);
        }
        #spin-button:active {
            transform: translateY(0);
        }
        #spin-button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .spin-result {
            margin-top: 20px;
            font-size: 1.5rem;
            font-weight: 900;
            color: var(--copper);
            text-align: center;
            min-height: 40px;
        }

        /* TRASH TALK SYSTEM */
        .trash-talk-bubble {
            position: absolute;
            background: white;
            color: black;
            padding: 8px 15px;
            border-radius: 15px;
            font-family: 'Outfit', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-weight: bold;
            font-size: 0.85rem;
            box-shadow: var(--shadow-md);
            z-index: 3000;
            animation: trash-talk-pop 3s ease-out forwards;
            pointer-events: none;
            max-width: 250px;
            text-align: center;
            white-space: nowrap;
        }
        .trash-talk-bubble::after {
            content: '';
            position: absolute;
            top: -8px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 8px solid white;
        }
        /* Player bubble: arrow at the bottom pointing down toward avatar */
        .trash-talk-bubble.trash-talk-player::after {
            top: auto;
            bottom: -8px;
            border-bottom: none;
            border-top: 8px solid white;
        }
        @keyframes trash-talk-pop {
            0% { transform: translateX(-50%) scale(0) translateY(0); opacity: 0; }
            10% { transform: translateX(-50%) scale(1.1) translateY(-10px); opacity: 1; }
            20% { transform: translateX(-50%) scale(1) translateY(-10px); opacity: 1; }
            85% { transform: translateX(-50%) scale(1) translateY(-10px); opacity: 1; }
            100% { transform: translateX(-50%) scale(0) translateY(-10px); opacity: 0; }
        }
        
        .quick-chat-container {
            display: flex;
            gap: 6px;
            margin-top: 8px;
            justify-content: center;
            flex-wrap: wrap;
        }
        .quick-chat-btn {
            background: var(--slate-dark);
            border: 1px solid var(--glass-border);
            color: var(--text-secondary);
            padding: 6px 12px;
            border-radius: 8px;
            font-size: 0.75rem;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            font-weight: 600;
        }
        .quick-chat-btn:hover {
            background: var(--slate);
            border-color: var(--copper-dark);
            color: var(--text-primary);
        }
        .quick-chat-btn:active {
            transform: scale(0.95);
            background: linear-gradient(135deg, var(--copper-bright) 0%, var(--copper) 100%);
            color: var(--obsidian);
        }
        .quick-chat-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .player-bar {
            background: rgba(21, 22, 25, 0.95);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-top: 1px solid var(--glass-border); 
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
            padding-top: 10px;
            display: flex;
            flex-direction: column;
            width: 100%;
            z-index: 50; 
            position: relative;
            box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
        }
        
        .controls-row {
            display: flex;
            justify-content: center;
            gap: 15px;
            align-items: center;
            padding: 0 10px 10px 10px;
        }

        /* CPU MOVE SPOTLIGHT */
        #cpu-card-spotlight {
            position: fixed;
            top: 35%; 
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 4000;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }
        
        .spotlight-row {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .spotlight-card {
            width: 100px; 
            height: 140px; 
            transform: scale(1.0); 
            box-shadow: 0 0 60px var(--copper-glow-strong);
            animation: popIn 0.3s ease-out;
            background: white; 
            border-radius: 12px; 
            display: flex; 
            flex-direction: column; 
            justify-content: space-between; 
            padding: 8px; 
            color: black; 
            font-weight: bold; 
            font-size: 1.2rem;
            margin: 0 -20px;
            border: 2px solid #ccc;
        }
        .spotlight-card.red { color: var(--card-red); }
        .spotlight-card span:nth-child(2) { align-self: flex-end; transform: rotate(180deg); }

        .spotlight-text {
            color: var(--copper);
            font-size: 1.5rem;
            font-weight: 900;
            margin-bottom: 20px;
            text-shadow: 0 4px 10px black;
            text-transform: uppercase;
            animation: fadeIn 0.3s ease;
        }

        @keyframes popIn {
            0% { transform: scale(0); opacity: 0; }
            80% { transform: scale(1.1); opacity: 1; }
            100% { transform: scale(1.0); }
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
		
		/* Modal animations */
		@keyframes slideUp {
		from {
		opacity: 0;
		transform: translateY(30px);
		}
		to {
		opacity: 1;
		transform: translateY(0);
			}
		}

		/* Apple button hover */
		#apple-signin-btn:hover {
		background: #1a1a1a !important;
		transform: translateY(-2px);
	}

		/* Input focus states */
		#email-input:focus,
		#password-input:focus {
		border-color: var(--copper);
		box-shadow: 0 0 0 3px var(--copper-glow);
	}

        /* ================================================
           DESKTOP LAYOUT — Sidebar + Content
           Triggered by body.layout-desktop (device detection)
           ================================================ */

        /* Hidden by default (mobile-first) */
        #desktop-sidebar { display: none; }
        .ad-placement { display: none; }

        /* --- BODY BECOMES FLEX ROW --- */
        body.layout-desktop {
            /* Layout dimensions as CSS custom properties — single source of truth.
               Ad dimensions default to 0; JS expands them when ads actually fill. */
            --sidebar-width: 250px;
            --ad-top-height: 0px;
            --ad-right-width: 0px;
            --ad-right-gap: 0px;
            --ad-right-total: calc(var(--ad-right-width) + var(--ad-right-gap) * 2);
            /* Content area = viewport minus sidebar and right ad zone */
            --content-left: var(--sidebar-width);
            --content-right: var(--ad-right-total);
            --content-width: calc(100vw - var(--sidebar-width) - var(--ad-right-total));
            --content-center: calc(var(--sidebar-width) + var(--content-width) / 2);

            flex-direction: row;
            align-items: stretch;
            justify-content: flex-start;
        }

        /* --- SIDEBAR --- */
        body.layout-desktop #desktop-sidebar {
            display: flex;
            flex-direction: column;
            width: var(--sidebar-width);
            flex-shrink: 0;
            background: var(--glass-light);
            border-right: 1px solid var(--glass-border);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            padding: 0;
            z-index: 6000;
            margin-top: var(--ad-top-height);
            height: calc(100vh - var(--ad-top-height));
            height: calc(100dvh - var(--ad-top-height));
            overflow-y: auto;
        }

        body.layout-desktop .sidebar-logo {
            padding: 8px 20px 6px 20px;
            border-bottom: 1px solid var(--glass-border);
            text-align: center;
        }
        body.layout-desktop .sidebar-logo img {
            width: 100px;
            height: auto;
            border-radius: 8px;
            filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
        }

        body.layout-desktop .sidebar-nav {
            display: flex;
            flex-direction: column;
            padding: 6px 0;
            gap: 0px;
        }

        body.layout-desktop .sidebar-item {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 10px 24px;
            cursor: pointer;
            color: var(--text-secondary);
            font-weight: 600;
            font-size: 0.95rem;
            transition: all 0.2s ease;
            border-left: 3px solid transparent;
            user-select: none;
        }
        body.layout-desktop .sidebar-item:hover {
            background: rgba(201, 150, 91, 0.08);
            color: var(--text-primary);
        }
        body.layout-desktop .sidebar-item.active {
            background: rgba(201, 150, 91, 0.12);
            border-left-color: var(--copper);
            color: var(--copper-bright);
        }
        body.layout-desktop .sidebar-icon {
            font-size: 1.25rem;
            width: 28px;
            text-align: center;
            flex-shrink: 0;
        }

        /* --- SIDEBAR USER PROFILE --- */
        body.layout-desktop .sidebar-user {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 20px;
            border-bottom: 1px solid var(--glass-border);
            cursor: pointer;
            transition: background 0.2s ease;
        }
        body.layout-desktop .sidebar-user:hover {
            background: rgba(201, 150, 91, 0.08);
        }
        body.layout-desktop .sidebar-user-avatar {
            font-size: 2rem;
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--slate-dark);
            border-radius: 50%;
            border: 2px solid var(--copper);
            flex-shrink: 0;
        }
        body.layout-desktop .sidebar-user-info {
            min-width: 0;
            flex: 1;
        }
        body.layout-desktop .sidebar-user-name {
            font-weight: 700;
            font-size: 0.9rem;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        body.layout-desktop .sidebar-user-sub {
            font-size: 0.7rem;
            color: var(--text-tertiary);
            margin-top: 2px;
        }

        /* --- SIDEBAR MUSIC --- */
        body.layout-desktop .sidebar-music {
            padding: 14px 20px;
            border-top: 1px solid var(--glass-border);
        }
        body.layout-desktop .sidebar-music-label {
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin-bottom: 8px;
        }
        body.layout-desktop .sidebar-music-controls {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        body.layout-desktop .sidebar-music-controls .music-btn {
            width: 32px;
            height: 32px;
            font-size: 0.85rem;
            padding: 0;
            flex-shrink: 0;
        }
        body.layout-desktop .sidebar-volume-slider {
            flex: 1;
            min-width: 0;
            height: 4px;
            accent-color: var(--copper);
        }

        /* --- SIDEBAR AUTH --- */
        body.layout-desktop .sidebar-auth {
            padding: 12px 20px;
            border-top: 1px solid var(--glass-border);
        }
        body.layout-desktop .sidebar-auth-btn {
            display: block;
            width: 100%;
            background: var(--glass-light);
            border: 1px solid var(--glass-border);
            color: var(--text-secondary);
            padding: 10px 16px;
            border-radius: var(--radius-md);
            cursor: pointer;
            font-weight: 600;
            font-size: 0.8rem;
            text-align: center;
            transition: all 0.2s ease;
        }
        body.layout-desktop .sidebar-auth-btn:hover {
            border-color: var(--glass-border-bright);
            color: var(--text-primary);
        }
        body.layout-desktop .sidebar-auth-signout {
            margin-top: 6px;
            background: none;
            font-size: 0.72rem;
            padding: 6px 12px;
            color: var(--text-tertiary);
        }
        body.layout-desktop .sidebar-auth-signed-in {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 4px 0 2px 0;
        }
        body.layout-desktop .sidebar-auth-name {
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--copper);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        body.layout-desktop .sidebar-footer {
            margin-top: auto;
            padding: 16px 20px;
            border-top: 1px solid var(--glass-border);
            font-size: 0.75rem;
            color: var(--text-tertiary);
            text-align: center;
        }

        body.layout-desktop .sidebar-footer-links {
            display: flex;
            justify-content: center;
            gap: 12px;
            flex-wrap: wrap;
        }

        body.layout-desktop .sidebar-footer-link {
            color: var(--text-tertiary);
            text-decoration: none;
            font-size: 0.7rem;
            font-weight: 500;
            letter-spacing: 0.02em;
            transition: color 0.2s ease;
        }

        body.layout-desktop .sidebar-footer-link:hover {
            color: var(--copper-bright, #ddb070);
        }

        /* Sidebar during active gameplay — subtle dimming */
        body.layout-desktop #desktop-sidebar.game-active .sidebar-nav {
            opacity: 0.4;
            pointer-events: none;
        }
        body.layout-desktop #desktop-sidebar.game-active .sidebar-nav .sidebar-item:first-child {
            opacity: 1;
            pointer-events: auto;
        }

        /* --- APP CONTENT AREA --- */
        body.layout-desktop #app-content {
            flex: 1;
            position: relative;
            overflow: hidden;
            margin-top: var(--ad-top-height);
            height: calc(100vh - var(--ad-top-height));
            height: calc(100dvh - var(--ad-top-height));
            display: flex;
            flex-direction: column;
        }

        /* --- AD PLACEMENTS --- */
        /* Hidden until ads actually fill; JS adds .ad-filled to reveal them. */
        body.layout-desktop #ad-banner-top,
        body.layout-desktop #ad-sidebar-right {
            display: none !important;
        }
        body.layout-desktop #ad-banner-top.ad-filled,
        body.layout-desktop #ad-sidebar-right.ad-filled {
            display: flex !important;
        }

        /* Top ad banner spans the full width of the viewport, above the sidebar. */
        body.layout-desktop #ad-banner-top.ad-filled {
            align-items: center;
            justify-content: center;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            width: 100%;
            height: var(--ad-top-height);
            background: linear-gradient(135deg, #1a1a2e, #16213e);
            border-bottom: 1px solid var(--glass-border);
            color: var(--text-tertiary);
            font-size: 0.7rem;
            letter-spacing: 0.15em;
            font-weight: 600;
            z-index: 9500;
        }

        /* The 728x90 ins slot should stretch to fill the full-width banner. */
        body.layout-desktop #ad-banner-top ins.adsbygoogle {
            width: 100% !important;
            max-width: 100%;
            height: var(--ad-top-height) !important;
        }

        body.layout-desktop #ad-sidebar-right.ad-filled {
            justify-content: center;
            position: fixed;
            right: var(--ad-right-gap);
            top: calc(var(--ad-top-height) + var(--ad-right-gap));
            width: var(--ad-right-width);
            height: 600px;
            background: linear-gradient(180deg, #1a1a3e 0%, #0d1b2a 100%);
            border: 2px solid var(--glass-border-bright);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 0.75rem;
            letter-spacing: 0.12em;
            text-align: center;
            z-index: 9500;
            writing-mode: vertical-rl;
        }

        /* --- SCREENS: absolute within app-content instead of fixed --- */
        body.layout-desktop .screen {
            position: absolute;
            top: var(--ad-top-height);
            left: 0;
            right: var(--ad-right-total);
            bottom: 0;
            padding-top: 0;
            padding-bottom: 0;
            z-index: 5000;
        }

        /* --- SETUP SCREEN (HOME) — desktop-optimised layout --- */
        body.layout-desktop #setup-overlay .setup-box {
            max-width: 700px;
            max-height: calc(100vh - var(--ad-top-height) - 50px);
        }

        /* Mode buttons as side-by-side cards on desktop */
        body.layout-desktop #setup-overlay .button-group {
            display: flex;
            gap: 12px;
        }
        body.layout-desktop #setup-overlay .button-group .btn-ui {
            flex: 1;
        }

        /* --- SHOP / LEADERBOARD / RULES — wider panels --- */
        body.layout-desktop #shop-overlay .setup-box {
            max-width: 700px;
            max-height: calc(100vh - var(--ad-top-height) - 50px);
        }
        body.layout-desktop #leaderboard-overlay .setup-box {
            max-width: 600px;
            max-height: calc(100vh - var(--ad-top-height) - 50px);
        }
        body.layout-desktop #rules-overlay .setup-box {
            max-width: 550px;
        }

        /* --- GAME WRAPPER — fills content area --- */
        body.layout-desktop .game-wrapper {
            flex: 1;
            height: auto !important;
            min-height: 0;
        }

        body.layout-desktop .table-container {
            border-radius: 0;
            border: none;
            height: 100% !important;
            margin: 0 !important;
            /* Leave room for right ad */
            margin-right: var(--ad-right-total) !important;
        }

        /* --- GAMEPLAY OVERLAYS — between sidebar and right ad --- */
        body.layout-desktop #game-over-overlay,
        body.layout-desktop #pause-overlay,
        body.layout-desktop #level-up-overlay,
        body.layout-desktop #suit-picker,
        body.layout-desktop #wild-picker,
        body.layout-desktop #demo-complete-overlay {
            left: var(--sidebar-width);
            right: var(--ad-right-total);
        }

        /* --- TOAST — centered in content area between sidebar and right ad --- */
        body.layout-desktop .toast {
            top: calc(var(--ad-top-height) + 10px) !important;
            left: var(--content-center) !important;
            right: auto !important;
            transform: translateX(-50%) !important;
            max-width: 400px;
            height: auto !important;
            max-height: none !important;
            bottom: auto !important;
            align-items: center;
        }

        /* --- NAV CONTROLS — move to right side on desktop (left of right ad) --- */
        body.layout-desktop .nav-controls {
            top: calc(var(--ad-top-height) + 10px);
            left: auto;
            right: var(--ad-right-total);
            align-items: flex-end;
        }

        /* --- MUSIC CONTROL — hidden on desktop (in sidebar instead) --- */
        body.layout-desktop .game-music-control {
            display: none !important;
        }

        /* --- TIMER — reposition to right side --- */
        body.layout-desktop #timer-container {
            top: calc(var(--ad-top-height) + 10px);
            right: calc(var(--ad-right-total) + 50px);
        }

        /* --- PENALTY MSG — shift down for ad banner --- */
        body.layout-desktop .penalty-msg {
            top: calc(var(--ad-top-height) + 15%);
            left: var(--content-center) !important;
            transform: translateX(-50%) !important;
        }

        /* --- CPU SPOTLIGHT — center between sidebar and right ad --- */
        body.layout-desktop #cpu-card-spotlight {
            left: var(--content-center);
        }

        /* --- ACHIEVEMENT — center between sidebar and right ad --- */
        body.layout-desktop .achievement-popup {
            left: var(--content-center) !important;
        }

        /* --- SPIN WHEEL — between sidebar and right ad --- */
        body.layout-desktop #spin-wheel-overlay {
            left: var(--sidebar-width);
            right: var(--ad-right-total);
        }

        /* --- AUTH MODAL — between sidebar and right ad --- */
        body.layout-desktop #auth-modal-overlay {
            left: var(--sidebar-width);
            right: var(--ad-right-total);
        }

        /* Hide redundant nav/close buttons on desktop — sidebar handles navigation */
        body.layout-desktop .setup-nav-buttons,
        body.layout-desktop .shop-close-btn,
        body.layout-desktop .leaderboard-close-btn,
        body.layout-desktop .rules-dismiss-btn {
            display: none !important;
        }

        /* Hide mobile setup-box on desktop */
        body.layout-desktop #setup-overlay > .setup-box {
            display: none !important;
        }

        /* === DESKTOP HOME — Mode Selection === */
        #desktop-home { display: none; }
        .dh-config-panel { display: none; }

        body.layout-desktop #desktop-home {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            gap: 24px;
            width: 100%;
            height: 100%;
            padding: 60px 16px 16px 16px;
            box-sizing: border-box;
            overflow-y: auto;
        }

        body.layout-desktop .dh-hero {
            text-align: center;
        }
        body.layout-desktop .dh-logo {
            width: 340px;
            height: auto;
            border-radius: 12px;
            filter: drop-shadow(0 10px 30px rgba(0,0,0,0.8));
            margin-bottom: 10px;
        }
        body.layout-desktop .dh-rank {
            color: var(--copper);
            font-weight: 700;
            font-size: 0.9rem;
            margin-bottom: 4px;
        }
        body.layout-desktop .dh-stats {
            color: var(--text-tertiary);
            font-size: 0.85rem;
        }

        /* Mode cards */
        body.layout-desktop .dh-modes {
            display: flex;
            gap: 24px;
        }
        body.layout-desktop .dh-mode-card {
            width: 280px;
            padding: 36px 28px;
            border-radius: var(--radius-lg);
            border: 1px solid var(--glass-border);
            background: var(--glass-light);
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
        }
        body.layout-desktop .dh-mode-card:hover {
            border-color: var(--glass-border-bright);
            transform: translateY(-4px);
            box-shadow: var(--shadow-lg);
        }
        body.layout-desktop .dh-mode-card.dh-primary {
            background: linear-gradient(135deg, var(--copper-bright), var(--copper));
            color: var(--obsidian);
            border: none;
            box-shadow: var(--shadow-copper);
        }
        body.layout-desktop .dh-mode-card.dh-primary:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 40px var(--copper-glow-strong);
        }
        body.layout-desktop .dh-mode-icon {
            font-size: 3rem;
            margin-bottom: 12px;
        }
        body.layout-desktop .dh-mode-title {
            font-size: 1.3rem;
            font-weight: 800;
            margin-bottom: 6px;
        }
        body.layout-desktop .dh-mode-sub {
            font-size: 0.85rem;
            opacity: 0.85;
            font-weight: 500;
        }

        /* Footer row (auth + music) */
        /* === DESKTOP CONFIG PANELS === */
        body.layout-desktop .dh-config-panel {
            width: 100%;
            height: 100%;
            padding: 60px 16px 16px 16px;
            box-sizing: border-box;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
        }
        body.layout-desktop .dh-config-inner {
            max-width: 800px;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        body.layout-desktop .dh-config-inner .dh-back-btn {
            align-self: flex-start;
        }
        body.layout-desktop .dh-config-inner .dh-config-section {
            width: 100%;
        }
        body.layout-desktop .dh-config-inner .dh-config-grid {
            width: 100%;
        }
        body.layout-desktop .dh-back-btn {
            position: absolute;
            top: 16px;
            left: 16px;
            background: none;
            border: 1px solid var(--glass-border);
            color: var(--text-secondary);
            padding: 8px 20px;
            border-radius: var(--radius-md);
            cursor: pointer;
            font-weight: 600;
            font-size: 0.85rem;
            transition: all 0.2s ease;
            z-index: 10;
        }
        body.layout-desktop .dh-back-btn:hover {
            border-color: var(--glass-border-bright);
            color: var(--text-primary);
        }
        body.layout-desktop .dh-config-title {
            color: var(--copper);
            font-weight: 900;
            font-size: 1.6rem;
            margin-bottom: 24px;
        }
        body.layout-desktop .dh-config-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
        }
        body.layout-desktop .dh-config-section {
            background: var(--glass-light);
            border: 1px solid var(--glass-border);
            border-radius: var(--radius-lg);
            padding: 24px;
        }
        body.layout-desktop .dh-label {
            display: block;
            color: var(--text-secondary);
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            font-weight: 600;
            margin-bottom: 10px;
        }
        /* Difficulty cards */
        body.layout-desktop .dh-difficulty-cards {
            display: flex;
            gap: 10px;
            margin-bottom: 12px;
        }
        body.layout-desktop .dh-diff-card {
            flex: 1;
            padding: 16px 10px;
            border-radius: var(--radius-md);
            border: 1px solid var(--glass-border);
            background: var(--slate-dark);
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        body.layout-desktop .dh-diff-card:hover {
            border-color: var(--glass-border-bright);
            transform: translateY(-2px);
        }
        body.layout-desktop .dh-diff-card.dh-diff-primary {
            border-color: var(--copper);
            background: rgba(201, 150, 91, 0.1);
        }
        body.layout-desktop .dh-diff-card.dh-diff-hard {
            border-color: var(--card-red);
            background: rgba(220, 53, 69, 0.08);
        }
        body.layout-desktop .dh-diff-title {
            font-weight: 800;
            font-size: 0.95rem;
            color: var(--text-primary);
            margin-top: 6px;
        }
        body.layout-desktop .dh-diff-sub {
            font-size: 0.7rem;
            color: var(--text-tertiary);
            margin-top: 4px;
        }

        /* === DESKTOP PROFILE VIEW — Avatar Grid === */
        body.layout-desktop .dh-profile-inner .dh-config-section {
            max-width: 550px;
            width: 100%;
        }
        body.layout-desktop .dh-profile-inner .dh-avatar-grid {
            display: grid !important;
            grid-template-columns: repeat(4, 1fr) !important;
            gap: 12px !important;
        }
        body.layout-desktop .dh-profile-inner .avatar-option {
            width: 100%;
            height: auto;
            aspect-ratio: 1;
            font-size: 1.8rem;
            padding: 8px;
            box-sizing: border-box;
        }

        /* --- TRASH TALK BUBBLES — ensure visible on desktop --- */
        body.layout-desktop .trash-talk-bubble {
            z-index: 6500;
            max-width: 200px;
        }

        /* Large desktop screens — extra breathing room */
        body.layout-desktop.screen-xxlarge .table-container {
            margin-right: calc(var(--ad-right-total) + 20px) !important;
        }

        /* ================================================
           MOBILE LAYOUT — Panel-based screens + Bottom Nav + Sticky Ad
           Triggered by body.layout-mobile (device detection)
           ================================================ */

        /* Hidden by default */
        #mobile-bottom-nav { display: none; }
        #ad-banner-bottom { display: none; }
        #mobile-top-hud { display: none; }

        /* --- LAYOUT VARIABLES --- */
        body.layout-mobile {
            --mob-hud-height: 48px;
            --mob-nav-height: 64px;
            --mob-ad-height: 50px;
            --mob-safe-bottom: env(safe-area-inset-bottom, 0px);
            --mob-bottom-total: calc(var(--mob-nav-height) + var(--mob-ad-height) + var(--mob-safe-bottom));
            --mob-top-total: calc(var(--mob-hud-height) + env(safe-area-inset-top));
        }

        /* --- MOBILE TOP HUD (avatar + name) --- */
        body.layout-mobile #mobile-top-hud {
            display: flex;
            align-items: center;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: var(--mob-hud-height);
            padding-top: env(safe-area-inset-top);
            padding-left: 16px;
            padding-right: 16px;
            background: var(--glass);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-bottom: 1px solid var(--glass-border);
            z-index: 8500;
            gap: 10px;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }
        body.layout-mobile .mob-hud-left {
            display: flex;
            align-items: center;
            gap: 10px;
            flex: 1;
            min-width: 0;
        }
        body.layout-mobile .mob-hud-avatar {
            font-size: 1.5rem;
            line-height: 1;
            flex-shrink: 0;
        }
        body.layout-mobile .mob-hud-name {
            font-size: 0.85rem;
            font-weight: 700;
            color: var(--text-primary);
            text-transform: uppercase;
            letter-spacing: 0.04em;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        body.layout-mobile .mob-hud-right {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-shrink: 0;
        }
        body.layout-mobile .mob-hud-stat {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        body.layout-mobile #mob-hud-coins {
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }
        body.layout-mobile .mob-hud-music {
            font-size: 1.2rem;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            margin-left: 4px;
            line-height: 1;
            padding: 8px 0 8px 8px;
            min-width: 28px;
            min-height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* --- BOTTOM AD BANNER (sticky, very bottom) --- */
        body.layout-mobile #ad-banner-bottom {
            display: flex;
            align-items: center;
            justify-content: center;
            position: fixed;
            bottom: var(--mob-safe-bottom);
            left: 0;
            right: 0;
            height: var(--mob-ad-height);
            background: linear-gradient(135deg, #1a1a2e, #16213e);
            border-top: 1px solid var(--glass-border);
            color: var(--text-tertiary);
            font-size: 0.65rem;
            letter-spacing: 0.12em;
            font-weight: 600;
            z-index: 8000;
        }

        /* --- NATIVE AD BANNER OVERRIDE (Capacitor AdMob) ---
           When a native AdMob banner is active, it renders as a native overlay
           at the bottom of the screen. We must push the WebView content up by
           the actual banner height so it doesn't overlap the bottom nav. */
        body.layout-mobile.native-ad-active {
            --mob-ad-height: var(--native-ad-height, 50px);
            --mob-bottom-total: calc(var(--mob-nav-height) + var(--mob-ad-height) + var(--mob-safe-bottom));
        }

        /* --- BOTTOM NAVIGATION BAR (above ad) --- */
        body.layout-mobile #mobile-bottom-nav {
            display: flex;
            align-items: center;
            justify-content: space-around;
            position: fixed;
            bottom: calc(var(--mob-ad-height) + var(--mob-safe-bottom));
            left: 0;
            right: 0;
            height: var(--mob-nav-height);
            background: var(--glass);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-top: 1px solid var(--glass-border);
            z-index: 8500;
            padding-bottom: 0;
        }

        /* --- NAV SLIDING CIRCLE (copper circle moves to active tab) --- */
        body.layout-mobile .mob-nav-circle {
            position: absolute;
            /* Center vertically in the nav bar */
            top: 50%;
            transform: translateY(-50%);
            width: 20%;
            display: flex;
            justify-content: center;
            align-items: center;
            pointer-events: none;
            z-index: 0;
            transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        body.layout-mobile .mob-nav-circle::after {
            content: '';
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--copper-bright), var(--copper));
            box-shadow: 0 4px 16px var(--copper-glow);
        }

        /* --- NAV TABS --- */
        body.layout-mobile .mob-nav-tab {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            height: 100%;
            cursor: pointer;
            color: var(--text-tertiary);
            gap: 2px;
            transition: color 0.2s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            position: relative;
            z-index: 1;
            transform: scale(1);
        }
        body.layout-mobile .mob-nav-tab.active {
            color: var(--obsidian);
            transform: scale(1.25);
        }
        body.layout-mobile .mob-nav-tab.active .mob-nav-label {
            color: var(--obsidian);
        }
        body.layout-mobile .mob-nav-icon {
            font-size: 1.4rem;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }
        body.layout-mobile .mob-nav-label {
            font-size: 0.6rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            transition: color 0.2s ease;
        }

        /* --- SCREENS: fit between top HUD and bottom nav+ad, align top --- */
        body.layout-mobile .screen {
            top: var(--mob-top-total);
            bottom: var(--mob-bottom-total);
            left: 0;
            right: 0;
            justify-content: flex-start;
            padding: 16px;
            overflow-y: auto;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            /* Hide scrollbar to prevent gutter stealing horizontal space */
            scrollbar-width: none;
            -ms-overflow-style: none;
        }
        body.layout-mobile .screen::-webkit-scrollbar {
            display: none;
        }

        /* --- SWIPE NAVIGATION TRANSITIONS --- */
        body.layout-mobile .screen.slide-out-left {
            transition: transform 250ms ease-out;
            transform: translateX(-100%);
        }
        body.layout-mobile .screen.slide-out-right {
            transition: transform 250ms ease-out;
            transform: translateX(100%);
        }
        /* Incoming: starts off-screen, then slides to center */
        body.layout-mobile .screen.slide-in-right {
            transform: translateX(100%);
        }
        body.layout-mobile .screen.slide-in-left {
            transform: translateX(-100%);
        }
        body.layout-mobile .screen.slide-in-right-active,
        body.layout-mobile .screen.slide-in-left-active {
            transition: transform 250ms ease-out;
            transform: translateX(0);
        }

        /* Rules list — allow wrapping on narrow screens */
        body.layout-mobile .rules-list li {
            gap: 12px;
        }
        body.layout-mobile .rules-list li span:last-child {
            flex-shrink: 1;
            min-width: 0;
            word-break: break-word;
        }

        /* Force border-box on everything inside mobile screens to prevent overflow */
        body.layout-mobile .screen *,
        body.layout-mobile .screen *::before,
        body.layout-mobile .screen *::after {
            box-sizing: border-box;
        }

        /* --- MOBILE SETUP: hide old scrollable setup-box, show panels --- */
        body.layout-mobile #setup-overlay > .setup-box {
            display: none !important;
        }

        /* Show the desktop home panel on mobile — NO !important so JS can hide it */
        body.layout-mobile #desktop-home {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            gap: 16px;
            width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-hero {
            text-align: center !important;
            width: 100%;
        }
        body.layout-mobile .dh-hero,
        body.layout-mobile .dh-hero * {
            text-align: center !important;
        }
        body.layout-mobile .dh-logo {
            width: 230px;
            height: auto;
            border-radius: 10px;
            filter: drop-shadow(0 8px 20px rgba(0,0,0,0.8));
            margin-bottom: 6px;
        }
        body.layout-mobile .dh-rank {
            color: var(--copper);
            font-weight: 700;
            font-size: 0.85rem;
            margin-bottom: 4px;
        }
        /* Hide only XP/coins lines on mobile; keep "Next: RANK" visible */
        body.layout-mobile .dh-stat-line {
            display: none !important;
        }

        /* Mode cards — stack vertically on mobile */
        body.layout-mobile .dh-modes {
            display: flex;
            flex-direction: column;
            gap: 14px;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-mode-card {
            width: 100%;
            max-width: 100%;
            padding: 16px;
            border-radius: var(--radius-lg);
            border: 1px solid var(--glass-border);
            background: var(--glass-light);
            color: var(--text-primary);
            cursor: pointer;
            text-align: center;
            transition: all 0.2s ease;
        }
        body.layout-mobile .dh-mode-card.dh-primary {
            background: linear-gradient(135deg, var(--copper-bright), var(--copper));
            color: var(--obsidian);
            border: none;
            box-shadow: var(--shadow-copper);
        }
        body.layout-mobile .dh-mode-icon {
            font-size: 2rem;
            margin-bottom: 4px;
        }
        body.layout-mobile .dh-mode-title {
            font-size: 1rem;
            font-weight: 800;
            margin-bottom: 2px;
        }
        body.layout-mobile .dh-mode-sub {
            font-size: 0.8rem;
            opacity: 0.85;
            font-weight: 500;
        }

        /* Config panels — show on mobile with mobile styling */
        body.layout-mobile .dh-config-panel {
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            flex-direction: column;
            align-items: center;
            position: relative;
            overflow-x: hidden;
        }
        body.layout-mobile .dh-config-inner {
            max-width: 100%;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-config-title {
            color: var(--copper);
            font-weight: 900;
            font-size: 1.3rem;
            margin-bottom: 20px;
        }
        body.layout-mobile .dh-config-section {
            background: var(--glass-light);
            border: 1px solid var(--glass-border);
            border-radius: var(--radius-lg);
            padding: 16px;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-label {
            display: block;
            color: var(--text-secondary);
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            font-weight: 600;
            margin-bottom: 8px;
        }
        body.layout-mobile .dh-back-btn {
            position: absolute;
            top: 12px;
            left: 12px;
            background: none;
            border: 1px solid var(--glass-border);
            color: var(--text-secondary);
            padding: 6px 16px;
            border-radius: var(--radius-md);
            cursor: pointer;
            font-weight: 600;
            font-size: 0.8rem;
            z-index: 10;
        }
        body.layout-mobile .dh-difficulty-cards {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
        }
        body.layout-mobile .dh-diff-card {
            flex: 1;
            padding: 14px 8px;
            border-radius: var(--radius-md);
            border: 1px solid var(--glass-border);
            background: var(--slate-dark);
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        body.layout-mobile .dh-diff-card.dh-diff-primary {
            border-color: var(--copper);
            background: rgba(201, 150, 91, 0.1);
        }
        body.layout-mobile .dh-diff-card.dh-diff-hard {
            border-color: var(--card-red);
            background: rgba(220, 53, 69, 0.08);
        }
        body.layout-mobile .dh-diff-title {
            font-weight: 800;
            font-size: 0.85rem;
            color: var(--text-primary);
            margin-top: 4px;
        }
        body.layout-mobile .dh-diff-sub {
            font-size: 0.65rem;
            color: var(--text-tertiary);
            margin-top: 3px;
        }

        /* Profile panel on mobile */
        body.layout-mobile .dh-profile-inner {
            max-width: 100%;
            width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-profile-inner .dh-config-section {
            max-width: 100%;
            width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-profile-inner .dh-avatar-grid {
            display: grid !important;
            grid-template-columns: repeat(4, 1fr) !important;
            gap: 10px !important;
            width: 100%;
            box-sizing: border-box;
        }
        body.layout-mobile .dh-profile-inner .avatar-option {
            width: 100%;
            height: auto;
            aspect-ratio: 1;
            font-size: 1.6rem;
            padding: 6px;
            box-sizing: border-box;
            min-width: 0;
        }

        /* --- HIDE DESKTOP ELEMENTS ON MOBILE --- */
        body.layout-mobile #desktop-sidebar {
            display: none !important;
        }
        body.layout-mobile #ad-banner-top {
            display: none !important;
        }
        body.layout-mobile #ad-sidebar-right {
            display: none !important;
        }

        /* --- HIDE OLD MOBILE NAV BUTTONS + CLOSE BUTTONS (bottom nav replaces them) --- */
        body.layout-mobile .setup-nav-buttons,
        body.layout-mobile .shop-close-btn,
        body.layout-mobile .leaderboard-close-btn,
        body.layout-mobile .rules-dismiss-btn {
            display: none !important;
        }

        /* --- SHOP / LEADERBOARD / RULES — full width, no inner scroll on mobile --- */
        body.layout-mobile #shop-overlay .setup-box,
        body.layout-mobile #leaderboard-overlay .setup-box,
        body.layout-mobile #rules-overlay .setup-box {
            max-width: 100%;
            width: 100%;
            max-height: none;
            overflow-y: visible;
            border-radius: 0;
            border: none;
            background: transparent;
            box-shadow: none;
            padding: 16px;
        }

        /* --- TOAST — top below HUD on mobile --- */
        body.layout-mobile .toast {
            top: calc(var(--mob-top-total) + 10px) !important;
            bottom: auto !important;
            left: 50% !important;
            transform: translateX(-50%) !important;
            max-width: calc(100vw - 40px);
            font-size: clamp(0.75rem, 2.5vw, 1.1rem);
            padding: 8px 16px;
            min-width: 0;
            border-radius: 30px;
            border-width: 2px;
        }

        /* --- LOCK VIEWPORT WIDTH ON MOBILE --- */
        html.layout-mobile {
            overflow: clip !important;
            width: 100% !important;
        }
        body.layout-mobile {
            overflow: clip !important;
            width: 100% !important;
        }

        /* --- GAMEPLAY: game fills between HUD and ad banner --- */
        body.layout-mobile .game-wrapper {
            position: fixed !important;
            top: var(--mob-hud-height) !important;
            bottom: calc(var(--mob-ad-height) + var(--mob-safe-bottom)) !important;
            left: 0 !important;
            right: 0 !important;
            height: auto !important;
            margin: 0 !important;
            padding: 0 !important;
            box-sizing: border-box;
            overflow: clip !important;
        }
        body.layout-mobile .table-container {
            height: 100% !important;
            margin: 0 !important;
            border-radius: 0 !important;
            overflow: visible !important;
        }
        /* Reduce felt margin on mobile to use more space */
        body.layout-mobile .felt-surface {
            margin: 4px !important;
        }
        /* Player-bar: clip horizontally, visible vertically so cards pop up */
        body.layout-mobile .player-bar {
            overflow-x: clip !important;
            overflow-y: visible !important;
            padding-bottom: 4px;
        }

        /* --- HAND AREA: scrollable horizontal, card pop-up contained via padding --- */
        body.layout-mobile .hand-area {
            overflow-x: auto !important;
            overflow-y: hidden !important;
            justify-content: flex-start;
            padding: 35px 12px 4px 12px;
            margin-top: -35px;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            touch-action: pan-x;
        }
        body.layout-mobile .hand-area .card {
            touch-action: pan-x;
        }
        body.layout-mobile .hand-area .card:first-child {
            margin-left: 0 !important;
        }
        body.layout-mobile .hand-area .card:last-child {
            margin-right: 0 !important;
        }
        body.layout-mobile .hand-area::-webkit-scrollbar {
            display: none;
        }
        body.layout-mobile .hand-area .card:hover {
            transform: translateY(-12px);
            margin: 0 -8px !important;
        }
        body.layout-mobile .hand-area .card.selected {
            transform: translateY(-30px) scale(1.05);
            margin: 0 -8px !important;
        }

        /* --- Hide old nav-controls and music bar on mobile (HUD replaces them) --- */
        body.layout-mobile .nav-controls {
            display: none !important;
        }
        body.layout-mobile .game-music-control {
            display: none !important;
        }

        /* --- GAME HUD BUTTONS --- */
        body.layout-mobile .mob-game-btn {
            font-size: 1.3rem;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            padding: 4px;
            line-height: 1;
        }

        /* --- ACHIEVEMENT — below HUD on mobile --- */
        body.layout-mobile .achievement-popup {
            top: calc(var(--mob-top-total) + 10px) !important;
            left: 50% !important;
            transform: translateX(-50%) !important;
            padding: 10px 18px;
            border-radius: 12px;
            border-width: 2px;
            max-width: calc(100vw - 40px);
        }
        body.layout-mobile .achievement-icon {
            font-size: clamp(1.5rem, 5vw, 3rem);
            margin-bottom: 4px;
        }
        body.layout-mobile .achievement-title {
            font-size: clamp(0.8rem, 2.8vw, 1.2rem);
            margin-bottom: 2px;
        }
        body.layout-mobile .achievement-desc {
            font-size: clamp(0.65rem, 2.2vw, 0.9rem);
        }

        /* --- GAMEPLAY OVERLAYS — full screen on mobile --- */
        body.layout-mobile #game-over-overlay,
        body.layout-mobile #pause-overlay,
        body.layout-mobile #level-up-overlay,
        body.layout-mobile #suit-picker,
        body.layout-mobile #wild-picker,
        body.layout-mobile #demo-complete-overlay {
            top: 0;
            bottom: 0;
        }

