/* ===== SPELLWRIGHT ACADEMY - ENHANCED UI & ANIMATIONS ===== */

/* ===== IMPORTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Lexend:wght@300;400;500&family=Patrick+Hand&family=Playfair+Display:wght@600;700&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
    /* Spell School Colors */
    --foundation-green: #48bb78;
    --foundation-gold: #ffd700;
    --adventure-orange: #ed8936;
    --art-red: #f56565;
    --art-purple: #9f7aea;
    --science-blue: #4299e1;
    --theater-magenta: #ed64a6;

    /* Base Colors */
    --bg-primary: #F7FAFC;
    --brand-primary: #4A90E2;
    --brand-secondary: #48BB78;
    --accent-yellow: #F6E05E;
    --accent-purple: #9F7AEA;
    --accent-orange: #F6AD55;

    --success: #48BB78;
    --error: #F56565;
    --warning: #F6E05E;

    --text-primary: #2D3748;
    --text-secondary: #718096;
    --text-light: #A0AEC0;

    --white: #FFFFFF;
    --card-bg: #FFFFFF;
    --border: #E2E8F0;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Typography */
    --font-heading: 'Fredoka', sans-serif;
    --font-elegant: 'Playfair Display', Georgia, serif;
    --font-body: 'Lexend', sans-serif;
    --font-mono: 'Consolas', 'Monaco', monospace;
    --font-accent: 'Patrick Hand', cursive;

    /* Spacing System */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    position: relative;
}

/* ===== BACKGROUND SYSTEM ===== */

/* Legacy background scene - DISABLED (using CSS-based 3-tier system now) */
/*
.background-scene {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease-out;
}

.background-scene::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.background-scene.with-overlay::before {
    opacity: 1;
}

.background-scene.foundation {
    background-image: url('assets/backgrounds/foundation-garden-background.jpg');
}
*/

/* ===== 3-TIER BACKGROUND SYSTEM ===== */

/* Smooth transitions between backgrounds */
.screen {
    transition: background-image 0.5s ease-in-out;
}

/* TIER 1 - Main Academy Background (entrance hall) */
.screen.academy-background {
    background-image: url('assets/backgrounds/academy-entrance-hall.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.screen.academy-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.screen.academy-background > * {
    position: relative;
    z-index: 1;
}

/* TIER 2 - Quest Hall Background (quest selection) */
.screen.quest-hall-background {
    background-image: url('assets/backgrounds/quest-selection-hall.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.screen.quest-hall-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.screen.quest-hall-background > * {
    position: relative;
    z-index: 1;
}

/* TIER 3 - Spell School Classroom Backgrounds */
.screen.classroom-background {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.screen.classroom-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.screen.classroom-background > * {
    position: relative;
    z-index: 1;
}

.screen.classroom-background.foundation {
    background-image: url('assets/backgrounds/foundation-garden-background.jpg');
}

.screen.classroom-background.adventure {
    background-image: url('assets/backgrounds/adventure-quest-background.jpg');
}

.screen.classroom-background.art {
    background-image: url('assets/backgrounds/art-studio-background.jpg');
}

.screen.classroom-background.science {
    background-image: url('assets/backgrounds/science-laboratory-background.jpg');
}

.screen.classroom-background.theater {
    background-image: url('assets/backgrounds/theater-stage-background.jpg');
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    display: none;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    padding: var(--space-3) 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    animation: screenFadeIn 0.5s ease-out;
}

/* Typing screen uses minimal padding for max viewport usage */
#typingChallengeScreen {
    padding: var(--space-2) 0;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Force hide inactive screens */
.screen:not(.active) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ===== CONTAINER SYSTEM ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
    width: 100%;
    position: relative;
    z-index: 1;
}

/* ===== QUEST INTRO SCREEN REDESIGN ===== */
#quest1IntroScreen,
#quest2IntroScreen,
#midQuestScreen {
    position: relative;
}

#quest1IntroScreen::before,
#quest2IntroScreen::before,
#midQuestScreen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: -1;
}

.quest-intro {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-12);
    padding: var(--space-8);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.quest-intro-character {
    flex: 0 0 380px;
    animation: slideInLeft 0.6s ease-out 0.2s both;
    position: -webkit-sticky;
    position: sticky;
    top: var(--space-6);
    align-self: flex-start;
    will-change: transform;
}

