:root {
    --primary: #2e7d32;
    --secondary: #1976d2;
    --accent: #ff9800;
    --bg-color: #f0f4f8;
    --glass: rgba(255, 255, 255, 0.85);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
    color: #333;
    overflow-x: hidden;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.05);
    position: relative;
    padding-bottom: 50px;
}

@media (max-width: 600px) {
    #app {
        max-width: 100%;
        box-shadow: none;
    }
}

/* Header */
.main-header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(to bottom, #ffffff, rgba(255, 255, 255, 0));
    position: relative;
}

.main-header h1 {
    font-size: 1.8rem;
    color: #1b5e20;
    margin-bottom: 5px;
}

@media (max-width: 480px) {
    .main-header h1 {
        font-size: 1.4rem;
    }
    .main-header p {
        font-size: 0.8rem;
    }
}

/* Path Container */
.path-container {
    position: relative;
    width: 100%;
    min-height: 1000px;
    margin-top: 20px;
}

.winding-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.units-wrapper {
    position: relative;
    z-index: 2;
    height: 1000px;
}

/* Unit Bubble */
.unit-bubble {
    position: absolute;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 6px solid var(--color);
    text-align: center;
    transform: translateX(-50%);
    padding: 10px;
}

.unit-bubble:hover {
    transform: translateX(-50%) scale(1.15);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.unit-bubble .label {
    font-weight: bold;
    font-size: 0.8rem;
    color: #333;
    margin-bottom: 5px;
}

.unit-bubble .icon {
    font-size: 1.5rem;
}

/* Modal / Mission Control Map */
.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(180deg, #bbdefb, #e3f2fd);
    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.3);
    border: 5px solid white;
}

@media (max-width: 600px) {
    .modal-content {
        padding: 15px;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
    .close-btn {
        top: 10px; left: 10px;
    }
}

.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); }

/* Adventure Map Levels */
.chapter-block {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border-right: 8px solid var(--primary);
}

@media (max-width: 480px) {
    .chapter-block {
        padding: 15px;
        border-radius: 15px;
    }
}

.chapter-block h3 {
    margin-bottom: 20px;
    color: #333;
    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, #f5f5f5, #ffffff);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #eee;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    position: relative;
}

.lesson-item:hover {
    transform: translateY(-8px) scale(1.05);
    border-color: var(--secondary);
    box-shadow: 0 8px 15px rgba(255,152,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: #555;
    display: block;
}

.star-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #FFD700;
    color: #fff;
    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.2);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Lesson Navigation & Header */
.lesson-nav {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    color: #555;
    transition: 0.3s;
}

.nav-btn:hover {
    background: #e0e0e0;
}

#lesson-title-display {
    font-size: 1.1rem;
    color: var(--primary);
}

/* Lesson Content Container */
.content-area {
    padding: 20px;
    line-height: 1.8;
}

.main-idea-box {
    background: #e8f5e9;
    border-right: 6px solid #4CAF50;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.main-idea-box h4 {
    color: #1b5e20;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.vocab-container {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.vocab-tag {
    background: #fff9c4;
    padding: 5px 15px;
    border-radius: 15px;
    font-weight: bold;
    color: #f57f17;
    border: 1px dashed #fbc02d;
}

.lesson-section {
    margin-bottom: 35px;
    animation: fadeIn 0.6s ease forwards;
}

.lesson-section h3 {
    color: var(--secondary);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.lesson-section-img {
    width: 100%;
    max-width: 250px;
    display: block;
    margin: 20px auto;
    border-radius: 15px;
}

.qa-container {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 15px;
    margin-top: 40px;
}

.qa-item {
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.qa-item .question {
    font-weight: bold;
    color: #d32f2f;
    margin-bottom: 5px;
    display: block;
}

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

.placeholder-msg {
    text-align: center;
    padding: 50px 20px;
}

/* Toast Message */
.toast-message {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    font-size: 1.1rem;
}

.toast-message.show {
    bottom: 30px;
}

/* Achievement Item */
.achievement-item {
    background: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
    font-weight: bold;
    color: #1b5e20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 4px solid #fbc02d;
    transition: transform 0.2s;
}

.achievement-item:hover {
    transform: scale(1.02);
}

/* Tabs Navigation */
.lesson-tabs-nav {
    display: flex;
    justify-content: space-around;
    background: white;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 60px;
    z-index: 9;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 5px;
    font-family: inherit;
    font-weight: bold;
    color: #888;
    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(--primary);
    border-bottom: 3px solid var(--primary);
    background: #e8f5e9;
}

.tab-btn:hover:not(.active) {
    background: #f5f5f5;
}

/* Tab Panes */
.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

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

/* Game Styles */
.quiz-container {
    background: linear-gradient(135deg, #fff3e0, #ffe082);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.2);
    margin-top: 20px;
}

.quiz-container h3 {
    color: #e65100;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.quiz-option {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #ffcc80;
    background: white;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-option:hover {
    background: #fff9c4;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.quiz-option.correct {
    background: #4CAF50;
    color: white;
    border-color: #388E3C;
    transform: scale(1.05);
}

.quiz-option.wrong {
    background: #f44336;
    color: white;
    border-color: #d32f2f;
    animation: shake 0.4s;
}

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

.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: white;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* --- Full Gamification Styles --- */
/* Bubble Popper (Vocabulary) */
.bubble-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: linear-gradient(to bottom, #81d4fa, #e1f5fe);
    border-radius: 20px;
    overflow: hidden;
    margin-top: 20px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

.vocab-bubble-wrapper {
    position: absolute;
    bottom: -80px;
    animation: floatUp linear infinite forwards;
    /* Duration will be set in JS */
}

.vocab-bubble {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
    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.1), 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: #FF9800; border: none; }
    10% { transform: scale(1.5); opacity: 0.9; background: #FF9800; }
    80% { transform: scale(1.5); opacity: 0.9; background: #FF9800; }
    100% { transform: scale(2); opacity: 0; display: none; }
}

/* RPG Dialog Engine */
.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;
}

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

.dialog-box {
    background: #fff;
    border: 4px solid #4CAF50;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    min-height: 150px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    position: relative;
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    line-height: 1.6;
    text-align: center;
}

.dialog-next-btn {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff5722;
    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(255,87,34,0.4);
    transition: transform 0.2s;
}

.dialog-next-btn:hover {
    transform: translateX(-50%) scale(1.1);
}

/* Flip Cards (Q&A) */
.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;
}

@media (max-width: 480px) {
    .flip-card {
        height: 180px;
    }
}

.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.1);
    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;
}

.flip-card-front {
    background: linear-gradient(135deg, #FFC107, #FF9800);
    color: white;
    border: 4px solid #fff;
}

.flip-card-back {
    background: linear-gradient(135deg, #4CAF50, #8BC34A);
    color: white;
    transform: rotateY(180deg);
    border: 4px solid #fff;
}

/* Flying Coin Animation */
@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;
}
