@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&family=Comfortaa:wght@400;600&display=swap');
@import url('./src/styles/auth.css');

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-dark);
    font-family: var(--font-system);
    line-height: 1.6;
}

.app-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(34, 139, 34, 0.02) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}


.success-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10B981;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #EF4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

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

.app-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 5rem;
    background: transparent;
    contain: layout;
}

.section {
    display: none;
    min-height: calc(100vh - 140px);
    padding: var(--container-padding);
    background: transparent;
    contain: layout style;
}

.section.active {
    display: block;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem var(--container-padding);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
    opacity: 0.7;
}

.header-content {
    flex: 1;
    text-align: center;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: black;
    margin: 0 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.header-content h2 {
    font-family: var(--font-geez), serif;
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: black;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    position: relative;
}

.header-content h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
    border-radius: 1px;
}

.level-description {
    font-family: var(--font-modern);
    font-size: var(--font-size-base);
    color: #333333 !important;
    font-weight: 400;
    text-shadow: none;
    background: #FFFFFF !important;
    background-color: #FFFFFF !important;
    font-style: italic;
    letter-spacing: 0.01em;
    margin-top: 0.75rem;
    opacity: 0.9;
}

.level-progress {
    display: flex;
    align-items: center;
}

.progress-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.progress-circle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* ===== COMPACT HEADER STYLES ===== */
.header-content-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    color: black;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.level-info-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.level-number {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-dark);
}

.level-change-btn {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
}

.level-change-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.level-selector-arrow {
    font-size: 0.75rem;
    opacity: 0.7;
}

.progress-indicator {
    display: flex;
    align-items: center;
}

.progress-text-compact {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--primary);
}

/* Update app-header height for compact layout */
.app-header {
    padding: 0.5rem var(--container-padding); /* Reduced from 1rem */
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 5rem; /* Space for bottom nav */
}

.section {
    display: none;
    min-height: calc(100vh - 140px); /* Account for header + nav */
    padding: var(--container-padding);
}

.section.active {
    display: block;
}

/* ===== BOTTOM NAVIGATION WITH ACCESSIBILITY ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 2px solid var(--primary-light);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.bottom-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    background: none;
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-medium);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    border-radius: var(--border-radius-sm);
    position: relative;
    overflow: hidden;
}

/* Focus indicator for keyboard navigation */
.nav-item:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(255, 220, 0, 0.3);
}

.nav-item:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--primary);
    font-weight: 700;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 2px 2px;
}

.nav-icon {
    font-size: 1.375rem;
    margin-bottom: 0.25rem;
    transition: transform 0.2s ease;
}

.nav-item:hover .nav-icon {
    transform: scale(1.1);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

/* ===== FLASHCARD COMPONENTS ===== */
.flashcard-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
    padding: 2rem var(--container-padding);
}

.flashcard {
    width: 100%;
    height: 300px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard:active .flashcard-inner {
    transform: scale(0.98);
    transition: transform 0.1s ease-out;
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: auto;
    padding-top: 1rem;
    gap: 0.5rem;
}

.card-actions > div:empty {
    width: 60px; /* Reserve space for back button when not present */
}

.tap-hint {
    font-size: 0.75rem;
    color: var(--gray-600);
    opacity: 0.7;
    font-style: italic;
    text-align: center;
}

.keyboard-hint {
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-family: monospace;
    opacity: 0.8;
}

.character-display {
    font-family: var(--font-geez);
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 400;
    color: var(--slate-800);
    margin-bottom: 1rem;
    line-height: 1;
}

.sound-display {
    font-family: var(--font-playful);
    font-size: 2rem;
    font-weight: 600;
    color: var(--emerald-600);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--emerald-50), var(--emerald-100));
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    border: 2px solid var(--emerald-200);
    display: inline-block;
    min-width: 8rem;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sound-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.flashcard.flipped .sound-display::before {
    left: 100%;
}

.sound-display:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(34, 139, 34, 0.2);
    border-color: var(--emerald-300);
}

.phonetic-marker {
    font-family: var(--font-system);
    color: var(--emerald-500);
    opacity: 0.6;
    font-size: 1.5rem;
    font-weight: 400;
    margin: 0 0.1em;
}

.formula-hint {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 0.5rem;
    font-style: italic;
}

.formula-display {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
    font-family: var(--font-system);
}

.formula-display .geez-char {
    font-family: var(--font-geez);
    font-size: 1.25rem;
}

/* ===== BUTTONS WITH ETHIOPIAN COLORS ===== */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.875rem 1.75rem;
    font-weight: 700;
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: var(--touch-target);
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-nav {
    background: var(--primary-light);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--border-radius-sm);
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.btn-nav:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-nav:active {
    transform: translateY(0) scale(0.98);
}



/* Flip button styles removed - using simple click-to-flip instead */

/* ===== PROGRESS INDICATORS WITH ETHIOPIAN COLORS ===== */
.progress-dots {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    justify-content: center;
    align-items: center;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-medium);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--border-light);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.progress-dot.active {
    background: var(--primary);
    border-color: var(--primary-hover);
    transform: scale(1.4);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(34, 139, 34, 0.2);
}

