html {
    font-size: 16px !important; 
    -webkit-text-size-adjust: 100%; 
    text-size-adjust: 100%;
}
/* 1. Importamos la fuente de iOS */
@font-face {
    font-family: 'iOS Emojis';
    src: url('fonts/AppleColorEmoji.woff2') format('woff2'); /* Quité el ./ por si Capacitor no lo resuelve bien */
    font-display: block;
    /* 🔥 LA MAGIA: Obliga a Android a usar esta fuente SOLO para estos caracteres (Emojis) 🔥 */
    unicode-range: U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F, U+2190-21FF, U+2300-23FF, U+2460-24FF, U+2500-257F, U+2580-259F, U+25A0-25FF, U+2600-26FF, U+2700-27BF, U+2800-28FF, U+2900-297F, U+2B00-2BFF, U+2C60-2C7F, U+2E00-2E7F, U+3000-303F, U+3130-318F, U+3200-32FF, U+A000-A48F, U+A490-A4CF, U+E000-F8FF, U+FE00-FE0F, U+1F000-1F02F, U+1F0A0-1F0FF, U+1F100-1F1FF, U+1F200-1F2FF, U+1F300-1F5FF, U+1F600-1F64F, U+1F680-1F6FF, U+1F700-1F77F, U+1F780-1F7FF, U+1F800-1F8FF, U+1F900-1F9FF, U+1FA00-1FA6F, U+1FA70-1FAFF;
}

* { 
    box-sizing: border-box; 
    /* 2. Ponemos 'iOS Emojis' PRIMERO. 
       Como esta fuente SOLO tiene emojis, las letras normales pasarán automáticamente 
       a usar 'system-ui' (Roboto en Android), pero los emojis quedarán como iOS. */
    font-family: 'iOS Emojis', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; 
}
body {
    margin: 0; padding: 6px;
    background: linear-gradient(135deg, #1a1f2e 0%, #2c3e50 50%, #1a1f2e 100%);
    min-height: 100vh; height: 100vh;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; box-sizing: border-box;
}
#app-container {
    width: 100%; height: 100%;
    max-width: 98vw;
    background: #fff;
    display: flex; flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(52,152,219,0.3), 0 0 30px rgba(52,152,219,0.15), 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid rgba(52,152,219,0.4);
}
.input-section {
    position: sticky; 
    bottom: 0; 
    z-index: 10;
    flex-shrink: 0; 
    padding: 10px 15px; 
    background: #ffffff; 
    /* 👇 ESTA ES LA LÍNEA QUE DIVIDE EL CHAT DEL ÁREA DE ESCRITURA 👇 */
    border-top: 1px solid #dcdde1; 
    display: flex; 
    flex-direction: column; /* Para que la barra de emotes esté arriba del texto */
    gap: 8px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
}
#chat-panels { min-height: 0; }
.chat-panel { min-height: 0; }

#btn-usuarios-float {
    display: none;
    position: fixed; right: 14px; top: 50%; transform: translateY(-50%);
    background: rgba(11, 12, 16, 0.85) !important; /* Fondo oscuro translúcido */
    color: #00e5ff !important; 
    border: 1px solid #00e5ff !important;
    border-radius: 8px 0 0 8px !important; /* Más cuadrado/moderno */
    padding: 12px 8px !important; font-size: 0.8rem !important;
    font-weight: 800 !important; cursor: pointer; z-index: 99;
    writing-mode: vertical-rl; text-orientation: mixed;
    letter-spacing: 2px !important; text-transform: uppercase;
    box-shadow: -2px 0 10px rgba(0, 229, 255, 0.2), inset 0 0 5px rgba(0, 229, 255, 0.1) !important;
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.5) !important;
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important; 
    outline: none; -webkit-tap-highlight-color: transparent;
}

/* 🔥 El destello de luz al tocar el botón 🔥 */
#btn-usuarios-float:active {
    transform: translateY(-50%) scale(0.92) !important;
    background: rgba(0, 229, 255, 0.2) !important;
    box-shadow: -4px 0 20px #00e5ff, inset 0 0 15px #00e5ff !important;
    color: #fff !important;
    text-shadow: 0 0 10px #fff !important;
}

.chat-input-field::-webkit-search-decoration,
.chat-input-field::-webkit-search-cancel-button,
.chat-input-field::-webkit-search-results-button,
.chat-input-field::-webkit-search-results-decoration {
    -webkit-appearance: none;
    display: none;
}

