Check out this Pen I made!


<!DOCTYPE html>




تحدّي أبطال التجويد - أقسام المد :root { --bg: #0f172a; --card: #1e293b; --card-light: #334155; --primary: #10b981; --primary-hover: #059669; --accent: #f59e0b; --danger: #ef4444; --text: #f8fafc; --muted: #94a3b8; } * { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { margin: 0; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%); color: var(--text); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 16px; } .container { width: 100%; max-width: 720px; background: var(--card); border-radius: 24px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.08); } .badge { display: inline-block; background: rgba(16, 185, 129, 0.15); color: var(--primary); padding: 6px 14px; border-radius: 999px; font-size: 0.9rem; font-weight: bold; margin-bottom: 12px; } .start-screen, .end-screen { text-align: center; padding: 20px 10px; } .start-screen h1 { font-size: 2rem; color: #fff; margin: 0 0 12px; } .start-screen p { color: var(--muted); font-size: 1.05rem; line-height: 1.7; margin-bottom: 24px; } .features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 28px; } .feat-box { background: rgba(255,255,255,0.04); padding: 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); } .feat-box span { font-size: 1.6rem; display: block; margin-bottom: 6px; } .btn { background: var(--primary); color: #fff; border: none; padding: 14px 32px; font-size: 1.1rem; font-weight: bold; border-radius: 14px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35); } .btn:hover { background: var(--primary-hover); transform: translateY(-2px); } .btn-secondary { background: var(--card-light); box-shadow: none; padding: 10px 18px; font-size: 0.95rem; } .btn-secondary:hover:not(:disabled) { background: #475569; } .btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; } .top-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; background: rgba(15, 23, 42, 0.6); padding: 12px 16px; border-radius: 16px; } .stat { font-weight: bold; font-size: 1rem; display: flex; align-items: center; gap: 6px; } .hearts { color: var(--danger); letter-spacing: 2px; font-size: 1.2rem; } .streak { color: var(--accent); } .timer-bar-bg { width: 100%; height: 10px; background: #0f172a; border-radius: 999px; overflow: hidden; margin-bottom: 20px; } .timer-bar-fill { height: 100%; width: 100%; background: var(--primary); transition: width 0.25s linear, background-color 0.3s ease; } .q-header { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; } .question-text { font-size: 1.3rem; font-weight: bold; line-height: 1.6; margin-bottom: 20px; color: #fff; } .options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; } .option-btn { background: rgba(255, 255, 255, 0.05); border: 2px solid rgba(255, 255, 255, 0.1); color: #fff; padding: 15px 18px; border-radius: 14px; text-align: right; font-size: 1.05rem; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; gap: 12px; } .option-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); border-color: var(--primary); } .option-btn.correct { background: rgba(16, 185, 129, 0.2); border-color: var(--primary); color: #a7f3d0; } .option-btn.wrong { background: rgba(239, 68, 68, 0.2); border-color: var(--danger); color: #fecaca; } .option-btn.hidden-opt { opacity: 0.25; pointer-events: none; } .lifelines { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; } .hint-box { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.4); color: #fde68a; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 0.95rem; display: none; } .feedback-box { padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; display: none; line-height: 1.6; } .feedback-box.good { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--primary); color: #d1fae5; } .feedback-box.bad { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: #fee2e2; } .actions-footer { display: flex; justify-content: flex-end; } .hidden { display: none !important; } .score-circle { width: 130px; height: 130px; border-radius: 50%; background: rgba(16, 185, 129, 0.15); border: 4px solid var(--primary); display: flex; flex-direction: column; justify-content: center; align-items: center; margin: 0 auto 20px; } .score-circle strong { font-size: 2rem; color: var(--primary); } .review-list { text-align: right; margin-top: 24px; max-height: 320px; overflow-y: auto; padding-left: 6px; } .review-item { background: rgba(15, 23, 42, 0.6); padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; border-right: 4px solid var(--primary); } .review-item.bad-item { border-right-color: var(--danger); }
يعمل مباشرة بدون إنترنت أو تسجيل دخول <h1>🎮 تحدّي أبطال التجويد</h1> <p>اختبار تفاعلي ممتع من <strong>درس أقسام المد</strong> حتى نهاية <strong>الدرس الخامس عشر</strong> (12 سؤالاً سهلاً ومتدرجاً).</p> <span>⏱️</span><strong>20 ثانية</strong><br><small>لكل سؤال</small> <span>❤️</span><strong>3 قلوب</strong><br><small>فرص المحاولة</small> <span>🔥</span><strong>مضاعف نقاط</strong><br><small>للإجابات المتتالية</small> <span>💡</span><strong>وسائل مساعدة</strong><br><small>حذف إجابتين وتلميح</small> ابدأ التحدّي الآن 🚀 🏆 النقاط: <span id="scoreVal">0</span> 🔥 السلسلة: <span id="streakVal">0</span> ❤️❤️❤️ <span id="qCounter">السؤال 1 من 12</span> <span id="timerText">⏳ 20 ثانية</span> ✂️ حذف إجابتين 💡 تلميح سريع السؤال التالي ⬅️ اكتمل التحدّي! <h2 id="endTitle">أحسنت يا بطل التجويد! 🌟</h2> <strong id="finalScore">0</strong> <span>نقطة</span> <p id="endSummary"></p> العب مرة أخرى 🔄 

const questions = [
{
q: "ينقسم المد في درس أقسام المد إلى قسمين رئيسيين هما:",
options: ["المد الطبيعي (الأصلي) والمد الفرعي", "المد القصير والمد الطويل", "مد اللين والمد العارض", "المد الكلمي والمد الحرفي"],
answer: 0,
hint: "أحدهما لا يتوقف على سبب، والآخر يتوقف على همز أو سكون.",
explain: "ينقسم المد إلى قسمين: المد الطبيعي (الأصلي) والمد الفرعي."
},
{
q: "مقدار المد الطبيعي (الأصلي) هو:",
options: ["4 حركات", "6 حركات", "حركتان فقط", "5 حركات"],
answer: 2,
hint: "صاحب الطبيعة السليمة لا يزيده ولا ينقصه عن هذا المقدار.",
explain: "المد الطبيعي يُمدّ بمقدار حركتين وصلاً ووقفاً."
},
{
q: "ضابط المد الطبيعي (الأصلي) هو ألا يأتي بعد حرف المد:",
options: ["حرف متحرك", "همز أو سكون", "تنوين فتح", "حرف مشدد في كلمة أخرى"],
answer: 1,
hint: "هذان هما سببا المد الفرعي!",
explain: "ضابط المد الطبيعي ألا يأتي بعد حرف المد همز أو سكون."
},
{
q: "أيٌّ مما يلي يُعدّ من أقسام المد الطبيعي؟",
options: ["المد الواجب المتصل", "المد اللازم", "مد العِوَض ومد البدل ومد التمكين", "المد العارض للسكون"],
answer: 2,
hint: "كلها تُمدّ بمقدار حركتين وتُلحق بالمد الطبيعي.",
explain: "أقسام المد الطبيعي خمسة: الطبيعي، مد العِوَض، مد الصّلة الصّغرى، مد البدل، ومد التمكين."
},
{
q: "مدّ العِوَض يكون عند الوقف على الكلمة المنوّنة بـ:",
options: ["تنوين الضم", "تنوين الكسر", "تنوين الفتح (النصب)", "السكون الأصلي"],
answer: 2,
hint: "مثل الوقف على كلمة (عَلِيمًا) فنقف عليها (عَلِيمَا).",
explain: "مد العوض هو التعويض عن تنوين الفتح (النصب) حال الوقف بألف مدية مقدارها حركتان."
},
{
q: "مدّ الصّلة الصّغرى يكون ثابتاً في حالة:",
options: ["الوقف فقط", "الوصل فقط", "الوصل والوقف معاً", "الابتداء بالكلمة"],
answer: 1,
hint: "إذا وقفت على هاء الضمير تسكنها ويزول المد.",
explain: "مد الصلة الصغرى ثابت في حالة الوصل فقط بمقدار حركتين."
},
{
q: "سُمّي (مدّ البدل) بهذا الاسم لأن حرف المد فيه يكون مبدلاً عن:",
options: ["همزة ساكنة", "ألف مقصورة", "واو متحركة", "نون ساكنة"],
answer: 0,
hint: "أصل (ءَامَنُوا) هو (أَأْمَنُوا) فأُبدلت الهمزة الثانية حرف مد.",
explain: "سُمي بدلاً لأن حرف المد فيه مبدل عن همزة ساكنة، ومقداره حركتان."
},
{
q: "الهدف من (مدّ التمكين) هو:",
options: ["تطويل الصوت عند الوقف", "منع إدغام حرف المد في حرف مماثل متحرك أو منع سقوطه", "إظهار الهمزة المتطرفة", "تسهيل النطق بالقلقلة"],
answer: 1,
hint: "مثل (حُيِّيتُم) أو (فِي يَوْمٍ) لتمكين حرف المد وإبرازه.",
explain: "مد التمكين يمنع إدغام حرف المد في حرف مماثل له متحرك أو سقوطه من النطق."
},
{
q: "المد الواجب المتصل يأتي فيه حرف المد وبعده همزة في:",
options: ["كلمتين متتاليتين", "كلمة واحدة", "حرف واحد من الحروف المقطعة", "آخر الآية فقط"],
answer: 1,
hint: "مثل كلمة (السَّمَاءِ) و(أُولَئِكَ).",
explain: "المد الواجب المتصل يجتمع فيه حرف المد والهمز في كلمة واحدة ويمد 4 أو 5 حركات."
},
{
q: "مقدار المد الجائز المنفصل (مثل: إِنَّا أَعْطَيْنَاكَ) هو:",
options: ["حركتان وجوباً", "4 أو 5 حركات", "6 حركات لزوماً", "حركة واحدة"],
answer: 1,
hint: "نفس مقدار المد المتصل في الوصل في رواية حفص.",
explain: "المد الجائز المنفصل يأتي في كلمتين ويمد بمقدار 4 أو 5 حركات."
},
{
q: "المد العارض للسكون (مثل: تَعْلَمُونَ عند الوقف) يُمدّ بمقدار:",
options: ["حركتين فقط", "4 حركات فقط", "2 أو 4 أو 6 حركات", "6 حركات وجوباً"],
answer: 2,
hint: "يجوز فيه القصر والتوسط والطول.",
explain: "المد العارض للسكون يجوز مده بمقدار 2 أو 4 أو 6 حركات."
},
{
q: "المد اللازم يُمدّ بمقدار 6 حركات وصلاً ووقفاً، وينقسم إلى:",
options: ["مد لازم كلمي ومد لازم حرفي", "مد متصل ومد منفصل", "مد عوض ومد صلة", "مد لين ومد بدل"],
answer: 0,
hint: "أحدهما يقع في الكلمات مثل (الضَّالِّينَ) والآخر في الحروف المقطعة.",
explain: "المد اللازم يمد 6 حركات لزوماً وينقسم إلى مد لازم كلمي ومد لازم حرفي."
}
];

let currentIdx = 0, score = 0, streak = 0, hearts = 3;
let timer = null, timeLeft = 20, used5050 = false, usedHint = false, answered = false;
let historyLog = [];

function playTone(freq, type, duration) {
try {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.type = type;
osc.frequency.value = freq;
gain.gain.setValueAtTime(0.12, ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + duration);
osc.connect(gain);
gain.connect(ctx.destination);
osc.start();
osc.stop(ctx.currentTime + duration);
} catch (e) {}
}

function startGame() {
currentIdx = 0; score = 0; streak = 0; hearts = 3;
used5050 = false; usedHint = false; historyLog = [];
document.getElementById("btn5050").disabled = false;
document.getElementById("btnHint").disabled = false;
document.getElementById("startScreen").classList.add("hidden");
document.getElementById("endScreen").classList.add("hidden");
document.getElementById("gameScreen").classList.remove("hidden");
updateStats();
loadQuestion();
}

function updateStats() {
document.getElementById("scoreVal").textContent = score;
document.getElementById("streakVal").textContent = streak;
document.getElementById("heartsVal").textContent = "❤️".repeat(hearts) + "🖤".repeat(3 - hearts);
}

function loadQuestion() {
answered = false;
const qObj = questions[currentIdx];
document.getElementById("qCounter").textContent = السؤال ${currentIdx + 1} من ${questions.length};
document.getElementById("questionText").textContent = qObj.q;
document.getElementById("hintBox").style.display = "none";
document.getElementById("feedbackBox").style.display = "none";
document.getElementById("nextBtn").classList.add("hidden");

const optionsBox = document.getElementById("optionsBox");
optionsBox.innerHTML = "";
const letters = ["أ", "ب", "ج", "د"];

qObj.options.forEach((opt, i) => {
const btn = document.createElement("button");
btn.className = "option-btn";
btn.innerHTML = &lt;strong&gt;${letters[i]})&lt;/strong&gt; &lt;span&gt;${opt}&lt;/span&gt;;
btn.onclick = () => selectAnswer(i);
optionsBox.appendChild(btn);
});

startTimer();
}

