        /* ==========================================================================
           1. CSS RESET & VARIABLES
           ========================================================================== */
        *, ::before, ::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: #e5e7eb; }
        ::before, ::after { --tw-content: ''; }
        html { line-height: 1.5; -webkit-text-size-adjust: 100%; tab-size: 4; font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
        body { margin: 0; line-height: inherit; background-color: #050629;}
        hr { height: 0; color: inherit; border-top-width: 1px; }
        button, input, optgroup, select, textarea { font-family: inherit; font-size: 100%; font-weight: inherit; line-height: inherit; color: inherit; margin: 0; padding: 0; }
        button, [type='button'], [type='reset'], [type='submit'] { -webkit-appearance: button; background-color: transparent; background-image: none; }
        button { cursor: pointer; }
        h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; margin: 0; }
        p { margin: 0; }
        ul { list-style: none; margin: 0; padding: 0; }
        
        *, ::before, ::after {
            --tw-translate-x: 0;
            --tw-translate-y: 0;
            --tw-rotate: 0;
            --tw-skew-x: 0;
            --tw-skew-y: 0;
            --tw-scale-x: 1;
            --tw-scale-y: 1;
            --tw-transform: translateX(var(--tw-translate-x)) translateY(var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
        }

        /* ==========================================================================
           2. TAILWIND COMPILED UTILITIES
           ========================================================================== */
        /* Layout & Position */
        .absolute { position: absolute; }
        .relative { position: relative; }
        .fixed { position: fixed; }
        .inset-0 { top: 0px; right: 0px; bottom: 0px; left: 0px; }
        .top-4 { top: 1rem; }
        .top-10 { top: 2.5rem; }
        .-top-3 { top: -0.75rem; }
        .left-1\/2 { left: 50%; }
        .z-10 { z-index: 10; }
        .z-40 { z-index: 40; }
        .z-50 { z-index: 50; }
        .flex { display: flex; }
        .grid { display: grid; }
        .hidden { display: none !important; }
        .block { display: block; }
        
        /* Flexbox */
        .flex-col { flex-direction: column; }
        .flex-row { flex-direction: row; }
        .flex-1 { flex: 1 1 0%; }
        .flex-grow { flex-grow: 1; }
        .flex-shrink-0 { flex-shrink: 0; }
        .flex-wrap { flex-wrap: wrap; }
        .items-center { align-items: center; }
        .justify-center { justify-content: center; }
        .justify-between { justify-content: space-between; }
        
        /* Grid */
        .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        
        /* Spacing (Margin & Padding) */
        .m-0 { margin: 0px; }
        .mx-4 { margin-left: 1rem; margin-right: 1rem; }
        .mb-2 { margin-bottom: 0.5rem; }
        .mb-3 { margin-bottom: 0.75rem; }
        .mb-4 { margin-bottom: 1rem; }
        .mb-6 { margin-bottom: 1.5rem; }
        .mb-8 { margin-bottom: 2rem; }
        .mb-10 { margin-bottom: 2.5rem; }
        .mt-1 { margin-top: 0.25rem; }
        .mt-2 { margin-top: 0.5rem; }
        .mt-4 { margin-top: 1rem; }
        .ml-1 { margin-left: 0.25rem; }
        
        .p-2 { padding: 0.5rem; }
        .p-3 { padding: 0.75rem; }
        .p-4 { padding: 1rem; }
        .p-6 { padding: 1.5rem; }
        .p-8 { padding: 2rem; }
        .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
        .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
        .px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
        .px-4 { padding-left: 1rem; padding-right: 1rem; }
        .px-8 { padding-left: 2rem; padding-right: 2rem; }
        .py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
        .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
        .py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
        .py-4 { padding-top: 1rem; padding-bottom: 1rem; }
        .pl-5 { padding-left: 1.25rem; }
        
        /* Gap & Space Between */
        .gap-1 { gap: 0.25rem; }
        .gap-2 { gap: 0.5rem; }
        .gap-3 { gap: 0.75rem; }
        .gap-4 { gap: 1rem; }
        .space-y-1 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem; }
        .space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
        .space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
        .space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
        
        /* Sizing */
        .w-full { width: 100%; }
        .h-full { height: 100%; }
        .w-screen { width: 100vw; }
        .h-screen { height: 100vh; }
        .w-2 { width: 0.5rem; } .h-2 { height: 0.5rem; }
        .w-3 { width: 0.75rem; } .h-3 { height: 0.75rem; }
        .w-4 { width: 1rem; } .h-4 { height: 1rem; }
        .w-5 { width: 1.25rem; } .h-5 { height: 1.25rem; }
        .w-6 { width: 1.5rem; } .h-6 { height: 1.5rem; }
        .w-8 { width: 2rem; } .h-8 { height: 2rem; }
        .w-1\/3 { width: 33.333333%; }
        .w-2\/3 { width: 66.666667%; }
        .max-w-sm { max-width: 24rem; }
        .max-w-md { max-width: 28rem; }
        .max-w-lg { max-width: 50rem; }
        .max-w-2xl { max-width: 50rem; }
        .max-w-\[200px\] { max-width: 200px; }
        .h-48 { height: 12rem; }
        .h-64 { height: 16rem; }
        .min-h-\[6rem\] { min-height: 6rem; }
        .max-h-\[90vh\] { max-height: 90vh; }
        .h-px { height: 1px; }

        /* Typography */
        .font-display { font-family: 'Poppins', sans-serif; }
        .font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
        .text-xxs { font-size: 11.5px; }
        .text-xs { font-size: 0.85rem;line-height: 1.2rem; }
        .text-sm { font-size: 0.875rem; line-height: 1.25rem; }
        .text-base { font-size: 1rem; line-height: 1.5rem; }
        .text-lg { font-size: 1.125rem; line-height: 1.75rem; }
        .text-xl { font-size: 1.25rem; line-height: 1.75rem; }
        .text-2xl { font-size: 1.5rem; line-height: 2rem; }
        .text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
        .text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
        .text-5xl { font-size: 3rem; line-height: 1; }
        .text-6xl { font-size: 3.75rem; line-height: 1; }
        .text-8xl { font-size: 6rem; line-height: 1; }
        .font-semibold { font-weight: 600; }
        .font-bold { font-weight: 700; }
        .font-black { font-weight: 900; }
        .text-center { text-align: center; }
        .text-right { text-align: right; }
        .uppercase { text-transform: uppercase; }
        .tracking-wider { letter-spacing: 0.05em; }
        .list-disc { list-style-type: disc; }

        /* Colors - Background */
        .bg-slate-800 { background-color: #1e293b; }
        .bg-slate-800\/50 { background-color: rgba(30, 41, 59, 0.5); }
        .bg-slate-900\/80 { background-color: rgba(15, 23, 42, 0.8); }
        .bg-slate-900\/90 { background-color: rgba(15, 23, 42, 0.9); }
        .bg-slate-700 { background-color: #334155; }
        .bg-emerald-600 { background-color: #059669; }
        .bg-emerald-500 { background-color: #10b981; }
        .bg-red-500 { background-color: #ef4444; }
        .bg-red-900\/50 { background-color: rgba(127, 29, 29, 0.5); }
        .bg-purple-500 { background-color: #a855f7; }
        .bg-purple-900\/30 { background-color: rgba(88, 28, 135, 0.3); }
        .bg-purple-900\/40 { background-color: rgba(88, 28, 135, 0.4); }
        .bg-pink-500\/10 { background-color: rgba(236, 72, 153, 0.1); }
        .bg-yellow-500\/20 { background-color: rgba(234, 179, 8, 0.2); }
        .bg-black\/20 { background-color: rgba(0, 0, 0, 0.2); }
        .bg-black\/30 { background-color: rgba(0, 0, 0, 0.3); }
        .bg-white\/5 { background-color: rgba(255, 255, 255, 0.05); }
        .bg-slate-500 { background-color: #64748b; }
        
        .hover\:bg-slate-700:hover { background-color: #334155; }
        .hover\:bg-slate-600:hover { background-color: #475569; }
        .hover\:bg-emerald-500:hover { background-color: #10b981; }
        .hover\:bg-red-800\/80:hover { background-color: rgba(153, 27, 27, 0.8); }

        /* Colors - Text */
        .text-white { color: #ffffff; }
        .text-slate-200 { color: #e2e8f0; }
        .text-slate-300 { color: #cbd5e1; }
        .text-slate-400 { color: #94a3b8; }
        .text-slate-500 { color: #64748b; }
        .text-purple-300 { color: #d8b4fe; }
        .text-purple-400 { color: #c084fc; }
        .text-pink-400 { color: #f472b6; }
        .text-emerald-400 { color: #34d399; }
        .text-red-400 { color: #f87171; }
        .text-red-500 { color: #ef4444; }
        .text-yellow-500 { color: #eab308; }
        .hover\:text-white:hover { color: #ffffff; }
        .hover\:text-red-500:hover { color: #ef4444; }
        
        /* Gradients */
        .bg-clip-text { background-clip: text; -webkit-background-clip: text; }
        .text-transparent { color: transparent; }

        .from-purple-600 { --tw-gradient-from: #9333ea; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(147, 51, 234, 0)); }
        .to-indigo-600 { --tw-gradient-to: #4f46e5; }
        .hover\:from-purple-500:hover { --tw-gradient-from: #a855f7; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(168, 85, 247, 0)); }
        .hover\:to-indigo-500:hover { --tw-gradient-to: #6366f1; }

        .from-purple-400 { --tw-gradient-from: #c084fc; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(192, 132, 252, 0)); }
        .to-pink-500 { --tw-gradient-to: #ec4899; }

        .from-blue-600 { --tw-gradient-from: #2563eb; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(37, 99, 235, 0)); }
        .hover\:from-blue-500:hover { --tw-gradient-from: #3b82f6; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(59, 130, 246, 0)); }

        .from-emerald-600 { --tw-gradient-from: #059669; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(5, 150, 105, 0)); }
        .to-teal-600 { --tw-gradient-to: #0d9488; }
        .hover\:from-emerald-500:hover { --tw-gradient-from: #10b981; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(16, 185, 129, 0)); }
        .hover\:to-teal-500:hover { --tw-gradient-to: #14b8a6; }

        .from-pink-500 { --tw-gradient-from: #ec4899; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(236, 72, 153, 0)); }
        .to-orange-500 { --tw-gradient-to: #f97316; }

        .from-yellow-400 { --tw-gradient-from: #facc15; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(250, 204, 21, 0)); }
        .via-orange-500 { --tw-gradient-stops: var(--tw-gradient-from), #f97316, var(--tw-gradient-to, rgba(249, 115, 22, 0)); }
        .to-yellow-400 { --tw-gradient-to: #facc15; }

        .bg-gradient-to-br { background-image: linear-gradient(to bottom right, var(--tw-gradient-stops)); }
        .bg-gradient-to-r { background-image: linear-gradient(to right, var(--tw-gradient-stops)); }

        /* Borders & Ring */
        .border { border-width: 1px; }
        .border-t { border-top-width: 1px; }
        .border-b { border-bottom-width: 1px; }
        .border-l-2 { border-left-width: 2px; }
        
        .border-slate-600 { border-color: #475569; }
        .border-slate-700 { border-color: #334155; }
        .border-purple-500 { border-color: #a855f7; }
        .border-transparent { border-color: transparent; }
        .border-white\/20 { border-color: rgba(255, 255, 255, 0.2); }
        .border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
        .border-red-500\/30 { border-color: rgba(239, 68, 68, 0.3); }
        .border-purple-500\/30 { border-color: rgba(168, 85, 247, 0.3); }

        .rounded { border-radius: 0.25rem; padding: 2px;}
        .rounded-lg { border-radius: 0.5rem; }
        .rounded-xl { border-radius: 0.75rem; }
        .rounded-2xl { border-radius: 1rem; }
        .rounded-full { border-radius: 9999px; }

        .focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
        .focus\:ring-2:focus { box-shadow: 0 0 0 2px #a855f7; }
        
        /* Shadow & Effects */
        .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
        .shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
        .drop-shadow-lg { filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.04)) drop-shadow(0 4px 3px rgba(0, 0, 0, 0.1)); }
        .drop-shadow-2xl { filter: drop-shadow(0 25px 25px rgba(0, 0, 0, 0.15)); }
        
        .backdrop-blur-sm { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
        .backdrop-blur-md { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
        .backdrop-blur-xl { backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }

        /* Transforms, Transitions & Animations */
        .transform { transform: var(--tw-transform); }
        .-translate-x-1\/2 { --tw-translate-x: -50%; }
        .translate-y-4 { --tw-translate-y: 1rem; }
        .scale-50 { --tw-scale-x: .5; --tw-scale-y: .5; }
        .scale-100 { --tw-scale-x: 1; --tw-scale-y: 1; }
        .scale-110 { --tw-scale-x: 1.1; --tw-scale-y: 1.1; }
        .active\:scale-95:active { --tw-scale-x: .95; --tw-scale-y: .95; }
        
        .transition { transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
        .transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
        .transition-opacity { transition-property: opacity; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
        .transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
        .duration-300 { transition-duration: 300ms; }
        .duration-500 { transition-duration: 500ms; }
        .duration-700 { transition-duration: 700ms; }
        
        .opacity-0 { opacity: 0; }
        .opacity-50 { opacity: 0.5; }
        .opacity-100 { opacity: 1; }
        .disabled\:opacity-50:disabled { opacity: 0.5; }
        
        .animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
        @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
        
        .animate-toast { animation: fadeInDown 0.3s ease-out; }
        .animate-log { animation: fadeIn 0.3s ease-out; }
        @keyframes fadeIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
        @keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px) translateX(-50%); } to { opacity: 1; transform: translateY(0) translateX(-50%); } }

        /* NEW: Dice Farkle Spell Animation */
        @keyframes dieFarkleShake {
           0%, 100% { transform: scale(1.15) rotate(0deg); }
           25% { transform: scale(1.15) rotate(-5deg); }
           75% { transform: scale(1.15) rotate(5deg); }
        }
        .farkle-die-anim {
             animation: dieFarkleShake 0.3s infinite !important;
             z-index: 50;
        }
        .farkle-die-anim .die-face .dot {
            opacity: 0 !important;
        }
        .farkle-die-anim .die-face::after {
            content: attr(data-farkle-char);
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 3rem;
            font-weight: 900;
            color: #ef4444;
            text-shadow: 0 0 15px rgba(239,68,68,0.8);
            font-family: 'Poppins', sans-serif;
        }
        .farkle-die-anim .die-face {
            background: #0f172a !important; 
            border-color: #ef4444 !important;
            box-shadow: 0 0 20px rgba(239,68,68,0.6) !important;
        }

        /* Misc */
        .overflow-hidden { overflow: hidden; }
        .overflow-y-auto { overflow-y: auto; }
        .pointer-events-none { pointer-events: none; }
        .cursor-not-allowed { cursor: not-allowed; }
        .disabled\:cursor-not-allowed:disabled { cursor: not-allowed; }
        ::selection { background-color: #a855f7; color: #ffffff; }

        /* Responsive Breakpoints */
        @media (min-width: 768px) {
            .md\:flex-row { flex-direction: row; }
            .md\:w-64 { width: 16rem; }
            .md\:w-80 { width: 20rem; }
            .md\:h-auto { height: auto; }
            .md\:h-full { height: 100%; }
            .md\:h-64 { height: 16rem; }
            .md\:p-6 { padding: 1.5rem; }
            .md\:p-8 { padding: 2rem; }
            .md\:gap-4 { gap: 1rem; }
            .md\:text-base { font-size: 1rem; line-height: 1.5rem; }
            .md\:text-sm { font-size: 0.875rem; line-height: 1.25rem; }
            .md\:text-5xl { font-size: 3rem; line-height: 1; }
            .md\:text-8xl { font-size: 6rem; line-height: 1; }
        }

        /* ==========================================================================
           3. CUSTOM GAME STYLES
           ========================================================================== */
        /* Glassmorphism */
        .glass {
            background: rgba(30, 41, 59, 0.7);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* 3D Dice Styles */
        :root {
            --die-size: 4rem;
            --die-tz: 2rem;
        }
        @media (min-width: 640px) {
            :root {
                --die-size: 5rem;
                --die-tz: 2.5rem;
            }
        }

        .die-scene {
            width: var(--die-size);
            height: var(--die-size);
            perspective: 800px;
            cursor: pointer;
            position: relative;
            top: 0;
            transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .die-scene:active {
            transform: scale(0.95);
        }

        .die-cube {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
        }

        .die-face {
            position: absolute;
            width: 100%;
            height: 100%;
            background: white;
            border-radius: 0.75rem;
            box-shadow: inset 0 0 15px rgba(0,0,0,0.1), 0 0 2px rgba(0,0,0,0.2);
            border: 1px solid #e5e7eb;
            display: grid;
            grid-template-areas:
                "a . c"
                "e g f"
                "d . b";
            padding: 0.5rem;
            gap: 0.25rem;
            backface-visibility: hidden;
        }

        @media (min-width: 640px) {
            .die-face { padding: 0.75rem; gap: 0.375rem; }
        }

        .face-1 { transform: rotateY(0deg) translateZ(var(--die-tz)); }
        .face-2 { transform: rotateX(-90deg) translateZ(var(--die-tz)); }
        .face-3 { transform: rotateY(90deg) translateZ(var(--die-tz)); }
        .face-4 { transform: rotateY(-90deg) translateZ(var(--die-tz)); }
        .face-5 { transform: rotateX(90deg) translateZ(var(--die-tz)); }
        .face-6 { transform: rotateY(180deg) translateZ(var(--die-tz)); }

        .die-scene.locked .die-face { 
            background: #10b981; 
            box-shadow: inset 0 0 15px rgba(0,0,0,0.2), 0 0 2px rgba(0,0,0,0.3);
            border-color: #059669;
        }
        .die-scene.locked .dot { background: white; }
        
        .die-scene.banked { opacity: 0.6; cursor: not-allowed; }
        .die-scene.banked .die-face { background: #374151; border-color: #1f2937; }
        .die-scene.banked .dot { background: #9ca3af; }

        .dot {
            background: #1f2937;
            border-radius: 50%;
            width: 100%;
            height: 100%;
        }

        /* Dot Positions */
        .die-face[data-face-val="1"] .dot:nth-child(1) { grid-area: g; }
        
        .die-face[data-face-val="2"] .dot:nth-child(1) { grid-area: a; }
        .die-face[data-face-val="2"] .dot:nth-child(2) { grid-area: b; }
        
        .die-face[data-face-val="3"] .dot:nth-child(1) { grid-area: a; }
        .die-face[data-face-val="3"] .dot:nth-child(2) { grid-area: g; }
        .die-face[data-face-val="3"] .dot:nth-child(3) { grid-area: b; }
        
        .die-face[data-face-val="4"] .dot:nth-child(1) { grid-area: a; }
        .die-face[data-face-val="4"] .dot:nth-child(2) { grid-area: c; }
        .die-face[data-face-val="4"] .dot:nth-child(3) { grid-area: d; }
        .die-face[data-face-val="4"] .dot:nth-child(4) { grid-area: b; }
        
        .die-face[data-face-val="5"] .dot:nth-child(1) { grid-area: a; }
        .die-face[data-face-val="5"] .dot:nth-child(2) { grid-area: c; }
        .die-face[data-face-val="5"] .dot:nth-child(3) { grid-area: g; }
        .die-face[data-face-val="5"] .dot:nth-child(4) { grid-area: d; }
        .die-face[data-face-val="5"] .dot:nth-child(5) { grid-area: b; }
        
        .die-face[data-face-val="6"] .dot:nth-child(1) { grid-area: a; }
        .die-face[data-face-val="6"] .dot:nth-child(2) { grid-area: c; }
        .die-face[data-face-val="6"] .dot:nth-child(3) { grid-area: e; }
        .die-face[data-face-val="6"] .dot:nth-child(4) { grid-area: f; }
        .die-face[data-face-val="6"] .dot:nth-child(5) { grid-area: d; }
        .die-face[data-face-val="6"] .dot:nth-child(6) { grid-area: b; }

        @keyframes bounce-roll {
            0% { top: 0; }
            50% { top: -3rem; }
            100% { top: 0; }
        }

        .rolling-bounce {
            animation: bounce-roll 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
        }

        /* Custom Scrollbar */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
        ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

        #toast-container { z-index: 1000; }

        /* ==========================================================================
           1. CSS RESET & VARIABLES
           ========================================================================== */
        *, ::before, ::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: #e5e7eb; }
        ::before, ::after { --tw-content: ''; }
        html { 
            line-height: 1.5; 
            -webkit-text-size-adjust: 100%; 
            tab-size: 4; 
            font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
            height: 100%;
        }
        body { 
            margin: 0; 
            line-height: inherit; 
            background-color: #050629; 
            height: 100dvh; /* Mobile-friendly height */
            overflow: hidden;
            overscroll-behavior: none; /* Prevents pull-to-refresh */
        }
        
        /* ==========================================================================
           2. TAILWIND & RESPONSIVE UTILITIES
           ========================================================================== */
        .absolute { position: absolute; }
        .relative { position: relative; }
        .fixed { position: fixed; }
        .inset-0 { top: 0px; right: 0px; bottom: 0px; left: 0px; }
        .top-4 { top: 1rem; }
        .z-50 { z-index: 50; }
        .flex { display: flex; }
        .hidden { display: none !important; }
        .flex-col { flex-direction: column; }
        .items-center { align-items: center; }
        .justify-center { justify-content: center; }
        .w-full { width: 100%; }
        .h-full { height: 100%; }
        
        /* Mobile Specific Layout Adjustments */
        #game-screen {
            display: flex;
            flex-direction: column;
            height: 100%;
            padding: 0.5rem;
            gap: 0.5rem;
        }

        @media (min-width: 768px) {
            #game-screen {
                flex-direction: row;
                padding: 1.5rem;
                gap: 1rem;
            }
        }

        /* Responsive Sidebar */
        .player-sidebar {
            width: 100%;
            max-height: 25dvh; /* Limit height on mobile */
        }

        @media (min-width: 768px) {
            .player-sidebar {
                width: 16rem;
                max-height: none;
            }
        }

        /* ==========================================================================
           3. DICE SCALING FOR SMALL SCREENS
           ========================================================================== */
        :root {
            --die-size: 3.2rem; /* Smaller for mobile */
            --die-tz: 1.6rem;
        }
        @media (min-width: 400px) {
            :root {
                --die-size: 4rem;
                --die-tz: 2rem;
            }
        }
        @media (min-width: 768px) {
            :root {
                --die-size: 5rem;
                --die-tz: 2.5rem;
            }
        }

        .die-scene {
            width: var(--die-size);
            height: var(--die-size);
            perspective: 800px;
            touch-action: manipulation; /* Faster taps on mobile */
        }

        .die-face {
            position: absolute;
            width: 100%;
            height: 100%;
            background: white;
            border-radius: 0.5rem;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.1);
            border: 1px solid #e5e7eb;
            display: grid;
            padding: 0.35rem;
            gap: 0.15rem;
            backface-visibility: hidden;
        }

        /* ==========================================================================
           4. GLASS & UI ELEMENTS
           ========================================================================== */
        .glass {
            background: rgba(30, 41, 59, 0.7);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1rem;
        }

        #board-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-around; /* Distribute space better on vertical screens */
            padding: 1rem 0.5rem;
            overflow-y: auto;
        }

        /* Action Buttons Mobile Bar */
        .controls-footer {
            padding: 0.75rem;
            background: rgba(0,0,0,0.4);
            border-top: 1px solid rgba(255,255,255,0.1);
            width: 100%;
        }

        .btn-game {
            padding: 1rem 0.5rem;
            font-size: 1.1rem;
            font-weight: 800;
            border-radius: 0.75rem;
            transition: all 0.2s;
            text-transform: uppercase;
            touch-action: manipulation;
        }

        /* Typography sizing for mobile */
        .text-mobile-header { font-size: 1.25rem; }
        @media (min-width: 768px) { .text-mobile-header { font-size: 1.875rem; } }

        /* FARKLE Animation Overlay */
        #game-status-message {
            font-size: 4rem;
            pointer-events: none;
            text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
        }
        @media (min-width: 768px) { #game-status-message { font-size: 6rem; } }

        /* Toast Container Adjustment */
        #toast-container {
            width: 90%;
            max-width: 400px;
        }

        /* Custom Scrollbar for small lists */
        #players-list::-webkit-scrollbar { width: 4px; }
        #players-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

        /* Base safety */
html,
body {
    width: 100%;
    min-width: 0;
    min-height: 100%;
    background: #050629;
}

body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

button,
.die-scene {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Keep modals safe everywhere */
#help-modal,
#winner-screen,
#lobby-screen {
    position: fixed;
    inset: 0;
}

/* DESKTOP RESTORE */
@media (min-width: 768px) {
    #game-screen {
        display: flex;
        flex-direction: row !important;
        height: 100vh !important;
        height: 100dvh !important;
        width: 100vw !important;
        padding: 1.5rem !important;
        gap: 1rem !important;
        overflow: hidden;
    }

    #game-screen.hidden {
        display: none !important;
    }

    #game-screen > .glass:first-child {
        width: 16rem !important;
        max-height: none !important;
        height: auto !important;
        padding: 1rem !important;
        flex-shrink: 0;
        overflow: hidden;
    }

    #game-screen > .glass:nth-child(2) {
        flex: 1 1 auto !important;
        min-width: 0;
        min-height: 0;
        width: auto !important;
        border-radius: 1rem;
    }

    #game-screen > div:last-child {
        display: flex !important;
        width: 20rem !important;
        flex-shrink: 0;
        max-height: 100%;
    }

    #players-list {
        max-height: none !important;
        overflow-y: auto;
    }

    #board-area {
        padding: 1rem !important;
        justify-content: center;
        overflow-y: auto;
    }

    :root {
        --die-size: 5rem;
        --die-tz: 2.5rem;
    }

    .die-face {
        border-radius: 0.75rem !important;
        padding: 0.75rem !important;
        gap: 0.375rem !important;
    }

    #active-dice-container,
    #kept-dice-container {
        gap: 1.5rem !important;
        min-height: 6rem !important;
    }

    #current-player-name {
        font-size: 1.875rem !important;
        line-height: 2.25rem !important;
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    #turn-score-display {
        font-size: 2.25rem !important;
        line-height: 2.5rem !important;
    }

    #btn-roll,
    #btn-bank {
        max-width: 240px !important;
        padding: 1.25rem 1rem !important;
        font-size: 1.25rem !important;
        border-radius: 0.75rem !important;
    }

    #btn-roll span,
    #btn-bank span {
        display: inline !important;
    }

    #help-modal {
        align-items: center;
        justify-content: center;
        padding: 1rem !important;
        overflow-y: auto;
    }

    #help-modal .glass {
        max-height: 90vh;
        padding: 2rem !important;
        border-radius: 1rem;
    }

    #help-modal .grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #lobby-screen {
        align-items: center !important;
        justify-content: center !important;
        padding: 1rem !important;
        overflow-y: auto;
    }

    #lobby-screen .glass {
        margin: 0 auto !important;
        padding: 2rem !important;
        max-width: 28rem !important;
    }
}

/* MOBILE ONLY */
@media (max-width: 767px) {
    input,
    button,
    textarea,
    select {
        font-size: 16px;
    }

    #help-modal,
    #winner-screen,
    #lobby-screen {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #lobby-screen {
        padding: 16px !important;
        align-items: flex-start !important;
    }

    #lobby-screen .glass {
        margin: 24px auto;
        padding: 22px !important;
        max-width: 440px;
    }

    #game-screen {
        height: 100vh !important;
        height: 100dvh !important;
        width: 100vw !important;
        display: flex;
        flex-direction: column !important;
        overflow: hidden;
        padding: 10px !important;
        gap: 10px !important;
    }

    #game-screen.hidden {
        display: none !important;
    }

    #game-screen > .glass:first-child {
        width: 100% !important;
        max-height: 24dvh;
        min-height: auto;
        padding: 12px !important;
        border-radius: 16px;
        overflow: hidden;
    }

    #players-list {
        max-height: 12dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #game-screen > .glass:nth-child(2) {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        border-radius: 16px;
    }

    #game-screen > div:last-child {
        display: none !important;
    }

    #game-screen > .glass:nth-child(2) > .p-4,
    #game-screen > .glass:nth-child(2) > .md\:p-6 {
        padding: 10px 12px !important;
        gap: 10px;
    }

    #current-player-name {
        font-size: clamp(1.15rem, 6vw, 1.7rem) !important;
        line-height: 1.1;
        max-width: 48vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #turn-score-display {
        font-size: clamp(1.6rem, 8vw, 2.5rem) !important;
        line-height: 1;
    }

    #board-area {
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 8px !important;
        justify-content: center;
    }

    #active-dice-container,
    #kept-dice-container {
        gap: 10px !important;
        min-height: 4.7rem !important;
        align-items: center;
    }

    #board-area .mb-10 {
        margin-bottom: 18px !important;
    }

    #board-area .mb-4 {
        margin-bottom: 8px !important;
    }

    :root {
        --die-size: 3.15rem;
        --die-tz: 1.575rem;
    }

    .die-face {
        border-radius: 10px !important;
        padding: 0.35rem !important;
        gap: 0.14rem !important;
    }

    .dot {
        min-width: 7px;
        min-height: 7px;
    }

    #game-status-message {
        top: 14px !important;
        font-size: clamp(2.4rem, 14vw, 4.2rem) !important;
        line-height: 1;
    }

    #game-screen > .glass:nth-child(2) > div:last-child {
        padding: 10px !important;
        gap: 8px !important;
    }

    #game-screen > .glass:nth-child(2) > div:last-child .flex {
        gap: 10px !important;
    }

    #btn-roll,
    #btn-bank {
        max-width: none !important;
        padding: 13px 8px !important;
        font-size: clamp(0.95rem, 4vw, 1.15rem) !important;
        border-radius: 14px;
        white-space: nowrap;
    }

    #btn-roll span,
    #btn-bank span {
        display: none !important;
    }

    #help-modal {
        padding: 12px !important;
    }

    #help-modal .glass {
        max-height: calc(100dvh - 24px);
        padding: 18px !important;
        border-radius: 18px;
    }

    #help-modal h2 {
        font-size: 1.55rem !important;
        line-height: 1.15;
    }

    #help-modal h3 {
        font-size: 1.1rem !important;
    }

    #help-modal .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    #winner-content {
        padding: 20px;
    }

    #winner-content h2 {
        font-size: clamp(3rem, 16vw, 5rem) !important;
    }

    #winner-name-display {
        font-size: clamp(1.6rem, 8vw, 3rem) !important;
    }

    #btn-play-again,
    #btn-close-winner {
        width: 100%;
    }
}

/* SMALL PHONES ONLY */
@media (max-width: 390px) {
    #game-screen {
        padding: 7px !important;
        gap: 7px !important;
    }

    :root {
        --die-size: 2.75rem;
        --die-tz: 1.375rem;
    }

    #active-dice-container,
    #kept-dice-container {
        gap: 7px !important;
        min-height: 4rem !important;
    }

    #current-player-name {
        max-width: 42vw;
    }

    #btn-roll,
    #btn-bank {
        font-size: 0.9rem !important;
        padding: 11px 6px !important;
    }

    #game-screen > .glass:first-child {
        max-height: 22dvh;
    }

    #players-list {
        max-height: 10dvh;
    }
}

