/* ChatLord — app stylesheet (/app and /text). The admin page has its own
   admin.css; login and signup carry their styles inline. */

:root {
    --bg: #0c0a1d;
    --bg-2: #120f29;
    --surface: #18143a;
    --surface-2: #211b4a;
    --surface-3: #2a2359;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f4f2ff;
    --text-2: #c3bee3;
    --text-3: #9690bd;
    --accent: #8b7cff;
    --accent-strong: #7461f7;
    --accent-soft: rgba(139, 124, 255, 0.16);
    --accent-text: #b3a9ff;
    --mint: #4fe3c1;
    --mint-soft: rgba(79, 227, 193, 0.14);
    --gold: #ffc94d;
    --gold-soft: rgba(255, 201, 77, 0.14);
    --danger: #ff6b7a;
    --danger-soft: rgba(255, 107, 122, 0.14);
    --ok: #3ddc97;
    --r-sm: 10px;
    --r: 14px;
    --r-lg: 20px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    --bar-h: 60px;
    --side-w: 380px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

/* The hidden attribute wins over any display a class sets. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(116, 97, 247, 0.22), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(79, 227, 193, 0.10), transparent 60%),
        var(--bg);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
img { display: block; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.22); }
/* The track starts below the rounded corners of the boxes that scroll (20px
   is the largest rounding), so the thumb never pokes out of a corner. */
::-webkit-scrollbar-track { background: transparent; margin-block: 20px; }
/* Firefox has no track margin; a thin bar keeps clear of the curve. */
@supports (-moz-appearance: none) {
    * { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
}

.muted { color: var(--text-3); }
.small { font-size: 0.85rem; }

/* ── Icons ─────────────────────────────────────────────────────────────── */

.ic {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ic-xs { width: 14px; height: 14px; }
.ic-xl { width: 44px; height: 44px; stroke-width: 1.5; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn .ic { width: 18px; height: 18px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.88rem; }
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 6px 18px rgba(116, 97, 247, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(116, 97, 247, 0.5); }
.btn-ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--line-strong);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.btn-danger { color: #fff; background: #e04656; }
.btn-danger:hover { background: #ea5a69; }
.btn-danger-text { color: var(--danger); }

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn-sm { width: 36px; height: 36px; border-radius: 10px; }

.badge {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg);
}
.count-badge {
    margin-left: 2px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
}
#people-btn { width: auto; padding: 0 10px; gap: 6px; }

/* Buttons that also show their name when there is room for it. */
.icon-btn.labeled { width: auto; padding: 0 12px; gap: 8px; }
.btn-label { font-size: 0.88rem; font-weight: 600; white-space: nowrap; }

/* Related controls sit together, with a hairline between the groups. */
.bar-group { display: flex; align-items: center; gap: 2px; }
.bar-group + .bar-group { margin-left: 6px; padding-left: 8px; border-left: 1px solid var(--line); }

.seg-switch {
    display: flex;
    padding: 3px;
    margin-right: 4px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
}
.seg-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(139, 124, 255, 0.45); }
.seg-btn .ic { width: 18px; height: 18px; }

/* Hover tips (data-tip): one floating tip, placed by common.js beside the
   control and kept on screen — above it when there is no room below, shifted
   in from the sides. */
/* Kept from the old CSS tips: badges inside these controls are placed against them. */
[data-tip] { position: relative; }
#ui-tip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2000;
    max-width: 260px;
    padding: 7px 11px;
    border-radius: 9px;
    background: #2d2663;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    box-shadow: var(--shadow);
    pointer-events: none;
    animation: tip-in 0.12s ease both;
}
#ui-tip[hidden] { display: none; }
@keyframes tip-in { from { opacity: 0; } }

.chip-btn {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text-2);
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }
.chip-btn.active {
    color: #fff;
    background: var(--accent-soft);
    border-color: rgba(139, 124, 255, 0.6);
}

/* ── Screens ───────────────────────────────────────────────────────────── */

.screen { display: none; width: 100%; height: 100%; position: relative; }
.screen.active { display: flex; flex-direction: column; }

/* ── Lobby ─────────────────────────────────────────────────────────────── */

.topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 68px;
    padding: 0 clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: rgba(12, 10, 29, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: relative;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 40px; height: 36px; }
.brand-word {
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: 3px;
    white-space: nowrap;
}
.brand-gold {
    background: linear-gradient(90deg, #e9c349, #b98d1b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.admin-actions { display: flex; gap: 6px; margin-right: 6px; }

.profile-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 6px;
    padding: 4px 14px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.15s, border-color 0.15s;
}
.profile-chip:hover { background: rgba(255, 255, 255, 0.09); }
.profile-chip img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
}
.chip-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.chip-name { font-weight: 600; font-size: 0.9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-points { display: flex; align-items: center; gap: 3px; font-size: 0.78rem; color: var(--gold); }

.lobby {
    flex: 1;
    overflow-y: auto;
    padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 60px;
}
.lobby > * { max-width: 1240px; margin-left: auto; margin-right: auto; }

.lobby-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 28px;
}
.lobby-title {
    margin: 0;
    font-size: clamp(1.6rem, 3.4vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.lobby-title .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.2s ease-in-out 0.4s 1; }
@keyframes wave {
    0%, 60%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(14deg); }
    20%, 40% { transform: rotate(-8deg); }
}
.lobby-sub { margin: 6px 0 0; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.6);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}
.lobby-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.room-grid-empty {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-3);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
}

