# 🌟 30 Preguntas para Aprobar el Código de Circulación 2024 - Test Gratuito | 2ROUE

Pon a prueba tus conocimientos sobre el carnet de conducir con este quiz interactivo. 30 preguntas de verdadero o falso para repasar el código.

---

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


{/* Hero Section Premium */}
<div className="article-container" style={{textAlign: 'center', padding: '40px 20px'}}>
    <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'}}>✨ CÓDIGO 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 Preguntas de Código
    </h1>
    
    <p style={{fontSize: '1.2em', color: '#cbd5e1', maxWidth: '700px', margin: '0 auto 30px', lineHeight: '1.6'}}>
        Pon a prueba tus conocimientos con <strong style={{color: '#3498db'}}>30 preguntas Verdadero/Falso</strong>, feedback instantáneo y perfil personalizado según tus resultados.
    </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 min crono</div>
        </div>
        <div className="hero-info-card">
            <div style={{fontSize: '2em', marginBottom: '5px'}}>📚</div>
            <div className="hero-info-text">30 preguntas</div>
        </div>
        <div className="hero-info-card">
            <div style={{fontSize: '2em', marginBottom: '5px'}}>🏆</div>
            <div className="hero-info-text">Perfil Piloto</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'}}>
        🚀 INICIAR TEST
    </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'}}>
    <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">Pregunta 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'}}>
    <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>VERDADERO</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>FALSO</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'}}>Puntuación: </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'}}>Publicidad</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
        <button className="continue-btn-30">Continuar serie →</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'}}>Publicidad</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
         <button className="continue-btn-30">Continuar serie →</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'}}>Publicidad</div>
        <ins className="adsbygoogle" data-ad-client="ca-pub-7586675070258543" data-ad-slot="4357278838" data-ad-format="rectangle"></ins>
         <button className="continue-btn-30">Continuar serie →</button>
    </div>
</div>

{/* Results Panel */}
<div id="quiz30-result" style={{display: 'none', maxWidth: '800px', margin: '60px auto', padding: '0 20px'}}>
    <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'}}>Resultado Final</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'}}>
                🔄 Reiniciar
            </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'}}>
                📊 Ver mi perfil
            </a>
        </div>
    </div>
</div>

{/* Content Section */}
<div className="article-container" style={{maxWidth: '800px', margin: '60px auto', padding: '0 20px'}}>
    <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>
            ¿Por qué hacer este test?
        </h2>
        <ul style={{lineHeight: '1.8', color: '#cbd5e1'}}>
            <li><strong>Repaso eficaz</strong>: Diferentes tipos de preguntas (tráfico, señales, prioridades...)</li>
            <li><strong>Formato realista</strong>: Preguntas cercanas al examen oficial</li>
            <li><strong>Aprendizaje lúdico</strong>: Ponte a prueba mientras te diviertes</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>
            Consejos para aprobar
        </h2>
        <ul style={{lineHeight: '1.8', color: '#cbd5e1'}}>
            <li><strong>Estudia regularmente</strong>: Repasa cada día la señalización y las reglas</li>
            <li><strong>Usa tests</strong>: Entrena con este quiz y otras simulaciones</li>
            <li><strong>Analiza tus errores</strong>: Comprende por qué te equivocaste</li>
            <li><strong>Lee atentamente</strong>: Tómate el tiempo de entender cada pregunta</li>
            <li><strong>Mantén la calma</strong>: El día D, guarda tu concentración</li>
        </ul>
    </div>
</div>