/* LANDSCAPE PHONES ONLY */
@media (max-width: 767px) and (orientation: landscape) {
    #game-screen {
        flex-direction: row !important;
        overflow: hidden;
    }

    #game-screen > .glass:first-child {
        width: 180px !important;
        max-height: none;
    }

    #players-list {
        max-height: 45dvh;
    }

    #game-screen > .glass:nth-child(2) {
        min-width: 0;
    }

    #board-area {
        padding: 8px !important;
    }

    :root {
        --die-size: 2.7rem;
        --die-tz: 1.35rem;
    }

    #active-dice-container,
    #kept-dice-container {
        min-height: 3.5rem !important;
    }

    #board-area .mb-10 {
        margin-bottom: 10px !important;
    }
}




        /* Super Die Power-Up Shop */
        .superdie-panel {
            margin-top: 0.75rem;
            padding: 0.75rem;
            border-radius: 1rem;
            background: linear-gradient(135deg, rgba(234,179,8,.16), rgba(168,85,247,.16));
            border: 1px solid rgba(234,179,8,.28);
            box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 12px 30px rgba(0,0,0,.18);
        }
        .superdie-toggle {
            width: 100%;
            padding: 0.65rem 0.75rem;
            border-radius: 0.85rem;
            font-weight: 900;
            font-size: 0.82rem;
            letter-spacing: .04em;
            text-transform: uppercase;
            background: rgba(15, 23, 42, .72);
            color: #fde68a;
            border: 1px solid rgba(234,179,8,.35);
            transition: transform .18s ease, filter .18s ease, background .18s ease;
        }
        .superdie-toggle:hover { filter: brightness(1.08); }
        .superdie-toggle:active { transform: scale(.97); }
        .superdie-toggle.is-on {
            background: linear-gradient(90deg, #f59e0b, #a855f7);
            color: #fff;
            border-color: rgba(255,255,255,.25);
            box-shadow: 0 0 22px rgba(234,179,8,.28);
        }
        .superdie-status {
            margin-top: .45rem;
            font-size: .72rem;
            line-height: 1.25;
            color: #cbd5e1;
            text-align: center;
        }
        .superdie-buy-wrap {
            width: 100%;
            max-width: 500px;
            display: flex;
            flex-direction: column;
            gap: .45rem;
            align-items: center;
        }
        .superdie-buy-btn {
            width: 100%;
            padding: .82rem 1rem;
            border-radius: 999px;
            font-weight: 950;
            letter-spacing: .035em;
            text-transform: uppercase;
            background: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6);
            color: #fff;
            border: 1px solid rgba(255,255,255,.25);
            box-shadow: 0 14px 35px rgba(236,72,153,.22);
            transition: transform .18s ease, opacity .18s ease, filter .18s ease;
        }
        .superdie-buy-btn:hover:not(:disabled) { filter: brightness(1.09); transform: translateY(-1px); }
        .superdie-buy-btn:active:not(:disabled) { transform: scale(.98); }
        .superdie-buy-btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.35); }
        .superdie-help {
            font-size: .72rem;
            color: #cbd5e1;
            text-align: center;
            line-height: 1.25;
        }
        .superdie-last {
            width: 100%;
            padding: .65rem .8rem;
            border-radius: .9rem;
            background: rgba(15,23,42,.72);
            border: 1px solid rgba(255,255,255,.1);
            color: #fef3c7;
            font-size: .78rem;
            font-weight: 800;
            text-align: center;
        }
        .superdie-badge {
            display: inline-flex;
            align-items: center;
            gap: .2rem;
            padding: 2px 7px;
            border-radius: 999px;
            background: rgba(234,179,8,.16);
            border: 1px solid rgba(234,179,8,.28);
            color: #fde68a;
            font-size: 10px;
            font-weight: 900;
            white-space: nowrap;
        }
        .superdie-anim-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1rem;
            background:
                radial-gradient(circle at 50% 50%, rgba(250, 204, 21, 0.18), rgba(15, 23, 42, 0.12) 42%, rgba(2, 6, 23, 0.76) 100%);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            z-index: 25;
            transition: opacity .25s ease, visibility .25s ease;
        }
        .superdie-anim-overlay.is-visible {
            opacity: 1;
            visibility: visible;
        }

        .superdie-anim-kicker {
            font-size: .72rem;
            font-weight: 900;
            letter-spacing: .28em;
            text-transform: uppercase;
            color: #fde68a;
            margin-bottom: .55rem;
        }
        .superdie-anim-player {
            font-size: .88rem;
            font-weight: 800;
            color: #e9d5ff;
            margin-bottom: .8rem;
        }
        .superdie-roulette-desc {
            min-height: 2.3rem;
            margin-top: .35rem;
            color: #e2e8f0;
            font-size: .8rem;
            line-height: 1.3;
        }
        .superdie-anim-overlay.is-result .superdie-roulette-box {
            animation: superdie-flash .45s ease;
        }
        .superdie-anim-overlay.is-result .superdie-roulette-name {
            color: #fde68a;
        }
        @keyframes superdie-bob {
            from { transform: translateY(-4px) scale(1) rotate(-4deg); }
            to { transform: translateY(4px) scale(1.06) rotate(4deg); }
        }
        @keyframes superdie-flash {
            0% { transform: scale(.88); filter: brightness(.75); }
            60% { transform: scale(1.08); filter: brightness(1.22); }
            100% { transform: scale(1); filter: brightness(1); }
        }
        @media (max-width: 767px) {
            .superdie-anim-card {
                width: min(96vw, 370px);
                padding: .9rem .9rem 1rem;
            }
            .superdie-roulette-box {
                min-height: 128px;
            }
        }





