/* --- The Celestial Journey Theme --- */
:root {
    /* Palette: Deep Space & Neon Signals */
    --bg-deep: #030712;
    /* Almost black blue */
    --bg-card: rgba(17, 24, 39, 0.7);
    /* Glassy dark */
    --bg-card-hover: rgba(31, 41, 55, 0.8);

    --accent-primary: #6366f1;
    /* Indigo Neon */
    --accent-glow: rgba(99, 102, 241, 0.5);
    --accent-secondary: #10b981;
    /* Emerald Signal */
    --accent-danger: #ef4444;

    --text-main: #f9fafb;
    --text-muted: #9ca3af;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    --shadow-glow: 0 0 20px var(--accent-glow);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 25%);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Layout & Container --- */
.app-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
}

/* --- Header --- */
.app-header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(to right, #fff, #9ca3af);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.streak-container {
    background: rgba(255, 255, 255, 0.05);
    border: var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.streak-icon {
    filter: drop-shadow(0 0 5px orange);
}

/* --- Screens --- */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    position: absolute;
    inset: 60px 0 0 0;
    /* Below header */
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    position: relative;
    inset: auto;
}

.hidden {
    display: none !important;
}

/* --- Journey Dashboard (The "Intriguing" Part) --- */
.journey-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 3rem;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.level-display {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* The Glowing Orb / Portal */
.level-orb {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--accent-primary), #312e81);
    box-shadow:
        0 0 30px var(--accent-glow),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: 800;
    color: white;
    margin-bottom: 1rem;
    position: relative;
    animation: pulse 4s infinite ease-in-out;
}

.level-orb::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px dashed rgba(99, 102, 241, 0.3);
    animation: spin 20s linear infinite;
}

.level-label {
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: var(--accent-secondary);
}

#current-level-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

#level-description {
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.5;
}

/* Progress Bar */
.level-progress-bar {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    overflow: hidden;
    margin-top: 0.5rem;
}

#level-progress-fill {
    height: 100%;
    background: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary);
    transition: width 0.5s ease;
}

/* Buttons */
.primary-btn {
    background: var(--text-main);
    color: var(--bg-deep);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
}

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

/* Stats Grid */
.stats-grid {
    display: flex;
    gap: 2rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Quiz Interface --- */
.quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.question-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.q-text {
    font-size: 1.25rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Options */
.options-grid {
    display: grid;
    gap: 1rem;
}

.option-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

.option-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

/* Feedback Overlay */
.feedback-overlay {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    background: var(--bg-deep);
    border: 1px solid var(--accent-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.feedback-content h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

/* Charts */
.chart-wrapper {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    height: 200px;
}

.chart-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

/* Sandbox */
.sandbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.controls-container {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    border: var(--glass-border);
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
}

/* --- Mission Log Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background: var(--bg-card);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

.mission-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
}

.level-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.level-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.lvl-num {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-muted);
    width: 30px;
}

.level-item.active .lvl-num {
    color: var(--accent-primary);
}

.lvl-info {
    flex: 1;
}

.lvl-title {
    font-weight: 600;
    display: block;
}

.lvl-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.lvl-status {
    font-size: 1.2rem;
}

.danger-zone {
    padding: 1.5rem;
    border-top: var(--glass-border);
    display: flex;
    justify-content: center;
}

.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid var(--accent-danger);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.danger-btn:hover {
    background: var(--accent-danger);
    color: white;
}

/* Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 30px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 50px var(--accent-glow);
    }

    100% {
        box-shadow: 0 0 30px var(--accent-glow);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .app-container {
        padding: 0;
    }

    .journey-container {
        gap: 2rem;
    }

    .level-orb {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .chart-wrapper {
        flex-direction: column;
        height: 300px;
    }
}