{/* Social Sharing */}
<div className="action-buttons-grid" style={{maxWidth: '800px', margin: '40px auto', padding: '0 20px'}}>
    <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'}}>
        📱 Compartir en WhatsApp
    </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: 'Reglas de Tráfico', question: 'Está prohibido adelantar a un coche acercándose a un paso a nivel.', answer: true },
    { category: 'Reglas de Tráfico', question: 'Las luces antiniebla traseras pueden usarse bajo lluvia ligera.', answer: false },
    { category: 'Señalización', question: 'Una señal redonda con fondo blanco y borde rojo indica una prohibición.', answer: true },
    { category: 'Señalización', question: 'Una señal triangular con una bicicleta indica un carril bici obligatorio.', answer: false },
    { category: 'Prioridades', question: 'En un cruce sin señalizar, la prioridad es a la derecha.', answer: true },
    { category: 'Prioridades', question: 'Un vehículo prioritario en servicio de urgencia debe respetar siempre los semáforos rojos.', answer: false },
    { category: 'Velocidad', question: 'La velocidad máxima en autopista en Francia es de 130 km/h.', answer: true },
    { category: 'Velocidad', question: 'En ciudad, la velocidad está limitada a 50 km/h incluso sin señal.', answer: true },
    { category: 'Alcohol y Drogas', question: 'El límite de alcohol permitido para un conductor novel es de 0,2 g/L en sangre (Francia).', answer: true },
    { category: 'Alcohol y Drogas', question: 'Conducir bajo la influencia de drogas está permitido si la cantidad es pequeña.', answer: false },
    { category: 'Iluminación', question: 'Las luces de cruce deben encenderse de día en caso de mala visibilidad.', answer: true },
    { category: 'Iluminación', question: 'Las luces de posición son suficientes para conducir de noche en ciudad.', answer: false },
    { category: 'Estacionamiento', question: 'Está prohibido estacionar a menos de 5 metros de un paso de peatones.', answer: true },
    { category: 'Estacionamiento', question: 'Está permitido estacionar en las aceras si el coche no molesta a los peatones.', answer: false },
    { category: 'Eco-conducción', question: 'Reducir la velocidad ayuda a disminuir el consumo de combustible.', answer: true },
    { category: 'Eco-conducción', question: 'Apagar el motor en un semáforo en rojo está prohibido.', answer: false },
    { category: 'Seguridad', question: 'El uso del cinturón de seguridad es obligatorio delante y detrás.', answer: true },
    { category: 'Seguridad', question: 'Los niños menores de 10 años pueden sentarse delante sin silla de auto.', answer: false },
    { category: 'Túneles', question: 'En un túnel, es obligatorio encender las luces de cruce.', answer: true },
    { category: 'Túneles', question: 'En caso de incendio en un túnel, quédese en su coche.', answer: false },
    { category: 'Peatones', question: 'Los peatones siempre tienen prioridad en los pasos de cebra.', answer: true },
    { category: 'Peatones', question: 'Un peatón que cruza fuera de un paso de cebra nunca tiene prioridad.', answer: false },
    { category: 'Vehículos Lentos', question: 'Los vehículos lentos deben ceñirse a la derecha para facilitar los adelantamientos.', answer: true },
    { category: 'Vehículos Lentos', question: 'Un tractor agrícola puede circular a 80 km/h en una carretera nacional.', answer: false },
    { category: 'Teléfono', question: 'Está prohibido sostener un teléfono en la mano mientras se conduce.', answer: true },
    { category: 'Teléfono', question: 'Usar un kit manos libres está prohibido mientras se conduce.', answer: false },
    { category: 'Permiso por puntos', question: 'Un permiso novel comienza con 6 puntos.', answer: true },
    { category: 'Permiso por puntos', question: 'Se aplica una retirada de 3 puntos por un exceso de velocidad de 20 km/h.', answer: false },
    { category: 'Accidentes', question: 'En caso de accidente, es obligatorio rellenar un parte amistoso.', answer: true },
    { category: 'Accidentes', question: 'Si un accidente implica un animal salvaje, no es necesario declararlo.', 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 = 'Pregunta ' + (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 = "Peatón";
    let emoji = "📚";
    let message = "";
    
    if (score30 === 30) {
        pilotProfile = "Maestro del Código";
        emoji = "🏆";
        message = "¡Perfecto! ¡Dominas totalmente el código de circulación!";
    } else if (score30 >= 25) {
        pilotProfile = "Candidato Listo";
        emoji = "🎯";
        message = "¡Excelente! ¡Estás realmente listo para el examen!";
    } else if (score30 >= 20) {
        pilotProfile = "Aprendiz";
        emoji = "📈";
        message = "¡Buen comienzo! ¡Sigue repasando para perfeccionar tus conocimientos!";
    } else {
        pilotProfile = "Peatón";
        emoji = "📚";
        message = "Hay que repasar las bases. ¡Tómate el tiempo de estudiar bien!";
    }
    
    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('¡He obtenido ' + score30 + '/30 en el quiz de código en 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);
`} />