.room-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    padding: 0;
    color: inherit;
    transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s;
    animation: card-in 0.4s ease both;
}
.room-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 124, 255, 0.45);
    box-shadow: var(--shadow-lg);
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}
.room-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-2);
    overflow: hidden;
}
.room-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(12, 10, 29, 0) 40%, rgba(12, 10, 29, 0.85) 100%);
}
.room-card:hover .room-thumb-img { transform: scale(1.05); }
.room-thumb-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}
.room-thumb-text {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(79, 227, 193, 0.35), transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(139, 124, 255, 0.45), transparent 50%),
        linear-gradient(135deg, #1d1747, #2a1f63);
    display: flex;
    align-items: center;
    justify-content: center;
}
.room-thumb-text .ic { width: 56px; height: 56px; stroke-width: 1.4; color: rgba(255, 255, 255, 0.75); }
.room-tags {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 1;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: rgba(12, 10, 29, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.14);
}
.tag .ic { width: 13px; height: 13px; }
.tag-lock { color: var(--gold); }
.tag-live { margin-left: auto; color: var(--ok); }
.tag-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.room-members {
    position: absolute;
    left: 14px;
    bottom: 12px;
    z-index: 1;
    display: flex;
    align-items: center;
}
.room-members img, .room-members .avatar-fallback {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    background: var(--surface-2);
    margin-left: -8px;
}
.room-members > :first-child { margin-left: 0; }
.room-members .more {
    margin-left: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
}
/* The picture zooms on hover in a layer of its own, the darkening over it does
   not; at a fractional screen scale (125%, 150%) their bottom edges round
   differently and the picture's last, undarkened row showed as a light line.
   The body covers that edge. */
.room-body { position: relative; z-index: 1; margin-top: -2px; background: var(--surface); padding: 16px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.room-card-name { font-size: 1.08rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-3); font-size: 0.85rem; }
.device-hint { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.device-hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-hint .ic { width: 16px; height: 16px; color: var(--mint); }
.room-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.room-card.current { border-color: rgba(79, 227, 193, 0.5); }

/* ── Room screen ───────────────────────────────────────────────────────── */

#room-screen.active { display: flex; }
.room-bar {
    flex-shrink: 0;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(12, 10, 29, 0.8);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 30;
}
.room-title { min-width: 0; flex: 1; }
.room-name { font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.room-bar-actions { display: flex; align-items: center; gap: 2px; }
.points-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-right: 4px;
    border-radius: 999px;
    color: var(--gold);
    background: var(--gold-soft);
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.points-pill-lg { font-size: 0.95rem; padding: 6px 12px; }

.ws-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-3); }
.ws-connected { background: var(--ok); }
.ws-connecting, .ws-reconnecting { background: var(--gold); animation: blink 1s infinite; }
.ws-disconnected { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }

.room-main { flex: 1; min-height: 0; display: flex; position: relative; }

#room-stage {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: #07061a;
}
/* A blurred copy of the room fills the letterbox around the scaled canvas. */
#room-stage::before {
    content: '';
    position: absolute;
    inset: -40px;
    background-image: var(--room-bg, none);
    background-size: cover;
    background-position: center;
    filter: blur(30px) brightness(0.45) saturate(1.2);
}
#room-container { position: absolute; inset: 0; overflow: hidden; }
#avatars-layer {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    background-repeat: no-repeat;
    background-color: #1a1640;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}
#room-container.reposition #avatars-layer { cursor: crosshair; }
.stage-hint {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(12, 10, 29, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line-strong);
    font-size: 0.85rem;
    color: var(--text-2);
    pointer-events: none;
    transition: opacity 0.6s;
    z-index: 5;
}
.stage-hint.gone { opacity: 0; }

#room-side {
    width: var(--side-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--line);
    background: var(--bg-2);
    position: relative;
    min-height: 0;
}
/* Chat column folded away: the room gets the whole width, and the chat sits
   at the bottom centre — the composer, with the latest messages above it
   fading out towards the top so the room stays visible. */
