:root {
    --primary-color: #7B68EE; /* Morado medio, un color vibrante */
    --secondary-color: #FFD700; /* Dorado brillante */
    --accent-color: #FF69B4; /* Rosa chicle */
    --background-color: #E0FFFF; /* Azul cielo claro */
    --text-color: #333;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --border-radius: 15px;
    --card-size: 140px; /* Tamaño base de las cartas (Desktop) */
}

/* Fuentes */
body {
    font-family: 'Fredoka One', cursive; /* Fuente principal amigable */
    background-color: var(--background-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-color);
    overflow: hidden; /* Evita barras de desplazamiento innecesarias en el body */
    transition: background-color 0.3s ease, color 0.3s ease; /* Transición para cambios de tema */
}

/* Estilos globales para pantallas */
.screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 90%;
    max-width: 800px;
    padding: 30px;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    transition: all 0.5s ease-in-out, background-color 0.3s ease, box-shadow 0.3s ease; /* Transición para cambios de tema */
    position: relative;
    min-height: 90vh;
    box-sizing: border-box;
    overflow-y: auto;
    margin: auto;
}

/* IMPORTANTE: Ahora el global .hidden SOLO maneja display: none.
   Las transiciones de opacidad y visibilidad las manejan .screen y .modal directamente. */
.hidden {
    display: none !important;
}

.screen.hidden {
    opacity: 0;
    transform: scale(0.9);
}

.screen.active {
    display: flex; /* Asegura que la pantalla sea visible como flex */
    opacity: 1;
    transform: scale(1);
}

/* Botones */
.btn {
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: all 0.3s ease;
    font-family: 'Fredoka One', cursive;
}

/* Botón Principal (Jugar Ahora, Volver a Jugar) */
.btn-primary {
    background-color: var(--primary-color);
}
.btn-primary:hover {
    background-color: #6A5ACD;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px var(--shadow-color);
}

/* ESTILO DE BOTONES AMARILLOS (SALIR, VOLVER AL MENÚ) */
.btn-secondary-yellow {
    background-color: var(--secondary-color); /* Amarillo brillante */
    color: var(--text-color); /* Color de texto oscuro para buen contraste */
    border: 2px solid var(--primary-color); /* Borde con el color primario */
}

.btn-secondary-yellow:hover {
    background-color: #FFC107; /* Un tono más oscuro de amarillo en hover */
    transform: translateY(-3px);
    box-shadow: 0 8px 20px var(--shadow-color);
}

/* ESTILO DEL BOTÓN DE TUTORIAL (NUEVO) */
.btn-tutorial {
    background-color: #3CB371; /* Medium Sea Green (un verde agradable) */
    color: white;
    border: 2px solid #2E8B57; /* Borde verde más oscuro */
}
.btn-tutorial:hover {
    background-color: #2E8B57; /* Verde más oscuro en hover */
    transform: translateY(-3px);
    box-shadow: 0 8px 20px var(--shadow-color);
}
/* Estilos de Modo Oscuro para el botón de Tutorial */
body.dark-mode .btn-tutorial {
    background-color: #3498db; /* Un azul vibrante para modo oscuro */
    border-color: #2980b9;
    color: white;
}
body.dark-mode .btn-tutorial:hover {
    background-color: #2980b9;
}


/* Estilo general para el botón de icono (solo para el botón de música ahora) */
.btn-icon {
    background-color: transparent;
    color: white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    border: none;
    overflow: hidden;
}

/* Estilo de la imagen dentro del botón de icono */
.btn-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.btn-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
}

.btn-icon:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Contenedores para agrupar los botones de la pantalla de inicio y final */
.start-buttons,
.end-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}


/* Pantalla de Inicio */
#start-screen {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--background-color), #ADD8E6);
    box-shadow: none;
}

.start-title {
    font-size: 3.5em;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    animation: bounceIn 1s ease-out;
}

.start-subtitle {
    font-size: 1.8em;
    color: var(--text-color);
    margin-bottom: 30px;
    animation: fadeIn 1.5s ease-out;
}

.start-animation {
    margin-top: 40px;
    position: relative;
    width: 150px;
    height: 150px;
}

