/* واجهة التفعيل وحماية الجهازين */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
}
.auth-card {
    background: white;
    padding: 50px 30px;
    border-radius: 40px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.15);
    max-width: 450px; width: 90%;
    border: 8px solid var(--primary-light);
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.auth-icon { font-size: 3.5rem; margin-bottom: 15px; }
.auth-card h2 { color: var(--primary); margin-bottom: 15px; font-size: 1.8rem; }
.auth-card p { color: #555; line-height: 1.6; }
.auth-card input {
    width: 85%;
    padding: 15px;
    border-radius: 20px;
    border: 3px solid #eee;
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
    transition: 0.3s;
    font-family: inherit;
}
.auth-card input:focus { border-color: var(--primary); box-shadow: 0 0 15px rgba(255,107,129,0.2); }
#activate-btn { width: 100%; font-size: 1.2rem; padding: 15px; }

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

:root {
    --bg-color: #f0e6ff;
    --primary: #6c5ce7;
    --primary-dark: #5641d8;
    --secondary: #00b894;
    --secondary-dark: #00a381;
    --accent: #fdcb6e;
    --accent-dark: #e0a93b;
    --rose: #fd79a8;
    --text: #2d3436;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(108,92,231,0.15);
}

body {
    margin: 0;
    font-family: 'Baloo Bhaijaan 2', cursive, sans-serif;
    background: linear-gradient(160deg, #e0d4ff 0%, #fff0f8 50%, #d4f5f0 100%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* خلفية الفقاعات الإبداعية */
.bubbles {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}
.bubble {
    position: absolute;
    bottom: -100px;
    background: rgba(108,92,231,0.12);
    border-radius: 50%;
    animation: float 8s infinite ease-in;
}
.bubble:nth-child(1) { width: 40px; height: 40px; left: 10%; animation-duration: 6s; background: rgba(253,121,168,0.15); }
.bubble:nth-child(2) { width: 80px; height: 80px; left: 30%; animation-duration: 9s; background: rgba(0,184,148,0.12); }
.bubble:nth-child(3) { width: 50px; height: 50px; left: 50%; animation-duration: 7s; background: rgba(253,203,110,0.2); }
.bubble:nth-child(4) { width: 100px; height: 100px; left: 70%; animation-duration: 12s; background: rgba(108,92,231,0.1); }
.bubble:nth-child(5) { width: 30px; height: 30px; left: 85%; animation-duration: 5s; background: rgba(253,121,168,0.18); }

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); opacity: 0.9; }
    100% { transform: translateY(-1000px) rotate(360deg); opacity: 0; }
}

/* إدارة الشاشات */
.view { display: none; animation: slideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.view.active-view { display: block; }
@keyframes slideIn { from{ opacity: 0; transform: scale(0.9) translateY(30px); } to{ opacity: 1; transform: scale(1) translateY(0); } }

/* ===== HEADER ===== */
.app-header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    color: var(--primary);
    text-shadow: 2px 2px 0px rgba(255,255,255,0.9);
}
.app-header h1 { font-size: 3rem; margin: 0; letter-spacing: 1px; }
.app-header p { font-size: 1.4rem; font-weight: bold; color: var(--rose); margin-top: 0.5rem; }

/* ===== LESSONS GRID ===== */
.lessons-path {
    max-width: 960px;
    margin: 1rem auto 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 22px;
    padding: 0 1.5rem;
    align-items: start;
}

.user-stats {
    background: white;
    padding: 10px 22px;
    border-radius: 30px;
    box-shadow: 0 6px 20px rgba(108,92,231,0.2);
    display: inline-block;
    margin-bottom: 10px;
    border: 3px solid var(--accent);
}

.stars-badge {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    gap: 5px;
}

