:root {
    /* Colores Core de la Marca */
    --bg-base: #E8E5D9;
    --bg-surface: #F4F1E1;
    --color-red: #CC3300;
    --color-blue: #336699;
    --color-yellow: #CC9900;
    --text-main: #1A1A1A;
    --text-dim: #666666;
    --border-heavy: #1A1A1A;

    /* Mapeo para la estructura de la App */
    --bg-color: var(--bg-base);
    --text-primary: var(--text-main);
    --text-secondary: var(--text-dim);
    --accent-primary: var(--color-red);
    --error-color: var(--color-red);
    --success-color: var(--color-blue);
    /* Usamos el azul corporativo para los aciertos */
    --radius-md: 12px;
    --border-thickness: 3px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "dunkel-sans-cond-rounded", sans-serif;
    font-weight: 700; /* Prueba con 400 (normal), 700 (bold) o 900 (black) */
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.2;
}

.screen {
    width: 100%;
    max-width: 480px;
    padding: 20px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Clase para reservar espacio sin afectar la estructura y evitar clics */
.invisible {
    visibility: hidden !important;
    opacity: 0;
    pointer-events: none;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-weight: bold;
    color: var(--text-secondary);
}

.song-metadata {
    font-size: 0.9rem;
    color: var(--text-primary);
    /* Cambiamos a negro oscuro para mejor lectura */
    margin-bottom: 10px;
    font-style: normal;
    /* Adiós a la cursiva */
    font-weight: 900;
    /* Hola al grosor "Cómic" del resto de la app */
    text-transform: uppercase;
    /* Mayúsculas para darle formato de etiqueta oficial */
    letter-spacing: 1px;
    /* Un pequeño respiro entre letras */
}

.translation-text {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 10px 0 30px 0;
    min-height: 3em;
    line-height: 1.4;
    font-weight: 700;
}

/* NUEVA CLASE: Resaltado dinámico desde JS */
.highlight-guide {
    color: var(--accent-primary);
    font-weight: 900;
    border-bottom: 2px dashed var(--accent-primary);
    padding: 0 2px;
}

.drop-zone-container,
.tiles-container {
    min-height: 80px;
    margin: 20px 0;
    padding: 15px;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* --- DDA UI (Día 9 - Gamificación) --- */
.drop-zone-container,
.tiles-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    /* Magia para el Nivel 5: espaciado perfecto sin romper la línea */
    min-height: 80px;
    margin: 20px 0;
    padding: 15px;
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* --- TABLERO Y HUECOS DE JUEGO (ESTILO CÓMIC) --- */
.drop-zone {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 70px;
    height: 40px;
    border: 2px dashed var(--text-secondary);
    border-radius: 8px;
    margin: 0 4px;
    background: rgba(0, 0, 0, 0.05);
    font-weight: 900;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.drop-zone.filled {
    border: var(--border-thickness) solid var(--border-heavy);
    border-bottom: 5px solid var(--border-heavy);
    background-color: var(--color-yellow);
    color: var(--text-primary);
    border-style: solid;
}

.drop-zone.success {
    background-color: var(--color-blue);
    color: white;
    border-color: var(--border-heavy);
}

.drop-zone.error {
    background-color: var(--color-red);
    color: white;
    border-color: var(--border-heavy);
    animation: shake 0.4s ease-in-out;
}

.word-visible {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.5;
}

/* --- BOTONES Y FICHAS (ESTILO CÓMIC UNIFICADO) --- */
.btn-auth,
.btn-lang,
.tile-btn,
.guest-start {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 900;
    font-size: 1.1rem;
    padding: 12px 20px;
    border: var(--border-thickness) solid var(--border-heavy);
    border-bottom: 6px solid var(--border-heavy);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    cursor: pointer;
    transition: transform 0.1s, border-width 0.1s;
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    /* Aplica para los de Auth */
}

/* Ajuste específico para que las fichas y langs no ocupen el 100% */
.tile-btn,
.btn-lang {
    width: auto;
}

.btn-auth:active,
.btn-lang:active,
.tile-btn:active,
.guest-start:active {
    transform: translateY(3px);
    border-bottom-width: var(--border-thickness);
}

.btn-lang.selected,
#btn-google {
    background-color: var(--color-red);
    color: white;
}

.guest-start {
    background-color: var(--color-blue);
    color: white;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

/* =========================================
   DÍA 10: RESPONSIVIDAD Y AJUSTES MÓVILES
========================================= */

@media (max-width: 480px) {
    .screen {
        padding: 15px 20px; /* Aumentamos el padding lateral para evitar que toque los bordes */
    }

    .translation-text {
        font-size: 1.3rem;
        margin: 5px 0 20px 0;
        padding: 0 10px; /* Respiro lateral extra para la frase */
    }

    .drop-zone-container,
    .tiles-container {
        width: 94%; /* Evitamos que ocupe el 100% del espacio */
        margin: 15px auto; /* Lo centramos automáticamente */
        padding: 12px 10px;
        gap: 6px;
        /* Reducimos el gap para que quepan 5 huecos en móviles */
    }

    .drop-zone {
        min-width: 60px;
        height: 38px;
        font-size: 1rem;
    }

   .word-visible {
        font-size: 1rem;
    }

    .tile-btn {
        padding: 10px 16px;
        font-size: 1rem;
        margin-bottom: 2px;
    }
}

/* Ajuste crítico de altura (Evita que el juego se rompa si la pantalla es muy chata) */
@media (max-height: 650px) {
    body {
        align-items: flex-start;
        /* Anula el center vertical para poder scrollear si es necesario */
        padding-top: 15px;
    }

    .translation-text {
        min-height: auto;
        margin-bottom: 10px;
    }
}

/* =========================================
   DÍA 13: TOAST NOTIFICATION Y GAME OVER
========================================= */

.toast {
    position: fixed;
    right: -200px;
    /* Oculto fuera de la pantalla */
    top: 20px;
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    padding: 15px 25px;
    border-left: 4px solid var(--success-color);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.4);
    font-weight: bold;
    font-size: 1.1rem;
    transition: right 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    right: 0;
    /* Desliza hacia adentro */
}

.toast.level-down {
    border-left-color: var(--error-color);
}

.final-streak {
    margin: 30px 0;
    font-size: 1.5rem;
    color: var(--accent-primary);
}

/* =========================================
   DÍA 16: PANTALLA UNIFICADA ONBOARDING
========================================= */
.logo-container h1 {
    font-size: 2.6rem; /* Hacemos el título más imponente para llenar el espacio superior */
}

.onboarding-flow {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 60px;       /* Aumentamos al doble la separación entre los pasos 1 y 2 */
    margin-top: 50px; /* Separamos más las opciones del título principal */
}

.step-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Fila de idiomas (Horizontal) */
.lang-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.lang-row .btn-lang {
    flex: 1;
    /* Para que midan lo mismo */
    padding: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

/* El idioma seleccionado brilla */
.lang-row .btn-lang.selected {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background-color: rgba(226, 54, 112, 0.1);
}

/* Botones de Acceso */
.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.btn-auth.google {
    background-color: #ffffff;
    color: #333333;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-auth.google .g-icon {
    color: #4285F4;
    font-size: 1.2rem;
}

/* --- Formulario Integrado de Invitado --- */
.guest-input {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 1.05rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.guest-input:focus {
    border-color: var(--accent-primary);
}

.btn-auth.guest-start {
    background-color: var(--accent-primary);
    color: white;
}

/* =========================================
   DÍA 18: LEADERBOARD ITEMS
========================================= */
.lb-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.1rem;
    color: var(--text-primary);
}

.lb-item:last-child {
    border-bottom: none;
}

.lb-item.top-1 {
    color: #FFD700;
    font-weight: 900;
    transform: scale(1.05);
}

/* Oro */
.lb-item.top-2 {
    color: #C0C0C0;
    font-weight: bold;
}

/* Plata */
.lb-item.top-3 {
    color: #CD7F32;
    font-weight: bold;
}

/* Bronce */

/* =========================================
   DÍA 20: MODO OFFLINE
========================================= */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--color-red);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 3000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.offline-banner.hidden-offline {
    transform: translateY(-150%);
}

/* --- BOTÓN LEADERBOARD SUPERIOR --- */
.btn-lb-top {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--color-yellow);
    color: var(--text-primary);
    font-weight: 900;
    font-size: 0.85rem;
    padding: 6px 12px;
    border: var(--border-thickness) solid var(--border-heavy);
    border-bottom: 4px solid var(--border-heavy);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, border-width 0.1s;
    text-transform: uppercase;
}

.btn-lb-top:active {
    transform: translateY(2px);
    border-bottom-width: var(--border-thickness);
}

.trophy-icon {
    width: 16px;
    height: 16px;
}

/* =========================================
   DÍA 23: BOTÓN DE AUDIO (AYUDA)
========================================= */
.btn-audio-clue {
    background-color: var(--color-blue);
    width: 38px;
    /* <-- Reducido a dieta */
    height: 38px;
    /* <-- Reducido a dieta */
    border-radius: 50%;
    border: 2px solid var(--border-heavy);
    /* <-- Borde más fino proporcional al tamaño */
    border-bottom: 4px solid var(--border-heavy);
    /* <-- Sombra inferior reducida */
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s, border-width 0.1s, background-color 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.btn-audio-clue:active:not(:disabled) {
    transform: translateY(3px);
    border-bottom-width: var(--border-thickness);
}

/* Estado bloqueado temporalmente (Cargando o Reproduciendo) */
.btn-audio-clue:disabled {
    cursor: wait;
    opacity: 0.9;
}

/* NUEVO: Forzar reducción de los íconos SVG y textos internos */
.btn-audio-clue svg {
    width: 18px !important;
    height: 18px !important;
}

#audio-icon-load {
    font-size: 1rem !important;
    letter-spacing: 1px !important;
}

#audio-error-text {
    font-size: 0.7rem !important;
}

