/* ========================================
   MATHS MASTER - JEDI CALCULATION QUEST
   Space Theme CSS
   ======================================== */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --space-dark: #0a0a1a;
    --space-deep: #0d1033;
    --space-mid: #1a1a3e;
    --neon-blue: #00d4ff;
    --neon-cyan: #00ffc8;
    --neon-purple: #b44dff;
    --neon-pink: #ff44aa;
    --neon-yellow: #ffd700;
    --neon-red: #ff3333;
    --neon-green: #00ff66;
    --saber-blue: #4488ff;
    --saber-green: #44ff88;
    --saber-red: #ff4444;
    --text-primary: #e0e8ff;
    --text-secondary: #8890b0;
    --font-title: 'Orbitron', sans-serif;
    --font-body: 'Exo 2', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--space-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
}

/* ---------- STARS BACKGROUND ---------- */
.stars-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(1px 1px at 20% 30%, white 1px, transparent 0),
        radial-gradient(1px 1px at 40% 70%, white 1px, transparent 0),
        radial-gradient(1px 1px at 60% 20%, white 1px, transparent 0),
        radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,0.8) 1px, transparent 0),
        radial-gradient(1.5px 1.5px at 10% 80%, rgba(255,255,255,0.6) 1px, transparent 0),
        radial-gradient(1px 1px at 70% 40%, rgba(200,220,255,0.7) 1px, transparent 0),
        radial-gradient(1.5px 1.5px at 50% 50%, rgba(200,200,255,0.5) 1px, transparent 0),
        radial-gradient(1px 1px at 30% 10%, rgba(255,255,255,0.9) 1px, transparent 0),
        radial-gradient(1px 1px at 90% 90%, rgba(255,255,200,0.6) 1px, transparent 0),
        radial-gradient(1px 1px at 15% 55%, white 1px, transparent 0);
    background-size: 200px 200px;
    animation: twinkle 4s ease-in-out infinite alternate;
    z-index: 0;
    pointer-events: none;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ---------- SCREENS ---------- */
.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--space-dark), var(--space-deep), var(--space-mid));
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* ---------- BUTTONS ---------- */
.btn-glow {
    font-family: var(--font-title);
    font-size: 1.2rem;
    padding: 15px 50px;
    border: 2px solid var(--neon-blue);
    background: rgba(0, 212, 255, 0.1);
    color: var(--neon-blue);
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 3px;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
    margin: 8px;
}

.btn-glow:hover {
    background: rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5), inset 0 0 30px rgba(0, 212, 255, 0.1);
    transform: scale(1.05);
}

.btn-outline {
    font-family: var(--font-title);
    font-size: 0.9rem;
    padding: 12px 35px;
    border: 1px solid var(--text-secondary);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
    margin: 8px;
}

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    transform: scale(1.05);
}

/* ---------- TITLE SCREEN ---------- */
.title-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.title-sub {
    font-family: var(--font-title);
    font-size: 0.9rem;
    letter-spacing: 10px;
    color: var(--neon-yellow);
    margin-bottom: 10px;
}

.title-main {
    font-family: var(--font-title);
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(180deg, var(--neon-yellow), #ff8800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 10px;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.3));
}

.title-tagline {
    font-size: 1rem;
    color: var(--neon-cyan);
    letter-spacing: 4px;
    margin-bottom: 30px;
}

.title-jedi-icon {
    font-size: 4rem;
    margin: 20px 0;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* ---------- HOW TO PLAY ---------- */
.howto-content {
    z-index: 2;
    max-width: 600px;
    padding: 30px;
    text-align: center;
}

.howto-content h2 {
    font-family: var(--font-title);
    color: var(--neon-yellow);
    margin-bottom: 25px;
    font-size: 1.8rem;
}

.howto-steps {
    text-align: left;
    margin-bottom: 25px;
}

.howto-step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.step-icon {
    font-size: 1.5rem;
    min-width: 40px;
    text-align: center;
}

.howto-step p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.level-info {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.level-info h3 {
    font-family: var(--font-title);
    color: var(--neon-blue);
    margin-bottom: 10px;
    font-size: 1rem;
}

.level-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 3px 0;
}

/* ---------- LEVEL SELECT ---------- */
.level-content {
    z-index: 2;
    text-align: center;
    width: 90%;
    max-width: 800px;
}

.level-content h2 {
    font-family: var(--font-title);
    color: var(--neon-yellow);
    margin-bottom: 30px;
    font-size: 1.5rem;
    letter-spacing: 3px;
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.level-card {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.level-card:hover:not(.locked) {
    border-color: var(--neon-blue);
    background: rgba(0, 212, 255, 0.08);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.2);
}

.level-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-card.locked .lock-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    z-index: 3;
}

.level-card.completed {
    border-color: var(--neon-green);
}

.level-card.completed::after {
    content: '✅';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.2rem;
}

.level-number {
    font-family: var(--font-title);
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: var(--neon-blue);
    margin-bottom: 8px;
}

.level-ops {
    font-size: 2rem;
    margin: 8px 0;
    color: var(--neon-yellow);
}

.level-name {
    font-family: var(--font-title);
    font-size: 1rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.level-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------- GAME HUD ---------- */
#game-screen {
    background: transparent;
    overflow: hidden;
}

#game-hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: linear-gradient(180deg, rgba(10,10,26,0.95), rgba(10,10,26,0.7), transparent);
}

#hud-level {
    font-family: var(--font-title);
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: var(--neon-purple);
    padding: 5px 12px;
    border: 1px solid var(--neon-purple);
    border-radius: 5px;
}

