/* ==========================================================================
   1. VARIABLES, CONFIGURACIÓN GENERAL Y ANIMACIONES
   ========================================================================== */

:root {
    --bg-color: #0d0e12;
    --panel-bg: rgba(30, 32, 42, 0.75);
    --accent-green: #00ffaa;
    --accent-pink: #ff0077;
    --accent-yellow: #ffcc00;
    --border-color: rgba(255, 255, 255, 0.08);
}

@keyframes pulse { 
    0%, 100% { opacity: 0.6; } 
    50% { opacity: 1; } 
}

@keyframes popIn { 
    0% { transform: scale(0.3); opacity: 0; } 
    100% { transform: scale(1); opacity: 1; } 
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at center, #1a1c24 0%, var(--bg-color) 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 10px 20px; /* Reducido para evitar scroll vertical */
    overflow-x: hidden;
    box-sizing: border-box;
}

hr { 
    border: 0; 
    height: 1px; 
    background: var(--border-color); 
    margin: 12px 0; 
    width: 100%; 
}


/* ==========================================================================
   2. COMPONENTES REUTILIZABLES (UI/UX)
   ========================================================================== */

.btn {
    background: linear-gradient(135deg, var(--accent-green) 0%, #00bfff 100%);
    color: #0d0e12;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 15px rgba(0, 255, 170, 0.2);
}

.btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(0, 255, 170, 0.4); 
}

.input-group {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 5px;
    margin: 12px 0;
}


/* ==========================================================================
   3. CABECERA Y TEXTOS DE ESTADO
   ========================================================================== */

h1.game-title {
    font-family: 'Lacquer', cursive;
    font-size: 4rem;
    margin: 5px 0;
    letter-spacing: 2px;
    background: linear-gradient(45deg, var(--accent-green), #00bcff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    transition: font-size 0.3s ease;
}

/* Reducción dinámica de tamaño si la pantalla está en modo juego */
body:has(#game-room[style*="display: flex"]) h1.game-title {
    font-size: 2rem;
    margin: 0px 0 5px 0;
}

#status-text {
    font-size: 0.85rem;
    color: var(--accent-pink);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    font-weight: bold;
    animation: pulse 2s infinite ease-in-out;
    text-align: center;
}

.instructions { 
    color: #626775; 
    font-size: 0.8rem; 
    margin-top: 5px; 
    text-align: center; 
}

.instructions p {
    margin: 5px 0 0 0;
}


/* ==========================================================================
   4. PANELES DEL LOBBY (CONEXIÓN Y USUARIOS)
   ========================================================================== */

.network-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 20px;
    width: 360px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    text-align: center;
    box-sizing: border-box;
}

.network-panel h3 { 
    margin-top: 0; 
    margin-bottom: 8px;
    color: #a0a5b5; 
    font-weight: 500;
    font-size: 1rem; 
}

.network-panel input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px;
    width: 100%;
    text-align: center;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

.network-panel input:focus { 
    outline: none; 
}

.input-group.nickname-group {
    border: 1px solid var(--accent-yellow);
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.15);
}

.btn-host-start {
    background: linear-gradient(135deg, var(--accent-yellow) 0%, #ff9900 100%);
    box-shadow: 0 4px 15px rgba(255, 204, 0, 0.2);
    margin-top: 12px;
    display: none;
}

.btn-host-start:hover { 
    box-shadow: 0 6px 20px rgba(255, 204, 0, 0.4); 
}

.connected-users-list {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    margin: 12px 0;
    text-align: left;
    max-height: 100px;
    overflow-y: auto;
}

.connected-users-list h4 { 
    margin: 0 0 6px 0; 
    font-size: 0.85rem; 
    color: #a0a5b5; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.user-badge {
    font-size: 0.85rem;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-badge::before {
    content: "•";
    color: var(--accent-green);
    margin-right: 8px;
    font-size: 1.1rem;
}


/* ==========================================================================
   5. ESCENARIO DE JUEGO (GAME LAYOUT ULTRA COMPACTO)
   ========================================================================== */

.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 950px;
    width: 100%;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 18px 22px;
    border-radius: 20px;
    box-shadow: 0 24px 50px rgba(0,0,0,0.3);
    box-sizing: border-box;
    display: none;
}

/* Área superior estilizada en una sola línea horizontal para ahorrar espacio */
.top-objective-area {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

#timer-container {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-yellow);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
    min-width: 100px;
    text-align: left;
}

.progress-indicator {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: right;
    min-width: 130px;
}

/* Arena de batalla dividida equitativamente */
.battle-arena {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 30px;
    width: 100%;
}


/* ==========================================================================
   6. SECCIÓN DE TABLEROS (JUGADOR PRINCIPAL)
   ========================================================================== */

.player-zone {
    display: flex;
    flex-direction: row; /* Coloca el objetivo al lado de tu panel para optimizar alto */
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.15);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-title {
    margin: 0 0 5px 0; 
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 45px); /* Reducido ligeramente de 55px a 45px */
    grid-template-rows: repeat(4, 45px);    /* Reducido ligeramente de 55px a 45px */
    gap: 5px;
    margin: 5px auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cell {
    background-color: #2a2d3a;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: all 0.08s ease;
}

.cell.active { 
    background-color: var(--accent-green); 
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.4); 
}

