/* Habemus Papam - Estilos con mejoras: contador, fondo oscuro, móvil optimizado */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* NUEVO: Fondo oscuro en lugar de morado */
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(32, 32, 32, 0.7)), 
                url('images/habemus-papam-bg.jpg') center/cover no-repeat fixed;
    min-height: 100vh;
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* NUEVO: CONTADOR DE PARTIDAS TOTALES */
.game-counter {
    position: fixed;
    top: 20px;
    left: 20px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 215, 0, 0.3);
    animation: counterPulse 3s infinite ease-in-out;
}

.counter-icon {
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-icon i {
    font-size: 1.5em;
    color: #8b4513;
}

.counter-info {
    display: flex;
    flex-direction: column;
}

.counter-label {
    font-size: 0.8em;
    font-weight: 600;
    color: #8b4513;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.counter-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #8b4513;
    line-height: 1;
}

@keyframes counterPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }
    50% { transform: scale(1.02); box-shadow: 0 12px 30px rgba(255,215,0,0.4); }
}

/* SCREENS */
.screen { display: none; }
.screen.active { display: block; }

/* LOBBY CON FONDO OSCURO */
.lobby-header {
    text-align: center; margin-bottom: 40px; 
    background: rgba(255, 255, 255, 0.95);
    padding: 30px; border-radius: 15px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
}

