/* Extracted from templates/letters.html style block 1 */
:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --primary-dark: #3a0ca3;
    --secondary: #f72585;
    --accent: #4cc9f0;
    --success: #4ade80;
    --warning: #f59e0b;
    --error: #ef4444;
    --background: #ffffff;
    --surface: #ffffff;
    --surface-light: #f8fafc;
    --text: #1e293b;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-light: 0 5px 15px rgba(0, 0, 0, 0.05);
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-light));
    --gradient-accent: linear-gradient(135deg, var(--accent), var(--primary-light));
    --gradient-success: linear-gradient(135deg, var(--success), #22c55e);
    --gradient-surface: linear-gradient(135deg, #ffffff, #f8fafc);
    
    --night-bg: #0f172a;
    --night-surface: #1e293b;
    --night-text: #f1f5f9;
    --night-text-secondary: #cbd5e1;
    --night-border: #475569;
    --night-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.night-mode {
    --background: var(--night-bg);
    --surface: var(--night-surface);
    --surface-light: #334155;
    --text: var(--night-text);
    --text-secondary: var(--night-text-secondary);
    --border: var(--night-border);
    --shadow: var(--night-shadow);
    --shadow-light: 0 5px 15px rgba(0, 0, 0, 0.2);
    --gradient-surface: linear-gradient(135deg, var(--surface), #1e293b);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Touch feedback for buttons */
button:active, .btn-touch-active, .control-btn:active, .game-card:active {
    transform: scale(0.92);
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy effect */
}

/* Animation for buttons */
@keyframes buttonPop {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.btn-animate {
    animation: buttonPop 0.3s ease-out;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    min-height: 100vh;
    background: var(--background);
    font-family: 'Segoe UI', 'Tajawal', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    line-height: 1.6;
    padding: 20px 15px;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(67, 97, 238, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(244, 114, 182, 0.05) 0%, transparent 40%);
    transition: all 0.3s ease;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.night-mode body {
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(67, 97, 238, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(244, 114, 182, 0.1) 0%, transparent 40%);
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.3s ease;
}

.app-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    z-index: 10;
}

/* Header Styles */
.app-header {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.night-mode .app-header {
    background: rgba(30, 41, 59, 0.95);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
    box-shadow: var(--shadow-light);
}

.logo-text h1 {
    font-size: 18px;
    margin: 0;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    line-height: 1.2;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin: 0;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text);
    cursor: pointer;
    padding: 5px;
    margin-left: 15px; /* Space between hamburger and logo in RTL */
}

/* Mobile Header Layout */
@media (max-width: 768px) {
    .app-header {
        justify-content: flex-start; /* Align specifically for mobile customization */
    }
    
    .hamburger-btn {
        display: block;
        order: -1; /* Ensure it's first */
    }
    
    .logo-section {
        margin-right: 0;
    }
    
    .user-controls {
        margin-right: auto; /* Push to the left */
    }
}



/* User Menu & Dropdown */
.user-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-auth-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-auth-actions .btn {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
}

.learning-levels-nav {
    display: flex;
    align-items: stretch;
    gap: 8px;
    max-width: min(760px, 58vw);
    overflow-x: auto;
    padding: 4px 2px;
    scrollbar-width: thin;
}

.learning-level-link {
    min-height: 44px;
    min-width: 138px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text);
    text-decoration: none;
    touch-action: manipulation;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.learning-level-link:hover,
.learning-level-link.is-active {
    transform: translateY(-1px);
    border-color: var(--primary-light);
    box-shadow: 0 12px 24px rgba(67, 97, 238, 0.14);
}

.learning-level-link.is-active {
    color: #111827;
    background: linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
    border-color: rgba(67, 97, 238, 0.42);
    box-shadow: 0 16px 32px rgba(67, 97, 238, 0.18);
}

.learning-level-link.is-active::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.12);
    margin-inline-start: auto;
}

.learning-level-link i {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #ffffff;
    background: var(--gradient-primary);
}

.learning-level-text {
    display: grid;
    gap: 1px;
    line-height: 1.15;
    white-space: nowrap;
}

.learning-level-text strong {
    font-size: 0.86rem;
    font-weight: 900;
}

.learning-level-text small {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 800;
}

.night-mode .learning-level-link {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.night-mode .learning-level-link.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.32), rgba(16, 185, 129, 0.14));
    border-color: rgba(147, 197, 253, 0.42);
}

.menu-section-label {
    margin: 10px 6px 4px;
    color: #111827;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0;
}

.learning-menu-item {
    min-height: 58px;
    align-items: center;
    border-color: rgba(226, 232, 240, 0.9);
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.learning-menu-item span {
    display: grid;
    gap: 2px;
}

.learning-menu-item strong {
    font-size: 0.96rem;
    font-weight: 900;
}

.learning-menu-item small {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 800;
}

.learning-menu-item.is-active {
    color: #111827;
    border-color: rgba(67, 97, 238, 0.42);
    background: linear-gradient(135deg, #eef4ff 0%, #ffffff 64%);
    box-shadow: 0 14px 28px rgba(67, 97, 238, 0.16);
}

.learning-menu-item.is-active i {
    color: #ffffff;
    background: var(--gradient-primary);
    border-radius: 8px;
    padding: 6px;
}

.night-mode .menu-section-label {
    color: #f8fafc;
}

.night-mode .learning-menu-item {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.user-menu-container {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-btn:hover {
    background: var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.user-name-display {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: none; /* Hidden on very small screens */
}

@media (min-width: 600px) {
    .user-name-display { display: block; }
}

.dropdown-menu {
    position: fixed;
    top: 0;
    right: -330px; /* Start off-screen */
    width: 320px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 20px;
    transition: right 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 2000;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: -18px 0 42px rgba(15, 23, 42, 0.14);
}

.dropdown-menu.show {
    right: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    bottom: 0;
    display: flex !important; /* Ensure flex is maintained */
}

.night-mode .dropdown-menu {
    background: var(--surface);
    border-color: var(--border);
}

.night-mode .dropdown-menu {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

/* .dropdown-menu.show is handled above */

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    .hamburger-btn {
        display: block;
    }

    .learning-levels-nav {
        max-width: 100%;
        width: 100%;
        order: 3;
    }

    .learning-level-link {
        min-width: 146px;
    }

    .user-controls {
        width: 100%;
        margin-right: 0;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .header-auth-actions {
        display: none;
    }
    
    .user-menu-btn {
        display: none;
    }
    
    .dropdown-menu {
        position: fixed;
        top: 0;
        right: -330px; 
        width: min(330px, 92vw);
        height: 100vh;
        background: var(--surface);
        border-radius: 0;
        border: none;
        border-left: 1px solid var(--border);
        padding: 20px;
        transition: right 0.3s ease;
        display: flex; /* Always flex */
        z-index: 2000;
        box-shadow: -18px 0 42px rgba(15, 23, 42, 0.14);
        animation: none;
        transform: none;
        flex-direction: column;
        gap: 5px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    
    .dropdown-menu.show {
        right: 0;
        display: flex;
    }
    
    .mobile-only {
        display: flex !important;
    }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    border-radius: 12px;
    color: #111827;
    text-decoration: none;
    font-size: 15px;
    font-weight: 800;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    text-align: right;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.menu-item:hover {
    background: var(--surface-light);
    color: var(--primary);
    transform: translateX(-5px);
    border-color: var(--border);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.09);
}

.night-mode .menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-item:active {
    transform: translateX(-2px) scale(0.98);
}

.menu-item i {
    width: 24px;
    text-align: center;
    color: #475569;
    font-size: 18px;
    transition: color 0.2s;
}

.night-mode .menu-item {
    color: #f8fafc;
}

.menu-item:hover i {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(67, 97, 238, 0.3);
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Mobile Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.2);
    z-index: 1000;
    display: none;
}
.menu-overlay.active { display: block; }

/* Theme Toggle (Small) */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}
.theme-toggle-btn:hover {
    background: var(--surface-light);
    color: var(--warning);
}


/* Letters Navigation */
.letters-nav {
    padding: 15px 20px;
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    display: flex;
    gap: 10px;
    transition: all 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
}

.letters-nav::-webkit-scrollbar {
    height: 6px;
}

.letters-nav::-webkit-scrollbar-track {
    background: transparent;
}

.letters-nav::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 3px;
}

.night-mode .letters-nav {
    background: rgba(30, 41, 59, 0.9);
}

.letter-tab {
    min-width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    font-weight: 700;
    flex-shrink: 0;
}

.night-mode .letter-tab {
    background: rgba(30, 41, 59, 0.9);
}

.letter-tab.active {
    background: var(--gradient-primary);
    border-color: var(--primary-light);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-light);
}

.letter-tab.completed::after {
    content: '✓';
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--success);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.letter-tab.locked {
    opacity: 0.5;
    cursor: pointer;
    background: rgba(248, 250, 252, 0.9);
}

.night-mode .letter-tab.locked {
    background: rgba(30, 41, 59, 0.9);
}

.letter-tab.locked::before {
    content: '🔒';
    position: absolute;
    font-size: 12px;
    top: -5px;
    right: -5px;
}

.letter-tab.locked::before {
    content: '\1F512';
}

.letter-tab.locked::after {
    display: none;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 25px;
}

@media (max-width: 900px) {
    .main-content {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .main-content > * {
        width: 100%;
        display: block !important; /* Ensure no section is hidden */
    }
}

.panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.night-mode .panel {
    background: rgba(30, 41, 59, 0.95);
}

/* Improved Touch Targets for Mobile */
@media (max-width: 768px) {
    .btn, .modal-btn, .control-btn {
        min-height: 48px; /* Recommended touch target size */
        min-width: 48px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .game-controls {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .game-controls .btn {
        flex: 1;
        min-width: 120px;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.letter-title-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.letters-worksheet-book-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 20px;
    border: 0;
    background: linear-gradient(135deg, #0f766e 0%, #2563eb 55%, #7c3aed 100%);
    color: #ffffff;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.letters-worksheet-book-btn span,
.letters-worksheet-book-btn small {
    display: block;
    line-height: 1.15;
}

.letters-worksheet-book-btn small {
    opacity: 0.88;
    font-size: 11px;
    font-weight: 700;
}

.letters-worksheet-book-btn:hover,
.letters-worksheet-book-btn:focus-visible {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.3);
}

@media (max-width: 520px) {
    .letter-title-actions {
        width: 100%;
    }

    .letter-title-actions .download-worksheet-btn,
    .letters-worksheet-book-btn {
        width: 100%;
    }
}

.panel-badge {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary);
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 12px;
    border: 1px solid rgba(67, 97, 238, 0.2);
    font-weight: 600;
}

.night-mode .panel-badge {
    background: rgba(67, 97, 238, 0.2);
}

/* Letter Display */
.letter-display {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.letter-visual {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.letter-visual::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite linear;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.letter-uppercase {
    font-size: 42px;
    line-height: 1;
}

.letter-lowercase {
    font-size: 32px;
    line-height: 1;
    opacity: 0.9;
}

.letter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    padding: 10px 18px;
    border-radius: 50px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
    user-select: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-light);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--error);
    color: #ffffff;
    border: 1px solid var(--error);
}

.night-mode .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

.external-games-btn {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 46px;
    padding-inline: 20px;
    color: #ffffff !important;
    text-decoration: none;
    background: linear-gradient(135deg, #7c3aed 0%, #4361ee 52%, #10b981 100%);
    border: 1px solid rgba(255, 255, 255, 0.38);
    box-shadow: 0 14px 28px rgba(67, 97, 238, 0.24);
    animation: externalGamesFloat 2.7s ease-in-out infinite;
}

.external-games-btn::before {
    content: "";
    position: absolute;
    inset: -45% auto -45% -35%;
    width: 38%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transform: rotate(18deg) translateX(-120%);
    animation: externalGamesShine 3.4s ease-in-out infinite;
    z-index: -1;
}

.external-games-btn span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.external-games-btn:hover {
    color: #ffffff !important;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 18px 34px rgba(67, 97, 238, 0.32);
}

.external-games-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.letter-worksheet-btn {
    position: relative;
    isolation: isolate;
    min-height: 46px;
    padding-inline: 20px;
    color: #ffffff !important;
    background: linear-gradient(135deg, #0f9f6e 0%, #10b981 48%, #2563eb 100%);
    border: 1px solid rgba(255, 255, 255, 0.38);
    box-shadow: 0 14px 28px rgba(16, 185, 129, 0.22);
}

.letter-worksheet-btn:hover {
    color: #ffffff !important;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 18px 34px rgba(16, 185, 129, 0.3);
}

.letter-worksheet-btn span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
}

@keyframes externalGamesFloat {
    0%, 100% {
        box-shadow: 0 14px 28px rgba(67, 97, 238, 0.24);
    }
    50% {
        box-shadow: 0 18px 36px rgba(124, 58, 237, 0.32);
    }
}

@keyframes externalGamesShine {
    0%, 35% {
        transform: rotate(18deg) translateX(-140%);
        opacity: 0;
    }
    55% {
        opacity: 1;
    }
    82%, 100% {
        transform: rotate(18deg) translateX(420%);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .external-games-btn,
    .external-games-btn::before {
        animation: none;
    }
}

.btn-special-animation {
    position: relative;
    overflow: hidden;
    z-index: 1;
    background: linear-gradient(135deg, #f72585, #b5179e);
    box-shadow: 0 4px 15px rgba(247, 37, 133, 0.4);
}

.btn-special-animation::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.8s ease;
}

.btn-special-animation:hover::before {
    transform: translate(-50%, -50%) scale(1);
}


/* Words Grid */
.words-section {
    margin-bottom: 25px;
}

.section-title {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
}

.word-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.night-mode .word-card {
    background: rgba(30, 41, 59, 0.9);
}

.word-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-light);
    border-color: var(--primary-light);
}

.word-emoji {
    font-size: 46px;
    line-height: 1;
}

.word-text {
    font-size: 20px;
    font-weight: 700;
    direction: ltr;
    text-align: center;
    color: var(--text);
}

.word-ar {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.word-actions {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text);
    user-select: none;
}

.night-mode .icon-btn {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.icon-btn.mic-active {
    background: var(--secondary);
    color: white;
    animation: pulse 1.5s infinite;
}

.word-card.pronunciation-correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.12);
}

.word-pronunciation-badge {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--success);
    color: #ffffff;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.25);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(247, 37, 133, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(247, 37, 133, 0); }
    100% { box-shadow: 0 0 0 0 rgba(247, 37, 133, 0); }
}

/* Writing Section */
.writing-section {
    margin-bottom: 25px;
}

.writing-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.writing-label {
    min-width: 120px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.writing-boxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.writing-practice-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.writing-mode {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.writing-mode-label {
    min-width: 54px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: rgba(67, 97, 238, 0.12);
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.writing-box {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(67, 97, 238, 0.22);
    background: #f8fbff;
    color: var(--text);
    text-align: center;
    font-size: 21px;
    font-weight: 700;
    direction: ltr;
    transition: all 0.3s ease;
    font-family: 'Arial', sans-serif;
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.85),
        0 8px 18px rgba(15, 23, 42, 0.08);
}

.night-mode .writing-box {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(147, 197, 253, 0.42);
    box-shadow:
        inset 0 0 0 2px rgba(15, 23, 42, 0.35),
        0 8px 18px rgba(0, 0, 0, 0.22);
}

.writing-box:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.3);
}

.writing-box.correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
    color: var(--success);
}

.writing-box.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.writing-drag-practice {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.writing-drag-slots,
.writing-drag-bank {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.writing-drag-slot,
.writing-drag-letter {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: 21px;
    font-weight: 800;
    direction: ltr;
    user-select: none;
}

.writing-drag-slot {
    border: 2px dashed rgba(67, 97, 238, 0.35);
    background:
        linear-gradient(135deg, rgba(67, 97, 238, 0.06), rgba(16, 185, 129, 0.04)),
        #f8fbff;
    color: var(--text);
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.82),
        0 8px 18px rgba(15, 23, 42, 0.08);
}

.writing-drag-slot.drag-over,
.writing-drag-slot.selected {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.writing-drag-slot.correct {
    border-style: solid;
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.12);
    color: var(--success);
}

.writing-drag-letter {
    border: 1px solid rgba(67, 97, 238, 0.28);
    background: var(--primary);
    color: white;
    cursor: grab;
    box-shadow: 0 8px 18px rgba(67, 97, 238, 0.18);
}

.writing-drag-letter:active {
    cursor: grabbing;
}

.writing-drag-letter.selected {
    outline: 3px solid rgba(76, 201, 240, 0.45);
    transform: translateY(-1px);
}

.writing-drag-letter.used {
    opacity: 0.35;
    cursor: default;
    transform: none;
}

.night-mode .writing-drag-slot {
    background: rgba(30, 41, 59, 0.75);
    border-color: rgba(147, 197, 253, 0.48);
    box-shadow:
        inset 0 0 0 2px rgba(15, 23, 42, 0.32),
        0 8px 18px rgba(0, 0, 0, 0.22);
}

/* Word Writing */
.word-writing-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-writing-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(248, 250, 252, 0.9);
    padding: 12px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.night-mode .word-writing-item {
    background: rgba(30, 41, 59, 0.9);
}

.word-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.word-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.word-input {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.9);
    color: var(--text);
    direction: ltr;
    min-width: 150px;
    transition: all 0.3s ease;
    font-weight: 600;
    font-family: 'Arial', sans-serif;
}

.night-mode .word-input {
    background: rgba(30, 41, 59, 0.9);
}

.word-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.3);
}

.word-input.correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
    color: var(--success);
}

.word-input.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.drag-word-card {
    display: grid;
    gap: 12px;
    background: rgba(248, 250, 252, 0.9);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.night-mode .drag-word-card {
    background: rgba(30, 41, 59, 0.9);
}

.drag-word-card.completed {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.12);
}

.drag-word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.drag-word-target {
    direction: ltr;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.drag-word-slot {
    width: 52px;
    height: 52px;
    border: 2px dashed var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
    font-family: Arial, sans-serif;
    transition: all 0.2s ease;
}

.drag-word-slot.drag-over,
.drag-word-slot.selected {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.15);
    transform: scale(1.04);
}

.drag-word-slot.filled {
    border-style: solid;
    border-color: var(--primary-light);
    background: rgba(67, 97, 238, 0.1);
}

.scrambled-word-letters {
    direction: ltr;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.drag-word-letter {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #facc15, #fb923c);
    color: #111827;
    font-size: 24px;
    font-weight: 900;
    font-family: Arial, sans-serif;
    cursor: grab;
    box-shadow: 0 8px 18px rgba(234, 88, 12, 0.22);
    transition: all 0.2s ease;
}

.drag-word-letter:hover {
    transform: translateY(-2px) scale(1.04);
}

.drag-word-letter.selected {
    outline: 3px solid var(--primary-light);
    transform: scale(1.06);
}

.drag-word-letter.used {
    opacity: 0.58;
    cursor: pointer;
    transform: scale(0.92);
}

.drag-word-letter.used:hover {
    opacity: 0.9;
    transform: scale(0.98);
    outline: 3px solid rgba(239, 68, 68, 0.24);
}

.drag-word-feedback {
    min-height: 28px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
}

.drag-word-feedback.correct {
    color: var(--success);
}

.drag-word-feedback.wrong {
    color: var(--error);
}

/* Quiz Section */
.quiz-container {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    padding: 15px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.night-mode .quiz-container {
    background: rgba(30, 41, 59, 0.9);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.quiz-question {
    font-size: 16px;
    margin-bottom: 15px;
    direction: ltr;
    font-weight: 600;
}

.quiz-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.quiz-option {
    padding: 10px 15px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    user-select: none;
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.night-mode .quiz-option {
    background: rgba(30, 41, 59, 0.9);
}

.quiz-option:hover {
    background: rgba(67, 97, 238, 0.1);
    border-color: var(--primary-light);
}

.quiz-option.correct {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.quiz-option.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Quiz Navigation */
.quiz-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.quiz-next-btn {
    padding: 10px 20px;
    border-radius: 50px;
    border: none;
    background: var(--gradient-primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.quiz-next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quiz-next-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Score Panel */
.score-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.score-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    padding: 15px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: all 0.3s ease;
}

.night-mode .score-card {
    background: rgba(30, 41, 59, 0.9);
}

.score-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.score-value {
    font-size: 20px;
    font-weight: 700;
}

.score-value.high {
    color: var(--success);
}

.score-value.medium {
    color: var(--warning);
}

.score-value.low {
    color: var(--error);
}

/* Footer Actions */
.footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: 20px;
}

.night-mode .modal {
    background: rgba(15, 23, 42, 0.95);
}

.modal-content {
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-lg);
    padding: 25px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    max-height: 90vh;
    overflow-y: auto;
}

.night-mode .modal-content {
    background: rgba(30, 41, 59, 0.98);
}

.modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.modal-close:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text);
}

.night-mode .modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-badge {
    display: inline-block;
    background: var(--gradient-primary);
    color: white;
    padding: 5px 15px;
    border-radius: 50px;
    font-size: 14px;
    margin-bottom: 15px;
    font-weight: 600;
}

.modal-title {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--primary);
    font-weight: 700;
}

.modal-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 600;
}

.modal-quote {
    background: rgba(248, 250, 252, 0.9);
    padding: 15px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent);
    margin-bottom: 20px;
    font-style: italic;
    transition: all 0.3s ease;
    font-weight: 600;
}

