/* ============================================================
   P2P DARK CHAT — COMPLETE STYLE OVERHAUL
   Flat design with no shadows or glows
   ============================================================ */

/* Allow theme accent colors to transition smoothly */
@property --accent { syntax: '<color>'; inherits: true; initial-value: #5C6BC0; }
@property --accent-hover { syntax: '<color>'; inherits: true; initial-value: #7986CB; }

:root {
    /* Core palette */
    --bg-deep: #0f0f17;
    --bg-nav: #10101c;
    --bg-input: #141422;
    --bg-dropdown: #0e0e1c;
    --bg-card: rgba(14, 14, 28, 0.7);

    /* Accent gradient */
    --accent: #5C6BC0;
    --accent-hover: #7986CB;
    --accent-dim: rgba(92, 107, 192, 0.13);
    --gradient-accent: linear-gradient(135deg, #3F51B5, #7986CB);
    --gradient-accent-warm: linear-gradient(135deg, #3F51B5, #9FA8DA);
    --gradient-subtle: linear-gradient(135deg, rgba(92, 107, 192, 0.08), rgba(121, 134, 203, 0.05));

    /* Text */
    --text-primary: #e8e8f8;
    --text-secondary: #b0b0d0;
    --text-muted: #6a6a90;

    /* Semantic */
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;

    /* Borders & surfaces */
    --border-dim: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.03);
    --glass: rgba(14, 14, 28, 0.65);
    --glass-heavy: rgba(10, 10, 20, 0.85);
    --glass-light: rgba(255, 255, 255, 0.03);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.25, 0.8, 0.25, 1);

    /* Theme transition */
    transition: --accent 0.4s ease, --accent-hover 0.4s ease;
}

/* === BRIGHT INDIGO THEME === */
[data-theme="bright"] {
    --accent: #7986CB;
    --accent-hover: #9FA8DA;
    --accent-dim: rgba(121, 134, 203, 0.16);
    --gradient-accent: linear-gradient(135deg, #5C6BC0, #9FA8DA);
    --gradient-accent-warm: linear-gradient(135deg, #5C6BC0, #9FA8DA);
}

/* Brighter navbar in bright theme */
[data-theme="bright"] #navbar {
    background: rgba(37, 35, 66, 1.0);
}
[data-theme="bright"] #navbar::after {
    background: linear-gradient(90deg, transparent 2%, rgba(159, 168, 218, 0.55) 20%, rgba(159, 168, 218, 0.7) 50%, rgba(159, 168, 218, 0.55) 80%, transparent 98%);
}

/* Brighter input bar in bright theme */
[data-theme="bright"] #input-container {
    background: rgba(31, 29, 55, 0.98);
}
[data-theme="bright"] #input-container::before {
    background: linear-gradient(90deg, transparent 2%, rgba(159, 168, 218, 0.55) 20%, rgba(159, 168, 218, 0.7) 50%, rgba(159, 168, 218, 0.55) 80%, transparent 98%);
}

/* Theme transition: navbar and input bar backgrounds */
#navbar {
    transition: background 0.4s ease;
}
#navbar::after {
    transition: opacity 0.4s ease;
}
#input-container {
    transition: background 0.4s ease;
}
#input-container::before {
    transition: opacity 0.4s ease;
}

/* === RESET & BASE === */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

html {
    width: 100%; height: 100%;
    background: var(--bg-deep);
    overflow: hidden;
    position: fixed;
}

body {
    width: 100%; height: 100dvh;
    margin: 0; padding: 0;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex; flex-direction: column;
    position: fixed;
    touch-action: none;
    overscroll-behavior: none;
}


/* === SHARED KEYFRAMES === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes breatheText { 0%, 100% { opacity: 0.55; transform: scale(0.98); } 50% { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.015); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes menuPop { from { transform: translateY(12px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes buttonPop { 0% { transform: scale(0.9) translateY(10px); opacity: 0; } 100% { transform: scale(1) translateY(0); opacity: 1; } }
@keyframes rotate-phone { 0% { transform: rotate(-90deg); } 50% { transform: rotate(0deg); } 100% { transform: rotate(-90deg); } }
@keyframes breathe { 0%, 100% { opacity: 0.7; transform: scale(0.98); } 50% { opacity: 1; transform: scale(1); } }

.fade-out-anim { animation: fadeOut 0.3s ease forwards !important; }

/* === WAIT OVERLAY (SENDER) === */
#wait-overlay {
    display: none; position: fixed; inset: 0; z-index: 3000;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.5s ease;
    touch-action: none;
}

.wait-text {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.95rem; letter-spacing: 4px; color: #fff;
    margin-bottom: 48px; font-weight: 500; text-transform: uppercase;
    text-align: center;
    animation: breatheText 3s infinite ease-in-out;
}


/* Sleek cancel button */
.cancel-req-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    color: rgba(255, 255, 255, 0.3);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 10px 28px;
    transition: all 0.3s var(--ease-smooth);
    -webkit-user-select: none; user-select: none;
}
.cancel-req-btn:hover, .cancel-req-btn:active {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.06);
    transform: scale(1.03);
}

/* === UPDATE OVERLAY === */
#update-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 30px; touch-action: none;
    animation: fadeIn 0.5s ease;
    transition: opacity 0.4s ease;
}

.update-content-box {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; transition: opacity 0.4s ease; width: 100%;
}

.update-title-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem; font-weight: 900; letter-spacing: 6px;
    color: var(--accent);
    animation: breatheText 3s infinite ease-in-out;
    margin-bottom: 14px;
}

.update-subtitle-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem; color: var(--text-muted);
    letter-spacing: 2px; text-transform: uppercase;
    line-height: 1.8;
}

.update-reload-trigger {
    margin-top: 44px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem; color: #fff; font-weight: bold;
    letter-spacing: 3px; cursor: pointer;
    padding: 15px 40px;
    background: var(--accent);
    border: none; border-radius: var(--radius-sm);
    transition: all 0.3s var(--ease-smooth);
    -webkit-user-select: none; user-select: none;
    position: relative;
    overflow: hidden;
}
.update-reload-trigger::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
}
.update-reload-trigger:hover {
    transform: translateY(-2px);
    background: var(--accent-hover);
}
.update-reload-trigger:active {
    transform: scale(0.97) translateY(0);
}

/* === SUCCESS BANNER === */
#update-success-banner {
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    left: 0; right: 0;
    display: flex; justify-content: center;
    padding-top: 20px;
    z-index: 95;
    transform: translateY(-250px);
    opacity: 0;
    transition: transform 0.6s var(--ease-out), opacity 0.6s ease;
    pointer-events: none;
}
#update-success-banner.active { transform: translateY(0); opacity: 1; }

.success-banner-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem; font-weight: bold;
    letter-spacing: 3px; text-transform: uppercase;
    background: var(--gradient-accent);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: breatheText 3s infinite ease-in-out;
}