function startTimer() {
clearInterval(timer);
timeLeft = 20;
updateTimerUI();
timer = setInterval(() => {
timeLeft--;
updateTimerUI();
if (timeLeft <= 0) {
clearInterval(timer);
handleTimeout();
}
}, 1000);
}

function updateTimerUI() {
document.getElementById("timerText").textContent = ⏳ ${timeLeft} ثانية;
const fill = document.getElementById("timerFill");
fill.style.width = ((timeLeft / 20) * 100) + "%";
fill.style.backgroundColor = timeLeft > 10 ? "#10b981" : timeLeft > 5 ? "#f59e0b" : "#ef4444";
}

function handleTimeout() {
if (answered) return;
answered = true;
streak = 0;
hearts = Math.max(0, hearts - 1);
updateStats();
playTone(200, "sawtooth", 0.35);

const qObj = questions[currentIdx];
document.querySelectorAll(".option-btn").forEach((b, i) => {
b.disabled = true;
if (i === qObj.answer) b.classList.add("correct");
});

showFeedback(false, انتهى الوقت! ⏰ الإجابة الصحيحة هي: "${qObj.options[qObj.answer]}". ${qObj.explain});
historyLog.push({ q: qObj.q, ok: false, correct: qObj.options[qObj.answer] });
document.getElementById("nextBtn").classList.remove("hidden");
}

