:root {
    --fondo: #050508;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --acento: #00ffcc;
    --glow: rgba(0, 255, 204, 0.4);
    --morado: #6200ea;
    --error: #ff3366;
    --texto: #ffffff;
    --racha: #ffae00;
}

/* 1. EL BODY AHORA PERMITE SCROLL (overflow-y: auto) y se expande (min-height) */
.body {
    background: var(--fondo);
    background-image: radial-gradient(circle at top right, #1a1a2e 0%, #050508 100%);
    color: var(--texto);
    font-family: 'Inter', sans-serif;
    margin: 0; 
    min-height: 100dvh; /* Cambiado a min-height para que crezca */
    display: flex; 
    justify-content: center; 
    align-items: flex-start; /* Comienza desde arriba para que no se corte */
    padding: 20px 0; /* Da un respiro arriba y abajo */
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto; /* ESTO LIBERA EL SCROLL */
}

/* 2. EL CONTENEDOR CRECE SEGÚN LO QUE TENGA DENTRO */
.contenedor {
    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 35px; 
    width: 88%; 
    max-width: 380px;
    padding: 25px 20px; 
    text-align: center; 
    margin: auto; /* Lo centra de forma natural */
    height: max-content; /* Se adapta a los anuncios y botones */
}

.logo-aura { font-size: 3.2rem; font-weight: 900; color: var(--acento); letter-spacing: -3px; margin: 0; text-shadow: 0 0 15px var(--glow); line-height: 1; }
.logo-match { font-size: 0.9rem; font-weight: 900; color: #fff; letter-spacing: 5px; margin-top: -5px; opacity: 0.5; text-transform: uppercase; }

.stats-fantasma { margin-bottom:18px; background: rgba(0,0,0,0.3); padding: 12px; border-radius: 25px; border: 1px solid var(--glass-border); }
.barra-progreso-bg { background:rgba(255,255,255,0.05); height: 8px; border-radius:10px; overflow:hidden; margin: 8px 0; }
#progreso-xp { background:var(--acento); height:100%; transition:1s; box-shadow: 0 0 10px var(--acento); }

.grid-avatares { display: flex; gap: 12px; margin-bottom: 20px; overflow-x: auto; padding: 15px 5px; scrollbar-width: none; }
.avatar-btn { 
    flex: 0 0 auto; background: var(--glass); font-size: 1.4rem; padding: 10px; 
    border-radius: 15px; border: 2px solid transparent; cursor: pointer; 
    position: relative; transition: 0.3s; 
}
.avatar-btn.bloqueado { filter: grayscale(1) opacity(0.3); cursor: not-allowed; }
.avatar-btn.bloqueado::after {
    content: attr(data-lvl);
    position: absolute; top: -5px; right: -5px;
    background: var(--error); color: #fff; font-size: 0.55rem; font-weight: 900;
    padding: 2px 4px; border-radius: 5px; box-shadow: 0 0 5px var(--error);
}
.avatar-btn.seleccionado { border-color: var(--acento); background: rgba(0,255,204,0.1); transform: scale(1.1); }

#input-apodo { width: 100%; padding: 18px; font-size: 1.3rem; font-weight: 800; background: rgba(0,0,0,0.5); border: 2px solid var(--glass-border); border-radius: 20px; color: var(--acento); text-align: center; box-sizing: border-box; margin-bottom: 15px; }
.btn { width: 100%; padding: 16px; border-radius: 20px; border: none; font-weight: 900; cursor: pointer; margin-bottom: 10px; font-size: 0.95rem; text-transform: uppercase; }
.btn-principal { background: var(--acento); color: #000; box-shadow: 0 8px 20px var(--glow); }
.grid-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-grupal { background: #1a1a20; color: #fff; border: 1px solid var(--glass-border); }
.btn-privado { background: linear-gradient(45deg, var(--morado), #9d50bb); color: #fff; }

.redes-footer { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--glass-border); display: flex; justify-content: center; gap: 20px; }
.redes-link { text-decoration: none; font-weight: 900; font-size: 0.75rem; padding: 8px 15px; border-radius: 12px; }
.link-tg { color: #0088cc; border: 1px solid rgba(0, 136, 204, 0.3); }
.link-tk { color: #ff0050; border: 1px solid rgba(255, 0, 80, 0.3); }

/* 3. EL CHAT SE QUEDA FIJO Y PERFECTO (Para que no salte el teclado) */
.contenedor-chat { 
    width: 100%; 
    max-width: 500px; 
    height: 100dvh; 
    display: none; 
    flex-direction: column; 
    background: var(--fondo); 
    position: fixed; /* Fijo para protegerlo del scroll del body */
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

#caja-mensajes { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.mensaje { padding: 10px 15px; border-radius: 20px; max-width: 80%; font-size: 0.95rem; display: flex; flex-direction: column; }
.mensaje-mio { background: var(--acento); color: #000; align-self: flex-end; border-bottom-right-radius: 4px; }
.mensaje-otro { background: var(--glass); color: #fff; align-self: flex-start; border: 1px solid var(--glass-border); border-bottom-left-radius: 4px; }
.msg-info { font-size: 0.7rem; font-weight: 900; margin-bottom: 4px; opacity: 0.7; }

#zona-escribir { padding: 10px 12px 30px 12px; background: #050508; display: flex; gap: 10px; border-top: 1px solid var(--glass-border); flex-shrink: 0; }
#input-mensaje { flex: 1; height: 48px; background: rgba(255,255,255,0.05); border-radius: 24px; border: 1px solid var(--glass-border); color: #fff; padding: 0 18px; font-size: 16px; }
.btn-enviar { width: 48px; height: 48px; border-radius: 50%; background: var(--acento); border: none; display: flex; justify-content: center; align-items: center; }

.loader { border: 4px solid rgba(255,255,255,0.1); border-top: 4px solid var(--acento); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { 100% { transform: rotate(360deg); } }