body.side-collapsed:not(.text-only-mode) #room-side {
    /* Centred with auto margins, not a transform: a transformed box would
       trap the fixed-position people drawer inside it. */
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
    margin: 0 auto;
    width: min(640px, calc(100% - 32px));
    /* Small by default, so the room stays in view; the grip makes it taller. */
    height: var(--float-chat-h, 200px);
    max-height: calc(100% - 36px);
    background: transparent;
    border: none;
    z-index: 20;
}
body.side-collapsed:not(.text-only-mode) .chat-history {
    padding: 24px 4px 8px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 36px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 36px);
}
.float-grip { display: none; }
body.side-collapsed:not(.text-only-mode) .float-grip {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    height: 18px;
    cursor: ns-resize;
    touch-action: none;
    pointer-events: auto;
}
.float-grip span {
    width: 46px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    transition: background 0.15s, width 0.15s;
}
.float-grip:hover span, .float-grip.dragging span { background: #fff; width: 64px; }
/* The see-through part must not swallow clicks meant for the floor behind
   it; only the messages and the composer take the pointer. */
body.side-collapsed:not(.text-only-mode) #room-side,
body.side-collapsed:not(.text-only-mode) .chat-history { pointer-events: none; }
body.side-collapsed:not(.text-only-mode) .chat-history > *,
body.side-collapsed:not(.text-only-mode) .composer,
body.side-collapsed:not(.text-only-mode) .jump-latest,
body.side-collapsed:not(.text-only-mode) .retry-bar,
body.side-collapsed:not(.text-only-mode) .people-pane { pointer-events: auto; }
/* Each line gets its own dark backing so it reads over a bright room. */
body.side-collapsed:not(.text-only-mode) .msg,
body.side-collapsed:not(.text-only-mode) .sys-msg {
    background: rgba(12, 10, 29, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 14px;
    margin-top: 6px;
    padding: 6px 10px;
}
body.side-collapsed:not(.text-only-mode) .msg.grouped { margin-top: 2px; }
body.side-collapsed:not(.text-only-mode) .day-sep { display: none; }
body.side-collapsed:not(.text-only-mode) .composer {
    margin: 0;
    background: rgba(24, 20, 58, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow-lg);
}
body.side-collapsed:not(.text-only-mode) .retry-bar { margin: 0 0 8px; }
body.side-collapsed:not(.text-only-mode) .jump-latest { bottom: 64px; }
body.side-collapsed:not(.text-only-mode) .stage-hint { display: none; }

.side-pane { display: flex; flex-direction: column; min-height: 0; }
#chat-panel { flex: 1; position: relative; }

/* The people list is a drawer over the side column (or over the whole room on
   a phone); on a wide text view it becomes its own column instead. */
.people-pane {
    position: fixed;
    top: var(--bar-h);
    right: 0;
    bottom: 0;
    width: min(320px, 88vw);
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    transform: translateX(105%);
    transition: transform 0.25s ease;
    z-index: 40;
}
.people-pane.open { transform: none; }
.pane-head {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 54px;
    padding: 0 8px 0 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    flex-shrink: 0;
}
.pane-head .icon-btn { margin-left: auto; }
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 4, 15, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    /* Below the side column (z 20 while it floats), so the people drawer
       inside it stays above the dimming and can be clicked. */
    z-index: 15;
}
.drawer-backdrop.visible { opacity: 1; pointer-events: auto; }

.people-list { flex: 1; overflow-y: auto; padding: 8px; }
.person {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 12px;
    background: transparent;
    text-align: left;
    transition: background 0.15s;
}
.person:hover { background: rgba(255, 255, 255, 0.06); }
.person-info { min-width: 0; flex: 1; }
.person-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { font-size: 0.78rem; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.person.is-muted { opacity: 0.5; }
.person-you { font-size: 0.72rem; color: var(--accent-text); margin-left: 6px; font-weight: 600; }

/* Text view: no stage, the side column is the whole room. */
body.text-only-mode #room-stage { display: none; }
body.text-only-mode #room-side { width: auto; flex: 1; border-left: none; background: transparent; margin-right: 0; }
body.text-only-mode #chat-panel { max-width: 920px; width: 100%; margin: 0 auto; }
body.text-only-mode #side-toggle-btn { display: none !important; }
@media (min-width: 1100px) {
    body.text-only-mode #room-side { flex-direction: row; }
    body.text-only-mode #chat-panel { margin: 0; max-width: none; flex: 1; }
    body.text-only-mode .people-pane {
        position: static;
        transform: none;
        width: 280px;
        box-shadow: none;
        background: var(--bg-2);
        border-left: 1px solid var(--line);
    }
    body.text-only-mode #people-btn,
    body.text-only-mode #people-close-btn { display: none; }
}

/* ── Avatars on the canvas ─────────────────────────────────────────────── */

.user-entity {
    position: absolute;
    width: 120px;
    height: 200px;
    transition: left 0.5s ease-out, top 0.5s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    will-change: left, top;
    backface-visibility: hidden;
    cursor: pointer;
}
/* Your own label: a purple ring, not a purple fill — the role colours (gold
   admin, pink superadmin) stay readable on it. */
.user-entity.is-me .user-name { box-shadow: 0 0 0 2px rgba(139, 124, 255, 0.95); }
.user-avatar { width: 160px; height: 160px; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }
/* A drawn avatar: 2:3 like its drawing. A little taller than the old 160px
   pictures, which had no empty space round the figure. */
.user-avatar-kit { width: 120px; height: 180px; flex-shrink: 0; }
.user-avatar-sprite { width: 160px; height: 160px; background-size: auto 160px; background-repeat: no-repeat; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }
.avatar-boy { background-image: url('/images/avatars/avatar_boy_idle.png'); }
.avatar-girl { background-image: url('/images/avatars/avatar_girl_idle.png'); }
.avatar-boy-rocker { background-image: url('/images/avatars/avatar_boy_rocker_idle.png'); }
.avatar-girl-rocker { background-image: url('/images/avatars/avatar_girl_rocker_idle.png'); }
.user-avatar-sprite.idle { animation: sprite-blink 3.5s step-end infinite; }
.avatar-boy.walking { background-image: url('/images/avatars/avatar_boy_walk.png'); animation: sprite-walk 0.6s steps(6) infinite; }
.avatar-girl.walking { background-image: url('/images/avatars/avatar_girl_walk.png'); animation: sprite-walk 0.6s steps(6) infinite; }
.avatar-boy-rocker.walking { background-image: url('/images/avatars/avatar_boy_rocker_walk.png'); animation: sprite-walk 0.6s steps(6) infinite; }
.avatar-girl-rocker.walking { background-image: url('/images/avatars/avatar_girl_rocker_walk.png'); animation: sprite-walk 0.6s steps(6) infinite; }
@keyframes sprite-blink {
    0% { background-position: 0 0; }
    87% { background-position: -160px 0; }
    91% { background-position: 0 0; }
    100% { background-position: 0 0; }
}
@keyframes sprite-walk {
    from { background-position: 0 0; }
    to { background-position: -960px 0; }
}
.user-name {
    /* Never squeezed by the figure above it: a shrunk label cut its letters. */
    flex-shrink: 0;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    /* Dense enough for 4.5:1 whatever part of the room shows through. */
    background: rgba(12, 10, 29, 0.86);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.speech-bubble {
    position: absolute;
    bottom: 196px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 240px;
    padding: 10px 14px;
    border-radius: 16px;
    background: #fff;
    color: #1b1640;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    animation: bubble-in 0.25s ease-out;
    z-index: 10;
}
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    margin-left: -8px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #fff transparent transparent;
}
.speech-bubble.leaving { animation: bubble-out 0.3s ease-in forwards; }
@keyframes bubble-in { from { opacity: 0; transform: translate(-50%, 8px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes bubble-out { to { opacity: 0; transform: translate(-50%, -6px); } }

/* ── Avatars in lists ──────────────────────────────────────────────────── */

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-xl { width: 96px; height: 96px; }
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
}
.avatar-xl.avatar-fallback { font-size: 2.2rem; }

.role-superadmin { color: #ff8fa3; }
.role-admin { color: var(--gold); }
.role-bot { color: var(--mint); }
.role-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-2);
}
.role-tag:empty { display: none; }

/* ── Chat history ──────────────────────────────────────────────────────── */

.chat-history {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
}
/* Pushes a short history to the bottom, next to the composer. */
.chat-history::before { content: ''; flex: 1; }

.msg {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    margin-top: 10px;
    transition: background 0.15s;
}
.msg.grouped { margin-top: 0; }
.msg.grouped .msg-avatar { visibility: hidden; height: 0; }
.msg.grouped .msg-head { display: none; }
.msg:hover { background: rgba(255, 255, 255, 0.03); }
.msg.highlight { background: var(--accent-soft); }
.msg-avatar { margin-top: 2px; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.msg-name { font-weight: 700; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 0.72rem; color: var(--text-3); flex-shrink: 0; }
.msg-text { color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-text a { color: var(--mint); }
.msg.own .msg-name { color: var(--accent-text); }
.msg.bot .msg-text {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px 14px 14px 14px;
    background: var(--mint-soft);
    border: 1px solid rgba(79, 227, 193, 0.22);
}
.msg.warning .msg-text { background: var(--danger-soft); border-color: rgba(255, 107, 122, 0.3); }
.msg-reply-btn {
    position: absolute;
    top: -6px;
    right: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text-2);
}
.msg:hover .msg-reply-btn { display: flex; }
.msg-reply-btn .ic { width: 16px; height: 16px; }

.sys-msg {
    align-self: center;
    margin: 10px 0 2px;
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-3);
    font-size: 0.8rem;
    text-align: center;
    max-width: 90%;
}
.day-sep {
    align-self: center;
    margin: 18px 0 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.chat-empty {
    margin: auto;
    padding: 30px 16px;
    text-align: center;
    color: var(--text-3);
}
.chat-empty .ic { width: 40px; height: 40px; stroke-width: 1.5; margin-bottom: 8px; color: var(--accent-text); }

.reply-quote {
    display: flex;
    flex-direction: column;
    margin: 2px 0 4px;
    padding: 4px 10px;
    border-left: 3px solid var(--accent);
    border-radius: 4px 8px 8px 4px;
    background: rgba(139, 124, 255, 0.08);
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 520px;
}
.reply-quote-name { font-weight: 700; color: var(--accent-text); }
.reply-quote-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.jump-latest {
    position: absolute;
    left: 50%;
    bottom: 76px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: none;
    background: var(--accent-strong);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    z-index: 5;
}

.retry-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 12px 8px;
    padding: 8px 8px 8px 12px;
    border-radius: 12px;
    background: var(--danger-soft);
    border: 1px solid rgba(255, 107, 122, 0.3);
    color: #ffc2c8;
    font-size: 0.88rem;
}
.retry-bar span { flex: 1; }

.reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 12px;
    padding: 8px 8px 8px 12px;
    border-radius: 12px 12px 0 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: none;
}
.reply-bar-icon { color: var(--accent-text); }
.reply-bar-body { min-width: 0; flex: 1; display: flex; flex-direction: column; font-size: 0.85rem; }
.reply-bar-name { font-weight: 700; color: var(--accent-text); }
.reply-bar-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-cancel { border: none; background: none; color: var(--text-3); width: 30px; height: 30px; border-radius: 8px; }
.reply-bar-cancel:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.composer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 12px calc(12px + var(--safe-b));
    padding: 6px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: rgba(139, 124, 255, 0.6); box-shadow: 0 0 0 4px rgba(139, 124, 255, 0.12); }
.composer input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 8px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
}
.composer input::placeholder { color: var(--text-3); }
.composer input:disabled { opacity: 0.5; }
.send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    transition: transform 0.1s, opacity 0.15s;
}
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn .ic { width: 18px; height: 18px; }
.send-count { font-size: 0.75rem; font-weight: 700; margin-left: 2px; }
.reply-bar + .attach-tray, .reply-bar + .composer, .attach-tray + .composer { border-top-left-radius: 0; border-top-right-radius: 0; }