/* === REQUEST POPUP (RECEIVER) === */
#request-popup {
    position: fixed;
    top: -400px;
    left: 0; right: 0; margin: auto;
    width: 85%; max-width: 340px;
    background: var(--glass-heavy);
    backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(92, 107, 192, 0.15);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    z-index: 90;
    display: flex; flex-direction: column; align-items: center; gap: 28px;
    transition: top 0.6s var(--ease-out);
}

@keyframes forceBlurUpdate {
    0% { backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
    100% { backdrop-filter: blur(24.1px); -webkit-backdrop-filter: blur(24.1px); }
}
#request-popup.active {
    top: calc(75px + env(safe-area-inset-top));
    animation: forceBlurUpdate 1s infinite alternate;
}

.req-info { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }

.req-title {
    font-size: 0.8rem; color: #fff; font-weight: 700;
    text-transform: uppercase; letter-spacing: 3px;
    font-family: 'JetBrains Mono', monospace;
    text-align: center; line-height: 1.6;
}

.req-timer {
    font-size: 0.7rem; color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase; letter-spacing: 1.5px;
}

.req-icons { display: flex; gap: 64px; justify-content: center; width: 100%; align-items: center; padding: 0 20px; }

.icon-btn {
    background: transparent; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 50%;
    transition: transform 0.25s var(--ease-spring);
    -webkit-user-select: none; user-select: none;
    flex-shrink: 0;
}
.icon-btn svg { width: 34px; height: 34px; }

.btn-accept {
    color: var(--success);
    animation: breatheGreen 3s infinite ease-in-out;
}
.btn-accept svg { fill: var(--success); }

.btn-decline {
    color: var(--danger);
    animation: breatheRed 3s infinite ease-in-out;
}
.btn-decline svg { fill: var(--danger); }

@keyframes breatheGreen {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
@keyframes breatheRed {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.icon-btn:active { animation: none; transform: scale(0.88); opacity: 0.8; }

/* === UPLOAD OVERLAY === */
#upload-overlay {
    display: none; position: fixed; inset: 0; z-index: 3000;
    background-color: rgba(0, 0, 0, 0.95);
    flex-direction: column; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
    touch-action: none;
}
.upload-content { width: 80%; max-width: 320px; text-align: center; }

/* Upload icon */
.upload-content::before {
    content: '';
    display: block;
    width: 44px; height: 44px;
    margin: 0 auto 20px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: waitSpin 0.8s linear infinite;
}

.upload-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem; letter-spacing: 3px; color: rgba(255, 255, 255, 0.85);
    margin-bottom: 28px; font-weight: 600; text-transform: uppercase;
}
.progress-track {
    width: 100%; height: 3px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-full);
    overflow: hidden; position: relative;
    border: none;
}
#progress-bar {
    width: 0%; height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.15s linear;
    position: relative;
}
#progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
#progress-percent {
    margin-top: 18px;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace; font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

/* === AUDIO PLAYER (in-chat) === */
.chat-audio {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--glass);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 18px;
    width: 100%; max-width: 400px; margin-top: 8px;
    transition: border-color 0.3s;
    backdrop-filter: blur(8px);
}
.chat-audio.active-track {
    border-color: rgba(92, 107, 192, 0.4);
}
.chat-audio:hover { border-color: rgba(92, 107, 192, 0.25); }
.audio-top-row { display: flex; align-items: center; gap: 15px; width: 100%; }
.audio-bottom-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.audio-btn {
    background: var(--gradient-accent);
    border: none; border-radius: 50%; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: white;
    transition: all 0.25s var(--ease-smooth);
    flex-shrink: 0; font-size: 16px;
    -webkit-user-select: none; user-select: none;
}
.audio-btn:hover { transform: scale(1.08); }
.audio-btn:active { transform: scale(0.94); }
.audio-time { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--text-muted); letter-spacing: 0.5px; flex: 1; }

/* === SLIDER CSS === */
input[type=range].common-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 40px;
    background: transparent; cursor: pointer; outline: none;
    margin: 0; padding: 0;
    background-size: 100% 4px; background-repeat: no-repeat; background-position: center;
}
input[type=range].common-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    height: 40px; width: 40px; background: transparent; border: none; opacity: 0;
}
input[type=range].common-slider::-moz-range-thumb {
    height: 40px; width: 40px; background: transparent; border: none; opacity: 0;
}
input[type=range].common-slider::-webkit-slider-runnable-track {
    -webkit-appearance: none; background: transparent; height: 40px; border: none;
}

.chat-slider { flex: 1; display: block; }
.volume-wrapper { display: flex; align-items: center; gap: 8px; margin-left: 10px; margin-right: 10px; }
.volume-slider { width: 70px; display: block; }
.audio-expand-btn {
    background: var(--glass-light); border: 1px solid transparent; border-radius: var(--radius-sm);
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); transition: all 0.2s;
}
.audio-expand-btn:hover { color: white; background: rgba(255,255,255,0.08); border-color: var(--border-dim); }

/* === DROP OVERLAY === */
.drop-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.drop-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
.drop-overlay-content {
    display: flex; flex-direction: column; align-items: center;
    gap: 18px; padding: 50px 56px;
    border: 2px dashed rgba(92, 107, 192, 0.25);
    border-radius: var(--radius-lg);
    background: rgba(92, 107, 192, 0.03);
    text-align: center; max-width: 90%;
    animation: dropBorderPulse 2.5s infinite ease-in-out;
}
@keyframes dropBorderPulse {
    0%, 100% { border-color: rgba(92, 107, 192, 0.15); }
    50% { border-color: rgba(92, 107, 192, 0.35); }
}
.drop-overlay-icon {
    width: 52px; height: 52px; fill: var(--accent); opacity: 0.8;
    animation: float 3s ease-in-out infinite;
}
.drop-overlay-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem; font-weight: 700; letter-spacing: 4px;
    text-transform: uppercase; color: rgba(255, 255, 255, 0.9);
}
.drop-overlay-hint {
    font-size: 0.75rem; color: var(--text-muted);
    letter-spacing: 1.5px; text-transform: uppercase;
}

/* === MODALS === */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background-color: rgba(0, 0, 0, 0.95); backdrop-filter: blur(8px);
    flex-direction: column; align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    touch-action: none;
}

#modal-img, #modal-video {
    max-width: 95%; max-height: 85%; border-radius: var(--radius-md);
    object-fit: contain; cursor: default;
}
.close-corner {
    position: absolute; right: 30px;
    top: calc(20px + env(safe-area-inset-top));
    font-size: 40px; font-weight: bold; cursor: pointer; line-height: 1;
    font-family: 'JetBrains Mono', monospace;
    z-index: 2001;
    -webkit-user-select: none; user-select: none;
    color: var(--accent-hover);
    background: none;
    border: none;
    transition: all 0.2s var(--ease-smooth);
}
.close-corner:hover {
    color: #9888d8;
    transform: scale(1.1);
}