.night-mode .modal-quote {
    background: rgba(30, 41, 59, 0.9);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    padding: 12px 20px;
    border-radius: 50px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    user-select: none;
}

.modal-btn.game {
    background: var(--gradient-accent);
    color: white;
}

.modal-btn.next {
    background: var(--gradient-success);
    color: white;
}

.parent-report-modal {
    max-width: 560px;
}

#parentReportModal,
#letterPaywallModal {
    z-index: 2500;
}

#letterCompletionModal {
    z-index: 2700;
}

.letter-completion-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.letter-completion-card {
    position: relative;
    width: min(560px, calc(100vw - 24px));
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid rgba(67, 97, 238, 0.16);
    border-radius: 22px;
    background:
        radial-gradient(circle at top left, rgba(255, 214, 102, 0.22), transparent 34%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.16), transparent 30%),
        #ffffff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.2);
    padding: 26px;
    text-align: center;
    animation: letterCompletionPop 320ms ease-out;
    -webkit-overflow-scrolling: touch;
}

.letter-completion-close {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 999px;
    background: rgba(241, 245, 249, 0.95);
    color: var(--text);
    cursor: pointer;
    font-size: 1.45rem;
    font-weight: 900;
    touch-action: manipulation;
}

.letter-completion-stars {
    pointer-events: none;
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
}