/* Animación sutil para los puntos de carga */
@keyframes pulse-load {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

#audio-icon-load {
    animation: pulse-load 1s infinite ease-in-out;
}

/* Estado del botón cuando el audio falla (Día 1) */
.btn-audio-unavailable {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-blue) !important;
    /* Mantener color de audio */
    color: white !important;
    font-weight: 900;
    font-size: 0.75rem !important;
    padding: 6px 15px !important;
    border: var(--border-thickness) solid var(--border-heavy) !important;
    border-bottom: 4px solid var(--border-heavy) !important;
    border-radius: 8px !important;
    /* Forma rectangular como el Premium */
    text-transform: uppercase;
    cursor: default;
    width: auto !important;
    height: auto !important;
}

/* Animación de vibración (Shake) */
@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    50% {
        transform: translateX(8px);
    }

    75% {
        transform: translateX(-8px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Clase que aplicaremos cuando haya error */
.input-error {
    border: 2px solid #CC3300 !important;
    animation: shake 0.4s ease-in-out;
}

/* Estilo del mensajito debajo del input */
.error-helper {
    color: #CC3300;
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 5px;
    display: block;
}

/* =========================================
   MÓDULO DE ESTUDIO (FLASHCARDS 3D)
========================================= */

/* Ajuste del nuevo Header en 3 columnas */
.header-col {
    flex: 1;
}
.header-col.center {
    text-align: center;
}
.header-col.right {
    text-align: right;
}

/* Contenedor principal de la tarjeta */
.flashcard {
    background-color: transparent;
    width: 140px; 
    height: 48px; /* Altura unificada solicitada */
    perspective: 1000px; 
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Capa interna que gira */
.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

/* Rotación al agregar la clase 'flipped' desde JS */
.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

/* Caras de la tarjeta (Frente y Dorso) */
.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; 
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    font-weight: 900;
    font-size: 1rem;
    border: 3px solid var(--text-main);
    border-bottom: 6px solid var(--text-main); 
    transition: border-color 0.3s, color 0.3s;
}

/* Diseño del Frente (Beige y Negro) */
.flashcard-front {
    background-color: var(--bg-base);
    color: var(--text-main);
}

/* Diseño del Dorso (Beige y Negro, inicia girado) */
.flashcard-back {
    background-color: var(--bg-base);
    color: var(--text-main);
    transform: rotateY(180deg); 
}

/* --- ESTADOS DE VALIDACIÓN --- */
.flashcard.correct .flashcard-front,
.flashcard.correct .flashcard-back {
    border-color: var(--color-blue);
    border-bottom-color: var(--color-blue);
    color: var(--color-blue);
}

.flashcard.incorrect .flashcard-front,
.flashcard.incorrect .flashcard-back {
    border-color: var(--color-red);
    border-bottom-color: var(--color-red);
    color: var(--color-red);
}

.flashcard.processing .flashcard-front,
.flashcard.processing .flashcard-back {
    border-color: var(--color-yellow);
    border-bottom-color: var(--color-yellow);
}

/* --- ANIMACIÓN AL GUARDAR UNA PALABRA --- */
@keyframes pop-save {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); color: var(--color-yellow); border-color: var(--color-yellow); }
    100% { transform: scale(1); }
}

