:root {
            /* Calmer euroglass — muted slate/navy, no neon mint */
            --eu-bg: linear-gradient(160deg, #141c2c 0%, #1a2744 42%, #1c2438 72%, #201e32 100%);
            --euromaja-bg-base: #1a2744;
            --theme-gradient: var(--eu-bg);
            --eu-text: #e8eef7;
            --eu-accent: #9bb4d0;
            --eu-glass: rgba(255, 255, 255, 0.07);
            --eu-glass-border: rgba(255, 255, 255, 0.14);
            --eu-btn-primary: #4a6fa5;
            --eu-btn-primary-hover: #5a82bc;
            --eu-panel: linear-gradient(180deg, rgba(28, 38, 58, 0.94) 0%, rgba(30, 32, 50, 0.96) 100%);
        }

        /* Quiet the shared arcade blobs */
        .eu-blobs { opacity: 0.2; }
        .eu-blob { filter: blur(100px); animation: none !important; }
        .eu-blob-1 { background: radial-gradient(circle, #2a4a6a, #152030) !important; }
        .eu-blob-2 { background: radial-gradient(circle, #3a3f6a, #1a1830) !important; }
        .eu-blob-3 { background: radial-gradient(circle, #243848, #121820) !important; }
        .eu-blob-4 { background: radial-gradient(circle, #3a3558, #181420) !important; }

        *, *::before, *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-user-select: none !important;
            -moz-user-select: none !important;
            -ms-user-select: none !important;
            user-select: none !important;
            -webkit-touch-callout: none !important;
            -webkit-tap-highlight-color: transparent;
            /* pan only — do NOT use manipulation (still allows pinch on Chromium) */
            touch-action: pan-x pan-y;
        }

        html,
        html.eu-game-root {
            touch-action: pan-x pan-y;
            overscroll-behavior: none;
            background-color: #1a2744 !important;
            background-image: none !important;
        }
        html.eu-game-root::before,
        html:has(body.eu-game-theme)::before {
            background: #1a2744 !important;
            background-image: none !important;
        }

        input, textarea {
            -webkit-user-select: text !important;
            -moz-user-select: text !important;
            -ms-user-select: text !important;
            user-select: text !important;
            touch-action: manipulation;
        }

        /* Messages are not text-selectable so a long-press opens the action menu
           instead of the OS text-selection callout. Use the Copy action instead. */
        .message {
            -webkit-user-select: none !important;
            user-select: none !important;
            -webkit-touch-callout: none !important;
        }

        body.eu-game-theme {
            font-family: 'Nunito', system-ui, sans-serif;
            color: var(--eu-text);
            min-height: 100vh;
            min-height: 100dvh;
            padding: 16px;
            padding-top: max(16px, env(safe-area-inset-top));
            padding-bottom: max(16px, env(safe-area-inset-bottom));
            touch-action: pan-x pan-y;
            overscroll-behavior: none;
            background: #1a2744 !important;
        }

        .container {
            position: relative;
            z-index: 1;
            max-width: 960px;
            margin: 0 auto;
            color: var(--eu-text);
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            border-radius: clamp(22px, 4vw, 28px);
            padding: clamp(18px, 3vw, 30px);
            box-shadow:
                0 18px 48px rgba(0, 0, 0, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
            overflow: hidden;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 22px;
            flex-wrap: wrap;
            gap: 12px;
            min-width: 0;
        }

        h1 {
            color: #fff;
            font-size: clamp(1.35rem, 4vw, 2rem);
            font-weight: 800;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            min-width: 0;
        }

        .header-actions {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-wrap: nowrap;
            min-width: 0;
            justify-content: flex-end;
            flex: 1 1 auto;
            overflow: hidden;
        }

        .pill-btn {
            background: var(--eu-glass);
            color: var(--eu-text);
            border: 1px solid var(--eu-glass-border);
            padding: 10px 18px;
            border-radius: 999px;
            text-decoration: none;
            font-size: clamp(0.78rem, 2vw, 0.92rem);
            font-family: inherit;
            font-weight: 700;
            cursor: pointer;
            transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .pill-btn:hover {
            background: rgba(255, 255, 255, 0.14);
            border-color: rgba(255, 255, 255, 0.28);
            transform: translateY(-1px);
        }

        /* Title chip is its own shrinkable slot; tool buttons sit beside it */
        .room-chrome {
            display: none;
            align-items: center;
            gap: 6px;
            min-width: 0;
            flex: 1 1 0%;
            max-width: min(62vw, 360px);
            overflow: hidden;
        }
        .room-chrome.show { display: flex; }
        body.chat-room-open .room-chrome.show {
            flex: 1 1 auto;
            max-width: 100%;
            width: 100%;
        }
        .room-title-wrap {
            display: flex;
            align-items: center;
            gap: 0;
            min-width: 0;
            flex: 1 1 auto;
            overflow: hidden;
        }
        .room-tool-btns {
            display: flex;
            align-items: center;
            gap: 6px;
            flex: 0 0 auto;
            flex-shrink: 0;
        }
        .room-code-chip {
            background: rgba(0, 0, 0, 0.22);
            border: 1px solid rgba(255, 255, 255, 0.14);
            color: var(--eu-text);
            padding: 8px 10px;
            border-radius: 999px;
            font-size: clamp(0.78rem, 2.4vw, 0.95rem);
            font-weight: 700;
            flex: 1 1 auto;
            width: 100%;
            min-width: 0;
            max-width: 100%;
            overflow: hidden;
            box-sizing: border-box;
        }
        .room-rename-btn {
            background: var(--eu-glass);
            border: 1px solid var(--eu-glass-border);
            color: #fff;
            border-radius: 50%;
            width: 34px;
            height: 34px;
            padding: 0;
            cursor: pointer;
            font-size: 0.95rem;
            line-height: 1;
            flex-shrink: 0;
            font-family: inherit;
        }
        .room-rename-btn:hover {
            background: rgba(255, 255, 255, 0.14);
            border-color: rgba(255, 255, 255, 0.28);
        }
        .room-rename-btn[hidden] { display: none !important; }

        .screen { display: none; }
        .screen.active { display: block; }

        /* Home / lobby */
        .lobby {
            display: flex;
            flex-direction: column;
            gap: 22px;
            align-items: center;
            padding: 24px 10px 10px;
        }

        .lobby-card {
            width: 100%;
            max-width: 420px;
            background: rgba(0, 0, 0, 0.28);
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 18px;
            padding: 24px;
            text-align: center;
        }

        .lobby-card h2 {
            color: #fff;
            font-size: 1.05rem;
            margin-bottom: 8px;
            font-weight: 800;
        }

        .lobby-card p {
            color: rgba(240, 249, 255, 0.62);
            font-size: 0.9rem;
            line-height: 1.5;
            margin-bottom: 18px;
        }

        .big-btn {
            display: block;
            width: 100%;
            background: var(--eu-btn-primary);
            background-image: none;
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.12);
            padding: 14px 16px;
            border-radius: 14px;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 800;
            font-family: inherit;
            box-shadow: none;
            transition: background 0.2s ease;
        }

        .big-btn:hover {
            background: var(--eu-btn-primary-hover);
            background-image: none;
            filter: none;
            transform: none;
        }
        .big-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }

        .code-input {
            width: 100%;
            padding: 16px;
            font-size: 1.7rem;
            letter-spacing: 8px;
            text-align: center;
            font-family: inherit;
            font-weight: 800;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            color: var(--eu-text);
            outline: none;
            margin-bottom: 16px;
        }
        .code-input:focus {
            border-color: rgba(155, 180, 208, 0.55);
            box-shadow: 0 0 0 3px rgba(155, 180, 208, 0.12);
        }

        .lobby-msg {
            min-height: 1.2em;
            color: #fecaca;
            font-size: 0.82rem;
            margin-top: 12px;
            font-weight: 600;
        }

        /* Room / chat */
        .chat-area {
            height: 58vh;
            background: rgba(0, 0, 0, 0.22);
            border-radius: 16px;
            padding: 18px;
            overflow-y: auto;
            overflow-x: hidden;
            margin-bottom: 16px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-width: 0;
        }

        .chat-empty {
            margin: auto;
            color: rgba(240, 249, 255, 0.55);
            font-size: 0.9rem;
            text-align: center;
            padding: 0 12px;
            line-height: 1.5;
        }

        .message {
            padding: 10px 14px;
            border-radius: 16px;
            max-width: min(72%, 100%);
            min-width: 0;
            word-wrap: break-word;
            overflow-wrap: anywhere;
            animation: fadeIn 0.3s ease-out;
        }

        .message .msg-who {
            font-size: 0.72rem;
            opacity: 0.8;
            margin-bottom: 3px;
            font-weight: 700;
            min-width: 0;
            max-width: 100%;
            overflow: hidden;
        }

        .eu-online-dot {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 6px;
            flex-shrink: 0;
            vertical-align: middle;
        }

        .eu-online-dot.is-online {
            background: #6fbf8a;
            box-shadow: none;
        }

        .eu-online-dot.is-offline {
            background: #6b7280;
        }

        .room-code-chip,
        .history-item .hi-code,
        .message .msg-who {
            display: flex;
            align-items: center;
            min-width: 0;
            max-width: 100%;
            overflow: hidden;
            gap: 6px;
        }
        .room-code-chip > .eu-online-dot,
        .history-item .hi-code > .eu-online-dot,
        .message .msg-who > .eu-online-dot {
            margin-right: 0;
            flex-shrink: 0;
        }
        /* Long usernames must ellipsize: flex child needs flex-basis 0 + min-width 0 */
        .title-label {
            flex: 1 1 0%;
            min-width: 0 !important;
            max-width: 100%;
            overflow: hidden !important;
            text-overflow: ellipsis !important;
            white-space: nowrap !important;
            display: block;
            word-break: normal;
            overflow-wrap: normal;
        }
        .history-item .hi-code {
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }
        .history-item .hi-code .hi-unread {
            margin-left: 0;
            flex-shrink: 0;
        }

        .message .msg-time {
            display: block;
            font-size: 0.68rem;
            opacity: 0.65;
            margin-top: 5px;
            letter-spacing: 0.2px;
            text-align: right;
        }

        .day-sep {
            align-self: center;
            margin: 10px 0 6px;
            padding: 5px 12px;
            border-radius: 999px;
            background: var(--eu-glass);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: rgba(240, 249, 255, 0.78);
            font-size: 0.72rem;
            font-weight: 700;
            text-align: center;
        }

        .message.mine {
            background: rgba(74, 111, 165, 0.92);
            color: #fff;
            align-self: flex-end;
            box-shadow: none;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .message.theirs {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: var(--eu-text);
            align-self: flex-start;
        }

        .input-area {
            display: flex;
            gap: 10px;
            min-width: 0;
            align-items: stretch;
        }

        .composer-wrap {
            flex: 1;
            min-width: 0;
            position: relative;
        }

        #messageInput {
            width: 100%;
            box-sizing: border-box;
            padding: 14px 18px;
            border-radius: 999px;
            border: 1px solid var(--eu-glass-border);
            background: rgba(255, 255, 255, 0.1);
            color: var(--eu-text);
            font-size: 1rem;
            font-family: inherit;
            font-weight: 600;
            outline: none;
        }
        #messageInput:focus {
            border-color: rgba(155, 180, 208, 0.5);
            box-shadow: 0 0 0 3px rgba(155, 180, 208, 0.1);
        }

        #messageInput::placeholder { color: rgba(232, 238, 247, 0.4); }

        #sendBtn {
            background: var(--eu-btn-primary);
            background-image: none;
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.12);
            padding: 14px 22px;
            border-radius: 999px;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 800;
            transition: background 0.2s ease;
            font-family: inherit;
            flex-shrink: 0;
            box-shadow: none;
        }

        #sendBtn:hover {
            background: var(--eu-btn-primary-hover);
            transform: none;
            filter: none;
        }

        .attach-wrap { position: relative; flex-shrink: 0; }

        #attachBtn {
            background: var(--eu-glass);
            color: #fff;
            border: 1px solid var(--eu-glass-border);
            padding: 14px 16px;
            border-radius: 999px;
            cursor: pointer;
            font-size: 1.15rem;
            line-height: 1;
            flex-shrink: 0;
            transition: background 0.2s ease, border-color 0.2s ease;
            font-family: inherit;
        }

        #attachBtn:hover {
            background: rgba(255, 255, 255, 0.14);
            border-color: rgba(255, 255, 255, 0.28);
        }
        #attachBtn:disabled { opacity: 0.5; cursor: not-allowed; }

        .attach-menu {
            position: absolute;
            bottom: calc(100% + 8px);
            left: 0;
            min-width: 150px;
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            border-radius: 14px;
            padding: 6px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(16px) saturate(1.05);
            -webkit-backdrop-filter: blur(16px) saturate(1.05);
            z-index: 40;
        }

        .attach-opt {
            display: block;
            width: 100%;
            text-align: left;
            background: transparent;
            border: none;
            color: #f0f9ff;
            padding: 10px 12px;
            border-radius: 10px;
            cursor: pointer;
            font-family: inherit;
            font-size: 0.78rem;
            font-weight: 700;
        }

        .attach-opt:hover { background: rgba(255, 255, 255, 0.12); }
        .attach-opt:disabled { opacity: 0.4; cursor: not-allowed; }

        .mention-suggest {
            position: absolute;
            left: 0;
            right: 0;
            bottom: calc(100% + 6px);
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            border-radius: 14px;
            max-height: 160px;
            overflow-y: auto;
            z-index: 45;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
        }

        .mention-suggest button {
            display: block;
            width: 100%;
            text-align: left;
            background: transparent;
            border: none;
            color: #f0f9ff;
            padding: 10px 14px;
            cursor: pointer;
            font-family: inherit;
            font-size: 0.8rem;
            font-weight: 700;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mention-suggest button:hover,
        .mention-suggest button.active { background: rgba(255, 255, 255, 0.12); }

        .msg-receipt {
            display: inline-block;
            margin-left: 8px;
            font-size: 0.68em;
            letter-spacing: 0.02em;
            opacity: 0.72;
            text-transform: lowercase;
            font-weight: 600;
        }

        .msg-receipt.delivered { opacity: 0.85; color: rgba(255, 255, 255, 0.85); }
        .msg-receipt.read { color: var(--eu-accent); opacity: 1; }

        .msg-poll {
            width: 100%;
            max-width: 100%;
            min-width: 0;
            margin: 4px 0;
        }

        .msg-poll-q {
            font-weight: 800;
            margin-bottom: 8px;
            font-size: 0.9rem;
            overflow-wrap: anywhere;
        }

        .msg-poll-opt {
            display: block;
            width: 100%;
            max-width: 100%;
            text-align: left;
            margin: 0 0 6px;
            padding: 8px 10px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            cursor: pointer;
            font-family: inherit;
            font-size: 0.78rem;
            font-weight: 700;
            overflow-wrap: anywhere;
            box-sizing: border-box;
        }

        .msg-poll-opt.mine {
            border-color: rgba(155, 180, 208, 0.5);
            background: rgba(155, 180, 208, 0.14);
        }

        .msg-poll-opt .poll-bar {
            display: block;
            height: 3px;
            margin-top: 6px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.15);
            overflow: hidden;
        }

        .msg-poll-opt .poll-bar > i {
            display: block;
            height: 100%;
            background: var(--eu-accent);
            width: 0;
        }

        .hi-unread {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #e85d4c;
            margin-left: 8px;
            flex-shrink: 0;
            box-shadow: 0 0 0 2px rgba(232, 93, 76, 0.25);
        }

        /* Author CSS display must not override the HTML hidden attribute */
        .hi-unread[hidden],
        .history-invites-dot[hidden] {
            display: none !important;
        }

        .msg-img {
            display: block;
            max-width: min(240px, 60vw);
            max-height: 240px;
            border-radius: 10px;
            cursor: zoom-in;
            object-fit: cover;
        }

        .msg-caption { margin-top: 6px; }

        .img-lightbox {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 99999;
            background: rgba(0, 0, 0, 0.92);
            align-items: center;
            justify-content: center;
            cursor: zoom-out;
            padding: 16px;
        }

        .img-lightbox.open { display: flex; }
        .img-lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 10px; }

        /* Tap-to-act on messages */
        .message { cursor: pointer; }
        .message.flash { box-shadow: 0 0 0 2px rgba(155, 180, 208, 0.65); }

        /* Reply quote inside a bubble */
        .reply-quote {
            border-left: 3px solid rgba(155, 180, 208, 0.55);
            background: rgba(0, 0, 0, 0.18);
            border-radius: 6px;
            padding: 4px 8px;
            margin-bottom: 6px;
            font-size: 0.72rem;
            max-width: 100%;
            overflow: hidden;
        }
        .reply-quote .rq-name {
            display: block; font-weight: 800; opacity: 0.9; margin-bottom: 2px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .reply-quote .rq-text { display: block; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

        .msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
        .msg-mention {
            color: var(--eu-accent);
            font-weight: 800;
            background: rgba(155, 180, 208, 0.12);
            border-radius: 6px;
            padding: 0 3px;
        }

        /* Reaction chips under a bubble */
        .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
        .reactions:empty { display: none; }
        .reaction-chip {
            background: rgba(0, 0, 0, 0.28);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            padding: 1px 7px;
            font-size: 0.78rem;
            line-height: 1.5;
            cursor: pointer;
        }
        .reaction-chip.mine {
            background: rgba(155, 180, 208, 0.2);
            border-color: rgba(155, 180, 208, 0.45);
        }

        /* Bottom action sheet — arcade/landlord euroglass */
        .msg-actions {
            display: none; position: fixed; inset: 0; z-index: 100000;
            background: rgba(8, 15, 35, 0.72);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            align-items: flex-end; justify-content: center;
        }
        .msg-actions.open { display: flex; }
        .msg-actions-sheet {
            width: 100%; max-width: 420px;
            color: var(--eu-text);
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            border-bottom: none;
            border-radius: 20px 20px 0 0;
            padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
            box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            animation: slideUp 0.2s ease-out;
        }
        @keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        .emoji-row { display: flex; justify-content: space-around; gap: 6px; margin-bottom: 14px; }
        .emoji-pick {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 14px;
            width: 46px; height: 46px; font-size: 1.35rem; cursor: pointer;
            transition: transform 0.15s, background 0.15s, border-color 0.15s;
        }
        .emoji-pick:hover {
            transform: scale(1.06);
            background: rgba(255, 255, 255, 0.18);
            border-color: rgba(155, 180, 208, 0.45);
        }
        .sheet-action {
            display: block; width: 100%; text-align: left;
            background: rgba(255, 255, 255, 0.1); color: #f0f9ff;
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 12px; padding: 14px; font-size: 0.88rem;
            font-family: inherit; cursor: pointer; margin-top: 8px;
            font-weight: 700;
        }
        .sheet-action:hover {
            background: rgba(255, 255, 255, 0.16);
            border-color: rgba(155, 180, 208, 0.45);
        }
        .sheet-action.danger {
            color: #fecaca;
            background: rgba(220, 38, 38, 0.22);
            border-color: rgba(248, 113, 113, 0.35);
        }
        .sheet-action.danger:hover { background: rgba(220, 38, 38, 0.35); }
        .close-chat-copy {
            margin: 0 0 6px;
            color: rgba(240, 249, 255, 0.78);
            font-size: 0.88rem;
            font-weight: 600;
            line-height: 1.4;
        }

        /* Forward / rename / poll / new-chat — arcade/landlord euroglass */
        .fwd-modal {
            display: none; position: fixed; inset: 0; z-index: 100001;
            background: rgba(8, 15, 35, 0.72);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            align-items: center; justify-content: center; padding: 16px;
        }
        .fwd-modal.open { display: flex; }
        .fwd-card {
            color: var(--eu-text);
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            border-radius: 20px; padding: 20px;
            width: min(360px, 92vw); max-height: 75vh; overflow-y: auto;
        }
        .fwd-card h3 {
            color: #fff; font-size: 0.95rem; margin-bottom: 14px; text-align: center;
            font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
        }
        .fwd-room {
            width: 100%; text-align: left;
            background: rgba(0, 0, 0, 0.28); color: #f0f9ff;
            border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px; padding: 12px;
            margin-bottom: 8px; cursor: pointer; font-family: inherit; font-size: 0.82rem;
            font-weight: 700;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .fwd-room:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(155, 180, 208, 0.4);
        }
        .fwd-empty { color: rgba(240, 249, 255, 0.55); text-align: center; padding: 14px; font-size: 0.82rem; }
        .fwd-close {
            width: 100%; margin-top: 6px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.22);
            color: #f0f9ff; cursor: pointer; font-family: inherit; padding: 11px;
            border-radius: 999px; font-weight: 700;
        }
        .fwd-close:hover {
            background: rgba(255, 255, 255, 0.16);
            border-color: rgba(155, 180, 208, 0.55);
        }

        .newchat-card {
            width: min(400px, 94vw);
            color: var(--eu-text);
            background: var(--eu-panel);
            border: 1px solid var(--eu-glass-border);
            box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
            padding: 24px 20px 14px;
            border-radius: 20px;
        }
        .newchat-card h3 {
            color: #fff;
            font-size: 1rem;
            letter-spacing: 0.04em;
            text-transform: none;
            margin-bottom: 6px;
            font-weight: 800;
        }
        .newchat-sub {
            text-align: center;
            color: rgba(240, 249, 255, 0.55);
            font-size: 0.72rem;
            margin: 0 0 18px;
            line-height: 1.45;
        }
        /* Sliding pill tabs (Chats/Invites, New modal, Create sub-tabs).
           Tab buttons must stay transparent — theme CSS used to paint a gradient
           on every <button>, which sat on top of the sliding pill. */
        .eu-tab-rail {
            position: relative;
            display: grid;
            grid-auto-flow: column;
            grid-auto-columns: 1fr;
            gap: 4px;
            margin-bottom: 16px;
            padding: 4px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.07);
            border: 1px solid rgba(255, 255, 255, 0.1);
            touch-action: none;
            user-select: none;
            -webkit-user-select: none;
            isolation: isolate;
        }
        .eu-tab-pill {
            position: absolute;
            top: 4px;
            left: 0;
            z-index: 0;
            width: 0;
            height: calc(100% - 8px);
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.18);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
            pointer-events: none;
            transition: transform 0.2s ease, width 0.2s ease;
            will-change: transform, width;
        }
        .eu-tab-rail.is-dragging .eu-tab-pill { transition: none; }
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn,
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn:hover,
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn:focus,
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn:active,
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn.active {
            position: relative;
            z-index: 1;
            appearance: none;
            -webkit-appearance: none;
            min-width: 0;
            border: none !important;
            background: transparent !important;
            background-color: transparent !important;
            background-image: none !important;
            color: rgba(232, 238, 247, 0.55) !important;
            border-radius: 10px;
            padding: 10px 6px;
            font-family: inherit;
            font-size: 0.78rem;
            font-weight: 800;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            box-shadow: none !important;
            transform: none !important;
            transition: color 0.15s ease;
        }
        body.eu-game-theme .eu-tab-rail > button.eu-tab-btn.active {
            color: #fff !important;
        }
        .create-mode-panel { display: none; }
        .create-mode-panel.active { display: block; }
        .newchat-panel { display: none; animation: newchatIn 0.18s ease; }
        .newchat-panel.active { display: block; }
        @keyframes newchatIn {
            from { opacity: 0; transform: translateY(4px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .newchat-hint {
            color: rgba(240, 249, 255, 0.55); font-size: 0.72rem; text-align: center;
            margin: 0 0 16px; line-height: 1.5;
        }
        .newchat-hero {
            text-align: center;
            padding: 4px 4px 8px;
        }
        .friend-pick-list { max-height: 42vh; overflow-y: auto; padding-right: 2px; }
        .friend-pick {
            width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between;
            gap: 10px;
            background: rgba(0, 0, 0, 0.28);
            color: #f0f9ff;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 14px; padding: 12px 14px;
            margin-bottom: 8px; cursor: pointer; font-family: inherit; font-size: 0.8rem;
            font-weight: 700;
            transition: background 0.15s ease, border-color 0.15s ease;
        }
        .friend-pick:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(155, 180, 208, 0.4);
        }
        .friend-pick.selected {
            background: rgba(155, 180, 208, 0.14);
            border-color: rgba(155, 180, 208, 0.55);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        .friend-pick.selected small { color: var(--eu-accent); }
        .friend-pick:disabled { opacity: 0.45; cursor: not-allowed; }
        .group-create-meta {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin: 0 0 10px;
            color: rgba(240, 249, 255, 0.55);
            font-size: 0.72rem;
            font-weight: 700;
        }
        .group-create-meta strong { color: var(--eu-accent); font-weight: 800; }
        .newchat-card .euroglass-input { margin-bottom: 12px; }
        .friend-pick .fp-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; overflow: hidden; }
        .friend-pick .fp-name {
            flex: 1 1 0;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: block;
        }
        .friend-pick .fp-avatar {
            width: 32px; height: 32px; border-radius: 12px; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center;
            background: rgba(74, 111, 165, 0.85);
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: none;
            font-size: 0.78rem; font-weight: 700;
            color: #fff;
        }
        .friend-pick small {
            font-size: 0.62rem; letter-spacing: 0.08em;
            color: rgba(240, 249, 255, 0.55); flex-shrink: 0;
            text-transform: uppercase; font-weight: 700;
        }
        .newchat-card .big-btn {
            margin-top: 2px;
            background: var(--eu-btn-primary);
            background-image: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: none;
            color: #fff;
            border-radius: 14px;
        }
        .newchat-card .big-btn:hover {
            background: var(--eu-btn-primary-hover);
            background-image: none;
            transform: none;
            filter: none;
            box-shadow: none;
        }
        .newchat-card .code-input {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.18);
            color: #f0f9ff;
            letter-spacing: 0.35em;
        }
        .newchat-card .code-input:focus {
            border-color: rgba(155, 180, 208, 0.55);
            box-shadow: 0 0 0 3px rgba(155, 180, 208, 0.12);
        }
        .newchat-card .code-input::placeholder { color: rgba(240, 249, 255, 0.35); }
        .newchat-card .fwd-close {
            margin-top: 8px;
        }
        .newchat-card .lobby-msg,
        .fwd-card .lobby-msg { color: #fecaca; font-weight: 600; }
        .euroglass-input {
            width: 100%;
            padding: 12px 14px;
            border-radius: 14px;
            border: 1px solid rgba(255, 255, 255, 0.18);
            background: rgba(255, 255, 255, 0.08);
            color: #f0f9ff;
            font-family: inherit;
            font-size: 0.88rem;
            font-weight: 600;
            margin-bottom: 10px;
            box-sizing: border-box;
            outline: none;
        }
        .euroglass-input::placeholder { color: rgba(240, 249, 255, 0.4); }
        .euroglass-input:focus {
            border-color: rgba(155, 180, 208, 0.55);
            box-shadow: 0 0 0 3px rgba(155, 180, 208, 0.12);
        }
        .fwd-card .big-btn.euroglass-btn,
        .big-btn.euroglass-btn {
            background: var(--eu-btn-primary);
            background-image: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: none;
            color: #fff;
            border-radius: 14px;
        }
        .fwd-card .big-btn.euroglass-btn:hover,
        .big-btn.euroglass-btn:hover {
            background: var(--eu-btn-primary-hover);
            background-image: none;
            transform: none;
            filter: none;
            box-shadow: none;
        }
        .history-head { display: none; }
        .invite-row {
            width: 100%; text-align: left; background: rgba(255,255,255,0.08); color: var(--eu-text);
            border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 12px;
            margin-bottom: 8px; cursor: pointer; font-family: inherit;
            overflow: hidden; min-width: 0;
        }
        .invite-row:hover {
            background: rgba(255, 255, 255, 0.14);
            border-color: rgba(155, 180, 208, 0.35);
        }
        .invite-row strong {
            display: block; font-size: 0.88rem; margin-bottom: 4px; font-weight: 800;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .invite-row span {
            display: block; font-size: 0.72rem; opacity: 0.65;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .history-invites-dot { margin-left: 0; }

        /* Toast */
        .toast {
            position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
            transform: translateX(-50%);
            background: #fff; color: #1a2740;
            border: 1px solid rgba(40, 70, 120, 0.12);
            padding: 10px 14px; max-width: min(92vw, 420px);
            border-radius: 12px; font-size: 0.85rem; font-weight: 700;
            z-index: 100002; text-align: left;
            overflow-wrap: anywhere;
            opacity: 0; transition: opacity 0.2s; pointer-events: none;
            box-shadow: 0 10px 28px rgba(20, 40, 80, 0.16);
            font-family: Nunito, system-ui, sans-serif;
        }
        .toast.show { opacity: 1; }

        /* Reply preview above the input */
        .reply-bar {
            display: none; align-items: center; gap: 10px;
            background: rgba(0, 0, 0, 0.28);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-left: 3px solid var(--eu-accent);
            border-radius: 12px; padding: 8px 12px; margin-bottom: 10px;
            min-width: 0;
        }
        .reply-bar-content { flex: 1; min-width: 0; overflow: hidden; }
        .reply-bar-name {
            display: block; font-size: 0.78rem; font-weight: 800; color: var(--eu-accent);
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .reply-bar-text {
            display: block; font-size: 0.82rem; color: rgba(240, 249, 255, 0.7);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .reply-bar-cancel {
            background: none; border: none; color: rgba(240, 249, 255, 0.6);
            font-size: 1.2rem; cursor: pointer; flex-shrink: 0;
        }

        /* Two-pane app layout: chat + history sidebar */
        .room-layout { display: flex; gap: 16px; align-items: stretch; min-width: 0; }
        .chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
        .chat-active { display: flex; flex-direction: column; flex: 1; min-width: 0; }
        .chat-back {
            display: none;
            flex: 0 0 auto;
            align-self: center;
            margin: 0;
            padding: 8px 12px;
            white-space: nowrap;
        }

        /* Open conversation: strip New / Back / title — ← Chats sits with the name and ✕ */
        body.chat-room-open .header h1,
        body.chat-room-open #newChatBtn,
        body.chat-room-open #backBtn {
            display: none !important;
        }
        body.chat-room-open .room-chrome.show .chat-back {
            display: inline-flex;
            align-items: center;
        }
        body.chat-room-open .header {
            margin-bottom: 14px;
        }
        body.chat-room-open .header-actions {
            flex: 1 1 100%;
            width: 100%;
            justify-content: flex-end;
        }
        body.chat-room-open .room-chrome.show {
            flex: 1 1 auto;
            max-width: 100%;
        }
        .chat-placeholder {
            flex: 1; display: flex; align-items: center; justify-content: center;
            min-height: 58vh; background: rgba(0, 0, 0, 0.2);
            border: 1px dashed rgba(255, 255, 255, 0.16); border-radius: 16px; padding: 20px;
            text-align: center;
        }
        .chat-placeholder p {
            color: rgba(240, 249, 255, 0.62);
            overflow-wrap: anywhere;
        }

        .history-col {
            width: 270px; flex-shrink: 0;
            background: rgba(0, 0, 0, 0.22);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 16px;
            padding: 12px; overflow-y: auto; overflow-x: hidden; max-height: 66vh;
            min-width: 0;
        }
        .history-head { color: #fff; font-size: 0.78rem; margin-bottom: 12px; opacity: 0.8; letter-spacing: 0.5px; }
        .history-item {
            display: flex;
            flex-direction: column;
            align-items: stretch;
            width: 100%;
            max-width: 100%;
            text-align: left;
            background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; cursor: pointer;
            font-family: inherit; color: var(--eu-text);
            overflow: hidden; min-width: 0;
            box-sizing: border-box;
        }
        .history-item:hover {
            background: rgba(255, 255, 255, 0.14);
            border-color: rgba(155, 180, 208, 0.35);
        }
        .history-item.active {
            background: rgba(255, 255, 255, 0.16);
            border-color: rgba(155, 180, 208, 0.5);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
        }
        .history-item .hi-code {
            font-size: 0.98rem; font-weight: 800;
            width: 100%;
            max-width: 100%;
            min-width: 0;
        }
        .history-item .hi-sub {
            display: block; font-size: 0.72rem; opacity: 0.65; margin-top: 4px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
            min-width: 0; max-width: 100%;
        }
        .history-empty {
            color: rgba(240, 249, 255, 0.55); font-size: 0.85rem;
            text-align: center; padding: 20px 8px; line-height: 1.6;
        }

        .newchat-or { margin: 14px 0; text-align: center; color: rgba(240, 249, 255, 0.45); font-size: 0.78rem; }

        @media (max-width: 760px) {
            .history-col { width: 100%; max-height: none; }
            .chat-col { display: none; }
            .room-layout.show-chat .history-col { display: none; }
            .room-layout.show-chat .chat-col { display: flex; }

            /* Username needs a full row on phones — New/Back used to leave ~50px for the name */
            .header {
                align-items: flex-start;
            }
            .header-actions {
                flex: 1 1 100%;
                width: 100%;
                max-width: 100%;
                flex-wrap: wrap;
                overflow: visible;
                justify-content: flex-end;
                gap: 8px;
            }
            .room-chrome,
            .room-chrome.show {
                flex: 1 1 100%;
                width: 100%;
                max-width: 100%;
                order: -1;
            }
            .room-title-wrap {
                flex: 1 1 auto;
                min-width: 0;
            }
            .room-code-chip {
                font-size: 0.95rem;
                padding: 9px 12px;
            }
            .room-rename-btn {
                width: 32px;
                height: 32px;
            }
            .history-item {
                padding: 12px 14px;
            }
            .history-item .hi-code {
                font-size: 1.05rem;
            }
            .history-item .title-label {
                font-size: 1.05rem;
            }
        }

        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        @media (max-width: 768px) {
            body.eu-game-theme {
                padding: 0;
                padding-top: env(safe-area-inset-top);
                padding-bottom: env(safe-area-inset-bottom);
            }
            .container {
                padding: 14px 12px 16px;
                border-radius: 0;
                border: none;
                box-shadow: none;
                min-height: 100dvh;
                background: transparent;
            }
            h1 { font-size: clamp(1.25rem, 4vw, 1.8rem); }
            .chat-area { height: 52vh; padding: 14px; }
            .message { max-width: 85%; font-size: 0.92rem; padding: 9px 14px; }
            #messageInput { font-size: 16px; padding: 12px 18px; }
            #sendBtn { padding: 12px 20px; font-size: 0.9rem; }
            #attachBtn { padding: 12px 14px; font-size: 1.05rem; }
        }

        @media (max-width: 480px) {
            h1 { font-size: clamp(1.1rem, 4vw, 1.4rem); }
            .pill-btn { padding: 8px 12px; font-size: 0.78rem; }
            .room-code-chip { font-size: 0.92rem; padding: 8px 11px; }
            .chat-area { height: 56vh; padding: 12px; }
            .message { max-width: 90%; font-size: 0.88rem; padding: 8px 12px; }
            .input-area { gap: 8px; }
            #messageInput { font-size: 16px; padding: 10px 14px; }
            #sendBtn { padding: 10px 16px; font-size: 0.85rem; }
            #attachBtn { padding: 10px 12px; font-size: 1rem; }
            .code-input { font-size: 1.3rem; letter-spacing: 5px; }
            .history-col { width: 100%; }
        }

html.eu-game-root,
html.eu-game-root body,
body.eu-game-theme {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-x: hidden;
}
html.eu-game-root::-webkit-scrollbar,
html.eu-game-root body::-webkit-scrollbar,
body.eu-game-theme::-webkit-scrollbar {
    width: 0 !important;
    background: transparent !important;
}
