@charset "UTF-8";
/* ==========================================================================
   Game screens: live, liveplayer, spplayer. Loaded after core.css.
   ========================================================================== */

@layer app {

    /* ========================================= */
    /* 🛑 THEME VARIABLES & DESIGN TOKENS        */
    /* ========================================= */
    :root:where([data-portal="live"]) {
        --theme-primary: #0D47A1;
        --text-inverse: #ffffff;
        --basic-white: #ffffff;
        --basic-black: #000000;
        --basic-red: #ff0000;
        --basic-darkred: #D44638;
        --basic-green: #25D366;
        --basic-darkgreen: #28a745;
        --basic-darkgreen-2: #1e7e34;
        --basic-orange: #ffc107;
        --basic-darkorange: #f97316;
        --basic-blue: #007bff;
        --basic-darkblue: #0000ff;
        --basic-yellow: #ffff00;
        --basic-pink: #f8d7da;
        --basic-purple: #9c27b0;
        --basic-amber: #ff9800;
        --basic-lightblue: #2196f3;
        --basic-hotpink: #e83e8c;
        --basic-grey-alt: #6c757d;
        --basic-grey-w: #fff;
        --basic-grey-0: #ccc;
        --basic-grey-1: #aaa;
        --basic-grey-2: #999;
        --basic-grey-3: #888;
        --basic-grey-4: #777;
        --basic-grey-5: #666;
        --basic-grey-6: #555;
        --basic-grey-7: #444;
        --basic-grey-8: #333;
        --basic-grey-9: #222;
        --basic-grey-10: #111;
        --basic-grey-b: #000;
        --z-base: 1;
        --z-base1: 5;
        --z-base2: 10;
        --z-base3: 20;
        --z-base4: 100;
        --z-low1: 1000;
        --z-low2: 2000;
        --z-low2-5: 2500;
        --z-low3: 3000;
        --z-low3-5: 3500;
        --z-low3-6: 3600;
        --z-mid4: 4000;
        --z-mid4-5: 4500;
        --z-mid5: 5000;
        --z-mid5-5: 5500;
        --z-mid6: 6000;
        --z-mid6-5: 6500;
        --z-high7: 7000;
        --z-high8: 8000;
        --z-high9: 9000;
        --z-max: 9999;
        --z-top: 10000;
        --text-success-dark: #155724;
        --text-warning-dark: #856404;
        --text-danger-dark: #721c24;
        --bg-info-light: #e3f2fd;
        --border-info-light: #b6d4fe;
        --bg-warning-light: #fff3cd;
        --border-warning-light: #ffeeba;
        --loader-ring: #f3f3f3;
    }

    /* ========================================= */
    /* 🌐 RESET & GLOBAL STYLES                  */
    /* ========================================= */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    :where([data-portal="live"]) body {
        background: radial-gradient(circle at 50% 15%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
        background-color: var(--bg-body);
        background-image: none;
        min-height: 100vh;
        overflow-x: hidden;
        opacity: 0;
        transition: opacity 0.25s ease-in-out;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    :where([data-portal="live"], [data-portal="spplayer"]) body.app-ready {
        opacity: 1;
    }

    [dir="rtl"] {
        direction: rtl;
        text-align: right;
    }

    [dir="ltr"] {
        direction: ltr;
        text-align: left;
    }

    /* ========================================= */
    /* 📱 CONTAINERS & SCREEN LAYOUT             */
    /* ========================================= */
    :where([data-portal="live"]) .app-container {
        min-height: 100vh;
        width: 100%;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }

    :where([data-portal="live"]) .screen {
        display: none;
        width: 100%;
        min-height: 100vh;
    }

    :where([data-portal="live"]) .screen.active {
        display: flex;
        flex-direction: column;
    }

    /* ========================================= */
    /* 🧭 TOP BAR NAVIGATION & BUTTONS           */
    /* ========================================= */
    #live-lang-container {
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: var(--z-low1);
    }

    [dir="rtl"]:where([data-portal="live"]) #live-lang-container {
        right: auto;
        left: 20px;
    }

    :where([data-portal="live"]) .btn-nav {
        background: rgba(255, 255, 255, 0.12);
        color: var(--basic-white);
        border: 1px solid rgba(255, 255, 255, 0.25);
        padding: 10px 22px;
        border-radius: 12px;
        cursor: pointer;
        font-size: 1.1rem;
        font-weight: 700;
        font-family: inherit;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        text-decoration: none;
    }

    :where([data-portal="live"]) .btn-nav:hover {
        background: rgba(255, 255, 255, 0.25) !important;
        border-color: rgba(255, 255, 255, 0.45);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    }

    :where([data-portal="live"], [data-portal="spplayer"]) .btn-nav:active {
        transform: translateY(0);
    }

    /* ========================================= */
    /* 🔐 SETUP WRAPPERS (LOGIN & PIN SCREENS)   */
    /* ========================================= */
    .setup-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 40px 20px;
        text-align: center;
        position: relative;
        z-index: var(--z-base);
        box-sizing: border-box;
    }

    .setup-card {
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 24px;
        padding: 40px 32px;
        width: 100%;
        max-width: 440px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
        display: flex;
        flex-direction: column;
        gap: 16px;
        margin: 0 auto;
        box-sizing: border-box;
    }

    .setup-input {
        width: 100%;
        padding: 15px 20px;
        border-radius: 14px;
        border: 2px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        font-size: 1.15rem;
        font-weight: 600;
        font-family: inherit;
        outline: none;
        transition: all 0.2s ease;
        text-align: center;
        box-sizing: border-box;
    }

    .setup-input:focus {
        border-color: #3b82f6;
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
    }

    :where([data-portal="live"]) .btn-action {
        width: 100%;
        padding: 15px 24px;
        border-radius: 14px;
        border: none;
        font-size: 1.2rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        text-decoration: none;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    }

    :where([data-portal="live"]) .btn-action:hover {
        filter: brightness(1.1);
        box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.4);
    }

    .btn-action:active {
        transform: translateY(0);
    }

    .btn-blue {
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
        color: var(--basic-white);
    }

    .btn-green {
        background: linear-gradient(135deg, #059669 0%, #10b981 100%);
        color: var(--basic-white);
    }

    /* ========================================= */
    /* 📽️ LIVE SCREEN (PROJECTOR DISPLAY)       */
    /* ========================================= */
    #live-screen {
        height: 100vh;
        width: 100%;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
        background: #0f172a;
    }

    .live-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 18px 35px;
        background: var(--theme-primary);
        color: var(--basic-white);
        min-height: 110px;
        box-sizing: border-box;
        flex-shrink: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        z-index: var(--z-base2);
        gap: 20px;
    }

    .live-header h1 {
        font-size: 2rem;
        font-weight: 800;
        margin: 0;
        line-height: 1.3;
        color: var(--basic-white);
    }

    .room-code-box {
        background: rgba(0, 0, 0, 0.45);
        border: 2px solid rgba(255, 255, 255, 0.3);
        padding: 12px 28px;
        border-radius: 18px;
        font-size: 2.4rem;
        font-weight: 900;
        letter-spacing: 4px;
        color: var(--basic-white);
        display: flex;
        align-items: center;
        gap: 12px;
        font-family: 'Inter', monospace, sans-serif;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(8px);
        white-space: nowrap;
    }

    #display-pin {
        color: #fbbf24;
        text-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
        font-weight: 900;
    }

    /* ========================================= */
    /* 🎮 PROJECTOR STAGE & GAME COMPONENTS      */
    /* ========================================= */
    .projector-stage {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 30px 40px 100px 40px;
        position: relative;
        overflow-y: auto;
        background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 100%);
        box-sizing: border-box;
    }

    .question-banner {
        font-size: 2.8rem;
        font-weight: 900;
        text-align: center;
        color: var(--basic-white);
        max-width: 1200px;
        margin: 0 auto 30px auto;
        line-height: 1.35;
        text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
        word-break: break-word;
    }

    #live-timer-badge {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: var(--theme-danger);
        color: var(--basic-white);
        padding: 10px 32px;
        border-radius: 50px;
        font-size: 2rem;
        font-weight: 900;
        margin: 0 auto 25px auto;
        box-shadow: 0 8px 20px rgba(220, 53, 69, 0.4);
        animation: pulseTimer 1s infinite alternate;
    }

    .options-display,
    #options-display {
        width: 100%;
        max-width: 1100px;
        margin: 0 auto;
        box-sizing: border-box;
    }

    #answers-counter {
        text-align: center;
        font-size: 2rem;
        color: var(--text-muted);
        font-weight: 800;
        margin-top: auto;
        margin-bottom: 20px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #answers-counter.floating-mode {
        position: absolute;
        bottom: 90px;
        right: 35px;
        margin: 0 !important;
        background: rgba(15, 23, 42, 0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding: 12px 28px;
        border-radius: 40px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        font-size: 1.6rem !important;
        color: #f8fafc;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
        z-index: var(--z-base2);
    }

    [dir="rtl"]:where([data-portal="live"]) #answers-counter.floating-mode {
        right: auto;
        left: 35px;
    }

    /* ========================================= */
    /* 🏆 LEADERBOARDS & CHARTS                  */
    /* ========================================= */
    #leaderboard-wrapper {
        width: 100%;
        max-width: 900px;
        margin: 0 auto;
        padding: 10px;
    }

    .live-leaderboard {
        display: flex;
        flex-direction: column;
        gap: 14px;
        width: 100%;
    }

    .lb-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 18px 28px;
        background: var(--basic-white);
        color: #0f172a;
        border-radius: 16px;
        font-size: 1.6rem;
        font-weight: 700;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
        border-left: 8px solid #94a3b8;
        transition: transform 0.2s ease;
    }

    [dir="rtl"]:where([data-portal="live"]) .lb-row {
        border-left: none;
        border-right: 8px solid #94a3b8;
    }

    .lb-row.rank-1 {
        border-left-color: #f59e0b;
        background: linear-gradient(90deg, #fffbeb 0%, #ffffff 100%);
        transform: scale(1.03);
        box-shadow: 0 12px 30px rgba(245, 158, 11, 0.35);
        font-size: 1.85rem;
        font-weight: 900;
    }

    [dir="rtl"]:where([data-portal="live"]) .lb-row.rank-1 {
        border-left-color: transparent;
        border-right-color: #f59e0b;
        background: linear-gradient(270deg, #fffbeb 0%, #ffffff 100%);
    }

    .lb-row.rank-2 {
        border-left-color: #64748b;
        background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
        font-size: 1.7rem;
    }

    [dir="rtl"]:where([data-portal="live"]) .lb-row.rank-2 {
        border-left-color: transparent;
        border-right-color: #64748b;
        background: linear-gradient(270deg, #f8fafc 0%, #ffffff 100%);
    }

    .lb-row.rank-3 {
        border-left-color: #d97706;
        background: linear-gradient(90deg, #fff7ed 0%, #ffffff 100%);
        font-size: 1.65rem;
    }

    [dir="rtl"]:where([data-portal="live"]) .lb-row.rank-3 {
        border-left-color: transparent;
        border-right-color: #d97706;
        background: linear-gradient(270deg, #fff7ed 0%, #ffffff 100%);
    }

    .chart-container,
    #chart-wrapper {
        width: 100%;
        max-width: 1000px;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* ========================================= */
    /* 🕹️ STEALTH HOST CONTROLS                  */
    /* ========================================= */
    .stealth-host-bar {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 15px;
        padding: 10px 24px;
        background: rgba(15, 23, 42, 0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 20px;
        z-index: var(--z-low2);
        box-sizing: border-box;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        max-width: calc(100% - 60px);
    }

    .stealth-btn {
        padding: 12px 28px;
        border-radius: 12px;
        border: none;
        font-size: 1.15rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        white-space: nowrap;
    }

    .stealth-btn:hover {
        filter: brightness(1.15);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    }

    .stealth-btn:active {
        transform: translateY(0);
    }

    /* ========================================= */
    /* 🔄 ANIMATIONS & UTILITIES                 */
    /* ========================================= */
    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }

    @keyframes pulseTimer {
        from {
            transform: scale(1);
        }

        to {
            transform: scale(1.05);
        }
    }

    @media (max-width: 1000px) {
        .live-header {
            padding: 12px 20px;
            min-height: 90px;
        }

        .live-header h1 {
            font-size: 1.5rem;
        }

        .room-code-box {
            font-size: 1.8rem;
            padding: 8px 18px;
        }

        .question-banner {
            font-size: 2.2rem;
        }

        .projector-stage {
            padding: 20px;
        }

    }

    @media (max-width: 600px) {
        .live-header {
            flex-direction: column;
            text-align: center;
            gap: 10px;
        }

        .question-banner {
            font-size: 1.8rem;
        }

        .setup-card {
            padding: 25px 20px;
        }

    }

    /* ========================================= */
    /* 🌟 APP PRELOADER & SEAMLESS TRANSITIONS   */
    /* ========================================= */
    .app-preloader {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        z-index: 999999;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 16px;
        transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .app-preloader.hidden {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none;
    }

    .preloader-spinner {
        width: 44px;
        height: 44px;
        border: 3.5px solid rgba(255, 255, 255, 0.15);
        border-color: var(--m-tonal) !important;
        border-radius: 50%;
        animation: preloaderSpin 0.75s linear infinite;
    }

    .preloader-text {
        color: #ffffff;
        font-size: 0.95rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        opacity: 0.85;
    }

    @keyframes preloaderSpin {
        to {
            transform: rotate(360deg);
        }
    }

    /* --- Dark Mode Logo & Brand Title Glow --- */
    #projector-logo,
    .brand-logo,
    .ws-logo {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.65)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.28)) drop-shadow(0 0 22px rgba(255, 255, 255, 0.15)) !important;
    }

    /* ========================================= */
    /* 🛑 THEME VARIABLES & DESIGN TOKENS        */
    /* ========================================= */
    :root:where([data-portal="liveplayer"]) {
        --theme-primary: #0D47A1;
        --text-inverse: #ffffff;
        --basic-white: #ffffff;
        --basic-black: #000000;
        --basic-red: #ff0000;
        --basic-darkred: #D44638;
        --basic-green: #25D366;
        --basic-darkgreen: #28a745;
        --basic-orange: #ffc107;
        --basic-darkorange: #f97316;
        --basic-blue: #007bff;
        --basic-darkblue: #0000ff;
        --basic-yellow: #ffff00;
        --basic-pink: #f8d7da;
        --basic-amber: #ff9800;
        --basic-grey-alt: #6c757d;
        --basic-grey-0: #ccc;
        --basic-grey-1: #aaa;
        --basic-grey-2: #999;
        --basic-grey-3: #888;
        --basic-grey-4: #777;
        --basic-grey-5: #666;
        --basic-grey-6: #555;
        --basic-grey-7: #444;
        --basic-grey-8: #333;
        --basic-grey-9: #222;
        --text-success-dark: #155724;
        --text-warning-dark: #856404;
        --text-danger-dark: #721c24;
        --bg-info-light: rgba(23, 162, 184, 0.15);
        --border-info-light: rgba(23, 162, 184, 0.3);
        --bg-warning-light: rgba(255, 193, 7, 0.15);
        --border-warning-light: rgba(255, 193, 7, 0.3);
        --loader-ring: rgba(255, 255, 255, 0.2);
    }

    :where([data-portal="liveplayer"]) body {
        background: radial-gradient(circle at 50% 15%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
        background-color: var(--bg-body);
        background-image: none;
        min-height: 100vh;
        padding: 15px;
        -webkit-font-smoothing: antialiased;
    }

    :where([data-portal="liveplayer"]) .app-container {
        max-width: 520px;
        margin: 0 auto;
        min-height: 90vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    :where([data-portal="liveplayer"]) .screen {
        display: none;
        width: 100%;
    }

    :where([data-portal="liveplayer"], [data-portal="spplayer"]) .screen.active {
        display: block;
    }

    .welcome-subtitle {
        text-align: center;
        margin-bottom: 5px;
        color: var(--text-muted);
        font-size: 1.4rem;
        font-weight: 700;
    }

    :where([data-portal="liveplayer"]) .main-title {
        font-size: 2.2rem;
        font-weight: 900;
        text-align: center;
        color: var(--basic-white);
        margin-bottom: 20px;
    }

    :where([data-portal="liveplayer"]) .card {
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 20px;
        padding: 30px 24px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
        margin-bottom: 20px;
    }

    :where([data-portal="liveplayer"]) .input-field {
        width: 100%;
        padding: 14px 18px;
        border-radius: 12px;
        border: 2px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        font-size: 1.15rem;
        font-weight: 600;
        outline: none;
        transition: all 0.2s ease;
        text-align: center;
        box-sizing: border-box;
    }

    .input-field:focus {
        border-color: #3b82f6;
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
    }

    .code-box {
        margin: 20px 0;
        background: rgba(23, 162, 184, 0.15);
        padding: 20px 15px;
        border-radius: 16px;
        border: 1px solid rgba(23, 162, 184, 0.35);
        text-align: center;
    }

    .code-label {
        display: block;
        font-weight: 800;
        margin-bottom: 10px;
        color: #38bdf8;
        font-size: 1.15rem;
    }

    .pin-box {
        margin: 20px 0;
        background: rgba(255, 193, 7, 0.15);
        padding: 20px 15px;
        border-radius: 16px;
        border: 1px solid rgba(255, 193, 7, 0.35);
        text-align: center;
    }

    .pin-label {
        display: block;
        font-weight: 800;
        margin-bottom: 10px;
        color: #fbbf24;
        font-size: 1.15rem;
    }

    :where([data-portal="liveplayer"]) .btn-action {
        width: 100%;
        padding: 15px 24px;
        border-radius: 14px;
        border: none;
        font-size: 1.2rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    :where([data-portal="liveplayer"]) .btn-action:hover {
        filter: brightness(1.1);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    }

    :where([data-portal="liveplayer"]) .btn-nav {
        background: rgba(255, 255, 255, 0.12);
        color: var(--basic-white);
        border: 1px solid rgba(255, 255, 255, 0.25);
        padding: 8px 16px;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 700;
        font-family: inherit;
        transition: all 0.2s ease;
    }

    :where([data-portal="liveplayer"]) .btn-nav:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    :where([data-portal="liveplayer"]) .hud {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    :where([data-portal="liveplayer"]) .hud-item {
        font-size: 1.2rem;
        font-weight: bold;
        color: #fbbf24;
    }

    :where([data-portal="liveplayer"]) .v1-options-stack {
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin: 20px 0;
    }

    .v1-action-area {
        margin-top: 20px;
    }

    :where([data-portal="liveplayer"]) .loader {
        animation: spin 1s linear infinite;
    }

    /* --- Dark Mode Logo & Brand Title Glow --- */
    :where([data-portal="liveplayer"]) #waiting-logo,
    :where([data-portal="liveplayer"]) #ingame-logo,
    :where([data-portal="liveplayer"]) .welcome-game-logo,
    :where([data-portal="liveplayer"]) .ingame-logo,
    :where([data-portal="liveplayer"]) .brand-logo,
    :where([data-portal="liveplayer"]) .ws-logo {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.65)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.28)) drop-shadow(0 0 22px rgba(255, 255, 255, 0.15)) !important;
    }

    /* ========================================= */
    /* 🛑 THEME VARIABLES & DESIGN TOKENS        */
    /* ========================================= */
    :root:where([data-portal="spplayer"]) {
        --theme-primary: #0D47A1;
        --text-inverse: #ffffff;
        --basic-white: #ffffff;
        --basic-black: #000000;
        --basic-red: #ff0000;
        --basic-darkred: #D44638;
        --basic-green: #25D366;
        --basic-darkgreen: #28a745;
        --basic-darkgreen-2: #1e7e34;
        --basic-orange: #ffc107;
        --basic-darkorange: #f97316;
        --basic-blue: #007bff;
        --basic-darkblue: #0000ff;
        --basic-yellow: #ffff00;
        --basic-pink: #f8d7da;
        --basic-purple: #9c27b0;
        --basic-amber: #ff9800;
        --basic-lightblue: #2196f3;
        --basic-hotpink: #e83e8c;
        --basic-grey-alt: #6c757d;
        --basic-grey-w: #fff;
        --basic-grey-0: #ccc;
        --basic-grey-1: #aaa;
        --basic-grey-2: #999;
        --basic-grey-3: #888;
        --basic-grey-4: #777;
        --basic-grey-5: #666;
        --basic-grey-6: #555;
        --basic-grey-7: #444;
        --basic-grey-8: #333;
        --basic-grey-9: #222;
        --basic-grey-10: #111;
        --basic-grey-b: #000;
        --z-base: 1;
        --z-base1: 5;
        --z-base2: 10;
        --z-base3: 20;
        --z-base4: 100;
        --z-low1: 1000;
        --z-low2: 2000;
        --z-low2-5: 2500;
        --z-low3: 3000;
        --z-low3-5: 3500;
        --z-low3-6: 3600;
        --z-mid4: 4000;
        --z-mid4-5: 4500;
        --z-mid5: 5000;
        --z-mid5-5: 5500;
        --z-mid6: 6000;
        --z-mid6-5: 6500;
        --z-high7: 7000;
        --z-high8: 8000;
        --z-high9: 9000;
        --z-max: 9999;
        --z-top: 10000;
        --text-success-dark: #155724;
        --text-warning-dark: #856404;
        --text-danger-dark: #721c24;
        --bg-info-light: rgba(23, 162, 184, 0.15);
        --border-info-light: rgba(23, 162, 184, 0.3);
        --bg-warning-light: rgba(255, 193, 7, 0.15);
        --border-warning-light: rgba(255, 193, 7, 0.3);
    }

    :where([data-portal="spplayer"]) body {
        background: radial-gradient(circle at 50% 15%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
        background-color: var(--bg-body);
        background-image: none;
        min-height: 100vh;
        padding: 20px 15px;
        opacity: 0;
        transition: opacity 0.25s ease-in-out;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* ========================================= */
    /* 📱 MAIN CONTAINER & SCREENS               */
    /* ========================================= */
    :where([data-portal="spplayer"]) .app-container {
        max-width: 600px;
        margin: 0 auto;
        min-height: 90vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        position: relative;
    }

    :where([data-portal="spplayer"]) .screen {
        display: none;
        width: 100%;
        animation: fadeInScreen 0.3s ease-out;
    }

    @keyframes fadeInScreen {
        from {
            opacity: 0;
            transform: translateY(8px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* ========================================= */
    /* 🧭 TOP NAV & HEADERS                      */
    /* ========================================= */
    .top-nav-bar {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20px;
    }

    [dir="rtl"]:where([data-portal="spplayer"]) .top-nav-bar {
        justify-content: flex-start;
    }

    :where([data-portal="spplayer"]) .main-title {
        font-size: 2.2rem;
        font-weight: 900;
        text-align: center;
        color: var(--basic-white);
        margin-bottom: 25px;
        text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }

    /* ========================================= */
    /* 📦 CARDS & INPUTS                         */
    /* ========================================= */
    :where([data-portal="spplayer"]) .card {
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.18);
        border-radius: 24px;
        padding: 32px 24px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
        margin-bottom: 20px;
        box-sizing: border-box;
    }

    .form-group {
        margin-bottom: 15px;
    }

    :where([data-portal="spplayer"]) .input-field {
        width: 100%;
        padding: 14px 18px;
        border-radius: 14px;
        border: 2px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        font-size: 1.15rem;
        font-weight: 600;
        font-family: inherit;
        outline: none;
        transition: all 0.2s ease;
        text-align: center;
        box-sizing: border-box;
    }

    .code-input {
        letter-spacing: 5px;
        font-size: 1.6rem;
        font-weight: 900;
        font-family: 'Inter', monospace, sans-serif;
        color: var(--theme-primary);
    }

    .pin-input {
        letter-spacing: 6px;
        font-size: 1.6rem;
        font-weight: 900;
        font-family: 'Inter', monospace, sans-serif;
    }

    /* ========================================= */
    /* 🔘 BUTTONS & INTERACTIONS                 */
    /* ========================================= */
    :where([data-portal="spplayer"]) .btn-action {
        width: 100%;
        padding: 15px 24px;
        border-radius: 14px;
        border: none;
        font-size: 1.2rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        text-decoration: none;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
    }

    :where([data-portal="spplayer"]) .btn-action:hover {
        filter: brightness(1.1);
        box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.45);
    }

    .btn-yellow {
        background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
        color: #ffffff;
    }

    .btn-red {
        background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%);
        color: #ffffff;
    }

    :where([data-portal="spplayer"]) .btn-nav {
        background: rgba(255, 255, 255, 0.12);
        color: var(--basic-white);
        border: 1px solid rgba(255, 255, 255, 0.25);
        padding: 10px 20px;
        border-radius: 12px;
        cursor: pointer;
        font-size: 1.05rem;
        font-weight: 700;
        font-family: inherit;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        text-decoration: none;
    }

    :where([data-portal="spplayer"]) .btn-nav:hover {
        background: rgba(255, 255, 255, 0.25);
        border-color: rgba(255, 255, 255, 0.4);
    }

    /* ========================================= */
    /* 🎮 GAMES LIST & SELECTION                 */
    /* ========================================= */
    .games-list-container {
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin-bottom: 20px;
    }

    .game-select-btn {
        width: 100%;
        padding: 18px 22px;
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 16px;
        font-size: 1.25rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 14px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
        box-sizing: border-box;
    }

    .game-select-btn:hover {
        transform: translateY(-3px) scale(1.01);
        background: #ffffff;
        border-color: #3b82f6;
        box-shadow: 0 12px 25px rgba(59, 130, 246, 0.3);
    }

    :where([data-portal="spplayer"]) .lobby-game-logo,
    :where([data-portal="spplayer"]) .welcome-game-logo,
    :where([data-portal="spplayer"]) .ingame-logo {
        height: 48px;
        width: auto;
        object-fit: contain;
    }

    :where([data-portal="spplayer"]) .welcome-game-logo {
        height: 80px;
        margin: 0 auto 20px auto;
        display: block;
    }

    .rules-box {
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 16px;
        padding: 22px;
        margin-bottom: 20px;
        font-size: 1.15rem;
        line-height: 1.7;
        color: #e2e8f0;
        text-align: start;
    }

    .welcome-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* ========================================= */
    /* ⏱️ GAME HUD & PROGRESS                    */
    /* ========================================= */
    .overall-timer-pill {
        background: rgba(220, 53, 69, 0.2);
        border: 1px solid rgba(220, 53, 69, 0.4);
        color: #f87171;
        padding: 8px 20px;
        border-radius: 30px;
        text-align: center;
        font-size: 1.15rem;
        font-weight: 800;
        margin-bottom: 15px;
        backdrop-filter: blur(8px);
    }

    .progress-bar-track {
        width: 100%;
        height: 8px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 10px;
        margin-bottom: 15px;
        overflow: hidden;
    }

    :where([data-portal="spplayer"]) .progress-bar-fill {
        height: 100%;
        background: linear-gradient(90deg, #3b82f6, #60a5fa);
        width: 0%;
        transition: width 0.3s ease-out;
        border-radius: 10px;
    }

    :where([data-portal="spplayer"]) .hud {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    :where([data-portal="spplayer"]) .hud-item {
        font-size: 1.25rem;
        font-weight: 800;
        color: #94a3b8;
    }

    .hud-timer {
        color: #fbbf24;
    }

    :where([data-portal="spplayer"]) .hud-score {
        color: #38bdf8;
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    :where([data-portal="spplayer"]) .question-text {
        font-size: 1.6rem;
        font-weight: 800;
        color: var(--basic-white);
        margin-bottom: 15px;
        line-height: 1.4;
        text-align: center;
    }

    .question-attached-image {
        max-width: 100%;
        max-height: 250px;
        object-fit: contain;
        border-radius: 14px;
        margin: 0 auto 20px auto;
        display: block;
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    :where([data-portal="spplayer"]) .multi-select-hint {
        text-align: center;
        color: #fbbf24;
        font-size: 1rem;
        font-weight: 700;
        margin-bottom: 15px;
    }

    /* ========================================= */
    /* 🧩 OPTIONS & INPUTS                       */
    /* ========================================= */
    :where([data-portal="spplayer"]) .v1-options-stack {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    :where([data-portal="spplayer"]) .option-btn {
        width: 100%;
        padding: 16px 20px;
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        border: 3px solid transparent;
        border-radius: 16px;
        font-size: 1.2rem;
        font-weight: 800;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
        text-align: start;
        box-sizing: border-box;
    }

    :where([data-portal="spplayer"]) .option-btn:hover:not(:disabled) {
        background: #ffffff;
        border-color: #3b82f6;
    }

    :where([data-portal="spplayer"]) .option-btn.selected {
        background: #1e40af !important;
        color: #ffffff !important;
        border-color: #60a5fa !important;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
    }

    :where([data-portal="spplayer"]) .option-btn.correct {
        background: #059669 !important;
        color: #ffffff !important;
        border-color: #34d399 !important;
    }

    :where([data-portal="spplayer"]) .option-btn.wrong {
        background: #dc2626 !important;
        color: #ffffff !important;
        border-color: #f87171 !important;
    }

    :where([data-portal="spplayer"]) .tf-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }

    :where([data-portal="spplayer"]) .tf-btn {
        text-align: center;
        padding: 24px 15px;
        font-size: 1.4rem;
    }

    :where([data-portal="spplayer"]) .fib-container {
        margin: 20px 0;
    }

    :where([data-portal="spplayer"]) .fib-input {
        width: 100%;
        padding: 16px 20px;
        border-radius: 14px;
        border: 3px solid rgba(255, 255, 255, 0.3);
        background: #ffffff;
        color: #0f172a;
        font-size: 1.3rem;
        font-weight: 800;
        text-align: center;
        box-sizing: border-box;
    }

    :where([data-portal="spplayer"]) .fib-input.correct-input {
        border-color: #10b981;
        background: #ecfdf5;
        color: #065f46;
    }

    :where([data-portal="spplayer"]) .fib-input.wrong-input {
        border-color: #ef4444;
        background: #fef2f2;
        color: #991b1b;
    }

    /* ========================================= */
    /* 💬 FEEDBACK & ACTION ROWS                 */
    /* ========================================= */
    .feedback-box {
        border-radius: 16px;
        padding: 18px 22px;
        margin-bottom: 20px;
        font-size: 1.15rem;
        line-height: 1.6;
        animation: fadeInScreen 0.25s ease;
    }

    .feedback-box.show-correct {
        background: #d4edda;
        border: 2px solid #c3e6cb;
        color: #155724;
    }

    .feedback-box.show-wrong {
        background: #f8d7da;
        border: 2px solid #f5c6cb;
        color: #721c24;
    }

    .game-action-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .nav-btn-row {
        display: flex;
        gap: 12px;
        align-items: center;
    }

    .nav-btn-row>* {
        flex: 1;
    }

    /* ========================================= */
    /* 🏁 RESULT & STATS SCREEN                  */
    /* ========================================= */
    :where([data-portal="spplayer"]) .final-player-name {
        font-size: 2rem;
        font-weight: 900;
        color: #ffffff;
        margin-bottom: 20px;
        text-align: center;
    }

    .trivia-stats-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 25px;
        margin: 20px 0;
    }

    :where([data-portal="spplayer"]) .final-score-circle {
        width: 140px;
        height: 140px;
        border-radius: 50%;
        background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-shadow: 0 15px 35px rgba(37, 99, 235, 0.4);
        border: 4px solid rgba(255, 255, 255, 0.3);
    }

    #final-score-display {
        font-size: 3rem;
        font-weight: 900;
        line-height: 1;
        color: #ffffff;
    }

    .final-score-unit {
        font-size: 1rem;
        font-weight: 800;
        color: #bfdbfe;
        letter-spacing: 2px;
    }

    .stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        width: 100%;
    }

    .stat-box {
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 16px;
        padding: 16px 12px;
        text-align: center;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .stat-num {
        font-size: 1.8rem;
        font-weight: 900;
    }

    .stat-label {
        font-size: 0.95rem;
        color: var(--text-muted);
        font-weight: 700;
    }

    .stat-correct-color {
        color: #34d399;
    }

    .stat-wrong-color {
        color: #f87171;
    }

    .stat-skipped-color {
        color: #fbbf24;
    }

    .stat-time-color {
        color: #38bdf8;
    }

    .review-highlight {
        font-size: 1.8rem;
        font-weight: 900;
        color: #fbbf24;
        text-align: center;
        margin-bottom: 10px;
    }

    .review-submessage {
        text-align: center;
        color: var(--text-muted);
        font-size: 1.1rem;
        margin-bottom: 25px;
    }

    .review-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    @media (max-width: 480px) {
        :where([data-portal="spplayer"]) .card {
            padding: 24px 18px;
        }

        :where([data-portal="spplayer"]) .main-title {
            font-size: 1.8rem;
        }

        :where([data-portal="spplayer"]) .question-text {
            font-size: 1.35rem;
        }

        :where([data-portal="spplayer"]) .option-btn {
            font-size: 1.1rem;
            padding: 14px 16px;
        }

    }

    /* --- Dark Mode Logo & Brand Title Glow --- */
    :where([data-portal="spplayer"]) #welcome-logo,
    :where([data-portal="spplayer"]) #ingame-logo,
    :where([data-portal="spplayer"]) .welcome-game-logo,
    :where([data-portal="spplayer"]) .ingame-logo,
    :where([data-portal="spplayer"]) .lobby-game-logo,
    :where([data-portal="spplayer"]) .brand-logo,
    :where([data-portal="spplayer"]) .ws-logo {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.65)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.28)) drop-shadow(0 0 22px rgba(255, 255, 255, 0.15)) !important;
    }

    /* ===== Tonal theme overrides (from modern.css) ===== */
    /* ---------- 13e. Game screens & mobile field apps — dark tonal ----------
       live / liveplayer / spplayer and the m* / agent pages carry data-theme="dark" in their
       <html>; this gives them the tonal stage background (their own gradients are replaced). */
    [data-portal="live"] body,
    [data-portal="liveplayer"] body,
    [data-portal="spplayer"] body {
        background-color: var(--bg-body);
        background-image:
            radial-gradient(70% 45% at 50% 0%, color-mix(in srgb, var(--theme-primary) 38%, transparent), transparent 75%),
            radial-gradient(50% 40% at 100% 100%, color-mix(in srgb, var(--theme-secondary) 22%, transparent), transparent 70%);
        background-attachment: fixed;
    }
}