/* El objetivo usa un color azulado distintivo */
#target-grid .cell.active {
    background-color: var(--accent-yellow);
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.4);
}

.cell.cursor { 
    border-color: var(--accent-pink); 
    transform: scale(1.03); 
    box-shadow: 0 0 12px var(--accent-pink); 
}


/* ==========================================================================
   7. ZONA Y MINI-CUADRÍCULAS DE RIVALES
   ========================================================================== */

.opponents-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-left: 1px solid var(--border-color);
    padding-left: 25px;
    min-width: 220px;
}

.opponents-zone h3 {
    margin: 0 0 12px 0; 
    color: #8a8f9f; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-size: 0.8rem;
}

.opponents-row-container {
    display: flex;
    flex-direction: column; /* Columna vertical para encajar perfectamente a un lado */
    gap: 10px;
    width: 100%;
    max-height: 260px;
    overflow-y: auto; /* Previene roturas si se conectan muchos jugadores */
}

.mini-opponent-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: row; /* Diseño en fila horizontal para ahorrar espacio */
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.mini-meta {
    text-align: left;
}

.mini-opponent-name { 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: #b5b9c4; 
    margin-bottom: 2px; 
    max-width: 80px; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.mini-opponent-progress { 
    font-size: 0.7rem; 
    font-weight: 700; 
    color: var(--accent-yellow); 
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, 12px); /* Mini celdas súper compactas de 12px */
    grid-template-rows: repeat(4, 12px);
    gap: 2px;
    background: rgba(0,0,0,0.25);
    padding: 4px;
    border-radius: 6px;
}

.mini-cell { 
    background-color: #20222b; 
    border-radius: 2px; 
}

.mini-cell.active { 
    background-color: #00bcff; 
    box-shadow: 0 0 4px rgba(0, 188, 255, 0.5); 
}


/* ==========================================================================
   8. PANTALLAS SUPERPUESTAS Y MARKETING
   ========================================================================== */

#countdown-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13, 14, 18, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    display: none;
}

#countdown-number {
    font-size: 6rem;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow: 0 0 30px rgba(255, 204, 0, 0.5);
    animation: popIn 0.5s ease-out;
}

.welcome-container {
    text-align: center;
    max-width: 480px;
    padding: 15px;
    animation: popIn 0.6s ease-out;
}

.game-tagline {
    font-size: 1.2rem;
    color: var(--accent-yellow);
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.2);
}

.game-description {
    color: #b5b9c4;
    line-height: 1.5;
    font-size: 0.95rem;
    margin-bottom: 25px;
}

.btn-play-now {
    font-size: 1.15rem;
    padding: 14px 30px;
}

.section-sub {
    font-size: 0.75rem;
    color: #8a8f9f;
    margin: -5px 0 8px 0;
}

.hidden {
    display: none !important;
}

/* Responsive para pantallas muy pequeñas */
@media (max-width: 768px) {
    .battle-arena {
        flex-direction: column;
        align-items: center;
    }
    .player-zone {
        flex-direction: column;
    }
    .opponents-zone {
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-left: 0;
        padding-top: 15px;
    }
    .opponents-row-container {
        flex-direction: row;
    }
}