.progress-dot.active::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border-light);
    border-radius: 6px;
    overflow: hidden;
    margin: 0.75rem 0;
    border: 1px solid var(--border-medium);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        var(--primary) 0%, 
        var(--ethiopian-green-light) 50%, 
        var(--primary) 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255,255,255,0.3) 50%, 
        transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== QUIZ COMPONENTS WITH ETHIOPIAN COLORS ===== */
.quiz-container {
    max-width: 560px;
    margin: 0 auto;
    padding-top: 1.5rem;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.25rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-light);
    position: relative;
}

.quiz-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.quiz-progress {
    font-size: var(--font-size-base);
    color: var(--text-black);
    font-weight: 700;
    background: var(--primary-light);
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--primary);
}

.quiz-xp {
    font-size: var(--font-size-base);
    color: var(--accent-hover);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--accent-light);
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--accent);
}

.formula-hint::before {
    content: '💡';
    font-size: 1rem;
}

.quiz-question {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 2px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.quiz-question::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

.quiz-prompt {
    font-size: var(--font-size-xl);
    color: var(--text-black);
    margin-bottom: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
}

.quiz-display {
    font-family: var(--font-geez);
    font-size: var(--font-size-geez);
    color: var(--text-black);
    margin: 2rem 0;
    font-weight: 400;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: var(--cream);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--border-light);
    line-height: 0.9;
}

.quiz-sound {
    font-size: var(--font-size-2xl);
    color: var(--primary);
    margin: 2rem 0;
    font-weight: 700;
    font-style: italic;
    background: var(--primary-light);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--primary);
    display: inline-block;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 2.5rem;
}

.quiz-option {
    background: #FFFFFF;
    border: 2px solid var(--primary-light);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem 1rem;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: #1A202C;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 56px; /* Larger touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-family: var(--font-system);
}

.quiz-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--text-black);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(34, 139, 34, 0.1);
}

.quiz-option:active {
    transform: translateY(0) scale(0.98);
}

.quiz-option.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(34, 139, 34, 0.3);
    transform: scale(1.02);
}

/* ✨ Clean quiz feedback - now using inline styles for simplicity */

.quiz-tts {
    background: #F59E0B;
    color: #1A202C;
    border: 2px solid #D97706;
    border-radius: var(--border-radius-sm);
    padding: 0.875rem 1.75rem;
    margin: 1.5rem 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    font-size: 1rem;
    min-width: 180px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.quiz-tts:hover {
    background: var(--accent-hover);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ✨ Removed complex animations - using simple inline styles for clean feedback */

/* ===== ACHIEVEMENT SYSTEM WITH ETHIOPIAN FLAIR ===== */
.achievement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-width: 360px;
    text-align: center;
    animation: achievementAppear 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid var(--primary);
    position: relative;
    overflow: hidden;
}

.achievement-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

.achievement-popup::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(34, 139, 34, 0.05) 0%, transparent 70%);
    z-index: -1;
    animation: achievementGlow 2s infinite alternate;
}

@keyframes achievementGlow {
    0% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes achievementAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotateY(-90deg);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1) rotateY(10deg);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotateY(0deg);
    }
}

/* Feedback animations */
@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