.animated-card {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: floatUpDown 3s ease-in-out infinite alternate, rotate3D 5s linear infinite;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes rotate3D {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}
@keyframes floatUpDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(-20px); }
}


/* Contenedor Principal del Juego - Sobrescribe algunos estilos de .screen */
#game-container {
    justify-content: flex-start;
    padding: 150px 20px 20px 20px;
    max-width: 800px;
    width: 100%;
    flex-grow: 1;
}

/* ESTILO DEL CARTEL DE PUNTOS/VIDAS/NIVEL (HEADER) */
.game-header {
    position: fixed;
    top: 20px;
    right: 20px;
    width: auto;
    min-width: 170px;
    padding: 8px 15px;
    background: linear-gradient(135deg, var(--secondary-color), #FFC107);
    border: 3px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3),
                inset 0 0 15px rgba(255, 255, 0, 0.5);
    font-family: 'Nunito', sans-serif;
    color: var(--text-color);
    font-weight: bold;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    z-index: 999;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.game-header .label {
    font-size: 1.2em;
    font-weight: bold;
    color: #5B4CDC;
    margin-right: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    transition: color 0.3s ease;
}

.game-header span:not(.label) {
    font-family: 'Fredoka One', cursive;
    font-size: 2em;
    color: #1A1A1A;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.2);
    transition: color 0.3s ease;
}

/* ESTILO DEL BOTÓN DE MÚSICA (BOCINA) - FIJO EN INFERIOR DERECHA */
#music-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #768AA4, #5D728A);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    border: none;
    z-index: 1002;
    padding: 0;
}

/* ESTILO PARA EL BOTÓN "VOLVER AL MENÚ" DURANTE EL JUEGO (flotante inferior izquierda) */
.btn-float-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1001;
    /* Hereda estilos de .btn y .btn-secondary-yellow */
}

/* Tablero de Cartas */
.game-board {
    display: grid;
    gap: 10px;
    justify-content: center;
    align-content: center;
    width: 100%;
    margin-top: 0;
    perspective: 1000px;
    box-sizing: border-box;
    flex-grow: 1;
}

/* Estilos de las Cartas */
.card-container {
    width: var(--card-size);
    height: var(--card-size);
    position: relative;
    cursor: pointer;
    background-color: transparent;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    transition: transform 0.3s ease-out; /* Mantiene las transiciones existentes para hover */

    /* Estado inicial para la animación de aparición */
    opacity: 0;
    transform: translateY(20px) scale(0.8);
}

/* Animación para cartas apareciendo con efecto de ola */
@keyframes card-appear-wave {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8); /* Empieza un poco abajo y más pequeño */
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1); /* Termina en su posición normal */
    }
}

/* Clase que activa la animación cuando se añade por JavaScript */
.card-container.appear-animation-active {
    animation: card-appear-wave 0.6s ease-out forwards var(--card-appear-delay);
    /* 0.6s de duración, ease-out para un final suave, forwards para mantener el estado final,
       y --card-appear-delay para el retardo individual de cada carta */
}

.card-container:hover {
    transform: scale(1.05);
}

.card {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    border-radius: var(--border-radius);
}

.card.flipped {
    transform: rotateY(180deg);
}

/* Estilo para cartas que se desvanecen al coincidir (aplicado al card-container) */
.card-container.fade-out { 
    animation: fadeAndShrink 0.8s forwards; /* Duración de la animación */
    pointer-events: none; /* Deshabilita clicks inmediatamente */
}

@keyframes fadeAndShrink {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05); /* Efecto de "pop" */
    }
    100% {
        opacity: 0;
        transform: scale(0.8); /* Encoge y desaparece */
        visibility: hidden; /* Asegura que no ocupen espacio pero lo mantienen */
    }
}

/* Animación para cartas no coincidentes */
@keyframes shake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    20%, 60% { transform: rotateY(180deg) translateX(-5px); }
    40%, 80% { transform: rotateY(180deg) translateX(5px); }
}

.card.shake {
    animation: shake 0.4s ease-in-out;
    /* Asegura que la carta se mantenga de frente durante la animación de shake */
    transform: rotateY(180deg); 
}