header { background: #2c3e50; color: white; padding: 10px 16px; display: flex; flex-direction: row; align-items: center; gap: 12px; flex-shrink: 0; }
.logo-area { display: flex; justify-content: space-between; align-items: center; }
h1 { margin: 0; font-size: 1.5rem; font-weight: 600; }

#status-badge { 
    display: none;
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 0.85rem; 
    font-weight: bold; 
}
.offline { background: #e74c3c; color: white; }
.online  { background: #2ecc71; color: white; }

#login-bar { display: flex; gap: 10px; flex-wrap: wrap; }
input { padding: 8px 12px; border: 1px solid #bdc3c7; border-radius: 4px; outline: none; font-size: 0.95rem; }
input:focus { border-color: #3498db; }
button { padding: 8px 16px; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
#btn-connect    { background: #3498db; color: white; }
#btn-connect:hover { background: #2980b9; }
#btn-disconnect { background: #e74c3c; color: white; }
#btn-disconnect:disabled, #btn-send:disabled { background: #95a5a6; cursor: not-allowed; }
#btn-send { background: #2ecc71; color: white; }

main { display: flex; flex: 1; min-height: 0; overflow: hidden; background: #fdfdfd; }
#chat-section { flex: 1; display: flex; flex-direction: column; border-right: 1px solid #ecf0f1; min-width: 0; min-height: 0; }

/* ── PESTAÑAS PC (GLASSMORPHISM) ── */
#tab-bar-container { background: #222f3e; border-bottom: 1px solid #1e272e; flex-shrink: 0; position: relative; z-index: 2; }
#tab-bar { display: flex; gap: 8px; padding: 10px 12px; overflow: hidden; flex-wrap: nowrap; }

.tab-btn {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px; padding: 6px 12px; color: #bdc3c7; cursor: pointer;
    display: flex; align-items: center; gap: 8px; font-size: 0.82rem; 
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex: 0 1 auto; min-width: 45px; max-width: 250px; overflow: hidden;
}
.tab-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; transform: translateY(-1px); }
.tab-btn.active {
    background: rgba(52, 152, 219, 0.2);
    border-color: rgba(52, 152, 219, 0.4);
    color: #5bc8ff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.tab-btn .tab-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tab-close {
    width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; font-size: 14px; background: rgba(255,255,255,0.05); 
    transition: all 0.2s; line-height: 1; flex-shrink: 0;
}
.tab-close:hover { background: #e74c3c; color: white; transform: scale(1.1); }

.msg-badge, .pm-badge {
    background: #e74c3c; color: white; padding: 2px 6px; border-radius: 10px;
    font-size: 0.75rem; font-weight: 800; box-shadow: 0 2px 5px rgba(0,0,0,0.4); line-height: 1; flex-shrink: 0;
}

/* ── MEDIA QUERIES MOVILES Y TABLETS ── */
#salas-trigger-bar { display: none; }

@media (max-width: 768px) {
    html, body { 
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        height: 100%; height: 100dvh; width: 100vw;
        padding: 0 !important; margin: 0 !important; 
        background: #2c3e50; overflow: hidden; 
    }

    #app-container {
        position: absolute; top: 0; left: 0; right: 0; bottom: 0;
        height: 100%; height: 100dvh;
        width: 100% !important; max-width: none !important;
        border-radius: 0 !important; border: none !important;
        box-shadow: none !important; display: flex; flex-direction: column;
    }

    /* 🔥 ANIQUILADOR DE BORDES: Matamos la herencia del diseño de PC 🔥 */
    main, #chat-section {
        border: none !important; /* Mata el borde derecho gris del PC */
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* Aseguramos que los contenedores de las barras no tengan márgenes ocultos */
    #tab-bar-container, #salas-trigger-bar {
        border-left: none !important;
        border-right: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    #sidebar { display: none !important; }
    #btn-usuarios-float { display: block; }

    /* El topic forzado a una sola línea, respetando los espacios del color original */
    /* El topic forzado a una sola línea alineado a la izquierda */
    /* El topic forzado a una sola línea, alineado a la izq y respetando su ancho natural */
    /* El topic forzado a una sola línea: Modo Compactación Extrema */
    /* El topic en una sola línea, balanceado y elegante como en PC */
    /* Contenedor principal: Centra el contenido incluso si es gigante */
    #topic-bar {
        display: flex !important;
        justify-content: center !important; 
        align-items: center !important;
        overflow: hidden !important;        
        padding: 4px 0 !important;            
        margin: 0 !important;
        border: none !important;
        width: 100% !important;                
        max-width: 100vw !important;
        box-sizing: border-box !important;    
    }
    
    .topic-inner {
        white-space: pre !important; 
        font-size: 14px !important; 
        display: inline-block !important; 
        transform-origin: center center !important; 
        letter-spacing: normal !important;
        text-align: center !important;
    }
    header { 
        display: flex !important; flex-direction: row !important; align-items: center !important;
        padding: 4px 10px !important; min-height: 0 !important; gap: 6px !important;
        flex-wrap: nowrap !important; border-bottom: 2px solid #34495e !important;
    }

    h1 { font-size: 0.82rem !important; white-space: nowrap !important; order: 0 !important; }

    /* El div envolvente del botón: quitamos flex:1 y lo mandamos al final */
    header > div {
        flex: 0 !important;
        margin-left: 0 !important;
        order: 2 !important;
    }

    #btn-perfil { 
    padding: 4px 10px !important; 
    font-size: 0.75rem !important; 
    border-radius: 5px !important; 
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

    #status-badge { 
    display: inline-block !important; 
    font-size: 0.7rem !important; 
    padding: 2px 7px !important; 
    border-radius: 10px !important;
    order: 1 !important;
    margin: 0 auto !important;
}

    #tab-bar { display: none; }
    
    /* Dentro de @media (max-width: 768px) */
#salas-trigger-bar {
    display: flex;
    align-items: center;
    justify-content: center;   /* <-- centrado */
    padding: 10px 14px;
    background: rgba(34, 47, 62, 0.8);
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: white; font-weight: 600; font-size: 0.85rem;
    cursor: default;           /* <-- ya no es clickable */
    pointer-events: none;      /* <-- desactiva el click */
}
/* Ocultar la flecha y el badge en trigger bar */
#salas-trigger-bar .trigger-icon,
#salas-trigger-bar #salas-count-badge { display: none !important; }
}

@media (max-width: 480px) {
    .tab-btn { padding: 5px 10px; font-size: 0.8rem; }
    .input-section { padding: 6px 8px 8px 8px !important; gap: 6px; }
    .chat-input-field { padding: 7px 10px; font-size: 0.9rem; }
    .btn-send-msg { padding: 7px 12px; }
}

/* ── BOTTOM SHEET (GLASSMORPHISM) ── */
#salas-sheet-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6); z-index: 10002; opacity: 0; transition: opacity 0.3s;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#salas-sheet-overlay.visible { display: block; opacity: 1; }

#salas-bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(26, 31, 46, 0.95); backdrop-filter: blur(25px) saturate(180%); -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px 22px 0 0; z-index: 10003;
    transform: translateY(100%); transition: transform 0.1s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-height: 78vh; min-height: 21.5vh;
    display: flex; flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6); padding-bottom: env(safe-area-inset-bottom);
}
#salas-bottom-sheet.open { transform: translateY(0); }