#hud-question-box {
    text-align: center;
    flex: 1;
    margin: 0 20px;
}

#hud-question-label {
    font-family: var(--font-title);
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

#hud-question {
    font-family: var(--font-title);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--neon-yellow);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#hud-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    font-family: var(--font-title);
    font-size: 0.85rem;
}

#hud-progress {
    color: var(--text-secondary);
}

#hud-score {
    color: var(--neon-yellow);
}

#hud-streak {
    color: var(--neon-red);
}

/* ---------- EQUIPMENT DISPLAY ---------- */
#equipment-display {
    position: absolute;
    top: 65px; right: 15px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.equip-slot {
    width: 40px; height: 40px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    opacity: 0.3;
    transition: all 0.5s;
}

.equip-slot.unlocked {
    opacity: 1;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 200, 0.3);
    animation: equipGlow 2s ease-in-out infinite alternate;
}

@keyframes equipGlow {
    0% { box-shadow: 0 0 5px rgba(0, 255, 200, 0.2); }
    100% { box-shadow: 0 0 15px rgba(0, 255, 200, 0.5); }
}

/* ---------- RUNNER CONTAINER ---------- */
#runner-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#lane-touch-zones {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    z-index: 5;
}

.lane-zone {
    flex: 1;
    cursor: pointer;
}

/* ---------- FEEDBACK OVERLAY ---------- */
#feedback-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s;
}

#feedback-overlay.hidden {
    opacity: 0;
}

#feedback-icon {
    font-size: 4rem;
    animation: feedbackPop 0.5s ease-out;
}

#feedback-text {
    font-family: var(--font-title);
    font-size: 1.5rem;
    margin-top: 10px;
    text-shadow: 0 0 20px currentColor;
}

#feedback-overlay.correct #feedback-icon::after { content: '✅'; }
#feedback-overlay.correct #feedback-text { color: var(--neon-green); }
#feedback-overlay.wrong #feedback-icon::after { content: '❌'; }
#feedback-overlay.wrong #feedback-text { color: var(--neon-red); }

@keyframes feedbackPop {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

/* ---------- EQUIPMENT NOTIFICATION ---------- */
#equip-notification {
    position: absolute;
    top: 120px; left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    background: rgba(0, 255, 200, 0.1);
    border: 1px solid var(--neon-cyan);
    border-radius: 10px;
    padding: 12px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-title);
    font-size: 0.85rem;
    color: var(--neon-cyan);
    animation: slideDown 0.5s ease-out;
    pointer-events: none;
}

#equip-notification.hidden {
    display: none;
}

@keyframes slideDown {
    0% { transform: translateX(-50%) translateY(-30px); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

#equip-notif-icon {
    font-size: 1.5rem;
}

/* ---------- CONTROLS HINT ---------- */
#controls-hint {
    position: absolute;
    bottom: 15px; left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.3);
    display: flex;
    gap: 15px;
    align-items: center;
    font-family: var(--font-title);
    letter-spacing: 1px;
}

.key-hint {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    font-size: 0.7rem;
    margin-right: 3px;
}

/* ---------- BOSS FIGHT ---------- */
#boss-screen {
    background: linear-gradient(135deg, #1a0000, #0a0a1a, #1a0000);
}

#boss-arena {
    z-index: 2;
    width: 90%;
    max-width: 700px;
    text-align: center;
}

#boss-hud {
    margin-bottom: 30px;
}

#boss-hp-bar {
    width: 100%;
    height: 30px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 68, 68, 0.3);
}

#boss-hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--neon-red), #ff6644);
    border-radius: 15px;
    transition: width 0.5s ease-out;
}

#boss-hp-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-title);
    font-size: 0.7rem;
    letter-spacing: 3px;
    color: white;
    text-shadow: 0 0 5px black;
}

#boss-question-box {
    background: rgba(255, 68, 68, 0.08);
    border: 1px solid rgba(255, 68, 68, 0.3);
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 20px;
}

#boss-question {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

#boss-visual {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0;
    padding: 0 30px;
}

#boss-character {
    font-size: 5rem;
    animation: bossFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 0.5));
}

@keyframes bossFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.05); }
}