.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px var(--shadow-color);
}

.card-back {
    background-image: url('assets/images/card-back.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2),
                0 8px 15px rgba(0, 0, 0, 0.3);
}

.card-front {
    background-color: white;
    transform: rotateY(180deg);
    border: 3px solid var(--secondary-color);
    box-shadow: 0 4px 8px var(--shadow-color),
                inset 0 0 10px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-front img {
    /* Mantenemos el ajuste de tamaño para que las imágenes encajen */
    width: 90%;
    height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

/* Avatar Guía - Posicionado arriba a la izquierda y fijo */
.avatar-container {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 1000;
}

.avatar-container img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    background-color: white;
    object-fit: cover;
    box-shadow: 0 5px 15px var(--shadow-color);
    animation: floatUpDown 2s ease-in-out infinite alternate;
    margin-bottom: 10px;
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.avatar-message {
    background-color: white;
    color: var(--text-color);
    padding: 10px 15px;
    border-radius: 20px;
    box-shadow: 0 5px 10px var(--shadow-color);
    max-width: 180px;
    font-size: 0.85em;
    position: relative;
    text-align: left;
    border: 2px solid var(--primary-color);
    font-family: 'Nunito', sans-serif;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.avatar-message.show {
    opacity: 1;
    transform: translateY(0);
}

/* Flecha de la burbuja de mensaje (apuntando hacia arriba, hacia el avatar) */
.avatar-message::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 15px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--primary-color);
    transition: border-bottom-color 0.3s ease;
}

/* Modal de Preguntas */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex; /* Asegura que el modal siempre sea flexbox */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

/* Estilo para el contenido del modal de preguntas (quiz) */
.quiz-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.quiz-content h2 {
    color: var(--primary-color);
    font-size: 2em;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.answer-options button {
    background-color: var(--secondary-color);
    color: var(--text-color);
    padding: 12px 20px;
    border: 2px solid var(--primary-color);
    border-radius: 30px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
}

.answer-options button:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* --- THEME 1: General Quiz (e.g., Blue/Green for educational/nature-like) --- */
.quiz-content.general-quiz-theme {
    background-color: #E0FFF7; /* Light Aqua */
    border: 2px solid #20B2AA; /* Light Sea Green */
    box-shadow: 0 10px 30px rgba(32, 178, 170, 0.3);
}
.quiz-content.general-quiz-theme h2 {
    color: #20B2AA; /* Light Sea Green */
}
.quiz-content.general-quiz-theme .answer-options button {
    background-color: #ADD8E6; /* Light Blue */
    border: 2px solid #6A5ACD; /* Medium Purple */
    color: var(--text-color);
}
.quiz-content.general-quiz-theme .answer-options button:hover {
    background-color: #6A5ACD; /* Medium Purple */
    color: white;
}

/* Dark Mode Overrides for General Quiz Theme */
body.dark-mode .quiz-content.general-quiz-theme {
    background-color: #3D5A7D; /* Darker Muted Blue */
    border: 2px solid #66CDAA; /* Medium Sea Green */
    box-shadow: 0 10px 30px rgba(52, 73, 94, 0.5); /* Stronger shadow in dark mode */
}
body.dark-mode .quiz-content.general-quiz-theme h2 {
    color: #66CDAA; /* Medium Sea Green */
}
body.dark-mode .quiz-content.general-quiz-theme .answer-options button {
    background-color: #5F9EA0; /* Cadet Blue */
    border: 2px solid #34495e; /* Dark Mode Screen Background */
    color: white;
}
body.dark-mode .quiz-content.general-quiz-theme .answer-options button:hover {
    background-color: #3D5A7D; /* Darker Muted Blue */
    color: white;
}


/* --- THEME 2: Fun Quiz (e.g., Pink/Peach for playful/sweet) --- */
.quiz-content.fun-quiz-theme {
    background-color: #FFF0F5; /* Lavender Blush */
    border: 2px solid #FF69B4; /* Hot Pink */
    box-shadow: 0 10px 30px rgba(255, 105, 180, 0.3);
}
.quiz-content.fun-quiz-theme h2 {
    color: #FF69B4; /* Hot Pink */
}
.quiz-content.fun-quiz-theme .answer-options button {
    background-color: #FFDAB9; /* Peach Puff */
    border: 2px solid #FF69B4; /* Hot Pink */
    color: var(--text-color);
}
.quiz-content.fun-quiz-theme .answer-options button:hover {
    background-color: #FF69B4; /* Hot Pink */
    color: white;
}

/* Dark Mode Overrides for Fun Quiz Theme */
body.dark-mode .quiz-content.fun-quiz-theme {
    background-color: #5F405A; /* Darker Muted Pink/Purple */
    border: 2px solid #FFD700; /* Gold */
    box-shadow: 0 10px 30px rgba(95, 64, 90, 0.5);
}
body.dark-mode .quiz-content.fun-quiz-theme h2 {
    color: #FFD700; /* Gold */
}
body.dark-mode .quiz-content.fun-quiz-theme .answer-options button {
    background-color: #C79A9A; /* Muted Rose */
    border: 2px solid #F39C12; /* Dark Mode Primary-like */
    color: white;
}
body.dark-mode .quiz-content.fun-quiz-theme .answer-options button:hover {
    background-color: #F39C12; /* Dark Mode Primary-like */
    color: white;
}

/* Ensure correct/incorrect button styles still apply on top */
.answer-options button.correct {
    background-color: #66BB6A !important;
    color: white !important;
    border-color: #388E3C !important;
}
.answer-options button.incorrect {
    background-color: #EF5350 !important;
    color: white !important;
    border-color: #D32F2F !important;
}


.quiz-result-message {
    margin-top: 20px;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

/* Estilo para el nuevo modal de entrada de nombre */
.name-input-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px var(--shadow-color);
    text-align: center;
    max-width: 350px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.modal.active .name-input-content {
    transform: scale(1);
}

.name-input-content h2 {
    color: var(--primary-color);
    font-size: 2.2em;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.name-input-content p {
    font-family: 'Nunito', sans-serif;
    font-size: 1.2em;
    color: var(--text-color);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.name-input-content #current-final-score {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5em;
    color: var(--accent-color);
    font-weight: bold;
    transition: color 0.3s ease;
}

.name-input-content input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1em;
    text-align: center;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.name-input-content input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1), 0 0 8px rgba(var(--accent-color), 0.5);
}


/* Pantalla de Fin */
#end-screen {
    padding-bottom: 20px;
}
#end-screen h2 {
    font-size: 3em;
    color: var(--accent-color);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

#end-screen p {
    font-size: 1.5em;
    color: var(--text-color);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

#end-screen p span {
    font-size: 1.2em;
    color: var(--primary-color);
    font-weight: bold;
    transition: color 0.3s ease;
}

/* Estilos para la sección de Mejores Puntuaciones */
.high-scores-section {
    width: 80%;
    max-width: 400px;
    margin-top: 30px;
    padding: 15px;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.high-scores-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8em;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    transition: color 0.3s ease;
}

.high-scores-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.high-scores-list li {
    font-family: 'Nunito', sans-serif;
    font-size: 1.1em;
    color: var(--text-color);
    padding: 8px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.high-scores-list li:last-child {
    border-bottom: none;
}

.high-scores-list li strong {
    color: var(--accent-color);
    font-family: 'Fredoka One', cursive;
    font-size: 1.2em;
    transition: color 0.3s ease;
}


/* --- ESTILOS DEL INTERRUPTOR DE TEMA --- */
.theme-toggle-container {
    position: fixed;
    bottom: 20px;
    right: 90px; /* Calcula: Ancho del botón de música (60px) + margen deseado (10px) + 20px (right de la música) = 90px */
    width: 80px; /* Ancho total del contenedor para el interruptor */
    height: 40px; /* Altura total del contenedor */
    display: flex;
    align-items: center;
    justify-content: center; /* Centra el botón del interruptor en el contenedor */
    z-index: 1002;
    transition: all 0.3s ease;
}

.theme-toggle-button {
    width: 80px; /* Ancho del "track" del interruptor */
    height: 40px; /* Altura del "track" del interruptor */
    background-color: black; /* Color inicial (modo oscuro) */
    border-radius: 20px; /* Hace el interruptor redondeado */
    position: relative; /* Para que el thumb se posicione dentro */
    cursor: pointer;
    border: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3), 0 5px 15px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
}

.toggle-thumb {
    width: 36px; /* Tamaño del "pulgar" (círculo blanco) */
    height: 36px;
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 2px; /* Centrar verticalmente: (40px - 36px) / 2 = 2px */
    left: 2px; /* Pequeño padding del borde izquierdo */
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

/* Estado de MODO CLARO para el interruptor */
.theme-toggle-button.light-mode {
    background-color: var(--secondary-color); /* Amarillo/Naranja para modo claro */
}

.theme-toggle-button.light-mode .toggle-thumb {
    /* Mueve el pulgar a la derecha:
       Ancho del track (80) - ancho del thumb (36) - left_inicial (2) = 42px */
    transform: translateX(42px);
}


/* --- ESTILOS DE MODO OSCURO (body.dark-mode) --- */
body.dark-mode {
    background-color: #2c3e50; /* Azul oscuro-gris */
    color: #ecf0f1; /* Texto claro */
}
body.dark-mode .screen {
    background-color: #34495e; /* Un oscuro más suave para los paneles */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
/* Nuevo fondo para la pantalla de inicio en modo oscuro */
body.dark-mode #start-screen {
    background: linear-gradient(135deg, #1A2E3D, #2C3E50); /* Degradado azul-gris oscuro */
    box-shadow: none;
}

body.dark-mode .start-title,
body.dark-mode .quiz-content h2,
body.dark-mode .name-input-content h2,
body.dark-mode .high-scores-title,
body.dark-mode .tutorial-title { /* APLICA TAMBIÉN AL TUTORIAL */
    color: var(--secondary-color); /* Dorado brillante para títulos */
}
body.dark-mode .start-subtitle,
body.dark-mode .name-input-content p,
body.dark-mode #end-screen p,
body.dark-mode .high-scores-list li,
body.dark-mode .tutorial-steps p { /* APLICA TAMBIÉN AL TUTORIAL */
    color: #bdc3c7; /* Gris claro para texto general */
}
body.dark-mode .btn-primary {
    background-color: #4CAF50; /* Verde más vivo para el botón principal */
}
body.dark-mode .btn-primary:hover {
    background-color: #388E3C; /* Verde oscuro en hover */
}
body.dark-mode .btn-secondary-yellow {
    background-color: #f39c12; /* Naranja/Amarillo más oscuro para botones secundarios */
    border-color: #e67e22; /* Borde más oscuro */
    color: #ecf0f1; /* Texto claro */
}
body.dark-mode .btn-secondary-yellow:hover {
    background-color: #e67e22; /* Naranja más oscuro en hover */
}
body.dark-mode .card-front {
    background-color: #444; /* Frente de carta más oscuro */
    border-color: #f39c12; /* Borde naranja */
}
body.dark-mode .avatar-container img {
    border-color: #f39c12; /* Borde naranja para avatar */
    background-color: #34495e; /* Fondo de avatar oscuro */
}
body.dark-mode .avatar-message {
    background-color: #444;
    border-color: #f39c12;
    color: #ecf0f1;
}
body.dark-mode .avatar-message::after {
    border-bottom-color: #f39c12;
}
body.dark-mode .game-header {
    background: linear-gradient(135deg, #e67e22, #f39c12); /* Degradado naranja oscuro */
    border: 3px solid #d35400; /* Borde más oscuro */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(230, 126, 34, 0.5);
}
body.dark-mode .game-header .label {
    color: black; /* CAMBIO: Color negro para las etiquetas en modo oscuro */
}
body.dark-mode .game-header span:not(.label) {
    color: #ecf0f1; /* Texto claro para valores */
}
body.dark-mode .answer-options button {
    background-color: #7f8c8d; /* Gris oscuro para opciones de respuesta */
    border-color: #95a5a6;
    color: #ecf0f1;
}
body.dark-mode .answer-options button:hover {
    background-color: #95a5a6;
}
body.dark-mode .quiz-result-message {
    color: #3498db; /* Azul para mensajes de quiz */
}
body.dark-mode .name-input-content input[type="text"] {
    background-color: #555;
    border-color: #95a5a6;
    color: #ecf0f1;
}
body.dark-mode .name-input-content input[type="text"]:focus {
    border-color: #3498db;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1), 0 0 8px rgba(52, 152, 219, 0.5);
}
body.dark-mode .high-scores-section {
    background-color: #444;
    border-color: #95a5a6;
}
body.dark-mode .high-scores-list li {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
body.dark-mode .high-scores-list li strong {
    color: #3498db;
}

/* --- ESTILOS DEL MODAL DE TUTORIAL (NUEVO) --- */
@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tutorial-content-wrapper {
    background-color: #f8f8f8; /* Fondo claro para el tutorial */
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 600px;
    width: 90%;
    
    /* Estado inicial para la animación */
    opacity: 0;
    transform: translateY(-50px) scale(0.9); 
    
    /* Transiciones para que los cambios de tema y el ocultamiento sean suaves */
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    
    border: 3px solid var(--primary-color); /* Borde con el color primario */
}

/* Aplicar la animación cuando el modal esté activo */
.modal.active .tutorial-content-wrapper {
    animation: slideInFromTop 0.5s ease-out forwards; /* Aplicar animación al estado activo */
}

.tutorial-title {
    font-size: 2.8em;
    color: var(--accent-color); /* Color de acento para el título */
    margin-bottom: 25px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
    transition: color 0.3s ease;
}

.tutorial-steps p {
    font-family: 'Nunito', sans-serif;
    font-size: 1.3em;
    color: var(--text-color);
    margin-bottom: 15px;
    line-height: 1.6;
    transition: color 0.3s ease;
}

.tutorial-ok-button {
    margin-top: 30px;
    /* Hereda estilos de .btn y .btn-primary */
}

/* Estilos de Modo Oscuro para el Tutorial Modal */
body.dark-mode .tutorial-content-wrapper {
    background-color: #3f51b5; /* Fondo azul más oscuro */
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    border: 3px solid #FFD700; /* Borde dorado en modo oscuro */
}
body.dark-mode .tutorial-title {
    color: #FFD700; /* Título dorado en modo oscuro */
}
body.dark-mode .tutorial-steps p {
    color: #e0e0e0; /* Texto más claro para el modo oscuro */
}
body.dark-mode .tutorial-ok-button {
    background-color: #4CAF50; /* Botón primario verde en modo oscuro */
}
body.dark-mode .tutorial-ok-button:hover {
    background-color: #388E3C;
}

/* Estilo para el nuevo botón de tutorial en la pantalla de inicio */
#tutorial-button {
    margin: 0 10px; /* Ajusta el margen si es necesario para separar los botones */
}


/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --card-size: 100px;
    }

    .start-title { font-size: 2.5em; }
    .start-subtitle { font-size: 1.3em; }
    .btn { padding: 12px 25px; font-size: 1.2em; }
    .start-buttons, .end-buttons { gap: 15px; }
    .btn-secondary-yellow { padding: 12px 25px; font-size: 1.2em; }
    .game-header { font-size: 0.9em; padding: 8px 12px; min-width: 140px; top: 10px; right: 10px; }
    .game-header .label { font-size: 1em; }
    .game-header span:not(.label) { font-size: 1.8em; }
    #music-toggle-button { width: 40px; height: 40px; bottom: 15px; right: 15px; }

    /* Responsive para el interruptor de tema en 768px */
    .theme-toggle-container {
        right: 65px; /* 40px (ancho music) + 10px (gap) + 15px (right) = 65px */
        bottom: 15px;
        width: 70px; /* Ancho del contenedor */
        height: 35px; /* Altura del contenedor */
    }
    .theme-toggle-button {
        width: 60px; /* Ancho del track */
        height: 30px; /* Altura del track */
        border-radius: 15px;
    }
    .toggle-thumb {
        width: 26px; /* Tamaño del thumb */
        height: 26px;
        top: 2px; /* (30-26)/2 = 2px */
        left: 2px;
    }
    .theme-toggle-button.light-mode .toggle-thumb {
        transform: translateX(32px); /* 60 (track) - 26 (thumb) - 2 (left) = 32px */
    }


    .btn-float-bottom-left { bottom: 15px; left: 15px; padding: 12px 25px; font-size: 1.2em; }
    #game-container { padding-top: 90px; padding-left: 15px; padding-right: 15px; }
    .avatar-container { top: 10px; left: 10px; }
    .avatar-message { max-width: 130px; font-size: 0.75em; }
    .avatar-message::after { left: 10px; }
    .modal-content { padding: 20px; }
    .quiz-content h2 { font-size: 1.5em; }
    .answer-options button { font-size: 1em; padding: 10px 15px; }
    #end-screen h2 { font-size: 2em; }
    #end-screen p { font-size: 1.2em; }
    .game-board { gap: 8px; }
    .high-scores-title { font-size: 1.5em; }
    .high-scores-list li { font-size: 1em; }
    .name-input-content { padding: 20px; max-width: 300px; }
    .name-input-content h2 { font-size: 1.8em; }
    .name-input-content p { font-size: 1.1em; }
    .name-input-content #current-final-score { font-size: 1.4em; }
    .name-input-content input[type="text"] { padding: 8px; font-size: 1em; }

    /* Tutorial Modal Responsive */
    .tutorial-content-wrapper {
        padding: 30px;
    }
    .tutorial-title {
        font-size: 2.2em;
    }
    .tutorial-steps p {
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    :root { --card-size: 85px; }
    .start-title { font-size: 2em; }
    .start-subtitle { font-size: 1em; }
    .btn { font-size: 1em; }
    .start-buttons, .end-buttons { flex-direction: column; gap: 10px; align-items: center; }
    .btn-secondary-yellow { font-size: 1em; }
    .game-header { font-size: 0.7em; padding: 5px 8px; min-width: 110px; top: 5px; right: 5px; }
    .game-header .label { font-size: 1em; }
    .game-header span:not(.label) { font-size: 1.6em; }
    #music-toggle-button { width: 35px; height: 35px; bottom: 10px; right: 10px; }

    /* Responsive para el interruptor de tema en 480px */
    .theme-toggle-container {
        right: 55px; /* 35px (ancho music) + 10px (gap) + 10px (right) = 55px */
        bottom: 10px;
        width: 60px; /* Ancho del contenedor */
        height: 30px; /* Altura del contenedor */
    }
    .theme-toggle-button {
        width: 50px; /* Ancho del track */
        height: 25px; /* Altura del track */
        border-radius: 12.5px;
    }
    .toggle-thumb {
        width: 21px; /* Tamaño del thumb */
        height: 21px;
        top: 2px; /* (25-21)/2 = 2px */
        left: 2px;
    }
    .theme-toggle-button.light-mode .toggle-thumb {
        transform: translateX(27px); /* 50 (track) - 21 (thumb) - 2 (left) = 27px */
    }


    .btn-float-bottom-left { width: auto; height: auto; padding: 8px 18px; font-size: 0.9em; bottom: 10px; left: 10px; }
    #game-container { padding-top: 70px; padding-left: 10px; padding-right: 10px; }
    .avatar-container { top: 5px; left: 5px; }
    .avatar-container img { width: 60px; height: 60px; }
    .avatar-message { max-width: 110px; font-size: 0.7em; }
    .game-board { gap: 6px; }
    .high-scores-title { font-size: 1.3em; }
    .high-scores-list li { font-size: 0.9em; }
    .name-input-content { padding: 15px; max-width: 280px; }
    .name-input-content h2 { font-size: 1.6em; }
    .name-input-content p { font-size: 1em; }
    .name-input-content #current-final-score { font-size: 1.3em; }
    .name-input-content input[type="text"] { padding: 6px; font-size: 0.9em; }

    /* Tutorial Modal Responsive */
    .tutorial-content-wrapper {
        padding: 20px;
    }
    .tutorial-title {
        font-size: 1.8em;
    }
    .tutorial-steps p {
        font-size: 1em;
    }
}

@media (max-width: 320px) {
    :root { --card-size: 75px; }
    .game-board { gap: 8px; }
}