@keyframes bounceIn {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
    70% {
        transform: translate(-50%, -50%) scale(0.9);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes fadeInScale {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes celebrationBounce {
    0% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.achievement-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    animation: achievementIconBounce 2s infinite;
}

@keyframes achievementIconBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.achievement-name {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-black);
    margin-bottom: 0.75rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.achievement-description {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.achievement-xp {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--accent-hover);
    background: var(--accent-light);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--accent);
    display: inline-block;
    margin-top: 0.5rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ===== INSTALL PROMPT ===== */
.install-prompt {
    position: fixed;
    bottom: 6rem;
    left: var(--container-padding);
    right: var(--container-padding);
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 200;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.install-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--slate-800);
    margin-bottom: 0.5rem;
}

.install-content p {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.install-actions {
    display: flex;
    gap: 1rem;
}

.install-actions .btn-primary,
.install-actions .btn-secondary {
    flex: 1;
    padding: 0.75rem 1rem;
}

/* ===== DESIGN SYSTEM WITH ETHIOPIAN COLORS ===== */
:root {
    /* Ethiopian flag colors - Primary palette */
    --ethiopian-green: #228B22;
    --ethiopian-green-light: #32CD32;
    --ethiopian-green-dark: #006400;
    --ethiopian-green-50: #E8F5E8;
    --ethiopian-green-100: #D4F4D4;
    --ethiopian-green-200: #A7F3A7;
    
    --ethiopian-yellow: #FFDC00;
    --ethiopian-yellow-light: #FFF200;
    --ethiopian-yellow-dark: #DAA520;
    --ethiopian-yellow-50: #FFF9E6;
    --ethiopian-yellow-100: #FFF4CC;
    --ethiopian-yellow-200: #FFEB99;
    
    --ethiopian-red: #DA020E;
    --ethiopian-red-light: #FF1B28;
    --ethiopian-red-dark: #B8010C;
    --ethiopian-red-50: #FDEAEA;
    --ethiopian-red-100: #FBC7C8;
    --ethiopian-red-200: #F89D9F;
    
    /* High contrast neutrals for maximum readability */
    --white: #FEFEFE;
    --cream: #FCFCFC;
    --light-gray: #F8F9FA;
    --border-light: #E9ECEF;
    --border-medium: #CED4DA;
    --text-light: #6C757D;
    --text-medium: #495057;
    --text-dark: #212529;
    --text-black: #1A202C;
    
    /* Educational app colors for status and feedback */
    --success: var(--ethiopian-green);
    --warning: var(--ethiopian-yellow-dark);
    --danger: var(--ethiopian-red);
    --info: #0EA5E9;
    
    /* Semantic colors with Ethiopian integration */
    --primary: var(--ethiopian-green);
    --primary-hover: var(--ethiopian-green-dark);
    --primary-light: var(--ethiopian-green-50);
    --accent: var(--ethiopian-yellow);
    --accent-hover: var(--ethiopian-yellow-dark);
    --accent-light: var(--ethiopian-yellow-50);
    
    /* Background hierarchy for clean design */
    --bg-primary: var(--white);
    --bg-secondary: var(--cream);
    --bg-tertiary: var(--light-gray);
    
    /* Legacy support (gradually remove these) */
    --emerald-50: var(--ethiopian-green-50);
    --emerald-100: var(--ethiopian-green-100);
    --emerald-200: var(--ethiopian-green-200);
    --emerald-300: #86EFAC;
    --emerald-500: var(--ethiopian-green);
    --emerald-600: var(--ethiopian-green-dark);
    --emerald-700: #15803D;
    --gray-50: var(--light-gray);
    --gray-200: var(--border-light);
    --gray-600: var(--text-medium);
    --slate-800: var(--text-black);
    
    /* Design tokens */
    --font-geez: 'Noto Sans Ethiopic', 'Abyssinica SIL', serif;
    --font-system: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Inter', 'SF Pro Display', -apple-system, system-ui, sans-serif;
    --font-elegant: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-modern: 'Poppins', 'Inter', -apple-system, system-ui, sans-serif;
    --font-playful: 'Comfortaa', 'Nunito', 'Poppins', system-ui, sans-serif;
    --font-friendly: 'Nunito', 'Comfortaa', 'Poppins', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-geez: clamp(4rem, 8vw, 6rem);
    
    --border-radius: 0.75rem;
    --border-radius-sm: 0.5rem;
    --border-radius-xs: 0.25rem;
    --container-padding: 1rem;
    --touch-target: 48px; /* Increased for better accessibility */
    
    /* Shadows for depth hierarchy */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 8px 12px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.12);
    
    /* Performance optimizations */
    contain: layout;
}

/* ===== ACCESSIBILITY & FOCUS INDICATORS ===== */
/* Global focus styles with Ethiopian colors */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--border-radius-xs);
}

/* Button focus states */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-nav:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(255, 220, 0, 0.3);
}

/* Interactive element focus */
.flashcard:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

.quiz-option:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(255, 220, 0, 0.3);
}

.btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(255, 220, 0, 0.4);
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: var(--border-radius-xs);
    font-weight: 600;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #000000;
        --text-black: #000000;
        --white: #FFFFFF;
        --border-light: #000000;
    }
    
    .flashcard-front,
    .flashcard-back {
        border: 3px solid var(--text-black);
    }
    
    .quiz-option {
        border: 3px solid var(--text-black);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .flashcard-inner {
        transition: none;
    }
    
    .progress-dot.active::before {
        animation: none;
    }
}

/* ===== ADDITIONAL FLASHCARD STYLES ===== */
/* Removed hover effect to prevent conflicts with flip animation */

.flashcard .btn:hover {
    transform: scale(1.1);
}

.formula-display {
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    font-size: 1rem;
}

/* Enhanced Visual Formula Styling with Ethiopian Colors */
.visual-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--accent-light);
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.visual-formula::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

.formula-component {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    background: var(--white);
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--border-medium);
    min-width: 70px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.formula-component:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.formula-component .geez-char {
    font-family: var(--font-geez);
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-black);
    line-height: 0.9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.formula-component .sound-label {
    font-size: var(--font-size-xs);
    color: var(--text-medium);
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--border-radius-xs);
    font-family: var(--font-system);
}

.formula-operator {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    padding: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    background: var(--white);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--primary);
}

/* Ethiopian color coding for formula components */
.parent-char {
    border-color: var(--ethiopian-green);
    background: linear-gradient(135deg, var(--ethiopian-green-50) 0%, var(--ethiopian-green-100) 100%);
    position: relative;
}