/* === AUDIO MODAL === */
#audio-modal {
    display: none; position: fixed; inset: 0; z-index: 2100;
    background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(20px);
    flex-direction: column; align-items: center; justify-content: center;
}
.am-content { width: 90%; max-width: 500px; display: flex; flex-direction: column; align-items: center; gap: 30px; position: relative; }
.am-filename-container { position: fixed; top: calc(80px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; pointer-events: none; z-index: 10; }
.am-filename {
    font-family: 'JetBrains Mono', monospace; font-size: 0.95rem; color: rgba(255, 255, 255, 0.9);
    word-break: break-all; letter-spacing: 2px; display: inline-block;
    max-width: 80%;
}
.am-breathing { animation: breathe 3s infinite ease-in-out; }
.am-player-row { display: flex; align-items: center; gap: 20px; width: 100%; }
.am-play-btn {
    width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0;
    background: var(--gradient-accent);
    border: none; color: white; font-size: 1.8rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.25s var(--ease-smooth);
    -webkit-user-select: none; user-select: none;
}
.am-play-btn:hover { transform: scale(1.06); }
.am-play-btn:active { transform: scale(0.95); }
.am-scrubber-box { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.am-timestamps { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--text-muted); }
.am-volume-box { width: 100%; display: flex; align-items: center; justify-content: center; gap: 15px; margin-top: 5px; }
.am-icon { color: var(--text-muted); font-size: 1.3rem; cursor: pointer; width: 30px; text-align: center; flex-shrink: 0; -webkit-user-select: none; }
.am-vol-slider-container { width: 100%; max-width: 200px; display: flex; align-items: center; }
#am-progress::-webkit-slider-thumb, #am-volume::-webkit-slider-thumb { margin-top: -6px; }

/* === VIDEO === */
.chat-video-wrapper {
    position: relative; max-width: min(100%, 350px); margin-top: 5px;
    border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border-dim); background: black;
    transition: border-color 0.3s;
}
.chat-video-wrapper:hover { border-color: rgba(92, 107, 192, 0.25); }
.chat-video-thumb { width: 100%; display: block; max-height: 250px; object-fit: contain; }

/* === ROTATE SHIELD === */
#rotate-shield {
    display: none; position: fixed; top: -50px; left: -50px; right: -50px; bottom: -50px;
    width: calc(100% + 100px); height: calc(100% + 100px); background: var(--bg-deep);
    z-index: 2147483647; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 20px;
}
@media screen and (orientation: landscape) and (max-height: 500px) { #rotate-shield { display: flex; } }
.shield-content { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; }
.shield-icon { width: 60px; height: 60px; fill: var(--accent); animation: rotate-phone 2s infinite ease-in-out; margin-bottom: 20px; }

/* ============================================================
   NAVBAR
   ============================================================ */
#navbar {
    box-sizing: content-box;
    height: 60px;
    flex: 0 0 60px;
    padding-top: env(safe-area-inset-top);
    padding-left: 20px;
    padding-right: 20px;
    background: rgba(29, 29, 46, 1.0);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(92, 107, 192, 0.08);
    position: relative; z-index: 100;
}
/* Subtle gradient line at bottom of navbar */
#navbar::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 2%, rgba(121, 134, 203, 0.5) 20%, rgba(121, 134, 203, 0.6) 50%, rgba(121, 134, 203, 0.5) 80%, transparent 98%);
    pointer-events: none;
}

.nav-left-wrap { position: relative; display: flex; align-items: center; z-index: 2; }

#navbar-status {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    margin-top: calc(env(safe-area-inset-top) / 2);
    font-size: 0.7rem; letter-spacing: 3px; text-transform: uppercase; font-weight: 700;
    color: var(--text-muted); pointer-events: none; white-space: nowrap; z-index: 1;
    font-family: 'JetBrains Mono', monospace;
}

.nav-controls { display: flex; align-items: center; gap: 8px; z-index: 2; }

.menu-btn, .game-btn, .nav-bg-btn {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer; padding: 10px;
    display: flex; flex-direction: column; gap: 4px; justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.3s var(--ease-smooth);
}
.menu-btn .bar {
    width: 20px; height: 2px;
    background: var(--text-secondary);
    transition: all 0.3s var(--ease-smooth);
    border-radius: var(--radius-full);
}
.menu-btn .bar:nth-child(2) { width: 16px; }
.game-btn svg, .nav-bg-btn svg { width: 22px; height: 22px; fill: var(--text-secondary); transition: all 0.3s; }

.menu-btn:hover, .game-btn:hover, .nav-bg-btn:hover {
    background: rgba(92, 107, 192, 0.08);
    border-color: rgba(92, 107, 192, 0.12);
}
.menu-btn:hover .bar { background: var(--accent); width: 20px; }
.game-btn:hover svg, .nav-bg-btn:hover svg { fill: var(--accent); }
.nav-bg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* === BACKGROUND MENU === */
.bg-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    background: rgba(24, 24, 42, 0.98);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-lg);
    z-index: 150;
    overflow: hidden;
    padding: 6px;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
    pointer-events: none;
}
.bg-menu.open {
    display: block; opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.bg-menu-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 11px 14px;
    border: none; background: none;
    color: var(--text-secondary); font-size: 0.88rem; font-family: inherit;
    text-align: left; cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s var(--ease-smooth);
    -webkit-user-select: none; user-select: none;
}
.bg-menu-item svg { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; opacity: 0.7; }
.bg-menu-item:hover { background: rgba(92, 107, 192, 0.12); color: var(--accent-hover); }
.bg-menu-item:hover svg { opacity: 1; }
.bg-menu-item:active { background: rgba(92, 107, 192, 0.18); transform: scale(0.98); }
.bg-menu-item .bg-menu-check { margin-left: auto; opacity: 0; color: var(--accent); font-weight: bold; transition: opacity 0.2s; }
.bg-menu-item.extended-on .bg-menu-check { opacity: 1; }
.bg-menu-item.tint-full-on .bg-menu-check { opacity: 1; }
.bg-menu-item.theme-on .bg-menu-check { opacity: 1; }

.bg-menu-theme-section {
    margin: 4px 0;
}
.bg-menu-theme-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    padding: 0 2px;
}
.bg-menu-theme-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.bg-menu-theme-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
.bg-menu-theme-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}
.bg-menu-theme-btn .bg-menu-check {
    margin-left: auto;
    opacity: 0;
    color: var(--accent);
}
.bg-menu-theme-btn.theme-on .bg-menu-check { opacity: 1; }

.bg-menu-theme-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.bg-menu-theme-swatch-dark {
    background: #0c0c18;
}
.bg-menu-theme-swatch-bright {
    background: linear-gradient(135deg, #5C6BC0, #9FA8DA);
}

.bg-menu-divider {
    height: 1px;
    margin: 4px 12px;
    background: rgba(255, 255, 255, 0.05);
}

.bg-menu-slider-wrap {
    margin: 8px 4px 10px 4px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.25);
    display: flex; flex-direction: column; gap: 10px;
}
.bg-menu-slider-top {
    display: flex; align-items: center; justify-content: space-between;
    font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; letter-spacing: 1.5px;
}
.bg-menu-slider-label { color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.bg-menu-slider-value { color: var(--accent); font-weight: bold; }

.bg-menu-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    outline: none; cursor: pointer;
    transition: background 0.2s;
}
.bg-menu-slider:hover { background: rgba(255, 255, 255, 0.12); }
.bg-menu-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px;
    background: var(--accent); border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), background 0.2s;
    margin-top: -6px;
}
.bg-menu-slider::-moz-range-thumb {
    width: 16px; height: 16px;
    background: var(--accent); border: none; border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), background 0.2s;
}
.bg-menu-slider:active::-webkit-slider-thumb {
    transform: scale(1.15);
    background: var(--accent-hover);
}
.bg-menu-slider:active::-moz-range-thumb {
    transform: scale(1.15);
    background: var(--accent-hover);
}
.bg-menu-slider::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: transparent; border-radius: 2px; }
.bg-menu-slider::-moz-range-track { width: 100%; height: 4px; cursor: pointer; background: transparent; border-radius: 2px; }