.quest-intro-character img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: block;
}

.quest-intro-content {
    flex: 1;
    max-width: 600px;
    width: 100%;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    padding: var(--space-12);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    animation: fadeInContent 0.5s ease-out 0.4s both;
    margin: var(--space-6) 0;
}

.quest-title {
    font-family: var(--font-elegant);
    font-size: 3rem;
    font-weight: 700;
    color: var(--foundation-green);
    margin-bottom: var(--space-4);
    line-height: 1.2;
    animation: slideDown 0.4s ease-out 0.6s both;
}

.quest-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: var(--space-8);
    animation: fadeIn 0.3s ease-out 0.8s both;
}

.story-content {
    margin-bottom: var(--space-8);
}

.story-text-box {
    animation: fadeIn 0.3s ease-out 0.8s both;
}

.story-text {
    font-size: 1.125rem;
    line-height: 1.7;
    margin-bottom: var(--space-5);
    color: var(--text-primary);
}

.story-text.dialogue {
    font-style: italic;
    padding-left: var(--space-6);
    border-left: 4px solid var(--foundation-green);
    color: var(--brand-primary);
    background: rgba(72, 187, 120, 0.05);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin: var(--space-5) 0;
}

.finger-placement-guide,
.quest-objective {
    background: rgba(248, 250, 252, 0.8);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    margin-top: var(--space-6);
    border: 2px solid var(--border);
}

.quest-objective h3 {
    color: var(--foundation-green);
    font-size: 1.25rem;
    margin-bottom: var(--space-3);
}