.parent-char::after {
    content: 'Parent';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ethiopian-green);
    color: white;
    font-size: 0.5rem;
    padding: 0.125rem 0.25rem;
    border-radius: var(--border-radius-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.vowel-char {
    border-color: var(--ethiopian-yellow-dark);
    background: linear-gradient(135deg, var(--ethiopian-yellow-50) 0%, var(--ethiopian-yellow-100) 100%);
    position: relative;
}

.vowel-char::after {
    content: 'Vowel';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ethiopian-yellow-dark);
    color: white;
    font-size: 0.5rem;
    padding: 0.125rem 0.25rem;
    border-radius: var(--border-radius-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-char {
    border-color: var(--ethiopian-red);
    background: linear-gradient(135deg, var(--ethiopian-red-50) 0%, var(--ethiopian-red-100) 100%);
    transform: scale(1.08);
    font-weight: 700;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.result-char::after {
    content: 'Result';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ethiopian-red);
    color: white;
    font-size: 0.5rem;
    padding: 0.125rem 0.25rem;
    border-radius: var(--border-radius-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-char .geez-char {
    color: var(--ethiopian-red-dark);
    font-weight: 600;
}

.result-char .sound-label {
    color: var(--ethiopian-red-dark);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.9);
}

/* Formula loading state */
.formula-loading, .formula-error {
    padding: 0.5rem;
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
    font-size: 0.875rem;
}

.formula-error {
    color: var(--red-600);
    background: var(--red-50);
    border: 1px solid var(--red-200);
    border-radius: 6px;
}

/* Formula positioned in bottom-left corner for advanced levels */
.formula-corner {
    position: absolute;
    bottom: 60px;
    left: 20px;
    opacity: 0.8;
    transform: scale(0.5);
    transform-origin: left bottom;
    z-index: 1;
}

.formula-corner .formula-display {
    margin: 0;
    padding: 0.3rem;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
}

.formula-corner .visual-formula {
    padding: 0.4rem;
    margin: 0;
    gap: 0.3rem;
    border-width: 1px;
}

.formula-corner .formula-component {
    font-size: 0.8rem;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

/* ===== COMPLETION COMPONENTS ===== */
.completion-message-card {
    background: var(--white) !important;
    border-radius: var(--border-radius);
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    margin: 2rem auto;
    border: 2px solid var(--primary-light);
    position: relative;
    overflow: hidden;
    /* Ensure background stays white */
    background-color: #FFFFFF !important;
}

.completion-message-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

.completion-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.completion-message-card h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-black);
    margin-bottom: 0.75rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.level-name {
    font-size: var(--font-size-lg);
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.completion-text {
    font-size: var(--font-size-base);
    color: var(--text-dark);
    margin-bottom: 2rem;
    line-height: 1.6;
    font-weight: 500;
}

.completion-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 480px) {
    .completion-actions {
        flex-direction: row;
        justify-content: center;
    }
}

.completion-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.completion-hint {
    color: var(--text-medium);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.completion-hint small {
    color: var(--text-medium);
    font-weight: 600;
}

.quiz-prompt-card {
    background: #FFFFFF !important;
    background-color: #FFFFFF !important;
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    /* Force white background */
    color: #000000 !important;
}

.quiz-prompt-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
}

/* Removed - flags now handled by quiz-prompt-flags */

.quiz-prompt-flags {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 12px;
    pointer-events: none;
}

.quiz-flag-left, .quiz-flag-right {
    font-size: 1.25rem;
    opacity: 0.6;
}

.quiz-prompt-content {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000 !important;
}

/* Removed - no longer using quiz prompt icon */

.quiz-prompt-text {
    flex: 1;
    color: #000000 !important;
}

.quiz-prompt-text strong {
    color: #000000 !important;
    font-size: var(--font-size-lg);
    font-weight: 700;
    text-shadow: none;
}

.quiz-prompt-subtitle {
    font-size: var(--font-size-base);
    color: #000000 !important;
    margin-top: 0.25rem;
    font-weight: 600;
    opacity: 0.8;
}

.quiz-prompt-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
}

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

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.w-full { width: 100%; }
.h-full { height: 100%; }

/* ===== RESPONSIVE DESIGN ===== */
@media (min-width: 768px) {
    :root {
        --container-padding: 2rem;
        --touch-target: 48px;
    }
    
    .flashcard-container {
        max-width: 500px;
    }
    
    .character-display {
        font-size: clamp(4rem, 10vw, 6rem);
    }
    
    .quiz-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .install-prompt {
        max-width: 400px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

@media (min-width: 1024px) {
    :root {
        --container-padding: 3rem;
        --touch-target: 40px;
    }
    
    .flashcard-container,
    .quiz-container {
        max-width: 600px;
    }
    
    .character-display {
        font-size: 6rem;
    }
}

/* ===== SMOOTH TRANSITIONS ===== */
.section {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.section.active {
    opacity: 1;
    transform: translateY(0);
}

.quiz-option {
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-option:hover {
    transform: translateY(-3px) scale(1.02);
}

.flashcard-inner {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-dot {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary, .btn-secondary, .btn-nav {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flashcard {
    animation: fadeIn 0.5s ease-out;
}

.quiz-question {
    animation: slideInRight 0.4s ease-out;
}

.completion-message-card {
    animation: slideInLeft 0.5s ease-out;
}

/* XP Animation */
@keyframes xpFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-20px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.9);
    }
}

.xp-feedback {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    font-weight: 600;
    color: #D97706;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: xpFloat 2s ease-out forwards;
}

/* Ethiopian Confetti Animation */
@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Ethiopian themed confetti colors */
.confetti-ethiopian {
    background: var(--ethiopian-green) !important;
}

.confetti-ethiopian:nth-child(2n) {
    background: var(--ethiopian-yellow) !important;
}

.confetti-ethiopian:nth-child(3n) {
    background: var(--ethiopian-red) !important;
}

/* Success celebration with Ethiopian colors */
@keyframes ethiopianCelebration {
    0% { 
        transform: scale(1);
        filter: hue-rotate(0deg);
    }
    25% {
        transform: scale(1.1);
        filter: hue-rotate(90deg);
    }
    50% {
        transform: scale(0.95);
        filter: hue-rotate(180deg);
    }
    75% {
        transform: scale(1.05);
        filter: hue-rotate(270deg);
    }
    100% {
        transform: scale(1);
        filter: hue-rotate(360deg);
    }
}

.celebration-element {
    animation: ethiopianCelebration 1.5s ease-in-out;
}

/* ===== ERROR HANDLING ===== */
.error-message {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    color: #991B1B;
    max-width: 400px;
    margin: 2rem auto;
}

.error-message p {
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.error-message .btn-primary {
    background: #EF4444;
    border-color: #DC2626;
}

.error-message .btn-primary:hover {
    background: #DC2626;
}

/* Global error toast */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #EF4444;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    max-width: 300px;
    font-weight: 500;
}

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

.error-shake {
    animation: errorShake 0.5s ease-in-out;
}

/* ===== ENHANCED NAVIGATION WITH ACCESSIBILITY ===== */
.nav-spacer {
    width: 60px; /* Reserve space for navigation button when not present */
}

/* Keyboard navigation improvements */
.card-actions {
    gap: 0.75rem;
}

.card-actions button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    z-index: 1;
}

.nav-prev, .nav-next {
    background: var(--emerald-100);
    color: var(--emerald-700);
    border: 1px solid var(--emerald-200);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    min-width: 60px;
    position: relative;
}

.nav-prev:hover, .nav-next:hover {
    background: var(--emerald-200);
    border-color: var(--emerald-300);
    transform: translateY(-1px);
}

.nav-prev:active, .nav-next:active {
    transform: translateY(0) scale(0.98);
}

/* Desktop navigation tooltips */
@media (min-width: 768px) {
    .nav-prev::after, .nav-next::after {
        content: attr(title);
        position: absolute;
        bottom: calc(100% + 8px);
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        font-size: 0.75rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
        z-index: 1000;
    }
    
    .nav-prev:hover::after, .nav-next:hover::after {
        opacity: 1;
    }
}

/* ===== MASTER-LEVEL LEVEL SELECTION SYSTEM ===== */

/* Level Selection Container */
.level-selection-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--container-padding);
    min-height: calc(100vh - 140px);
}

/* Level Header */
.level-header {
    text-align: center;
    margin-bottom: 2rem;
}

.level-header-actions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.back-to-learning {
    background: var(--ethiopian-green);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-to-learning:hover {
    background: var(--ethiopian-green-dark);
    transform: translateY(-2px);
}

.level-header h2 {
    font-family: var(--font-elegant);
    font-size: var(--font-size-3xl);
    color: var(--ethiopian-green-dark);
    margin-bottom: 0.5rem;
    position: relative;
}

.level-header h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--ethiopian-green) 0% 33%, 
        var(--ethiopian-yellow) 33% 66%, 
        var(--ethiopian-red) 66% 100%);
    border-radius: 2px;
}

/* Progress Summary */
.level-progress-summary {
    background: linear-gradient(135deg, var(--ethiopian-green-50), var(--ethiopian-yellow-50));
    border: 2px solid var(--ethiopian-green-200);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 2rem 0;
}

.progress-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.progress-stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--ethiopian-green-dark);
    font-family: var(--font-modern);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-medium);
    font-weight: 600;
}

