/* CALCULUS ODYSSEY - Cyber-Arcane Math Stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600;700&family=Outfit:wght@300;400;600;800;900&display=swap');

:root {
    --bg-dark: #07090e;
    --bg-card: rgba(15, 23, 42, 0.75);
    --border-glow: rgba(56, 189, 248, 0.25);
    --neon-cyan: #06b6d4;
    --neon-purple: #a855f7;
    --neon-gold: #f59e0b;
    --neon-crimson: #f43f5e;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: #f1f5f9;
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    touch-action: manipulation;
}

/* Tipografía de código / fórmulas */
.font-mono-math {
    font-family: 'Fira Code', monospace;
}

/* Efectos de Brillo Neón */
.glow-cyan {
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.35);
}

.glow-purple {
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.4);
}

.glow-gold {
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.45);
}

.glow-crimson {
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.45);
}

.text-glow-cyan {
    text-shadow: 0 0 12px rgba(6, 182, 212, 0.7);
}

.text-glow-gold {
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.7);
}

/* Glassmorphism Cards */
.glass-panel {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-panel-interactive {
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.15);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel-interactive:hover {
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(6, 182, 212, 0.25);
}

/* Animación Sacudida de Pantalla (Screen Shake) */
.shake-screen {
    animation: shake 0.35s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
    40%, 60% { transform: translate3d(5px, 0, 0); }
}

/* Animación de Pulso de Daño Crítico */
.flash-crit {
    animation: critFlash 0.4s ease-out;
}

@keyframes critFlash {
    0% { background-color: rgba(239, 68, 68, 0.4); }
    100% { background-color: transparent; }
}

/* Animación de Entrada de Fórmulas */
.fade-in-scale {
    animation: fadeInScale 0.28s ease-out forwards;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Floating Boss Avatar */
.floating-boss {
    animation: floatingBoss 3.5s ease-in-out infinite;
}

@keyframes floatingBoss {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(1deg);
    }
}

/* Pulsación de Combo Frenzy */
.combo-pulse {
    animation: comboPulse 0.9s infinite alternate;
}

@keyframes comboPulse {
    from {
        transform: scale(1);
        filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
    }
    to {
        transform: scale(1.08);
        filter: drop-shadow(0 0 18px rgba(239, 68, 68, 0.9));
    }
}

/* Barra de Tiempo Dinámica */
.timer-bar-transition {
    transition: width 0.1s linear, background-color 0.3s ease;
}

/* Estilos de KaTeX en Dark Mode */
.katex {
    font-size: 1.22em !important;
    color: #ffffff !important;
}

.katex-display {
    margin: 0.5em 0 !important;
}

.formula-glow {
    filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.45));
}

/* Botón de Respuesta Interactivo */
.answer-btn {
    transition: all 0.15s ease-out;
    position: relative;
    overflow: hidden;
}

.answer-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: 0.4s;
}

.answer-btn:hover::after {
    left: 100%;
}

.answer-btn:active {
    transform: scale(0.98);
}

/* Scrollbar estilizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
}

::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.6);
}

/* =========================================================================
   OPTIMIZACIONES MÓVILES TOUCH-FIRST & PWA PARA CLOUDFLARE PAGES
   ========================================================================= */

/* Safe Area Insets (iPhone Notches, Dynamic Island & Android Bars) */
.mobile-safe-bottom {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
}

.mobile-safe-top {
    padding-top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
}

/* Tabs de Navegación Inferior Móvil */
.mobile-nav-tab {
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-nav-tab:active {
    transform: scale(0.92);
}

.mobile-nav-tab.active {
    color: #06b6d4 !important;
    background: rgba(6, 182, 212, 0.12);
    border-radius: 0.75rem;
}

.mobile-nav-tab.active span {
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.6));
}

/* Contenedor de Fórmulas Matemáticas con Scroll Horizontal Suave */
.formula-scroll-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 0.25rem 0.5rem;
}

/* Adaptabilidad para Teléfonos Inteligentes (Pantallas de 360px a 640px) */
@media (max-width: 640px) {
    /* KaTeX compacto y centrado */
    .katex {
        font-size: 1.05em !important;
    }
    
    .katex-display {
        margin: 0.35em 0 !important;
    }

    /* Opciones múltiples táctiles: altura ergonómica para pulgares */
    .answer-btn {
        min-height: 52px;
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem;
        touch-action: manipulation;
    }

    .answer-btn:active {
        transform: scale(0.96);
        background-color: rgba(6, 182, 212, 0.15) !important;
    }

    /* Fichas magnéticas de Token Snapping */
    .token-chip-btn {
        min-height: 48px;
        min-width: 54px;
        font-size: 1.15rem;
        touch-action: manipulation;
    }

    .token-chip-btn:active {
        transform: scale(0.92);
    }

    /* Modales de resumen adaptados a pantalla completa móvil */
    .game-modal > div {
        max-height: 90dvh;
        overflow-y: auto;
    }

    /* Botones gigantes de Trap Buster para dos pulgares */
    #trap-buster-screen .grid-cols-2 {
        gap: 0.6rem;
    }

    #trap-buster-screen button {
        touch-action: manipulation;
    }
}