.sheet-header { padding: 8px 15px 6px 15px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); position: relative; flex-shrink: 0; }
.sheet-drag-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.3); border-radius: 4px; margin: 0 auto 10px auto; }
.sheet-header h3 { margin: 0 0 6px 0; color: white; font-size: 0.9rem; font-weight: 600; }
.sheet-close { position: absolute; right: 15px; top: 10px; font-size: 1.5rem; color: #bdc3c7; cursor: pointer; line-height: 1; -webkit-tap-highlight-color: transparent;}
#salas-sheet-list { overflow-y: auto; padding: 6px 9px 9px 9px; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; flex: 1; align-content: flex-start; }

.sheet-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px; color: #ecf0f1; font-size: 0.82rem; cursor: pointer; transition: all 0.2s;
    flex: 0 1 calc(50% - 3px); min-width: 0;
}
/* ── ESTADO ACTIVO EN EL BOTTOM SHEET (SALAS MÓVIL) ── */
.sheet-item.active {
    background: rgba(52, 152, 219, 0.18); /* Fondo azul sutil y translúcido */
    border: 1px solid rgba(52, 152, 219, 0.4); /* Borde celeste resaltante */
    color: #5bc8ff; /* Texto en un tono celeste más brillante */
    font-weight: 600; /* Letra un poco más gruesa */
    box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.1), 0 4px 12px rgba(0, 0, 0, 0.2); /* Brillo interno + sombra externa */
    transform: translateY(-1px); /* Efecto sutil de elevación */
}

/* Toque extra opcional: le da un ligero resplandor al nombre de la sala activa */
.sheet-item.active .sheet-item-name {
    text-shadow: 0 0 8px rgba(91, 200, 255, 0.4);
}
.sheet-item-close { 
    color: #e74c3c; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; 
    border-radius: 50%; font-size: 1.2rem; background: rgba(231, 76, 60, 0.15); transition: background 0.2s; 
}
.sheet-item-close:active { background: rgba(231, 76, 60, 0.35); }

#pm-tab-bar {
    display: none; background: #2c3e50; overflow: hidden; flex-wrap: nowrap; 
    flex-shrink: 0; padding: 8px 12px; gap: 8px; border-bottom: 1px solid #1e272e;
}
#pm-tab-bar.active-pms { display: flex; }

#chat-panels { flex: 1; min-height: 0; position: relative; }
.chat-panel { display: none; flex-direction: column; position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.chat-panel.active { display: flex; }
/* Usamos 'gap: 3px' para que la separación sea matemáticamente perfecta y no se acumule */
.chat-box { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 8px 4px; display: flex; flex-direction: column; gap: 1px; transition: opacity 0.15s ease-in-out; }
.input-section {
    position: sticky; 
    bottom: 0; 
    z-index: 10;
    flex-shrink: 0; 
    padding: 10px 15px; 
    background: #ffffff; 
    /* 👇 ANIQUILAMOS LA LÍNEA QUE DIVIDE EL CHAT 👇 */
    border-top: none !important; 
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
}
.chat-input-field { 
    flex: 1; 
    border-radius: 8px; /* Un poco más redondeado */
    -webkit-appearance: none; 
    appearance: none;
    /* 👇 14px arriba/abajo (altura) y SOLO 6px a los lados (pegadito a la izquierda) 👇 */
    padding: 14px 6px; 
    background: #f8f9fa; /* Un gris suuuuuper clarito */
    /* 👇 LA FRANJA LINDA QUE DEFINE EL CUADRO 👇 */
    border: 1px solid #ced6e0; 
    outline: none; 
    font-size: 0.95rem; 
    font-family: 'iOS Emojis', system-ui, sans-serif !important; 
}

/* 🔥 BLINDAJE TOTAL ANTI-BORDES Y SOMBRAS NATIVAS 🔥 */
.chat-input-field:focus,
.chat-input-field:active,
.chat-input-field:hover,
.chat-input-field:focus-visible,
.chat-input-field:focus-within { 
    background: #ffffff !important; 
    border: 1px solid #ced6e0 !important; /* Declaramos el borde completo con grosor, no solo el color */
    border-color: #ced6e0 !important; 
    box-shadow: none !important; 
    -webkit-box-shadow: none !important; /* Aniquila sombras forzadas por WebKit/Android */
    outline: none !important; 
    outline-width: 0 !important;
    outline-color: transparent !important; /* Mata el anillo de selección oscuro nativo */
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-tap-highlight-color: transparent !important; 
}

.chat-input-field:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-send-msg { background: #2ecc71; color: white; padding: 8px 16px; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; }
.btn-send-msg:disabled { background: #95a5a6; cursor: not-allowed; }

/* Bajamos sutilmente el line-height a 1.35 para imitar el interlineado compacto de Android */
.msg-line { line-height: 1.35; word-wrap: break-word; font-size: 1rem; }
.msg-system { color: #7f8c8d; font-style: normal; font-size: 0.9rem; margin: 0; }
.msg-plain  { color: #ff0000; font-size: 0.95rem; margin: 0; }
.msg-chat   { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; margin: 0; }
.msg-nick   { white-space: nowrap; }
.msg-nick b, .msg-nick strong { font-weight: bold; }
.msg-text b, .msg-text strong { font-weight: bold; }
.msg-nick span { color: inherit; font-weight: inherit; }
.msg-nick.pm-out { color: #7f7f7f; }
.msg-nick.pm-in  { color: #7f7f7f; }
.msg-text   { color: #0000fc; }

.pm-panel .msg-chat { flex-direction: column; gap: 1px; margin: 3px 0; align-items: flex-start; }
.pm-panel .msg-nick { display: block !important; color: #7f7f7f; font-weight: normal; font-size: 0.95rem; margin-bottom: 2px; }
.pm-panel .msg-text { display: block !important; padding-left: 14px; color: #000000; font-weight: normal; font-size: 0.95rem; }

.ares-emote { vertical-align: middle; height: 18px; margin: 0 1px; border: none; background: transparent; }

/* ── SIDEBAR (NEÓN / GAMER) ── */
#sidebar { 
    width: 280px; 
    background: #0b0c10; /* Fondo casi negro */
    display: flex; flex-direction: column; color: white; flex-shrink: 0; 
    border-left: 1px solid rgba(0, 229, 255, 0.15); 
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.8); 
}
.sidebar-header { 
    padding: 18px 20px; background: #12141a; 
    font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; color: #00e5ff;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(0, 229, 255, 0.3); 
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.1); 
    position: sticky; top: 0; z-index: 10;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}
.sidebar-header #user-count {
    background: transparent; color: #ff007f; padding: 2px 10px;
    border-radius: 4px; font-size: 0.8rem; font-weight: 800; letter-spacing: 1px;
    border: 1px solid #ff007f; 
    box-shadow: 0 0 8px rgba(255, 0, 127, 0.4), inset 0 0 5px rgba(255, 0, 127, 0.2);
    text-shadow: 0 0 5px rgba(255, 0, 127, 0.6);
}
#user-list { list-style: none; margin: 0; padding: 10px; overflow-y: auto; flex: 1; }

/* Scrollbar estilo Neón */
#user-list::-webkit-scrollbar { width: 6px; }
#user-list::-webkit-scrollbar-track { background: #0b0c10; }
#user-list::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.2); border-radius: 0px; }
#user-list::-webkit-scrollbar-thumb:hover { background: #00e5ff; box-shadow: 0 0 10px #00e5ff; }

#user-list li { 
    padding: 8px 10px; margin-bottom: 8px; border-radius: 4px; 
    display: flex; align-items: center; gap: 12px; 
    background: #12141a; border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease-in-out;
    position: relative; overflow: hidden;
}
/* Barra lateral luminosa en hover */
#user-list li::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: transparent; transition: background 0.2s, box-shadow 0.2s;
}
#user-list li:hover { 
    background: #181b22;
    border-color: rgba(0, 229, 255, 0.4);
    transform: translateX(4px); 
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.15);
}
#user-list li:hover::before {
    background: #00e5ff;
    box-shadow: 0 0 10px #00e5ff, 0 0 20px #00e5ff;
}
#user-list li:active { 
    transform: scale(0.98); 
    border-color: #ff007f; 
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.3); 
}
#user-list li:active::before { 
    background: #ff007f; 
    box-shadow: 0 0 10px #ff007f; 
}

