/* ==========================================================================
   1. VARIABLES GLOBALES Y CONFIGURACIÓN BASE
   ========================================================================== */
:root {
    --primary-color: #3498db;
    --secondary-color: #4ECDC4;
    --tertiary-color: #9b59b6;
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --background-start: #667eea;
    --background-end: #764ba2;
    --text-light: #ffffff;
    --text-dark: #333333;
    --panel-bg: #f8f9fa;
    --map-base-color: #e0e0e0;
    --map-hover-color: #ffe082;
    --map-correct-color: #4caf50;
    --map-show-answer-color: #2196f3;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Nunito', 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--background-start) 0%, var(--background-end) 100%);
    min-height: 100%;
    color: var(--text-dark);
    margin: 0;
}

/* ==========================================================================
   2. LAYOUT PRINCIPAL (2 COLUMNAS)
   ========================================================================== */
.main-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* COLUMNA DE INFORMACIÓN (IZQUIERDA) */
.game-info {
    width: 320px;
    flex-shrink: 0;
    background: var(--text-light);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* COLUMNA DE JUEGO (DERECHA) */
.game-viewport {
    flex-grow: 1;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow-y: auto;
}

/* ==========================================================================
   3. COMPONENTES DE LA COLUMNA DE INFORMACIÓN
   ========================================================================== */
.header {
    background: linear-gradient(45deg, var(--primary-color), #5dade2);
    color: var(--text-light);
    padding: 20px;
    text-align: center;
}

.header-logo {
    width: 100px;
    height: auto;
    margin-bottom: 15px;
}

.header h1 {
    font-size: 1.8em;
    font-weight: 900;
    margin-bottom: 5px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1em;
    opacity: 0.9;
}

.game-controls {
    padding: 20px;
    background: var(--panel-bg);
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    width: 100%;
    padding: 15px;
    font-size: 1em;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn.btn-mode:nth-of-type(1) {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.btn.btn-mode:nth-of-type(2) {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
}

/* Nuevo color para Provincias */
.btn.btn-mode:nth-of-type(3) {
    background: linear-gradient(45deg, #8e44ad, #9b59b6);
    color: white;
}

.btn.btn-mode:nth-of-type(4) {
    background: linear-gradient(45deg, #e67e22, #f39c12);
    color: white;
}


.btn.btn-tertiary {
    background: #6c757d;
    color: var(--text-light);
}

.score-panel {
    display: flex;
    justify-content: space-around;
    background: var(--panel-bg);
    padding: 20px;
    flex-grow: 1;
    align-content: flex-start;
}

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

.score-number {
    font-size: 2.2em;
    font-weight: 900;
    color: var(--background-start);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e9ecef;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.5s ease-out;
}

.footer-link {
    background: #34495e;
    color: white;
    text-align: center;
    padding: 15px;
    margin-top: auto;
}

.footer-link a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
}

.footer-link a:hover {
    color: var(--secondary-color);
}

/* ==========================================================================
   4. COMPONENTES DEL ÁREA DE JUEGO
   ========================================================================== */
#game-intro {
    font-size: 2em;
    color: var(--text-light);
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

#game-intro p {
    font-size: 0.7em;
    opacity: 0.8;
}

#quiz-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* Alinea la pregunta arriba, permitiendo que el mapa crezca */
    align-items: center;
    padding: 20px 0;
    /* Añade un poco de espacio vertical para que no se pegue */
}

.question-panel {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-light);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    max-width: 800px;
}

.question {
    font-size: 2em;
    font-weight: 700;
}

.question strong {
    color: #FFD700;
    font-size: 1.3em;
    display: block;
    margin-top: 5px;
}

/* --- MAPA Y SVG --- */
.map-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    /* Permite que ocupe el espacio vertical restante */
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-container.locked .interactive-map-svg {
    cursor: not-allowed;
}

.interactive-map-svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
}

.interactive-map-svg .community-area {
    fill: var(--map-base-color);
    stroke: #333;
    stroke-width: 0.5;
    transition: fill 0.2s ease;
    cursor: pointer;
}

.interactive-map-svg .non-interactive {
    pointer-events: none;
}

.interactive-map-svg .community-area:hover {
    fill: var(--map-hover-color);
}

.interactive-map-svg .correct-answer {
    fill: var(--map-correct-color) !important;
    animation: pulse 0.5s 2 ease-in-out;
}

.interactive-map-svg .show-correct-answer {
    fill: var(--map-show-answer-color) !important;
    animation: pulse 0.5s 2 ease-in-out;
}

/* --- QUIZ DE CAPITALES (BOTONES DE OPCIÓN) --- */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
}

