/* ================= GLOBAL CUSTOM VARIABLE ENGINE ================= */
:root {
    --font-primary: 'Poppins', sans-serif;
    --bg-gradient: radial-gradient(circle at 15% 10%, #fdf2f4 0%, transparent 45%),
                   radial-gradient(circle at 85% 0%, #eef1ff 0%, transparent 50%),
                   linear-gradient(160deg, #ffffff 0%, #f4f6fb 45%, #eef1fb 100%);
    --panel-glass: rgba(255, 255, 255, 0.72);
    --panel-border: rgba(255, 255, 255, 0.65);
    --shadow-premium: 0 10px 36px -4px rgba(31, 38, 135, 0.10);
    --shadow-glow: 0 0 24px rgba(90, 145, 255, 0.32);

    /* Branding Accent Colors */
    --color-primary: #4a77ff;
    --color-primary-hover: #3562eb;
    --color-secondary: #ffffff;
    --color-accent: #9d4edd;
    --color-text-dark: #20222f;
    --color-text-muted: #6c7280;
    --color-success: #2ec4b6;
    --color-error: #e63946;

    /* Quiz card accent (red boxes) */
    --color-quiz-1: #ef233c;
    --color-quiz-2: #d00000;
    --shadow-quiz: 0 12px 28px -6px rgba(208, 0, 0, 0.45);

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================= THEME CORE & RESET ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-gradient);
    color: var(--color-text-dark);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    transition: background 0.6s ease;
}

/* Immersive full-screen quiz mode: darker, more focused, distraction-free */
body.quiz-active {
    background: radial-gradient(circle at 50% 0%, #1b1035 0%, #0d0a1f 55%, #070512 100%);
}
body.quiz-active #app-container {
    max-width: 760px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}
body.quiz-active .glass-panel {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.6);
}
body.quiz-active .question-presentation-card h2 {
    color: #ffffff;
    font-size: 1.75rem;
}
body.quiz-active .quiz-meta-info .badge { background: rgba(255, 255, 255, 0.12); color: #fff; }
body.quiz-active .quiz-meta-info .badge-alt { background: rgba(157, 78, 221, 0.35); color: #fff; }
body.quiz-active .progress-meta { color: rgba(255, 255, 255, 0.7); }
body.quiz-active .progress-track-bar { background: rgba(255, 255, 255, 0.1); }
body.quiz-active .btn-text-nav { color: rgba(255, 255, 255, 0.6); }
body.quiz-active .btn-text-nav:hover { color: var(--color-error); }
body.quiz-active .answer-option-btn {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}
body.quiz-active .answer-option-btn:hover {
    background: rgba(74, 119, 255, 0.18);
    border-color: var(--color-primary);
}
body.quiz-active .timer-text-val { color: #ffffff; }

/* Custom Interactive Desktop Cursor Engine Mock */
@media (min-width: 1024px) {
    body { cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><circle cx="6" cy="6" r="5" fill="none" stroke="%234a77ff" stroke-width="2"/></svg>'), auto; }
}

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#app-container {
    width: 100%;
    max-width: 1200px;
    padding: 24px;
    z-index: 1;
    position: relative;
}

/* Glassmorphism System Rule Component */
.glass-panel {
    background: var(--panel-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    padding: 28px;
    transition: var(--transition-smooth);
}

/* ================= INTERACTION COMPONENTS ================= */
.btn {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1rem;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    gap: 8px;
}

.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(74, 119, 255, 0.3);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 119, 255, 0.4);
}

.btn-secondary {
    background: #ffffff;
    color: var(--color-text-dark);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}
.btn-secondary:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--color-accent);
    color: white;
    box-shadow: 0 4px 14px rgba(157, 78, 221, 0.3);
}
.btn-accent:hover {
    background: #8338ec;
    transform: translateY(-2px);
}

/* Button Micro-interaction Ripple Layer Effect */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease-out, height 0.3s ease-out;
}
.btn:active::after {
    width: 200%;
    height: 200%;
    opacity: 0;
}

.badge {
    background: rgba(74, 119, 255, 0.1);
    color: var(--color-primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-alt {
    background: rgba(157, 78, 221, 0.1);
    color: var(--color-accent);
}

/* ================= VIEW SCREEN: SYSTEM STATES ================= */
.view-section {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s ease;
    animation: screenFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-section.hidden {
    display: none !important;
    opacity: 0;
    transform: scale(0.98);
}

@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= HOME VIEWPORT UI ELEMENTS ================= */
.hero-section {
    text-align: center;
    padding: 60px 0 40px;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.hero-brain-icon {
    width: 64px;
    height: 54px;
    animation: floatBrain 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(157, 78, 221, 0.35));
}

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

.hero-title {
    font-size: 3.75rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--color-primary), var(--color-accent) 60%, var(--color-quiz-1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1.5px;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: 32px;
}

.btn-hero {
    padding: 16px 40px;
    font-size: 1.1rem;
}

/* Dashboard Modules Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

@media(min-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

.daily-challenge-card, .settings-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.countdown-wrapper {
    font-weight: 600;
    font-size: 1.1rem;
}
.timer-highlight {
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-select {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.1);
    font-family: var(--font-primary);
    background: white;
    outline: none;
}

/* Accessibility Control Switch Sliders */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    border-radius: 34px;
    transition: .3s;
    cursor: pointer;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
}
input:checked + .slider { background-color: var(--color-primary); }
input:checked + .slider:before { transform: translateX(24px); }

/* Unified Exploratory Toolbar Search Engine */
.search-navigation-bar {
    margin-bottom: 32px;
}
.search-wrapper {
    position: relative;
    width: 100%;
}
.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--color-text-muted);
}
#category-search {
    width: 100%;
    padding: 18px 18px 18px 56px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0,0,0,0.05);
    background: var(--panel-glass);
    backdrop-filter: blur(8px);
    font-family: var(--font-primary);
    font-size: 1rem;
    outline: none;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
}
#category-search:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: var(--shadow-glow);
}