/* Attachments */
.attach-tray {
    margin: 0 12px;
    padding: 10px 12px;
    border: 1px dashed var(--line-strong);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    background: rgba(255, 255, 255, 0.03);
}
.pending-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; color: var(--text-2); margin-bottom: 8px; }
.pending-clear { border: none; background: none; color: var(--danger); font-size: 0.82rem; }
.pending-list { display: flex; gap: 8px; overflow-x: auto; }
.pending-file {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    padding: 6px;
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pending-thumb { width: 100%; height: 64px; object-fit: cover; border-radius: 6px; }
.pending-icon { height: 64px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.pending-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-size { color: var(--text-3); }
.pending-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.7rem;
}
.pending-hint { margin-top: 6px; font-size: 0.75rem; color: var(--text-3); }

.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chat-media {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    max-width: 320px;
    background: var(--surface-2);
}
.chat-attachments.multi .chat-media { width: 150px; height: 150px; }
.chat-file-image, .chat-file-video { display: block; max-width: 100%; max-height: 260px; object-fit: cover; }
.chat-attachments.multi .chat-file-image, .chat-attachments.multi .chat-file-video { width: 100%; height: 100%; max-height: none; }
.chat-play-badge {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.chat-file-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    max-width: 100%;
}
.chat-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-size { color: var(--text-3); font-size: 0.8rem; }
.chat-file-caption { overflow-wrap: anywhere; white-space: pre-wrap; }

/* ── Modals ────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 4, 15, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fade 0.15s ease;
}
.modal-overlay-light { background: rgba(5, 4, 15, 0.45); }
@keyframes fade { from { opacity: 0; } }
.modal-box {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100% - 16px);
    overflow-y: auto;
    padding: 24px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    animation: pop 0.2s ease;
}
.modal-wide { max-width: 620px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.modal-box h3 { margin: 0 0 14px; font-size: 1.2rem; font-weight: 800; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal-error, .status-line {
    margin: 10px 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    background: var(--danger-soft);
    color: #ffc2c8;
}
.status-line.status-ok { background: rgba(61, 220, 151, 0.12); color: #a8f0cf; }

.modal-box input[type="text"], .modal-box input[type="email"], .modal-box input[type="password"],
.modal-box input[type="number"], .modal-box select, #ui-dialog-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--bg-2);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-box input:focus, .modal-box select:focus, #ui-dialog-input:focus {
    border-color: rgba(139, 124, 255, 0.7);
    box-shadow: 0 0 0 4px rgba(139, 124, 255, 0.14);
}
.modal-box input:disabled { opacity: 0.6; }
.modal-box select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 19px, calc(100% - 15px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }

.seg { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span {
    display: block;
    padding: 8px 10px;
    border-radius: 9px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-2);
    cursor: pointer;
}
.seg input:checked + span { background: var(--accent-soft); color: #fff; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 4px 0 10px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--surface-3);
    transition: background 0.2s;
}
.switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent-strong); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px dashed var(--line-strong);
    color: var(--text-2);
    cursor: pointer;
}
.file-upload-label.chosen { color: var(--accent-text); border-color: rgba(139, 124, 255, 0.6); }

.dialog-box { max-width: 400px; }
.dialog-message { color: var(--text-2); margin: 0 0 14px; white-space: pre-line; }

/* Profile */
.profile-top { display: flex; gap: 22px; align-items: flex-start; }
.profile-photo-wrap { position: relative; flex-shrink: 0; }
.profile-photo-img {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    border: 3px solid rgba(139, 124, 255, 0.5);
}
.photo-upload-btn {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-strong);
    color: #fff;
    border: 3px solid var(--surface);
    cursor: pointer;
}
.photo-upload-btn .ic { width: 17px; height: 17px; }
#profile-photo { cursor: pointer; }
.avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.avatar-actions .btn .ic { width: 16px; height: 16px; }
.avatar-bg-switch { margin: 4px 0 2px; font-size: 0.9rem; color: var(--text-2); }
.profile-fields { flex: 1; min-width: 0; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.default-avatar-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text-2);
    font-size: 0.72rem;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.default-avatar-card img { width: 100%; max-width: 64px; aspect-ratio: 1; object-fit: contain; }
