/* Start with English Magic Butterflies Theme */
:root {
    --primary-color: #6C5CE7;
    --primary-light: #A29BFE;
    --secondary-color: #00CEC9;
    --secondary-light: #81ECEC;
    --accent-color: #FD79A8;
    --accent-light: #FAB1A0;
    --success-color: #00b894;
    --danger-color: #d63031;
    --background-color: #1A1A2E; /* Magical Night */
    --card-bg: #FFFFFF;
    --text-main: #E8E4D9; /* Light text for dark body */
    --text-muted: #A0A0A0;
    --shadow-soft: 0 10px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 15px 30px rgba(108, 92, 231, 0.15);
    --border-radius: 20px;
    --transition-speed: 0.3s;
    /* Science specific */
    --primary: #6C5CE7;
    --secondary: #00CEC9;
    --accent: #FFD700;
}

/* Grid & Cards (Books) */
.grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 3.5rem 2rem; justify-content: center; padding: 2rem; }
.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 0.3s; 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; }
.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; }
.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; }
.card h2 { font-size: 1.8rem; margin-bottom: 0.5rem; color: #FFD700; font-weight: 800; text-shadow: 0 0 5px rgba(255,215,0,0.5); }
.card p { color: #E8E4D9; font-weight: 700;}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--background-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(108, 92, 231, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(253, 121, 168, 0.15), transparent 25%),
        radial-gradient(circle at 50% 80%, rgba(0, 206, 201, 0.1), transparent 20%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app-container { flex-grow: 1; padding: 0; max-width: 1200px; margin: 0 auto; width: 100%; position: relative; z-index: 1; }

/* Header & Breadcrumb */
.app-header {
    background: linear-gradient(135deg, #E8E4D9, #DCD0FF);
    color: #2D1500;
    padding: 2rem 5%;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    box-shadow: 0 10px 30px rgba(220, 208, 255, 0.5);
    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; }

/* Modal Styles */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(5px); }
.modal.active { display: flex; animation: fadeIn 0.3s; }
.modal-content { background: linear-gradient(145deg, #2D1500, #4A2511); color: #E8E4D9; width: 95%; max-width: 800px; height: 90%; border-radius: 30px; padding: 30px; position: relative; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.5); border: 5px solid #FFD700; }
.close-btn { position: absolute; top: 15px; left: 15px; background: #ff5252; color: white; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 1.5rem; cursor: pointer; box-shadow: 0 4px 10px rgba(255,82,82,0.4); transition: transform 0.2s; z-index: 10; }
.close-btn:hover { transform: scale(1.1); }

/* Mission Control Map (Chapters) */
.chapter-block { background: rgba(255,255,255,0.1); border-radius: 20px; padding: 20px; margin-bottom: 25px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); border-right: 8px solid var(--primary-light); }
.chapter-block h3 { margin-bottom: 20px; color: #FFD700; display: flex; align-items: center; }
.lessons-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; }
.lesson-item { background: linear-gradient(135deg, #3a1c0d, #522d1b); padding: 15px; border-radius: 15px; text-align: center; cursor: pointer; transition: all 0.3s; border: 2px solid #6b4028; box-shadow: 0 4px 6px rgba(0,0,0,0.3); position: relative; }
.lesson-item:hover { transform: translateY(-8px) scale(1.05); border-color: #FFD700; box-shadow: 0 8px 15px rgba(255,215,0,0.2); }
.lesson-item .type-icon { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.lesson-item .lesson-name { font-weight: bold; font-size: 0.9rem; color: #E8E4D9; display: block; }
.star-badge { position: absolute; top: -10px; right: -10px; background: #FFD700; color: #2D1500; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; box-shadow: 0 2px 5px rgba(0,0,0,0.5); animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* Wavy Lesson Path */
.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; }
.units-wrapper { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 3rem; padding: 2rem 0; position: relative; z-index: 1;}
.wavy-lesson-item { position: relative; z-index: 1; width: 250px; display:flex; justify-content:center; }
.wavy-lesson-item:nth-child(odd) { transform: translateX(120px); }
.wavy-lesson-item:nth-child(even) { transform: translateX(-120px); }

/* Wooden Lantern Buttons (Unit Bubbles replaced) */
.lantern-card { background-color: var(--card-bg); border-radius: 50%; width: 180px; height: 180px; padding: 1.5rem; text-align: center; cursor: pointer; box-shadow: 0 10px 25px rgba(0,0,0,0.15), inset 0 0 15px rgba(139, 90, 43, 0.2); transition: all 0.4s ease; border: 8px solid #D2B48C; display: flex; flex-direction: column; justify-content: center; align-items: center; margin: 0 auto; background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.1)); position: relative;}
.lantern-card h2 { font-size: 1.2rem; color: #2D1500; font-weight: 800; margin-bottom: 0.5rem; }
.lantern-card .headphone-icon { font-size: 2.5rem; margin-bottom: 0.5rem; color: #2D1500; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.2)); }
.lantern-card:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 15px 35px rgba(255, 215, 0, 0.4), inset 0 0 20px rgba(255, 215, 0, 0.5); border-color: #FFD700; }
.lantern-card:hover h2 { text-shadow: 0 0 10px rgba(255, 215, 0, 0.8); }

/* Screens & Lesson View */
.screen { display: none; }
.screen.active { display: block; width: 100%; max-width: 800px; margin: 0 auto;}
.lesson-nav { padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 4px 12px rgba(0,0,0,0.3); position: sticky; top: 0; z-index: 10; border-radius: 20px 20px 0 0; margin-top: 20px;}
.nav-btn { padding: 8px 16px; border-radius: 20px; border: none; background: rgba(255,255,255,0.1); cursor: pointer; font-family: inherit; font-weight: bold; color: #E8E4D9; transition: 0.3s; }
.nav-btn:hover { background: rgba(255,255,255,0.2); }
.lesson-tabs-nav { display: flex; justify-content: space-around; padding: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); position: sticky; top: 70px; z-index: 9; overflow-x: auto; }
.tab-btn { flex: 1; border: none; background: none; padding: 12px 5px; font-family: inherit; font-weight: bold; color: #A0A0A0; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.3s; white-space: nowrap; margin: 0 5px; border-radius: 8px 8px 0 0; }
.tab-btn.active { color: var(--accent-color); border-bottom: 3px solid var(--accent-color); background: rgba(253,121,168,0.1); }
.tab-btn:hover:not(.active) { background: rgba(255,255,255,0.05); }
.tab-pane { display: none; animation: fadeIn 0.4s ease forwards; }
.tab-pane.active { display: block; }
.content-area { padding: 20px; line-height: 1.8; background: #1A1A2E; border-radius: 0 0 20px 20px;}

/* Main Idea Box */
.main-idea-box { background: linear-gradient(135deg, rgba(108,92,231,0.2), rgba(0,206,201,0.2)); border-right: 6px solid var(--accent-color); padding: 20px; border-radius: 12px; margin-bottom: 25px; box-shadow: var(--shadow-soft);}
.main-idea-box h4 { color: #FFD700; margin-bottom: 8px; display: flex; align-items: center; }

/* Science Image */
.lesson-section-img { width: 100%; max-width: 250px; display: block; margin: 20px auto; border-radius: 15px; box-shadow: 0 5px 15px rgba(0,0,0,0.5); border: 2px solid var(--primary-light);}

/* Vocab Bubble Game */
.bubble-container { position: relative; width: 100%; height: 300px; background: linear-gradient(to top, rgba(108,92,231,0.3), rgba(0,0,0,0.2)); border-radius: 20px; overflow: hidden; margin-top: 20px; border: 2px solid var(--primary-light); }
.vocab-bubble-wrapper { position: absolute; bottom: -80px; animation: floatUp linear infinite forwards; }
.vocab-bubble { width: 100%; height: 100%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.2)); border: 2px solid rgba(255,255,255,0.6); border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 10px 20px rgba(0,0,0,0.3), inset 0 0 20px rgba(255,255,255,0.5); transition: transform 0.1s; }
.vocab-bubble span { display: none; font-weight: bold; color: #fff; text-shadow: 1px 1px 2px #000; pointer-events: none; }
.vocab-bubble.popped { animation: popBubble 2s forwards !important; }
.vocab-bubble.popped span { display: block; }
@keyframes floatUp { 0% { transform: translateY(0) scale(1); opacity: 1; } 50% { transform: translateY(-200px) scale(1.1); } 100% { transform: translateY(-440px) scale(1); opacity: 0; } }
@keyframes popBubble { 0% { transform: scale(1); opacity: 1; background: var(--accent-color); border: none; } 10% { transform: scale(1.5); opacity: 0.9; background: var(--accent-color); } 80% { transform: scale(1.5); opacity: 0.9; background: var(--accent-color); } 100% { transform: scale(2); opacity: 0; display: none; } }

/* RPG Dialog */
.rpg-dialog-container { display: flex; flex-direction: column; align-items: center; margin-top: 20px; }
.avatar-character { width: 120px; height: 120px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' fill='%23FFCDD2'/%3E%3Ccircle cx='35' cy='45' r='8' fill='%23333'/%3E%3Ccircle cx='65' cy='45' r='8' fill='%23333'/%3E%3Cpath d='M 45 65 Q 50 75 55 65' stroke='%23333' stroke-width='4' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") no-repeat center center / contain; animation: bounceAvatar 2s infinite; margin-bottom: -20px; z-index: 2; filter: drop-shadow(0 0 10px rgba(255,215,0,0.5));}
@keyframes bounceAvatar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.dialog-box { background: rgba(255,255,255,0.9); border: 4px solid var(--primary-light); border-radius: 20px; padding: 30px; width: 90%; min-height: 150px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: relative; font-size: 1.4rem; font-weight: bold; color: #2D1500; line-height: 1.6; text-align: center; }
.dialog-next-btn { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); background: var(--accent-color); color: white; border: none; border-radius: 30px; padding: 10px 30px; font-size: 1.2rem; font-weight: bold; cursor: pointer; box-shadow: 0 5px 15px rgba(253,121,168,0.4); transition: transform 0.2s; border: 2px solid #fff; }
.dialog-next-btn:hover { transform: translateX(-50%) scale(1.1); }

/* Flip Cards */
.flip-cards-wrapper { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; margin-top: 20px; }
.flip-card { background-color: transparent; width: 100%; max-width: 280px; height: 200px; perspective: 1000px; cursor: pointer; }
.flip-card-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-style: preserve-3d; box-shadow: 0 8px 16px rgba(0,0,0,0.5); border-radius: 20px; }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 20px; display: flex; align-items: center; justify-content: center; padding: 20px; font-weight: bold; font-size: 1.3rem; flex-direction: column;}
.flip-card-front { background: linear-gradient(135deg, var(--primary-light), var(--primary-color)); color: white; border: 4px solid var(--accent-light); }
.flip-card-back { background: linear-gradient(135deg, var(--secondary-color), var(--secondary-light)); color: #1A1A2E; transform: rotateY(180deg); border: 4px solid #fff; }

/* Quiz & Gamification */
.quiz-container { background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05)); padding: 25px; border-radius: 20px; text-align: center; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); margin-top: 20px; border: 1px solid rgba(255,255,255,0.2);}
.quiz-container h3 { color: #FFD700; margin-bottom: 20px; font-size: 1.4rem; }
.quiz-option { display: block; width: 100%; margin-bottom: 12px; padding: 15px; border-radius: 12px; border: 2px solid var(--primary-light); background: rgba(0,0,0,0.3); font-family: inherit; font-size: 1.1rem; font-weight: bold; color: #E8E4D9; cursor: pointer; transition: all 0.2s; }
.quiz-option:hover { background: rgba(108,92,231,0.4); transform: translateY(-2px); border-color: #fff;}
.quiz-option.correct { background: var(--success-color); color: white; border-color: #fff; transform: scale(1.05); }
.quiz-option.wrong { background: var(--danger-color); color: white; border-color: #fff; animation: shake 0.4s; }
.quiz-feedback { font-size: 1.2rem; font-weight: bold; height: 30px; margin-top: 15px; transition: all 0.3s; }
.lesson-completion-box { margin-top: 30px; padding: 20px; background: rgba(255,255,255,0.05); border-radius: 15px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }

/* General Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-5px); } 100% { transform: translateX(0); } }
@keyframes flyCoin { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0.5); opacity: 0; } }
.flying-coin { position: fixed; font-size: 2rem; z-index: 9999; pointer-events: none; animation: flyCoin 1s cubic-bezier(0.25, 1, 0.5, 1) forwards; filter: drop-shadow(0 0 10px #FFD700); }

/* Toasts and Achievements */
.toast-message { position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--primary-color), var(--accent-color)); color: white; padding: 15px 30px; border-radius: 30px; font-weight: bold; box-shadow: 0 4px 15px rgba(0,0,0,0.5); transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 1000; font-size: 1.1rem; border: 2px solid #FFD700;}
.toast-message.show { bottom: 30px; }
.achievement-item { background: rgba(0,0,0,0.4); padding: 12px 20px; border-radius: 12px; margin-bottom: 10px; box-shadow: 0 3px 8px rgba(0,0,0,0.3); font-weight: bold; color: #FFD700; display: flex; justify-content: space-between; align-items: center; border-right: 4px solid var(--accent-color); transition: transform 0.2s; }
.achievement-item:hover { transform: scale(1.02); }

@media (max-width: 600px) {
    .app-header { padding: 1.5rem 5%; }
    .header-top { flex-direction: column; gap: 1rem; }
    .header-spacer { margin-top: 10px; }
    .modal-content { padding: 15px; width: 100%; height: 100%; border-radius: 0; border: none; }
    .wavy-lesson-item:nth-child(odd), .wavy-lesson-item:nth-child(even) { transform: translateX(0); }
    .lesson-path-container::before { left: 20px; }
}

/* --- New Magical Games CSS --- */
/* Game 1: Treasure Chests */
.treasure-container { display: flex; justify-content: center; gap: 40px; margin-top: 20px; flex-wrap: wrap; }
.treasure-chest { width: 120px; height: 120px; background: url('https://img.icons8.com/color/200/treasure-chest.png') no-repeat center/contain; cursor: pointer; transition: transform 0.2s; position: relative; }
.treasure-chest:hover { transform: scale(1.1); filter: drop-shadow(0 0 10px #FFD700); }
.treasure-chest.open { background: url('https://img.icons8.com/color/200/open-box.png') no-repeat center/contain; animation: flashGold 1s forwards; }
.chest-label { position: absolute; bottom: -50px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.7); color: white; padding: 5px 10px; border-radius: 10px; font-size: 0.8rem; width: 150px; text-align: center; white-space: normal; pointer-events: none; z-index:5; }
@keyframes flashGold { 0% { filter: drop-shadow(0 0 0px #FFD700); } 50% { filter: drop-shadow(0 0 30px #FFD700); } 100% { filter: drop-shadow(0 0 15px #FFD700); } }

/* Game 2: Star Catcher */
.star-catcher-sky { position: relative; height: 350px; background: radial-gradient(circle at top, #1A1A2E, #000); border-radius: 20px; overflow: hidden; border: 2px solid #A29BFE; margin-top: 15px; }
.falling-star { position: absolute; width: 60px; height: 60px; background: url('https://img.icons8.com/color/200/star--v1.png') no-repeat center/contain; cursor: pointer; display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 0 5px #FFD700); }
.falling-star span { background: rgba(0,0,0,0.7); color: white; font-size: 0.7rem; padding: 2px 5px; border-radius: 5px; transform: translateY(45px); pointer-events: none; white-space: normal; width: 120px; text-align: center; z-index:5;}
@keyframes fallDown { from { top: -60px; } to { top: 360px; } }

/* Game 3: Magic Cauldron */
.cauldron-container { display: flex; flex-direction: column; align-items: center; gap: 20px; position: relative; margin-top: 20px;}
.cauldron { width: 150px; height: 150px; background: url('https://img.icons8.com/color/200/cauldron.png') no-repeat center/contain; position: relative; }
.cauldron.bubbling::after { content: ''; position: absolute; top: -20px; left: 25px; width: 100px; height: 100px; background: radial-gradient(circle, rgba(76,175,80,0.8), transparent); filter: blur(10px); animation: floatUp 2s infinite; }
.potions-row { display: flex; gap: 70px; justify-content: center; flex-wrap: wrap; }
.potion-bottle { width: 60px; height: 80px; background: url('https://img.icons8.com/color/200/potion.png') no-repeat center/contain; cursor: pointer; transition: transform 0.3s; position: relative; }
.potion-bottle:hover { transform: scale(1.2) rotate(10deg); filter: drop-shadow(0 0 10px #FD79A8); }
.potion-label { position: absolute; bottom: -45px; left: 50%; transform: translateX(-50%); font-size: 0.75rem; background: rgba(0,0,0,0.8); color: white; padding: 2px 5px; border-radius: 5px; white-space: normal; width: 120px; text-align: center; pointer-events: none; z-index:5;}

/* Game 4: Magic Frog Jumps */
.pond-container { position: relative; height: 200px; background: linear-gradient(to bottom, #00CEC9, #0984e3); border-radius: 20px; margin-top: 30px; display: flex; align-items: center; justify-content: space-around; padding: 0 20px; border: 3px solid #81ECEC;}
.lily-pad { width: 80px; height: 60px; background: url('https://img.icons8.com/color/200/leaf.png') no-repeat center/contain; cursor: pointer; position: relative; transition: transform 0.2s; }
.lily-pad:hover { transform: scale(1.1); filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5)); }
.lily-label { position: absolute; top: -50px; left: 50%; transform: translateX(-50%); background: white; color: #2D1500; font-weight: bold; padding: 4px 8px; border-radius: 10px; font-size: 0.75rem; white-space: normal; width: 130px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.3); pointer-events: none; z-index:5; }
.frog { position: absolute; width: 60px; height: 60px; background: url('https://img.icons8.com/color/200/frog.png') no-repeat center/contain; top: 70px; left: -10px; transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1); z-index: 10; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.4));}