/* ============================================================
   GAME MENU
   ============================================================ */
#game-menu-box {
    width: min(90%, 340px); height: auto; max-height: 500px;
    background: rgba(12, 12, 24, 0.95);
    backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    overflow: hidden; padding: 8px;
    animation: menuPop 0.35s var(--ease-out);
}

.gm-header {
    padding: 14px 16px 16px 16px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 8px; flex-shrink: 0;
}
.gm-title {
    font-family: 'JetBrains Mono', monospace; font-weight: 700;
    letter-spacing: 1px; color: var(--text-muted); font-size: 0.8rem;
    text-transform: uppercase;
}
.gm-close-btn {
    cursor: pointer; color: var(--text-muted);
    font-size: 1.2rem; line-height: 1;
    transition: all 0.2s; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    -webkit-user-select: none; user-select: none;
}
.gm-close-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }

.gm-content {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
    padding-right: 4px;
}

.game-card {
    background: transparent; border: none;
    border-radius: var(--radius-md); padding: 14px 16px;
    display: flex; align-items: center; gap: 14px;
    cursor: pointer; transition: all 0.2s var(--ease-smooth);
    position: relative; overflow: hidden; min-height: 0;
    -webkit-user-select: none; user-select: none;
}
.game-card:not(.locked):hover { background: rgba(92, 107, 192, 0.08); }
.game-card:not(.locked):active { background: rgba(92, 107, 192, 0.12); transform: scale(0.98); }

.game-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); flex-shrink: 0;
    transition: all 0.25s var(--ease-smooth);
}
.game-icon svg { width: 20px; height: 20px; fill: currentColor; }
.game-card:not(.locked):hover .game-icon {
    background: var(--gradient-accent); color: white;
}

.game-info { display: flex; flex-direction: row; align-items: center; justify-content: space-between; flex: 1; }
.game-name { font-weight: 600; letter-spacing: 0.5px; font-size: 0.92rem; color: var(--text-primary); }
.game-card:not(.locked):hover .game-name { color: #fff; }
.game-card.locked { opacity: 0.4; cursor: default; }
.game-card.locked:hover { background: transparent; }
.coming-soon {
    font-size: 0.6rem; color: rgba(255, 255, 255, 0.25);
    letter-spacing: 1.5px; font-weight: 700; text-transform: uppercase;
}

/* === GAME BOARD === */
#game-board {
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
    gap: 10px; width: 300px; height: 300px; margin-bottom: 30px;
    transform: translateZ(0); will-change: opacity; transition: opacity 0.45s ease;
    padding: 12px; background: rgba(0,0,0,0.25);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(92, 107, 192, 0.08);
}
.fade-out-content { opacity: 0 !important; }
.cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 3.5rem; font-weight: bold; font-family: 'JetBrains Mono', monospace;
    cursor: pointer; user-select: none;
    transition: all 0.2s var(--ease-smooth);
    width: 100%; height: 100%; -webkit-user-select: none;
}
.cell:hover { background: rgba(255, 255, 255, 0.06); transform: scale(0.97); }
.cell:active { transform: scale(0.92); }
.cell.x {
    color: var(--accent);
    background: rgba(92, 107, 192, 0.08);
    border-color: rgba(92, 107, 192, 0.15);
}
.cell.o {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.15);
}

#game-status {
    font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; margin-bottom: 25px;
    color: var(--text-primary); text-transform: uppercase; letter-spacing: 3px;
    transform: translateZ(0); will-change: opacity; transition: opacity 0.45s ease;
    background: rgba(0,0,0,0.35); padding: 10px 20px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-dim);
}

/* === ANIMATIONS === */
.btn-animate { animation: buttonPop 0.8s var(--ease-out) forwards; }
.btn-pulse { animation: pulse 2s infinite; }
.btn-pulse.btn-enter { animation: buttonPop 0.8s var(--ease-out) forwards, pulse 2s infinite 0.8s; }
.text-pulse { animation: breatheText 2s infinite ease-in-out; }
.text-fade-in { opacity: 0; animation: fadeIn 0.5s ease forwards, breatheText 2s infinite ease-in-out 0.5s; }

/* ============================================================
   DROPDOWN / SIDEBAR
   ============================================================ */
#dropdown {
    position: absolute;
    top: calc(60px + env(safe-area-inset-top));
    right: 0; width: 340px; bottom: 0;
    background: rgba(22, 22, 38, 0.98);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border-left: 1px solid rgba(92, 107, 192, 0.08);
    padding: 40px;
    transform: translateX(100%); visibility: hidden;
    transition: transform 0.35s var(--ease-out), visibility 0s linear 0.35s;
    z-index: 99; overflow-y: auto;
    touch-action: pan-y;
}
#dropdown.active {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s var(--ease-out), visibility 0s linear 0s;
}
.menu-section { margin-bottom: 40px; }

/* Profile picture */
.profile-picture-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-picture-preview-wrap { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.profile-picture-preview,
.profile-picture-placeholder {
    width: 56px; height: 56px; border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(92, 107, 192, 0.2);
    transition: border-color 0.3s;
}
.profile-picture-preview-wrap:hover .profile-picture-preview,
.profile-picture-preview-wrap:hover .profile-picture-placeholder {
    border-color: rgba(92, 107, 192, 0.5);
}
.profile-picture-preview { display: block; }
.profile-picture-placeholder {
    display: flex; align-items: center; justify-content: center;
    background: rgba(92, 107, 192, 0.12);
    color: var(--accent); font-size: 1.25rem; font-weight: bold;
    font-family: 'JetBrains Mono', monospace;
}
.profile-picture-actions { display: flex; flex-direction: column; gap: 8px; }
.profile-picture-actions .btn { margin-top: 0; min-height: 40px; }

/* Avatar crop modal */
#avatar-crop-modal { display: none; justify-content: center; align-items: center; padding: 20px; }
#avatar-crop-modal[aria-hidden="false"] { display: flex; }
.avatar-crop-box {
    width: 100%; max-width: 360px;
    background: rgba(12, 12, 24, 0.98);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.avatar-crop-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.avatar-crop-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); letter-spacing: 0.5px; }