/* Level Cards */
.level-list, .level-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .level-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 1.5rem;
    }
    
    .level-list.mobile-optimized {
        display: none;
    }
    
    .level-grid.desktop-only {
        display: grid;
    }
}

.level-card {
    background: var(--white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 44px;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border-light);
    transition: all 0.3s ease;
}

/* Level Card States */
.level-card.completed {
    border-color: var(--ethiopian-green-200);
    background: linear-gradient(135deg, var(--ethiopian-green-50) 0%, var(--white) 100%);
}

.level-card.completed::before {
    background: var(--ethiopian-green);
}

.level-card.completed:hover {
    border-color: var(--ethiopian-green);
    box-shadow: 0 8px 25px rgba(34, 139, 34, 0.15);
    transform: translateY(-4px);
}

.level-card.current {
    border-color: var(--ethiopian-yellow);
    background: linear-gradient(135deg, var(--ethiopian-yellow-50) 0%, var(--white) 100%);
    animation: currentLevelPulse 3s ease-in-out infinite;
}

.level-card.current::before {
    background: linear-gradient(90deg, var(--ethiopian-yellow), var(--ethiopian-red));
}

.level-card.current:hover {
    border-color: var(--ethiopian-yellow-dark);
    box-shadow: 0 8px 25px rgba(255, 220, 0, 0.25);
    transform: translateY(-4px);
}

