# 🌟 30 سؤالاً لاجتياز قانون المرور 2024 - اختبار مجاني وسريع | 2ROUE

اختبر معلوماتك عن رخصة القيادة من خلال هذا الاختبار التفاعلي. 30 سؤالاً بصيغة صح أو خطأ لمراجعة قانون المرور.

---

import ArticleScript from '@/components/ArticleScript';
import ArticleStyle from '@/components/ArticleStyle';


{/* Hero Section Premium */}
<div className="article-container" style={{textAlign: 'center', padding: '40px 20px'}} dir="rtl">
    <div style={{display: 'inline-block', background: 'linear-gradient(135deg, #3498db 0%, #2980b9 100%)', padding: '8px 20px', borderRadius: '20px', marginBottom: '20px'}}>
        <span style={{color: 'white', fontWeight: '700', fontSize: '0.9em'}}>✨ قانون 2024</span>
    </div>
    
    <h1 style={{fontSize: '2.5em', lineHeight: '1.2', marginBottom: '20px', background: 'linear-gradient(135deg, #ffffff 0%, #94a3b8 100%)', WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent', backgroundClip: 'text'}}>
        30 سؤالاً في قانون المرور
    </h1>
    
    <p style={{fontSize: '1.2em', color: '#cbd5e1', maxWidth: '700px', margin: '0 auto 30px', lineHeight: '1.6'}}>
        اختبر معلوماتك مع <strong style={{color: '#3498db'}}>30 سؤالاً صح/خطأ</strong>، مع نتائج فورية وملف شخصي مخصص حسب إجاباتك.
    </p>
    
    {/* Image removed: broken link (wp-content) */}
    
    <div className="hero-info-grid">
        <div className="hero-info-card">
            <div style={{fontSize: '2em', marginBottom: '5px'}}>⚡</div>
            <div className="hero-info-text">3 دقائق</div>
        </div>
        <div className="hero-info-card">
            <div style={{fontSize: '2em', marginBottom: '5px'}}>📚</div>
            <div className="hero-info-text">30 سؤالاً</div>
        </div>
        <div className="hero-info-card">
            <div style={{fontSize: '2em', marginBottom: '5px'}}>🏆</div>
            <div className="hero-info-text">ملف السائق</div>
        </div>
    </div>
    
    <button id="start-quiz30" style={{background: 'linear-gradient(135deg, #3498db, #2980b9)', color: 'white', border: 'none', padding: '18px 50px', borderRadius: '50px', fontSize: '1.3em', fontWeight: '700', cursor: 'pointer', boxShadow: '0 10px 30px rgba(52, 152, 219, 0.4)', marginTop: '40px', transition: 'all 0.3s'}}>
        🚀 ابدأ الاختبار
    </button>
</div>

{/* Progress Bar */}
<div id="quiz30-progress-container" style={{position: 'sticky', top: '0', zIndex: '100', background: 'rgba(2, 6, 23, 0.95)', backdropFilter: 'blur(10px)', padding: '15px 20px', borderBottom: '1px solid rgba(255,255,255,0.1)', display: 'none'}} dir="rtl">
    <div style={{maxWidth: '800px', margin: '0 auto'}}>
        <div style={{display: 'flex', justifyContent: 'space-between', marginBottom: '8px'}}>
            <span style={{fontSize: '0.9em', color: '#94a3b8'}} id="quiz30-progress-text">سؤال 1/30</span>
            <span style={{fontSize: '0.9em', color: '#3498db', fontWeight: '600'}} id="quiz30-timer">0:00</span>
        </div>
        <div style={{height: '6px', background: 'rgba(255,255,255,0.1)', borderRadius: '10px', overflow: 'hidden'}}>
            <div id="quiz30-progress-bar" style={{height: '100%', width: '3.33%', background: 'linear-gradient(90deg, #3498db, #2980b9)', transition: 'width 0.3s ease', borderRadius: '10px'}}></div>
        </div>
    </div>
</div>

{/* Quiz Container (Premium Design) */}
<div id="quiz30-container" style={{display: 'none', maxWidth: '800px', margin: '40px auto', padding: '0 20px'}} dir="rtl">
    <div style={{background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px', marginBottom: '20px'}}>
        <div style={{display: 'flex', alignItems: 'center', gap: '15px', marginBottom: '15px'}}>
            <div id="quiz30-badge" style={{background: 'linear-gradient(135deg, #3498db, #2980b9)', minWidth: '50px', height: '50px', borderRadius: '12px', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '1.5em', fontWeight: '800', color: 'white', flexShrink: '0'}}>1</div>
            <div id="quiz30-category" style={{textTransform: 'uppercase', fontSize: '0.85em', letterSpacing: '1.5px', color: '#3498db', background: 'rgba(52, 152, 219, 0.1)', padding: '6px 15px', borderRadius: '20px'}}></div>
        </div>
        
        <h3 id="quiz30-quest" style={{fontSize: '1.4em', margin: '25px 0', lineHeight: '1.5', color: '#e2e8f0'}}></h3>
        
        <div style={{display: 'grid', gap: '15px', marginTop: '30px'}}>
            <button id="answer-true-30" style={{display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '15px', padding: '20px', background: 'rgba(46, 204, 113, 0.1)', border: '2px solid rgba(46, 204, 113, 0.3)', borderRadius: '12px', cursor: 'pointer', transition: 'all 0.3s', color: '#2ecc71', fontSize: '1.1em', fontWeight: '600'}}>
                <span style={{fontSize: '1.8em'}}>✓</span>
                <span>صح</span>
            </button>
            <button id="answer-false-30" style={{display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '15px', padding: '20px', background: 'rgba(231, 76, 60, 0.1)', border: '2px solid rgba(231, 76, 60, 0.3)', borderRadius: '12px', cursor: 'pointer', transition: 'all 0.3s', color: '#e74c3c', fontSize: '1.1em', fontWeight: '600'}}>
                <span style={{fontSize: '1.8em'}}>✗</span>
                <span>خطأ</span>
            </button>
        </div>
        
        <div style={{textAlign: 'center', marginTop: '30px', paddingTop: '20px', borderTop: '1px solid rgba(255,255,255,0.1)'}}>
            <span style={{fontSize: '1.1em', color: '#94a3b8'}}>النقاط: </span>
            <span id="quiz30-points" style={{fontSize: '1.3em', fontWeight: '700', color: '#3498db'}}>0</span>
        </div>
    </div>

    {/* Ad Interstitials */}
    <div id="quiz30-ad-2" className="quiz-ad-interstitial" style={{display: 'none', background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px', textAlign: 'center'}}>
        <div style={{fontSize: '0.75em', color: '#64748b', marginBottom: '8px'}}>إعلان</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
        <button className="continue-btn-30">متابعة السلسلة ←</button>
    </div>
    <div id="quiz30-ad-4" className="quiz-ad-interstitial" style={{display: 'none', background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px', textAlign: 'center'}}>
        <div style={{fontSize: '0.75em', color: '#64748b', marginBottom: '8px'}}>إعلان</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
         <button className="continue-btn-30">متابعة السلسلة ←</button>
    </div>
    <div id="quiz30-ad-6" className="quiz-ad-interstitial" style={{display: 'none', background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px', textAlign: 'center'}}>
        <div style={{fontSize: '0.75em', color: '#64748b', marginBottom: '8px'}}>إعلان</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
         <button className="continue-btn-30">متابعة السلسلة ←</button>
    </div>
</div>

{/* Results Panel */}
<div id="quiz30-result" style={{display: 'none', maxWidth: '800px', margin: '60px auto', padding: '0 20px'}} dir="rtl">
    <div style={{background: 'linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(41, 128, 185, 0.1))', border: '2px solid rgba(52, 152, 219, 0.3)', borderRadius: '24px', padding: '50px 40px', textAlign: 'center'}}>
        <div style={{fontSize: '4em', marginBottom: '20px'}} id="quiz30-emoji">🎉</div>
        <h2 style={{fontSize: '2.2em', marginBottom: '15px'}}>النتيجة النهائية</h2>
        <div id="quiz30-final-score" style={{fontSize: '3.5em', fontWeight: '800', background: 'linear-gradient(135deg, #3498db, #2980b9)', WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent', backgroundClip: 'text', marginBottom: '20px'}}></div>
        <p id="quiz30-result-text" style={{fontSize: '1.2em', color: '#cbd5e1', marginBottom: '10px'}}></p>
        <div id="quiz30-profile" style={{display: 'inline-block', background: 'rgba(52, 152, 219, 0.2)', padding: '12px 30px', borderRadius: '20px', marginTop: '20px'}}>
            <span style={{color: '#3498db', fontWeight: '700', fontSize: '1.1em'}} id="quiz30-profile-badge"></span>
        </div>

        <div style={{display: 'flex', gap: '15px', justifyContent: 'center', marginTop: '40px', flexWrap: 'wrap'}}>
            <button id="reset-quiz30" style={{background: 'linear-gradient(135deg, #3498db, #2980b9)', color: 'white', border: 'none', padding: '16px 35px', borderRadius: '12px', fontSize: '1.05em', fontWeight: '700', cursor: 'pointer'}}>
                🔄 إعادة المحاولة
            </button>
            <a href="/dashboard" style={{background: 'rgba(255,255,255,0.05)', color: 'white', border: '2px solid rgba(255,255,255,0.2)', padding: '16px 35px', borderRadius: '12px', fontSize: '1.05em', fontWeight: '600', textDecoration: 'none', display: 'inline-block'}}>
                📊 عرض الملف الشخصي
            </a>
        </div>
    </div>
</div>

{/* Content Section */}
<div className="article-container" style={{maxWidth: '800px', margin: '60px auto', padding: '0 20px'}} dir="rtl">
    <div style={{background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px', marginBottom: '30px'}}>
        <h2 style={{display: 'flex', alignItems: 'center', gap: '15px', marginBottom: '20px'}}>
            <span style={{fontSize: '2em'}}>❓</span>
            لماذا هذا الاختبار؟
        </h2>
        <ul style={{lineHeight: '1.8', color: '#cbd5e1'}}>
            <li><strong>مراجعة فعالة</strong>: أنواع مختلفة من الأسئلة (حركة المرور، الإشارات، الأولويات...)</li>
            <li><strong>تنسيق واقعي</strong>: أسئلة قريبة من الامتحان الرسمي</li>
            <li><strong>تعلم ممتع</strong>: اختبر نفسك أثناء الاستمتاع</li>
        </ul>
    </div>
    
    <div style={{background: 'rgba(255,255,255,0.02)', border: '1px solid rgba(255,255,255,0.1)', borderRadius: '20px', padding: '40px'}}>
        <h2 style={{display: 'flex', alignItems: 'center', gap: '15px', marginBottom: '20px'}}>
            <span style={{fontSize: '2em'}}>📝</span>
            نصائح للنجاح
        </h2>
        <ul style={{lineHeight: '1.8', color: '#cbd5e1'}}>
            <li><strong>ادرس بانتظام</strong>: راجع الإشارات والقواعد يومياً</li>
            <li><strong>استخدم الاختبارات</strong>: تدرب مع هذا الاختبار ومحاكاة أخرى</li>
            <li><strong>حلل أخطاءك</strong>: افهم لماذا أخطأت</li>
            <li><strong>اقرأ بعناية</strong>: خذ وقتك لفهم كل سؤال</li>
            <li><strong>ابق هادئاً</strong>: في يوم الامتحان، حافظ على تركيزك</li>
        </ul>
    </div>
</div>

{/* Social Sharing */}
<div className="action-buttons-grid" style={{maxWidth: '800px', margin: '40px auto', padding: '0 20px'}} dir="rtl">
    <a href="#" id="share-whatsapp-30" className="btn-share-whatsapp" style={{background: 'linear-gradient(135deg, #25D366, #128C7E)', color: 'white', padding: '20px', borderRadius: '16px', textDecoration: 'none', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '12px', fontWeight: '700', fontSize: '1.1em', transition: 'transform 0.2s'}}>
        📱 مشاركة عبر واتساب
    </a>
</div>


<ArticleStyle content={`

/* Fix text overflow in results */
#quiz30-result,
#quiz30-result p,
#quiz30-quest {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}
#quiz30-result li {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

/* Hero Info Cards */
.hero-info-grid { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.hero-info-card { background: rgba(255,255,255,0.05); padding: 12px 20px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); text-align: center; min-width: 120px; }
.hero-info-text { font-size: 0.9em; color: #94a3b8; }
.continue-btn-30 {
    display: block; width: 100%; margin-top: 20px; padding: 15px;
    background: linear-gradient(135deg, #3498db, #2980b9); color: white;
    border: none; border-radius: 12px; font-weight: 700; cursor: pointer;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .article-container { padding: 20px 10px; }
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }
    p { font-size: 1em; }

    .hero-info-grid { gap: 8px; }
    .hero-info-card { padding: 8px 5px; flex: 1; min-width: 80px; }
    .hero-info-card div:first-child { font-size: 1.4em; margin-bottom: 2px; }
    .hero-info-text { font-size: 0.75em; line-height: 1.2; }
    
    #answer-true-30, #answer-false-30 {
        padding: 12px;
        font-size: 1em;
        width: 100%;
        box-sizing: border-box;
    }
    
    #start-quiz30, #reset-quiz30, a[href="/dashboard"] {
        width: 100%;
        padding: 15px 20px;
        box-sizing: border-box;
        margin-bottom: 10px;
        display: block;
        text-align: center;
    }
}

`} />

<ArticleScript content={`
if (window.initCode2024QuizDone) {
    // Already initialized
} else {
    // Reset flag just in case
}

const questions30 = [
    { category: 'قواعد المرور', question: 'يُمنع تجاوز سيارة عند الاقتراب من معبر سكة حديد.', answer: true },
    { category: 'قواعد المرور', question: 'يمكن استخدام مصابيح الضباب الخلفية في المطر الخفيف.', answer: false },
    { category: 'الإشارات', question: 'علامة دائرية بخلفية بيضاء وحافة حمراء تشير إلى المنع.', answer: true },
    { category: 'الإشارات', question: 'علامة مثلثة مع دراجة تشير إلى مسار دراجات إلزامي.', answer: false },
    { category: 'الأولويات', question: 'في تقاطع بدون إشارات، الأولوية لليمين.', answer: true },
    { category: 'الأولويات', question: 'مركبة الطوارئ في مهمة يجب أن تحترم دائماً الإشارات الحمراء.', answer: false },
    { category: 'السرعة', question: 'السرعة القصوى على الطريق السريع في فرنسا هي 130 كم/ساعة.', answer: true },
    { category: 'السرعة', question: 'في المدينة، السرعة محددة بـ 50 كم/ساعة حتى في غياب الإشارات.', answer: true },
    { category: 'الكحول والمخدرات', question: 'حد الكحول المسموح به للسائق المبتدئ هو 0.2 غرام/لتر في الدم.', answer: true },
    { category: 'الكحول والمخدرات', question: 'القيادة تحت تأثير المخدرات مسموحة إذا كانت الكمية قليلة.', answer: false },
    { category: 'الإضاءة', question: 'يجب تشغيل المصابيح الأمامية المنخفضة نهاراً في حالة ضعف الرؤية.', answer: true },
    { category: 'الإضاءة', question: 'أضواء الموضع كافية للقيادة ليلاً في المدينة.', answer: false },
    { category: 'الوقوف', question: 'يُمنع الوقوف على مسافة أقل من 5 أمتار من معبر المشاة.', answer: true },
    { category: 'الوقوف', question: 'يُسمح بالوقوف على الأرصفة إذا كانت السيارة لا تعيق المشاة.', answer: false },
    { category: 'القيادة الاقتصادية', question: 'تقليل السرعة يساعد في تقليل استهلاك الوقود.', answer: true },
    { category: 'القيادة الاقتصادية', question: 'إيقاف المحرك عند الإشارة الحمراء ممنوع.', answer: false },
    { category: 'السلامة', question: 'ارتداء حزام الأمان إلزامي في الأمام والخلف.', answer: true },
    { category: 'السلامة', question: 'يمكن للأطفال دون سن 10 سنوات الجلوس في الأمام بدون مقعد سيارة.', answer: false },
    { category: 'الأنفاق', question: 'في النفق، يجب تشغيل المصابيح الأمامية المنخفضة.', answer: true },
    { category: 'الأنفاق', question: 'في حالة نشوب حريق في نفق، ابق في سيارتك.', answer: false },
    { category: 'المشاة', question: 'للمشاة دائماً الأولوية على معابر المشاة.', answer: true },
    { category: 'المشاة', question: 'المشاة الذين يعبرون خارج معبر المشاة ليس لهم أولوية أبداً.', answer: false },
    { category: 'المركبات البطيئة', question: 'يجب على المركبات البطيئة التزام اليمين لتسهيل التجاوز.', answer: true },
    { category: 'المركبات البطيئة', question: 'يمكن لجرار زراعي السير بسرعة 80 كم/ساعة على طريق وطني.', answer: false },
    { category: 'الهاتف', question: 'يُمنع حمل الهاتف باليد أثناء القيادة.', answer: true },
    { category: 'الهاتف', question: 'استخدام مجموعة أدوات اليدين ممنوع أثناء القيادة.', answer: false },
    { category: 'رخصة النقاط', question: 'تبدأ الرخصة التجريبية بـ 6 نقاط.', answer: true },
    { category: 'رخصة النقاط', question: 'يتم خصم 3 نقاط لتجاوز السرعة بمقدار 20 كم/ساعة.', answer: false },
    { category: 'الحوادث', question: 'في حالة وقوع حادث، يجب ملء تقرير ودي.', answer: true },
    { category: 'الحوادث', question: 'إذا تسبب حادث في إصابة حيوان بري، فليس من الضروري الإبلاغ عنه.', answer: false }
];

let currentQuestionIndex30 = 0;
let score30 = 0;
let startTime30 = Date.now();
let timerInterval30 = null;

function startTimer30() {
    if (timerInterval30) clearInterval(timerInterval30);
    startTime30 = Date.now();
    timerInterval30 = setInterval(updateTimer30, 1000);
}

function updateTimer30() {
    const elapsed = Math.floor((Date.now() - startTime30) / 1000);
    const minutes = Math.floor(elapsed / 60);
    const seconds = elapsed % 60;
    const timerEl = document.getElementById('quiz30-timer');
    if (timerEl) {
        timerEl.textContent = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
    }
}

function updateProgress30() {
    const progressText = document.getElementById('quiz30-progress-text');
    const progressBar = document.getElementById('quiz30-progress-bar');
    const progressContainer = document.getElementById('quiz30-progress-container');
    const badge = document.getElementById('quiz30-badge');
    
    if (progressText) progressText.textContent = 'سؤال ' + (currentQuestionIndex30 + 1) + '/30';
    if (progressBar) progressBar.style.width = ((currentQuestionIndex30 + 1) / 30 * 100) + '%';
    if (progressContainer) progressContainer.style.display = 'block';
    if (badge) badge.textContent = (currentQuestionIndex30 + 1);
}

function startQuiz30() {
    const startBtn = document.getElementById('start-quiz30');
    const quizContainer = document.getElementById('quiz30-container');
    
    if (startBtn) startBtn.style.display = 'none';
    if (quizContainer) quizContainer.style.display = 'block';
    
    currentQuestionIndex30 = 0;
    score30 = 0;
    startTimer30();
    showQuestion30();
    
    quizContainer.scrollIntoView({ behavior: 'smooth' });
}

function showQuestion30() {
    const question = questions30[currentQuestionIndex30];
    const categoryEl = document.getElementById('quiz30-category');
    const questEl = document.getElementById('quiz30-quest');
    const pointsEl = document.getElementById('quiz30-points');
    
    if (categoryEl) categoryEl.textContent = question.category;
    if (questEl) questEl.textContent = question.question;
    if (pointsEl) pointsEl.textContent = score30;
    
    updateProgress30();
}

function answerQuiz30(userAnswer) {
    const question = questions30[currentQuestionIndex30];
    if (userAnswer === question.answer) {
        score30++;
    }
    currentQuestionIndex30++;
    
    // Ad break at index 2, 4, 6
    if ([2, 4, 6].includes(currentQuestionIndex30)) {
        showAdBreak30(currentQuestionIndex30);
    } else if (currentQuestionIndex30 < questions30.length) {
        showQuestion30();
    } else {
        endQuiz30();
    }
}

function showAdBreak30(index) {
    const container = document.getElementById('quiz30-container');
    if(!container) return;
    
    const children = container.children;
    for(let i=0; i<children.length; i++) {
        children[i].style.display = 'none';
    }
    
    const adId = 'quiz30-ad-' + index;
    const adFn = document.getElementById(adId);
    if (adFn) {
        adFn.style.display = 'block';
        try { (window.adsbygoogle = window.adsbygoogle || []).push({}); } catch(e) {}
    } else {
        proceedToNextQuestion30();
    }
}

function resumeQuiz30() {
    document.querySelectorAll('.quiz-ad-interstitial').forEach(ad => ad.style.display = 'none');
    
    const container = document.getElementById('quiz30-container');
    if(container && container.firstElementChild) {
        container.firstElementChild.style.display = 'block';
    }
    
    if (currentQuestionIndex30 < questions30.length) {
        showQuestion30();
    } else {
        endQuiz30();
    }
}

function proceedToNextQuestion30() {
    const container = document.getElementById('quiz30-container');
    if(container && container.firstElementChild) {
        container.firstElementChild.style.display = 'block';
    }
    if (currentQuestionIndex30 < questions30.length) {
        showQuestion30();
    } else {
        endQuiz30();
    }
}

function endQuiz30() {
    if (timerInterval30) clearInterval(timerInterval30);
    
    const quizContainer = document.getElementById('quiz30-container');
    const resultDiv = document.getElementById('quiz30-result');
    const scoreEl = document.getElementById('quiz30-final-score');
    const textEl = document.getElementById('quiz30-result-text');
    const profileEl = document.getElementById('quiz30-profile-badge');
    const emojiEl = document.getElementById('quiz30-emoji');
    const progressContainer = document.getElementById('quiz30-progress-container');
    
    if (quizContainer) quizContainer.style.display = 'none';
    if (progressContainer) progressContainer.style.display = 'none';
    
    // Profiling
    let pilotProfile = "مشاة";
    let emoji = "📚";
    let message = "";
    
    if (score30 === 30) {
        pilotProfile = "سيد القانون";
        emoji = "🏆";
        message = "مثالي! أنت تتقن قانون المرور تماماً!";
    } else if (score30 >= 25) {
        pilotProfile = "مرشح جاهز";
        emoji = "🎯";
        message = "ممتاز! أنت جاهز حقاً للامتحان!";
    } else if (score30 >= 20) {
        pilotProfile = "متدرب";
        emoji = "📈";
        message = "بداية جيدة! استمر في المراجعة لإتقان معرفتك!";
    } else {
        pilotProfile = "مشاة";
        emoji = "📚";
        message = "تحتاج إلى مراجعة الأساسيات. خذ وقتك للدراسة!";
    }
    
    try {
        if (typeof window.save2RoueQuizResult === 'function') {
            window.save2RoueQuizResult(score30, 30, '30 Questions Code', pilotProfile);
        }
    } catch(e) { console.error(e); }
    
    if (scoreEl) scoreEl.textContent = score30 + '/30';
    if (textEl) textEl.textContent = message;
    if (profileEl) profileEl.textContent = '🎖️ ' + pilotProfile;
    if (emojiEl) emojiEl.textContent = emoji;
    
    // Update share link
    const shareBtn = document.getElementById('share-whatsapp-30');
    if (shareBtn) {
        const shareText = encodeURIComponent('لقد حصلت على ' + score30 + '/30 في اختبار قانون المرور على 2roue.com! 🏍️');
        shareBtn.href = 'https://wa.me/?text=' + shareText;
    }
    
    if (resultDiv) {
        resultDiv.style.display = 'block';
        resultDiv.scrollIntoView({ behavior: 'smooth', block: 'center' });
    }
}

function restartQuiz30() {
    document.getElementById('quiz30-result').style.display = 'none';
    document.getElementById('start-quiz30').style.display = 'inline-block';
    
    currentQuestionIndex30 = 0;
    score30 = 0;
    
    window.scrollTo({ top: 0, behavior: 'smooth' });
}

window.startTimer30 = startTimer30;
window.startQuiz30 = startQuiz30;
window.restartQuiz30 = restartQuiz30;
window.resumeQuiz30 = resumeQuiz30;

window.initCode2024Quiz = function() {
    if (window.initCode2024QuizDone) return;
    window.initCode2024QuizDone = true;
    
    const startBtn = document.getElementById('start-quiz30');
    const trueBtn = document.getElementById('answer-true-30');
    const falseBtn = document.getElementById('answer-false-30');
    const resetBtn = document.getElementById('reset-quiz30');
    
    if (startBtn) startBtn.onclick = startQuiz30;
    if (trueBtn) trueBtn.onclick = function() { answerQuiz30(true); };
    if (falseBtn) falseBtn.onclick = function() { answerQuiz30(false); };
    if (resetBtn) resetBtn.onclick = restartQuiz30;
    
    document.querySelectorAll('.continue-btn-30').forEach(btn => {
        btn.onclick = resumeQuiz30;
    });
};

if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', window.initCode2024Quiz);
} else {
    window.initCode2024Quiz();
}
setTimeout(function() {
   if(!window.initCode2024QuizDone && window.initCode2024Quiz) window.initCode2024Quiz();
}, 500);
`} />

