/* =========================================
   1. VARIABLES & RESET
   ========================================= */
   :root {
    --neon: #ccff00;            /* Amarillo Lando Norris */
    --neon-dim: rgba(204, 255, 0, 0.2);
    --neon-glow: rgba(204, 255, 0, 0.4);
    --dark: #050505;            /* Fondo casi negro */
    --panel-bg: #111111;        /* Fondo sólido para paneles */
    --border: #333333;
    --text-main: #ffffff;
    --text-muted: #888888;
    
    --font-head: 'Rajdhani', sans-serif; /* Títulos técnicos */
    --font-body: 'Inter', sans-serif;    /* Texto lectura */
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Quitar brillo azul en móviles */
}

body {
    margin: 0;
    background-color: var(--dark);
    color: var(--text-main);
    font-family: var(--font-body);
    /* CAMBIO AQUÍ: Usamos dvh para evitar que la barra del navegador tape cosas */
    min-height: 100vh;
    min-height: 100dvh; 
    overflow-x: hidden;
    /* Evita el rebote elástico en iOS al hacer scroll en los bordes */
    overscroll-behavior: none; 
}

/* =========================================
   2. FONDOS & AMBIENTE
   ========================================= */

/* Rejilla de fondo técnica */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* Efecto Scanline (TV antigua) */
.scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.5) 51%);
    background-size: 100% 4px;
    opacity: 0.1;
}

/* =========================================
   3. HEADER & NAVEGACIÓN
   ========================================= */

   header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* CAMBIO AQUÍ: Añadimos env(safe-area...) */
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top)); 
    background: #0a0a0a;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* --- MODAL --- */
.modal {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: rgba(0,0,0,0.85);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
}
.modal-content {
    background: #111;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}
.neon-border {
    border: 2px solid var(--neon);
    box-shadow: 0 0 15px var(--neon), inset 0 0 10px var(--neon);
}

.brand {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 2px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #222;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
}

.user-profile:active {
    background: #333;
}

.avatar-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #333;
}

/* =========================================
   4. ESTRUCTURA PRINCIPAL (VIEWS)
   ========================================= */

main {
    padding: 20px;
    padding-bottom: 80px;
    max-width: 600px;
    margin: 0 auto;
}

.view {
    display: none;
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.view.active {
    display: block;
}

/* =========================================
   5. LOGIN
   ========================================= */

.login-box {
    margin-top: 60px;
    text-align: center;
}

.glitch {
    font-family: var(--font-head);
    font-size: 3.5rem;
    margin: 0;
    letter-spacing: -2px;
    color: white;
    text-shadow: 2px 2px 0px rgba(204, 255, 0, 0.3);
}

/* Input Tech */
.input-tech-wrapper {
    display: flex;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: 0.3s;
}

.input-tech-wrapper:focus-within {
    border-color: var(--neon);
    box-shadow: 0 0 15px var(--neon-glow);
}

.input-tech {
    width: 100%;
    background: transparent;
    border: none;
    padding: 15px;
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
}

.center { justify-content: center; }

.btn-plus {
    background: var(--neon);
    border: none;
    font-size: 1.5rem;
    width: 50px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-plus:active { background: white; }

/* Botón Neón Principal */
.btn-neon {
    background: var(--neon);
    color: black;
    font-weight: 800;
    width: 100%;
    padding: 16px;
    border: none;
    font-family: var(--font-head);
    text-transform: uppercase;
    margin-top: 20px;
    cursor: pointer;
    font-size: 1.1rem;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    transition: transform 0.1s, background 0.2s;
}

.btn-neon:active {
    transform: scale(0.98);
    background: white;
}

/* Botón Volver */
.top-nav { margin-bottom: 15px; }

.btn-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-head);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    padding: 0;
}
.btn-back:hover { color: var(--neon); }

/* =========================================
   6. LISTA DE JUEGOS (DASHBOARD)
   ========================================= */

