:root {
    --bg-gradient-1: #8EC5FC;
    --bg-gradient-2: #E0C3FC;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --text-main: #2d3436;
    --text-muted: #636e72;
    --primary-color: #6c5ce7;
    --white: #ffffff;

    /* Font */
    --font-heading: 'Fredoka', sans-serif;

    --font-body: 'Nunito', sans-serif;

    /* Defaults for fallback */
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-focus-bg: #ffffff;
    --element-bg: rgba(255, 255, 255, 0.5);
    --element-active-bg: #ffffff;
    --hover-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    min-height: 100vh;
    color: var(--text-main);
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
}

/* Glassmorphism Utilities */
.glass-panel,
.glass-card,
.glass-header,
.glass-content-area {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* App Container */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Loading Overlay Fix */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
}

.view-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

.center-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Profile Creation */
.profile-creation {
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.logo-area {
    margin-bottom: 2rem;
}

.school-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 0.5rem;
}

h1 {
    font-family: var(--font-heading);
    margin: 0;
    font-size: 2.5rem;
    color: var(--primary-color);
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--text-muted);
}

input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1.1rem;
    font-family: var(--font-body);
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--input-focus-bg);
}

/* Radio buttons and checkboxes */
input[type="radio"],
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-right: 10px;
    accent-color: var(--primary-color);
}

input[type="radio"]:focus,
input[type="checkbox"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.avatars-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 2rem;
}

.avatar-option {
    font-size: 2rem;
    background: var(--element-bg);
    border-radius: 50%;
    padding: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.avatar-option:hover {
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary-color);
    background: var(--element-active-bg);
}

/* Button System */
.btn-primary,
.btn-secondary,
.btn-icon {
    border: none;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary:active,
.btn-secondary:active,
.btn-icon:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 30px;
    font-size: 1.2rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

/* Glass Header Specifics */
.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Back to center for alignment safety */
    padding: 15px 30px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    /* Prevent wrapping */
    gap: 15px;
    /* Spacing */

    /* Sticky Magic */
    position: sticky;
    top: 10px;
    z-index: 1000;
    /* Smooth Transition for Container */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Explicit transitions for children to prevent jumpiness */
.glass-header h2,
.glass-header .header-title,
.glass-header .btn-icon,
.glass-header .btn-secondary,
.glass-header .btn-primary,
.glass-header .user-avatar,
.glass-header .username,
.glass-header .long-title,
.glass-header .header-actions,
.glass-header .user-info {
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Scrolled State (Compact) */
/* Scrolled State (Compact) */
.glass-header.scrolled {
    padding: 2px 10px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    top: 0;
    border-radius: 0 0 15px 15px;
    margin-top: 0;
    margin-bottom: 120px;
    /* Layout Shift Fix: Compensate for height reduction */
}

/* Fluid Hiding of Elements */
.long-title,
.header-actions,
.user-info,
.greeting,
.theme-selector,
/* Assuming class name */
.glass-header select {
    transition: all 0.3s ease;
    opacity: 1;
    max-width: 500px;
    /* Arbitrary large width for transition */
}

/* Scrolled: Hide detailed info */
.glass-header.scrolled .long-title,
.glass-header.scrolled .header-actions,
.glass-header.scrolled .user-info,
.glass-header.scrolled .greeting,
.glass-header.scrolled .theme-selector,
.glass-header.scrolled select {
    opacity: 0;
    max-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
    border: none;
    /* Ensure no border remains */
    display: none !important;
    /* Force remove from flow to be sure */
}

/* Direct Sizing Updates (No Transforms) */
.glass-header.scrolled .user-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 1.2rem !important;
}

.glass-header.scrolled .username {
    font-size: 0.9rem;
}

.glass-header.scrolled .btn-icon,
.glass-header.scrolled .btn-secondary,
.glass-header.scrolled .btn-primary {
    padding: 2px 8px !important;
    font-size: 0.8rem !important;
}

.glass-header.scrolled h2,
.glass-header.scrolled .header-title {
    font-size: 1.1rem !important;
    margin: 0 !important;
    white-space: nowrap;
}

/* Move Back Button back to Left (Compact) */
.glass-header.scrolled #back-to-levels,
.glass-header.scrolled #back-to-subjects,
.glass-header.scrolled #back-to-content,
.glass-header.scrolled #exit-exercise {
    position: static;
    /* Back to flow */
    transform: none;

    background: var(--primary-color) !important;
    color: white !important;
    border-radius: 20px;
    padding: 2px 8px !important;
    font-size: 0.75rem !important;
    /* Tiny text */
    margin-right: 10px;
    box-shadow: none;
    white-space: nowrap;
}