.placement-option {
    margin-bottom: var(--space-8);
    padding: var(--space-4);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

/* OPTION 1: Simplified Home Row */
.home-row-simple {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: var(--space-4);
}

.key-simple {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    min-width: 50px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-simple.pinky { background: rgba(159, 122, 234, 0.3); border: 2px solid #9f7aea; }
.key-simple.ring { background: rgba(237, 100, 166, 0.3); border: 2px solid #ed64a6; }
.key-simple.middle { background: rgba(66, 153, 225, 0.3); border: 2px solid #4299e1; }
.key-simple.index { background: rgba(237, 137, 54, 0.3); border: 2px solid #ed8936; }

.key-letter-simple {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.bump-simple {
    font-size: 0.75rem;
    color: #ed8936;
}

.key-label-simple {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.key-gap {
    width: 30px;
}

.finger-legend-simple {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.legend-item-simple {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.color-dot.pinky { background: #9f7aea; }
.color-dot.ring { background: #ed64a6; }
.color-dot.middle { background: #4299e1; }
.color-dot.index { background: #ed8936; }

/* OPTION 2: Full Keyboard Context */
.keyboard-intro {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--space-3);
}

.keyboard-row-intro {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.key-intro {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-intro.inactive-intro {
    background: rgba(160, 174, 192, 0.2);
    color: #a0aec0;
    border: 1px solid #e2e8f0;
}

.key-intro.pinky { background: rgba(159, 122, 234, 0.4); border: 2px solid #9f7aea; color: var(--text-primary); }
.key-intro.ring { background: rgba(237, 100, 166, 0.4); border: 2px solid #ed64a6; color: var(--text-primary); }
.key-intro.middle { background: rgba(66, 153, 225, 0.4); border: 2px solid #4299e1; color: var(--text-primary); }
.key-intro.index { background: rgba(237, 137, 54, 0.4); border: 2px solid #ed8936; color: var(--text-primary); }

.bump-intro {
    position: absolute;
    bottom: 4px;
    font-size: 0.6rem;
    color: #ed8936;
}

.finger-labels-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: var(--space-2);
}

.finger-label-intro {
    width: 38px;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* OPTION 3: Hand-Separated Layout */
.hand-separated-layout {
    display: flex;
    justify-content: center;
    gap: var(--space-8);
}

.hand-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.hand-indicator {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foundation-green);
}

.hand-keys {
    display: flex;
    gap: 6px;
}

.key-hand {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    min-width: 50px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-hand.pinky { background: rgba(159, 122, 234, 0.3); border: 2px solid #9f7aea; }
.key-hand.ring { background: rgba(237, 100, 166, 0.3); border: 2px solid #ed64a6; }
.key-hand.middle { background: rgba(66, 153, 225, 0.3); border: 2px solid #4299e1; }
.key-hand.index { background: rgba(237, 137, 54, 0.3); border: 2px solid #ed8936; }

.key-letter-hand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.finger-name-hand {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* OPTION 4: Compact Annotated */
.annotated-keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.annotations-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.annotation {
    width: 50px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px;
    border-radius: 4px;
}

.annotation.pinky { color: #9f7aea; background: rgba(159, 122, 234, 0.1); }
.annotation.ring { color: #ed64a6; background: rgba(237, 100, 166, 0.1); }
.annotation.middle { color: #4299e1; background: rgba(66, 153, 225, 0.1); }
.annotation.index { color: #ed8936; background: rgba(237, 137, 54, 0.1); }

.annotation-gap {
    width: 30px;
}

.keys-row-annotated {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key-annotated {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-annotated.pinky { background: rgba(159, 122, 234, 0.3); border: 2px solid #9f7aea; }
.key-annotated.ring { background: rgba(237, 100, 166, 0.3); border: 2px solid #ed64a6; }
.key-annotated.middle { background: rgba(66, 153, 225, 0.3); border: 2px solid #4299e1; }
.key-annotated.index { background: rgba(237, 137, 54, 0.3); border: 2px solid #ed8936; }

.bump-annotated {
    position: absolute;
    bottom: 4px;
    font-size: 0.7rem;
    color: #ed8936;
}

.annotated-gap {
    width: 30px;
}

.placement-tip {
    text-align: center;
    font-size: 0.95rem;
    color: var(--foundation-green);
    font-weight: 500;
    margin-top: var(--space-4);
}

.btn-primary.btn-large {
    display: block;
    margin: var(--space-8) auto 0;
    padding: var(--space-5) var(--space-12);
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--foundation-green), var(--foundation-gold));
    border-radius: var(--radius-xl);
    animation: popIn 0.3s ease-out 1s both;
    box-shadow: 0 8px 24px rgba(72, 187, 120, 0.3);
}

/* ===== TYPING SCREEN REDESIGN ===== */
#typingChallengeScreen {
    background: transparent;
}

#typingChallengeScreen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: -1;
}

#typingChallengeScreen .container {
    max-width: 1200px;
    width: 100%;
    display: grid;
    grid-template-columns: 180px 1fr 180px;
    gap: var(--space-4);
    align-items: start;
    margin: var(--space-2) auto;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

#typingChallengeScreen .background-scene::before {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 1;
}

.character-typing-display {
    animation: slideInLeft 0.5s ease-out;
    max-width: 180px;
}

.character-typing-display img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.plant-container {
    position: relative;
    animation: slideInRight 0.5s ease-out;
    max-width: 180px;
}

.progression-image {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.progression-image.updating {
    opacity: 0;
    transform: scale(0.95);
}

.plant-stage-text {
    text-align: center;
    margin-top: var(--space-2);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.typing-section {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease-out 0.2s both;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border);
}

.challenge-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--foundation-green);
}

.progress-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.typing-area {
    text-align: center;
    padding: var(--space-3) 0;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.feedback-area {
    min-height: 30px;
    margin-top: var(--space-2);
}

.current-key-finger {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    font-weight: 500;
}

.prompt-word {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.2em;
    margin: var(--space-3) 0;
    text-transform: lowercase;
}

.typing-input {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    text-align: center;
    padding: var(--space-3);
    border: 3px solid var(--foundation-green);
    border-radius: var(--radius-lg);
    background: var(--white);
    width: 100%;
    max-width: 450px;
    outline: none;
    transition: all 0.2s ease;
    letter-spacing: 0.1em;
}

.typing-input:focus {
    border-color: var(--foundation-gold);
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2);
}

.typing-input.correct {
    animation: correctPulse 0.3s ease;
}

.typing-input.incorrect {
    animation: shake 0.3s ease;
    border-color: var(--error);
}

.typed-display {
    display: none;
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.stat-box {
    background: rgba(248, 250, 252, 0.5);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    text-align: center;
    border: 2px solid var(--border);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-number {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--foundation-green);
    font-family: var(--font-mono);
}

/* ===== VISUAL KEYBOARD ===== */
.visual-keyboard-container {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(10px);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin: var(--space-2) auto var(--space-3);
    width: 100%;
    max-width: 1000px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.visual-keyboard-container h3 {
    text-align: center;
    color: var(--foundation-green);
    margin-bottom: var(--space-2);
    font-size: 1rem;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: auto;
}

.keyboard-row {
    display: flex;
    gap: 3px;
    justify-content: center;
    min-width: 700px;
}

.key {
    min-width: 38px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 250, 252, 0.6);
    border: 2px solid rgba(226, 232, 240, 0.7);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.15s ease;
    position: relative;
    flex-shrink: 0;
}

.key.home-key {
    border-color: var(--foundation-green);
    background: rgba(72, 187, 120, 0.15);
}

.key.active {
    background: rgba(72, 187, 120, 0.85);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.key .bump {
    position: absolute;
    bottom: 3px;
    font-size: 0.7rem;
    color: var(--foundation-green);
}

/* Finger color coding */
.key.pinky { background: rgba(236, 72, 153, 0.15); }
.key.ring { background: rgba(139, 92, 246, 0.15); }
.key.middle { background: rgba(59, 130, 246, 0.15); }
.key.index { background: rgba(34, 197, 94, 0.15); }

.finger-colors-legend {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
    font-size: 0.7rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.color-box.pinky { background: rgba(236, 72, 153, 0.3); }
.color-box.ring { background: rgba(139, 92, 246, 0.3); }
.color-box.middle { background: rgba(59, 130, 246, 0.3); }
.color-box.index { background: rgba(34, 197, 94, 0.3); }

/* ===== COMPLETION SCREEN REDESIGN ===== */
#checkpointScreen,
#plantCelebrationScreen,
#questCompleteScreen {
    position: relative;
}

#checkpointScreen::before,
#plantCelebrationScreen::before,
#questCompleteScreen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: -1;
}

.celebration,
.completion {
    text-align: center;
    max-width: 700px;
    margin: var(--space-6) auto;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    padding: var(--space-12);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    width: 100%;
}

.badge-image {
    width: 256px;
    height: 256px;
    margin: 0 auto var(--space-8);
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(255, 215, 0, 0.4);
    animation: badgeEntrance 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s both;
}

.badge-image.small {
    width: 128px;
    height: 128px;
}

.celebration-title,
.completion-title {
    font-family: var(--font-elegant);
    font-size: 2.5rem;
    color: var(--foundation-green);
    margin-bottom: var(--space-6);
    animation: slideDown 0.5s ease-out 0.5s both;
}

.celebration-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
    animation: fadeIn 0.5s ease-out 0.7s both;
}

.achievement-box {
    background: rgba(255, 247, 213, 0.5);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    border: 2px solid var(--foundation-gold);
    margin: var(--space-8) 0;
    animation: fadeIn 0.5s ease-out 1s both;
}

.achievement-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--foundation-green);
    margin: var(--space-4) 0 var(--space-2);
}

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

.session-stats {
    margin: var(--space-8) 0;
    animation: fadeIn 0.5s ease-out 1.2s both;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
    margin-top: var(--space-6);
}

.stat-card {
    background: rgba(248, 250, 252, 0.8);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    border: 2px solid var(--border);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--foundation-green);
    font-family: var(--font-mono);
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* ===== SPARKLE EFFECTS ===== */
.sparkle {
    position: absolute;
    pointer-events: none;
    font-size: 30px;
    animation: sparkleFloat 1.5s ease-out forwards;
}

@keyframes sparkleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5) rotate(180deg);
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes badgeEntrance {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    60% {
        transform: scale(1.1) rotate(10deg);
    }
    80% {
        transform: scale(0.95) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ===== BUTTON STYLES ===== */
.btn-primary,
.btn-secondary {
    font-family: var(--font-heading);
    padding: var(--space-4) var(--space-10);
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    pointer-events: auto;
    position: relative;
}

/* Ensure button children don't capture clicks */
.btn-primary *,
.btn-secondary * {
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--foundation-green), var(--foundation-gold));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: white;
    color: var(--foundation-green);
    border: 2px solid var(--foundation-green);
}

.btn-secondary:hover {
    background: var(--foundation-green);
    color: white;
}

.button-group {
    display: flex;
    gap: var(--space-5);
    justify-content: center;
    margin-top: var(--space-8);
    flex-wrap: wrap;
}


/* ===== HOME SCREEN STYLES ===== */
#homeScreen {
    /* Background set via quest-hall-background class */
}

.welcome-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-2xl);
    padding: var(--space-10);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    max-width: 900px;
    width: 100%;
    margin: var(--space-6) auto;
    position: relative;
    z-index: 1;
}

.title {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
    color: var(--brand-primary);
    margin-bottom: var(--space-6);
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--space-8);
    font-style: italic;
    font-weight: 300;
}

/* ===== SPELL SCHOOL SECTIONS (Quest Selection) ===== */

.spell-school-section {
    margin: 30px auto;
    max-width: 900px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-2xl);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    backdrop-filter: blur(10px);
}

.spell-school-section.foundation {
    border-left: 5px solid var(--foundation-green);
}

.spell-school-section.adventure {
    border-left: 5px solid var(--adventure-orange);
}

.spell-school-section.art {
    border-left: 5px solid var(--art-purple);
}

.spell-school-section.science {
    border-left: 5px solid var(--science-blue);
}

.spell-school-section.theater {
    border-left: 5px solid var(--theater-magenta);
}

.spell-school-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--border);
}

.spell-school-icon {
    font-size: 3rem;
    flex-shrink: 0;
}

.spell-school-info {
    flex: 1;
}

.spell-school-info h2 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--text-primary);
}

.spell-school-info p {
    margin: var(--space-1) 0 0 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.spell-school-teacher {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: var(--space-1);
}

/* Quest Grid within spell school sections */
.quest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

/* Quest Cards */
.quest-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.quest-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.quest-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border-color: var(--brand-primary);
}

.quest-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-primary);
}

.quest-card.locked:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
}

.quest-card.completed {
    background: rgba(240, 255, 244, 0.8);
    border-color: var(--foundation-green);
    cursor: pointer;
}

/* Completed quests get hover effects too */
.quest-card.completed:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(72, 187, 120, 0.4);
    border-color: var(--foundation-green);
    background: rgba(240, 255, 244, 0.95);
}

.quest-card.sub-locked {
    opacity: 0.5;
    border-color: var(--text-light);
}

.quest-card.current {
    border-color: var(--brand-primary);
    border-width: 3px;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.4);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1) 0%, rgba(72, 187, 120, 0.1) 100%);
}

.quest-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.quest-card.completed .quest-number {
    color: var(--foundation-green);
}

.quest-info {
    flex: 1;
    width: 100%;
}

.quest-info h4 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    line-height: 1.3;
}

.quest-desc {
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    font-size: 0.85rem;
    line-height: 1.4;
}

.quest-keys {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: var(--space-2);
}

.btn-quest {
    padding: var(--space-2) var(--space-4);
    background: var(--foundation-green);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    width: 100%;
    pointer-events: auto;
    position: relative;
}

/* Ensure button children don't capture clicks */
.btn-quest * {
    pointer-events: none;
}

.btn-quest:hover:not(:disabled) {
    background: var(--foundation-gold);
    box-shadow: var(--shadow-md);
}

.btn-quest:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.quest-card.completed .btn-quest {
    background: var(--foundation-green);
    position: relative;
}

/* Change button text on hover for completed quests */
.quest-card.completed:hover .btn-quest {
    background: var(--foundation-green);
    color: white;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.quest-card.completed .btn-quest span {
    transition: opacity 0.2s ease;
}

/* Hide "Completed" text on hover */
.quest-card.completed:hover .btn-quest span {
    opacity: 0;
}

/* Show "Try Again" on hover */
.quest-card.completed .btn-quest::after {
    content: 'Try Again';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.quest-card.completed:hover .btn-quest::after {
    opacity: 1;
}

.quest-card.sub-locked .btn-quest {
    background: var(--accent-orange);
}

.quest-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.quest-card.completed .quest-status {
    color: var(--foundation-green);
    font-weight: 700;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    #typingChallengeScreen .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .character-typing-display,
    .plant-container {
        max-width: 250px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .quest-intro {
        flex-direction: column;
        padding: var(--space-6);
    }

    .quest-intro-character {
        flex: 0 0 auto;
        max-width: 300px;
    }

    .quest-title {
        font-size: 2rem;
    }

    .prompt-word {
        font-size: 2.5rem;
    }

    .typing-input {
        font-size: 1.75rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

.invisible {
    opacity: 0;
    pointer-events: none;
}

/* ===== FOCUS STATES ===== */
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--foundation-gold);
    outline-offset: 2px;
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-light);
    font-size: 0.75rem;
    font-family: var(--font-body);
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    background: transparent;
}

footer a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--brand-secondary);
    text-decoration: underline;
}

/* ===== AUTH / LOGIN SCREENS ===== */

.auth-container {
    max-width: 480px;
    width: 100%;
    margin: var(--space-16) auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    padding: var(--space-12);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    text-align: center;
    animation: fadeInContent 0.5s ease-out;
}

.auth-container-wide {
    max-width: 640px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--brand-primary);
    margin-bottom: var(--space-2);
}

.auth-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-input {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    outline: none;
    transition: border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.auth-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.auth-input.color-input {
    height: 48px;
    padding: var(--space-1);
    cursor: pointer;
}

.auth-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-top: var(--space-6);
}

.btn-auth-option {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: var(--font-body);
    pointer-events: auto;
}

.btn-auth-option * {
    pointer-events: none;
}

.btn-auth-option:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-auth-option.admin-option {
    opacity: 0.7;
}

.auth-option-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.auth-option-label {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.auth-option-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: block;
}

.auth-link {
    margin-top: var(--space-6);
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--brand-primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.form-error {
    color: var(--error);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: var(--space-2);
}

.form-row {
    display: flex;
    gap: var(--space-3);
}

.form-row .auth-input {
    flex: 1;
}

.form-buttons {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-6);
    flex-wrap: wrap;
}

/* ===== SIGNUP FLOW ===== */

.signup-step {
    animation: fadeIn 0.3s ease-out;
}

.signup-student-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    padding: var(--space-6);
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.signup-student-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    justify-content: center;
}

.signup-student-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--white);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

.signup-student-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
}

.signup-confirmation {
    text-align: left;
    padding: var(--space-6);
    background: rgba(72, 187, 120, 0.08);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(72, 187, 120, 0.2);
    margin-bottom: var(--space-6);
}

.trial-features {
    list-style: none;
    padding: var(--space-3) 0;
}

.trial-features li {
    padding: var(--space-2) 0;
    padding-left: var(--space-6);
    position: relative;
}

.trial-features li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--foundation-green);
    font-weight: 700;
}

.avatar-color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.avatar-color-picker input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 2px;
}

/* ===== STUDENT SELECTION ===== */

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-5);
    margin: var(--space-6) 0;
}