.lesson-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ===== LESSON CARD ===== */
.lesson-node {
    background: white;
    border-radius: 22px;
    padding: 18px 10px 14px;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
    border: none;
    border-bottom: 5px solid #c4b5fd;
    box-shadow: 0 6px 18px rgba(108,92,231,0.13);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    text-align: center;
}
.lesson-node:hover {
    transform: translateY(-8px) scale(1.04);
    background: linear-gradient(135deg, var(--primary), #a29bfe);
    color: white;
    box-shadow: 0 16px 30px rgba(108,92,231,0.4);
    border-bottom-color: var(--primary-dark);
}
.lesson-node::after { display: none; }
.lesson-node:last-child::after { display: none; }

.lesson-node.completed {
    background: linear-gradient(135deg, var(--secondary), #55efc4);
    color: white;
    border-bottom-color: var(--secondary-dark);
    box-shadow: 0 8px 20px rgba(0,184,148,0.3);
}
.lesson-node.completed::before {
    content: '✅';
    position: absolute;
    top: -12px;
    right: -12px;
    font-size: 1.8rem;
    background: white;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* الدرس الداخلي */
#lesson-view { max-width: 900px; margin: 2rem auto; background: rgba(255,255,255,0.9); padding: 2rem; border-radius: 30px; box-shadow: 0 15px 35px rgba(0,0,0,0.1); border: 4px solid white; backdrop-filter: blur(10px); }
.back-btn { background: var(--text); color: white; border: none; padding: 10px 20px; border-radius: 20px; font-size: 1.2rem; cursor: pointer; font-family: inherit; font-weight: bold; margin: 0; }
.lesson-title { text-align: center; font-size: 3rem; color: var(--primary); margin-top: 0; }

.lesson-tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; }
.tab-btn { background: #f0ebff; border: none; padding: 13px 22px; border-radius: 25px; font-size: 1.2rem; font-weight: bold; cursor: pointer; color: var(--primary); transition: all 0.3s; font-family: inherit; border: 2px solid #d4c5ff; }
.tab-btn.active, .tab-btn:hover { background: var(--primary); color: white; transform: translateY(-5px); box-shadow: 0 8px 15px rgba(108,92,231,0.35); border-color: var(--primary); }

.tab-content { display: none; text-align: center; padding: 2rem; background: white; border-radius: 20px; min-height: 350px; box-shadow: inset 0 0 20px rgba(0,0,0,0.02); }
.tab-content.active-tab { display: block; animation: fadeIn 0.4s; }
.instruction-text { font-size: 1.8rem; color: var(--primary); margin-bottom: 20px; }

/* قسم الاستماع */
.listen-zone { display: flex; flex-direction: column; align-items: center; gap: 30px; }
.big-letter { font-size: 8rem; font-weight: bold; color: var(--primary); background: linear-gradient(135deg, #f0ebff, #e6dbff); width: 200px; height: 200px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(108,92,231,0.3); cursor: pointer; border: 8px solid white; }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* أزرار تفاعلية */
.action-btn { background: linear-gradient(135deg, var(--accent), #ffeaa7); color: var(--text); border: none; padding: 15px 35px; border-radius: 30px; font-size: 1.5rem; font-weight: bold; cursor: pointer; font-family: inherit; transition: all 0.2s; box-shadow: 0 5px 0 var(--accent-dark); }
.action-btn:active { transform: translateY(5px); box-shadow: none; }
.bouncy:hover { animation: bouncy 0.5s; }
@keyframes bouncy { 0%, 100%{ transform: translateY(0); } 50%{ transform: translateY(-10px); } }

/* قسم الحركات */
.harakat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; padding: 10px; }
.haraka-card { background: #fff8e1; border: 3px solid var(--accent); border-radius: 20px; padding: 15px; text-align: center; cursor: pointer; transition: all 0.3s; }
.haraka-card:hover { transform: scale(1.1); background: var(--accent); }
.haraka-display { font-size: 4rem; font-weight: bold; color: var(--primary); line-height: 1.2; }
.haraka-name { font-size: 1.1rem; color: #666; margin-top: 5px; font-weight: bold; }

/* قسم المد */
.mad-machine { display: flex; justify-content: center; gap: 15px; align-items: flex-start; flex-wrap: wrap; padding: 10px; }
.mad-block { background: #e8faf4; border: 3px dashed var(--secondary); border-radius: 20px; padding: 20px 15px; width: 160px; text-align: center; cursor: pointer; transition: 0.3s; }
.mad-block:hover { background: var(--secondary); color: white; transform: scale(1.08); }
.mad-label { font-size: 1rem; color: #555; margin-bottom: 8px; font-weight: bold; }
.mad-letters { font-size: 4rem; color: var(--primary); display: block; margin-bottom: 10px; }
.mad-block:hover .mad-letters { color: white; }
.mad-block button { display: block; margin: 10px auto 0; font-family: inherit; font-size: 1.1rem; padding: 8px 18px; }

/* تبويبات الكتابة الداخلية */
.draw-sub-tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; }
.draw-sub-btn { background: #f1f2f6; border: 2px solid var(--primary); color: var(--primary); padding: 8px 22px; border-radius: 20px; font-size: 1.2rem; font-weight: bold; cursor: pointer; font-family: inherit; transition: all 0.25s; }
.draw-sub-btn.active, .draw-sub-btn:hover { background: var(--primary); color: white; transform: translateY(-3px); }
.draw-hint { font-size: 1.2rem; color: #888; margin: 5px 0 12px; font-style: italic; }

/* لوحة الكتابة */
.drawing-zone { display: block; width: 100%; position: relative; }
canvas { background: repeating-linear-gradient(transparent, transparent 34px, #e0e0e0 34px, #e0e0e0 35px), repeating-linear-gradient(90deg, transparent, transparent 34px, #f0f0f0 34px, #f0f0f0 35px), #fff; border: 5px solid var(--accent); border-radius: 20px; cursor: crosshair; box-shadow: var(--shadow); display: block; width: 100%; }
.tools { margin-top: 15px; display: flex; justify-content: center; gap: 15px; }

/* اللعبة */
.game-zone { min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.syllable-draggable { background: linear-gradient(135deg, var(--primary), #a29bfe); color: white; padding: 20px 30px; border-radius: 15px; font-size: 3rem; font-weight: bold; box-shadow: 0 8px 0 var(--primary-dark); cursor: pointer; transition: all 0.2s; min-width: 100px; text-align: center; }
.syllable-draggable:hover { transform: translateY(-5px); box-shadow: 0 13px 0 var(--primary-dark); }
.syllable-draggable:active { transform: translateY(8px); box-shadow: 0 0 0 transparent; }
.wrong-shake { animation: shake 0.5s; background: #e74c3c !important; }
.game-result { font-size: 3.5rem; margin-top: 20px; color: var(--primary); text-shadow: 2px 2px 0 rgba(108,92,231,0.2); text-align: center; line-height: 1.4; }

/* اللعبة التفاعلية للوعي الصوتي */
.find-zone { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-top: 30px; }
.find-card { background: white; border: 3px solid #e0d4ff; border-radius: 22px; padding: 22px 15px; text-align: center; cursor: pointer; transition: 0.3s; width: 150px; font-size: 1.8rem; box-shadow: 0 6px 20px rgba(108,92,231,0.1); }
.find-card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 14px 30px rgba(108,92,231,0.25); background: #f5f0ff; }
.find-card.correct { background: linear-gradient(135deg, #e8faf4, #d4f5f0); border-color: var(--secondary); animation: pulse 0.5s; pointer-events: none; }
.find-card .emoji { font-size: 4rem; display: block; margin-bottom: 15px; }

/* نجمة طائرة */
.flying-star {
    position: fixed;
    font-size: 3rem;
    z-index: 9999;
    pointer-events: none;
    animation: flystar 1s ease-out forwards;
}
@keyframes flystar {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    60%  { transform: translate(-50%, -140%) scale(1.4); opacity: 1; }
    100% { transform: translate(-50%, -260%) scale(0.8); opacity: 0; }
}

@keyframes fadeIn { from{ opacity:0; } to{ opacity:1; } }
@keyframes shake { 0%,100%{ transform: translateX(0); } 25%{ transform: translateX(-10px); } 75%{ transform: translateX(10px); } }

/* صندوق تسجيل الدخول */
.login-box {
    background: white;
    max-width: 400px;
    margin: 3rem auto;
    padding: 2.5rem;
    border-radius: 25px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 5px solid var(--primary);
    position: relative;
    z-index: 10;
}
.login-box input {
    width: 80%;
    padding: 15px;
    margin-bottom: 20px;
    border: 3px solid #eee;
    border-radius: 12px;
    font-size: 1.5rem;
    font-family: inherit;
    text-align: center;
    color: var(--text);
    transition: 0.3s;
}
.login-box input:focus {
    border-color: var(--secondary);
    outline: none;
    transform: scale(1.05);
}

/* التجاوب مع جميع أحجام الشاشات (Responsive Design) */
@media screen and (max-width: 768px) {
    .app-header h1 { font-size: 2.2rem; }
    .app-header p { font-size: 1.2rem; }
    
    .lesson-node {
        width: 80%;
        max-width: 250px;
        padding: 10px 20px;
        font-size: 1.5rem;
    }
    
    #lesson-view {
        margin: 1rem;
        padding: 1rem;
        border-radius: 20px;
    }

    .lesson-title { font-size: 2rem; }

    .tab-btn {
        padding: 10px 15px;
        font-size: 1.1rem;
        flex: 1 1 40%;
        text-align: center;
    }

    .tab-content { padding: 1rem; min-height: auto; }
    
    .big-letter {
        width: 150px;
        height: 150px;
        font-size: 6rem;
    }

    .haraka-display { font-size: 3rem; }
    .haraka-card { padding: 10px; }
    
    .mad-block { width: 120px; padding: 15px 10px; }
    .mad-letters { font-size: 3rem; }

    .action-btn { padding: 10px 25px; font-size: 1.2rem; border-radius: 20px; }

    .game-result { font-size: 2.2rem; }
    .syllable-draggable { padding: 10px 15px; font-size: 1.8rem; }
    
    .login-box {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
    
    .login-box input {
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
        font-size: 1.2rem;
    }
    
    .draw-sub-btn {
        padding: 8px 15px;
        font-size: 1rem;
    }
}

@media screen and (max-width: 480px) {
    .app-header h1 { font-size: 1.8rem; }
    .tab-btn { flex: 1 1 100%; }
    .big-letter { width: 120px; height: 120px; font-size: 5rem; }
    .harakat-grid { grid-template-columns: repeat(2, 1fr); }
    .lesson-tabs { gap: 5px; }
}