.word-saved {
    animation: pop-save 0.4s ease-out forwards;
    pointer-events: none; 
}

/* Altura unificada de fichas según Mapa de Ruta */
.tile-btn, .drop-zone {
    height: 48px !important; 
}

/* Contenedor de perspectiva para el giro 3D */
#active-card-container {
    perspective: 1000px;
    touch-action: none; /* Evita el scroll del navegador al arrastrar */
}

/* La tarjeta ahora tiene dos caras */
.single-flashcard {
    width: 100%;
    max-width: 320px;
    height: 220px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease, border-color 0.3s ease;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none; /* Bloquea la selección de texto en iOS */
    -webkit-touch-callout: none; /* Bloquea el menú contextual en iOS */
}

.single-flashcard:active { cursor: grabbing; }

/* Caras de la tarjeta */
.fc-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    border: 4px solid var(--border-heavy);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1);
    padding: 20px;
}

/* Cara Frontal (Palabra) */
.fc-front {
    background-color: var(--bg-surface);
    z-index: 2;
}

/* Cara Trasera (Traducción - Amarilla) */
.fc-back {
    background-color: var(--color-yellow);
    transform: rotateY(180deg);
    z-index: 1;
}

/* Clase para el giro */
.single-flashcard.flipped {
    transform: rotateY(180deg);
}