.student-card {
    background: var(--white);
    border: 3px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.student-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.student-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.add-avatar {
    background: var(--border) !important;
    color: var(--text-secondary) !important;
    font-size: 2rem;
}

.add-student-card {
    border-style: dashed;
    opacity: 0.7;
}

.add-student-card:hover {
    opacity: 1;
}

.student-card-info h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.student-card-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.student-card-progress {
    font-weight: 600;
    color: var(--foundation-green) !important;
}

.selection-actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-4);
}

/* ===== ADD STUDENT FORM ===== */

.add-student-form {
    max-width: 400px;
    margin: var(--space-6) auto;
    padding: var(--space-6);
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.add-student-form h3 {
    font-family: var(--font-heading);
    color: var(--brand-primary);
    margin-bottom: var(--space-2);
}

/* ===== SUBSCRIPTION BADGES ===== */

.sub-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
}

.sub-badge.active {
    background: rgba(72, 187, 120, 0.15);
    color: var(--foundation-green);
    border: 1px solid var(--foundation-green);
}

.sub-badge.trial {
    background: rgba(246, 224, 94, 0.15);
    color: #b7791f;
    border: 1px solid #ecc94b;
}

.sub-badge.expired {
    background: rgba(245, 101, 101, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

/* ===== DASHBOARD ===== */

.dashboard-container {
    max-width: 800px;
    width: 100%;
    margin: var(--space-8) auto;
    padding: var(--space-8);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    animation: fadeInContent 0.5s ease-out;
}

.dashboard-header {
    text-align: center;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 2px solid var(--border);
}

.dashboard-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--brand-primary);
    margin-bottom: var(--space-2);
}