.letter-completion-stars span {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #facc15;
    box-shadow: 0 0 0 5px rgba(250, 204, 21, 0.14);
    animation: letterCompletionStar 1.8s ease-in-out infinite;
}

.letter-completion-stars span:nth-child(1) { top: 18%; left: 12%; }
.letter-completion-stars span:nth-child(2) { top: 12%; right: 20%; animation-delay: 0.25s; background: #38bdf8; }
.letter-completion-stars span:nth-child(3) { top: 46%; left: 7%; animation-delay: 0.5s; background: #34d399; }
.letter-completion-stars span:nth-child(4) { right: 10%; bottom: 30%; animation-delay: 0.75s; background: #fb7185; }
.letter-completion-stars span:nth-child(5) { bottom: 14%; left: 28%; animation-delay: 1s; }

.letter-completion-hero {
    display: grid;
    place-items: center;
    margin: 6px auto 12px;
}

.letter-completion-medal {
    display: grid;
    place-items: center;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #bbf7d0);
    border: 3px solid rgba(250, 204, 21, 0.45);
    font-size: 2.8rem;
    animation: letterCompletionBounce 1.8s ease-in-out infinite;
}

.letter-completion-body {
    position: relative;
    z-index: 1;
}

.letter-completion-kicker {
    color: #0f766e;
    font-size: 0.9rem;
    font-weight: 900;
    margin: 0 0 6px;
}

.letter-completion-title {
    color: var(--text);
    font-size: clamp(1.55rem, 4vw, 2.35rem);
    line-height: 1.2;
    margin: 0 0 8px;
}

.letter-completion-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 16px;
}

.letter-completion-subtitle strong {
    color: var(--primary);
    font-size: 1.2em;
}

.letter-completion-score {
    display: inline-grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    margin-bottom: 18px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.24);
    color: #047857;
    font-weight: 900;
}

.letter-completion-score strong {
    color: var(--text);
    font-size: 1.35rem;
}

.letter-completion-words {
    display: grid;
    gap: 10px;
    margin: 0 auto 18px;
    max-width: 460px;
}

.letter-completion-section-title {
    color: var(--text);
    font-weight: 900;
}

.letter-completion-word-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.letter-completion-word {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-weight: 900;
}

.letter-completion-bird-message {
    margin: 0 auto 20px;
    max-width: 460px;
    border-radius: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 1.02rem;
    font-weight: 900;
    line-height: 1.6;
    padding: 12px 14px;
}

.letter-completion-actions {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.letter-completion-btn {
    min-height: 48px;
    width: 100%;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 900;
    padding: 12px 14px;
    touch-action: manipulation;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.letter-completion-btn:focus-visible,
.letter-completion-close:focus-visible {
    outline: 3px solid rgba(67, 97, 238, 0.35);
    outline-offset: 3px;
}

.letter-completion-btn:active,
.letter-completion-close:active {
    transform: scale(0.98);
}

.letter-completion-btn.primary {
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #10b981);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24);
}

.letter-completion-btn.secondary {
    color: #1f2937;
    background: #f8fafc;
    border: 1px solid #dbeafe;
}

.letter-completion-btn.ghost {
    color: #475569;
    background: transparent;
    border: 1px solid #e2e8f0;
}

@keyframes letterCompletionPop {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes letterCompletionStar {
    0%, 100% {
        transform: translateY(0) scale(0.9);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-8px) scale(1.12);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .letter-completion-card,
    .letter-completion-medal,
    .letter-completion-stars span {
        animation: none;
    }
}

@media (max-width: 520px) {
    .letter-completion-overlay {
        padding: 10px;
        align-items: flex-start;
    }

    .letter-completion-card {
        width: min(100%, calc(100vw - 20px));
        max-height: 90vh;
        margin-top: 10px;
        padding: 22px 14px 16px;
        border-radius: 18px;
    }

    .letter-completion-medal {
        width: 72px;
        height: 72px;
        font-size: 2.25rem;
    }

    .letter-completion-actions {
        grid-template-columns: 1fr;
    }

    .letter-completion-btn {
        min-height: 52px;
        font-size: 0.98rem;
    }

    .letter-completion-word {
        min-height: 34px;
        padding: 7px 10px;
    }
}

.letter-paywall-modal {
    max-width: 520px;
}

.letter-paywall-badge {
    background: linear-gradient(135deg, #f59e0b, #f72585);
}

.letter-paywall-copy {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-right: 4px solid var(--warning);
    border-radius: var(--radius-md);
    color: var(--text);
    font-weight: 700;
    margin-bottom: 16px;
    padding: 15px;
}

.parent-report-badge {
    background: linear-gradient(135deg, #0ea5e9, #10b981);
}

.parent-report-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.parent-report-stat {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}

.parent-report-stat strong {
    display: block;
    color: var(--primary);
    font-size: 24px;
    line-height: 1.2;
    margin-top: 6px;
}

.parent-report-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.parent-report-note,
.parent-report-recommendation {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    color: var(--text);
    font-weight: 600;
}

.child-note {
    border-right: 4px solid var(--success);
}

.parent-note {
    border-right: 4px solid var(--primary);
}

.parent-report-recommendation {
    border-right: 4px solid var(--warning);
}

.premium-preview-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0 20px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.parent-report-upgrade {
    background: linear-gradient(135deg, #f59e0b, #f72585);
    color: white;
    text-decoration: none;
}

.parent-report-back {
    background: #f8fafc;
    color: var(--text);
    border: 1px solid var(--border);
}

.parent-report-whatsapp {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #ffffff;
}

.parent-report-download {
    background: linear-gradient(135deg, #2563eb, #4361ee);
    color: #ffffff;
}

.parent-report-print {
    background: linear-gradient(135deg, #0f766e, #0891b2);
    color: #ffffff;
}

.parent-report-modal .modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.parent-report-modal .modal-actions .modal-btn {
    width: 100%;
    min-height: 46px;
}

@media (max-width: 520px) {
    .parent-report-summary,
    .premium-preview-list {
        grid-template-columns: 1fr;
    }

    .parent-report-modal .modal-actions {
        grid-template-columns: 1fr;
    }
}

/* Game Modal */
.game-modal {
    max-width: 800px;
    padding: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.game-title {
    font-size: 18px;
    font-weight: 700;
}

.game-score {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(248, 250, 252, 0.9);
    padding: 8px 15px;
    border-radius: 50px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    font-weight: 600;
    flex-wrap: wrap;
}

.night-mode .game-score {
    background: rgba(30, 41, 59, 0.9);
}

.game-area {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    height: 400px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    touch-action: none;
}

.night-mode .game-area {
    background: rgba(30, 41, 59, 0.9);
}

.game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* New Game Styles */
.games-container-wrapper {
    position: relative;
    margin-top: 20px;
}

.optional-games-note {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(67, 97, 238, 0.18);
    border-radius: var(--radius-md);
    background: rgba(67, 97, 238, 0.08);
    color: var(--text);
    text-align: center;
}

.optional-games-note strong {
    color: var(--primary);
    font-size: 1rem;
}

.optional-games-note span {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 700;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.games-grid::-webkit-scrollbar {
    width: 6px;
}

.games-grid::-webkit-scrollbar-track {
    background: transparent;
}

.games-grid::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 3px;
}

/* Scroll Arrows for Mobile */
.games-scroll-arrows {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.scroll-arrow {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.scroll-arrow:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

.scroll-arrow:active {
    transform: scale(0.9);
}

.scroll-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

@media (min-width: 769px) {
    .games-scroll-arrows {
        display: none;
    }
    .games-grid {
        max-height: none;
        overflow-y: visible;
    }
}

.game-card {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    position: relative;
    /* السماح بالتمرير العمودي فقط لمنع فتح اللعبة عند التمرير */
    touch-action: pan-y;
    /* Minimum touch target size for accessibility */
    min-height: 120px;
    min-width: 120px;
}

.night-mode .game-card {
    background: rgba(30, 41, 59, 0.9);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-light);
    border-color: var(--primary-light);
}

.game-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.mandatory-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
}

.game-card.completed .mandatory-badge {
    background: #22c55e;
    content: '✓';
}

.game-icon {
    font-size: 40px;
}

.game-name {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

/* Certificate Styles */
.certificate-modal-panel {
    display: grid;
    gap: 14px;
    justify-items: center;
    width: min(96vw, 920px);
    max-height: 94vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

.certificate-container {
    isolation: isolate;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.98)),
        radial-gradient(circle at 18% 12%, rgba(250, 204, 21, 0.22), transparent 28%),
        radial-gradient(circle at 88% 22%, rgba(67, 97, 238, 0.16), transparent 30%),
        radial-gradient(circle at 50% 92%, rgba(16, 185, 129, 0.16), transparent 28%);
    color: #172033;
    padding: 44px;
    border-radius: 24px;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
    max-width: 860px;
    width: min(94vw, 860px);
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(67, 97, 238, 0.18);
    font-family: 'Arial', sans-serif;
}

.certificate-logo {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1d4ed8, #0f766e);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: 0 14px 28px rgba(29, 78, 216, 0.22);
}

.certificate-container::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 3px double rgba(67, 97, 238, 0.52);
    pointer-events: none;
    border-radius: 18px;
    z-index: -1;
}

.certificate-container::after {
    content: '';
    position: absolute;
    inset: 28px;
    border: 1px solid rgba(245, 158, 11, 0.42);
    border-radius: 14px;
    pointer-events: none;
    z-index: -1;
}

.certificate-watermark {
    position: absolute;
    inset-inline-start: 50%;
    top: 52%;
    transform: translate(-50%, -50%) rotate(-12deg);
    color: rgba(67, 97, 238, 0.055);
    font-size: clamp(6rem, 18vw, 11rem);
    font-weight: 900;
    letter-spacing: 0;
    direction: ltr;
    z-index: -1;
    user-select: none;
}

.certificate-ribbon {
    position: absolute;
    top: 22px;
    inset-inline-start: -58px;
    width: 220px;
    transform: rotate(-38deg);
    background: linear-gradient(135deg, #2563eb, #10b981);
    color: #ffffff;
    padding: 8px 0;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.22);
}

.certificate-header {
    display: grid;
    place-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.certificate-medal {
    position: relative;
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: linear-gradient(135deg, #facc15, #f97316 52%, #ef4444);
    color: #ffffff;
    box-shadow: 0 16px 36px rgba(249, 115, 22, 0.28);
    border: 5px solid rgba(255, 255, 255, 0.86);
}

.certificate-medal span {
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1;
}

.certificate-medal small {
    position: absolute;
    bottom: 15px;
    inset-inline-end: 22px;
    font-size: 0.9rem;
    font-weight: 900;
}

.certificate-stars {
    color: #f59e0b;
    font-size: 1.45rem;
    letter-spacing: 4px;
    direction: ltr;
}

.certificate-title {
    color: #233876;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.15;
    margin: 4px 0 0;
    font-weight: 900;
}

.certificate-subtitle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 18px;
    border-radius: 999px;
    background: rgba(67, 97, 238, 0.1);
    color: #4361ee;
    font-size: 1rem;
    font-weight: 900;
    margin: 0;
}

.certificate-body {
    position: relative;
    display: grid;
    gap: 16px;
    margin: 18px auto 0;
    max-width: 680px;
}

.certificate-presented {
    color: #475569;
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
}

.certificate-student-name {
    justify-self: center;
    min-width: min(100%, 420px);
    color: #be185d;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.15;
    margin: 0;
    padding: 14px 28px 16px;
    border-bottom: 4px solid #38bdf8;
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(236, 253, 245, 0.74));
    font-weight: 900;
    box-shadow: 0 12px 28px rgba(190, 24, 93, 0.12);
}

.certificate-message {
    color: #334155;
    font-size: 1.08rem;
    line-height: 1.85;
    margin: 0;
    font-weight: 800;
}

.certificate-achievement-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 4px 0;
}

.certificate-achievement-grid div {
    display: grid;
    gap: 6px;
    padding: 13px 12px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.88);
    border: 1px solid rgba(67, 97, 238, 0.16);
}

.certificate-achievement-grid span {
    color: #64748b;
    font-size: 0.86rem;
    font-weight: 800;
}

.certificate-achievement-grid strong {
    color: #0f766e;
    font-size: 1.35rem;
    font-weight: 900;
}

.certificate-quote {
    margin: 0;
    padding: 14px 18px;
    border-radius: 16px;
    background: rgba(245, 158, 11, 0.11);
    border: 1px solid rgba(245, 158, 11, 0.22);
    color: #92400e;
    font-size: 1rem;
    font-weight: 900;
}

.certificate-date {
    color: #475569;
    font-size: 0.98rem;
    margin: 0;
    font-weight: 800;
}

.certificate-id {
    color: #64748b;
    font-size: 0.86rem;
    margin: -6px 0 0;
    font-weight: 900;
    direction: ltr;
    text-align: center;
}

.certificate-signatures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    margin-top: 12px;
}

.certificate-signatures div {
    display: grid;
    gap: 8px;
}

.certificate-signatures span {
    display: block;
    height: 2px;
    background: #cbd5e1;
}

.certificate-signatures strong {
    color: #475569;
    font-size: 0.88rem;
}

.certificate-stamp {
    position: absolute;
    bottom: 34px;
    inset-inline-end: 36px;
    width: 118px;
    height: 118px;
    border: 4px solid rgba(190, 24, 93, 0.78);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.92rem;
    background: rgba(253, 242, 248, 0.84);
    text-align: center;
    transform: rotate(-12deg);
    color: #be185d;
    box-shadow: 0 12px 28px rgba(190, 24, 93, 0.14);
}

.certificate-stamp span {
    color: #f59e0b;
    font-size: 1.1rem;
    line-height: 1;
}

.certificate-stamp strong {
    color: #be185d;
    font-size: 1.05rem;
    letter-spacing: 0;
    line-height: 1;
}

.certificate-actions {
    position: relative;
    z-index: 1;
    margin-top: 28px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.certificate-actions .btn {
    min-height: 44px;
    border-radius: 999px;
    font-weight: 900;
}

.no-print {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

@media (max-width: 720px) {
    .certificate-container {
        width: min(96vw, 860px);
        padding: 30px 16px 24px;
        border-radius: 18px;
    }

    .certificate-container::before {
        inset: 10px;
        border-width: 2px;
    }

    .certificate-container::after {
        inset: 18px;
    }

    .certificate-ribbon {
        display: none;
    }

    .certificate-medal {
        width: 74px;
        height: 74px;
    }

    .certificate-medal span {
        font-size: 2.2rem;
    }

    .certificate-achievement-grid,
    .certificate-signatures {
        grid-template-columns: 1fr;
    }

    .certificate-stamp {
        position: static;
        margin: 8px auto 0;
        width: 96px;
        height: 96px;
        font-size: 0.82rem;
    }

    .certificate-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .certificate-actions .btn {
        width: 100%;
    }
}

/* Print styles for certificate */
@page {
    size: A4 landscape;
    margin: 10mm;
}

@media print {
    html,
    body {
        width: 100%;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: hidden !important;
    }

    .certificate-container {
        background: white !important;
        border: 2px solid #000 !important;
        box-shadow: none !important;
        max-width: none !important;
        width: 100% !important;
        min-height: 180mm !important;
        margin: 0 !important;
        border-radius: 0 !important;
        padding: 24px 34px !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    
    .certificate-container::before {
        border: 2px solid #000 !important;
        top: 15px !important;
        left: 15px !important;
        right: 15px !important;
        bottom: 15px !important;
    }
    
    .certificate-title,
    .certificate-student-name,
    .certificate-achievement-grid strong {
        color: #000 !important;
        text-shadow: none !important;
    }

    .certificate-ribbon,
    .certificate-actions,
    .no-print,
    .close-button {
        display: none !important;
    }
    
    .certificate-stamp {
        border-color: #000 !important;
        color: #000 !important;
        background: white !important;
    }
}

/* Completion Animation */
.completion-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent);
    opacity: 0.8;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
    }
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: rgba(248, 250, 252, 0.9);
    border-radius: 4px;
    margin: 15px 0;
    overflow: hidden;
}

.night-mode .progress-container {
    background: rgba(30, 41, 59, 0.9);
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Achievement Badges */
.achievements-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.achievement-badge {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-size: 24px;
    position: relative;
    box-shadow: var(--shadow-light);
    font-weight: 600;
}

.achievement-badge.locked {
    background: rgba(248, 250, 252, 0.9);
    color: var(--text-secondary);
}

.night-mode .achievement-badge.locked {
    background: rgba(30, 41, 59, 0.9);
}

.achievement-badge .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-light);
    font-weight: 600;
}

.night-mode .achievement-badge .tooltip {
    background: rgba(30, 41, 59, 0.98);
}

.achievement-badge:hover .tooltip {
    opacity: 1;
}

/* Microphone Permission Status */
.mic-status {
    position: fixed;
    bottom: 80px;
    left: 20px;
    background: var(--gradient-primary);
    color: white;
    padding: 10px 15px;
    border-radius: 50px;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 100;
    box-shadow: var(--shadow);
    font-weight: 600;
}

.mic-status.show {
    display: flex;
}

.mic-status.error {
    background: var(--gradient-accent);
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    user-select: none;
}

.control-btn:active {
    transform: scale(0.95);
}

/* Touch Controls for Mobile */
.touch-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none; /* Hidden by default, shown via JS */
    justify-content: space-between;
    padding: 0 30px;
    pointer-events: none;
    z-index: 100;
}

.touch-controls .control-btn {
    pointer-events: auto;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
    backdrop-filter: blur(5px);
}

.touch-controls .control-btn:active {
    transform: scale(0.9);
    background: var(--primary);
    color: white;
}

/* Game Canvas Responsive */
.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
    touch-action: none; /* Prevent scrolling while playing */
}

/* Game Instructions */
.game-instructions {
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.night-mode .game-instructions {
    background: rgba(30, 41, 59, 0.9);
}

/* Letter Jump Menu */
.letter-jump-menu {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    z-index: 100;
    display: none;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
}

.letter-jump-menu.show {
    display: flex;
}

.letter-jump-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.letter-jump-item:hover {
    background: var(--primary);
    color: white;
}

/* Game Win Modal */
.win-modal .modal-content {
    max-width: 400px;
}

.win-animation {
    font-size: 60px;
    text-align: center;
    margin: 20px 0;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

/* Scroll to Top Button */
.scroll-top {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: none;
    z-index: 99;
    transition: all 0.3s ease;
    font-weight: 600;
}

.scroll-top.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-top:hover {
    transform: translateY(-5px);
}

/* Difficulty Indicator */
.difficulty-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

.difficulty-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
}

.difficulty-dot.active {
    background: var(--primary);
}

/* Game Stats */
.game-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    padding: 10px;
    background: rgba(248, 250, 252, 0.9);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.night-mode .game-stats {
    background: rgba(30, 41, 59, 0.9);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gradient-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow);
    z-index: 1001;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    min-width: 250px;
    max-width: 90%;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Quiz Completion Effect */
.quiz-completed {
    border-color: var(--success) !important;
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.4) !important;
    animation: pulse 2s infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    
    .student-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .main-content {
        padding: 15px;
        gap: 15px;
    }
    
    .letter-display {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .footer-actions {
        flex-direction: column;
        gap: 15px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .writing-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .writing-label {
        min-width: auto;
    }
    
    .word-writing-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .word-input-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .word-input {
        flex: 1;
        min-width: auto;
    }
    
    .certificate-container {
        padding: 20px;
    }
    
    .certificate-title {
        font-size: 28px;
    }
    
    .certificate-student-name {
        font-size: 24px;
    }

    .theme-toggle {
        position: relative;
        top: auto;
        left: auto;
        margin-top: 10px;
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .mobile-menu {
        display: block;
        position: absolute;
        top: 20px;
        left: 25px;
    }
    
    .theme-toggle {
        top: 20px;
        right: 25px;
        left: auto;
        width: auto;
    }

    .mic-status {
        bottom: 100px;
        left: 10px;
        right: 10px;
        justify-content: center;
    }

    .game-area {
        height: 300px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .modal-content {
        padding: 20px;
    }

    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .letter-jump-menu {
        right: 10px;
        max-height: 200px;
    }

    .quiz-option {
        min-width: 100px;
        font-size: 13px;
        padding: 8px 12px;
    }

    .quiz-navigation {
        flex-direction: column;
        gap: 10px;
    }

    .quiz-next-btn {
        width: 100%;
        justify-content: center;
    }

    .toast {
        bottom: 120px;
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 15px;
    }
    
    .logo-section {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .logo-text h1 {
        font-size: 18px;
    }
    
    .student-info {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 10px;
    }
    
    .student-name {
        width: 100%;
    }
    
    .student-name input {
        width: 100%;
    }
    
    .progress-chip {
        width: 100%;
        justify-content: center;
    }
    
    .letter-tab {
        min-width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .words-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .writing-box {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .score-panel {
        grid-template-columns: 1fr;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }

    .game-modal .modal-content {
        padding: 15px;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .game-score {
        width: 100%;
        justify-content: center;
    }

    .control-btn {
        width: 50px;
        height: 50px;
    }

    .quiz-option {
        min-width: 80px;
        font-size: 12px;
        padding: 6px 10px;
    }

    .toast {
        bottom: 150px;
        min-width: 180px;
        font-size: 14px;
        padding: 10px 16px;
    }
}

@media (max-width: 360px) {
    .letter-tab {
        min-width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .words-grid {
        grid-template-columns: 1fr;
    }

    .writing-box {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .game-area {
        height: 250px;
    }

    .quiz-option {
        min-width: 70px;
        font-size: 11px;
    }
}

/* Landscape orientation for mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .game-area {
        height: 250px;
    }

    .modal-content {
        max-height: 80vh;
        padding: 15px;
    }
}

/* Prevent text selection on game elements */
.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Game button active state */
.game-card:active {
    transform: translateY(-2px);
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Copy protection */
.no-copy {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Canvas Touch Fix */
canvas {
    touch-action: none;
}

/* Celebration Animations */
.celebrate-balloon {
    position: fixed;
    bottom: -100px;
    font-size: 40px;
    animation: floatUp linear forwards;
    z-index: 9999;
    pointer-events: none;
}

.mini-celebrate-balloon {
    position: fixed;
    bottom: -50px;
    font-size: 25px;
    animation: miniFloatUp 2s ease-out forwards;
    z-index: 10000;
    pointer-events: none;
}

@keyframes floatUp {
    0% { bottom: -100px; transform: translateX(0) rotate(0deg); }
    50% { transform: translateX(20px) rotate(10deg); }
    100% { bottom: 120vh; transform: translateX(-20px) rotate(-10deg); }
}

@keyframes miniFloatUp {
    0% { 
        bottom: -50px; 
        transform: translateX(0) rotate(0deg) scale(1); 
        opacity: 1; 
    }
    50% { 
        transform: translateX(10px) rotate(5deg) scale(1.2); 
        opacity: 0.8; 
    }
    100% { 
        bottom: 80vh; 
        transform: translateX(-10px) rotate(-5deg) scale(0.8); 
        opacity: 0; 
    }
}

.confetti {
    position: fixed;
    top: -20px;
    width: 10px;
    height: 10px;
    animation: fallDown linear forwards;
    z-index: 9998;
    pointer-events: none;
}

@keyframes fallDown {
    0% { top: -20px; transform: rotate(0deg); }
    100% { top: 100vh; transform: rotate(720deg); }
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    .app-header {
        padding: 10px 15px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
    
    .logo-text p {
        font-size: 0.9rem !important;
    }
    
    .main-content {
        padding: 15px;
        gap: 15px;
    }
    
    .panel {
        padding: 15px;
    }
    
    .game-area {
        height: 60vh; /* Dynamic height for mobile games */
        max-height: 400px;
    }
    
    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .modal-content {
        width: 95%;
        padding: 15px;
        margin: 10px;
    }
    
    .letters-nav {
        padding: 10px;
    }
    
    .letter-tab {
        min-width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    /* Improve touch targets */
    button, .btn, .letter-tab, .game-card {
        cursor: pointer;
        touch-action: manipulation;
    }
    
    /* Prevent text selection during games */
    .game-modal {
        user-select: none;
        -webkit-user-select: none;
    }
}

/* ===== FIX: Standard Sidebar Drawer (Mobile + Desktop) ===== */
#userDropdown {
    position: fixed;
    top: 0;
    right: -280px; /* Start off-screen */
    width: 280px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 2005; /* Above overlay */
    
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: visible;
    opacity: 1;
}

/* Open State */
#userDropdown.show {
    right: 0 !important;
}

/* Night Mode */
.night-mode #userDropdown {
    background: #0f172a;
    border-color: rgba(255,255,255,.12);
}

/* Extracted from templates/letters.html style block 2 */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 30px 20px;
    margin-top: 40px;
    text-align: center;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-link, .footer-link-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    padding: 10px 20px;
    border-radius: 50px;
    background-color: var(--surface-light);
    box-shadow: var(--shadow-light);
}

.footer-link:hover, .footer-link-btn:hover {
    color: var(--primary);
    background-color: white;
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.footer-copyright {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.developer-credit {
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.8;
}

/* Bird Tutor */
.bird-tutor-card {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    margin: 18px 0;
    padding: 18px;
    border-radius: 24px;
    border: 2px solid rgba(67, 97, 238, 0.16);
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 52%, #ecfdf5 100%);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.09);
    overflow: hidden;
}

.bird-lesson-shell {
    display: block;
}

.bird-lesson-main {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.bird-lesson-intro {
    min-height: 360px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    place-items: center;
    gap: 18px;
    padding: 22px;
    text-align: center;
}

.bird-intro-bubble {
    max-width: 620px;
    min-height: 78px;
    padding: 18px 22px;
    border-radius: 8px;
    background: #ffffff;
    border: 2px solid rgba(67, 97, 238, 0.16);
    color: #172033;
    font-size: 1.15rem;
    font-weight: 900;
    line-height: 1.8;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.bird-intro-character {
    width: min(260px, 70vw);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: radial-gradient(circle, #ffffff 0%, #ecfdf5 58%, #dbeafe 100%);
    border: 2px solid rgba(16, 185, 129, 0.18);
    box-shadow: 0 24px 46px rgba(15, 23, 42, 0.12);
}

.bird-intro-lottie {
    width: min(220px, 62vw);
    height: min(220px, 62vw);
}

.bird-intro-fallback {
    width: min(220px, 62vw);
    height: min(220px, 62vw);
    font-size: clamp(6rem, 22vw, 11rem);
    animation: birdFloat 2.4s ease-in-out infinite;
}

.bird-intro-continue {
    min-width: 180px;
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 12px 22px;
    background: linear-gradient(135deg, #4361ee, #10b981);
    color: #ffffff;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(67, 97, 238, 0.22);
}

.night-mode .bird-tutor-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
    border-color: rgba(255, 255, 255, 0.12);
}

.bird-tutor-visual {
    width: 120px;
    min-height: 120px;
    display: grid;
    place-items: center;
}

.bird-lottie {
    width: 110px;
    height: 110px;
}

.bird-fallback {
    width: 110px;
    height: 110px;
    display: grid;
    place-items: center;
    font-size: 4.4rem;
    line-height: 1;
    transform-origin: center bottom;
    animation: birdFloat 2.8s ease-in-out infinite;
}

.bird-tutor-card[data-state="talking"] .bird-fallback {
    animation: birdPulse 0.75s ease-in-out infinite;
}

.bird-tutor-card[data-state="happy"] .bird-fallback {
    animation: birdBounce 0.8s ease-in-out infinite;
}

.bird-tutor-card[data-state="celebrate"] .bird-fallback {
    animation: birdCelebrate 0.9s ease-in-out infinite;
}

.bird-tutor-card[data-state="jump"] .bird-fallback {
    animation: birdJump 0.7s ease-in-out infinite;
}

.bird-tutor-card[data-state="sad"] .bird-fallback {
    animation: birdSad 1s ease-in-out infinite;
    filter: saturate(0.75);
}

.bird-tutor-card[data-state="wrong"] .bird-fallback {
    animation: birdShake 0.42s ease-in-out infinite;
}

.bird-tutor-card[data-state="thinking"] .bird-fallback {
    animation: birdFloat 1.2s ease-in-out infinite;
    filter: saturate(0.85);
}

.bird-tutor-card[data-state="listening"] .bird-fallback {
    animation: birdListen 0.9s ease-in-out infinite;
    filter: drop-shadow(0 0 14px rgba(16, 185, 129, 0.36));
}

.bird-tutor-locked {
    border-color: rgba(245, 158, 11, 0.28);
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 54%, #fef3c7 100%);
}

.night-mode .bird-tutor-locked {
    background: linear-gradient(135deg, rgba(69, 26, 3, 0.9), rgba(15, 23, 42, 0.96));
}

.bird-fallback.locked {
    animation: birdFloat 3s ease-in-out infinite;
    opacity: 0.82;
    filter: grayscale(0.15);
}

.bird-tutor-content {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.bird-tutor-name {
    font-weight: 900;
    color: var(--primary);
    font-size: 0.95rem;
}

.developer-vip-preview-badge {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #111827;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
}

.bird-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.bird-stat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid rgba(67, 97, 238, 0.16);
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1.25;
}

.bird-stat-review {
    background: #ecfdf5;
    color: #047857;
    border-color: rgba(16, 185, 129, 0.22);
}

.bird-bubble {
    min-height: 58px;
    padding: 14px 16px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid rgba(67, 97, 238, 0.15);
    color: #1e293b;
    font-weight: 800;
    line-height: 1.7;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    overflow-wrap: anywhere;
}

.bird-bubble strong,
.bird-bubble span {
    display: block;
}

.bird-bubble span {
    margin-top: 4px;
    color: #64748b;
    font-size: 0.95rem;
}

.night-mode .bird-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.12);
}

.bird-hint {
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid rgba(249, 115, 22, 0.2);
    font-weight: 800;
    line-height: 1.6;
}

.bird-hint[data-tone="success"] {
    background: #ecfdf5;
    color: #047857;
    border-color: rgba(16, 185, 129, 0.24);
}

.bird-hint[data-tone="review"] {
    background: #fef3c7;
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.28);
}

.night-mode .bird-stat-badge,
.night-mode .bird-hint {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.12);
}

.bird-visual-question {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid rgba(67, 97, 238, 0.14);
}

.bird-visual-title {
    color: #334155;
    font-weight: 900;
    text-align: center;
}

.bird-target-picture {
    min-height: 112px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #172033;
    font-size: clamp(2.4rem, 11vw, 5.2rem);
    font-weight: 900;
}

.bird-pronounce-target {
    font-size: clamp(2.4rem, 12vw, 5.4rem);
    letter-spacing: 0;
    text-transform: lowercase;
}

.bird-pronounce-target.pronunciation-correct {
    border-color: #22c55e;
    background: #ecfdf5;
    color: #047857;
}

.bird-pronounce-target.pronunciation-wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #b91c1c;
}

.bird-pronounce-check {
    margin-inline-start: 10px;
    color: #22c55e;
    font-size: 0.45em;
}

.bird-mic-btn {
    justify-self: center;
    min-height: 48px;
    min-width: 180px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #10b981, #4361ee);
    color: #ffffff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(16, 185, 129, 0.22);
}

.bird-mic-btn.listening {
    animation: birdMicPulse 0.9s ease-in-out infinite;
}

.bird-mic-btn:disabled {
    cursor: wait;
    opacity: 0.82;
}

.bird-mic-test-btn {
    justify-self: center;
    min-height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 9px 14px;
    background: #ffffff;
    color: #334155;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 900;
    cursor: pointer;
}

.bird-mic-test-btn.listening {
    animation: birdMicPulse 0.9s ease-in-out infinite;
    border-color: #10b981;
    color: #047857;
}

.bird-listening-status {
    display: grid;
    gap: 6px;
    text-align: center;
    color: #047857;
    font-weight: 900;
}

.bird-listening-status.error {
    color: #b91c1c;
}

.bird-listening-status.success {
    color: #047857;
}

.bird-speech-heard {
    line-height: 1.5;
}

.bird-speech-debug {
    display: grid;
    gap: 2px;
    margin-top: 4px;
    padding: 8px;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: left;
    direction: ltr;
}

.bird-picture-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.bird-picture-choice {
    min-height: 112px;
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #172033;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.bird-picture-choice:hover,
.bird-picture-choice.selected {
    border-color: #4361ee;
    box-shadow: 0 10px 22px rgba(67, 97, 238, 0.18);
    transform: translateY(-2px);
}

.bird-picture-choice.correct {
    border-color: #22c55e;
    background: #ecfdf5;
    color: #047857;
}

.bird-picture-choice.wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

.bird-picture-emoji {
    font-size: 2.8rem;
    line-height: 1;
}

.bird-picture-label {
    color: #475569;
    font-size: 1rem;
    font-weight: 900;
}

.night-mode .bird-visual-question,
.night-mode .bird-target-picture,
.night-mode .bird-picture-choice {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.12);
}

.bird-controls,
.bird-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.bird-control-btn,
.bird-choice-btn {
    border: 0;
    border-radius: 999px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 8px 18px rgba(67, 97, 238, 0.16);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bird-control-btn {
    background: var(--primary);
    color: #ffffff;
}

.bird-upgrade-btn {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 12px 18px;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    text-decoration: none;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(245, 158, 11, 0.25);
}

.bird-control-btn.secondary {
    background: #ffffff;
    color: var(--primary);
    border: 1px solid rgba(67, 97, 238, 0.2);
}

.bird-review-btn:not([hidden]) {
    display: inline-flex;
}

.bird-choice-btn {
    min-width: 94px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.bird-control-btn:hover,
.bird-choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(67, 97, 238, 0.22);
}

@keyframes birdFloat {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
}

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

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

@keyframes birdBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-14px) scale(1.08); }
    70% { transform: translateY(2px) scale(0.98); }
}

@keyframes birdShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px) rotate(-3deg); }
    75% { transform: translateX(6px) rotate(3deg); }
}

@keyframes birdCelebrate {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    35% { transform: translateY(-12px) rotate(-8deg) scale(1.08); }
    70% { transform: translateY(-4px) rotate(8deg) scale(1.05); }
}

@keyframes birdJump {
    0%, 100% { transform: translateY(0) scale(1); }
    45% { transform: translateY(-18px) scale(1.06); }
}

@keyframes birdSad {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(4px) rotate(-2deg); }
}

@keyframes birdMicPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 12px 26px rgba(16, 185, 129, 0.22); }
    50% { transform: scale(1.04); box-shadow: 0 16px 34px rgba(67, 97, 238, 0.28); }
}

@media (max-width: 640px) {
    .bird-tutor-card {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
    }

    .bird-lesson-main {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
    }

    .bird-lesson-intro {
        min-height: 320px;
        padding: 16px;
    }

    .bird-intro-bubble {
        font-size: 1rem;
        padding: 14px 16px;
    }

    .bird-picture-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bird-controls,
    .bird-actions {
        justify-content: center;
    }

    .bird-stats {
        justify-content: center;
    }

    .bird-control-btn,
    .bird-choice-btn {
        flex: 1 1 150px;
    }
}

/* Extracted from templates/letters.html style block 3 */
.ai-float-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    border: 2px solid white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 9999;
    padding: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: visible;
}

.ai-float-btn:hover {
    transform: scale(1.1) rotate(5deg);
}

.pulse-ring {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    100% { transform: scale(1.4); opacity: 0; }
}

.ai-chat-box {
    position: fixed;
    bottom: 100px;
    left: 30px;
    width: 320px;
    height: 450px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
    animation: slideUp 0.4s ease;
}

.ai-chat-box.active {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 15px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.ai-body {
    flex: 1;
    padding: 15px;
    background: #f8f9fa;
    overflow-y: auto;
    direction: rtl;
}

.ai-msg {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.ai-msg.bot {
    background: white;
    color: #333;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-left: auto;
}

.ai-msg.user {
    background: var(--primary);
    color: white;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-right: auto;
}

/* Production header layout guard: prevents the level navigation from forcing
   the landing page wider than the viewport on Render and desktop browsers. */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-header {
    gap: 14px;
    flex-wrap: wrap;
}

.logo-section {
    flex: 0 1 300px;
    min-width: 220px;
}

.logo-text {
    min-width: 0;
}

.logo-text p {
    max-width: 260px;
    line-height: 1.55;
    white-space: normal;
}

.user-controls {
    flex: 1 1 620px;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.learning-levels-nav {
    flex: 1 1 520px;
    min-width: 0;
    max-width: 100%;
}

.learning-level-link {
    flex: 0 0 auto;
}

@media (min-width: 1100px) {
    .app-container {
        width: min(100%, 1440px);
    }
}

@media (max-width: 1099px) {
    .app-header {
        align-items: stretch;
    }

    .logo-section,
    .user-controls {
        flex-basis: 100%;
    }

    .learning-levels-nav {
        order: 1;
        flex-basis: 100%;
    }
}

@media (max-width: 640px) {
    body {
        padding: 8px;
    }

    .logo-section {
        min-width: 0;
    }

    .logo {
        width: 42px;
        height: 42px;
        font-size: 15px;
    }

    .logo-text p {
        max-width: none;
        font-size: 0.75rem !important;
    }

    .learning-level-link {
        min-width: 128px;
    }
}

.hamburger-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    align-self: flex-start;
    display: none;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-light);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    line-height: 1;
}

.hamburger-btn i {
    display: none;
}

.hamburger-btn::before {
    content: "\2630";
    color: var(--text);
    font-family: Arial, sans-serif;
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
}

@media (max-width: 768px) {
    .hamburger-btn {
        display: grid !important;
        order: -10;
        margin: 0;
    }

    .app-header {
        align-items: flex-start;
    }
}

.ai-footer {
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
}

.typing-indicator {
    display: inline-block;
    padding: 5px 10px;
    background: white;
    border-radius: 15px;
    margin-left: auto;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