.default-avatar-card:hover { transform: translateY(-2px); border-color: rgba(139, 124, 255, 0.5); }
.default-avatar-card.selected { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.notif-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.notif-row .switch { margin: 0; }
.profile-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lang-switch { display: flex; gap: 6px; }
.ios-steps { padding-left: 20px; color: var(--text-2); }
.ios-steps li { margin-bottom: 6px; }

/* User card */
.user-card-box { max-width: 340px; text-align: center; padding-top: 30px; }
.user-card-box .avatar-xl { margin: 0 auto 12px; border: 3px solid rgba(139, 124, 255, 0.45); }
.user-card-close { position: absolute; top: 10px; right: 10px; }
.user-card-name { font-size: 1.25rem; font-weight: 800; margin-bottom: 6px; overflow-wrap: anywhere; }
.user-card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.user-card-actions .btn { width: 100%; }

/* Leaderboard */
.leaderboard-box { max-width: 520px; }
.leaderboard-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bg-2);
    border: 1px solid var(--line);
}
.leaderboard-row.top { background: linear-gradient(90deg, rgba(255, 201, 77, 0.12), transparent 70%); border-color: rgba(255, 201, 77, 0.25); }
.leaderboard-rank { width: 28px; text-align: center; font-weight: 800; color: var(--text-3); font-size: 1rem; }
.leaderboard-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.leaderboard-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-stat { font-size: 0.82rem; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.leaderboard-points { color: var(--gold); font-weight: 700; }
.vote-btn {
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 600;
}
.vote-btn.voted { background: var(--accent-soft); color: #fff; border-color: rgba(139, 124, 255, 0.6); }
.leaderboard-msg { padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 0.88rem; margin-bottom: 8px; }

/* ── Messages drawer ───────────────────────────────────────────────────── */

.drawer { position: fixed; inset: 0; z-index: 900; }
/* Inside the drawer the dimming sits under the sheet, whatever the shared
   backdrop rule says about the room screen. */
.drawer > .drawer-backdrop { z-index: 0; }
.drawer-sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(860px, 100%);
    display: flex;
    background: var(--bg-2);
    border-left: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.22s ease;
    z-index: 1;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 12px 0 18px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.drawer-head h3 { margin: 0; font-size: 1.15rem; font-weight: 800; flex: 1; }
.conv-col { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 12px;
    background: transparent;
    text-align: left;
    transition: background 0.15s;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.05); }
.conv-item.active { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 0.72rem; color: var(--text-3); flex-shrink: 0; }
.conv-last { font-size: 0.85rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-last { color: var(--text); font-weight: 600; }
.conv-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent-strong);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}
.conv-empty { padding: 30px 14px; text-align: center; color: var(--text-3); font-size: 0.9rem; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--ok);
    border: 2px solid var(--bg-2);
}