.dashboard-header p {
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.dashboard-section {
    margin-bottom: var(--space-8);
}

.dashboard-section h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.dashboard-actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}

/* Student rows in dashboard */
.student-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: var(--space-3);
}

.student-row-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.student-row-info {
    flex: 1;
    min-width: 0;
}

.student-row-info h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: var(--space-1);
}

.student-row-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.student-row-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Progress bar mini */
.progress-bar-mini {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--foundation-green), var(--foundation-gold));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Small buttons */
.btn-small {
    font-family: var(--font-heading);
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--bg-primary);
    border-color: var(--brand-primary);
}

.btn-small.btn-danger {
    color: var(--error);
    border-color: var(--error);
}

.btn-small.btn-danger:hover {
    background: rgba(245, 101, 101, 0.1);
}

/* ===== ADMIN DASHBOARD ===== */

.admin-stats {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-bottom: var(--space-6);
}

.admin-stat {
    text-align: center;
    padding: var(--space-4) var(--space-6);
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    min-width: 120px;
}

.admin-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--brand-primary);
    font-family: var(--font-mono);
}

.admin-stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-family-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: var(--space-3);
}

.admin-family-info h4 {
    font-family: var(--font-heading);
    margin-bottom: var(--space-1);
}

.admin-family-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.no-data {
    text-align: center;
    color: var(--text-light);
    padding: var(--space-8);
    font-style: italic;
}