.lobby-header h1 { font-size: 2.5em; color: #333; margin-bottom: 10px; }
.lobby-header h1 i { color: #d4af37; margin-right: 15px; }
.subtitle { font-size: 1.2em; color: #666; }

.lobby-options {
    display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin: 30px 0;
}

.option-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px; border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2); transition: transform 0.3s;
    backdrop-filter: blur(5px);
}
.option-card:hover { transform: translateY(-5px); }
.option-card h3 { color: #495057; margin-bottom: 20px; font-size: 1.3em; }

.form-group { margin: 15px 0; }

input {
    width: 100%; padding: 12px 15px; border: 2px solid #dee2e6;
    border-radius: 8px; font-size: 16px; transition: border-color 0.3s;
    background: rgba(255, 255, 255, 0.9);
}
input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }

/* BOTONES */
.btn {
    padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer;
    font-size: 16px; font-weight: bold; transition: all 0.3s;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.btn-primary { background: #007bff; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-warning { background: #ffc107; color: #212529; }
.btn-danger { background: #dc3545; color: white; }
.btn-info { background: #17a2b8; color: white; }

/* PARTIDAS PÚBLICAS */
.public-games {
    background: rgba(255, 255, 255, 0.95); padding: 25px; border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2); margin: 30px 0;
    backdrop-filter: blur(5px);
}
.public-games h3 { color: #495057; margin-bottom: 20px; font-size: 1.3em; }
.games-list { max-height: 300px; overflow-y: auto; margin-bottom: 20px; }

.game-item {
    background: rgba(248, 249, 250, 0.8); padding: 15px; border-radius: 8px; margin: 10px 0;
    cursor: pointer; transition: all 0.3s; border: 1px solid #dee2e6;
}
.game-item:hover {
    transform: translateX(5px); box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #007bff; background: rgba(255, 255, 255, 0.9);
}

.loading { text-align: center; color: #aaa; font-style: italic; }

/* GAME SCREEN */
.game-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 30px; background: rgba(255, 255, 255, 0.95); padding: 20px 30px;
    border-radius: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    flex-wrap: wrap; gap: 15px; backdrop-filter: blur(5px);
}
.game-header h1 { color: #333; font-size: 2em; margin: 0; }
.game-header-info { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.player-info, .players-count {
    background: rgba(248, 249, 250, 0.8); padding: 8px 15px; border-radius: 20px;
    font-weight: 500; color: #495057;
}

/* CONTROL DE RONDA */
.round-control {
    background: linear-gradient(135deg, rgba(255, 234, 167, 0.9), rgba(250, 177, 160, 0.9));
    padding: 25px; border-radius: 15px; margin: 20px 0; text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); backdrop-filter: blur(5px);
}
.round-control h3 { color: #2d3436; margin-bottom: 20px; font-size: 1.4em; }
.round-display { margin: 20px 0; }
.current-round { font-size: 2.5em; font-weight: bold; color: #2d3436; margin-bottom: 10px; }
.round-rule { font-size: 1.1em; color: #636e72; margin-bottom: 20px; }

/* EDICIÓN DE CARDENALES */
.cardinals-editor {
    background: linear-gradient(135deg, rgba(129, 236, 236, 0.9), rgba(116, 185, 255, 0.9));
    padding: 25px; border-radius: 15px; margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); backdrop-filter: blur(5px);
}

.cardinals-editor h3 {
    color: #2d3436; margin-bottom: 10px; font-size: 1.4em;
    display: flex; align-items: center; gap: 10px;
}

.editor-info {
    color: #636e72; margin-bottom: 20px; font-style: italic;
}

.editor-controls {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}

.cardinals-edit-panel {
    background: rgba(255, 255, 255, 0.95); margin-top: 20px; padding: 20px;
    border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
}

.edit-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; flex-wrap: wrap; gap: 15px;
}

.cardinal-count-controls {
    display: flex; align-items: center; gap: 10px;
}

.count-btn {
    width: 35px; height: 35px; border: none; border-radius: 50%;
    background: #007bff; color: white; cursor: pointer;
    font-size: 18px; font-weight: bold; transition: all 0.3s;
}

.count-btn:hover { transform: scale(1.1); background: #0056b3; }

#cardinal-count-display {
    font-size: 1.5em; font-weight: bold; color: #2d3436;
    min-width: 40px; text-align: center;
}

.cardinals-edit-list {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px; max-height: 400px; overflow-y: auto;
}

.cardinal-edit-item {
    background: rgba(248, 249, 250, 0.9); padding: 15px; border-radius: 8px;
    border: 1px solid #dee2e6; transition: all 0.3s;
}

.cardinal-edit-item:hover { border-color: #007bff; }

.cardinal-edit-item label {
    display: block; margin-bottom: 5px; font-weight: 500; color: #495057;
}

.cardinal-edit-item input {
    width: 100%; padding: 8px 12px; border: 1px solid #ced4da;
    border-radius: 5px; font-size: 14px; background: rgba(255, 255, 255, 0.9);
}

/* INFORMACIÓN DEL JUEGO */
.game-info {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px; margin: 20px 0;
}
.info-card {
    background: rgba(255, 255, 255, 0.95); padding: 20px; border-radius: 10px; text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); transition: transform 0.3s;
    backdrop-filter: blur(5px);
}
.info-card:hover { transform: translateY(-3px); }
.info-card h4 { color: #495057; margin-bottom: 10px; font-size: 1em; }
.info-value { font-size: 2em; font-weight: bold; color: #007bff; }

.pope-status { position: relative; }
.pope-status.has-pope {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    animation: popeGlow 2s infinite;
}
.pope-status.has-pope .info-value { color: #d63031; }

@keyframes popeGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255,215,0,0.5); }
    50% { box-shadow: 0 0 20px rgba(255,215,0,0.8); }
}

/* CARDENALES */
.cardinals-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; margin: 20px 0;
}
.cardinal-card {
    background: rgba(255, 255, 255, 0.95); border: 2px solid #dee2e6; border-radius: 10px;
    padding: 20px; text-align: center; position: relative; transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); backdrop-filter: blur(5px);
}
.cardinal-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }

.cardinal-card.pope {
    border-color: #ffd700; background: linear-gradient(135deg, rgba(255, 248, 220, 0.95), rgba(255, 235, 59, 0.95));
    animation: cardinalGlow 2s infinite;
}

@keyframes cardinalGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255,215,0,0.5); }
    50% { box-shadow: 0 0 25px rgba(255,215,0,0.8); }
}

.cardinal-card .crown {
    position: absolute; top: -10px; right: -10px;
    font-size: 24px; color: #ffd700; animation: bounce 1s infinite;
}

/* INDICADORES DE VOTOS */
.cardinal-card .votes-needed {
    position: absolute; top: 8px; left: 8px;
    color: white; padding: 4px 10px;
    border-radius: 15px; font-size: 11px; font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3); z-index: 2;
}

