:root {
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary-color: #a855f7;
    --secondary-glow: rgba(168, 85, 247, 0.5);
    --accent-color: #ec4899;
    --background-bg: #0b0f19;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background-bg);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden; /* Impide scroll horizontal global */
    width: 100%;
    max-width: 100vw;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Ambient Background Glows */
body::before, body::after {
    content: '';
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    z-index: -1;
    filter: blur(120px);
    opacity: 0.4;
    animation: drift 20s infinite alternate ease-in-out;
}

body::before {
    top: -100px;
    left: -100px;
    background: radial-gradient(circle, var(--primary-color), transparent 60%);
}

body::after {
    bottom: -100px;
    right: -100px;
    background: radial-gradient(circle, var(--secondary-color), transparent 60%);
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Header & Glassmorphism */
header {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--card-border);
    padding: 1.2rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.brand {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand::before {
    content: '⚛';
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: spin 10s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* Layout */
.container {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    width: 100%;
    flex: 1;
    box-sizing: border-box;
}

/* User Status */
.user-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 0 0 15px var(--primary-glow);
    border: 2px solid rgba(255,255,255,0.2);
}

/* Progress Bar */
.progress-bar-container {
    width: 160px;
    height: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.05);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    box-shadow: 0 0 10px var(--success-glow);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
}

/* Premium Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    margin-bottom: 2.5rem;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

/* Add a subtle shine to cards */
.card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.03), transparent);
    transform: skewX(-20deg);
    animation: shine 8s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

h1, h2, h3 {
    margin-top: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

h1 { font-size: 2.5rem; background: linear-gradient(to right, #fff, var(--text-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Dynamic Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.8rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.05rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px var(--secondary-glow);
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(1px); }

/* Inputs */
.input-group { margin-bottom: 1.8rem; }
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
    box-sizing: border-box;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Feedback Box (Skinnerian Reinforcement) */
.feedback {
    margin-top: 1.5rem;
    padding: 1.2rem 1.5rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
}

.feedback::before {
    font-size: 1.5rem;
    display: block;
}

.feedback.correct, .feedback.positive, .feedback.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
    box-shadow: 0 0 20px var(--success-glow);
}
/* Sin ::before emoji — el template ya muestra el ícono explícitamente */
.feedback.correct::before, .feedback.positive::before { content: ''; display: none; }
.feedback.success::before { content: ''; display: none; }

.feedback.incorrect, .feedback.corrective {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    box-shadow: 0 0 20px var(--error-glow);
}
.feedback.incorrect::before, .feedback.corrective::before { content: '💡'; }

.feedback.positive { animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.feedback.corrective { animation: gentleShake 0.6s; }

@keyframes popIn {
    0% { transform: scale(0.9) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes gentleShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

@keyframes pulseScale {
    from { transform: scale(1); }
    to { transform: scale(1.2); }
}

/* Selection Mode (MC) */
.mc-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

@media(min-width: 600px) {
    .mc-options { grid-template-columns: 1fr 1fr; }
}

.mc-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
    position: relative;
    overflow: hidden;
}

.mc-option:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.mc-option input[type="radio"] {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.mc-option input[type="radio"]:checked {
    border-color: var(--primary-color);
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
}

.mc-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 8px; height: 8px;
    background: white;
    border-radius: 50%;
}

.mc-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.mc-option:has(input:checked) span {
    color: #fff;
    font-weight: 700;
}

/* Gamification Toasts & Modals */
.xp-toast {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 1.2rem 2.5rem;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: 800;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.4), inset 0 2px 0 rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.2);
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.xp-toast::before { content: '🌟'; }

.xp-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-secondary); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--background-bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* General links */
a { color: var(--primary-color); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--secondary-color); text-decoration: underline; }

/* ── Responsive Navbar (Móvil) ───────────────────────────────────────────── */
@media (max-width: 640px) {
    header {
        padding: 0.5rem 1rem;
    }

    .navbar {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: space-between;
        align-items: center;
    }

    .brand {
        font-size: 1.2rem;
    }

    .brand::before {
        font-size: 1.4rem;
    }

    /* Ocultar barra de progreso en móvil para ahorrar espacio */
    .progress-bar-container {
        display: none;
    }

    .user-status {
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .avatar-container {
        gap: 0.4rem;
    }

    /* Nombre de usuario más corto en móvil */
    .user-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.78rem;
    }

    .avatar {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }

    /* Botón Dashboard compacto en móvil */
    .avatar-container > a {
        font-size: 0.75rem !important;
        padding: 0.2rem 0.5rem !important;
        margin-right: 0.3rem !important;
    }
}