.thread-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-empty {
    margin: auto;
    padding: 30px;
    max-width: 300px;
    text-align: center;
    color: var(--text-3);
}
.thread-empty .ic { color: var(--accent-text); margin-bottom: 10px; }
.thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.thread-back { display: none; }
.thread-close { display: none; }
.thread-who { flex: 1; min-width: 0; }
.thread-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.thread-messages::before { content: ''; flex: 1; }
.pm {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 18px;
    background: var(--surface-2);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}
.pm.me {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 6px;
}
.pm-time { font-size: 0.68rem; color: var(--text-3); margin: 2px 6px 8px; align-self: flex-start; }
.pm-time.me { align-self: flex-end; }
.pm-note { align-self: center; font-size: 0.8rem; color: var(--text-3); margin: 8px 0; text-align: center; }
.pm-load-more { align-self: center; margin-bottom: 10px; }
#thread-composer { margin-top: 8px; }

/* ── Toasts ────────────────────────────────────────────────────────────── */

#ws-toast-container {
    position: fixed;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: calc(100% - 32px);
}
.ws-toast {
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
}
.ws-toast.show { opacity: 1; transform: none; }
.ws-toast.ok { border-left: 3px solid var(--ok); }
.ws-toast.err { border-left: 3px solid var(--danger); }
.ws-toast.info { border-left: 3px solid var(--accent); cursor: pointer; }

/* ── Quiz & bots ───────────────────────────────────────────────────────── */

#quiz-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 4, 15, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.quiz-card {
    width: 100%;
    max-width: 520px;
    padding: 24px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    animation: pop 0.2s ease;
}
.quiz-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.quiz-progress { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); flex: 1; }
.quiz-timer { padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.quiz-hide-btn { width: 32px; height: 32px; border-radius: 8px; border: none; background: rgba(255, 255, 255, 0.06); color: var(--text-2); }
.quiz-question { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }
.quiz-options { display: grid; gap: 8px; }
.quiz-option-btn {
    min-height: 48px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--bg-2);
    text-align: left;
    font-weight: 600;
    transition: border-color 0.15s, background 0.15s;
}
.quiz-option-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option-btn:disabled { opacity: 0.55; cursor: default; }
.quiz-results-table { width: 100%; border-collapse: collapse; }
.quiz-results-table th, .quiz-results-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); }
.quiz-results-table th { font-size: 0.78rem; text-transform: uppercase; color: var(--text-3); }
.quiz-pill {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 1050;
    padding: 10px 16px;
    border-radius: 999px;
    border: none;
    background: var(--accent-strong);
    color: #fff;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.bot-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 4, 15, 0.6);
}
.bot-modal-card {
    width: 100%;
    max-width: 360px;
    padding: 20px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
}
.bot-modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bot-modal-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); object-fit: contain; }
.bot-modal-name { font-weight: 700; }
.bot-modal-subtitle { font-size: 0.8rem; color: var(--mint); }
.bot-modal-close { margin-left: auto; border: none; background: none; color: var(--text-3); width: 32px; height: 32px; border-radius: 8px; }
.bot-modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.bot-modal-section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.bot-modal-body .btn { width: 100%; margin-bottom: 8px; }
.bot-modal-body .muted { text-align: center; padding: 4px 0; font-size: 0.88rem; }