.avatar-crop-viewport-wrap {
    position: relative; width: 240px; height: 240px;
    margin: 0 auto 20px; border-radius: 50%; overflow: hidden;
    background: #060610;
    border: 2px solid rgba(92, 107, 192, 0.2);
    cursor: move; -webkit-user-select: none; user-select: none;
}
.avatar-crop-viewport { width: 100%; height: 100%; position: relative; overflow: hidden; border-radius: 50%; }
.avatar-crop-image { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: none; max-height: none; pointer-events: none; }
.avatar-crop-controls { margin-bottom: 20px; }
.avatar-crop-zoom-label {
    display: block; font-size: 0.7rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 10px;
    font-family: 'JetBrains Mono', monospace;
}
.avatar-crop-zoom-slider {
    width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
    background: rgba(255, 255, 255, 0.08); border-radius: var(--radius-full); outline: none;
}
.avatar-crop-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px;
    background: var(--accent); border-radius: 50%; cursor: pointer;
}
.avatar-crop-zoom-slider::-moz-range-thumb {
    width: 18px; height: 18px; background: var(--accent);
    border: none; border-radius: 50%; cursor: pointer;
}
.avatar-crop-actions { display: flex; gap: 12px; justify-content: flex-end; }
.avatar-crop-actions .btn { margin-top: 0; flex: 1; }

h3 {
    font-size: 0.65rem; text-transform: uppercase;
    color: var(--text-muted); margin: 0 0 16px 0;
    letter-spacing: 2px; font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    border-bottom: 1px solid rgba(92, 107, 192, 0.08);
    padding-bottom: 8px;
    -webkit-user-select: none; user-select: none;
}

/* === FULLSCREEN BACKGROUND (extended mode) === */
.fullscreen-bg {
    position: fixed; inset: 0; z-index: 0;
    pointer-events: none; opacity: 0;
    transition: opacity 0.3s ease;
}
.fullscreen-bg.active { opacity: 1; }
.fullscreen-bg::before {
    content: ''; position: absolute; inset: 0;
    background-image: var(--chat-bg);
    background-size: cover; background-position: center; background-repeat: no-repeat;
}
/* Tint: by default only on message area; .tint-full applies tint to full screen (navbar & input bar too) */
.fullscreen-bg::after {
    content: ''; position: absolute; inset: 0;
    background: transparent;
    pointer-events: none;
}
.fullscreen-bg.tint-full::after {
    background: rgba(0, 0, 0, var(--chat-bg-tint, 0.92));
}
#navbar.bg-extended-overlay { background: transparent; }
#navbar.bg-extended-overlay::before {
    content: ''; position: absolute; inset: 0;
    background: rgba(0, 0, 0, var(--chat-bg-ui-extra, 0.18));
    pointer-events: none; z-index: 0;
}
#navbar.bg-extended-overlay .nav-left-wrap,
#navbar.bg-extended-overlay .nav-controls { position: relative; z-index: 1; }
#navbar.bg-extended-overlay #navbar-status { z-index: 1; }
#input-container.bg-extended-overlay { background: transparent; }
#input-container.bg-extended-overlay::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(0, 0, 0, var(--chat-bg-ui-extra, 0.18));
    pointer-events: none; z-index: 0;
}
#input-container.bg-extended-overlay > * { position: relative; z-index: 1; }

/* Tint only on message area when background is extended (navbar & input bar stay untinted) */
#chat-wrapper.has-custom-bg-tint::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(0, 0, 0, var(--chat-bg-tint, 0.92));
    z-index: 1; pointer-events: none;
}
#chat-wrapper.has-custom-bg-tint > #custom-scrollbar-track,
#chat-wrapper.has-custom-bg-tint > #chat-box,
#chat-wrapper.has-custom-bg-tint > #typing-indicator {
    position: relative; z-index: 2;
}

/* ============================================================
   CHAT AREA
   ============================================================ */
#main {
    flex: 1; display: flex; flex-direction: column; position: relative;
    overflow: hidden; width: 100%; min-height: 0;
}
#chat-wrapper { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; min-height: 0; }

/* Custom chat background */
#chat-wrapper.has-custom-bg::before {
    content: ''; position: absolute; inset: 0;
    background-image: var(--chat-bg);
    background-size: cover; background-position: center; background-repeat: no-repeat;
    z-index: 0;
}
#chat-wrapper.has-custom-bg::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(0, 0, 0, var(--chat-bg-tint, 0.92));
    z-index: 1; pointer-events: none;
}
#chat-wrapper.has-custom-bg > #custom-scrollbar-track,
#chat-wrapper.has-custom-bg > #chat-box,
#chat-wrapper.has-custom-bg > #typing-indicator {
    position: relative; z-index: 2;
}

#chat-box {
    flex: 1; width: 100%; padding: 24px 30px;
    display: flex; flex-direction: column; gap: 0;
    overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none;
    overscroll-behavior: contain; height: 100%;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
#chat-box::-webkit-scrollbar { display: none; }

/* === SCROLLBAR === */
#custom-scrollbar-track {
    position: absolute; left: 8px; top: 15px; bottom: 40px;
    width: 3px; background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-full); z-index: 50;
    opacity: 0; transition: opacity 0.4s ease;
    pointer-events: none;
}
#custom-scrollbar-thumb {
    position: absolute; top: 0; left: 0; width: 100%; height: 50px;
    background: var(--gradient-accent);
    border-radius: var(--radius-full);
    cursor: pointer; pointer-events: auto;
    transition: opacity 0.2s;
}
#custom-scrollbar-thumb:hover, #custom-scrollbar-thumb.dragging {
}

/* ============================================================
   TYPING INDICATOR & INPUT
   ============================================================ */
#typing-indicator {
    height: 24px; padding: 0 30px 10px 30px;
    font-size: 0.7rem; color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase; letter-spacing: 2px;
    opacity: 0; transform: translateZ(0); -webkit-transform: translateZ(0); will-change: opacity;
    transition: opacity 0.3s ease;
    display: flex; align-items: center; gap: 8px;
    pointer-events: none; flex-shrink: 0;
}
#typing-indicator.active { opacity: 1; }
.typing-dot {
    width: 4px; height: 4px;
    background: var(--accent); border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

#input-container {
    flex: 0 0 auto;
    padding: 18px 24px;
    background: rgba(20, 20, 34, 0.98);
    backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border-top: 1px solid rgba(92, 107, 192, 0.06);
    display: flex; align-items: center; gap: 14px;
    z-index: 60;
    touch-action: none;
    position: relative;
}
/* Subtle gradient line at top of input */
#input-container::before {
    content: '';
    position: absolute;
    top: -1px; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 2%, rgba(121, 134, 203, 0.5) 20%, rgba(121, 134, 203, 0.6) 50%, rgba(121, 134, 203, 0.5) 80%, transparent 98%);
    pointer-events: none;
}

.message-input-wrap {
    flex: 1;
    display: flex; align-items: center;
    position: relative;
    background: rgba(16, 16, 28, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-xl);
    transition: all 0.3s var(--ease-smooth);
    min-height: 54px; height: 54px;
}
.message-input-wrap:focus-within {
    border-color: rgba(92, 107, 192, 0.4);
    background: rgba(16, 16, 28, 0.85);
    border: 1px solid rgba(92, 107, 192, 0.4);
    transform: translateY(-1px);
}

