/**
 * Letras e Números - Estilos
 * Desenvolvido por B20 Conteúdo Digital
 * https://www.b20.com.br
 */

/* ========================================
   CSS CUSTOM PROPERTIES
   ======================================== */
:root {
    /* Paleta Candy Shop */
    --primary-color: #FFB6D9;
    --secondary-color: #FEE1E8;
    --accent-color: #FED7C3;
    --surface-color: #F6EAC2;
    --text-color: #5D4E6D;
    
    /* Derived Colors */
    --primary-hover: #FF9AC7;
    --primary-light: #FFD4E8;
    --primary-dark: #E89BBF;
    --bg-color: #FFFBF5;
    --text-muted: #8B7B9B;
    --text-light: #A99AB8;
    --border-color: #F0E4D7;
    --shadow-color: rgba(93, 78, 109, 0.1);
    
    /* Feedback Colors */
    --success-color: #7DD3A8;
    --success-light: #D4F5E4;
    --warning-color: #FFD166;
    --warning-light: #FFF3D4;
    --error-color: #FF8585;
    --error-light: #FFE4E4;
    --info-color: #7EB8DA;
    --info-light: #E4F3FA;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Typography */
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;
    --font-size-3xl: 48px;
    --font-size-4xl: 64px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 500;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-toast: 1100;
    --z-celebration: 1200;
    
    /* Header & Nav Heights */
    --header-height: 60px;
    --bottom-nav-height: 65px;
}



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

html {
    font-size: clamp(14px, 2.5vw, 16px);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    min-height: 100vh;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Safe Areas */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: max(var(--header-height), env(safe-area-inset-top));
    }
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-color);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-base); }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    box-shadow: 0 2px 12px var(--shadow-color);
    z-index: var(--z-fixed);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.header-logo h1 {
    font-size: var(--font-size-lg);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.desktop-nav {
    display: none;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Desktop Navigation */
@media (min-width: 768px) {
    .desktop-nav {
        display: flex;
        gap: var(--spacing-xs);
    }
    
    .desktop-nav .nav-link {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        padding: var(--spacing-sm) var(--spacing-md);
        border-radius: var(--radius-md);
        color: var(--text-muted);
        font-weight: 600;
        font-size: var(--font-size-sm);
        transition: all var(--transition-fast);
    }
    
    .desktop-nav .nav-link:hover {
        background: var(--secondary-color);
        color: var(--text-color);
        text-decoration: none;
    }
    
    .desktop-nav .nav-link.active {
        background: var(--primary-color);
        color: white;
    }
    
    .desktop-nav .nav-link i {
        font-size: var(--font-size-base);
    }
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px var(--shadow-color);
    z-index: var(--z-fixed);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--font-size-xs);
    font-weight: 600;
    transition: all var(--transition-fast);
    min-width: 60px;
    min-height: 48px;
}

.nav-item i {
    font-size: 20px;
    transition: transform var(--transition-bounce);
}

.nav-item.active {
    color: var(--primary-color);
}

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

.nav-item-fab {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    margin-top: -28px;
    color: white !important;
    box-shadow: 0 4px 16px rgba(255, 182, 217, 0.5);
    flex-direction: row;
}

.nav-item-fab i {
    font-size: 24px;
}

.nav-item-fab span {
    display: none;
}

/* Hide bottom nav on desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: none !important;
    }
    
    body {
        padding-bottom: 0;
    }
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--surface-color);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 48px;
    min-width: 48px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(255, 182, 217, 0.5);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--text-color);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-lg);
}

.btn-block {
    width: 100%;
}

.btn-circle {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}

.btn-circle.btn-lg {
    width: 64px;
    height: 64px;
    font-size: var(--font-size-xl);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--secondary-color);
    color: var(--text-color);
}

.btn-icon i {
    font-size: 20px;
}

.btn-close {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: var(--error-light);
    color: var(--error-color);
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.container {
    width: 100%;
    max-width: 100%;
    padding: var(--spacing-md);
    margin: 0 auto;
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
        padding: var(--spacing-lg);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }
}

/* Sections */
.section {
    display: none;
    animation: fadeIn var(--transition-base);
}

.section.active {
    display: block;
}

.section[hidden] {
    display: none !important;
}

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

.section-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.section-header h2 {
    margin-bottom: var(--spacing-sm);
}

.section-header p {
    color: var(--text-muted);
    margin-bottom: 0;
}

.section-title {
    font-size: var(--font-size-lg);
    margin: var(--spacing-xl) 0 var(--spacing-md);
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--shadow-color);
}