.user-avatar { 
    width: 42px; height: 42px; border-radius: 6px; object-fit: cover; flex-shrink: 0; 
    background-color: #0b0c10; border: 1px solid rgba(0, 229, 255, 0.2);
    transition: all 0.3s;
}
#user-list li:hover .user-avatar { 
    border-color: #00e5ff; 
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}
.user-avatar-placeholder { 
    display: flex; align-items: center; justify-content: center; 
    font-size: 18px; font-weight: bold; color: #00e5ff; 
    background: #12141a; border-radius: 6px; border: 1px solid rgba(0, 229, 255, 0.2);
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.5);
}
.user-info  { display: flex; flex-direction: column; flex: 1; overflow: hidden; justify-content: center; }
.user-name  { font-size: 0.95rem; font-weight: 600; text-shadow: 1px 1px 2px rgba(0,0,0,0.8); }
.user-pm    { font-size: 0.78rem; color: #a0aec0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; display: block; font-style: normal; }

/* ── PANEL MÓVIL (NEÓN / GAMER MODERNIZADO) ── */
#panel-usuarios-mobile {
    display: none; position: fixed; top: 0; right: 0; bottom: 0;
    width: 75vw; max-width: 280px; 
    background: rgba(11, 12, 16, 0.92); 
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); 
    z-index: 600; flex-direction: column; 
    border-left: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.9), -2px 0 15px rgba(0, 229, 255, 0.15); 
    /* 🔥 Protección Anti-Lag (Aceleración por Hardware) 🔥 */
    will-change: transform; -webkit-transform: translateZ(0); transform: translateZ(0); contain: strict; 
}
#panel-usuarios-mobile.open { 
    display: flex; z-index: 601; 
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.mobile-header {
    background: #12141a !important; 
    border-bottom: 1px solid rgba(0, 229, 255, 0.3) !important;
    padding: 12px 16px !important; display: flex !important; justify-content: space-between !important; align-items: center !important;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.1) !important;
    color: #00e5ff; text-transform: uppercase; letter-spacing: 1px; font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.5);
}
.mobile-count-pill {
    background: transparent; color: #ff007f; padding: 2px 8px; border-radius: 4px; 
    font-size: 0.75rem; font-weight: 800; border: 1px solid #ff007f;
    box-shadow: 0 0 8px rgba(255, 0, 127, 0.4);
    text-shadow: 0 0 5px rgba(255, 0, 127, 0.6);
}
.mobile-close-btn {
    cursor: pointer; font-size: 24px; color: #00e5ff; line-height: 1; width: 28px; height: 28px; 
    display: flex; align-items: center; justify-content: center;
    background: transparent; border-radius: 4px; transition: all 0.2s; border: 1px solid transparent;
}
.mobile-close-btn:active { 
    border-color: #ff007f; color: #ff007f;
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.4); 
}
#user-list-mobile { 
    list-style: none; margin: 0; padding: 10px; 
    overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; 
}

#user-list-mobile li {
    padding: 10px !important; margin-bottom: 0 !important; border-bottom: none !important; 
    border-radius: 6px !important; 
    background: rgba(18, 20, 26, 0.8) !important; 
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    display: flex !important; align-items: center !important; gap: 10px !important; 
    position: relative; overflow: hidden;
    
    /* 🔥 LA SOLUCIÓN AL APLASTAMIENTO 🔥 */
    flex-shrink: 0 !important; 
    min-height: 58px !important; 
}
#user-list-mobile li::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: transparent; transition: background 0.2s;
}
/* 🔥 ESTADOS DE TOQUE MÓVIL REFINADOS (SIN FUGA DE LUZ) 🔥 */
#user-list-mobile li:active { 
    transform: scale(0.97) !important; 
    border-color: rgba(0, 229, 255, 0.4) !important; 
    background: rgba(30, 35, 45, 0.95) !important; 
    box-shadow: none !important; /* Apagamos el neón exterior */
}