#message-input {
    flex: 1; width: 0; min-width: 0;
    background: transparent; border: none;
    padding: 14px 12px 14px 22px;
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-size: 0.95rem; font-family: inherit;
    resize: none; line-height: 1.5;
    height: 100%; min-height: 0; overflow: hidden;
}
#message-input::placeholder { color: var(--text-muted); opacity: 0.6; }

/* Format icon */
.format-icon-wrap {
    flex-shrink: 0; margin-right: 10px; padding: 8px;
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-user-select: none; user-select: none;
    position: relative; border-radius: 50%;
    transition: all 0.25s var(--ease-smooth);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}
.format-icon-wrap:hover {
    background: rgba(92, 107, 192, 0.12);
    color: var(--accent);
    transform: scale(1.08);
}
.format-icon-wrap.active-state {
    background: var(--gradient-accent);
    color: white; border-color: transparent;
}
.format-icon-wrap .format-icon { width: 20px; height: 20px; fill: currentColor; }
.format-icon-wrap .format-icon-code { width: 18px; height: 18px; }

/* Format dropdown */
.format-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%; transform: translateX(-50%) scale(0.92);
    min-width: 175px;
    background: rgba(12, 12, 24, 0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.03);
    z-index: 100; overflow: hidden; padding: 6px;
    opacity: 0;
    transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
    pointer-events: none;
}
.format-dropdown.open {
    display: block; opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}

.format-option {
    display: flex; align-items: center; width: 100%;
    padding: 11px 14px; border: none; background: none;
    color: var(--text-secondary); font-size: 0.88rem; font-family: inherit;
    text-align: left; cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.15s var(--ease-smooth);
    margin-bottom: 2px;
}
.format-option:last-child { margin-bottom: 0; }
.format-option:hover { background: rgba(92, 107, 192, 0.08); color: white; }
.format-option.active { background: rgba(92, 107, 192, 0.15); color: var(--accent-hover); }

.format-option-icon {
    width: 24px; font-weight: 700; font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
    margin-right: 10px; opacity: 0.7;
}
.format-option-icon.code { font-family: 'Consolas', monospace; font-size: 0.8rem; letter-spacing: -1px; }
.format-option-label { flex: 1; font-weight: 500; letter-spacing: 0.5px; }

.check-icon {
    width: 16px; height: 16px; fill: var(--accent);
    opacity: 0; transform: scale(0.5);
    transition: all 0.25s var(--ease-spring);
}
.format-option.active .check-icon { opacity: 1; transform: scale(1); }

.format-dropdown::after {
    content: ''; position: absolute;
    bottom: -6px; left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px; height: 12px;
    background: rgba(12, 12, 24, 0.95);
    border-right: 1px solid rgba(92, 107, 192, 0.12);
    border-bottom: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: 0 0 2px 0;
}

.format-option[data-format="text"] .format-option-label::before { content: none; }
.format-option[data-format="code"] .format-option-label::before { content: none; }
.format-dropdown-close { display: none; }

/* GIF button */
.input-extra-buttons {
    flex-shrink: 0; display: flex; align-items: center;
    gap: 2px; margin-right: 4px;
}
.input-extra-btn {
    width: 36px; height: 36px; padding: 0;
    border: none; background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted); border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.25s var(--ease-smooth);
    -webkit-user-select: none; user-select: none;
}
.input-extra-btn:hover {
    background: rgba(92, 107, 192, 0.12);
    color: var(--accent);
    transform: scale(1.08);
}
.input-extra-btn:active { transform: scale(0.94); }
.input-extra-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* GIF Picker */
.picker-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%; transform: translateX(-50%) scale(0.95);
    width: min(320px, calc(100vw - 32px));
    max-height: 280px;
    background: rgba(12, 12, 24, 0.98);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.03);
    z-index: 100; overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
    pointer-events: none;
    flex-direction: column;
}
.picker-popover.open {
    display: flex; opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}
.picker-popover::after {
    content: ''; position: absolute;
    bottom: -6px; left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px; height: 12px;
    background: rgba(12, 12, 24, 0.98);
    border-right: 1px solid rgba(92, 107, 192, 0.12);
    border-bottom: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: 0 0 2px 0;
}

.gif-picker { max-height: 320px; }
.gif-search-wrap {
    padding: 12px; flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.gif-search-input {
    width: 100%; padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-primary); font-size: 0.92rem; font-family: inherit;
    transition: border-color 0.2s;
}
.gif-search-input::placeholder { color: var(--text-muted); }
.gif-search-input:focus { border-color: var(--accent); outline: none; }
.gif-search-hint { display: block; margin-top: 6px; font-size: 0.65rem; color: var(--text-muted); letter-spacing: 0.5px; }
.gif-results {
    flex: 1; overflow-y: auto; padding: 10px;
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.gif-results-item {
    position: relative; border-radius: var(--radius-md);
    overflow: hidden; cursor: pointer; aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.2);
    transition: transform 0.2s var(--ease-smooth), opacity 0.2s;
}
.gif-results-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-results-item:hover { transform: scale(0.97); opacity: 0.9; }
.gif-loading, .gif-error { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.gif-error { color: var(--danger); }

/* === BUTTONS === */
.input-btn {
    background: transparent; border: none;
    color: var(--text-muted); border-radius: 50%;
    cursor: pointer; font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s var(--ease-smooth);
    height: 48px; width: 48px;
    -webkit-user-select: none; user-select: none;
}
.input-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    transform: translateY(-2px);
}
.input-btn:active { transform: scale(0.94); }
.input-btn svg { width: 22px; height: 22px; fill: currentColor; }

#attach-btn:hover {
    color: var(--accent);
    background: rgba(92, 107, 192, 0.1);
}

#send-btn {
    width: auto; padding: 0 26px; gap: 10px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(92, 107, 192, 0.15);
    border-radius: var(--radius-xl);
    position: relative; overflow: hidden;
}
#send-btn::before {
    content: '';
    position: absolute; inset: 0;
    background: var(--gradient-accent);
    opacity: 0;
    transition: opacity 0.3s;
}
#send-btn:hover {
    color: white;
    border-color: rgba(92, 107, 192, 0.4);
    transform: translateY(-2px);
}
#send-btn:hover::before { opacity: 0.15; }
#send-btn svg { width: 18px; height: 18px; position: relative; z-index: 1; }
#send-text { display: inline-block; font-size: 0.85rem; letter-spacing: 1.5px; position: relative; z-index: 1; }
#send-icon { transform: none; position: relative; z-index: 1; }

/* ============================================================
   CHAT MESSAGES
   ============================================================ */
.message {
    display: block; position: relative;
    padding-left: 52px; max-width: 100%;
    word-wrap: break-word; font-size: 0.95rem; line-height: 1.65;
    animation: slideUp 0.25s var(--ease-out);
    cursor: default;
    transition: background 0.2s;
    border-radius: var(--radius-sm);
    padding-top: 2px;
    padding-bottom: 2px;
}
.message:hover {
    background: rgba(255, 255, 255, 0.015);
}