#boss-jedi {
    font-size: 4rem;
    animation: jediReady 1.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 15px rgba(0, 212, 255, 0.5));
}

@keyframes jediReady {
    0% { transform: translateX(0); }
    100% { transform: translateX(-10px); }
}

#boss-answers {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.boss-answer-btn {
    font-family: var(--font-title);
    font-size: 1.3rem;
    padding: 18px 35px;
    min-width: 100px;
    border: 2px solid rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.05);
    color: var(--text-primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.boss-answer-btn:hover {
    border-color: var(--neon-blue);
    background: rgba(0, 212, 255, 0.15);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.boss-answer-btn.correct-flash {
    border-color: var(--neon-green);
    background: rgba(0, 255, 102, 0.2);
    box-shadow: 0 0 30px rgba(0, 255, 102, 0.5);
}

.boss-answer-btn.wrong-flash {
    border-color: var(--neon-red);
    background: rgba(255, 51, 51, 0.2);
    box-shadow: 0 0 30px rgba(255, 51, 51, 0.5);
}

#boss-feedback {
    margin-top: 20px;
    font-family: var(--font-title);
    font-size: 1.2rem;
    min-height: 40px;
}

#boss-feedback.hidden {
    visibility: hidden;
}

/* ---------- VICTORY SCREEN ---------- */
.victory-content, .final-content, .gameover-content {
    z-index: 2;
    text-align: center;
    max-width: 500px;
}

#victory-type-icon, .gameover-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
}

.victory-content h2, .gameover-content h2 {
    font-family: var(--font-title);
    font-size: 2rem;
    margin-bottom: 20px;
    letter-spacing: 3px;
}

.victory-content h2 { color: var(--neon-green); }
.gameover-content h2 { color: var(--neon-red); }

#victory-stats p, #gameover-stats p, #final-stats p {
    font-size: 1rem;
    color: var(--text-secondary);
    padding: 5px 0;
}

#victory-stats span, #gameover-stats span, #final-stats span {
    color: var(--neon-yellow);
    font-weight: 700;
}

#victory-equip {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 255, 200, 0.05);
    border: 1px solid rgba(0, 255, 200, 0.2);
    border-radius: 10px;
}

#victory-equip h3 {
    font-family: var(--font-title);
    font-size: 0.8rem;
    color: var(--neon-cyan);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#v-equip-list {
    font-size: 2rem;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.gameover-msg {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

/* ---------- FINAL VICTORY ---------- */
.final-content h1 {
    font-family: var(--font-title);
    font-size: 2.5rem;
    background: linear-gradient(180deg, var(--neon-yellow), #ff8800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.3));
}

.final-celebration {
    font-size: 5rem;
    animation: celebrate 1s ease-in-out infinite;
}

@keyframes celebrate {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.1); }
    75% { transform: rotate(10deg) scale(1.1); }
}

.final-subtitle {
    color: var(--neon-cyan);
    font-size: 1.1rem;
    margin-bottom: 25px;
    letter-spacing: 2px;
}

#final-jedi-display {
    margin: 25px 0;
}

.final-jedi-char {
    font-size: 4rem;
    margin-bottom: 10px;
}

#final-equip-showcase {
    font-size: 2rem;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* ---------- BOSS ATTACK ANIMATION ---------- */
@keyframes bossHit {
    0% { transform: translateX(0); }
    25% { transform: translateX(-20px); }
    50% { transform: translateX(20px); }
    75% { transform: translateX(-10px); }
    100% { transform: translateX(0); }
}

.boss-hit {
    animation: bossHit 0.4s ease-out;
}

@keyframes jediAttack {
    0% { transform: translateX(0); }
    40% { transform: translateX(-80px) scale(1.2); }
    60% { transform: translateX(-80px) scale(1.2); }
    100% { transform: translateX(0) scale(1); }
}

.jedi-attack {
    animation: jediAttack 0.6s ease-in-out;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .title-main {
        font-size: 2rem;
    }

    .level-cards {
        grid-template-columns: 1fr;
    }

    #hud-question {
        font-size: 1.2rem;
    }

    #hud-stats {
        font-size: 0.7rem;
        gap: 8px;
    }

    #equipment-display {
        flex-direction: row;
        top: auto;
        bottom: 50px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .equip-slot {
        width: 35px;
        height: 35px;
    }

    .boss-answer-btn {
        padding: 14px 20px;
        font-size: 1rem;
        min-width: 80px;
    }

    #boss-character { font-size: 3.5rem; }
    #boss-jedi { font-size: 3rem; }

    #controls-hint {
        display: none;
    }
}

@media (max-width: 480px) {
    .title-main {
        font-size: 1.5rem;
    }

    .title-tagline {
        font-size: 0.8rem;
        letter-spacing: 2px;
    }

    #hud-question {
        font-size: 1rem;
    }

    #boss-question {
        font-size: 1.3rem;
    }
}
