/* Variables y Tokens de Diseño */
:root {
    --bg-gradient: radial-gradient(circle at 50% 50%, #11251c 0%, #08110d 100%);
    --primary-color: #10b981;
    /* Verde Esmeralda */
    --primary-glow: rgba(16, 185, 129, 0.3);
    --secondary-color: #f59e0b;
    /* Amarillo / Ámbar */
    --secondary-glow: rgba(245, 158, 11, 0.3);
    --danger-color: #ef4444;
    /* Rojo Rubí */
    --danger-glow: rgba(239, 68, 68, 0.3);
    --text-primary: #f3f4f6;
    /* Blanco Hueso */
    --text-muted: #9ca3af;
    /* Gris suave */
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(10, 20, 15, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Quicksand', sans-serif;
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Reset de Estilos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

/* Contenedor Principal */
.app-container {
    width: 100%;
    max-width: 500px;
    min-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    box-shadow: var(--shadow-premium);
    position: relative;
    overflow: hidden;
}

.app-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.app-header {
    z-index: 10;
    text-align: center;
    margin-bottom: 20px;
}

.logo-area {
    display: inline-block;
}

.brand-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--secondary-color), #d97706);
    color: #111;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
    margin-bottom: 8px;
    font-family: var(--font-heading);
}

.main-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

/* Controles (Nivel y Modo) */
.controls-section {
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 25px;
}

/* Selector de Niveles */
.level-selector-wrapper {
    position: relative;
    width: 100%;
}

.level-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 4px;
    position: relative;
    width: 100%;
}

.level-btn {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    z-index: 2;
    transition: var(--transition-smooth);
}

.level-btn.active {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.active-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(33.33% - 4px);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.35));
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 12px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.1);
    z-index: 1;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15);
}

/* Desplazamiento del Indicador */
.level-tabs[data-active-index="0"] .active-indicator {
    transform: translateX(0);
}

.level-tabs[data-active-index="1"] .active-indicator {
    transform: translateX(100%);
}

.level-tabs[data-active-index="2"] .active-indicator {
    transform: translateX(200%);
}

/* Selector de Modo */
.mode-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.mode-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.mode-label.active {
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Switch Slider */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: .4s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s cubic-bezier(0.25, 0.8, 0.25, 1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

input:checked+.slider {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(28px);
    background-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-glow);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Main Workspace (Slider) */
.slider-container {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    z-index: 10;
}

/* Flechas de Navegación */
.nav-btn {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    z-index: 20;
    box-shadow: var(--shadow-premium);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.nav-btn:active {
    transform: scale(0.95);
}

.prev-btn {
    left: -22px;
}

.next-btn {
    right: -22px;
}

.nav-icon {
    width: 24px;
    height: 24px;
}

/* Viewport del Carrusel */
.card-viewport {
    width: 100%;
    overflow: hidden;
    border-radius: 24px;
    padding: 10px 0;
    touch-action: pan-y;
    /* Permite scroll vertical pero captura horizontal */
    user-select: none;
    -webkit-user-select: none;
}

.card-slider {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: transform;
}

/* Tarjeta de Animal */
.animal-card {
    min-width: 100%;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.card-inner {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

/* Contenedor de Imagen de Animal */
.image-container {
    width: 100%;
    aspect-ratio: 1.25 / 1;
    border-radius: 18px;
    overflow: clip;
    position: relative;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition-smooth);
    user-select: none;
    -webkit-user-drag: none;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
    /* Evita que el navegador intente arrastrar la imagen en sí */
    user-select: none;
    -webkit-user-drag: none;
}

/* Hover & Active en la Imagen */
.image-container:hover img {
    transform: scale(1.05);
}

.image-container:active {
    transform: scale(0.98);
}

/* Indicador de Parlante Flotante */
.speaker-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0.9;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.image-container:hover .speaker-overlay {
    background: var(--primary-color);
    box-shadow: 0 0 12px var(--primary-glow);
    transform: scale(1.1);
}

.speaker-icon {
    width: 18px;
    height: 18px;
}

/* Ondulación de Audio al hacer clic */
.audio-ripple {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4), 0 8px 20px rgba(0, 0, 0, 0.3);
    }

    100% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0), 0 8px 20px rgba(0, 0, 0, 0.3);
    }
}

/* Modo Aprender: Textos */
.info-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeInUp 0.5s ease;
}

.animal-english {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 3.5px;
}

.animal-phonetic {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--secondary-color);
    letter-spacing: 3.5px;
}

.animal-spanish {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
    margin-top: 4px;
}

/* Modo Practicar: Inputs de Letras */
.practice-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeInUp 0.5s ease;
}

.letters-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 360px;
}

.letter-input {
    width: 36px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: var(--transition-smooth);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.letter-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px var(--secondary-glow), inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.07);
}

/* Estados de Verificación (Clases JS) */
.practice-section.correct .letter-input {
    border-color: var(--primary-color) !important;
    color: #fff !important;
    background: rgba(16, 185, 129, 0.1) !important;
    box-shadow: 0 0 12px var(--primary-glow) !important;
}

.practice-section.incorrect .letter-input {
    border-color: var(--danger-color) !important;
    color: #fff !important;
    background: rgba(239, 68, 68, 0.1) !important;
    box-shadow: 0 0 12px var(--danger-glow) !important;
}

/* Mensaje de Feedback */
.feedback-msg {
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0;
    transform: translateY(5px);
    transition: var(--transition-smooth);
    padding: 4px 16px;
    border-radius: 20px;
}

.feedback-msg.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-msg.correct {
    color: #fff;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.feedback-msg.incorrect {
    color: #fff;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.feedback-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Animación Vibratoria (Incorrecto) */
.shake {
    animation: shakeAnim 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakeAnim {

    10%,
    90% {
        transform: translate3d(-2px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(4px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-6px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(6px, 0, 0);
    }
}

/* Animación de Celebración (Correcto) */
.bounce {
    animation: bounceAnim 0.6s cubic-bezier(0.25, 0.8, 0.25, 1.4) both;
}

@keyframes bounceAnim {

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

    50% {
        transform: translateY(-12px) scale(1.02);
    }
}

/* Fade In Up para transiciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer / Navegación inferior */
.app-footer {
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

/* Puntos de Paginación */
.pagination-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
    flex-wrap: wrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.dot.active {
    background: var(--primary-color);
    transform: scale(1.3);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Barra de Progreso */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--primary-color), #34d399);
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--primary-glow);
}

.branding-footer {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.6;
    letter-spacing: 0.5px;
}

/* Toast para configuraciones de voz */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(16, 24, 20, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--primary-color);
    padding: 12px 24px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    z-index: 100;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsivo */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .app-container {
        border-radius: 24px;
        min-height: 90vh;
    }

    .main-title {
        font-size: 1.8rem;
    }

    /* En móvil ocultamos las flechas para priorizar el swipe táctil */
    .nav-btn {
        display: none;
    }

    .prev-btn {
        left: -10px;
    }

    .next-btn {
        right: -10px;
    }

    .image-container {
        aspect-ratio: 1.35 / 1;
    }

    .animal-english {
        font-size: 1.8rem;
    }

    .letter-input {
        width: 32px;
        height: 40px;
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .letter-input {
        width: 28px;
        height: 36px;
        font-size: 1.1rem;
        border-radius: 6px;
    }
}