/* Custom select (common.js) */
.custom-select > select.form-input { display: none; }
.custom-select { position: relative; margin-bottom: 10px; user-select: none; }
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--bg-2);
    cursor: pointer;
}
.custom-select.open .custom-select-trigger { border-color: rgba(139, 124, 255, 0.7); }
.custom-select-trigger-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-arrow { display: flex; opacity: 0.6; transition: transform 0.2s; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }
.custom-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    box-shadow: var(--shadow);
    z-index: 200;
}
.custom-select.open .custom-select-dropdown { display: block; }
.custom-select-option { padding: 10px 14px; cursor: pointer; color: var(--text-2); }
.custom-select-option:hover, .custom-select-option.selected { background: var(--accent-soft); color: #fff; }

/* Media lightbox */
#media-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
}
#media-modal.open { display: flex; }
.media-modal-body { max-width: 94vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.media-modal-image, .media-modal-video { max-width: 94vw; max-height: 82vh; border-radius: 10px; }
.media-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.1rem;
}
.media-modal-bar { display: flex; gap: 16px; align-items: center; font-size: 0.9rem; color: var(--text-2); }
.media-modal-name { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-modal-download { color: var(--accent-text); font-weight: 600; text-decoration: none; }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1199px) {
    .icon-btn.labeled .btn-label, .seg-btn .btn-label { display: none; }
    .icon-btn.labeled { width: 42px; padding: 0; }
    .seg-btn { padding: 0 9px; }
}

@media (max-width: 900px) {
    .chip-text { display: none; }
    .profile-chip { padding: 3px; }
    .admin-actions .btn span { display: none; }
    .admin-actions .btn { padding: 0 10px; }
}

@media (max-width: 760px) {
    :root { --bar-h: 56px; }
    html, body { font-size: 15px; }
    .topbar { height: 60px; gap: 8px; }
    .brand-word { display: none; }
    .topbar-actions { gap: 0; }
    .room-grid { grid-template-columns: 1fr; gap: 14px; }
    .lobby-hero { margin-bottom: 18px; }
    .lobby-filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .hide-narrow { display: none !important; }
    .room-bar .points-pill { display: none; }

    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-box {
        max-width: none;
        max-height: 92%;
        border-radius: 22px 22px 0 0;
        padding-bottom: calc(24px + var(--safe-b));
        animation: sheet-up 0.22s ease;
    }
    @keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } }
    .profile-top { flex-direction: column; align-items: center; }
    .profile-fields { width: 100%; }
    .avatar-grid { grid-template-columns: repeat(3, 1fr); }

    .drawer-sheet { width: 100%; border-left: none; }
    .conv-col { width: 100%; border-right: none; }
    .thread-col { display: none; }
    .messages-sheet.show-thread .conv-col { display: none; }
    .messages-sheet.show-thread .thread-col { display: flex; }
    .thread-back { display: inline-flex; }
    .msg-reply-btn { display: flex; top: 2px; opacity: 0.7; background: transparent; border: none; }
    .jump-latest { bottom: 72px; }
}

/* Phones zoom in on a field whose text is under 16px when it is tapped. */
@media (max-width: 720px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select { font-size: 16px; }
}

/* ── Gestures ───────────────────────────────────────────────────────────── */
.emote-bar {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 6;
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(12, 10, 29, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line-strong);
}
.emote-bar > button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.12s, background 0.12s;
}
.emote-bar > button:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px) scale(1.08); }
.emote-bar > button:active { transform: scale(0.92); }
body.text-only-mode .emote-bar, .room-text-view .emote-bar { display: none; }
/* The emoji that rises over a figure making a gesture (photos too). */
.emote-pop {
    position: absolute;
    left: 50%;
    top: -14px;
    font-size: 34px;
    line-height: 1;
    pointer-events: none;
    animation: emote-pop 1.6s ease-out forwards;
    z-index: 3;
}
@keyframes emote-pop {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
    15% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); }
    30% { transform: translate(-50%, -10px) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* ── Reports ────────────────────────────────────────────────────────────── */
.msg-report-btn {
    position: absolute;
    top: -6px;
    right: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text-2);
}
.msg-reply-btn ~ .msg-report-btn, .msg-report-btn.beside-reply { right: 44px; }
.msg:hover .msg-report-btn { display: flex; }
.msg-report-btn .ic { width: 15px; height: 15px; }
.msg-report-btn:hover { color: var(--danger); }
@media (hover: none) {
    .msg-report-btn { display: flex; top: 2px; opacity: 0.6; background: transparent; border: none; }
}

/* ── "came online" toast ────────────────────────────────────────────────── */
.ws-toast.friend { display: flex; align-items: center; gap: 10px; border-left: 3px solid var(--mint); cursor: pointer; }
.ws-toast.friend img { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); }
.ws-toast.friend b { color: var(--text); }
.ws-toast.friend .toast-cta { margin-left: 6px; color: var(--accent-text); font-weight: 700; }

/* ── Status line over a figure, and its picker ────────────────────────── */
.user-status {
    position: absolute;
    bottom: 186px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 170px;
    padding: 3px 9px;
    border-radius: 10px 10px 10px 3px;
    background: rgba(12, 10, 29, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    z-index: 4;
}
/* A speech bubble takes the same place for a moment. */
.user-entity:has(.speech-bubble) .user-status { opacity: 0; }
.emote-sep { width: 1px; align-self: stretch; margin: 6px 2px; background: var(--line-strong); }
.status-pop {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    width: 290px;
    padding: 12px;
    border-radius: 16px;
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    z-index: 20;
}
.status-pop-title { font-weight: 800; font-size: 0.9rem; margin-bottom: 8px; }
.status-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.status-preset {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}
.status-preset:hover { border-color: var(--accent); }
.status-preset[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.status-own { display: flex; gap: 6px; margin-bottom: 6px; }
.status-own input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--text); font: inherit; font-size: 0.85rem; }
.user-card-status { margin: 4px 0 2px; color: var(--text-2); font-size: 0.9rem; }