.level-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--gray-50);
    border-color: var(--border-light);
    filter: grayscale(0.5);
}

@keyframes currentLevelPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(255, 220, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 30px rgba(255, 220, 0, 0.4);
    }
}

/* Level Card Content */
.level-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.level-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ethiopian-green-100);
}

.level-card.current .level-icon {
    background: var(--ethiopian-yellow-100);
}

.level-card.locked .level-icon {
    background: var(--gray-200);
}

.level-name {
    font-family: var(--font-geez), var(--font-elegant);
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.level-description {
    font-size: var(--font-size-sm);
    color: var(--text-medium);
    line-height: 1.5;
}

/* Enhanced Learning Header */
.level-selector-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
}

.level-selector-btn:hover {
    transform: translateY(-2px);
}

.level-change-icon {
    font-size: 1.5rem;
    background: var(--ethiopian-green-100);
    padding: 0.5rem;
    border-radius: 50%;
}

.change-level-text {
    font-size: var(--font-size-sm);
    color: var(--ethiopian-green);
    font-weight: 600;
    opacity: 0.8;
}

/* Accessibility */
.level-card:focus {
    outline: 3px solid var(--ethiopian-yellow);
    outline-offset: 2px;
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    .level-card {
        min-height: 60px;
    }
    
    .level-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Profile Page Styles */
.profile-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #059669, #10B981);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
}