/* Textos */
.fc-word, .fc-translation {
    font-weight: 900;
    font-size: 2rem;
    text-align: center;
    color: var(--text-primary);
}

/* Barra de Maestría dentro de las caras */
.fc-mastery-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.fc-mastery-fill {
    height: 100%;
    background: var(--color-blue);
}

/* =========================================================
   PANTALLA DE CARGA (SPLASH SCREEN)
   ========================================================= */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-base, #F3EFE6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-in-out;
}

#splash-screen svg {
    width: 200px;
    height: auto;
}

/* Animación inyectada a la caja principal */
.logo-vector {
    color: #cc9900; /* Inicia en el Amarillo oficial */
    fill-rule: evenodd;
    animation: cicloColores 1s ease-in-out forwards;
}

/* Transición con los colores exactos */
@keyframes cicloColores {
    0%   { color: #cc9900; } 
    50%  { color: #cc3300; } 
    100% { color: #336699; } 
}

/* Clase de apoyo para ocultar la app al inicio */
.oculto {
    display: none !important;
}

/* =========================================
   HUB: MENÚ PRINCIPAL Y LOOP DE COLORES
========================================= */
.menu-logo-container {
    width: 180px;
    margin: 40px auto 50px auto; /* 40px arriba para bajarlo, 50px abajo para separarlo del saludo */
    display: flex;
    justify-content: center;
}

.logo-vector-infinite {
    width: 100%;
    height: auto;
    fill: currentColor; /* Hereda el color de la animación */
    animation: colorLoop 4s infinite alternate ease-in-out;
}

/* Loop infinito entre Amarillo Dorado, Rojo Oscuro y Azul Profundo */
@keyframes colorLoop {
    0% { color: #CC9900; }   
    50% { color: #cc3300; }  
    100% { color: #336699; } 
}

@keyframes strokeLoop {
    0% { stroke: #000000; }
    50% { stroke: #ffffff; }
    100% { stroke: #ffffff; }
}

.menu-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.menu-section-box {
    background: var(--bg-surface);
    padding: 20px 15px;
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-heavy);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1);
    text-align: center;
}

/* Ajuste para los subtítulos de los botones de estudio */
#btn-menu-flashcards small,
#btn-menu-glossary small {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 4px;
    opacity: 0.8;
}

/* --- ALERTA VISUAL: SELECCIÓN DE IDIOMA --- */
@keyframes shake-yellow {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.lang-alert-yellow {
    animation: shake-yellow 0.4s ease-in-out;
    border-color: var(--color-yellow) !important;
    color: var(--color-yellow) !important;
    background-color: rgba(204, 153, 0, 0.1) !important;
}
/* Estilos para la estrella y tarjetas de favoritos */
#btn-fav-star.active {
    color: var(--color-yellow) !important;
    transform: scale(1.2);
    filter: drop-shadow(0 0 5px rgba(204, 153, 0, 0.4));
}

.fav-card {
    background: var(--bg-surface);
    padding: 15px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-heavy);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.fav-content {
    flex: 1;
}

.fav-phrase {
    font-weight: 900;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.fav-translation {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.btn-fav-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-heavy);
    background: var(--color-blue);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.btn-fav-delete {
    background: none;
    border: none;
    color: var(--color-red);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* --- PANTALLA DE MEMORY --- */
#screen-memory {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Tablero de 2x5 */
.memory-board {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columnas */
    grid-template-rows: repeat(5, 1fr);    /* 5 filas */
    gap: 12px;
    width: 100%;
    max-width: 350px;
    margin: 20px auto;
    perspective: 1000px; /* Necesario para el efecto 3D */
}

/* Iconos de Vida */
.life-icon {
    transition: filter 0.3s ease, transform 0.3s ease;
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.1));
}

/* Efecto para vida perdida */
.life-icon.lost {
    filter: grayscale(100%) opacity(0.3);
    transform: scale(0.8);
}

/* ESTILO DE LAS CARTAS (Para el futuro app.js) */
.memory-card {
    height: 60px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
}

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid var(--border-heavy);
    border-radius: 8px;
    font-weight: 900;
    font-size: 0.9rem;
    padding: 5px;
}

/* Reverso (Lo que se ve al inicio) */
.card-back {
    background-color: var(--bg-surface);
    color: var(--color-blue);
}

/* Frente (La palabra revelada) */
.card-front {
    background-color: #CC9900;
    transform: rotateY(180deg);
}

/* Estados de acierto y error */
.memory-card.matched .card-front {
    background-color: var(--color-blue);
    color: white;
    border-color: var(--border-heavy);
}

.memory-card.wrong .card-front {
    animation: flash-red 0.5s;
}

@keyframes flash-red {
    0%, 100% { background-color: white; }
    50% { background-color: var(--color-red); color: white; }
}

/* Animación de advertencia para los logos de vida */
@keyframes shake-life {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-5deg); }
    75% { transform: translateX(5px) rotate(5deg); }
}

.life-icon.warning {
    animation: shake-life 0.3s ease-in-out;
    color: var(--color-yellow) !important;
    filter: drop-shadow(0 0 8px rgba(204, 153, 0, 0.6));
}

/* =========================================
   CUSTOMIZATION ROOM (BACHATAMAN)
========================================= */

/* =========================================
   CUSTOMIZATION ROOM (CORRECCIONES DISEÑO)
========================================= */

/* Paleta de Colores Fija (Grid) */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 15px;
    background-color: var(--bg-surface);
    border: var(--border-thickness) solid var(--border-heavy);
    border-radius: var(--radius-md);
    box-shadow: inset 0px 4px 0px rgba(0,0,0,0.1);
}

.color-swatch {
    width: 45px; /* Tamaño ajustado para caber mejor */
    height: 45px;
    border-radius: 50%;
    border: var(--border-thickness) solid var(--border-heavy);
    box-shadow: 0px 3px 0px var(--border-heavy);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.color-swatch:active {
    transform: translateY(3px);
    box-shadow: 0px 0px 0px var(--border-heavy);
}

/* Iconos Minimalistas en Pestañas */
.layers-row button.tab-layer {
    background: none;
    border: none;
    padding: 10px;
    opacity: 0.5;
    transition: all 0.2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.layers-row button.tab-layer.selected {
    opacity: 1;
    transform: scale(1.15);
}

.layers-row button.tab-layer .icon-ui {
    width: 32px;
    height: 32px;
    fill: var(--text-primary);
}

/* =========================================
   MINIJUEGO BACHATAMAN (WORD CLOCK)
========================================= */
.bachataman-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    touch-action: none; /* Vital para evitar el scroll al arrastrar */
}

.circle-area {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.b-word-bubble {
    position: absolute;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-weight: 900;
    font-size: 1.1rem; 
    color: var(--color-blue);
    user-select: none;
    white-space: nowrap;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.bachataman-sprite {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--color-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-surface);
    z-index: 10;
    cursor: grab;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.bachataman-sprite:active {
    cursor: grabbing;
}

/* Efecto suave para cuando el jugador suelta al personaje */
.bachataman-sprite.returning {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- ESTADOS DE VALIDACIÓN BACHATAMAN --- */
.b-word-bubble {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Cuando una palabra es recolectada con éxito */
.b-word-bubble.collected {
    transform: scale(0) !important;
    opacity: 0;
    pointer-events: none;
}

/* Cuando el hueco de la frase se llena */
.b-slot.filled {
    color: var(--color-blue);
    border-bottom-color: var(--color-blue);
}

/* Temblor de error al chocar con la palabra equivocada */
.bachataman-sprite.error-shake {
    animation: b-shake-error 0.4s ease-in-out;
    border-color: var(--color-red) !important;
    background-color: rgba(204, 51, 0, 0.1);
}

@keyframes b-shake-error {
    0%, 100% { transform: translate(0, 0); }
    20%, 60% { transform: translate(-8px, 0); }
    40%, 80% { transform: translate(8px, 0); }
}

/* --- SISTEMA DE CONSTRUCCIÓN DINÁMICA (SIN GUIONES) --- */
.b-slot-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: b-pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Efecto de rebote al aparecer */
}

.b-slot {
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--color-blue);
    padding: 0 4px;
    /* Adiós a los bordes y anchos mínimos */
}

.b-slot-translation {
    font-size: 0.85rem;
    color: var(--color-red);
    font-weight: 900;
}

@keyframes b-pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- ANIMACIÓN ICONOS MATERIAL SYMBOLS --- */
.animated-back-icon {
    font-size: 1.2rem;
    vertical-align: middle;
    animation: colorLoop 4s infinite alternate ease-in-out;
}

/* --- ANIMACIÓN ICONOS GENÉRICA --- */
.animated-icon {
    font-size: 1.2rem;
    vertical-align: text-bottom;
    animation: colorLoop 4s infinite alternate ease-in-out;
}

/* =========================================
   FRASE DEL JUEGO DE MEMORIA
========================================= */
.memory-phrase-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 8px 6px;
    margin: 10px 0 25px 0;
    padding: 0 10px;
    min-height: 3em;
}

.memory-word-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.memory-word-es {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 700;
}

.memory-word-tr {
    font-size: 0.73rem; /* 2/3 de 1.1rem */
    color: transparent; /* Oculto por defecto */
    font-weight: 900;
    min-height: 1.2em; /* Reserva el espacio vertical */
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.memory-word-tr.revealed {
    color: var(--color-red);
    animation: b-pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Animación de Batería Vacía para Bachataman */
@keyframes pulse-battery {
    0% { box-shadow: 0 0 0 0 rgba(204, 51, 0, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(204, 51, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(204, 51, 0, 0); }
}

/* --- ANIMACIÓN DE CARGA BACHATAMAN --- */
.loading-b-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.loading-b-icon {
    width: 24px;
    height: 24px;
    opacity: 0;
    animation: b-loader-bounce 1.5s infinite ease-in-out, colorLoop 4s infinite alternate ease-in-out;
}

.loading-b-icon:nth-child(1) { animation-delay: 0s, 0s; }
.loading-b-icon:nth-child(2) { animation-delay: 0.2s, 0s; }
.loading-b-icon:nth-child(3) { animation-delay: 0.4s, 0s; }

@keyframes b-loader-bounce {
    0%, 100% { transform: scale(0.6); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* Clase para hacer el botón transparente durante la animación de carga */
.btn-transparent-loading {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* --- TABLA COMPARATIVA PREMIUM --- */
.premium-comparison-table {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
}

.comp-col {
    flex: 1;
    background: var(--bg-surface);
    border: 2px solid var(--border-heavy);
    border-radius: var(--radius-md);
    padding: 15px 10px;
    text-align: left;
}

.comp-col.pro-col {
    border-color: var(--color-yellow);
    border-bottom: 5px solid var(--color-yellow);
    background: rgba(204, 153, 0, 0.05);
}

.tier-title {
    text-align: center;
    font-weight: 900;
    margin-bottom: 10px;
    color: var(--text-dim);
}

.tier-features {
    list-style: none;
    padding: 0;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-primary);
}

.tier-features li {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    line-height: 1.2;
}

.premium-footnote {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: bold;
    margin-bottom: 10px;
    text-align: left;
    line-height: 1.3;
}

/* --- FORZAR RENDERIZADO DE MATERIAL SYMBOLS --- */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal !important;
    font-style: normal !important;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none !important;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga' !important;
    -webkit-font-feature-settings: 'liga' !important;
    -webkit-font-smoothing: antialiased;
}