.section-header h2 {
    font-family: var(--font-head);
    color: var(--neon);
    margin: 0;
    font-size: 1.5rem;
}
.section-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 5px 0 20px 0;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-card {
    display: flex;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    height: 100px;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
}

.game-card:hover {
    border-color: var(--neon);
    transform: translateX(5px);
}

.game-img {
    width: 110px;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    transition: 0.3s;
    border-right: 1px solid var(--border);
}

.game-card:hover .game-img { filter: grayscale(0%); }

.game-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-info h3 {
    margin: 0;
    font-family: var(--font-head);
    font-size: 1.4rem;
    color: white;
    text-transform: uppercase;
}

/* =========================================
   7. INTERFAZ DE JUEGO
   ========================================= */

.game-header-card {
    position: relative;
    height: 160px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 25px;
}

.game-header-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gradient-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--dark) 0%, transparent 80%);
}

.game-title-overlay {
    position: absolute;
    bottom: 15px;
    left: 20px;
    margin: 0;
    font-family: var(--font-head);
    font-size: 2.5rem;
    text-transform: uppercase;
    text-shadow: 0 4px 10px black;
    color: white;
    z-index: 2;
}

/* Paneles */
.panel-box {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.center-text { text-align: center; }

.panel-header {
    font-family: var(--font-head);
    color: var(--neon);
    font-size: 0.9rem;
    margin-bottom: 15px;
    opacity: 0.8;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.desc-text {
    color: #ccc;
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: bold;
}

/* Grid Jugadores */
.players-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.player-chip {
    background: #222;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #333;
}

.player-chip.joined {
    border: 1px solid var(--neon);
    background: rgba(204, 255, 0, 0.05);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--neon);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--neon);
    animation: blink 2s infinite;
}

/* Caja de añadir contenido */
.add-content-box {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    margin-bottom: 20px;
}

.label-tech {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 8px;
    display: block;
}

.success-text {
    color: var(--neon);
    font-size: 0.8rem;
    margin-top: 5px;
    text-align: center;
    font-weight: bold;
}

/* Barra de espera */
.status-bar {
    margin-top: 20px;
    padding: 12px;
    text-align: center;
    font-family: var(--font-head);
    background: #111;
    border: 1px solid var(--neon);
    color: var(--neon);
    border-radius: 6px;
    animation: pulse 2s infinite;
}

/* =========================================
   8. VOTACIÓN AVANZADA (BARRAS)
   ========================================= */

.vote-buttons-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

/* Botón con barra de progreso */
.btn-vote-complex {
    position: relative;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    height: 55px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.1s;
}

.btn-vote-complex:active { transform: scale(0.98); }

/* ESTILO GANADOR */
.btn-vote-complex.winner {
    border: 2px solid #00ff00;
    background: rgba(0, 255, 0, 0.1);
}
.btn-vote-complex.winner .btn-content { color: #00ff00; }

.winner-text {
    color: #00ff00;
    font-weight: bold;
    font-size: 1.2rem;
    margin-top: 15px;
    animation: popIn 0.3s;
}

.progress-bar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: var(--neon-dim);
    border-right: 2px solid var(--neon);
    width: 0%;
    transition: width 0.4s ease-out;
    z-index: 1;
}

.btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    color: white;
    font-family: var(--font-body);
    font-weight: 600;
}

.percent-text {
    color: var(--neon);
    font-family: var(--font-head);
    font-weight: bold;
}

/* =========================================
   9. GRID DE AVATARES (VOTACIÓN)
   ========================================= */

.avatars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 10px;
    margin-top: 10px;
    min-height: 100px;
}

.btn-vote {
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    color: white;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.btn-vote.selected {
    border-color: var(--neon);
    background: rgba(204, 255, 0, 0.1);
}

.btn-vote img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: block;
}

.btn-vote.winner {
    border-color: #00ff00;
    box-shadow: 0 0 15px #00ff00;
    transform: scale(1.05);
}

/* =========================================
   10. RESULTADOS & PODIUM
   ========================================= */