.message-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    flex-shrink: 0; object-fit: cover;
    background: rgba(92, 107, 192, 0.15);
    position: absolute; left: 0; top: 6px;
    border: 1px solid rgba(92, 107, 192, 0.1);
    transition: border-color 0.3s;
}
.message:hover .message-avatar {
    border-color: rgba(92, 107, 192, 0.3);
}
.message-avatar-placeholder {
    width: 40px; height: 40px; border-radius: 50%;
    flex-shrink: 0;
    background: rgba(16, 16, 30, 0.9);
    border: 1px solid rgba(92, 107, 192, 0.1);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 1.1rem; font-weight: bold;
    font-family: 'JetBrains Mono', monospace;
    position: absolute; left: 0; top: 6px;
    transition: border-color 0.3s;
}
.message:hover .message-avatar-placeholder { border-color: rgba(92, 107, 192, 0.25); }
.message-avatar-empty { display: none; }

.message-body-wrap { min-width: 0; flex: 1; }
.message-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 2px; }
.message-header b {
    color: var(--accent-hover); font-size: 0.82rem;
    letter-spacing: 1px; font-family: 'JetBrains Mono', monospace;
    margin-right: 0;
}
.message.local .message-header b { color: var(--text-muted); }
.message-time {
    font-size: 0.6rem; color: #fff;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid transparent;
    opacity: 0.75;
    transition: opacity 0.2s, border-color 0.2s, background 0.2s;
}
.message:hover .message-time { opacity: 1; }

/* Show timestamp container only when a background is active */
.has-custom-bg .message-time,
.fullscreen-bg.active ~ * .message-time {
    background: rgba(8, 6, 16, 0.9);
    border-color: rgba(92, 107, 192, 0.3);
}
.has-custom-bg .message:hover .message-time,
.fullscreen-bg.active ~ * .message:hover .message-time {
    opacity: 1;
}

.message { margin-top: 0; }
.message-group-start { margin-top: 1em; }
#chat-box > .message-group-start:first-child { margin-top: 0; }
.message-continuation { margin-top: 0.08em; padding-top: 0; }
.message-continuation .message-avatar-empty { display: none; }

/* Reply */
.message-reply-wrap {
    display: flex; align-items: flex-start; gap: 8px;
    margin-top: 8px; padding-left: calc(1rem + 8px);
    position: relative;
}
.message-reply-wrap::before {
    content: ''; position: absolute;
    left: 6px; top: 15%; bottom: 20%;
    width: 2px; background: var(--gradient-accent);
    border-radius: 2px;
}
.message-reply-wrap::after {
    content: ''; position: absolute;
    left: 2px; bottom: calc(20% - 6px);
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid var(--accent);
}
.message-reply-quote {
    flex: 1; min-width: 0;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: rgba(92, 107, 192, 0.06);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: background 0.2s;
}
.message-reply-quote:hover { background: rgba(92, 107, 192, 0.1); }
.message-reply-label { display: block; font-size: 0.72rem; margin-bottom: 4px; }
.message-reply-label strong { color: var(--accent); font-weight: 600; }
.message-reply-content {
    font-size: 0.83rem; color: var(--text-secondary);
    display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.85;
}
.message-body { margin-top: 4px; }

