:root {
    --bg-color: #f8fafc; /* slate-50 */
    --text-color: #1f2937; /* gray-800 */
    --primary-color: #6366f1; /* indigo-500 */
    --primary-dark: #4f46e5; /* indigo-600 */
    --primary-light: #e0e7ff; /* indigo-100 */
    --success-color: #22c55e; /* green-500 */
    --error-color: #ef4444; /* red-500 */
    --card-bg: #ffffff;
    --border-color: #f3f4f6; /* gray-100 */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Utils */
.hidden { display: none !important; }

/* Canvas de Partículas */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* Para asegurar que los contenedores estén sobre las partículas */
.view-container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Animaciones */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    70% { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 30px rgba(99,102,241,0.2); }
    50% { opacity: 0.8; transform: scale(1.02); box-shadow: 0 0 40px rgba(99,102,241,0.4); }
}

.animate-fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }
.animate-pop-in { animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.animate-pulse { animation: pulseGlow 2s infinite; }

/* Contenedores de Vistas */
.view-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* =========================================
   VISTA 1: MENÚ
========================================= */
.menu-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
@media (max-width: 600px) {
    .menu-wrapper { max-width: 90vw; }
}

.center-circle {
    position: absolute;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    width: 25%;
    height: 25%;
    border: 4px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(99,102,241,0.2);
    animation: pulseGlow 3s ease-in-out infinite;
}

.center-circle h1 {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(to bottom right, #312e81, var(--primary-color));
    -webkit-background-clip: text;
    color: transparent;
    letter-spacing: 0.05em;
}
@media (max-width: 600px) { .center-circle h1 { font-size: 1.25rem; } }

.orbit-container {
    position: absolute;
    width: 100%;
    height: 100%;
}

.topic-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    pointer-events: none;
}

.topic-btn {
    pointer-events: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    width: 28%;
    height: 22%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.topic-btn:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-color: #818cf8;
}
.topic-btn:active { transform: scale(0.95); }

.topic-name {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    transition: color 0.3s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.topic-btn:hover .topic-name { color: var(--primary-dark); }

.topic-start {
    font-size: 0.7rem;
    font-weight: 600;
    color: #818cf8;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}
.topic-btn:hover .topic-start { opacity: 1; }

.dashed-circle {
    position: absolute;
    width: 80%;
    height: 80%;
    border: 1px dashed #e5e7eb;
    border-radius: 50%;
    z-index: -1;
    opacity: 0.5;
}


/* =========================================
   VISTA 2: QUIZ
========================================= */
.quiz-card {
    width: 100%;
    max-width: 48rem; /* 3xl */
    background: var(--card-bg);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

.progress-container {
    width: 100%;
    height: 0.5rem;
    background: var(--border-color);
    position: absolute;
    top: 0; left: 0;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(to right, #818cf8, var(--primary-dark));
    transition: width 0.5s ease-out;
    width: 0%;
}

.quiz-header {
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.btn-back {
    position: absolute;
    left: 1rem;
    top: 2rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: all 0.2s;
}
.btn-back:hover {
    color: var(--primary-dark);
    background: var(--primary-light);
}

.quiz-topic-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}
.quiz-counter {
    font-size: 1rem;
    font-weight: 700;
    color: #9ca3af;
}
.current-q {
    color: var(--text-color);
    font-size: 1.125rem;
}

.quiz-body {
    padding: 2.5rem 3.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
@media (max-width: 600px) { .quiz-body { padding: 1.5rem; } }

.question-text {
    font-size: 1.875rem;
    font-weight: 900;
    text-align: center;
    color: var(--text-color);
    margin-bottom: 3rem;
}
@media (max-width: 600px) { .question-text { font-size: 1.25rem; margin-bottom: 2rem; } }

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    width: 100%;
}
@media (max-width: 600px) { .options-grid { grid-template-columns: 1fr; } }

.option-btn {
    width: 100%;
    text-align: left;
    padding: 1.25rem;
    font-size: 1.125rem;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    background: white;
    color: #374151;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    transition: all 0.3s;
}
.option-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: #eef2ff;
}
.option-btn:active:not(:disabled) {
    transform: scale(0.98);
}
.option-btn:disabled {
    cursor: default;
}

.option-content {
    display: flex;
    align-items: center;
}

.option-letter {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #6b7280;
    transition: all 0.3s;
}

/* Estados de respuesta */
.option-btn.selected-correct {
    border-color: var(--success-color);
    background: var(--success-color);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(34, 197, 94, 0.3);
    transform: scale(1.02);
    z-index: 10;
}
.option-btn.selected-wrong {
    border-color: var(--error-color);
    background: var(--error-color);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
    transform: scale(0.98);
    opacity: 0.9;
}
.option-btn.unselected-correct {
    border-color: #4ade80;
    background: #f0fdf4;
    color: #15803d;
}
.option-btn.dimmed {
    border-color: #e5e7eb;
    color: #9ca3af;
    opacity: 0.5;
}
.option-btn.selected-correct .option-letter,
.option-btn.selected-wrong .option-letter,
.option-btn.unselected-correct .option-letter {
    background: rgba(255,255,255,0.2);
    color: inherit;
}
.option-icon {
    width: 24px; height: 24px;
}


/* =========================================
   VISTA 3: RESULTADOS
========================================= */
.result-card {
    width: 100%;
    max-width: 28rem; /* md */
    background: var(--card-bg);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.icon-success {
    width: 5rem; height: 5rem;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.result-title {
    font-size: 2.25rem;
    font-weight: 900;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}
.result-subtitle {
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 2rem;
}

.score-card {
    width: 100%;
    background: linear-gradient(to bottom right, #eef2ff, #e0e7ff);
    border: 2px solid #c7d2fe;
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.score-glow {
    position: absolute;
    top: 0; right: 0;
    margin-top: -1rem; margin-right: -1rem;
    width: 6rem; height: 6rem;
    background: var(--primary-color);
    opacity: 0.1;
    border-radius: 50%;
    filter: blur(20px);
}
.score-label {
    font-size: 0.875rem;
    color: #3730a3;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}
.score-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
}
.score-big {
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--primary-dark);
    text-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.score-small {
    font-size: 1.875rem;
    color: #818cf8;
    font-weight: 700;
    margin-left: 0.25rem;
}
.score-message {
    margin-top: 1rem;
    color: #4338ca;
    font-weight: 500;
}

.qr-section {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.qr-box {
    width: 7rem; height: 7rem;
    border: 4px dashed #d1d5db;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: #f9fafb;
    margin-bottom: 0.75rem;
    transition: all 0.3s;
}
.qr-section:hover .qr-box {
    border-color: #818cf8;
    color: var(--primary-color);
    background: #eef2ff;
    transform: scale(1.05);
}
.qr-text {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    transition: color 0.3s;
}
.qr-section:hover .qr-text { color: var(--primary-dark); }

.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: #111827;
    color: white;
    padding: 1rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 1.125rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 20px 25px -5px rgba(17, 24, 39, 0.2);
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.3);
}
.btn-primary:active { transform: scale(0.95); }
.btn-primary:hover .btn-icon { transform: rotate(-180deg); }
.btn-icon { transition: transform 0.5s; }
