        :root {
            --bg: #0f172a;
            --primary: #6366f1;
            --primary-dark: #4338ca;
            --accent: #f43f5e;
            --success: #10b981;
            --glass: rgba(255, 255, 255, 0.07);
            --glass-border: rgba(255, 255, 255, 0.12);
            --text: #f1f5f9;
            --text-muted: #94a3b8;
            --card-front-grad: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
            --gold: #f59e0b;
        }

        * {
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            font-family: 'Vazirmatn', sans-serif;
            user-select: none;
            outline: none;
        }

        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            height: 100dvh;
            background-color: var(--bg);
            overflow: hidden;
            color: var(--text);
            display: flex;
            align-items: center;
            justify-content: center;
            background-image:
                radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 20%),
                radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.15) 0%, transparent 20%);
        }

        @keyframes textShine {
            0% { background-position: -200% center; }
            100% { background-position: 200% center; }
        }

        .shimmer-text {
            background: linear-gradient(120deg, var(--text) 40%, #a5b4fc 50%, var(--text) 60%);
            background-size: 200% auto;
            color: transparent;
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            animation: textShine 20s linear infinite; /* slowed from 8s */
        }

        /* Pause all animations inside non-active views to save CPU */
        .view:not(.active) * {
            animation-play-state: paused !important;
        }

        @keyframes shimmer-sweep {
            0% { transform: translateX(-150%) skewX(-25deg); }
            40% { transform: translateX(150%) skewX(-25deg); }
            100% { transform: translateX(150%) skewX(-25deg); }
        }

        @keyframes glow-pulse {
            0% { box-shadow: 0 10px 30px -5px rgba(99, 102, 241, 0.5); }
            50% { box-shadow: 0 10px 40px -5px rgba(99, 102, 241, 0.8); }
            100% { box-shadow: 0 10px 30px -5px rgba(99, 102, 241, 0.5); }
        }

        @keyframes talking-pulse {
            0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); border-color: var(--success); }
            70% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); border-color: var(--success); }
            100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); border-color: var(--success); }
        }

        .talking-indicator {
            animation: talking-pulse 1.5s infinite !important;
            border: 2px solid var(--success) !important;
            background: rgba(16, 185, 129, 0.15) !important;
        }

        @keyframes float {
            0% { transform: translateY(100vh) scale(0); opacity: 0; }
            50% { opacity: 0.5; }
            100% { transform: translateY(-100px) scale(1); opacity: 0; }
        }

        @keyframes popIn {
            0% { transform: scale(0); }
            80% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }

        @keyframes slideDown {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes bounceIn {
            0% { opacity:0; transform: scale(0.8); }
            60% { transform: scale(1.05); }
            100% { opacity:1; transform: scale(1); }
        }

        @keyframes pulse {
            0%,100% { transform: scale(1); opacity: 0.2; }
            50% { transform: scale(1.1); opacity: 0.5; }
        }

        /* GPU layer promotion only for elements that actually animate frequently */
        .game-card { will-change: transform; }
        /* Removed: will-change on .view — it was applied to ALL views at once,
           creating unnecessary GPU compositing layers for every hidden screen */

        .toast-container {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 5000;
            display: flex;
            flex-direction: column;
            gap: 10px;
            width: 90%;
            max-width: 400px;
            pointer-events: none;
        }

        .toast-box {
            background: rgba(15, 23, 42, 0.97);
            border: 1px solid var(--accent);
            border-left: 5px solid var(--accent);
            color: #fff;
            padding: 15px 20px;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            gap: 15px;
            font-size: 0.95rem;
            animation: toastEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, shake 0.4s 0.2s;
            pointer-events: all;
            /* Removed: backdrop-filter: blur(10px) — GPU-intensive, background is already opaque */
        }

        .toast-box.hiding { animation: toastExit 0.4s forwards; }
        .toast-icon { font-size: 1.5rem; color: var(--accent); animation: pulse 3s infinite; }
        @keyframes toastEnter { from { opacity: 0; transform: translateY(-50px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes toastExit { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-20px) scale(0.9); } }
        @keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

        .particles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: 0.5; }
        .particle { position: absolute; border-radius: 50%; background: white; opacity: 0.3; animation: float infinite linear; will-change: transform; }

        .app-wrapper {
            width: 100%;
            height: 100%;
            position: relative;
            z-index: 10;
            display: flex;
            flex-direction: column;
            transition: max-width 0.3s ease;
        }

        @media (min-width: 768px) {
            .app-wrapper {
                max-width: 1000px;
                height: 95vh;
                border-radius: 24px;
                overflow: hidden;
                box-shadow: 0 0 50px rgba(0,0,0,0.5);
                border: 1px solid var(--glass-border);
                background: rgba(15, 23, 42, 0.6);
            }
        }

        .view {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 15px 20px;
            background: rgba(15, 23, 42, 0.95);
            opacity: 0;
            pointer-events: none;
            transform: scale(0.95);
            transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

        @media (min-width: 768px) { .view { background: transparent; padding: 40px; } }
        .view.active { opacity: 1; pointer-events: all; transform: scale(1); z-index: 5; }

        .scroll-content {
            width: 100%;
            overflow-y: auto;
            flex: 1;
            padding-bottom: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .scroll-content::-webkit-scrollbar { width: 6px; }
        .scroll-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

        h1 {
            margin: 0 0 5px 0;
            font-size: 1.8rem;
            font-weight: 900;
            text-align: center;
            background: linear-gradient(120deg, #fff 40%, #818cf8 50%, #fff 60%);
            background-size: 200% auto;
            color: transparent;
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            animation: textShine 20s linear infinite; /* slowed from 10s — less GPU work */
        }

        h2 {
            font-size: 1.4rem;
            margin: 10px 0;
            text-align: center;
            color: #c7d2fe; /* static color — removed continuous gradient animation */
            -webkit-text-fill-color: #c7d2fe;
        }

        .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; font-weight: 400; text-align: center; }

        .top-bar { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; min-height: 40px; }
        .left-button-group { display: flex; gap: 4px; align-items: center; }
        .right-button-group { display: flex; gap: 4px; align-items: center; }
        .center-icons { display: flex; gap: 15px; flex: 1; justify-content: flex-end; }

        .icon-btn {
            background: var(--glass);
            border: 1px solid var(--glass-border);
            color: #fff;
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: grid;
            place-items: center;
            cursor: pointer;
            transition: 0.3s;
            position: relative;
        }

        .icon-btn:hover { box-shadow: 0 0 15px rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); transform: scale(1.05); }
        .icon-btn:active { transform: scale(0.9); background: var(--primary); }
        .icon-btn.active { background: var(--accent); border-color: var(--accent); }
        .icon-btn.mic-on { background: var(--success); border-color: var(--success); box-shadow: 0 0 15px var(--success); }

        .input-box { width: 100%; max-width: 600px; position: relative; margin-bottom: 20px; display: flex; gap: 8px; }
        .main-input { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); border-radius: 16px; padding: 12px; color: white; font-size: 1rem; text-align: right; }
        .main-input:focus { border-color: var(--primary); }

        .add-btn { width: 50px; background: var(--primary); border: none; border-radius: 16px; color: white; font-size: 1.2rem; cursor: pointer; position: relative; overflow: hidden; }
        .add-btn::after { content: ''; position: absolute; top: 0; left: -200%; width: 200%; height: 100%; background: linear-gradient(to right, transparent, rgba(255,255,255,0.6), transparent); transform: skewX(-25deg); pointer-events: none; }
        .add-btn:hover::after { animation: shimmer-sweep 0.6s ease-out forwards; }

        .stacked-inputs { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
        .stacked-buttons { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }

        .tags-container { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }

        .tag { background: rgba(255,255,255,0.1); padding: 8px 12px 8px 16px; border-radius: 30px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; transition: all 0.2s ease; }
        .tag i { opacity: 0.5; cursor: pointer; padding: 4px; }

        .status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 5px rgba(0,0,0,0.5); }
        .status-online { background-color: #10b981; box-shadow: 0 0 8px #10b981; }
        .status-offline { background-color: #94a3b8; }

        .kick-btn { margin-right: 5px; width: 24px; height: 24px; background: rgba(244, 63, 94, 0.2); color: var(--accent); border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 0.7rem; }
        .kick-btn:hover { background: var(--accent); color: white; }

        .section-title { width: 100%; text-align: right; font-size: 0.9rem; color: var(--text-muted); margin: 10px 0; font-weight: 700; max-width: 800px; }
        .topics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; margin-bottom: 10px; }
        @media (min-width: 600px) { .topics-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } }

        .topic-card {
            background: var(--glass); border: 1px solid var(--glass-border); padding: 15px; border-radius: 16px;
            text-align: center; cursor: pointer; transition: 0.3s; position: relative; overflow: hidden;
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
        }
        .topic-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); }
        .topic-card.selected { background: rgba(99, 102, 241, 0.2); border-color: var(--primary); box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.2); }
        .topic-card.selected::before { content: none; } /* removed continuous shimmer — was always running on every selected card */
        .topic-card.selected::after { content: '\f00c'; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; top: 8px; right: 8px; font-size: 0.8rem; color: var(--primary); }
        .topic-card i { font-size: 1.5rem; margin-bottom: 5px; }

        #custom-words-container { width: 100%; max-width: 600px; margin-bottom: 20px; display: none; animation: slideDown 0.3s forwards; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 16px; border: 1px dashed var(--glass-border); }
        #custom-words-input { width: 100%; min-height: 70px; background: transparent; color: white; border: none; resize: vertical; font-size: 0.9rem; outline: none; }

        .control-row { display: flex; justify-content: space-between; width: 100%; max-width: 600px; align-items: center; background: var(--glass); padding: 12px 15px; border-radius: 16px; border: 1px solid var(--glass-border); margin-bottom: 10px; }
        .stepper { display: flex; align-items: center; gap: 15px; background: rgba(0,0,0,0.3); padding: 5px 10px; border-radius: 12px; }
        .step-btn { color: var(--text); background: none; border: none; font-size: 1.1rem; width: 30px; cursor: pointer; }
        .step-btn:disabled { opacity: 0.3; cursor: not-allowed; }
        .step-val { font-weight: 900; width: 20px; text-align: center; }

        .primary-btn {
            width: 100%; max-width: 400px;
            background: linear-gradient(90deg, var(--primary), var(--primary-dark));
            color: white; border: none; padding: 16px; border-radius: 20px;
            font-size: 1.1rem; font-weight: 700;
            cursor: pointer; margin-top: 5px; z-index: 100;
            position: relative; overflow: hidden; transition: 0.2s;
            display: flex; justify-content: center; align-items: center; gap: 10px; flex-shrink: 0;
            box-shadow: 0 10px 30px -5px rgba(99, 102, 241, 0.5); /* static glow — was infinite glow-pulse animation */
        }
        .primary-btn.secondary { background: var(--glass); border: 1px solid var(--glass-border); box-shadow: none; }
        .primary-btn.danger { background: rgba(244, 63, 94, 0.2); border: 1px solid var(--accent); color: var(--accent); box-shadow: none; }
        .primary-btn.danger:hover { background: rgba(244, 63, 94, 0.4); }
        .primary-btn.success { background: rgba(16, 185, 129, 0.2); border: 1px solid var(--success); color: var(--success); box-shadow: none; }
        .primary-btn.success:hover { background: rgba(16, 185, 129, 0.4); }

        .primary-btn span, .primary-btn i { position: relative; z-index: 2; color: white; -webkit-text-fill-color: white; } /* static white — was infinite textShine gradient animation */
        /* Shimmer on ::after only plays on hover — was running infinitely on all buttons at once */
        .primary-btn::after { content: ''; position: absolute; top: 0; left: -200%; width: 200%; height: 100%; background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%); transform: skewX(-25deg); transition: none; pointer-events: none; }
        .primary-btn:hover::after { animation: shimmer-sweep 0.6s ease-out forwards; }
        .primary-btn:active { transform: scale(0.98); }
        .primary-btn:hover { box-shadow: 0 15px 35px -5px rgba(99, 102, 241, 0.7); }
        .primary-btn:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; box-shadow: none; }

        .card-wrapper { perspective: 1500px; width: 100%; max-width: 340px; height: 55vh; min-height: 350px; max-height: 550px; margin: 20px 0; transition: all 0.3s ease; }
        @media (min-width: 768px) { .card-wrapper { max-width: 450px; height: 60vh; max-height: 650px; } }
        .game-card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); cursor: pointer; }
        .game-card.flipped { transform: rotateY(180deg); }

        .card-face {
            position: absolute; width: 100%; height: 100%; backface-visibility: hidden;
            border-radius: 24px; border: 2px solid var(--glass-border);
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            box-shadow: 0 30px 60px rgba(0,0,0,0.5); text-align: center;
            background-size: cover; background-position: center;
        }
        .face-front { background: var(--card-front-grad); z-index: 2; }
        .fingerprint { font-size: 5rem; color: rgba(255,255,255,0.1); margin-bottom: 20px; animation: pulse 4s infinite; }
        .tap-text { color: rgba(255,255,255,0.6); font-size: 1rem; letter-spacing: 2px; text-transform: uppercase; }
        .face-back { transform: rotateY(180deg); background: white; color: #1e293b; padding: 20px; }
        .role-badge { background: #1e293b; color: white; padding: 6px 14px; border-radius: 20px; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; }
        .secret-word { font-size: 2.5rem; font-weight: 900; color: #1e293b; line-height: 1.4; margin: 15px 0; word-break: break-word; background: linear-gradient(120deg, #1e293b 40%, #6366f1 50%, #1e293b 60%); background-size: 200% auto; color: transparent; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: textShine 15s linear infinite; }
        .face-back.spy-mode { background: #111; color: #fff; border: 3px solid var(--accent); }
        .face-back.spy-mode .role-badge { background: var(--accent); color: #fff; }
        .face-back.spy-mode .secret-word { color: var(--accent); font-size: 3.5rem; text-shadow: 0 0 20px rgba(244, 63, 94, 0.4); margin: 30px 0; background: linear-gradient(120deg, #f43f5e 40%, #fff 50%, #f43f5e 60%); background-size: 200% auto; color: transparent; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: textShine 15s linear infinite; }

        .timer-ring {
            position: relative; width: 220px; height: 220px; border-radius: 50%;
            display: grid; place-items: center; margin: 30px 0;
            background: conic-gradient(var(--primary) var(--progress, 0%), rgba(255,255,255,0.1) 0);
            transition: background 0.1s linear;
        }
        @media (min-width: 768px) { .timer-ring { width: 300px; height: 300px; } .time-text { font-size: 5rem !important; } }
        .timer-ring::before { content:''; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg); }
        .time-text { position: relative; font-size: 3.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }

        .starter-box { background: linear-gradient(135deg, #1e293b, #0f172a); padding: 30px; border-radius: 24px; border: 1px solid var(--glass-border); text-align: center; margin: auto; box-shadow: 0 30px 80px rgba(0,0,0,0.7); transform: scale(0.9); animation: bounceIn 0.5s forwards; width: 90%; max-width: 400px; }
        .starter-avatar { width: 70px; height: 70px; background: var(--gold); border-radius: 50%; margin: 0 auto 15px; display: grid; place-items: center; font-size: 2rem; color: #000; }

        .modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.88); z-index: 50; display: none; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s; /* Removed backdrop-filter: blur — GPU-intensive */ }
        .modal-overlay.open { display: flex; opacity: 1; }
        .modal-content { width: 90%; max-width: 500px; background: #1e293b; padding: 25px; border-radius: 24px; max-height: 85%; overflow-y: auto; border: 1px solid var(--glass-border); position: relative; }
        .modal-close { position: absolute; top: 15px; right: 15px; color: var(--text-muted); background: transparent; border: none; font-size: 1.5rem; cursor: pointer; }

        .rule-item { display: flex; gap: 12px; margin-bottom: 15px; align-items: flex-start; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 10px; }
        html[dir="rtl"] .rule-item { text-align: right; }
        html[dir="ltr"] .rule-item { text-align: left; }
        .rule-icon { width: 35px; height: 35px; background: rgba(255,255,255,0.1); border-radius: 8px; display: grid; place-items: center; color: var(--primary); flex-shrink: 0; }
        
        #ios-install-modal .modal-content {
            text-align: center;
        }
        #ios-install-modal p {
            margin: 15px 0;
            padding: 10px;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
            border-left: 3px solid var(--primary);
            text-align: start;
        }
        html[dir="rtl"] #ios-install-modal p {
            border-left: none;
            border-right: 3px solid var(--primary);
        }

        .social-container { width: 100%; display: flex; justify-content: center; gap: 20px; margin-top: 15px; padding-top: 10px; }
        .social-container a { transition: transform 0.2s; display: block; }
        .social-container a:hover { transform: scale(1.2); }

        .results-card { background: rgba(255,255,255,0.05); width: 100%; max-width: 600px; border-radius: 16px; padding: 15px; margin: 20px 0; }
        .spy-reveal { display: flex; align-items: center; justify-content: space-between; background: rgba(244, 63, 94, 0.2); padding: 12px; border-radius: 10px; margin-top: 10px; border: 1px solid rgba(244, 63, 94, 0.5); }
        .result-phase-container { width: 100%; display: flex; flex-direction: column; align-items: center; }

        .attempts-display {
            background: rgba(99, 102, 241, 0.15); border: 1px solid var(--primary);
            color: #fff; padding: 10px 20px; border-radius: 12px;
            font-size: 1.2rem; font-weight: bold; margin-bottom: 15px;
            display: flex; align-items: center; gap: 10px;
        }

        .status-box { width: 100%; max-width: 600px; padding: 15px; background: rgba(0,0,0,0.3); border-radius: 12px; text-align: center; margin-bottom: 20px; font-weight: bold; min-height: 54px; border: 1px solid var(--glass-border); }
        .status-box.success { background: rgba(16, 185, 129, 0.2); color: var(--success); border-color: var(--success); }
        .status-box.error { background: rgba(244, 63, 94, 0.2); color: var(--accent); border-color: var(--accent); }

        .suspect-card {
            background: var(--glass); border: 1px solid var(--glass-border); padding: 15px; border-radius: 16px;
            text-align: center; cursor: pointer; transition: 0.3s; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
        }
        .suspect-card:active { transform: scale(0.95); }
        .suspect-card:hover { background: rgba(255,255,255,0.1); }
        .suspect-card.eliminated { opacity: 0.3; pointer-events: none; filter: grayscale(1); transform: scale(0.9); }
        .suspect-card.caught { background: var(--accent); border-color: var(--accent); pointer-events: none; }
        .suspect-card.selected-vote { background: rgba(99, 102, 241, 0.4); border-color: var(--primary); transform: scale(1.02); box-shadow: 0 0 15px rgba(99, 102, 241, 0.5); }

        .voter-badge { position: absolute; bottom: 5px; right: 5px; background: var(--primary); width: 24px; height: 24px; border-radius: 50%; font-size: 0.7rem; display: grid; place-items: center; border: 1px solid white; z-index: 10;}

        #host-timer-controls { display: flex; justify-content: center; gap: 15px; width: 100%; align-items: center; margin-bottom: 20px; }

        .winner-header { text-align: center; margin-top: 20px; }
        .winner-header i { font-size: 3rem; margin-bottom: 10px; }
        .winner-citizens i { color: var(--success); }
        .winner-citizens h1 { background: linear-gradient(120deg, #10b981 40%, #fff 50%, #10b981 60%); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; }
        .winner-spies i { color: var(--accent); }
        .winner-spies h1 { background: linear-gradient(120deg, #f43f5e 40%, #fff 50%, #f43f5e 60%); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; }

        .footer { width: 100%; text-align: center; padding: 15px 0 5px 0; font-size: 0.75rem; color: rgba(255,255,255,0.4); letter-spacing: 1px; text-transform: uppercase; }
        .footer b { color: var(--primary); font-weight: 900; }

        .waiting-message { font-size: 1.2rem; color: var(--text-muted); animation: pulse 3s infinite; margin-top: 20px; text-align: center;}

        #chat-drawer {
            position: fixed; top: 0; right: -100%; width: 100%; max-width: 400px; height: 100%;
            background: rgba(15, 23, 42, 0.99); z-index: 3000; /* Removed backdrop-filter: blur — GPU-intensive */
            transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column;
            border-left: 1px solid var(--glass-border); box-shadow: -10px 0 30px rgba(0,0,0,0.5);
        }
        #chat-drawer.open { right: 0; }
        .chat-header { padding: 15px 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }
        #chat-messages { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
        .msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; position: relative; }
        .msg.received { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-border); border-bottom-right-radius: 2px; }
        .msg.sent { align-self: flex-end; background: var(--primary); color: white; border-bottom-left-radius: 2px; text-align: right; }
        .msg-sender { font-size: 0.7rem; font-weight: bold; margin-bottom: 4px; display: block; opacity: 0.8; }
        .chat-input-area { padding: 15px; background: rgba(0,0,0,0.2); display: flex; gap: 8px; border-top: 1px solid var(--glass-border); }
        .unread-badge { position: absolute; top: -5px; right: -5px; background: var(--accent); color: white; font-size: 0.65rem; width: 20px; height: 20px; border-radius: 50%; display: none; place-items: center; border: 2px solid var(--bg); font-weight: bold; }

@media (max-height: 600px) {
            h1 { font-size: 1.4rem; }
            .card-wrapper { height: 60vh; min-height: 250px; }
            .timer-ring { width: 160px; height: 160px; margin: 10px 0; }
            .time-text { font-size: 2.5rem; }
            .topics-grid { grid-template-columns: repeat(3, 1fr); }
            .view { padding: 10px 20px; }
        }

        /* Accessibility + performance: disable decorative animations for users with OS reduce-motion setting */
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }


html[dir="ltr"] .language-switcher {
    left: 50%;
    transform: translateX(-50%);
}

html[dir="rtl"] .language-switcher {
    left: 50%;
    transform: translateX(-50%);
}

/* Override: language switcher is fixed, not absolute */
.language-switcher {
    position: fixed !important;
    top: calc(15px + env(safe-area-inset-top, 0px));
}

.flag-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    background-color: #222;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    outline: none;
}

.flag-btn:hover {
    transform: scale(1.1);
}

.flag-btn:active {
    transform: scale(0.95);
}

.flag-btn.active {
    border-color: #4ade80; /* Green highlight for active language */
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}