/* Responsive Grid Categorization Modules */
.categories-section h2 {
    margin-bottom: 20px;
    font-weight: 600;
}
.categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin-bottom: 48px;
}

.category-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    flex: 1 1 260px;
    max-width: 100%;
    position: relative;
    background: linear-gradient(155deg, var(--color-quiz-1) 0%, var(--color-quiz-2) 100%);
    border: none;
    color: #ffffff;
    box-shadow: var(--shadow-quiz);
    overflow: hidden;
    animation: cardRiseIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
@media (min-width: 620px) {
    .category-card { flex-basis: calc(50% - 11px); }
}
@media (min-width: 920px) {
    .category-card { flex-basis: calc(33.333% - 15px); }
}
@media (min-width: 1180px) {
    .category-card { flex-basis: calc(25% - 17px); }
}
@keyframes cardRiseIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.category-card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -30%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, rgba(255,255,255,0.16) 0%, transparent 70%);
    pointer-events: none;
}
.category-card:hover {
    transform: translateY(-8px) scale(1.015);
    box-shadow: 0 20px 40px -8px rgba(208, 0, 0, 0.55);
    border-color: transparent;
}
.category-card:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

.cat-icon-frame {
    font-size: 1.9rem;
    margin-bottom: 16px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    backdrop-filter: blur(4px);
}
.category-card h3 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
}
.category-card p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.9rem;
    margin-bottom: 16px;
    flex-grow: 1;
}
.cat-meta-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding-top: 12px;
}
.category-card .cat-meta-footer {
    color: #ffffff;
    font-weight: 700;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
}

/* Analytics Stats Blocks and Achievement Layouts */
.analytics-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 24px;
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}
.stat-box {
    background: rgba(255,255,255,0.5);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.5);
}
.stat-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-lbl {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 6px;
}
.achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.4);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.2);
    transition: var(--transition-smooth);
}
.achievement-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
}
.ach-icon { font-size: 1.4rem; }
.ach-info h4 { font-size: 0.9rem; font-weight: 600; }
.ach-info p { font-size: 0.75rem; color: var(--color-text-muted); }

/* ================= QUIZ PLAY MATRIX FRAMEWORK ================= */
.quiz-interface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.btn-text-nav {
    background: none;
    border: none;
    font-family: var(--font-primary);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.btn-text-nav:hover { color: var(--color-error); }

.quiz-meta-info {
    display: flex;
    gap: 8px;
}

/* Custom Circular Dashboard SVG Timer Context */
.quiz-timer-circle {
    position: relative;
    width: 52px;
    height: 52px;
}
.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.circle-bg {
    fill: none;
    stroke: rgba(0,0,0,0.05);
    stroke-width: 3.8;
}
.circle {
    fill: none;
    stroke-width: 3.8;
    stroke-linecap: round;
    stroke: var(--color-primary);
    transition: stroke-dasharray 1s linear;
}
.timer-text-val {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.95rem;
    font-weight: 700;
}

/* Core Horizontal Progress Metrics Component */
.quiz-progress-wrapper {
    margin-bottom: 32px;
}
.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text-muted);
}
.progress-track-bar {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill-element {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Question Delivery System Presenter Grid */
.question-presentation-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 32px;
    line-height: 1.4;
}

.answers-stack-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 768px) {
    .answers-stack-grid { grid-template-columns: 1fr 1fr; }
}

.answer-option-btn {
    background: #ffffff;
    border: 2px solid rgba(0,0,0,0.03);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    text-align: left;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.01);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
}
.answer-option-btn:hover {
    border-color: var(--color-primary);
    background: rgba(74, 119, 255, 0.02);
    transform: translateY(-2px);
}

/* Dynamic State Response Color Animations */
.answer-option-btn.correct-pulse {
    background: var(--color-success) !important;
    border-color: var(--color-success) !important;
    color: white !important;
    animation: successFlash 0.3s ease 2;
}
.answer-option-btn.incorrect-pulse {
    background: var(--color-error) !important;
    border-color: var(--color-error) !important;
    color: white !important;
    animation: errorShake 0.4s ease-in-out;
}

@keyframes successFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ================= POST-GAME SUMMARY VIEWPORT ================= */
.results-main-card {
    text-align: center;
    max-width: 650px;
    margin: 40px auto;
    position: relative;
    overflow: hidden;
}
.confetti-holder-box {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
.medal-podium-icon {
    font-size: 4.5rem;
    margin-bottom: 12px;
    animation: popMedal 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popMedal {
    from { transform: scale(0) rotate(-30deg); }
    to { transform: scale(1) rotate(0); }
}

#result-heading {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}
#result-feedback-text {
    color: var(--color-text-muted);
    margin-bottom: 28px;
}

.score-hero-display {
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.7);
    padding: 24px;
    border-radius: var(--radius-lg);
    display: inline-flex;
    flex-direction: column;
    margin-bottom: 32px;
    min-width: 220px;
}
.fraction-main {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
}
.percentage-sub {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-accent);
}

.performance-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 36px;
}
.metric-tile {
    background: rgba(255,255,255,0.4);
    padding: 14px;
    border-radius: var(--radius-sm);
    text-align: left;
    border: 1px solid rgba(0,0,0,0.02);
}
.m-lbl {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.m-val {
    font-size: 1.1rem;
    font-weight: 600;
}

.results-actions-matrix {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media(min-width: 480px) {
    .results-actions-matrix { grid-template-columns: 1fr 1fr; }
}