.secret-card, .question-card {
    background: #0a0a0a;
    border: 1px solid var(--neon);
    padding: 30px 20px;
    text-align: center;
    border-radius: 12px;
    margin-bottom: 20px;
}

.impostor-text {
    font-size: 2.5rem;
    font-weight: 800;
    color: #ff3333;
    margin: 10px 0;
    text-transform: uppercase;
    animation: pulse 0.5s infinite alternate;
}

.reveal-word {
    font-size: 2.2rem;
    font-weight: bold;
    color: white;
    margin: 10px 0;
}

.reveal-category {
    font-size: 0.9rem;
    letter-spacing: 3px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.countdown-wrapper { text-align: center; margin-top: 60px; }
.countdown-number { font-size: 10rem; font-family: var(--font-head); color: var(--neon); font-weight: bold; line-height: 1; animation: pulse 0.5s infinite; }

/* --- PODIUM ANIMADO --- */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    height: 280px;
    padding-bottom: 20px;
    margin-top: 30px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 85px;
    position: relative;
    opacity: 0;
    animation: popIn 0.6s forwards;
}

/* Orden visual: 2 - 1 - 3 */
.place-2 { order: 1; animation-delay: 0.2s; }
.place-1 { order: 2; animation-delay: 0.5s; z-index: 10; }
.place-3 { order: 3; animation-delay: 0.8s; }

.podium-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid white;
    background: #222;
    margin-bottom: 10px;
    cursor: pointer;
    animation: bounce 2s infinite ease-in-out;
    position: relative;
    z-index: 2;
}

.place-1 .podium-avatar { width: 70px; height: 70px; border-color: #ffd700; animation: dance 1s infinite; }
.place-2 .podium-avatar { border-color: #c0c0c0; }
.place-3 .podium-avatar { border-color: #cd7f32; }

.podium-block {
    width: 100%;
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: black;
    font-weight: bold;
    font-family: var(--font-head);
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.place-1 .podium-block { height: 140px; background: linear-gradient(to bottom, #ffd700, #b8860b); font-size: 1.5rem; }
.place-2 .podium-block { height: 90px; background: linear-gradient(to bottom, #c0c0c0, #808080); font-size: 1.2rem; }
.place-3 .podium-block { height: 60px; background: linear-gradient(to bottom, #cd7f32, #8b4513); font-size: 1rem; }

.podium-name {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #aaa;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crown {
    font-size: 2rem;
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    animation: bounce 1s infinite alternate;
}

/* Rondas */
.round-tracker { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.round-dot { width: 8px; height: 8px; background: #333; border-radius: 50%; }
.round-dot.active { background: var(--neon); box-shadow: 0 0 10px var(--neon); transform: scale(1.2); }
.round-dot.completed { background: #666; }

/* =========================================
   11. MODAL & UTILIDADES
   ========================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-box {
    background: #111;
    border: 1px solid var(--neon);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 0 30px rgba(204,255,0,0.1);
    animation: popIn 0.3s;
}

.modal-box h3 { color: white; font-family: var(--font-head); margin-top: 0; font-size: 1.5rem; }
.modal-buttons { display: flex; gap: 10px; margin-top: 20px; }

.btn-cancel {
    flex: 1; padding: 12px; background: transparent;
    border: 1px solid #444; color: #888;
    border-radius: 6px; cursor: pointer; font-weight: bold;
}

.btn-confirm {
    flex: 1; padding: 12px; background: var(--neon);
    border: none; color: black;
    border-radius: 6px; cursor: pointer; font-weight: bold;
}

.hidden { display: none !important; }
.mt-20 { margin-top: 20px; }

/* Animaciones */
@keyframes slideUp { from {opacity:0; transform:translateY(20px);} to {opacity:1; transform:translateY(0);} }
@keyframes pulse { 0% {opacity:0.6;} 50% {opacity:1;} 100% {opacity:0.6;} }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 80% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes dance { 0% { transform: rotate(0deg); } 25% { transform: rotate(-5deg) translateY(-5px); } 75% { transform: rotate(5deg) translateY(-5px); } 100% { transform: rotate(0deg); } }