/* ===== SETTINGS SCREENS ===== */

.settings-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    text-align: left;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.settings-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    flex-direction: row !important;
}

.toggle-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ===== SESSION BAR ===== */

.session-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-6);
    background: rgba(45, 55, 72, 0.9);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.session-bar.hidden {
    display: none;
}

.btn-session-logout {
    font-family: var(--font-body);
    padding: var(--space-1) var(--space-4);
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-session-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: white;
}

/* Offset screens when session bar is visible */
.session-bar:not(.hidden) ~ .screen.active#homeScreen {
    padding-top: calc(var(--space-3) + 40px);
}

/* ===== UPGRADE PROMPT OVERLAY ===== */

.upgrade-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.upgrade-overlay.hidden {
    display: none;
}

.upgrade-card {
    max-width: 480px;
    width: 90%;
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: var(--space-10);
    box-shadow: var(--shadow-2xl);
    text-align: center;
    animation: popIn 0.3s ease-out;
}

.upgrade-card h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--brand-primary);
    margin-bottom: var(--space-4);
}

.upgrade-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.upgrade-features {
    text-align: left;
    padding: var(--space-4);
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}

.upgrade-features ul {
    list-style: none;
    padding: 0;
}

.upgrade-features li {
    padding: var(--space-2) 0;
    padding-left: var(--space-5);
    position: relative;
    font-size: 0.9rem;
}