#user-list-mobile li:active::before {
    background: rgba(0, 229, 255, 0.8);
    box-shadow: none !important; /* Apagamos el neón de la rayita */
}

/* 👇 Esta es la que NO debemos perder para que no se aplasten 👇 */
#user-list-mobile .user-avatar, #user-list-mobile .user-avatar-placeholder { 
    width: 38px !important; height: 38px !important; 
    border-radius: 8px !important; font-size: 14px !important; 
    border: 1px solid rgba(0, 229, 255, 0.2) !important; background: #0b0c10 !important;
    color: #00e5ff !important; 
    flex-shrink: 0 !important; /* El avatar tampoco se aplasta */
    object-fit: cover !important;
}

#user-list-mobile li:active .user-avatar, #user-list-mobile li:active .user-avatar-placeholder {
    border-color: rgba(0, 229, 255, 0.5) !important;
    box-shadow: none !important; /* Apagamos el neón del avatar */
}

#user-list-mobile span { font-size: 0.88rem !important; line-height: 1.2 !important; } 
#user-list-mobile .user-pm { font-size: 0.72rem !important; margin-top: 3px !important; line-height: 1.3 !important; }

/* 🔥 Limitador Anti-Lag para GIFs dentro de Mensajes Personales 🔥 */
#user-list-mobile .user-pm img, 
#user-list-mobile .user-name img {
    max-height: 18px !important; 
    max-width: 40px !important;
    width: auto !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