/* ── Badges and the streak ────────────────────────────────────────────── */
.badge-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0 4px; }
.badge-chip, .streak-chip {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    font-size: 1.05rem;
}
.streak-chip { font-size: 0.82rem; font-weight: 700; color: var(--gold); }
.section-label .streak-chip { height: auto; padding: 2px 8px; margin-left: 6px; text-transform: none; letter-spacing: 0; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-strong); }
.badge-tile .badge-icon { font-size: 1.5rem; }
.badge-tile b { font-size: 0.86rem; }
.badge-tile small { color: var(--text-2); font-size: 0.76rem; line-height: 1.35; }
.badge-tile.locked { background: transparent; border-style: dashed; }
.badge-tile.locked .badge-icon { filter: grayscale(1); opacity: 0.5; }
.badge-tile.locked b { color: var(--text-2); }

/* ── Games ────────────────────────────────────────────────────────────── */
.game-pick-box { max-width: 460px; }
.game-pick-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.game-pick-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 10px;
    border-radius: 16px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: center;
    transition: transform 0.12s, border-color 0.12s;
}
.game-pick-option:hover { border-color: var(--accent); transform: translateY(-2px); }
.game-pick-icon { font-size: 1.6rem; }
.game-pick-option small { color: var(--text-2); font-size: 0.78rem; }
.game-invite, .game-panel {
    position: fixed;
    right: 16px;
    bottom: calc(16px + var(--safe-b));
    z-index: 900;
    width: min(320px, calc(100vw - 32px));
    padding: 14px;
    border-radius: 18px;
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: card-in 0.25s ease both;
}
.game-invite { border-left: 3px solid var(--gold); }
.game-invite-text { font-weight: 600; margin-bottom: 10px; }
.game-invite-buttons { display: flex; gap: 8px; }
.game-invite-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold); transform-origin: left; animation: invite-timer 30s linear forwards; }
@keyframes invite-timer { to { transform: scaleX(0); } }
.game-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.game-head span { color: var(--text-2); font-size: 0.85rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-score { display: flex; justify-content: center; align-items: baseline; gap: 10px; font-size: 0.95rem; }
.game-score b { font-size: 1.6rem; }
.game-round { margin: 4px 0; text-align: center; color: var(--text-2); font-size: 0.82rem; }
.game-line { margin: 8px 0; text-align: center; color: var(--text-2); }
.game-result { margin: 10px 0; text-align: center; font-weight: 800; font-size: 1.05rem; }
.game-rps { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
.game-rps button { width: 64px; height: 64px; border-radius: 18px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 2rem; cursor: pointer; transition: transform 0.12s; }
.game-rps button:hover { transform: translateY(-3px); border-color: var(--accent); }
.game-ttt { display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(3, 72px); gap: 6px; justify-content: center; }
.game-ttt button { border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 2rem; cursor: pointer; color: var(--text); }
.game-ttt button:not(:disabled):hover { border-color: var(--accent); background: var(--accent-soft); }
.game-ttt button:disabled { cursor: default; }
.game-buttons { display: flex; justify-content: center; gap: 8px; }
/* Two figures playing each other. */
.user-entity.in-game::before {
    content: '⚔️';
    position: absolute;
    right: 6px;
    top: 34px;
    font-size: 20px;
    z-index: 3;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

/* ── The drawing board (opened from the room bar) ─────────────────────── */
/* Hung on the wall: a framed picture in room space. */
.room-board {
    position: absolute;
    left: 3%;
    top: 6%;
    width: 22%;
    aspect-ratio: 16 / 10;
    padding: 0.6%;
    border: 0;
    border-radius: 6px;
    background: linear-gradient(145deg, #8a5a33, #5f3b1f);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.12);
    cursor: pointer;
    z-index: 1;
    animation: card-in 0.35s ease both;
}
.room-board canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.room-board-label { position: absolute; right: 4%; bottom: 6%; font-size: 1.6em; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4)); }
.room-board:hover { box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.3), 0 0 0 4px var(--accent); }
.board-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 2px var(--bg);
    animation: live-dot 1.6s ease-in-out infinite;
}
@keyframes live-dot { 50% { transform: scale(1.25); } }
.board-modal { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 4, 18, 0.72); backdrop-filter: blur(6px); }
.board-modal[hidden] { display: none; }
.board-sheet { width: min(1040px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); }
.board-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.board-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
.board-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); cursor: pointer; padding: 0; }
.board-color[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 2px; }
.board-width { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); display: grid; place-items: center; cursor: pointer; }
.board-width i { display: block; border-radius: 50%; background: var(--text); }
.board-width[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.board-sep { width: 1px; height: 24px; background: var(--line-strong); margin: 0 4px; }
.board-sheet canvas { width: 100%; height: auto; aspect-ratio: 16 / 10; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 12px; background: #fbfaf6; touch-action: none; cursor: crosshair; }
.board-modal.view-only .board-tools { opacity: 0.4; pointer-events: none; }
.board-modal.view-only .board-sheet canvas { cursor: default; }
.board-note { margin: 0; text-align: center; color: var(--text-2); font-size: 0.85rem; }