.upgrade-features li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--foundation-green);
    font-weight: 700;
}

/* Subscription-locked quest cards */
.quest-card.sub-locked {
    opacity: 0.5;
    border-color: var(--text-light);
}

.quest-card.sub-locked .btn-quest {
    background: var(--accent-orange);
}

/* ===== RANK PROGRESS BAR ===== */

.rank-progress {
    height: 10px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: var(--space-2) 0 var(--space-4);
}

.rank-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--foundation-green), var(--foundation-gold));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

/* ===== STATS MINI (home screen) ===== */

.stats-mini {
    display: flex;
    gap: var(--space-6);
    justify-content: center;
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.stat-item .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.stat-item .stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--foundation-green);
}

/* ===== COMPLETION ICON ===== */

.completion-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
}

.completion-message {
    margin: var(--space-6) 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.completion-stats {
    margin: var(--space-4) 0 var(--space-6);
    color: var(--text-secondary);
}

.completion-stats h4 {
    margin-bottom: var(--space-2);
}

/* ===== NAVIGATION BAR ===== */

.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-6);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.95), rgba(72, 187, 120, 0.95));
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    color: white;
    gap: var(--space-4);
}

.nav-bar.hidden {
    display: none;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
}

.nav-center {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-logo:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-logo-icon {
    font-size: 1.5rem;
}

.nav-student-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: rgba(255, 255, 255, 0.15);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    max-width: 300px;
}