/* ── LOBBY ── */
#lobby-inner { display: flex; flex-direction: column; height: 100%; background: #1e272e; }
#lobby-toolbar { padding: 10px 16px 10px 4px; background: #222f3e; display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
#lobby-search { flex: 1; padding: 7px 12px; border-radius: 6px; border: 1px solid #3d4a56; background: #2f3640; color: #ecf0f1; font-size: 0.9rem; outline: none; }
#lobby-search:focus { border-color: #3498db; }
#lobby-count { color: #bdc3c7; font-size: 0.85rem; white-space: nowrap; }
#lobby-refresh { background: #3498db; color: white; border: none; border-radius: 5px; padding: 6px 12px; cursor: pointer; font-weight: bold; }
#lobby-refresh:hover { background: #2980b9; }
#lobby-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 16px 16px 16px 4px; align-content: start; }
.lobby-card {
    background: linear-gradient(180deg, #303b47 0%, #26313c 100%);
    border: 1px solid rgba(255,255,255,0.055);
    border-radius: 0;
    padding: 8px 6px 9px;
    box-shadow:
        0 6px 18px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.035);
}
.lobby-card:hover {
    border-color: rgba(82, 178, 255, 0.22);
    box-shadow:
        0 10px 24px rgba(0,0,0,0.22),
        inset 0 1px 0 rgba(255,255,255,0.045);
}
.lobby-card-name { font-size: 0.95rem; font-weight: 700; color: #ecf0f1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.lobby-card-topic {
    font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
    font-size: 0.83rem;
    font-weight: 600;
    letter-spacing: 0.08px;
    line-height: 1.55;

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;

    margin-top: 6px;
    padding: 2px 2px 3px;

    color: #d8e3ec;

    background: transparent;
    border: none;
    box-shadow: none;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.lobby-card-meta {
    margin-top: 5px;
    font-size: 0.73rem;
    color: #6f7d86;
    line-height: 1.2;
}

/* ── MENÚ CONTEXTUAL ── */
#user-context-menu {
    display: none; position: fixed;
    background: rgba(8, 12, 22, 0.82); backdrop-filter: blur(28px) saturate(170%); -webkit-backdrop-filter: blur(28px) saturate(170%);
    border: 1px solid rgba(255,255,255,0.09); border-radius: 18px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(52,152,219,0.12), inset 0 1px 0 rgba(255,255,255,0.07);
    z-index: 10001; flex-direction: column; width: 256px; max-width: 92vw;
    animation: ctx-pop 0.26s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes ctx-pop { from { opacity:0; transform:scale(0.86) translateY(12px); } to { opacity:1; transform:scale(1) translateY(0); } }
#ctx-header { position: relative; width: 100%; overflow: hidden; border-top-left-radius: 18px; border-top-right-radius: 18px; }
#ctx-avatar { 
    width: 100%; 
    height: auto; 
    min-height: 140px; 
    max-height: 260px; /* Subí un poco el alto para aprovechar más la foto */
    object-fit: contain; /* <-- LA MAGIA: Obliga a encajar la foto completa sin recortar */
    background-color: rgba(8, 12, 22, 0.95); /* Fondo oscuro por si quedan espacios a los lados */
    display: none; 
    cursor: default; 
    position: relative; 
    z-index: 2; 
}
#ctx-header-overlay { position: absolute; bottom:0; left:0; right:0; height: 95px; background: linear-gradient(to top, rgba(8,12,22,0.97) 0%, transparent 100%); pointer-events: none; z-index: 3; }
#ctx-header-info { position: absolute; bottom: 11px; left: 14px; right: 14px; z-index: 4; pointer-events: none; }
#ctx-nick { color: #fff; font-weight: 700; font-size: 1.0rem; text-shadow: 0 2px 10px rgba(0,0,0,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ctx-pmsg { color: rgba(190,210,235,0.8); font-size: 0.76rem; font-style: italic; margin-top: 3px; line-height: 1.35; text-shadow: 0 1px 5px rgba(0,0,0,0.9); word-wrap: break-word; }
#ctx-level-badge { position: absolute; top: 11px; right: 11px; padding: 3px 10px; border-radius: 20px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; backdrop-filter: blur(10px); display: none; }
#ctx-actions { padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.ctx-action-btn {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: none; border-radius: 10px;
    background: transparent; color: rgba(215,228,248,0.88); font-size: 0.87rem; font-weight: 500; cursor: pointer;
    text-align: left; width: 100%; transition: background 0.15s, transform 0.1s, color 0.15s;
    font-family: 'Segoe UI', system-ui, sans-serif; letter-spacing: 0.15px;
}
.ctx-action-btn:hover { background: rgba(255,255,255,0.07); transform: translateX(3px); }
.ctx-action-btn:active { transform: scale(0.97); background: rgba(255,255,255,0.04); }
.ctx-action-btn .ctx-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; transition: transform 0.15s; }
.ctx-action-btn:hover .ctx-icon { transform: scale(1.12); }
.ctx-btn-pm    .ctx-icon { background: rgba(52,152,219,0.22); }
.ctx-btn-copy  .ctx-icon { background: rgba(149,165,166,0.18); }
.ctx-btn-ignore .ctx-icon { background: rgba(243,156,18,0.2); }
.ctx-btn-kick  .ctx-icon { background: rgba(211,84,0,0.22); }
.ctx-btn-ban   .ctx-icon { background: rgba(192,57,43,0.22); }
.ctx-btn-pm:hover     { color: #5bc8ff; }
.ctx-btn-copy:hover   { color: #ecf0f1; }
.ctx-btn-ignore:hover { color: #f7c349; }
.ctx-btn-kick:hover   { color: #e67e22; }
.ctx-btn-ban:hover    { color: #ff6b6b; }
.ctx-divider { height: 1px; background: rgba(255,255,255,0.065); margin: 3px 5px; }

/* ── BOTONES SCRIBBLE/FOTO ── */
.btn-tool { background: #ecf0f1; border: none; border-radius: 12px; padding: 4px 12px; cursor: pointer; font-size: 0.85rem; font-weight: bold; color: #2c3e50; display: flex; align-items: center; gap: 5px; transition: background 0.2s; }
.btn-tool:hover { background: #bdc3c7; }

/* ── MENÚ DE EMOTES ── */
#emote-menu {
    display: none; position: fixed; background: #fff; border: 1px solid #bdc3c7; border-radius: 8px; padding: 10px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2); width: 360px; max-width: 95vw; max-height: 220px; overflow-y: auto;
    z-index: 9999; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 5px;
}
.emote-option { cursor: pointer; padding: 4px 6px; text-align: center; border-radius: 4px; transition: background 0.2s; height: 34px; display: flex; align-items: center; justify-content: center; }
.emote-option:hover { background: #ecf0f1; }
.emote-option img { max-width: 100%; max-height: 24px; pointer-events: none; }

/* ── MENÚ DE COLORES ── */
#color-menu { display: none; position: fixed; background: #fff; border: 1px solid #a0a0a0; padding: 4px; box-shadow: 2px 2px 5px rgba(0,0,0,0.3); z-index: 10005; flex-direction: row; gap: 6px; }
.color-column-classic { display: flex; flex-direction: column; width: 24px; }
.color-grid-extras { display: grid; grid-template-columns: repeat(4, 20px); grid-auto-rows: 20px; gap: 2px; border-left: 1px solid #dcdde1; padding-left: 6px; }
.color-option { width: 100%; height: 100%; min-height: 18px; cursor: pointer; box-sizing: border-box; border: 1px solid transparent; }
.color-option:hover { border: 1px solid #000; transform: scale(1.15); z-index: 10; box-shadow: 0 0 4px rgba(0,0,0,0.4); }

/* ── LIGHTBOX ── */
#avatar-lightbox {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(8, 12, 22, 0.75); backdrop-filter: blur(15px) saturate(150%); -webkit-backdrop-filter: blur(15px) saturate(150%);
    z-index: 10005; align-items: center; justify-content: center; cursor: zoom-out; animation: fadeIn 0.2s ease-out;
}
#avatar-lightbox.open { display: flex; }
#avatar-lightbox-img { max-width: 90vw; max-height: 90vh; border-radius: 16px; box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1); object-fit: contain; animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── MENÚ CONTEXTUAL MÓVIL ── */
@media (max-width: 768px) {
    #user-context-menu {
        top: 0 !important; bottom: 0 !important; left: 0 !important; right: 0 !important;
        margin: auto !important; height: max-content !important;
        animation: ctx-pop-mobile 0.26s cubic-bezier(0.34,1.56,0.64,1) both !important;
    }
}
@keyframes ctx-pop-mobile { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ── LIGHTBOX CLOSE BTN ── */
#lightbox-close-btn {
    position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.9); font-size: 32px; font-weight: 300;
    display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10006;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    line-height: 1; user-select: none; -webkit-tap-highlight-color: transparent; 
}
#lightbox-close-btn:hover, #lightbox-close-btn:active { background: rgba(231, 76, 60, 0.4); border-color: rgba(231, 76, 60, 0.6); transform: scale(1.15) rotate(90deg); }

/* ── HISTORIAL DE CHAT ── */
.input-wrapper { position: relative; flex: 1; display: flex; min-width: 0; }
.history-controls { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: none; flex-direction: column; gap: 2px; z-index: 5; }
.hist-btn { background: rgba(0, 0, 0, 0.05); border: none; border-radius: 4px; font-size: 0.65rem; padding: 3px 8px; color: #7f8c8d; cursor: pointer; line-height: 1; transition: background 0.2s; }
.hist-btn:active { background: rgba(0, 0, 0, 0.15); }

@media (max-width: 768px) {
    .history-controls { display: flex; }
    .chat-input-field { padding-right: 38px !important; }
}

/* ── SCROLL HORIZONTAL ── */
.chat-box { overflow-x: hidden !important; }
.msg-line { width: 100%; max-width: 100%; word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; }

/* ── TEXTO FLUIDO ── */
.msg-chat { display: block !important; max-width: 100%; margin: 0; }
.msg-nick { display: inline !important; white-space: normal !important; word-break: break-word; }
.msg-text { display: inline !important; word-break: break-word; overflow-wrap: break-word; }

/* ── TOASTERS ── */
#pm-toaster-container { position: fixed; top: 20px; right: 20px; z-index: 100000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.pm-toast {
    background: rgba(142, 68, 173, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    color: white; padding: 6px 12px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex; align-items: center; gap: 10px; cursor: pointer; pointer-events: auto;
    animation: slideInToast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none; border-left: 3px solid #f1c40f; min-width: 220px;
}
@keyframes slideOutToast { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }

.tab-btn.has-pm .msg-badge, .sheet-item.has-pm .msg-badge { background: #9b59b6 !important; box-shadow: 0 0 10px rgba(155, 89, 182, 0.8); }
.tab-btn.has-pm .tab-title::before, .sheet-item.has-pm .sheet-item-name::before { content: '✉️ '; }

@media (max-width: 768px) {
    #pm-toaster-container { top: 60px; right: 10px; }
}

/* ── BOTÓN REGRESO MÓVIL ── */
#global-pm-back { display: none; }

@media (max-width: 768px) {
    #global-pm-back.is-visible {
        display: flex;
        position: fixed;
        right: 10px;
        top: 55.5vh;
        z-index: 500;

        width: 40px; height: 40px;
        /* 👇 AQUÍ ESTÁ LA MAGIA: Fondo azul oscuro como la cabecera + sombrita 👇 */
        background: rgba(44, 62, 80, 0.9); 
        backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.25); 
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        
        align-items: center; justify-content: center; 
        cursor: pointer;
        -webkit-tap-highlight-color: transparent; 
        transition: all 0.2s ease;
    }
    
    /* Flecha original apuntando a la derecha ( > ) */
    #global-pm-back::after {
        content: ''; 
        display: block; /* Asegura que la flecha se dibuje bien */
        width: 10px; height: 10px;
        border-top: 3px solid rgba(255, 255, 255, 0.95); 
        border-right: 3px solid rgba(255, 255, 255, 0.95);
        transform: rotate(45deg); 
        margin-right: 2px;
    }
    
    #global-pm-back:active { 
        background: rgba(34, 47, 62, 1); 
        transform: scale(0.9); 
    }
}

/* ── BOTÓN NAVEGACIÓN DRAGGABLE ── */
#fab-salas-nav {
    display: none;
    visibility: hidden;   /* ← AÑADIR ESTO */
    position: fixed;
    width: 48px; height: 48px;
    border-radius: 50%;
    align-items: center; justify-content: center;
    cursor: grab;
    z-index: 500;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08);
    border: 1px solid rgba(52, 152, 219, 0.35);
    font-size: 1.1rem; color: rgba(255,255,255,0.75);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.4s ease, background 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    /* 👇 NUEVO: Totalmente visible y opaco */
    opacity: 1;
    background: rgba(34, 47, 62, 0.95);

    /* CÓDIGO ANTERIOR (Comentado por si quieres restaurar la transparencia en el futuro):
      opacity: 0.38;
      background: rgba(34, 47, 62, 0.55);
    */
}

/* El estado .fab-active se queda casi igual, solo intensifica un poco el fondo al tocarlo */
#fab-salas-nav.fab-active {
    opacity: 1;
    background: rgba(34, 47, 62, 0.98);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
    border-color: rgba(52, 152, 219, 0.7);
    color: white;
}
#fab-salas-nav:active { cursor: grabbing; }

@media (max-width: 768px) {
    #fab-salas-nav { 
        display: none;        /* ← QUITAR esta línea */
        visibility: hidden;   /* ← dejar solo esto */
    }
}