.profile-rank {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.rank-icon {
    font-size: 2rem;
}

.profile-rank h2 {
    margin: 0;
    font-size: 1.5rem;
}

.profile-xp {
    font-size: 1.25rem;
    font-weight: 600;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #E2E8F0;
}

.stat-card.primary {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.8;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.achievement-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #E2E8F0;
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.achievement-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.action-btn {
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn.export {
    background: #10B981;
    color: white;
}

.action-btn.reset {
    background: #EF4444;
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Quiz Menu Styles */
.quiz-menu {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.quiz-menu-header {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-menu-header h2 {
    margin: 0 0 0.5rem 0;
    color: #1A202C;
}

.quiz-menu-header p {
    color: #475569;
    margin: 0;
}

.quiz-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.quiz-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 2px solid #E2E8F0;
    transition: all 0.3s ease;
}

.quiz-card:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-color: #10B981;
}

.quiz-card.completed {
    border-color: #10B981;
    background: linear-gradient(135deg, #F0FDF4, #FFFFFF);
}

.quiz-card.locked {
    opacity: 0.6;
    background: #F8FAFC;
    border-color: #CBD5E1;
}

.quiz-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.quiz-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quiz-icon {
    font-size: 1.5rem;
}

.quiz-title h3 {
    margin: 0;
    font-size: 1.125rem;
    color: #1A202C;
}

.quiz-status {
    font-size: 1.25rem;
}

.quiz-info {
    margin-bottom: 1.5rem;
}

.quiz-details {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #475569;
}

.quiz-score {
    font-size: 0.875rem;
    color: #059669;
    font-weight: 600;
}

.quiz-start-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.quiz-start-btn.start {
    background: #10B981;
    color: white;
}

.quiz-start-btn.retake {
    background: #F59E0B;
    color: white;
}

.quiz-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ===== RECOMMENDED QUIZ SYSTEM ===== */
.recommended-section {
    margin-bottom: 2rem;
}

.section-header {
    margin-bottom: 1rem;
    text-align: center;
}

.section-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #1A202C;
}

.section-header p {
    margin: 0;
    font-size: 0.875rem;
    color: #64748B;
}

.quiz-card.recommended {
    border: 3px solid #10B981;
    background: linear-gradient(135deg, #ECFDF5, #FFFFFF);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15);
    transform: scale(1.02);
    position: relative;
    margin-bottom: 1rem;
}

.quiz-card.recommended:hover {
    transform: scale(1.03) translateY(-2px);
    box-shadow: 0 12px 35px rgba(16, 185, 129, 0.25);
}

.recommended-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.quiz-card.recommended .quiz-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #059669;
}

.quiz-card.recommended .quiz-icon {
    font-size: 1.75rem;
}

.quiz-start-btn.recommended {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 1rem 1.5rem;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.quiz-start-btn.recommended:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.other-quizzes-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #E2E8F0;
}

.other-quizzes-section .section-header {
    margin-bottom: 1.5rem;
}

.other-quizzes-section .quiz-card {
    opacity: 0.85;
    transform: scale(0.98);
}

.other-quizzes-section .quiz-card:hover {
    opacity: 1;
    transform: scale(1) translateY(-2px);
}

.quiz-locked-msg {
    text-align: center;
    color: #6B7280;
    font-style: italic;
    font-size: 0.875rem;
    padding: 0.875rem;
    background: #F9FAFB;
    border-radius: 6px;
}

.quiz-exit-btn {
    background: #EF4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-exit-btn:hover {
    background: #DC2626;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    /* Mobile-first responsive fixes */
    .quiz-list {
        grid-template-columns: 1fr;
    }
    
    .quiz-details {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    /* Ensure mobile touch targets */
    .btn, .quiz-option, .nav-item, .flashcard {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Mobile navigation improvements */
    .nav-item {
        padding: 0.75rem 1rem;
    }
    
    /* Better mobile spacing */
    .container, .main-container {
        padding: 0.5rem;
    }
    
    /* Mobile flashcard adjustments */
    .flashcard-container {
        padding: 0.25rem;
        gap: 0.25rem;
    }
    
    .flashcard {
        height: 260px;
    }
    
    /* Mobile flashcard content adjustments */
    .flashcard-front,
    .flashcard-back {
        padding: 1.25rem;        /* Reduce padding for mobile */
    }
    
    .character-display {
        font-size: 3rem;         /* Reduce from 4rem */
    }
    
    .sound-display {
        font-size: 1.5rem;       /* Reduce from 2rem for mobile */
        margin-bottom: 0.75rem;  /* Reduce margin */
    }
    
    /* Mobile navigation button adjustments */
    .btn-nav, .nav-prev, .nav-next {
        padding: 0.5rem 0.875rem; /* Smaller padding */
        font-size: 0.75rem;       /* Smaller text */
        min-width: 55px;          /* Smaller minimum width */
    }
    
    .completion-trigger {
        padding: 0.5rem 0.875rem; /* Match other nav buttons */
        font-size: 0.75rem;
    }
    
    /* Reduce overall page container height */
    main {
        min-height: auto;
        padding-bottom: 1rem;
    }
    
    .main-container {
        min-height: calc(100vh - 400px);
    }
    
    /* Also reduce header space */
    .header-content {
        padding: 0.5rem;
    }
    
    /* Reduce the main gray background section */
    .section {
        min-height: calc(100vh - 390px);
    }
    
    /* CRITICAL FIX: Ultra-compact completion message cards */
    .completion-message-card {
        padding: 0.75rem;        /* Ultra-compact padding */
        margin: 0.25rem auto;    /* Minimal margins */
        max-width: 260px;        /* Smaller width for mobile */
    }
    
    .completion-message-card h2 {
        font-size: 1.125rem;     /* Smaller title */
        margin-bottom: 0.25rem;  /* Reduce spacing to make room for progress */
    }
    
    .completion-icon {
        font-size: 1.5rem;       /* Smaller icon */
        margin-bottom: 0.25rem;  /* Minimal spacing */
    }
    
    .level-progress {
        font-size: 0.75rem;      /* Small progress text */
        color: var(--primary);   /* Green color to match theme */
        font-weight: 600;        /* Bold for emphasis */
        margin-bottom: 0.75rem;  /* Space before buttons */
        opacity: 0.9;            /* Slightly subtle */
    }
    
    .completion-actions {
        display: flex;
        gap: 0.5rem;            /* Small gap between buttons */
        justify-content: center;
    }
    
    .completion-actions .completion-btn {
        padding: 0.5rem 0.75rem; /* Compact button padding */
        font-size: 0.75rem;      /* Smaller button text */
        font-weight: 600;        /* Bold for readability */
        min-height: 36px;        /* Smaller button height */
        flex: 1;                 /* Equal button width */
        max-width: 100px;        /* Limit button width */
    }
    
    /* Fix other modal/overlay sizing issues */
    .achievement-popup {
        padding: 1rem;           /* Was 2.5rem - saves 48px */
        max-width: 280px;        /* Reduce from 360px */
    }
    
    /* Level complete modal - add missing styles */
    .level-complete-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2000;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .level-complete-modal .modal-backdrop {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
    }
    
    .level-complete-modal .modal-content {
        background: var(--white);
        border-radius: var(--border-radius);
        padding: 1rem;           /* Compact padding for mobile */
        max-width: 300px;        /* Smaller than desktop */
        max-height: 250px;       /* Prevent overflow */
        text-align: center;
        position: relative;
        z-index: 2001;
        box-shadow: var(--shadow-xl);
        overflow: hidden;
    }
    
    .level-complete-modal h2 {
        font-size: 1.25rem;      /* Smaller title */
        margin-bottom: 0.5rem;
    }
    
    .level-complete-modal .level-name {
        font-size: 0.875rem;     /* Smaller level name */
        margin-bottom: 0.5rem;
    }
    
    .level-complete-modal .completion-message {
        font-size: 0.875rem;     /* Smaller message text */
        margin-bottom: 1rem;
    }
    
    /* Level complete feedback (inline) */
    .level-complete-feedback {
        max-height: 80px;        /* Prevent taking too much space */
    }
    
    .level-complete-feedback .level-complete-icon {
        font-size: 1.5rem;       /* Smaller celebration icon */
    }
    
    .level-complete-feedback .level-complete-text {
        font-size: 1rem;         /* Smaller text */
    }
    
    /* Apply global component spacing optimizations */
    
    /* Quiz page optimizations */
    .quiz-container {
        padding-top: 0.5rem;     /* Was 1.5rem - reduce top padding */
    }
    
    .quiz-header {
        margin-bottom: 1rem;     /* Was 2rem - reduce bottom margin */
        padding: 1rem;           /* Was 1.25rem - slight reduction */
    }
    
    .quiz-card {
        padding: 1rem;           /* Was 1.5rem - reduce padding */
    }
    
    /* Profile page optimizations */
    .profile-header {
        padding: 1rem;           /* Was 2rem - reduce padding */
        margin-bottom: 1rem;     /* Was 2rem - reduce margin */
    }
    
    .profile-container {
        padding: 0.5rem;         /* Was 1rem - reduce padding */
    }
    
    /* Level selection optimizations */
    .level-card {
        padding: 1rem;           /* Was 1.5rem - reduce padding */
    }
    
    /* Games page optimizations (if exists) */
    .games-container {
        padding: 0.5rem;         /* Compact padding */
    }
    
    .mini-game-card {
        padding: 1rem;           /* Compact padding for game cards */
        margin-bottom: 0.5rem;   /* Reduce spacing between cards */
    }
    
    /* Install prompt optimization */
    .install-prompt .install-content {
        padding: 1rem;           /* Compact install prompt */
        max-width: 300px;        /* Smaller on mobile */
    }
}

/* Additional mobile touch support */
@media (hover: none) and (pointer: coarse) {
    /* Enhanced touch targets for mobile */
    .btn, .quiz-option, .nav-item {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover, .quiz-option:hover, .nav-item:hover {
        transform: none;
    }
    
    /* Add active states for better touch feedback */
    .btn:active, .quiz-option:active, .nav-item:active, .touch-active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Compact header mobile adjustments */
    .header-content-compact {
        padding: 0.375rem 0.75rem; /* Slightly smaller padding on mobile */
        margin: 0 0.5rem;
    }
    
    .level-info-compact {
        gap: 0.5rem; /* Reduce gap on mobile */
    }
    
    .level-number {
        font-size: var(--font-size-base); /* Slightly smaller on mobile */
    }
    
    .level-change-btn {
        padding: 0.25rem 0.375rem; /* Smaller padding */
        font-size: 0.75rem; /* Smaller text */
        min-height: 32px; /* Ensure touch target */
        min-width: 60px;
    }
    
    .progress-text-compact {
        font-size: var(--font-size-base); /* Smaller on mobile */
        padding: 0.25rem 0.375rem;
    }
    
    /* Reduce app-header padding even more on mobile */
    .app-header {
        padding: 0.375rem var(--container-padding);
    }
}

/* Touch feedback class for mobile devices */
.touch-active {
    transform: scale(0.98) !important;
    opacity: 0.8;
    transition: all 0.1s ease;
}

/* ===== HEADER USER PROFILE STYLES ===== */

/* Header authentication button */
.auth-trigger-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--emerald-50);
    color: var(--emerald-700);
    border: 1px solid var(--emerald-200);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-trigger-btn:hover {
    background: var(--emerald-100);
    border-color: var(--emerald-300);
    transform: translateY(-1px);
}

.auth-trigger-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Header user profile */
.header-user-profile {
    position: relative;
}

.header-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
}

.header-profile-btn:hover {
    background: var(--gray-50);
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
}

.header-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.header-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.header-user-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.header-user-status.verified {
    color: var(--emerald-600);
}

.header-user-status.anonymous {
    color: var(--amber-600);
}

.header-menu-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.header-profile-btn[aria-expanded="true"] .header-menu-arrow {
    transform: rotate(180deg);
}

/* Header profile dropdown menu */
.header-profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    min-width: 200px;
    padding: 0.5rem 0;
    animation: fadeInDown 0.2s ease-out;
}

.header-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-align: left;
}

.header-menu-item:hover {
    background: var(--gray-50);
}

.header-menu-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.header-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.5rem 0;
}

/* Dropdown animation */
@keyframes fadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive adjustments for header profile */
@media (max-width: 640px) {
    .header-profile-btn {
        padding: 0.25rem 0.5rem;
        min-width: 120px;
    }
    
    .header-user-name {
        font-size: 0.75rem;
        max-width: 60px;
    }
    
    .header-user-status {
        font-size: 0.625rem;
    }
    
    .header-avatar {
        width: 28px;
        height: 28px;
    }
    
    .auth-trigger-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .auth-trigger-btn .auth-btn-text {
        display: none; /* Hide text on mobile, show only icon */
    }
    
    .header-profile-menu {
        right: -1rem; /* Offset for mobile */
        left: -1rem;
        min-width: auto;
    }
}