.cardinal-card .votes-needed {
    background: #dc3545; animation: pulse 2s infinite;
}

.cardinal-card .votes-needed.ready-indicator {
    background: #ffc107; color: #212529; animation: none;
    font-size: 10px; padding: 4px 8px;
}

.cardinal-card .votes-needed.pope-indicator {
    background: #28a745; animation: none;
    font-size: 10px; padding: 4px 8px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}

.cardinal-name { 
    font-size: 1.2em; font-weight: bold; color: #2d3436; 
    margin-bottom: 15px; margin-top: 10px;
}

.vote-counter {
    display: flex; align-items: center; justify-content: center; gap: 15px; margin-top: 15px;
}
.vote-btn {
    width: 45px; height: 45px; border: none; border-radius: 50%;
    font-size: 18px; cursor: pointer; transition: all 0.3s;
    display: flex; align-items: center; justify-content: center; font-weight: bold;
}
.vote-btn:hover { transform: scale(1.1); }
.vote-btn:active { transform: scale(0.95); }
.vote-btn.minus { background: #e74c3c; color: white; }
.vote-btn.plus { background: #27ae60; color: white; }
.vote-count { font-size: 1.5em; font-weight: bold; color: #2d3436; min-width: 50px; }

/* CONTROLES */
.controls { display: flex; justify-content: center; gap: 15px; margin: 30px 0; flex-wrap: wrap; }

/* ESTADO DE CONEXIÓN */
.connection-status {
    position: fixed; bottom: 20px; right: 20px; padding: 10px 15px;
    border-radius: 25px; color: white; font-weight: bold; z-index: 1000;
    display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.connection-status.connected { background: rgba(39, 174, 96, 0.9); }
.connection-status.disconnected { background: rgba(231, 76, 60, 0.9); }
.connection-status.connecting { background: rgba(243, 156, 18, 0.9); }

/* RESPONSIVE - MEJORADO PARA MÓVILES */
@media (max-width: 768px) {
    body {
        background: linear-gradient(rgba(0, 0, 0, 0.75), rgba(32, 32, 32, 0.8)), 
                    url('images/habemus-papam-bg.jpg') center/cover no-repeat fixed;
    }

    /* CONTADOR MÁS PEQUEÑO EN MÓVILES */
    .game-counter {
        top: 10px; left: 10px; padding: 10px 15px;
        border-radius: 12px;
    }

    .counter-icon {
        padding: 6px;
    }

    .counter-icon i {
        font-size: 1.2em;
    }

    .counter-label {
        font-size: 0.7em;
    }

    .counter-value {
        font-size: 1.4em;
    }

    .container { padding: 10px; }
    .lobby-options { grid-template-columns: 1fr; gap: 20px; }
    .game-header { flex-direction: column; text-align: center; }
    .game-header-info { justify-content: center; }

    /* CARDENALES MÁS PEQUEÑOS EN MÓVILES */
    .cardinals-grid { 
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .cardinal-card {
        padding: 12px;
        border-radius: 8px;
    }

    .cardinal-name {
        font-size: 0.9em;
        margin-bottom: 8px;
        margin-top: 8px;
    }

    .vote-counter {
        gap: 8px;
        margin-top: 8px;
    }

    .vote-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .vote-count {
        font-size: 1.2em;
        min-width: 35px;
    }

    .votes-needed {
        font-size: 9px !important;
        padding: 2px 5px !important;
        top: 5px;
        left: 5px;
    }

    .controls { flex-direction: column; align-items: center; }
    .current-round { font-size: 2em; }
    .edit-panel-header { flex-direction: column; }
    .cardinals-edit-list { grid-template-columns: 1fr; }
}

/* EXTRA PEQUEÑO PARA PANTALLAS MUY PEQUEÑAS */
@media (max-width: 480px) {
    .cardinals-grid { 
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }

    .cardinal-card {
        padding: 10px;
    }

    .cardinal-name {
        font-size: 0.8em;
    }

    .vote-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .vote-count {
        font-size: 1em;
        min-width: 30px;
    }
}