function selectAnswer(idx) {
if (answered) return;
answered = true;
clearInterval(timer);

const qObj = questions[currentIdx];
const btns = document.querySelectorAll(".option-btn");
btns.forEach(b => b.disabled = true);

if (idx === qObj.answer) {
btns[idx].classList.add("correct");
streak++;
const bonus = streak >= 3 ? 5 : 0;
score += 10 + bonus;
playTone(580, "sine", 0.25);
const msg = bonus > 0
? إجابة رائعة! 🎉 (+10 نقاط + ${bonus} مكافأة السلسلة المتتالية) — ${qObj.explain}
: إجابة صحيحة! 👏 (+10 نقاط) — ${qObj.explain};
showFeedback(true, msg);
historyLog.push({ q: qObj.q, ok: true, correct: qObj.options[qObj.answer] });
} else {
btns[idx].classList.add("wrong");
btns[qObj.answer].classList.add("correct");
streak = 0;
hearts = Math.max(0, hearts - 1);
playTone(210, "sawtooth", 0.35);
showFeedback(false, إجابة غير صحيحة! 💡 الصحيح هو: "${qObj.options[qObj.answer]}". ${qObj.explain});
historyLog.push({ q: qObj.q, ok: false, correct: qObj.options[qObj.answer] });
}

updateStats();
document.getElementById("nextBtn").classList.remove("hidden");
}