/* Reply preview bar */
.reply-preview {
    flex-shrink: 0; display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    background: rgba(16, 16, 28, 0.95);
    border-bottom: 1px solid rgba(92, 107, 192, 0.08);
    backdrop-filter: blur(8px);
}
.reply-preview-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reply-preview-label { font-size: 0.72rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.reply-preview-label strong { color: var(--accent); }
.reply-preview-text { font-size: 0.83rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview-close {
    flex-shrink: 0; width: 32px; height: 32px;
    border: none; background: rgba(255,255,255,0.04);
    color: var(--text-muted); border-radius: 50%;
    font-size: 1.2rem; cursor: pointer;
    transition: all 0.2s; line-height: 1;
}
.reply-preview-close:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }

/* Context menu */
.message-context-menu {
    display: none; position: fixed; z-index: 200;
    min-width: 170px; padding: 6px;
    background: rgba(12, 12, 24, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(92, 107, 192, 0.12);
    border-radius: var(--radius-md);
    animation: scaleIn 0.15s var(--ease-out);
}
.message-context-menu.open { display: block; }
.msg-menu-item {
    display: block; width: 100%; padding: 10px 14px;
    border: none; background: none;
    color: var(--text-secondary); font-size: 0.88rem; font-family: inherit;
    text-align: left; cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.msg-menu-item:hover { background: rgba(92, 107, 192, 0.1); color: var(--accent-hover); }

/* Edited label on messages */
.message-edited {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 4px;
}

/* === CODE BLOCK === */
.message-code-block {
    margin-top: 6px; max-width: 100%;
    background: rgba(8, 8, 16, 0.8);
    border: 1px solid rgba(92, 107, 192, 0.08);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem; line-height: 1.55;
}
.message-code-block pre {
    margin: 0; padding: 14px 16px;
    overflow-x: auto; white-space: pre;
    color: var(--text-primary);
}
/* Syntax highlighting */
.message-code-block .hl-keyword { color: #c678dd; }
.message-code-block .hl-keyword2 { color: #c678dd; opacity: 0.9; }
.message-code-block .hl-string { color: #98c379; }
.message-code-block .hl-comment { color: #5c6370; font-style: italic; }
.message-code-block .hl-number { color: #d19a66; }
.message-code-block .hl-regex { color: #56b6c2; }
.message-code-block .hl-function { color: #61afef; }
.message-code-block .hl-operator { color: #56b6c2; }
.message-code-block .hl-punctuation { color: #abb2bf; }
.message-code-block .hl-tag { color: #e06c75; }
.message-code-block .hl-selector { color: #e5c07b; }
.message-code-block .hl-attribute { color: #d19a66; }

.chat-link {
    color: var(--accent); text-decoration: none;
    border-bottom: 1px solid rgba(92, 107, 192, 0.3);
    transition: all 0.2s; word-break: break-all;
}
.chat-link:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-hover);
}

.chat-image {
    max-width: min(100%, 350px); max-height: 350px;
    width: auto; height: auto; display: block;
    margin-top: 5px; border-radius: var(--radius-md);
    border: 1px solid var(--border-dim);
    cursor: pointer; transition: all 0.3s var(--ease-smooth);
    object-fit: contain;
}
.chat-image:hover {
    border-color: rgba(92, 107, 192, 0.25);
    transform: scale(1.01);
}

.chat-gif-inline { margin-top: 6px; }
.chat-tenor-embed {
    margin-top: 6px; max-width: min(100%, 280px);
    border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border-dim); background: #060610;
}
.chat-tenor-iframe { display: block; width: 100%; height: 200px; border: none; }

/* === LINK PREVIEWS === */
.link-preview {
    margin-top: 10px; max-width: min(100%, 360px);
    background: var(--glass);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.3s;
    backdrop-filter: blur(4px);
}
.link-preview:hover {
    border-color: rgba(92, 107, 192, 0.25);
}
.link-preview-label {
    display: block; padding: 8px 12px;
    font-size: 0.68rem; font-family: 'JetBrains Mono', monospace;
    letter-spacing: 1px; color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.15);
    transition: color 0.2s;
}
.link-preview-label:hover { color: var(--accent); }
.link-preview-iframe { display: block; width: 100%; aspect-ratio: 16/9; max-height: 220px; border: none; background: #000; }
.link-preview-image {
    width: 100%; max-height: 280px; object-fit: contain;
    display: block; cursor: pointer; transition: opacity 0.2s;
}
.link-preview-image:hover { opacity: 0.92; }
.link-preview--generic { padding: 0; }
.link-preview-generic {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s; border: none;
    background: transparent; width: 100%; text-align: left;
}
.link-preview-generic:hover { background: rgba(92, 107, 192, 0.06); }
.link-preview-generic-icon { font-size: 1.1rem; color: var(--accent); opacity: 0.9; }
.link-preview-generic-domain {
    font-family: 'JetBrains Mono', monospace; font-size: 0.83rem;
    font-weight: 600; letter-spacing: 0.5px;
    color: var(--accent-hover); flex: 1; word-break: break-all;
}
.link-preview-generic-hint {
    font-size: 0.68rem; color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.link-preview--gif-only { padding: 0; border: none; background: transparent; max-width: none; }
.link-preview--gif-only .chat-image { margin-top: 0; }
.link-preview--gif-only .chat-tenor-embed { margin-top: 0; }

/* Invite button */
.invite-btn {
    flex: 1; color: white; border: none;
    padding: 12px; border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace; font-weight: bold;
    cursor: pointer;
    background: var(--gradient-accent);
    animation: pulse 2s infinite;
    text-transform: uppercase;
    transition: transform 0.2s, opacity 0.2s;
    -webkit-user-select: none; user-select: none;
    flex-shrink: 0;
    min-width: 0;
    max-width: calc(50% - 18px);
    transform-origin: center center;
    margin: 0 6px;
    box-sizing: border-box;
    isolation: isolate;
    position: relative;
}
.invite-btn:active { transform: scale(0.98); }
.invite-btn:hover { opacity: 0.9; }
.invite-btn.decline {
    background: rgba(15, 15, 26, 0.8);
    border: 1px solid var(--accent); color: var(--accent);
}

/* ============================================================
   UI CONTROLS
   ============================================================ */
.status-pill {
    background: rgba(0, 0, 0, 0.3);
    padding: 14px; font-size: 0.88rem;
    color: var(--text-muted);
    border: 1px solid var(--border-dim);
    cursor: pointer; margin-bottom: 15px;
    display: flex; justify-content: space-between; align-items: center;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.25s var(--ease-smooth);
    word-break: break-all;
    -webkit-user-select: none; user-select: none;
}
.status-pill:hover {
    border-color: rgba(92, 107, 192, 0.2);
    background: rgba(92, 107, 192, 0.04);
}

.btn {
    width: 100%;
    background: var(--accent-dim);
    border: 1px solid rgba(92, 107, 192, 0.12);
    color: var(--accent);
    padding: 14px; cursor: pointer;
    font-weight: 700; font-size: 0.78rem;
    letter-spacing: 1.5px; text-transform: uppercase;
    transition: all 0.25s var(--ease-smooth);
    border-radius: var(--radius-md);
    min-height: 48px;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 10px;
    -webkit-user-select: none; user-select: none;
    position: relative; overflow: hidden;
}
.btn:hover {
    background: rgba(92, 107, 192, 0.2);
    border-color: rgba(92, 107, 192, 0.3);
    transform: translateY(-1px);
}
.btn:active { transform: scale(0.98) translateY(0); }

.btn-disconnect {
    background: var(--danger-dim);
    border-color: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    display: none;
}
.btn-disconnect:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.3);
}

#remote-id, #my-nickname {
    width: 100%; padding: 14px; margin-bottom: 15px;
    background: rgba(6, 6, 14, 0.6);
    border: 1px solid var(--border-dim);
    color: #fff; outline: none; box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace; font-size: 0.88rem;
    border-radius: var(--radius-md);
    transition: all 0.25s var(--ease-smooth);
}
#remote-id:focus, #my-nickname:focus {
    border-color: rgba(92, 107, 192, 0.4);
    border: 1px solid rgba(92, 107, 192, 0.4);
    background: rgba(6, 6, 14, 0.8);
}

.copy-icon { font-size: 0.65rem; color: var(--accent); font-weight: bold; letter-spacing: 1.5px; }
.dot {
    width: 6px; height: 6px;
    background: #444; display: inline-block;
    margin-right: 8px; border-radius: 50%;
    transition: all 0.3s ease;
}
.dot.active-purple {
    background: var(--accent);
}

.btn-green {
    background: var(--gradient-accent);
    border-color: transparent; color: white;
}
.btn-green:hover {
}
.btn-red {
    background: rgba(15, 15, 26, 0.8);
    border: 1px solid var(--accent); color: var(--accent);
}

/* ============================================================
   MOBILE OVERRIDES
   ============================================================ */
@media (max-width: 768px) {
    #navbar { padding-left: 15px; padding-right: 15px; }
    .nav-label { display: none; }
    #navbar-status { font-size: 0.6rem; }

    #dropdown {
        width: 100%;
        top: calc(60px + env(safe-area-inset-top));
        height: auto; bottom: 0;
        border-left: none; padding: 25px;
    }

    #chat-box { padding: 15px 18px; }

    #input-container { padding: 14px 14px; gap: 10px; }
    .message-input-wrap { min-height: 48px; height: 48px; border-radius: 24px; }
    #message-input { font-size: 16px; padding: 10px 10px 10px 18px; }
    .input-extra-buttons { margin-right: 2px; }
    .input-extra-btn { width: 32px; height: 32px; }
    .input-extra-btn svg { width: 18px; height: 18px; }
    .format-icon-wrap { margin-right: 6px; padding: 6px; }
    .format-icon-wrap .format-icon { width: 18px; height: 18px; }
    .format-icon-wrap .format-icon-code { width: 16px; height: 16px; }
    .picker-popover { max-height: 240px; width: min(300px, calc(100vw - 24px)); }
    .gif-results { grid-template-columns: repeat(2, 1fr); gap: 6px; }

    .input-btn { width: 46px; height: 46px; }
    #send-btn { padding: 0; width: 46px; min-height: 46px; height: 46px; border-radius: 50%; }
    #send-text { display: none; }

    .input-btn svg { width: 20px; height: 20px; }
    #game-board { width: 280px; height: 280px; }
    .volume-wrapper { display: none !important; }
    .am-volume-box { display: none !important; }

    /* Touch devices: prevent text selection on messages */
    #chat-box .message,
    #chat-box .message * {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* ============================================================
   FADE TRANSITION UTILITY
   ============================================================ */
.fade-transition {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