#fab-salas-tooltip {
    position: fixed;
    background: rgba(26, 31, 46, 0.96);
    color: white;
    border-radius: 10px;
    padding: 11px 15px;
    font-size: 0.78rem;
    line-height: 1.6;
    max-width: 200px;
    text-align: center;
    pointer-events: none;
    z-index: 501;
    border: 1px solid rgba(52, 152, 219, 0.3);
    opacity: 0;
    transition: opacity 0.4s;
    display: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
#fab-salas-tooltip strong { 
    display: block; 
    font-size: 0.82rem; 
    margin-bottom: 4px; 
    color: #5bc8ff;
}
#fab-salas-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px; left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px; height: 10px;
    background: rgba(26, 31, 46, 0.96);
    border-right: 1px solid rgba(52, 152, 219, 0.3);
    border-bottom: 1px solid rgba(52, 152, 219, 0.3);
}

#fab-salas-badge {
    position: absolute; top: -5px; right: -5px;
    background: #e74c3c; color: white;
    border-radius: 50%; width: 18px; height: 18px;
    font-size: 0.62rem; font-weight: 800;
    display: none; align-items: center; justify-content: center;
    border: 2px solid #1a1f2e;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}


.emote-option.emote-gif img { max-width: 100%; max-height: 36px; pointer-events: none; }
.emote-option.emote-gif { height: 44px; }

/* ── ATAJO DE SALA EN LA BARRA DE PMs (Ares Style) ── */
#pm-room-shortcut {
    border-right: 2px solid rgba(255, 255, 255, 0.15);
    border-top-right-radius: 4px; 
    border-bottom-right-radius: 4px;
    margin-right: 6px;
    padding-right: 14px;
    background: rgba(44, 62, 80, 0.6); /* Ligeramente más opaco para jerarquía */
    flex-shrink: 0;
}
#pm-room-shortcut:hover {
    background: rgba(52, 152, 219, 0.4);
}
#pm-room-shortcut.active {
    background: rgba(52, 152, 219, 0.2);
    border-color: rgba(52, 152, 219, 0.4);
    color: #5bc8ff;
    font-weight: bold;
}

/* --- FIX PARA BARRAS DE ANDROID (STATUS BAR Y NAVEGACIÓN) --- */
@media (max-width: 768px) {
    /* Empuja el header hacia abajo para esquivar la batería/reloj */
    header {
        padding-top: calc(6px + env(safe-area-inset-top, 35px)) !important;
    }

    /* Empuja la barra para escribir hacia arriba para esquivar los botones de navegación */
    .input-section {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 20px)) !important;
    }
    
    /* Le damos el mismo respiro a la lista del menú lateral de usuarios si la abres */
    #panel-usuarios-mobile {
        padding-top: env(safe-area-inset-top, 35px) !important;
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    }
}