function showFeedback(isGood, text) {
const fb = document.getElementById("feedbackBox");
fb.className = "feedback-box " + (isGood ? "good" : "bad");
fb.textContent = text;
fb.style.display = "block";
}

function use5050() {
if (used5050 || answered) return;
used5050 = true;
document.getElementById("btn5050").disabled = true;
const qObj = questions[currentIdx];
const btns = Array.from(document.querySelectorAll(".option-btn"));
const wrongIndices = [0, 1, 2, 3].filter(i => i !== qObj.answer).sort(() => Math.random() - 0.5);
btns[wrongIndices[0]].classList.add("hidden-opt");
btns[wrongIndices[1]].classList.add("hidden-opt");
}

function useHint() {
if (usedHint || answered) return;
usedHint = true;
document.getElementById("btnHint").disabled = true;
const hintBox = document.getElementById("hintBox");
hintBox.textContent = "💡 تلميح: " + questions[currentIdx].hint;
hintBox.style.display = "block";
}

function nextQuestion() {
if (hearts === 0 || currentIdx + 1 >= questions.length) endGame();
else { currentIdx++; loadQuestion(); }
}

function endGame() {
clearInterval(timer);
document.getElementById("gameScreen").classList.add("hidden");
document.getElementById("endScreen").classList.remove("hidden");
const correctCount = historyLog.filter(item => item.ok).length;
document.getElementById("finalScore").textContent = score;
document.getElementById("endTitle").textContent =
hearts === 0 ? "انتهت المحاولات! 💪 حاول مجدداً" :
correctCount >= 10 ? "ممتاز يا بطل التجويد! 🏆" : "أداء جميل! 👏 واصل التقدم";
document.getElementById("endSummary").textContent =
أجبت إجابة صحيحة على ${correctCount} من أصل ${historyLog.length} أسئلة.;

const reviewList = document.getElementById("reviewList");
reviewList.innerHTML = "<h3>📋 مراجعة الأسئلة:</h3>";
historyLog.forEach((item, idx) => {
const div = document.createElement("div");
div.className = "review-item" + (item.ok ? "" : " bad-item");
div.innerHTML = &lt;strong&gt;${idx + 1}. ${item.q}&lt;/strong&gt;&lt;br&gt;&lt;span&gt;${item.ok ? "✅ إجابتك صحيحة:" : "❌ الإجابة الصحيحة:"} ${item.correct}&lt;/span&gt;;
reviewList.appendChild(div);
});
}