/* Mario Kart Inspired Roulette Styling */
.superdie-anim-card {
    width: min(92vw, 440px);
    border-radius: 2rem;
    padding: 2rem;
    text-align: center;
    color: #fff;
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    border: 4px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 50px rgba(0,0,0,0.8), 0 0 20px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: visible;
}

/* The "Item Box" container */
.superdie-roulette-box {
    position: relative;
    min-height: 180px;
    border-radius: 1.5rem;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 6px solid #334155;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Rainbow Pulse while spinning */
.superdie-anim-overlay.is-spinning .superdie-roulette-box {
    animation: mk-border-pulse 0.4s infinite alternate;
    border-color: #fff;
}

/* Giant Floating Icon */
.superdie-roulette-icon {
    font-size: 6rem;
    filter: drop-shadow(0 0 15px rgba(255,255,255,0.5));
    z-index: 2;
}

/* Speed lines effect background */
.superdie-roulette-box::after {
    content: '';
    position: absolute;
    inset: -50%;
    background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.05) 10px, rgba(255,255,255,0.05) 20px);
    animation: mk-speed-lines 0.2s linear infinite;
    display: none;
}
.superdie-anim-overlay.is-spinning .superdie-roulette-box::after { display: block; }

/* Impact Flash when item is landed */
.superdie-anim-overlay.is-result .superdie-roulette-box {
    animation: mk-impact 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.49);
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    border-color: #fff;
    box-shadow: 0 0 40px #f59e0b;
}