/* Ensure title doesn't break alignment */
.glass-header.scrolled h2,
.glass-header.scrolled .header-title {
    font-size: 0.9rem !important;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive tweaks for header */
@media (max-width: 600px) {
    .glass-header {
        padding: 10px 15px;
        top: 0;
        border-radius: 0 0 15px 15px;
    }

    .glass-header.scrolled .user-info {
        display: none;
    }
}


/* Breadcrumb Navigation Bar */
.breadcrumb-bar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 15px;
    border: var(--glass-border);
    padding: 0.75rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb-bar .breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.breadcrumb-bar .breadcrumb-separator {
    color: var(--text-muted);
    opacity: 0.5;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    font-size: 2.5rem;
    background: var(--white);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.user-text {
    display: flex;
    flex-direction: column;
}

.greeting {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.username {
    font-weight: 700;
    font-size: 1.4rem;
    font-family: var(--font-heading);
}

.btn-icon {
    background: var(--element-bg);
    color: var(--text-main);
    padding: 8px 15px;
    border-radius: 12px;
    font-weight: 600;
    gap: 8px;
}

.btn-icon:hover {
    background: var(--hover-bg);
}

.btn-secondary {
    background: var(--element-bg);
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

/* Dashboard Grids */
.section-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--white);
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    padding: 1rem;
}

.level-card {
    aspect-ratio: 1;
    background: var(--element-bg);
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 4px solid transparent;
}

.level-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.level-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.level-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
}

/* Subjects Grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
}

.subject-card {
    background: var(--glass-bg);
    padding: 1.5rem;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.subject-card:hover {
    background: var(--hover-bg);
    transform: translateY(-5px);
}

.subject-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.subject-name {
    font-weight: 700;
    color: var(--text-main);
}

/* Content Area */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.emoji-large {
    font-size: 5rem;
    display: block;
}

.path-display {
    background: rgba(0, 0, 0, 0.05);
    padding: 5px 10px;
    border-radius: 8px;
    font-family: monospace;
}

.instruction {
    max-width: 400px;
    line-height: 1.6;
    color: var(--text-muted);
}

.profile-item {
    transition: transform 0.2s, background 0.2s;
    padding: 10px;
    border-radius: 12px;
}

.profile-item:hover {
    transform: translateY(-5px);
    background: var(--hover-bg);
}

.profile-item div:first-child {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s;
}


.profile-item:hover div:first-child {
    border-color: var(--primary-color) !important;
}

/* Emoji Picker Styles */
.emoji-picker {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 320px;
    z-index: 1000;
    padding: 10px;
}

.emoji-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-grid span {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 5px;
    text-align: center;
}

.emoji-grid span:hover {
    background: #f0f0f0;
}

.emoji-btn {
    background: white;
    border: 1px solid #ddd;
    border-left: none;
    border-radius: 0 12px 12px 0;
    padding: 0 15px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.emoji-btn:hover {
    background: #f9f9f9;
}



/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {

    /* General Container Padding */
    .view-container {
        padding: 0 10px;
    }

    #app {
        padding: 10px;
    }

    /* Headers */
    .glass-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 1rem;
    }

    .glass-header div[style*="display:flex"] {
        flex-wrap: wrap;
        justify-content: center;
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Profile Creation */
    .profile-creation {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2rem;
    }

    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Grids */
    .levels-grid {
        display: flex;
        /* Use flex column for absolute stacking certainty */
        flex-direction: column;
        gap: 1.5rem;
    }

    .level-card {
        aspect-ratio: auto;
        /* Remove square constraint on mobile */
        min-height: 150px;
        width: 100%;
    }

    .subjects-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    /* Buttons & Inputs */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin-bottom: 5px;
    }

    .input-group input {
        font-size: 1rem;
    }

    /* Exercise View */
    .exercise-actions {
        flex-direction: column;
        gap: 10px;
    }
}

/* --- Futuristic Themes --- */
/* Themes have been moved to assets/themes/ */

/* Hyper-jump Animation Class */
.warp-active {
    animation: hyperJump 0.4s ease-in forwards;
}

@keyframes hyperJump {
    0% {
        transform: scale(1);
        filter: brightness(1) blur(0);
        opacity: 1;
    }

    50% {
        transform: scale(0.9);
        filter: brightness(2) blur(2px);
        opacity: 0.8;
    }

    100% {
        transform: scale(3);
        filter: brightness(5) blur(10px);
        opacity: 0;
    }
}

/* Matching Exercise Styles - Dropdown Based */
.matching-dropdown-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
}

.matching-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.5fr;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: var(--glass-bg);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.matching-col-a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
    text-align: center;
    padding: 10px;
    background: rgba(108, 92, 231, 0.1);
    border-radius: 8px;
}

.matching-col-dropdown {
    display: flex;
    align-items: center;
}

.matching-select {
    width: 100%;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s;
}

.matching-select:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: var(--input-focus-bg);
}

.matching-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--input-focus-bg);
}

/* Visual Feedback Banners */
.feedback-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 50px;
    border-radius: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    z-index: 10000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: feedbackPop 0.3s ease-out;
    transition: opacity 0.3s ease;
    text-align: center;
    max-width: 80%;
}

.feedback-correct {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
}

.feedback-incorrect {
    background: linear-gradient(135deg, #d63031, #e17055);
    color: white;
}

@keyframes feedbackPop {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Modal Overlay for Finish Screen */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 20001;
    /* Above feedback and theme overrides */
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Score Badges */
.score-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    z-index: 5;
}

/* Perfect Score Styles */
.card-perfect {
    border-color: #ffd700 !important;
    background: linear-gradient(135deg, #fff, #fff9e6) !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4) !important;
}

.score-perfect {
    background: #ffd700 !important;
    color: #d35400 !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.score-good {
    background: #00b894 !important;
    color: white !important;
}

/* Responsive Grid Utilities */
/* Responsive Grid Utilities (Flexbox) */
.responsive-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin-top: 20px;
}

.responsive-grid>div {
    width: 180px;
    flex-grow: 0;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .responsive-grid {
        gap: 10px;
    }

    .responsive-grid>div {
        width: 45%;
        flex-grow: 1;
    }
}