:root {
    --primary-color: #4EEDF5; /* Diamond Blue */
    --primary-light: #C29D62; /* Wood */
    --secondary-color: #5E8934; /* Grass Green */
    --secondary-light: #7D7D7D; /* Stone Gray */
    --accent-color: #45E039; /* Creeper Green */
    --accent-light: #5E8934; 
    --primary: #4EEDF5;
    --secondary: #5E8934;
    --success-color: #45E039;
    --danger-color: #ef4444;
    --background-color: #866043; /* Dirt */
    --card-bg: #C6C6C6; /* Light Stone */
    --text-main: #3d2616; /* Dark Dirt */
    --text-muted: #4a4a4a;
    --shadow-soft: 4px 4px 0px rgba(0, 0, 0, 0.5);
    --shadow-hover: 6px 6px 0px rgba(0, 0, 0, 0.6);
    --border-radius: 0px;
    --transition-speed: 0.1s;
    
    /* Reading Specific Extensions */
    --primary-bg: #866043; 
    --accent-glow: 0 0 0px rgba(0, 0, 0, 0);
    --star-gold: #4EEDF5;
    --radius-xl: 0px;
    --radius-lg: 0px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Cairo', sans-serif;
    background: var(--background-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    direction: rtl;
    border-top: 20px solid var(--secondary-color);
    text-shadow: 1px 1px 0px rgba(255,255,255,0.3);
}

.view {
    display: none;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.view.active-view {
    display: block;
    animation: viewEnter 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes viewEnter {
    from { opacity: 0; transform: scale(0.98) translateY(20px); filter: blur(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.app-header {
    background: white;
    color: var(--text-main);
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft), var(--accent-glow);
    border: 2px solid var(--primary-light);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.4);
    padding: 0.5rem 1rem 0.5rem 0.5rem;
    border-radius: 30px;
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.user-profile {
    font-size: 1.8rem;
    background: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.user-name {
    font-weight: 800;
    color: #2D1500;
    font-size: 1.1rem;
}

.header-spacer { width: 150px; }

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}
.logo h1 { font-size: 2.2rem; font-weight: 800; color: #2D1500; margin: 0; }

.user-stats {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.4);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #2D1500;
}

.progress-container {
    margin-top: 1.5rem;
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.progress-branch {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 8px;
    background: #8B5A2B;
    border-radius: 4px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}
.butterfly-indicator {
    position: absolute;
    right: 10px;
    font-size: 2rem;
    transition: right 1s ease-in-out;
    filter: drop-shadow(0 0 10px #DCD0FF);
    z-index: 2;
    transform: scaleX(-1);
}
.lantern-end {
    position: absolute;
    left: 10px;
    font-size: 2rem;
    z-index: 2;
    filter: drop-shadow(0 0 15px #FFD700);
}

.lesson-path-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    padding: 2rem 0;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.lesson-path-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    border-left: 4px dashed #FFD700;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 8px #FFD700);
    z-index: 0;
}

.wavy-lesson-item {
    position: relative;
    z-index: 1;
    width: 250px;
}

.wavy-lesson-item:nth-child(odd) { transform: translateX(120px); }
.wavy-lesson-item:nth-child(even) { transform: translateX(-120px); }

.lesson-card {
    background: linear-gradient(145deg, #2D1500, #4A2511);
    border-radius: 10px 25px 25px 10px;
    padding: 2rem; text-align: center;
    cursor: pointer; box-shadow: -5px 10px 20px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(255,215,0,0.1);
    transition: all var(--transition-speed);
    border: none; border-right: 15px solid #D2B48C; border-left: 8px solid #1A0D00;
    min-height: 200px; display: flex; flex-direction: column; justify-content: center;
    position: relative;
}
.lesson-card::after {
    content: ''; position: absolute; bottom: -20px; left: -15px; right: -25px; height: 15px;
    background: linear-gradient(to right, #3E2723, #5D4037); border-radius: 5px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.6); z-index: -1;
}
.lesson-card:hover { transform: translateY(-10px) scale(1.02); box-shadow: -5px 15px 30px rgba(255, 215, 0, 0.3), inset 0 0 15px rgba(255,215,0,0.3); border-right-color: #FFD700; }
.lesson-card h3 { font-size: 1.8rem; margin-bottom: 0.5rem; color: #FFD700; font-weight: 800; text-shadow: 0 0 5px rgba(255,215,0,0.5); }
.lesson-card .meta { color: #E8E4D9; font-weight: 700; }
.lesson-card .icon { font-size: 4rem; margin-bottom: 1rem; display: block; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5)); transition: transform 0.3s; }
.lesson-card:hover .icon { transform: scale(1.1) rotate(5deg); }
.lesson-number {
    position: absolute;
    top: -15px;
    left: -15px;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
    border: 2px solid #FFD700;
    z-index: 2;
}

/* --- Lesson View Navigation --- */
.lesson-header-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 2rem;
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.back-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: auto;
    padding: 0 15px;
    height: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: 0.3s;
    white-space: nowrap;
}

.back-btn:hover { background: rgba(255,255,255,0.1); transform: translateX(5px); }

#lesson-title-display {
    flex-grow: 1;
    font-size: 1.5rem;
}

.lesson-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.tab-trigger {
    padding: 0.8rem 1.8rem;
    border: 2px solid #e2e8f0;
    border-radius: 30px;
    background: #f8fafc;
    color: var(--text-main);
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tab-trigger:hover { 
    background: #e2e8f0; 
    transform: translateY(-2px);
}

.tab-trigger.active {
    background: var(--accent-glow);
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* --- Tab Content Switching --- */
.lesson-body {
    position: relative;
}

.tab-content {
    display: none; /* All tabs hidden by default */
    animation: tabSlideIn 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.tab-content.active {
    display: block;
}

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

.text-display {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    padding: 3rem;
    border-radius: var(--radius-xl);
    font-size: 2.2rem;
    line-height: 2.5;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    text-align: center;
    border: 8px solid rgba(255,255,255,0.05);
}

.reading-line {
    display: inline-block;
    padding: 0 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
    border: 2px solid transparent;
}

.reading-line:hover { 
    background: #f1f5f9; 
    border-color: #cbd5e1;
}

.reading-line.playing { 
    background: #4f46e5; 
    color: white; 
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

/* --- Vocabulary --- */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.vocab-item {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: 0.4s;
    cursor: pointer;
}

.vocab-item:hover { 
    transform: rotateY(10deg); 
    border-color: #a855f7;
}

.vocab-word {
    font-size: 2.2rem;
    font-weight: 900;
    color: #a855f7;
    margin-bottom: 1rem;
}

.vocab-meaning {
    color: var(--text-dim);
    font-size: 1.3rem;
    opacity: 0;
    transform: translateY(10px);
    transition: 0.4s;
}

/* --- Voice Corrector Styles --- */
.mic-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.mic-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 25px rgba(79, 70, 229, 0.4);
}

.mic-btn.listening {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    animation: micPulse 1.5s infinite;
    box-shadow: 0 10px 20px rgba(231, 76, 60, 0.4);
}

@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 20px rgba(231, 76, 60, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.voice-sub-btn {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    white-space: nowrap;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.voice-sub-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-light);
}

.voice-sub-btn.active {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary);
}

.vocab-item.flipped .vocab-meaning {
    opacity: 1;
    transform: translateY(0);
}

/* --- Game - Sentence Ordering & Memo --- */
.game-board, .memo-game {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius-xl);
    text-align: center;
}

.slots-container, .memo-lines {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 2rem;
    min-height: 50px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-lg);
}

.drop-slot {
    min-width: 80px;
    height: 45px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s;
}

.drop-slot.filled {
    border-style: solid;
    background: var(--accent-glow);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.words-bank, .memo-words {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

.memo-word, .order-word {
    padding: 10px 20px;
    background: #f8fafc;
    color: #1e293b;
    border-radius: 15px;
    cursor: grab;
    user-select: none;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: 0.3s;
    border: 2px solid transparent;
}

.memo-word:hover, .order-word:hover {
    transform: scale(1.1);
    background: #fff;
    border-color: #6366f1;
}

.memo-word.selected, .order-word.active {
    background: #6366f1;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

/* --- Writing Canvas --- */
.writing-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    min-width: 300px; /* Prevent collapsing to a line */
    background: rgba(255, 255, 255, 0.03);
    padding: 2rem;
    border-radius: var(--radius-xl);
}

#write-canvas {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 4px solid #6366f1;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    cursor: crosshair;
    width: 100%; /* Responsive display */
    max-width: 900px;
    height: 400px;
    display: block;
}

.canvas-controls {
    display: flex;
    gap: 15px;
}

.check-btn {
    background: var(--accent-glow);
    color: white;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(236, 72, 153, 0.4);
    margin-top: 2rem;
    transition: 0.3s;
}

.check-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(236, 72, 153, 0.6);
}

.hidden { display: none !important; }

/* --- Success Modal --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--primary-bg);
    border: 2px solid #a855f7;
    border-radius: var(--radius-xl);
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 50px rgba(168, 85, 247, 0.4);
    animation: modalPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.celebration-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: float 2s infinite ease-in-out;
}

.reward-stars {
    font-size: 2rem;
    letter-spacing: 5px;
    margin: 1.5rem 0;
}

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

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: 0.3s;
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(168, 85, 247, 0.4);
}

/* --- Checklist Styles --- */
.checklist-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: 0.3s;
    cursor: pointer;
}

.checklist-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-5px);
}

.checklist-item.completed {
    background: rgba(46, 204, 113, 0.15);
    border-color: #2ecc71;
}

.checklist-item.completed .checklist-title {
    color: #2ecc71;
    text-decoration: line-through;
    opacity: 0.8;
}

.checklist-checkbox {
    width: 25px;
    height: 25px;
    margin-left: 15px;
    cursor: pointer;
    accent-color: #2ecc71;
}

.checklist-title {
    font-size: 1.2rem;
    font-weight: bold;
    flex-grow: 1;
    transition: 0.3s;
}

.completed-badge {
    position: absolute;
    top: -15px;
    left: -15px;
    background: #2ecc71;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 3;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.top-buttons-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 100;
}

.top-left-btn, .top-right-btn {
    padding: 0.6rem 1.2rem;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.top-left-btn {
    background-color: #6C5CE7;
}

/* --- Responsiveness Media Queries --- */

/* Tablets and small desktops */
@media (max-width: 1024px) {
    .view {
        padding: 1rem;
    }
    
    .main-header {
        padding: 3rem 1rem;
    }
    
    .text-display {
        font-size: 1.8rem;
        padding: 2rem;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .home-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 1rem;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .portal-btn {
        width: 100%;
        margin: 0;
    }

    .header-content h1 {
        font-size: 2.5rem;
    }
    
    .header-content p {
        font-size: 1rem;
    }
    
    .lessons-container {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }
    
    .lesson-card {
        padding: 1.5rem 1rem;
    }
    
    .lesson-card .icon {
        font-size: 3.5rem;
    }
    
    .text-display {
        font-size: 1.5rem;
        padding: 1.5rem;
        line-height: 2;
    }
    
    .lesson-tabs {
        gap: 8px;
    }
    
    .tab-trigger {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .vocab-word {
        font-size: 1.8rem;
    }
    
    .vocab-meaning {
        font-size: 1.1rem;
    }
    
    #write-canvas {
        height: 300px;
    }
}

/* Very small screens (Phones) */
@media (max-width: 480px) {
    .main-header {
        padding: 2rem 0.5rem;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .user-stats {
        padding: 0.5rem 1rem;
    }
    
    .stat-item {
        font-size: 1.2rem;
    }
    
    .lesson-header-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .back-btn {
        width: auto;
        padding: 0 10px;
        height: 40px;
        font-size: 1rem;
    }
    
    .text-display {
        font-size: 1.3rem;
        padding: 1rem;
        border-width: 4px;
    }
    
    .reading-line {
        padding: 0 8px;
        margin: 3px;
    }
    
    .tab-trigger {
        flex-grow: 1;
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .celebration-icon {
        font-size: 3.5rem;
    }
    
    #write-canvas {
        height: 250px;
    }
    .top-buttons-container {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    .top-left-btn, .top-right-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }
}

/* --- Kinetic Games CSS --- */
.game-menu h3 { text-align: center; color: #FFD700; font-size: 2rem; margin-bottom: 2rem; }
.game-options-grid { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.game-card-btn { background: var(--card-bg); border: 2px solid var(--primary-light); border-radius: 20px; padding: 2rem; width: 200px; cursor: pointer; transition: 0.3s; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--text-main); }
.game-card-btn:hover { transform: translateY(-10px); border-color: var(--primary-color); box-shadow: 0 10px 25px rgba(108, 92, 231, 0.4); }
.game-icon { font-size: 4rem; display: block; }
.game-card-btn h4 { font-size: 1.2rem; font-family: 'Cairo'; margin: 0; }
.game-arena { background: rgba(0,0,0,0.2); border-radius: 20px; padding: 3rem 2rem 2rem 2rem; border: 2px solid var(--border-color); position: relative; overflow: hidden; min-height: 400px; margin-top: 1rem; }

.mini-btn { background: var(--primary-color); color: white; border: none; border-radius: 20px; padding: 0.5rem 1rem; font-size: 1rem; font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3); transition: 0.3s; position: absolute; top: 10px; right: 10px; z-index: 10; }
.mini-btn:hover { background: var(--primary-light); transform: translateY(-2px); }

/* Shared Game Arena */
.game-hud { position: absolute; top: 15px; left: 20px; right: 170px; display: flex; justify-content: space-between; font-size: 1.2rem; font-weight: bold; color: white; z-index: 10; pointer-events: none; }
.game-question { position: absolute; top: 50px; width: 100%; text-align: center; color: #FFD700; font-size: 1.8rem; z-index: 10; pointer-events: none; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); }

/* Catcher Game */
.catcher-area { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; overflow: hidden; touch-action: none; background: linear-gradient(to bottom, #595959, #333333); }
#catcher-basket { position: absolute; bottom: 20px; left: 50%; width: 80px; height: 80px; font-size: 4rem; transform: translateX(-50%); z-index: 5; text-align: center; transition: none; pointer-events: none; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.3)); }
.falling-word { position: absolute; background: #604029; color: #fff; padding: 10px 20px; border-radius: 5px; font-weight: bold; font-size: 1.2rem; box-shadow: inset 2px 2px 0px rgba(255,255,255,0.2), inset -2px -2px 0px rgba(0,0,0,0.4); border: 2px solid #3d2616; text-align: center; pointer-events: none; text-shadow: none !important; -webkit-text-stroke: 0 !important; }

/* Balloon Game */
.balloon-area { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; overflow: hidden; cursor: crosshair; background: linear-gradient(to top, #300000 0%, #700000 100%); }
.flying-balloon { position: absolute; background: #55FF55; color: #000; padding: 15px 20px; border-radius: 5px; font-weight: bold; font-size: 1.1rem; cursor: crosshair; box-shadow: inset 4px 4px 0px rgba(255,255,255,0.4), inset -4px -4px 0px rgba(0,0,0,0.4); border: 3px solid #000; text-align: center; min-width: 80px; min-height: 80px; display: flex; align-items: center; justify-content: center; text-shadow: none !important; -webkit-text-stroke: 0 !important; }
.flying-balloon::after { display: none; }

/* Runner Game */
.runner-area { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; overflow: hidden; cursor: pointer; background: linear-gradient(to bottom, #74b9ff, #81ecec); border-bottom: 50px solid #5E8934; }
#runner-player { position: absolute; bottom: 50px; left: 20%; font-size: 4rem; z-index: 5; transform: scaleX(-1); pointer-events: none; }
#runner-player.running { animation: runnerRun 0.2s infinite alternate; }
@keyframes runnerRun { from { transform: scaleX(-1) translateY(0); } to { transform: scaleX(-1) translateY(-10px); } }
#runner-player.jumping { animation: runnerJumpAnim 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
@keyframes runnerJumpAnim { 0% { bottom: 50px; } 50% { bottom: 200px; } 100% { bottom: 50px; } }
.runner-obstacle { position: absolute; bottom: 50px; right: -150px; background: #00AA00; color: #fff; padding: 10px 20px; border-radius: 5px; font-weight: bold; font-size: 1.2rem; border: 3px solid #005500; box-shadow: inset 4px 4px 0px rgba(255,255,255,0.4), inset -4px -4px 0px rgba(0,0,0,0.4); pointer-events: none; max-width: 150px; text-align: center; word-wrap: break-word; white-space: normal; text-shadow: none !important; -webkit-text-stroke: 0 !important; }

/* --- Math Theme UI --- */
.circuit-progress-container {
    width: 100%;
    margin-bottom: 3rem;
    padding: 0 1rem;
    position: relative;
}

.circuit-progress-bar {
    width: 100%;
    height: 15px;
    background-color: var(--primary-light);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    background-image: linear-gradient(90deg, transparent 50%, rgba(255, 255, 255, 0.5) 50%);
    background-size: 20px 20px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.circuit-progress-fill {
    height: 100%;
    background-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    transition: width 0.5s ease-in-out;
}

.books-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    padding: 2rem;
    position: relative;
    background: rgba(2, 132, 199, 0.03);
    border-radius: var(--radius-xl);
    border: 2px solid var(--primary-light);
}

.books-grid::before {
    content: '';
    position: absolute;
    top: 2rem;
    bottom: 2rem;
    left: 50%;
    width: 6px;
    background-image: linear-gradient(to bottom, var(--secondary) 50%, transparent 50%);
    background-size: 6px 20px;
    background-repeat: repeat-y;
    z-index: 0;
    transform: translateX(-50%);
}

.book-btn {
    background: white;
    width: 280px;
    height: 110px;
    border-radius: 55px;
    position: relative;
    cursor: pointer;
    box-shadow: 
        0 10px 20px rgba(0,0,0,0.1),
        inset 0 -5px 15px rgba(2, 132, 199, 0.1);
    border: 4px solid var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: right;
    outline: none;
    color: var(--text-main);
    z-index: 1;
}

.book-btn:nth-child(odd) {
    align-self: flex-start;
    margin-right: 15%;
}

.book-btn:nth-child(even) {
    align-self: flex-end;
    margin-left: 15%;
}

.book-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--secondary), inset 0 0 10px var(--secondary);
    border-color: var(--secondary);
    animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.5); }
    100% { box-shadow: 0 0 40px rgba(249, 115, 22, 0.8), inset 0 0 15px rgba(249, 115, 22, 0.4); }
}

.book-icon {
    font-size: 2.5rem;
    margin-left: 1rem;
    margin-bottom: 0;
    filter: none;
}

.book-title {
    color: var(--text-main);
    font-size: 1.4rem;
    font-weight: 800;
    text-shadow: none;
    line-height: 1.2;
    font-family: 'Cairo', sans-serif;
}

.book-meta {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    opacity: 1;
    background: white;
    padding: 0.2rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--primary-light);
}

.book-check {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 35px;
    height: 35px;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 5;
    left: auto;
}

.btn-speaker {
    position: absolute;
    left: 15px;
    font-size: 1.5rem;
    color: var(--primary);
    opacity: 0.7;
    transition: all 0.3s;
}

.book-btn:hover .btn-speaker {
    color: var(--secondary);
    opacity: 1;
}

.btn-speaker.playing {
    color: var(--primary) !important;
    opacity: 1 !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* --- New Header UI --- */
.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 4rem;
    color: #1e293b;
}

.header-user-icon {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-direction: column;
}

.user-avatar {
    width: 60px;
    height: 60px;
    background: #e0f2fe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #0ea5e9;
    font-size: 2.5rem;
}

.user-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    background: #e0f2fe;
    padding: 0.5rem 1rem;
    border-radius: 10px;
}

.header-content h1 {
    font-size: 2.2rem;
    margin-bottom: 0.2rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.portal-btn {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.portal-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

/* --- Minecraft Theme Overrides --- */
* {
    border-radius: 0 !important;
}

body {
    background-color: #724d31 !important;
    background-image: 
        repeating-linear-gradient(45deg, #604029 25%, transparent 25%, transparent 75%, #604029 75%, #604029),
        repeating-linear-gradient(45deg, #604029 25%, #724d31 25%, #724d31 75%, #604029 75%, #604029) !important;
    background-size: 32px 32px !important;
    background-position: 0 0, 16px 16px !important;
    border-top: 20px solid #5E8934 !important; /* Grass top */
}

.portal-btn, .primary-btn, .book-btn, .tab-trigger, .game-card-btn, .mini-btn, .back-btn, .voice-sub-btn {
    background: #c6c6c6 !important; /* Stone */
    border: 4px solid #000 !important;
    box-shadow: inset 4px 4px 0px #fff, inset -4px -4px 0px #555, 4px 4px 0px rgba(0,0,0,0.5) !important;
    color: #3f3f3f !important;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5) !important;
    font-weight: 900 !important;
}

.portal-btn:hover, .primary-btn:hover, .book-btn:hover, .tab-trigger:hover, .game-card-btn:hover, .mini-btn:hover, .back-btn:hover {
    background: #d9d9d9 !important; /* Lighter Stone on Hover */
    transform: none !important;
}

.portal-btn:active, .primary-btn:active, .book-btn:active, .tab-trigger:active, .game-card-btn:active, .mini-btn:active {
    box-shadow: inset 4px 4px 0px #555, inset -4px -4px 0px #fff, 2px 2px 0px rgba(0,0,0,0.5) !important;
    transform: translate(2px, 2px) !important;
}

.lesson-card, .vocab-item, .game-arena, .modal-content, .text-display, .app-header, .home-header, .books-grid {
    background-color: #888 !important;
    background-image: 
        repeating-linear-gradient(45deg, #777 25%, transparent 25%, transparent 75%, #777 75%, #777),
        repeating-linear-gradient(45deg, #777 25%, #888 25%, #888 75%, #777 75%, #777) !important;
    background-size: 16px 16px !important;
    background-position: 0 0, 8px 8px !important;
    border: 4px solid #3d2616 !important;
    box-shadow: inset 4px 4px 0px rgba(255,255,255,0.3), inset -4px -4px 0px rgba(0,0,0,0.5), 6px 6px 0px rgba(0,0,0,0.6) !important;
    color: #fff !important;
    text-shadow: 2px 2px 0px #3f3f15 !important;
}

.circuit-progress-bar {
    background: #333 !important;
    border: 4px solid #000 !important;
    border-radius: 0 !important;
}
.circuit-progress-fill {
    background: #45E039 !important; /* XP Green */
    background-image: linear-gradient(90deg, #45E039 50%, #2ea324 50%) !important;
    background-size: 20px 100% !important;
    box-shadow: none !important;
}

h1, h2, h3, h4 {
    font-family: 'Cairo', sans-serif !important;
    font-weight: 900 !important;
    color: #ffff55 !important; /* Minecraft Yellow Title */
    text-shadow: 4px 4px 0px #3f3f15 !important; /* Deep dark shadow */
}

.user-avatar {
    border: 4px solid #3d2616 !important;
    background: #c6c6c6 !important;
}

/* --- Dirt Rain Animation --- */
.dirt-block {
    position: fixed;
    width: 64px;
    height: 64px;
    background-color: #724d31;
    background-image: 
        repeating-linear-gradient(45deg, #604029 25%, transparent 25%, transparent 75%, #604029 75%, #604029),
        repeating-linear-gradient(45deg, #604029 25%, #724d31 25%, #724d31 75%, #604029 75%, #604029);
    background-size: 16px 16px;
    border-top: 12px solid #5E8934;
    border-bottom: 2px solid #3d2616;
    border-left: 2px solid #3d2616;
    border-right: 2px solid #3d2616;
    box-shadow: inset 4px 4px 0px rgba(255,255,255,0.2), inset -4px -4px 0px rgba(0,0,0,0.4), 4px 4px 0px rgba(0,0,0,0.5);
    z-index: 9999;
    animation: fallAndBounce ease-in forwards;
    pointer-events: none;
}

@keyframes fallAndBounce {
    0% { transform: translateY(-100px) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    100% { transform: translateY(110vh) rotate(360deg); opacity: 1; }
}

/* --- World Buttons --- */
.world-btn {
    padding: 10px 20px;
    background: #604029;
    color: #fff;
    border: 3px solid #3d2616;
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2rem;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    box-shadow: inset 2px 2px 0px rgba(255,255,255,0.2), inset -2px -2px 0px rgba(0,0,0,0.4);
    transition: transform 0.1s, background 0.2s;
}
.world-btn:hover {
    background: #724d31;
    transform: scale(1.05);
}
.world-btn.active {
    background: #5E8934;
    border-color: #3b5a1f;
}
