:root {
            --bg-color: #F7F9FC;
            --speed-pad: 30px;
            --speed-btn-size: 64px;
            --card-bg: #FFFFFF;
            --text-primary: #1C1C1E;
            --text-secondary: #8E8E93;
            --accent-blue: #007AFF; /* Blue accent */
            --accent-light-blue: #E3F2FD;
            --button-gradient: linear-gradient(90deg, #007AFF 0%, #5AC8FA 100%);

            /* extras */
            --border-color: rgba(0,0,0,0.06);
            --shadow-color: rgba(0,0,0,0.05);
            --subcard-bg: #F3F4F6;
            --matrix-bg-rgb: 255,255,255;
            --matrix-digit-rgb: 25,118,210;
            --overlay-bg: rgba(0,0,0,0.18);

            /* Glass (light) */
            /* More opaque, otherwise it looks "dark" over the dimmed overlay */
            --glass-bg: rgba(255,255,255,0.66);
            --glass-border: rgba(255,255,255,0.40);
            --glass-shadow: 0 12px 40px rgba(0,0,0,0.14);
            --glass-inset: inset 0 1px 0 rgba(255,255,255,0.18);

            /* Hints (light) */
            --hint-text: rgba(0,0,0,0.82);
            --hint-shadow: 0 10px 26px rgba(0,0,0,0.18);
        }

        /* Dark theme (manual or auto) */
        :root[data-theme="dark"] {
            /* Glass (dark) */
            --glass-bg: rgba(17,24,39,0.52);
            --glass-border: rgba(255,255,255,0.16);
            --glass-shadow: 0 16px 50px rgba(0,0,0,0.55);
            --glass-inset: inset 0 1px 0 rgba(255,255,255,0.10);


            --bg-color: #0B0F16;
            --card-bg: #111827;
            --text-primary: #E5E7EB;
            --text-secondary: #9CA3AF;
            --accent-blue: #60A5FA;
            --accent-light-blue: rgba(96,165,250,0.18);
            --button-gradient: linear-gradient(90deg, #3B82F6 0%, #60A5FA 100%);

            --border-color: rgba(255,255,255,0.08);
            --shadow-color: rgba(0,0,0,0.45);
            --subcard-bg: rgba(255,255,255,0.06);
            --matrix-bg-rgb: 11,15,22;
            --matrix-digit-rgb: 96,165,250;
            --overlay-bg: rgba(0,0,0,0.55);

            /* Hints (dark) */
            --hint-text: rgba(255,255,255,0.96);
            --hint-shadow: 0 10px 26px rgba(0,0,0,0.55);
        }

        @media (max-width: 420px) {
            :root {
                --speed-pad: 20px;
                --speed-btn-size: 56px;
            }
        }

        @media (prefers-color-scheme: dark) {
            :root[data-theme="auto"] {
                --bg-color: #0B0F16;
                --card-bg: #111827;
                --text-primary: #E5E7EB;
                --text-secondary: #9CA3AF;
                --accent-blue: #60A5FA;
                --accent-light-blue: rgba(96,165,250,0.18);
                --button-gradient: linear-gradient(90deg, #3B82F6 0%, #60A5FA 100%);

                --border-color: rgba(255,255,255,0.10);
                --shadow-color: rgba(0,0,0,0.45);

                --hint-text: rgba(255,255,255,0.96);
                --hint-shadow: 0 10px 26px rgba(0,0,0,0.55);
            }
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: var(--bg-color);
            margin: 0;
            padding: 0;
            padding-bottom: 80px; /* Space for bottom nav */
            color: var(--text-primary);
            -webkit-font-smoothing: antialiased;
            /* Disable pinch-zoom */
            touch-action: manipulation;

            /* No text selection anywhere */
            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
        }

        /* Re-enable selection in inputs/textareas where needed */
        input, textarea {
            -webkit-user-select: text;
            user-select: text;
            -webkit-touch-callout: default;
        }

        /* Glassmorphism utility */
        .glass {
            background: var(--glass-bg) !important;
            border: 0.5px solid var(--glass-border) !important;
            -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
            box-shadow: var(--glass-shadow), var(--glass-inset);
        }

        /* Old iOS WebView fallback:
           backdrop-filter can render as dark "dirty" overlays after scroll.
           Disable glass blur on list items for stability. */
        body.ios-webview .list-item {
            -webkit-backdrop-filter: none !important;
            backdrop-filter: none !important;
            background: var(--card-bg) !important;
            border: 1px solid var(--border-color) !important;
            box-shadow: 0 2px 8px var(--shadow-color) !important;
        }
        body.ios-webview .list-item .li-sub { color: var(--text-secondary) !important; }

        /* Apply glass across the app */
        .points,
        .header h1,
        .list-item,
        .modal,
        #bet-card,
        .multi-slot {
            background: var(--glass-bg) !important;
            border: 0.5px solid var(--glass-border) !important;
            -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
            box-shadow: var(--glass-shadow), var(--glass-inset);
        }
        /* Default active (used outside win/lose modes) */
        .multi-slot.active {
            border-color: color-mix(in oklab, var(--accent-blue) 60%, rgba(255,255,255,0.2)) !important;
            box-shadow: 0 0 0 2px rgba(90,200,250,0.18), var(--glass-shadow), var(--glass-inset);
            color: var(--accent-blue);
        }

        /* WIN mode: green highlight like "ПОБЕДА" */
        #multibar.win .multi-slot.won,
        #multibar.win .multi-slot.active {
            background: rgba(18,184,120,0.18) !important;
            border-color: rgba(18,184,120,0.40) !important;
            color: rgba(18,184,120,0.98) !important;
            box-shadow:
                0 0 0 2px rgba(18,184,120,0.20),
                0 20px 60px rgba(18,184,120,0.14),
                var(--glass-inset) !important;
        }
        :root:not([data-theme="dark"]) #multibar.win .multi-slot.won,
        :root:not([data-theme="dark"]) #multibar.win .multi-slot.active {
            background: rgba(18,184,120,0.14) !important;
            border-color: rgba(18,184,120,0.28) !important;
            box-shadow:
                0 0 0 2px rgba(18,184,120,0.12),
                0 18px 54px rgba(18,184,120,0.12),
                var(--glass-inset) !important;
        }

        /* Multibar: slide-in from top */
        #multibar {
            opacity: 0;
            transform: translateY(-18px);
            transition: transform 1000ms ease, opacity 1000ms ease;
            will-change: transform, opacity;
        }
        #multibar.show {
            opacity: 1;
            transform: translateY(0);
        }
        .multi-slot { position: relative; }
        .multi-res {
            margin-top: 4px;
            font-size: 18px;
            line-height: 18px;
            opacity: 0.95;
        }
        .multi-res > div { display:block; }
        .multi-res > div:first-child {
            font-size: 36px; /* ~2x emoji */
            line-height: 34px;
            margin-top: 2px;
            margin-bottom: 2px;
        }

        /* Keep generic containers transparent so glass surfaces stand out */
        .list,
        .match-card {
            background: transparent !important;
        }

        .header {
            padding: 14px 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: relative;
            z-index: 20; /* above arena canvas */
            background: transparent;
        }

        .header h1 {
            margin: 0;
            font-size: 15px;
            font-weight: 800;
            letter-spacing: 0.2px;

            /* glass is applied globally via selector list above */
            background: transparent;
            padding: 6px 12px;
            border-radius: 20px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            box-shadow: none;
            border: none;
            white-space: nowrap;
        }

        .user-badge {
            display: flex;
            gap: 10px;
        }

        .points {
            /* glass is applied globally via selector list above */
            background: transparent;
            padding: 6px 12px;
            border-radius: 20px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 6px;
            box-shadow: none;
        }

        .wallet-icon {
            width: 18px;
            height: 18px;
            border-radius: 6px;
            background: transparent; /* remove blue background */
            color: inherit; /* keep emoji natural */
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 900;
        }

        .avatar {
            width: 32px;
            height: 32px;
            background: var(--accent-blue);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }

        .banner {
            background: linear-gradient(135deg, var(--accent-light-blue) 0%, var(--card-bg) 100%);
            margin: 0 16px 20px;
            padding: 16px;
            border-radius: 16px;
            border: 1px solid var(--border-color);
            position: relative;
            box-shadow: 0 4px 14px var(--shadow-color);
        }

        .banner-tag {
            background: rgba(34,197,94,0.12);
            border: 1px solid rgba(34,197,94,0.25);
            color: #22c55e;
            padding: 4px 8px;
            border-radius: 10px;
            font-size: 12px;
            font-weight: 800;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 8px;
        }

        .stars {
            color: #FFD700;
            float: right;
        }

        .banner h2 {
            margin: 5px 0;
            font-size: 18px;
        }

        .banner p {
            color: var(--text-secondary);
            font-size: 13px;
            margin-bottom: 15px;
        }

        .cta-button {
            background: var(--button-gradient);
            border: none;
            padding: 12px 20px;
            border-radius: 12px;
            color: white;
            font-weight: 600;
            width: 100%;
            text-align: left;
            position: relative;
            cursor: pointer;
        }
        
        .cta-button::after {
            content: "→";
            position: absolute;
            right: 20px;
        }

        .section-title {
            margin: 0 16px 12px;
            font-size: 18px;
            font-weight: 700;
        }

        /* Profile list */
        .list {
            margin: 0 16px 12px;
            background: transparent;
            border-radius: 16px;
            box-shadow: none;
            overflow: visible;
            border: none;
        }
        .list-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 14px 14px;
            cursor: pointer;
            border-bottom: none;
            border-radius: 16px;
            margin-bottom: 10px;
        }
        .list-item:last-child { margin-bottom: 0; }
        .li-left { display:flex; align-items:center; gap: 12px; min-width: 0; }
        .li-icon {
            width: 36px;
            height: 36px;
            border-radius: 12px;
            display:flex;
            align-items:center;
            justify-content:center;
            font-weight: 900;
            background: var(--subcard-bg);
            border: 1px solid var(--border-color);
            color: var(--accent-blue);
        }
        .li-text { min-width:0; }
        .li-title { font-weight: 700; }
        .li-sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
        .chev { color: #C7C7CC; font-size: 18px; }

        /* Top bar inside views */
        .view-top {
            display:flex;
            align-items:center;
            justify-content: space-between;
            padding: 16px;
        }
        .back-btn {
            font-size: 30px;
            line-height: 30px;
            color: var(--text-primary);
            cursor: pointer;
            padding: 10px 12px;
            border-radius: 14px;
            background: var(--subcard-bg);
            border: 1px solid var(--border-color);
            box-shadow: 0 6px 18px var(--shadow-color);
            min-width: 44px;
            text-align: center;
        }
        .title-row { display:flex; align-items:center; gap:10px; }
        .big-title { font-size: 28px; font-weight: 800; }

        /* Modal */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: var(--overlay-bg);
            -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
            display: none;
            align-items: center;
            justify-content: center;
            padding: 16px;
            z-index: 999;
            pointer-events: auto;
        }
        .modal {
            width: 100%;
            max-width: 520px;
            border-radius: 18px;
            overflow: hidden;
        }
        .modal-head {
            display:flex;
            align-items:center;
            justify-content: space-between;
            padding: 14px 16px;
            border-bottom: 1px solid var(--border-color);
            font-weight: 800;
        }
        .modal-body { padding: 14px 16px 16px; }
        .close-x { cursor:pointer; font-size: 20px; color:#8E8E93; }

        /* Web auth modal: glassy, less transparent (web + TG safe) */
        #modal-webauth .modal {
            background: rgba(255,255,255,0.95);
            -webkit-backdrop-filter: blur(18px) saturate(1.35);
            backdrop-filter: blur(18px) saturate(1.35);
            border: 1px solid rgba(255,255,255,0.55);
            box-shadow: 0 26px 90px rgba(0,0,0,0.22);
        }
        :root:not([data-theme="light"]) #modal-webauth .modal {
            background: rgba(18,18,22,0.95);
            border-color: rgba(255,255,255,0.12);
            box-shadow: 0 26px 90px rgba(0,0,0,0.55);
        }
        #modal-webauth .modal-head {
            background: rgba(255,255,255,0.10);
        }
        :root:not([data-theme="light"]) #modal-webauth .modal-head {
            background: rgba(255,255,255,0.04);
        }

        /* Balance modal UI v2 (admin-only test) */
        body.admin-balance-ui-v2 #modal-balance .bal-head-v1 { display: none !important; }
        body.admin-balance-ui-v2 #modal-balance #close-balance-left { display: none !important; }
        body.admin-balance-ui-v2 #modal-balance #rate-float { display:none !important; } /* hide top floating rate pill */

        body.admin-balance-ui-v2 #modal-balance .modal {
            border-radius: 26px;
            border: 1px solid rgba(0,0,0,0.06);
            box-shadow: 0 22px 70px rgba(0,0,0,0.18);
            background: #fff !important; /* force solid white */
            opacity: 1 !important;
            overflow: visible; /* allow close button to sit on the edge without being clipped */
        }
        :root[data-theme="light"] body.admin-balance-ui-v2 #modal-balance .modal {
            background: #fff;
            border-color: rgba(0,0,0,0.08);
        }

        body.admin-balance-ui-v2 #modal-balance .modal-head {
            justify-content: flex-end;
            gap: 10px;
            border-bottom: none;
            padding: 0;
            height: 0;
            min-height: 0;
            background: transparent;
        }
        body.admin-balance-ui-v2 #modal-balance .modal { position: relative; }

        body.admin-balance-ui-v2 #modal-balance .close-x {
            position: absolute;
            left: 50%;
            top: -35px; /* 30px button + 5px gap */
            transform: translateX(-50%);
            z-index: 50;
            width: 30px;
            height: 30px;
            aspect-ratio: 1 / 1;
            padding: 0 !important;
            min-width: 0 !important;
            display:flex;
            align-items:center;
            justify-content:center;
            background: #fff;
            border: 0 !important;
            border-radius: 999px !important;
            overflow: hidden;
            box-shadow: 0 10px 22px rgba(0,0,0,0.16);
            color: var(--accent-blue);
            font-size: 22px;
            line-height: 1;
        }
        body.admin-balance-ui-v2 #modal-balance .close-x::after { content: none !important; }

        /* spacing between modal top and balance card */
        body.admin-balance-ui-v2 #modal-balance .modal-body { padding-top: 0 !important; }
        body.admin-balance-ui-v2 #modal-balance .bal-v2-card { margin-top: 0 !important; }
        body.admin-balance-ui-v2 #modal-balance #close-balance-left {
            font-size: 16px;
            font-weight: 900;
            padding: 6px 2px;
        }

        body.admin-balance-ui-v2 #modal-balance .modal-body {
            padding: 12px 14px 12px !important;
        }

        body.admin-balance-ui-v2 #modal-balance .modal { max-width: 440px; }

        /* Buttons styling (admin v2) */
        body.admin-balance-ui-v2 #modal-balance .segmented {
            background: rgba(245,245,247,1);
            border-color: rgba(0,0,0,0.06);
            border-radius: 18px;
            padding: 6px;
        }
        body.admin-balance-ui-v2 #modal-balance .seg-btn {
            font-size: 14px;
            padding: 10px 12px;
            border-radius: 14px;
            font-weight: 900;
            color: rgba(60,60,67,0.60);
        }
        body.admin-balance-ui-v2 #modal-balance .seg-btn.active {
            background: linear-gradient(180deg, #5AC8FA 0%, #0A84FF 60%, #0066FF 100%);
            color: #fff;
            box-shadow: 0 10px 22px rgba(10,132,255,0.22);
        }

        body.admin-balance-ui-v2 #modal-balance .big-action {
            border-radius: 20px;
            height: 52px;
            font-weight: 1000;
            font-size: 16px;
            box-shadow: 0 16px 34px rgba(10,132,255,0.20);
        }

        body.admin-balance-ui-v2 #modal-balance .buy-btn.ton-quick {
            background: #fff;
            border: 1px solid rgba(0,0,0,0.10);
            color: rgba(0,0,0,0.86);
            box-shadow: none;
        }
        body.admin-balance-ui-v2 #modal-balance .buy-btn.ton-quick:active {
            background: rgba(10,132,255,0.08);
        }
        body.admin-balance-ui-v2 #modal-balance .coin-chip.selected {
            border-color: rgba(10,132,255,0.55) !important;
            background: rgba(10,132,255,0.10);
        }

        /* Dark theme overrides for v2 */
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .modal {
            background: #0b1220 !important;
            border-color: rgba(255,255,255,0.10);
            box-shadow: 0 24px 80px rgba(0,0,0,0.55);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .bal-v2-title { color: rgba(255,255,255,0.62); }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .bal-v2-amt { color: rgba(255,255,255,0.94); }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .bal-v2-rate { color: rgba(255,255,255,0.60); }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .bal-v2-card {
            border-color: rgba(255,255,255,0.10);
            background:
                radial-gradient(130% 120% at 70% 0%, rgba(90,200,250,0.22) 0%, rgba(90,200,250,0.10) 34%, rgba(255,255,255,0.08) 64%, rgba(255,255,255,0.04) 100%),
                rgba(255,255,255,0.03);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .bal-v2-icon {
            background: rgba(90,200,250,0.10);
            border-color: rgba(90,200,250,0.18);
        }

        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .segmented {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,255,255,0.10);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .seg-btn {
            color: rgba(255,255,255,0.92);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .seg-btn.active {
            color: #fff;
        }

        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .buy-btn.ton-quick {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,255,255,0.12);
            color: rgba(255,255,255,0.92);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .buy-btn.ton-quick:active {
            background: rgba(90,200,250,0.12);
        }
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .coin-chip.selected {
            border-color: rgba(90,200,250,0.55) !important;
            background: rgba(90,200,250,0.16);
        }

        /* Close button on dark background */
        :root:not([data-theme="light"]) body.admin-balance-ui-v2 #modal-balance .close-x {
            background: rgba(255,255,255,0.14);
            color: rgba(255,255,255,0.92);
            box-shadow: 0 14px 34px rgba(0,0,0,0.55);
        }

        /* Small screens: reduce overall scale of the balance modal (admin v2) */
        @media (max-width: 420px) {
            /* chips spacing on small screens */
            body.admin-balance-ui-v2 #modal-balance #coin-select { gap: 2px !important; }

            /* reduce top whitespace on small screens */
            body.admin-balance-ui-v2 #modal-balance .modal-body { padding: 2px 12px 10px !important; }

            body.admin-balance-ui-v2 #modal-balance .modal-overlay { padding: 10px; }
            body.admin-balance-ui-v2 #modal-balance .modal { border-radius: 22px; }
            /* small top padding on small screens */
            body.admin-balance-ui-v2 #modal-balance .modal-head { padding: 6px 10px 0 !important; height: auto !important; min-height: 0 !important; }
            body.admin-balance-ui-v2 #modal-balance #close-balance-left { font-size: 16px; }

            body.admin-balance-ui-v2 #modal-balance .bal-v2-card { padding: 14px; border-radius: 18px; margin-bottom: 10px; }
            body.admin-balance-ui-v2 #modal-balance .bal-v2-amt { font-size: 30px; }
            body.admin-balance-ui-v2 #modal-balance .bal-v2-title { font-size: 12px; }
            body.admin-balance-ui-v2 #modal-balance .bal-v2-rate { font-size: 11px; }
            body.admin-balance-ui-v2 #modal-balance .bal-v2-icon { width: 76px; height: 76px; border-radius: 18px; font-size: 44px; }

            body.admin-balance-ui-v2 #modal-balance .segmented { border-radius: 16px; padding: 5px; }
            body.admin-balance-ui-v2 #modal-balance .seg-btn { font-size: 13px; padding: 10px 10px; border-radius: 12px; }

            body.admin-balance-ui-v2 #modal-balance .buy-row { padding: 10px; border-radius: 16px; }
            body.admin-balance-ui-v2 #modal-balance .big-action { height: 52px; border-radius: 20px; font-size: 16px; }
        }

        body.admin-balance-ui-v2 #modal-balance .bal-v2-card { display:flex !important; }
        body.admin-balance-ui-v2 #modal-balance .bal-v2-card {
            position: relative;
            border-radius: 20px;
            padding: 14px;
            margin-bottom: 12px;
            border: 1px solid rgba(255,255,255,0.12);
            background:
                radial-gradient(130% 120% at 70% 0%, rgba(90,200,250,0.26) 0%, rgba(90,200,250,0.12) 34%, rgba(255,255,255,0.10) 64%, rgba(255,255,255,0.06) 100%),
                color-mix(in oklab, var(--card-bg) 82%, rgba(255,255,255,0.28));
            box-shadow: 0 12px 36px rgba(0,0,0,0.14);
            display:flex;
            align-items:center;
            justify-content: space-between;
            gap: 12px;
            overflow:hidden;
        }
        /* soft “clouds” */
        body.admin-balance-ui-v2 #modal-balance .bal-v2-card::before {
            content: '';
            position: absolute;
            inset: -40px -60px -60px -60px;
            background:
                radial-gradient(220px 160px at 30% 52%, rgba(255,255,255,0.38) 0%, rgba(255,255,255,0.00) 70%),
                radial-gradient(260px 180px at 52% 60%, rgba(255,255,255,0.32) 0%, rgba(255,255,255,0.00) 72%),
                radial-gradient(240px 170px at 68% 48%, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.00) 74%);
            filter: blur(1px);
            opacity: 0.9;
            pointer-events: none;
        }
        body.admin-balance-ui-v2 #modal-balance .bal-v2-card > * { position: relative; }

        body.admin-balance-ui-v2 #modal-balance .bal-v2-title { font-weight: 900; font-size: 12px; color: rgba(60,60,67,0.60); }
        body.admin-balance-ui-v2 #modal-balance .bal-v2-amt { font-weight: 1000; font-size: 30px; letter-spacing: -0.03em; margin-top: 3px; color: rgba(0,0,0,0.92); }
        body.admin-balance-ui-v2 #modal-balance .bal-v2-rate { margin-top: 6px; font-weight: 900; font-size: 11px; color: rgba(60,60,67,0.55); }
        :root[data-theme="light"] body.admin-balance-ui-v2 #modal-balance .bal-v2-rate { color: rgba(60,60,67,0.55); }

        body.admin-balance-ui-v2 #modal-balance .bal-v2-icon {
            width: 78px;
            height: 78px;
            border-radius: 20px;
            display:flex;
            align-items:center;
            justify-content:center;
            font-size: 44px;
            background: rgba(90,200,250,0.16);
            border: 1px solid rgba(90,200,250,0.20);
            box-shadow: inset 0 2px 0 rgba(255,255,255,0.40), 0 10px 22px rgba(0,0,0,0.10);
        }
        :root[data-theme="light"] body.admin-balance-ui-v2 #modal-balance .bal-v2-icon {
            background: rgba(47,125,246,0.10);
            border-color: rgba(47,125,246,0.12);
        }

        .segmented {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            padding: 6px;
            border-radius: 16px;
            border: 1px solid var(--border-color);
            background: var(--subcard-bg);
        }
        .seg-btn {
            border: none;
            border-radius: 12px;
            padding: 10px 10px;
            font-weight: 1000;
            color: var(--text-secondary);
            background: transparent;
        }
        .seg-btn.active {
            background: var(--button-gradient);
            color: #fff;
        }
        .rate-pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 999px;
            background: rgba(47,125,246,0.14);
            border: 1px solid rgba(47,125,246,0.22);
            color: rgba(255,255,255,0.92);
            font-weight: 900;
            font-size: 13px;
            line-height: 1;
        }
        :root[data-theme="light"] .rate-pill {
            color: rgba(28,28,30,0.92);
            background: rgba(47,125,246,0.12);
            border: 1px solid rgba(47,125,246,0.20);
        }
        .rate-float {
            position: fixed;
            z-index: 1001; /* above modal overlay(999) */
            display: none;
            pointer-events: none;
            transform: translate(-50%, 0);
            animation: rate-sway 2.4s ease-in-out infinite;
            filter: drop-shadow(0 10px 24px rgba(0,0,0,0.22));
        }
        .copyable {
            padding: 10px 12px;
            border-radius: 12px;
            border: 1px dashed rgba(90,200,250,0.38);
            background: rgba(90,200,250,0.08);
        }
        .copyable:active { filter: brightness(0.98); }
        .copied {
            animation: copied-pop 420ms ease;
            border-color: rgba(34,197,94,0.55) !important;
            background: rgba(34,197,94,0.10) !important;
        }
        @keyframes copied-pop {
            0% { transform: scale(1); }
            35% { transform: scale(1.02); }
            100% { transform: scale(1); }
        }
        @keyframes rate-sway {
            0% { transform: translate(-50%, 0) rotate(-1.1deg); }
            50% { transform: translate(-50%, 0) rotate(1.1deg); }
            100% { transform: translate(-50%, 0) rotate(-1.1deg); }
        }
        .buy-row {
            display:flex;
            align-items:center;
            justify-content: space-between;
            padding: 14px;
            border: 1px solid var(--border-color);
            border-radius: 14px;
            margin-top: 10px;
            background: var(--subcard-bg);
        }
        .buy-row strong { font-size: 18px; }
        .pill {
            display:inline-block;
            padding: 4px 10px;
            border-radius: 999px;
            background: var(--accent-light-blue);
            color: var(--accent-blue);
            font-weight: 800;
            font-size: 12px;
            margin-left: 8px;
        }
        .buy-btn {
            background: var(--accent-blue);
            border: none;
            color: #fff;
            font-weight: 800;
            padding: 10px 16px;
            border-radius: 12px;
            cursor: pointer;
            min-width: 92px;
        }
        .buy-btn:disabled {
            opacity: 0.40;
            filter: grayscale(0.25);
            cursor: default;
        }
        .buy-btn.ton-quick {
            background: transparent;
            border: 2px solid rgba(90,200,250,0.55);
            color: rgba(255,255,255,0.92);
            box-shadow: none;
        }
        .buy-btn.ton-quick:active {
            background: rgba(90,200,250,0.12);
        }
        .coin-chip { padding: 9px 10px; min-width: 0; border-radius: 999px; font-weight: 800; border-color: rgba(255,255,255,0.65) !important; color: rgba(255,255,255,0.92); }
        .coin-chip.disabled { opacity: 0.35; border-color: rgba(255,255,255,0.18) !important; }
        .coin-chip.selected { border-color: rgba(90,200,250,0.95) !important; background: rgba(90,200,250,0.12); }
        body.web-mode #coin-select .coin-chip[data-coin="STARS"],
        body.web-mode #coin-select .coin-chip[data-coin="stars"] { display: none !important; }

        /* Demo mode: hide money-related UI */
        body.demo-mode:not(.boot-loading) .points,
        body.demo-mode:not(.boot-loading) #view-ref,
        body.demo-mode:not(.boot-loading) #modal-balance,
        body.demo-mode:not(.boot-loading) #li-buy,
        body.demo-mode:not(.boot-loading) #li-free,
        body.demo-mode:not(.boot-loading) #li-history,
        body.demo-mode:not(.boot-loading) #li-withdraw-req,
        body.demo-mode:not(.boot-loading) #li-stats { display: none !important; }
        body.demo-mode:not(.boot-loading) #bet-input,
        body.demo-mode:not(.boot-loading) #bet-range,
        body.demo-mode:not(.boot-loading) .bet-amt-row > div:first-child { display:none !important; }
        body.demo-mode:not(.boot-loading) .bet-amt-row { justify-content: center; }
        body.demo-mode:not(.boot-loading) #btn-start { width: 100% !important; height: 48px !important; }

        /* Boot loading: avoid 1s flicker before backend demoMode arrives */
        body.boot-loading .points,
        body.boot-loading #view-ref,
        body.boot-loading #modal-balance,
        body.boot-loading #li-buy,
        body.boot-loading #li-free,
        body.boot-loading #li-history,
        body.boot-loading #li-withdraw-req,
        body.boot-loading #li-stats { display: none !important; }
        body.boot-loading #bet-input,
        body.boot-loading #bet-range,
        body.boot-loading .bet-amt-row > div:first-child { display:none !important; }
        body.boot-loading .bet-amt-row { justify-content: center; }
        body.boot-loading #btn-start { width: 100% !important; height: 48px !important; opacity: 0.85; pointer-events: none; }

        /* Open animation: smooth reveal top -> bottom after boot-loading is removed */
        body.boot-loading .load-in {
            opacity: 0;
            transform: translateY(-10px);
        }
        body:not(.boot-loading) .load-in {
            opacity: 1;
            transform: translateY(0);
            transition: opacity 260ms ease, transform 260ms ease;
        }
        body:not(.boot-loading) .load-in.d1 { transition-delay: 40ms; }
        body:not(.boot-loading) .load-in.d2 { transition-delay: 90ms; }
        body:not(.boot-loading) .load-in.d3 { transition-delay: 140ms; }
        body:not(.boot-loading) .load-in.d4 { transition-delay: 190ms; }

        /* Light theme fixes for chips + quick buttons */
        :root[data-theme="light"] .buy-btn.ton-quick {
            border-color: rgba(0,0,0,0.28);
            color: rgba(0,0,0,0.80);
            background: rgba(255,255,255,0.65);
        }
        :root[data-theme="light"] .buy-btn.ton-quick:active {
            background: rgba(47,125,246,0.10);
        }
        :root[data-theme="light"] .coin-chip { 
            border-color: rgba(0,0,0,0.22) !important;
            color: rgba(0,0,0,0.82);
            background: rgba(255,255,255,0.65);
        }
        :root[data-theme="light"] .coin-chip.selected {
            border-color: rgba(47,125,246,0.65) !important;
            background: rgba(47,125,246,0.10);
            color: rgba(0,0,0,0.92);
        }
        :root[data-theme="light"] .coin-chip.disabled {
            opacity: 0.45;
            border-color: rgba(0,0,0,0.12) !important;
            color: rgba(0,0,0,0.38);
            background: rgba(255,255,255,0.45);
        }

        /* Bet controls */
        #btn-start,
        #btn-skip {
            font-size: 16px;
            position: relative;
            border-radius: 999px !important;
            border: 0;
            color: #fff;
            background: linear-gradient(180deg, #5AC8FA 0%, #0A84FF 46%, #0066FF 100%);
            box-shadow: none; /* no floating shadow */
            overflow: hidden;
            transform: translateZ(0);
        }
        /* thick outer rim (like the reference button) */
        #btn-start::after,
        #btn-skip::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 999px;
            box-shadow:
              inset 0 0 0 3px rgba(0,0,0,0.10),
              inset 0 -12px 18px rgba(0,0,0,0.22),
              inset 0 2px 0 rgba(255,255,255,0.45);
            pointer-events: none;
        }
        /* inner panel + glass */
        #btn-start::before,
        #btn-skip::before {
            content: '';
            position: absolute;
            left: 4px;
            right: 4px;
            top: 4px;
            bottom: 4px;
            border-radius: 999px;
            background:
              radial-gradient(120% 90% at 30% 18%, rgba(255,255,255,0.75) 0%, rgba(255,255,255,0.22) 42%, rgba(255,255,255,0.00) 74%),
              linear-gradient(180deg, rgba(255,255,255,0.38) 0%, rgba(255,255,255,0.10) 55%, rgba(255,255,255,0.00) 100%);
            mix-blend-mode: screen;
            box-shadow:
              inset 0 0 0 1px rgba(255,255,255,0.22);
            pointer-events: none;
        }
        #btn-start:active {
            transform: translateY(1px);
            filter: saturate(1.06) brightness(0.98);
        }

        /* Start button pulse (on first open, while hint overlay is shown) */
        @keyframes startPulse {
            0%   { transform: translateZ(0) scale(1);   filter: brightness(1); }
            40%  { transform: translateZ(0) scale(1.05); filter: brightness(1.06); }
            100% { transform: translateZ(0) scale(1);   filter: brightness(1); }
        }
        @keyframes startPulseGlow {
            0%   { opacity: 0.0; transform: scale(0.92); }
            40%  { opacity: 0.9; transform: scale(1.08); }
            100% { opacity: 0.0; transform: scale(1.16); }
        }
        #btn-start.pulse {
            animation: startPulse 1200ms ease-in-out infinite;
        }
        #btn-start.pulse::after {
            /* keep rim but add a soft outer glow pulse */
            box-shadow:
              inset 0 0 0 3px rgba(0,0,0,0.10),
              inset 0 -12px 18px rgba(0,0,0,0.22),
              inset 0 2px 0 rgba(255,255,255,0.45),
              0 0 0 0 rgba(90,200,250,0.00);
        }
        #btn-start.pulse::before {
            /* add gentle glow using existing inner panel */
        }
        #btn-start.pulse-glow {
            position: relative;
        }
        #btn-start.pulse-glow > .btn-pulse-ring { display:none; }

        /* Bigger slider */
        #bet-range {
            -webkit-appearance: none;
            appearance: none;
            height: 16px;
            border-radius: 999px;
            /* filled gradient part + remaining track */
            background:
              linear-gradient(90deg,
                #0A84FF 0%,
                #5AC8FA var(--p, 0%),
                rgba(0,0,0,0.12) var(--p, 0%),
                rgba(0,0,0,0.12) 100%);
        }
        :root[data-theme="dark"] #bet-range {
            background:
              linear-gradient(90deg,
                #0A84FF 0%,
                #5AC8FA var(--p, 0%),
                rgba(255,255,255,0.14) var(--p, 0%),
                rgba(255,255,255,0.14) 100%);
        }

        /* Bet input (keep non-focusable to avoid iOS autofill) */
        #bet-input { -webkit-appearance: none; appearance: none; cursor: default; pointer-events:none; }
        #bet-input-hit { cursor: pointer; }

        /* Bet amount custom dropdown */
        #bet-amt-wrap.pressed #bet-input{
            transform: scale(0.98);
            filter: brightness(0.97);
            transition: transform 120ms ease, filter 120ms ease;
        }
        #bet-input{ transition: transform 120ms ease, filter 120ms ease; }

        #bet-dd-backdrop{
            position:fixed;
            inset:0;
            background: rgba(0,0,0,0.18);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            display:none;
            z-index: 99999;
        }
        #bet-dd{
            position:fixed;
            left: 12px;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            max-width: 560px;
            margin: 0 auto;
            border-radius: 18px;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(14,18,30,0.88);
            box-shadow: 0 16px 60px rgba(0,0,0,0.55);
            padding: 10px;
        }
        #bet-dd-title{
            font-weight: 1000;
            letter-spacing: 0.2px;
            color: rgba(255,255,255,0.9);
            padding: 6px 10px 10px;
            font-size: 13px;
        }
        #bet-dd-list{
            display:flex;
            flex-wrap:wrap;
            gap:8px;
            padding: 0 6px 8px;
        }
        .bet-dd-item{
            flex: 1 0 20%;
            min-width: 68px;
            height: 36px;
            border-radius: 999px;
            display:flex;
            align-items:center;
            justify-content:center;
            font-weight: 1000;
            font-variant-numeric: tabular-nums;
            color: rgba(255,255,255,0.88);
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(0,0,0,0.22);
            user-select:none;
            -webkit-user-select:none;
        }
        .bet-dd-item.sel{
            color:#fff;
            border-color: rgba(10,132,255,0.85);
            background: linear-gradient(180deg, rgba(90,200,250,0.32) 0%, rgba(10,132,255,0.28) 55%, rgba(0,102,255,0.22) 100%);
            box-shadow: 0 0 0 2px rgba(10,132,255,0.14);
        }
        .bet-dd-item:active{ transform: scale(0.98); }
        #bet-dd-cancel{
            margin-top: 6px;
            width: 100%;
            height: 40px;
            border-radius: 14px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(255,255,255,0.06);
            color: rgba(255,255,255,0.9);
            font-weight: 1000;
        }

        /* light theme overrides */
        :root:not([data-theme="dark"]) #bet-dd-backdrop{
            background: rgba(0,0,0,0.08);
        }
        :root:not([data-theme="dark"]) #bet-dd{
            border-color: rgba(0,0,0,0.10);
            background: rgba(255,255,255,0.92);
            box-shadow: 0 18px 60px rgba(0,0,0,0.18);
        }
        :root:not([data-theme="dark"]) #bet-dd-title{
            color: rgba(0,0,0,0.82);
        }
        :root:not([data-theme="dark"]) .bet-dd-item{
            color: rgba(0,0,0,0.86);
            border-color: rgba(0,0,0,0.10);
            background: rgba(0,0,0,0.04);
        }
        :root:not([data-theme="dark"]) .bet-dd-item.sel{
            color: rgba(0,0,0,0.92);
            border-color: rgba(10,132,255,0.35);
            background: rgba(10,132,255,0.10);
            box-shadow: inset 0 0 0 1px rgba(10,132,255,0.18);
        }
        :root:not([data-theme="dark"]) #bet-dd-cancel{
            border-color: rgba(0,0,0,0.10);
            background: rgba(0,0,0,0.04);
            color: rgba(0,0,0,0.82);
        }

        /* Bet strip picker */
        #bet-strip-list::-webkit-scrollbar { display:none; }
        /* Bet strip sizing: only 2 tiers:
           - small screens (<=420px): ~3 items
           - big screens (>420px): ~5 items
        */
        #bet-strip-list {
            --betItemW: 120px;
            --betGap: 8px;
            gap: var(--betGap) !important;
            padding: 0 calc(50% - (var(--betItemW) / 2)) !important;
        }
        @media (min-width: 421px) {
            /* big screens: fit ~5 cards */
            #bet-strip-list { --betItemW: 78px; --betGap: 6px; }
        }

        .bet-strip-item {
            flex: 0 0 auto;
            width: var(--betItemW);
            height: 54px;
            border-radius: 18px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(0,0,0,0.22);
            color: rgba(255,255,255,0.92);
            display:flex;
            align-items:center;
            justify-content:center;
            font-weight: 1000;
            font-size: 22px;
            letter-spacing: 0px;
            font-variant-numeric: tabular-nums;
            scroll-snap-align: center;
            scroll-snap-stop: always;
            user-select: none;
            -webkit-user-select: none;
            transition: transform 180ms ease, opacity 180ms ease, background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
        }
        .bet-strip-item.inactive {
            opacity: 0.55;
            transform: scale(0.96);
        }
        /* Center preview while dragging (not yet selected) */
        .bet-strip-item.preview {
            opacity: 0.92;
            transform: scale(1.00);
            border-color: rgba(255,255,255,0.22);
            background: rgba(255,255,255,0.06);
            box-shadow: 0 0 0 2px rgba(255,255,255,0.10), inset 0 0 0 1px rgba(255,255,255,0.10);
        }
        .bet-strip-item.selected {
            opacity: 1;
            transform: scale(1);
            border-color: rgba(10,132,255,0.85);
            background: linear-gradient(180deg, rgba(90,200,250,0.32) 0%, rgba(10,132,255,0.28) 55%, rgba(0,102,255,0.22) 100%);
            box-shadow: 0 0 0 2px rgba(10,132,255,0.20), inset 0 0 0 1px rgba(255,255,255,0.18);
        }
        /* small screens (<=420): slightly smaller */
        .bet-strip-item { font-size: 20px; border-radius: 16px; }
        @media (min-width: 421px) {
            .bet-strip-item { font-size: 16px; border-radius: 16px; height: 50px; }
        }
        #bet-input { font-variant-numeric: tabular-nums; }
        /* Bet input: dark theme (extra iOS rounding glitch fix) */
        :root[data-theme="dark"] #bet-input {
            color: rgba(255,255,255,0.92) !important;
            background: rgba(18,22,32,0.88) !important;
            box-shadow:
              inset 0 0 0 3px rgba(255,255,255,0.12),
              inset 0 2px 0 rgba(255,255,255,0.10),
              inset 0 -8px 14px rgba(0,0,0,0.42) !important;
            -webkit-mask-image: -webkit-radial-gradient(white, black);
            transform: translateZ(0);
        }
        :root[data-theme="dark"] #lang-select {
            background: rgba(18,22,32,0.88) !important;
            color: rgba(255,255,255,0.92) !important;
            border-color: rgba(255,255,255,0.14) !important;
        }
        :root[data-theme="dark"] #lang-select option {
            background-color: #101522;
            color: rgba(255,255,255,0.92);
        }
        #bet-range::-webkit-slider-runnable-track {
            height: 16px;
            border-radius: 999px;
            background: transparent;
        }
        #bet-range::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 24px;
            height: 42px;
            margin-top: -13px;
            border-radius: 12px;
            background: #fff;
            border: 1px solid rgba(0,0,0,0.14);
            box-shadow: 0 14px 28px rgba(0,0,0,0.14);
        }
        #bet-range:active::-webkit-slider-thumb { transform: scale(1.03); }
        #bet-range::-moz-range-track {
            height: 16px;
            border-radius: 999px;
            background: rgba(0,0,0,0.12);
        }
        #bet-range::-moz-range-thumb {
            width: 24px;
            height: 42px;
            border-radius: 12px;
            background: #fff;
            border: 1px solid rgba(0,0,0,0.14);
            box-shadow: 0 14px 28px rgba(0,0,0,0.14);
        }

        .btns { justify-content: space-between; }
        
        .pick-btn {
            flex: 1 1 0;
            width: 0; /* equal-width buttons across full row */
            height: 52px; /* a bit smaller so the frame is visible */
            font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",system-ui,sans-serif;
            border-radius: 999px;

            /* Glassy look */
            background: color-mix(in oklab, var(--glass-bg) 72%, transparent) !important;
            border: 1px solid color-mix(in oklab, var(--glass-border) 70%, rgba(255,255,255,0.08)) !important;
            -webkit-backdrop-filter: blur(12px) saturate(140%);
            backdrop-filter: blur(12px) saturate(140%);
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.14),
                0 10px 26px rgba(0,0,0,0.18);

            outline: none;
            appearance: none;
            -webkit-appearance: none;
            color: var(--text-primary);
            font-weight: 900;
            font-size: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            transform: translateZ(0);
            filter: none;
            transition: filter 220ms ease, transform 180ms ease, border-color 180ms ease, background 180ms ease;
            -webkit-tap-highlight-color: transparent;
        }
        .pick-btn.active {
            transform: scale(1.02);
            background: color-mix(in oklab, var(--glass-bg) 82%, rgba(90,200,250,0.10)) !important;
            border-color: color-mix(in oklab, var(--accent-blue) 70%, var(--glass-border)) !important;
            /* iOS: filter drop-shadow can create square artifacts; use text-shadow instead */
            filter: none;
            text-shadow:
              0 0 12px rgba(0,122,255,0.98),
              0 0 28px rgba(0,122,255,0.82),
              0 0 56px rgba(0,122,255,0.52),
              0 0 92px rgba(0,122,255,0.32);
        }
        .pick-btn.shake {
            animation: pick-shake 120ms ease-in-out 0s 4;
        }
        /* paper shakes mirrored */
        #pick-paper.shake {
            animation-name: pick-shake-r;
        }
        @keyframes pick-shake {
            0% { transform: translateX(0) scale(1); }
            25% { transform: translateX(-3px) scale(1.01); }
            50% { transform: translateX(3px) scale(1.01); }
            75% { transform: translateX(-2px) scale(1.01); }
            100% { transform: translateX(0) scale(1); }
        }
        @keyframes pick-shake-r {
            0% { transform: translateX(0) scale(1); }
            25% { transform: translateX(3px) scale(1.01); }
            50% { transform: translateX(-3px) scale(1.01); }
            75% { transform: translateX(2px) scale(1.01); }
            100% { transform: translateX(0) scale(1); }
        }
        :root[data-theme="dark"] .pick-btn { color: #fff; }
        /* Light theme: keep shadows inside (no outer drop) */
        :root:not([data-theme="dark"]) .pick-btn {
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.24),
                inset 0 12px 26px rgba(0,0,0,0.10),
                inset 0 -14px 24px rgba(0,0,0,0.06);
        }
        .subtle { color: var(--text-secondary); font-size: 12px; }
        #bet-overlay [data-i18n="games.bet"] {
            font-size: 14px;
            font-weight: 900;
            color: var(--text-primary);
            opacity: 0.85;
            letter-spacing: 0.2px;
        }
        .big-action {
            width: 100%;
            border: none;
            border-radius: 14px;
            padding: 14px 16px;
            background: linear-gradient(90deg, #2f7df6 0%, #59a7ff 100%);
            color: #fff;
            font-weight: 900;
            cursor: pointer;
            margin-top: 10px;
        }
        .big-action:disabled {
            opacity: 0.55;
            filter: grayscale(0.55);
            pointer-events: none;
            background: rgba(120,120,130,0.28) !important;
            color: rgba(255,255,255,0.75) !important;
        }

        /* Withdraw receive hint (styled pill) */
        .receive-hint {
            margin-top: 10px;
            padding: 10px 12px;
            border-radius: 18px;
            border: 0.5px solid rgba(255,255,255,0.10);
            background: rgba(16,18,24,0.92);
            color: rgba(255,255,255,0.88);
            font-weight: 600;
            font-size: 12px;
            line-height: 1.35;
            box-shadow: 0 10px 26px rgba(0,0,0,0.28);
        }
        :root[data-theme="light"] .receive-hint {
            border: 0.5px solid rgba(0,0,0,0.10);
            background: rgba(255,255,255,0.86);
            color: rgba(0,0,0,0.78);
            box-shadow: 0 10px 26px rgba(0,0,0,0.10);
        }
        .receive-hint b { color: rgba(255,255,255,0.98); font-weight: 900; }
        :root[data-theme="light"] .receive-hint b { color: rgba(0,0,0,0.92); }
        .ref-box {
            margin: 0 16px;
            background: var(--card-bg);
            border-radius: 16px;
            padding: 16px;
            box-shadow: 0 2px 8px var(--shadow-color);
            border: 1px solid var(--border-color);
        }
        .ref-stats {
            margin-top: 12px;
            padding: 12px;
            border-radius: 12px;
            background: var(--subcard-bg);
            display:flex;
            align-items:center;
            justify-content: space-between;
            gap: 10px;
            font-weight: 800;
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }
        .ref-link {
            width: 100%;
            text-align: left;
            font-weight: 900;
            font-size: 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            opacity: 0.92;
        }
        .ref-actions {
            margin-top: 12px;
            display:flex;
            gap: 10px;
        }
        .share-btn {
            flex: 1;
            border: none;
            border-radius: 14px;
            height: 56px;
            padding: 0 14px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            background: var(--button-gradient);
            color: #fff;
            font-weight: 900;
            font-size: 16px;
            cursor: pointer;
        }
        .copy-btn {
            width: 56px;
            height: 56px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: none;
            border-radius: 18px;
            background: var(--button-gradient);
            box-shadow: none;
            color: #fff;
            font-weight: 900;
            font-size: 20px;
            line-height: 1;
            cursor: pointer;
            user-select: none;
            -webkit-user-select: none;
            transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
        }
        .copy-btn:active {
            transform: scale(0.98);
            filter: brightness(0.98);
        }

        /* iOS-like switch */
        .switch {
            position: relative;
            display: inline-block;
            width: 52px;
            height: 32px;
            flex: 0 0 auto;
        }
        .switch input { opacity: 0; width: 0; height: 0; }
        .slider {
            position: absolute;
            cursor: pointer;
            inset: 0;
            background: rgba(255,255,255,0.10);
            border: 1px solid var(--border-color);
            transition: .2s;
            border-radius: 999px;
        }
        .slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 3px;
            top: 2.5px;
            background: #fff;
            transition: .2s;
            border-radius: 50%;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        .switch input:checked + .slider {
            background: rgba(34,197,94,0.35);
            border-color: rgba(34,197,94,0.55);
        }
        .switch input:checked + .slider:before {
            transform: translateX(20px);
        }

        /* micro-animations */
        button, .nav-item { -webkit-tap-highlight-color: transparent; }

        /* Speed buttons (3D, like reference) */
        .speed-btn {
            position: relative;
            border: none;
            border-radius: 999px;
            padding: 0;
            margin: 0;
            display: grid;
            place-items: center;
            -webkit-tap-highlight-color: transparent;
            touch-action: none;
            /* no outer shadow (as requested) */
            box-shadow:
                inset 0 3px 0 rgba(255,255,255,0.34),
                inset 0 -14px 22px rgba(0,0,0,0.28);
        }
        /* outer rim */
        .speed-btn::after {
            content: '';
            position: absolute;
            inset: -3px;
            border-radius: 999px;
            background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,0.30), rgba(255,255,255,0.00) 62%);
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
            pointer-events: none;
        }
        /* inner glass highlight */
        .speed-btn::before {
            content: '';
            position: absolute;
            inset: 7px;
            border-radius: 999px;
            background:
                radial-gradient(120% 120% at 30% 18%, rgba(255,255,255,0.55), rgba(255,255,255,0.00) 52%),
                radial-gradient(120% 120% at 50% 100%, rgba(0,0,0,0.26), rgba(0,0,0,0.00) 55%);
            pointer-events: none;
        }
        .speed-btn:active {
            transform: translateY(1px) scale(0.99);
        }
        .speed-btn.speed-red {
            background: radial-gradient(120% 120% at 30% 18%, #ffb4ad 0%, #ff3b30 56%, #b70f0a 100%);
        }
        .speed-btn.speed-green {
            background: radial-gradient(120% 120% at 30% 18%, #caffc8 0%, #34c759 56%, #0f7c2d 100%);
        }
        .speed-arrow {
            width: 0;
            height: 0;
            filter: none;
        }
        .speed-arrow.up {
            border-left: 17px solid transparent;
            border-right: 17px solid transparent;
            border-bottom: 24px solid rgba(255,255,255,0.98);
            transform: translateY(-2px);
        }
        .speed-arrow.down {
            border-left: 17px solid transparent;
            border-right: 17px solid transparent;
            border-top: 24px solid rgba(255,255,255,0.98);
            transform: translateY(2px);
        }

        /* Speed control wave effect */
        .speed-wave {
            position: fixed;
            width: 14px;
            height: 14px;
            border-radius: 999px;
            transform: translate(-50%, -50%);
            pointer-events: none;
            z-index: 9999;
            border: 4px solid var(--c, rgba(255,255,255,0.70));
            opacity: 1;
            animation: speedWave 980ms ease-out forwards;
            filter: none;
        }
        @keyframes speedWave {
            0% { transform: translate(-50%, -50%) scale(0.35); opacity: 1; }
            60% { opacity: 0.95; }
            100% { transform: translate(-50%, -50%) scale(6.2); opacity: 0; }
        }

        /* Lock UI during a running round */
        body.ui-locked button,
        body.ui-locked input,
        body.ui-locked .nav-item,
        body.ui-locked .user-badge {
            pointer-events: none !important;
        }
        body.ui-locked .bottom-nav {
            pointer-events: none !important;
        }
        body.ui-locked #arena {
            pointer-events: none; /* no taps while running */
        }
        body.ui-locked #btn-start { opacity: 0.7; }
        body.ui-locked #bet-range { opacity: 0.7; }
        body.ui-locked .pick-btn { opacity: 0.75; }
        body.ui-locked .user-badge { opacity: 0.8; }
        body.ui-locked #btn-skip { pointer-events: auto !important; }
        /* Allow admin tools even while round is running */
        body.ui-locked #admin-tools-top,
        body.ui-locked #perf-open,
        body.ui-locked #tune-open,
        body.ui-locked #tune-panel,
        body.ui-locked #tune-panel button,
        body.ui-locked #tune-panel input,
        body.ui-locked #perf-debug {
            pointer-events: auto !important;
        }
        body.ui-locked #speed-ctl {
            pointer-events: none !important;
        }
        body.ui-locked #speed-ctl button {
            pointer-events: auto !important;
        }

        body.maintenance-mode #app-root { filter: blur(1px) saturate(0.6); }
        body.maintenance-mode #views,
        body.maintenance-mode .bottom-nav { pointer-events: none !important; }
        .pressable {
            transition: transform 120ms ease, filter 120ms ease;
            transform: translateZ(0);
        }
        .pressable:active { transform: scale(0.98); }
        .pressable.pulse {
            animation: pulse 240ms ease;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            40% { transform: scale(0.97); }
            100% { transform: scale(1); }
        }

        /* confetti */
        #confetti {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 12000;
        }

        /* Intro burst (flying preview emojis) */
        #intro-burst {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 11900;
        }

        /* Withdraw pending loader */
        .mini-spinner {
            width: 18px;
            height: 18px;
            border-radius: 999px;
            border: 2px solid rgba(255,255,255,0.18);
            border-top-color: rgba(90,200,250,0.95);
            animation: spin 0.9s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }
        .burst-emoji {
            position: fixed;
            left: var(--x0);
            top: var(--y0);
            transform: translate(-50%, -50%) translate(0,0) rotate(0deg);
            font-size: var(--fs);
            filter: drop-shadow(0 10px 20px rgba(0,0,0,0.30));
            animation: burst-fly var(--dur) cubic-bezier(.2,.8,.2,1) forwards;
            will-change: transform, opacity;
        }
        @keyframes burst-fly {
            0% { opacity: 1; transform: translate(-50%, -50%) translate(0,0) rotate(0deg); }
            100% { opacity: 0; transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--rot)); }
        }

        /* (confetti styles defined above) */

        .tut-bubble {
            position: absolute;
            max-width: 220px;
            padding: 10px 12px;
            border-radius: 14px;
            background: rgba(20,28,42,0.92);
            border: 1px solid rgba(255,255,255,0.12);
            color: #fff;
            font-weight: 900;
            font-size: 13px;
            line-height: 1.25;
            box-shadow: 0 10px 30px rgba(0,0,0,0.35);
        }
        .tut-label {
            position: fixed;
            z-index: 24010;
            font-weight: 1000;
            font-size: 16px;
            letter-spacing: 0.2px;
            text-shadow: 0 8px 22px rgba(0,0,0,0.65);
            pointer-events: none;
            white-space: nowrap;
        }
        .tut-arrow {
            display:none;
        }
        .tut-title { opacity: 0.92; }
        .tut-hint { opacity: 0.75; font-weight: 800; margin-top: 4px; }
        .confetti-piece {
            position: absolute;
            width: 10px;
            height: 14px;
            border-radius: 3px;
            opacity: 0.95;
            transform: translate3d(0,0,0) rotate(0deg);
            animation: confetti-fall 1700ms cubic-bezier(.2,.8,.2,1) forwards;
        }
        @keyframes confetti-fall {
            0% { transform: translate3d(var(--x0), var(--y0), 0) rotate(0deg); opacity: 1; }
            100% { transform: translate3d(var(--x1), 120vh, 0) rotate(520deg); opacity: 0.95; }
        }

        /* shatter effect (start game): small pieces fly out and fade */
        .shatter-piece {
            position: absolute;
            width: var(--w);
            height: var(--h);
            border-radius: 3px;
            background: rgba(255,255,255,0.12);
            border: 1px solid rgba(255,255,255,0.10);
            backdrop-filter: blur(2px);
            opacity: 0.95;
            transform: translate3d(0,0,0) rotate(0deg);
            animation: shatter-fly var(--dur) cubic-bezier(.2,.8,.2,1) forwards;
            will-change: transform, opacity;
        }
        @keyframes shatter-fly {
            0% { transform: translate3d(var(--x0), var(--y0), 0) rotate(0deg) scale(1); opacity: 0.95; }
            55% { opacity: 0.25; }
            75% { opacity: 0; }
            100% { transform: translate3d(calc(var(--x0) + var(--dx)), calc(var(--y0) + var(--dy)), 0) rotate(var(--rot)) scale(0.92); opacity: 0; }
        }
        .unlock-toast {
            position: fixed;
            left: 50%;
            top: 28px;
            transform: translateX(-50%);
            background: rgba(47,125,246,0.12);
            color: var(--accent-blue);
            border: 1px solid rgba(47,125,246,0.22);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            padding: 10px 14px;
            border-radius: 999px;
            font-weight: 900;
            z-index: 10000;
            opacity: 0;
            transition: opacity 200ms ease, transform 200ms ease;
        }
        .unlock-toast.show {
            opacity: 1;
        }

        .match-card {
            background: var(--card-bg);
            margin: 0 16px 14px;
            padding: 18px;
            border-radius: 22px;
            box-shadow: 0 6px 18px rgba(0,0,0,0.06);
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 14px;
        }

        .match-right {
            display:flex;
            flex-direction: column;
            align-items: flex-end;
            gap: 10px;
            min-width: 90px;
        }

        .match-right .match-time {
            padding-right: 0;
        }

        .match-info {
            flex: 1;
        }

        .league-info {
            font-size: 16px;
            color: var(--text-secondary);
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
        }
        .league-info .meta-left {
            display:flex;
            align-items:center;
            gap: 12px;
            min-width: 0;
        }
        .league-info .lock {
            font-size: 22px;
            opacity: .9;
        }
        .league-info .league-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 60vw;
        }

        .match-time {
            text-align: right;
            white-space: nowrap;
            font-size: 18px;
            color: var(--text-secondary);
            padding-right: 12px;
            flex: 0 0 auto;
        }

        .team {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 10px;
            font-weight: 900;
            font-size: 15px;
            letter-spacing: -0.1px;
            line-height: 1.15;
            color: var(--text-primary);
        }
        .team img {
            width: 28px !important;
            height: 28px !important;
            border-radius: 50% !important;
            background: rgba(255,255,255,0.08);
            object-fit: cover;
        }

        .odds-box {
            padding: 11px 12px;
            border-radius: 16px;
            font-weight: 900;
            font-size: 24px;
            min-width: 80px;
            text-align: center;
        }
        .odds-blue {
            background: var(--accent-light-blue);
            color: var(--accent-blue);
            border: 1px solid var(--border-color);
        }
        .odds-yellow {
            /* keep class for compatibility; use brand blue */
            background: var(--accent-light-blue);
            color: var(--accent-blue);
        }

        /* Loading balls animation (2s) */
        .loading-ball {
            position: fixed;
            font-size: 22px;
            line-height: 22px;
            width: 22px;
            height: 22px;
            transform: translate3d(0,0,0);
            will-change: transform, opacity;
            filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
        }

        html, body {
            height: 100%;
            overflow: hidden;
            overscroll-behavior: none;
            -webkit-overflow-scrolling: auto;
        }
        #app-root {
            position: fixed;
            inset: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        #views {
            /* iOS: position:fixed inside overflow containers can "stick" to the container.
               Make views span full screen to avoid top gap for fixed arena. */
            position: fixed;
            inset: 0;
            /* Important: do NOT scroll #views. Each view-section scrolls on its own.
               Nested scroll containers cause weird "page-size" swipes and scroll restore bugs. */
            overflow: hidden;
            -webkit-overflow-scrolling: auto;
            z-index: 1;
            /* Prevent browser scroll anchoring from "restoring" old scrollTop when content swaps */
            overflow-anchor: none;
        }
        .view-section { overflow-anchor: none; }

        .bottom-nav {
            /* Floating dark glass pill like iOS (Contacts/Calls/Chats style) */
            pointer-events: auto;
            z-index: 5000;

            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
            position: fixed;
            left: 12px;
            right: 12px;
            bottom: calc(4px + env(safe-area-inset-bottom, 0px));
            margin: 0 auto;
            max-width: 560px;

            padding: 3px 0px;
            display: flex;
            justify-content: space-around;
            gap: 10px;

            border-radius: 999px;
            z-index: 200;
            overflow: visible;

            background: rgba(10, 15, 25, 0.46);
            border: 0.5px solid rgba(255,255,255,0.10);
            -webkit-backdrop-filter: blur(18px) saturate(140%);
            backdrop-filter: blur(18px) saturate(140%);
            box-shadow:
                0 18px 60px rgba(0,0,0,0.55),
                inset 0 1px 0 rgba(255,255,255,0.10),
                inset 0 -14px 22px rgba(0,0,0,0.35);
        }
        /* light theme: light frosted pill */
        :root:not([data-theme="dark"]) .bottom-nav {
            background: rgba(250, 250, 252, 0.72);
            border-color: rgba(255,255,255,0.55);
            /* no outer drop shadow in light theme — keep it inside */
            box-shadow:
                inset 0 10px 26px rgba(0,0,0,0.10),
                inset 0 1px 0 rgba(255,255,255,0.55),
                inset 0 -14px 22px rgba(0,0,0,0.08);
        }

        /* Glass indicator around active item */
        .nav-indicator {
            position: absolute;
            left: 0;
            top: 0px;
            height: 100%;
            width: 0px;
            border-radius: 999px;
            pointer-events: none;

            /* inner pill (active) */
            background: rgba(255,255,255,0.12);
            border: 1px solid rgba(255,255,255,0.14);
            -webkit-backdrop-filter: blur(20px) saturate(160%);
            backdrop-filter: blur(20px) saturate(160%);
            box-shadow:
                0 16px 36px rgba(0,0,0,0.35),
                inset 0 1px 0 rgba(255,255,255,0.12),
                inset 0 -16px 26px rgba(0,0,0,0.28);

            --nav-x: 0px;
            --nav-scale: 1;
            transform: translateX(var(--nav-x)) scale(var(--nav-scale));
            transform-origin: center;
            will-change: transform, width;
            transition: transform 180ms cubic-bezier(.2,.8,.2,1), width 180ms cubic-bezier(.2,.8,.2,1);
        }
        .nav-indicator.bump {
            --nav-scale: 1.06;
        }
        :root:not([data-theme="dark"]) .nav-indicator {
            /* Clear active highlight in light theme */
            background: rgba(255,255,255,0.88);
            border-color: rgba(0,0,0,0.10);
            /* remove outer drop shadow in light theme (looks clipped near iOS UI) */
            box-shadow:
                inset 0 1px 0 rgba(255,255,255,0.65),
                inset 0 -18px 30px rgba(0,0,0,0.10);
        }

        /* iOS-like "magnifier" bubble animation (on press) */
        .nav-magnifier {
            position: absolute;
            left: 0;
            top: 0;
            width: 104px;
            height: 104px;
            border-radius: 999px;
            pointer-events: none;
            z-index: 3; /* above indicator */

            opacity: 0;
            transform: translate(-50%, -50%) scale(0.70);
            transform-origin: center;

            /* clean single magnifier (no inner highlight effect) */
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.20);
            -webkit-backdrop-filter: blur(18px) saturate(140%);
            backdrop-filter: blur(18px) saturate(140%);
            box-shadow: 0 22px 60px rgba(0,0,0,0.38);
        }
        :root:not([data-theme="dark"]) .nav-magnifier {
            background: rgba(255,255,255,0.12);
            border-color: rgba(255,255,255,0.28);
            box-shadow: 0 18px 52px rgba(0,0,0,0.20);
        }
        .nav-magnifier.mag-anim {
            animation: navMagnify 280ms cubic-bezier(.2,.9,.2,1) 1;
        }
        @keyframes navMagnify {
            0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.60); }
            40%  { opacity: 1; transform: translate(-50%, -50%) scale(1.00); }
            100% { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
        }
        .nav-indicator.dragging { transition: none; }

        /* Make sure items are above indicator */
        .nav-item { position: relative; z-index: 2; pointer-events: auto; }

        .nav-item {
            flex: 1;
            text-align: center;
            color: rgba(255,255,255,0.72);
            font-size: 10px;
            font-weight: 900;
            cursor: pointer;
            padding: 3px 0;
            border-radius: 16px;
            -webkit-user-select: none;
            user-select: none;
        }

        /* Light theme nav text should be dark */
        :root:not([data-theme="dark"]) .nav-item { color: rgba(15, 23, 42, 0.72); }

        .nav-item.active {
            color: rgba(255,255,255,0.98);
        }
        :root:not([data-theme="dark"]) .nav-item.active { color: var(--accent-blue); }

        .nav-item.active .nav-icon {
            filter: drop-shadow(0 6px 18px rgba(0,0,0,0.32));
        }
        :root:not([data-theme="dark"]) .nav-item.active .nav-icon {
            filter: drop-shadow(0 10px 26px rgba(0,0,0,0.18));
        }

        .bottom-nav.dragging .nav-item:active { background: transparent !important; }

        .nav-item:active {
            background: rgba(255,255,255,0.06);
        }
        :root:not([data-theme="dark"]) .bottom-nav.dragging .nav-item:active { background: transparent !important; }

        .nav-item:active {
            background: rgba(0,0,0,0.04);
        }

        .nav-item.active {
            color: var(--accent-blue);
        }

        /* active tab: no size change (pill moves instead) */
        .nav-item.active .nav-icon { font-size: 20px; }
        .nav-item.active { font-size: 10px; }

        .nav-icon {
            font-size: 20px;
            display: block;
            margin-bottom: 4px;
        }
        
        /* Views */
        .view-section {
            display: none;
            position: absolute;
            inset: 0;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
            will-change: transform, opacity;
        }
        .view-section.active {
            display: block;
            transform: translateX(0);
            opacity: 1;
            /* keep some padding, but main bottom gap is via ::after spacer below */
            padding-bottom: 120px;
            min-height: 100%;
        }
        /* Hard bottom spacer so last items never sit under the fixed bottom nav */
        .view-section.active:not(#view-games)::after {
            content: '';
            display: block;
            height: calc(140px + env(safe-area-inset-bottom, 0px));
        }
        .view-section.animating {
            display: block;
        }
        /* Games view controls already manage their own padding */
        #view-games.view-section.active { padding-bottom: 0; }
        /* Home may have short content; allow tiny scroll so swipe doesn't close */
        #view-home.view-section.active { min-height: calc(100% + 2px); }