/* 🔥 FIX PARA EL COLOR DEL SUBRAYADO 🔥 */
/* Obliga a que los hijos dibujen su propia línea con su color real, tapando el color por defecto del <u> padre */
.msg-line u span, 
.msg-line u b, 
.msg-line u i {
    text-decoration: underline;
}

@media (max-width: 768px) {
    #pm-room-shortcut {
        display: none !important;
    }
}

/* ════════════════════════════════════════════════════════════ */
/* UI MOD: ANIQUILACIÓN DEL HEADER Y NUEVO BOTÓN PERFIL         */
/* ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* 1. Desaparecemos el header gigante para siempre */
    header {
        display: none !important;
    }

    /* 2. Preparamos la barra oscura de la sala */
    #salas-trigger-bar {
        padding-top: calc(12px + env(safe-area-inset-top, 35px)) !important;
        position: relative !important; 
        
        /* APAGAMOS el click en toda la barra para que no abra la lista de salas por accidente */
        pointer-events: none !important; 
    }

    /* 3. Convertimos el botón en un ícono limpio y lo anclamos a la derecha */
    #btn-perfil {
        position: absolute !important;
        right: 12px !important;
        bottom: 8px !important; 
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        
        /* REDUCIMOS el tamaño del ícono para que sea más fino */
        font-size: 1.15rem !important; 
        
        padding: 4px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 100 !important;
        transition: transform 0.15s ease !important;
        color: #00e5ff !important;
        
        /* ENCENDEMOS el click ÚNICAMENTE para este botón */
        pointer-events: auto !important; 
    }

    /* Efecto al tocar el ícono */
    #btn-perfil:active {
        transform: scale(0.85) !important;
        opacity: 0.7;
    }
}

/* ════════════════════════════════════════════════════════════ */
/* LOGO NEÓN CUSTOMIZABLE (Puro CSS)                            */
/* ════════════════════════════════════════════════════════════ */
:root {
    --escala-logo: 0.85; 
}

#neon-brand-logo {
    position: absolute !important;
    left: 12px !important;
    bottom: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: scale(var(--escala-logo));
    transform-origin: left center;
    user-select: none;
    pointer-events: auto;
    
    /* Regresamos al orden de columna apilado a la derecha */
    display: flex;
    flex-direction: column;
    align-items: flex-end; 
}

.neon-xatero {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-weight: 900;
    letter-spacing: 1px;
    display: flex;
    align-items: baseline; /* Todo en la misma línea de suelo */
    background: linear-gradient(90deg, #9D4EDD, #ff007f);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0px 0px 4px rgba(255, 0, 127, 0.6));
}

.neon-x {
    font-size: 26px;
    margin-right: 1px;
}

.neon-atero {
    font-size: 20px;
}

.neon-app {
    color: #00e5ff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: lowercase;
    margin-top: -1px; /* Lo acercamos suavemente a la palabra de arriba */
    padding-right: 2px;
    text-shadow: 0 0 5px #00e5ff, 0 0 10px rgba(0, 229, 255, 0.6);
}
/* ── EVITAR SELECCIÓN DE TEXTO Y DESTELLOS TÁCTILES EN MÓVILES (DEFINITIVO) ── */
#user-list li,
#user-list li *,
#user-list-mobile li,
#user-list-mobile li *,
#user-context-menu,
#user-context-menu * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
}
/* 🔥 ANIQUILADOR DE LA LÍNEA DIVISORIA 🔥 */
div.input-section {
    border-top: 0px solid transparent !important;
    box-shadow: none !important;
} /* <--- ¡ESTA ES LA LLAVE QUE TE SALVÓ LA VIDA! */

/* 🔥 REGLAS EXCLUSIVAS PARA PC (Pantallas mayores a 768px) 🔥 */
@media (min-width: 769px) {
    
    #lobby-grid {
        grid-template-columns: 1fr; /* Una sola columna en PC */
    }

    /* 🔥 Alineación perfecta de la barra superior 🔥 */
    #lobby-toolbar {
        justify-content: flex-start; 
    }

    #lobby-search {
        flex: 0 0 200px !important; /* Mantiene el tamaño del cuadro de texto */
        
        /* 🔥 ESTA ES TU PROPIEDAD MANUAL PARA MOVERLO 🔥 */
        margin-left: 300px !important; 
        
        margin-right: 0 !important; 
    }

    .lobby-card {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 15px;
        border-radius: 4px;
        padding: 10px 16px;
    }

    /* COLUMNA 1: Nombre */
    .lobby-card-name { 
        order: 1;
        width: 260px; 
        flex-shrink: 0; 
        margin-bottom: 0; 
    }

    /* COLUMNA 2: SOLO Usuarios (Centrado verticalmente y más angosto) */
    .lobby-card-meta {
        order: 2;
        display: flex;
        align-items: center; 
        width: 65px; /* 🔥 Lo reducimos porque ahora solo está el número */
        flex-shrink: 0; 
        margin-top: 0;
    }

    /* 🔥 LA MAGIA: Ocultamos el texto "usuarios" solo en PC 🔥 */
    .hide-on-pc {
        display: none !important;
    }

    .lobby-card-meta span:nth-child(1) {
        width: 100%; 
        text-align: left;
    }

    /* 🔥 LA MAGIA: Ocultamos el servidor exclusivamente en PC 🔥 */
    .lobby-card-meta span:nth-child(2) {
        display: none !important; 
    }

    /* COLUMNA 3: Topic (Alineado a la izquierda) */
    .lobby-card-topic {
        order: 3;
        flex: 1; 
        font-size: 0.85rem; 
        font-weight: 700; 
        margin-top: 0;
        padding: 0 0 0 15px;
        text-align: left; 
        white-space: nowrap; 
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
}