.nav-student-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.nav-student-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-student-age {
    font-size: 0.85rem;
    opacity: 0.9;
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.nav-btn * {
    pointer-events: none;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.nav-btn-icon {
    font-size: 1.1rem;
}

.nav-btn-icon-only {
    padding: var(--space-2);
}

.nav-btn-icon-only .nav-btn-text {
    display: none;
}

/* Offset content when nav bar is visible */
.nav-bar:not(.hidden) ~ .screen {
    padding-top: calc(var(--space-3) + 60px);
}

.nav-bar:not(.hidden) ~ .screen#typingChallengeScreen {
    padding-top: calc(var(--space-2) + 60px);
}

/* ===== BACK BUTTONS ===== */

.back-button {
    position: absolute;
    top: var(--space-6);
    left: var(--space-6);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
}

.back-button * {
    pointer-events: none; /* Ensure child elements don't capture clicks */
}

.back-button:hover {
    background: var(--white);
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md);
    transform: translateX(-2px);
}

.back-button span:first-child {
    font-size: 1.2rem;
}

/* Back button on typing screen */
.back-button-small {
    position: static;
    padding: var(--space-1) var(--space-3);
    font-size: 0.85rem;
}

/* ===== TYPING SCREEN HEADER ===== */

.typing-screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-6);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    margin: 0 auto var(--space-3);
    max-width: 1200px;
    box-shadow: var(--shadow-sm);
    gap: var(--space-4);
}

.typing-header-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    flex: 1;
}

.typing-quest-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--brand-primary);
    font-weight: 600;
}

.typing-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== MODAL SYSTEM ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    max-width: 480px;
    width: 90%;
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    animation: popIn 0.3s ease-out;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-confirm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) var(--space-6) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.modal-header h2,
.modal-header h3 {
    font-family: var(--font-heading);
    color: var(--brand-primary);
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-4) var(--space-6) var(--space-6);
    border-top: 1px solid var(--border);
}

/* ===== SETTINGS MODAL ===== */

.settings-option {
    margin-bottom: var(--space-5);
}

.settings-option label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.modal-select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    outline: none;
    transition: border-color 0.2s ease;
    cursor: pointer;
}

.modal-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.toggle-option {
    display: flex !important;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.toggle-option:hover {
    background: rgba(0, 0, 0, 0.02);
}

.toggle-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-5) 0;
}

.modal-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: var(--space-2);
    pointer-events: auto;
}

.modal-btn * {
    pointer-events: none;
}

.modal-btn:hover {
    background: var(--bg-primary);
    border-color: var(--brand-primary);
}

.modal-btn-logout {
    color: var(--error);
    border-color: var(--error);
}

.modal-btn-logout:hover {
    background: rgba(245, 101, 101, 0.05);
}

.modal-btn span:first-child {
    font-size: 1.2rem;
}

/* ===== CONFIRMATION DIALOG ===== */

.modal-confirm .modal-body {
    text-align: center;
    padding: var(--space-8) var(--space-6);
}

.modal-confirm .modal-body p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* ===== RESPONSIVE NAVIGATION ===== */

@media (max-width: 768px) {
    .nav-bar {
        padding: var(--space-2) var(--space-4);
        gap: var(--space-2);
    }

    .nav-logo-text {
        display: none;
    }

    .nav-student-info {
        max-width: 180px;
        padding: var(--space-2) var(--space-3);
    }

    .nav-student-name {
        font-size: 0.9rem;
    }

    .nav-student-age {
        display: none;
    }

    .nav-btn-text {
        display: none;
    }

    .nav-btn {
        padding: var(--space-2);
    }

    .back-button {
        top: var(--space-4);
        left: var(--space-4);
        padding: var(--space-2) var(--space-3);
        font-size: 0.85rem;
    }

    .typing-screen-header {
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-2) var(--space-4);
    }

    .typing-header-progress {
        align-items: flex-start;
    }

    .typing-quest-title {
        font-size: 0.9rem;
    }

    .typing-progress-text {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .nav-student-info {
        max-width: 140px;
    }

    .nav-student-name {
        font-size: 0.8rem;
    }
}

/* ===== RESPONSIVE AUTH ===== */

@media (max-width: 640px) {
    .auth-container {
        margin: var(--space-6) var(--space-4);
        padding: var(--space-8);
    }

    .student-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .dashboard-container {
        margin: var(--space-4);
        padding: var(--space-6);
    }

    .student-row {
        flex-direction: column;
        text-align: center;
    }

    .student-row-actions {
        margin-top: var(--space-2);
    }

    .admin-stats {
        flex-direction: column;
        align-items: center;
    }

    .form-row {
        flex-direction: column;
    }
}