@keyframes mk-border-pulse {
    from { box-shadow: 0 0 10px #3b82f6; }
    to { box-shadow: 0 0 30px #a855f7; }
}

@keyframes mk-speed-lines {
    from { transform: translateY(0); }
    to { transform: translateY(20px); }
}

@keyframes mk-impact {
    0% { transform: scale(0.8); filter: brightness(2); }
    50% { transform: scale(1.1); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* Labels */
.superdie-roulette-name {
    margin-top: 1.5rem;
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
		


		
        /* Connection recovery UI */
        #connection-banner {
            position: fixed;
            left: 50%;
            bottom: 14px;
            transform: translateX(-50%);
            z-index: 1200;
            display: none;
            align-items: center;
            gap: 10px;
            padding: 10px 14px;
            border-radius: 999px;
            color: #fff;
            font-size: 13px;
            font-weight: 800;
            background: rgba(15, 23, 42, .94);
            border: 1px solid rgba(255,255,255,.16);
            box-shadow: 0 18px 50px rgba(0,0,0,.35);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
        }
        #connection-banner.is-visible { display: flex; }
        #connection-banner .conn-dot {
            width: 10px;
            height: 10px;
            border-radius: 999px;
            background: #eab308;
            box-shadow: 0 0 14px rgba(234,179,8,.8);
            animation: pulse 1s infinite;
        }
        .player-offline { opacity: .55; filter: grayscale(.35); }
        .connection-pill {
            font-size: 10px;
            font-weight: 900;
            padding: 2px 7px;
            border-radius: 999px;
            background: rgba(100,116,139,.24);
            color: #cbd5e1;
            border: 1px solid rgba(148,163,184,.25);
            white-space: nowrap;
        }