.option-btn {
    padding: 20px;
    font-size: 1.2em;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.option-btn:hover:not(.disabled) {
    background: rgba(0, 0, 0, 0.4);
    border-color: white;
}

.option-btn.correct {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.option-btn.incorrect {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
    opacity: 0.7;
}

.option-btn.disabled {
    pointer-events: none;
}

/* --- BANDERAS (SOLUCIÓN DE CENTRADO DEFINITIVA) --- */
.flag-container {
    padding: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 150px;
    height: 100px;
    margin: 0 auto 20px auto;
    /* Centra el contenedor en el Quiz de Banderas */
}

.flag-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Mantiene la proporción y ajusta dentro del contenedor */
    display: block;
}

/* Ajustes para cuando la bandera está al lado del texto (Quiz de Capitales) */
.question-panel.with-flag {
    display: flex;
    align-items: center;
    gap: 20px;
}

.question-panel.with-flag .flag-container {
    margin: 0;
    flex-shrink: 0;
}

.question-panel.with-flag .question {
    flex-grow: 1;
    text-align: left;
}

/* ==========================================================================
   5. EFECTOS GLOBALES (FEEDBACK, CONFETI)
   ========================================================================== */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: grid;
    place-items: center;
    padding: 20px;
}

.feedback-modal {
    padding: 40px;
    border-radius: 20px;
    color: var(--text-light);
    text-align: center;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
}

.feedback-modal.correct {
    background: linear-gradient(45deg, var(--success-color), #28a745);
}

.feedback-modal.incorrect {
    background: linear-gradient(45deg, var(--error-color), #c0392b);
}

.feedback-modal.end {
    background: linear-gradient(45deg, var(--primary-color), #2980b9);
}

.feedback-modal p {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 20px;
}

.feedback-modal span,
.feedback-modal div {
    font-size: 1.2em;
    line-height: 1.5;
}

.feedback-modal .flag-container {
    background: none;
    box-shadow: none;
    margin: 15px auto 10px auto;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    opacity: 0;
    animation: fall 4s linear infinite;
}

/* ==========================================================================
   6. ANIMACIONES Y CLASES DE UTILIDAD
   ========================================================================== */
@keyframes pulse {
    0% {
        transform-origin: center;
        transform: scale(1);
    }

    50% {
        transform-origin: center;
        transform: scale(1.02);
    }

    100% {
        transform-origin: center;
        transform: scale(1);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   7. DISEÑO RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .game-info {
        width: 100%;
        height: auto;
    }

    .game-viewport {
        padding: 20px;
        min-height: 50vh;
    }

    .map-container {
        min-height: 300px;
    }

    .question-panel.with-flag {
        flex-direction: column;
    }

    .question-panel.with-flag .flag-container {
        margin-bottom: 15px;
    }

    .question-panel.with-flag .question {
        text-align: center;
    }
}

/* En style.css, añade esta nueva regla */

.btn.btn-mode:nth-of-type(4) {
    background: linear-gradient(45deg, #e67e22, #f39c12);
    color: white;
}

/* NUEVA REGLA PARA EL BOTÓN DE EUROPA */
.btn.btn-mode:nth-of-type(5) {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    /* Un tono rojizo */
    color: white;
}