/* Welcome Card */
.welcome-card {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    text-align: center;
    margin-bottom: var(--spacing-lg);
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-avatar {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.avatar-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.welcome-title {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-xs);
}

.welcome-subtitle {
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--warning-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: var(--font-size-sm);
}

.streak-badge i {
    color: #FF6B35;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: 0 2px 12px var(--shadow-color);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-color);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.letters-icon { background: linear-gradient(135deg, #FF9A9E, #FECFEF); }
.numbers-icon { background: linear-gradient(135deg, #A8EDEA, #FED6E3); }
.stars-icon { background: linear-gradient(135deg, #FFD166, #FFA07A); }
.games-icon { background: linear-gradient(135deg, #667EEA, #764BA2); }

.stat-info {
    flex: 1;
}

.stat-value {
    display: block;
    font-size: var(--font-size-xl);
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Activity Grid */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.activity-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.activity-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.activity-card:active {
    transform: translateY(-2px);
}

.activity-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
}

.activity-card h4 {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-xs);
}

.activity-card p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.activity-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 2px var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 700;
}

/* Daily Challenge */
.daily-challenge {
    background: linear-gradient(135deg, var(--accent-color), var(--surface-color));
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.challenge-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.challenge-icon {
    font-size: var(--font-size-xl);
}

.challenge-header h4 {
    font-size: var(--font-size-base);
}

.challenge-text {
    color: var(--text-color);
    margin-bottom: var(--spacing-md);
}

.challenge-progress {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.challenge-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.challenge-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.challenge-status {
    font-weight: 700;
    font-size: var(--font-size-sm);
}

/* Achievements Preview */
.achievements-preview {
    margin-bottom: var(--spacing-lg);
}

.achievements-scroll {
    display: flex;
    gap: var(--spacing-md);
    overflow-x: auto;
    padding: var(--spacing-sm) 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.achievements-scroll::-webkit-scrollbar {
    display: none;
}

.achievement-badge {
    flex-shrink: 0;
    width: 80px;
    text-align: center;
}

.achievement-icon {
    width: 60px;
    height: 60px;
    background: var(--surface-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-xs);
    font-size: 28px;
    transition: all var(--transition-base);
}

.achievement-badge.unlocked .achievement-icon {
    background: linear-gradient(135deg, var(--warning-color), #FFA07A);
    box-shadow: 0 4px 16px rgba(255, 209, 102, 0.4);
}

.achievement-badge.locked .achievement-icon {
    filter: grayscale(1);
    opacity: 0.5;
}

.achievement-name {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
}

/* ========================================
   LETTERS SECTION
   ======================================== */
.letter-display {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.letter-card-large {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.letter-char {
    display: block;
    font-size: 120px;
    font-weight: 800;
    line-height: 1;
    color: var(--text-color);
    text-shadow: 4px 4px 0 rgba(255,255,255,0.5);
    animation: letterBounce 0.5s ease;
    text-align: center;
    margin: 0 auto;
}

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

.letter-word {
    display: block;
    font-size: var(--font-size-xl);
    color: var(--text-muted);
    margin-top: var(--spacing-md);
}

.letter-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Tracing Area */
.tracing-area {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.tracing-area h4 {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

#tracing-canvas {
    background: white;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
}

.canvas-controls {
    display: flex;
    gap: var(--spacing-md);
}

/* Alphabet Grid */
.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

.letter-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    font-weight: 800;
    background: var(--surface-color);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.letter-btn:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.letter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
}

.letter-btn.learned {
    background: var(--success-light);
    border-color: var(--success-color);
}

.letter-btn.learned::after {
    content: '✓';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   NUMBERS SECTION
   ======================================== */
.number-display {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.number-card-large {
    background: linear-gradient(135deg, var(--accent-color), var(--surface-color));
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.number-char {
    display: block;
    font-size: 120px;
    font-weight: 800;
    line-height: 1;
    color: var(--text-color);
    text-shadow: 4px 4px 0 rgba(255,255,255,0.5);
    animation: letterBounce 0.5s ease;
    text-align: center;
    margin: 0 auto;
}

.number-objects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    min-height: 60px;
}

.number-object {
    font-size: 32px;
    animation: popIn 0.3s ease backwards;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.number-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Counting Game */
.counting-game {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.counting-game h4 {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.counting-area {
    text-align: center;
}

.counting-objects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    min-height: 120px;
}

.counting-object {
    font-size: 40px;
    animation: popIn 0.3s ease backwards;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.counting-object:hover {
    transform: scale(1.2);
}

.counting-object.counted {
    opacity: 0.5;
    transform: scale(0.8);
}

.counting-input label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.number-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-sm);
}

.number-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    font-weight: 800;
    background: var(--surface-color);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.number-btn:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.number-btn.selected {
    background: var(--primary-color);
    color: white;
}

/* Numbers Grid */
.numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.number-grid-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    font-weight: 800;
    background: var(--surface-color);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.number-grid-btn:hover {
    background: var(--accent-color);
    transform: scale(1.05);
}

.number-grid-btn.active {
    background: var(--primary-color);
    color: white;
}

.number-grid-btn.learned {
    background: var(--success-light);
    border-color: var(--success-color);
}

/* ========================================
   GAMES SECTION
   ======================================== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.game-card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: all var(--transition-base);
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--shadow-color);
}

.game-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
}

.game-card h4 {
    margin-bottom: var(--spacing-xs);
}

.game-card p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

.game-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.game-difficulty {
    padding: 2px var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
}

.game-difficulty.easy {
    background: var(--success-light);
    color: var(--success-color);
}

.game-difficulty.medium {
    background: var(--warning-light);
    color: #E6A700;
}

.game-stars {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--warning-color);
    font-weight: 700;
}

/* Game Area */
.game-area {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
}

.game-score {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.score-label {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.score-value {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--primary-color);
}

.game-timer {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-muted);
}

.game-content {
    min-height: 300px;
}

/* Memory Game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    max-width: 400px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--primary-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: white;
    transition: all var(--transition-fast);
    transform-style: preserve-3d;
}

.memory-card:hover {
    transform: scale(1.05);
}

.memory-card.flipped {
    background: var(--surface-color);
    color: var(--text-color);
}

.memory-card.matched {
    background: var(--success-light);
    color: var(--success-color);
    cursor: default;
}

.memory-card .card-back {
    font-size: var(--font-size-xl);
}

/* Quiz Game */
.quiz-container {
    text-align: center;
}

.quiz-question {
    margin-bottom: var(--spacing-xl);
}

.quiz-image {
    font-size: 80px;
    margin-bottom: var(--spacing-md);
}

.quiz-text {
    font-size: var(--font-size-lg);
    color: var(--text-color);
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    max-width: 400px;
    margin: 0 auto;
}

.quiz-option {
    padding: var(--spacing-lg);
    background: var(--surface-color);
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-2xl);
    font-weight: 800;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quiz-option:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.quiz-option.correct {
    background: var(--success-light);
    border-color: var(--success-color);
}

.quiz-option.wrong {
    background: var(--error-light);
    border-color: var(--error-color);
}

/* Counting Game (in games) */
.counting-game-container {
    text-align: center;
}

.counting-game-objects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    min-height: 150px;
}

.counting-game-object {
    font-size: 48px;
    animation: popIn 0.3s ease backwards;
}

/* ========================================
   PROGRESS SECTION
   ======================================== */
.profile-card {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    position: relative;
}

.profile-avatar {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-shrink: 0;
}



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

.profile-info h3 {
    font-size: var(--font-size-lg);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-level {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.xp-bar {
    height: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 4px;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.xp-text {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

#edit-profile {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
}

/* Stats Overview */
.stats-overview {
    display: flex;
    justify-content: space-around;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px var(--shadow-color);
}

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

.stat-circle {
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto var(--spacing-sm);
}

.stat-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circle-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 3;
}

.circle-fill {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray var(--transition-slow);
}

.stat-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--font-size-base);
    font-weight: 800;
}

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

/* Achievements Grid */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.achievement-item {
    text-align: center;
    padding: var(--spacing-md);
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 12px var(--shadow-color);
    transition: all var(--transition-base);
}

.achievement-item:hover {
    transform: translateY(-2px);
}

.achievement-item .achievement-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto var(--spacing-sm);
}

.achievement-item.locked {
    opacity: 0.5;
}

.achievement-item.locked .achievement-icon {
    filter: grayscale(1);
}

.achievement-title {
    font-size: var(--font-size-xs);
    font-weight: 700;
    margin-bottom: 2px;
}

.achievement-desc {
    font-size: 10px;
    color: var(--text-muted);
}

/* Calendar Mini */
.calendar-mini {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: var(--spacing-md);
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px var(--shadow-color);
    margin-bottom: var(--spacing-xl);
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--surface-color);
}

.calendar-day.active {
    background: var(--success-color);
    color: white;
}

.calendar-day.today {
    border: 2px solid var(--primary-color);
}

/* Settings */
.settings-section {
    margin-bottom: var(--spacing-xl);
}

.settings-list {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-of-type {
    border-bottom: none;
}

.setting-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.setting-info i {
    width: 24px;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ========================================
   FAQ SECTION
   ======================================== */
.faq-section {
    margin-bottom: var(--spacing-xl);
}

.faq-container {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.faq-question:hover {
    background: var(--surface-color);
}

.faq-icon {
    transition: transform var(--transition-fast);
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 var(--spacing-lg) var(--spacing-md);
    color: var(--text-muted);
    animation: slideDown var(--transition-fast);
}

.faq-answer[hidden] {
    display: none;
}

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

/* ========================================
   PROGRESS BARS
   ======================================== */
.progress-section {
    margin-bottom: var(--spacing-xl);
}

.progress-section h4 {
    margin-bottom: var(--spacing-md);
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.progress-bar {
    flex: 1;
    height: 12px;
    background: var(--surface-color);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-text {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    background: var(--bg-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    animation: modalIn var(--transition-base);
}

.modal-sm {
    max-width: 320px;
}

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

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

.modal-header h3 {
    font-size: var(--font-size-lg);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.form-input {
    width: 100%;
    padding: var(--spacing-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--text-color);
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
}

.avatar-option {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.avatar-option:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.avatar-option.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.avatar-option img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    pointer-events: none;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--spacing-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

@media (min-width: 768px) {
    .toast-container {
        bottom: var(--spacing-lg);
    }
}

.toast {
    background: var(--text-color);
    color: var(--bg-color);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: toastIn var(--transition-base);
    pointer-events: auto;
}

.toast.success {
    background: var(--success-color);
    color: white;
}

.toast.error {
    background: var(--error-color);
    color: white;
}

.toast.warning {
    background: var(--warning-color);
    color: var(--text-color);
}

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

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

/* ========================================
   CELEBRATION OVERLAY
   ======================================== */
.celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-celebration);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.celebration-overlay[hidden] {
    display: none;
}

.celebration-content {
    text-align: center;
    padding: var(--spacing-2xl);
    animation: celebrationIn 0.5s ease;
}

@keyframes celebrationIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.celebration-emoji {
    font-size: 100px;
    animation: bounce 0.6s ease infinite;
}

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

.celebration-title {
    font-size: var(--font-size-2xl);
    color: white;
    margin: var(--spacing-md) 0;
}

.celebration-message {
    font-size: var(--font-size-lg);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--spacing-lg);
}

.celebration-stars {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.celebration-stars i {
    font-size: 40px;
    color: var(--warning-color);
    animation: starPop 0.5s ease backwards;
}

.celebration-stars i:nth-child(1) { animation-delay: 0.1s; }
.celebration-stars i:nth-child(2) { animation-delay: 0.2s; }
.celebration-stars i:nth-child(3) { animation-delay: 0.3s; }

@keyframes starPop {
    from {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xl);
}

.app-footer p {
    margin-bottom: var(--spacing-xs);
}

.b20-link {
    color: var(--primary-color);
    font-weight: 700;
    transition: all var(--transition-fast);
}

.b20-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ========================================
   SKELETON LOADING
   ======================================== */
.skeleton {
    background: linear-gradient(90deg, 
        var(--surface-color) 25%, 
        var(--border-color) 50%, 
        var(--surface-color) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: var(--spacing-sm);
    color: var(--text-color);
}

.empty-state p {
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   CONFETTI ANIMATION
   ======================================== */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confetti-fall 3s ease-out forwards;
    pointer-events: none;
    z-index: var(--z-celebration);
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .activity-grid {
        grid-template-columns: 1fr;
    }
    
    .letter-char,
    .number-char {
        font-size: 80px;
    }
    
    .quiz-options {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .activity-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .letter-char,
    .number-char {
        font-size: 150px;
    }
    
    .alphabet-grid {
        grid-template-columns: repeat(13, 1fr);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .app-header,
    .bottom-nav,
    .toast-container,
    .celebration-overlay,
    .modal {
        display: none !important;
    }
    
    body {
        padding: 0;
    }
    
    .section {
        display: block !important;
        page-break-inside: avoid;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
