import { useState } from "react";
const questions = [
// ===== EASY (1-10) =====
{
id: 1, level: "easy",
question: "Who discovered the phenomenon of gravitation?",
options: ["Galileo Galilei", "Sir Isaac Newton", "Johannes Kepler", "Albert Einstein"],
answer: 1,
explanation: "Sir Isaac Newton discovered gravitation, famously inspired by observing an apple fall from a tree."
},
{
id: 2, level: "easy",
question: "In which direction does an apple fall from a tree?",
options: ["At an angle to vertical", "Horizontally", "Vertically downward", "Upward"],
answer: 2,
explanation: "The earth attracts the apple towards its centre, which is the vertical direction, so the apple falls vertically downward."
},
{
id: 3, level: "easy",
question: "What is the SI unit of mass?",
options: ["Newton", "Kilogram", "Joule", "Metre"],
answer: 1,
explanation: "The SI unit of mass is kilogram (kg). Mass is a scalar quantity."
},
{
id: 4, level: "easy",
question: "What is the SI unit of weight?",
options: ["Kilogram", "Gram", "Newton", "Pascal"],
answer: 2,
explanation: "Weight is a force, so its SI unit is Newton (N)."
},
{
id: 5, level: "easy",
question: "The weight of an object is defined as:",
options: ["The amount of matter in the object", "The force with which the earth attracts the object", "The volume of the object", "The density of the object"],
answer: 1,
explanation: "Weight is defined as the force with which the earth attracts an object: W = mg."
},
{
id: 6, level: "easy",
question: "What is the approximate value of acceleration due to gravity (g) on the surface of the earth?",
options: ["9.8 m/s²", "6.67 × 10â»Â¹Â¹ m/s²", "11.2 km/s", "3.84 m/s²"],
answer: 0,
explanation: "The standard value of g on the surface of the earth is approximately 9.8 m/s²."
},
{
id: 7, level: "easy",
question: "A force acting on an object moving in a circle, directed towards the centre, is called:",
options: ["Gravitational force", "Frictional force", "Centripetal force", "Normal force"],
answer: 2,
explanation: "'Centripetal' means centre-seeking. The centripetal force is always directed towards the centre of the circular path."
},
{
id: 8, level: "easy",
question: "The value of the Universal Gravitational Constant G in SI units is:",
options: ["9.8 N/kg", "6.673 × 10â»Â¹Â¹ N m² kgâ»Â²", "6 × 10²ⴠN", "3 × 10⸠m/s"],
answer: 1,
explanation: "G = 6.673 × 10â»Â¹Â¹ N m² kgâ»Â², first measured experimentally by Henry Cavendish."
},
{
id: 9, level: "easy",
question: "Which planet-related laws did Kepler formulate?",
options: ["Laws of motion", "Laws of planetary motion", "Laws of thermodynamics", "Laws of reflection"],
answer: 1,
explanation: "Johannes Kepler formulated three laws of planetary motion based on observational data."
},
{
id: 10, level: "easy",
question: "When an object is in free fall, what is its initial velocity?",
options: ["Equal to g", "10 m/s", "Zero", "Equal to escape velocity"],
answer: 2,
explanation: "In free fall, the object starts from rest, so its initial velocity u = 0, and it accelerates under gravity."
},
// ===== MEDIUM (11-30) =====
{
id: 11, level: "medium",
question: "According to Kepler's First Law, the orbit of a planet is:",
options: ["A perfect circle with the Sun at the centre", "An ellipse with the Sun at one focus", "A parabola", "A straight line"],
answer: 1,
explanation: "Kepler's First Law states: The orbit of a planet is an ellipse with the Sun at one of the two foci."
},
{
id: 12, level: "medium",
question: "Kepler's Second Law states that the line joining the planet and the Sun sweeps:",
options: ["Equal distances in equal time", "Equal areas in equal time intervals", "Unequal areas in equal time", "Equal velocities in equal time"],
answer: 1,
explanation: "Kepler's Second Law: The line joining the planet and the Sun sweeps equal areas in equal intervals of time."
},
{
id: 13, level: "medium",
question: "According to Newton's Universal Law of Gravitation, if the distance between two objects is doubled, the gravitational force becomes:",
options: ["Double", "Half", "Four times smaller", "Four times larger"],
answer: 2,
explanation: "F ∠1/d². If d is doubled, F becomes 1/4th (four times smaller)."
},
{
id: 14, level: "medium",
question: "Kepler's Third Law relates the period of revolution T and mean distance r as:",
options: ["T ∠r²", "T² ∠r³", "T³ ∠r²", "T ∠r³"],
answer: 1,
explanation: "Kepler's Third Law: T²/r³ = constant, i.e. T² is directly proportional to r³."
},
{
id: 15, level: "medium",
question: "The gravitational force on Mahendra (75 kg) from Virat (80 kg) sitting 1 m apart is approximately:",
options: ["4.002 × 10â»Â³ N", "4.002 × 10â»â· N", "4.002 × 10â»Â¹Â¹ N", "4.002 × 10â»âµ N"],
answer: 1,
explanation: "F = G×mâ‚×mâ‚‚/r² = 6.67×10â»Â¹Â¹ × 75 × 80 / 1² = 4.002 × 10â»â· N"
},
{
id: 16, level: "medium",
question: "The value of g is highest at which location on Earth?",
options: ["Equator", "Tropics", "Poles", "Mount Everest"],
answer: 2,
explanation: "Earth is flattened at the poles, so the radius is smallest there. Since g = GM/R², g is highest at the poles (9.832 m/s²)."
},
{
id: 17, level: "medium",
question: "A person weighs 750 N on Earth. Their approximate weight on the Moon is:",
options: ["750 N", "350 N", "126.8 N", "4500 N"],
answer: 2,
explanation: "Moon's gravity is about 1/6th of Earth's. Weight on moon ≈ 750 × (3.7)² × (1/81) = 126.8 N."
},
{
id: 18, level: "medium",
question: "During free fall, which equation correctly relates velocity v, acceleration g, and time t (starting from rest)?",
options: ["v = g/t", "v = g + t", "v = gt", "v = g²t"],
answer: 2,
explanation: "For free fall starting from rest (u=0): v = u + gt = gt."
},
{
id: 19, level: "medium",
question: "The escape velocity from Earth's surface is approximately:",
options: ["9.8 km/s", "7.9 km/s", "11.2 km/s", "3.0 km/s"],
answer: 2,
explanation: "Escape velocity = √(2gR) = √(2 × 9.8 × 6.4×10â¶) ≈ 11.2 km/s"
},
{
id: 20, level: "medium",
question: "The gravitational potential energy of an object at the surface of the earth is taken as:",
options: ["Zero", "Positive", "Negative (−GMm/R)", "Infinite"],
answer: 2,
explanation: "Since potential energy is zero at infinity and increases as distance from earth decreases, it is negative at the surface: −GMm/R."
},
{
id: 21, level: "medium",
question: "An iron ball of mass 3 kg is released from 125 m height (g = 10 m/s²). Time to reach the ground is:",
options: ["10 s", "3 s", "25 s", "5 s"],
answer: 3,
explanation: "s = ½gt² → 125 = ½×10×t² → t² = 25 → t = 5 s"
},
{
id: 22, level: "medium",
question: "A stone is thrown vertically upwards. When it is moving upward, the acceleration due to gravity is:",
options: ["Zero", "Positive (upward)", "Negative (downward, opposing motion)", "Equal to escape velocity"],
answer: 2,
explanation: "When thrown upward, g acts downward (opposing motion), so acceleration = −g, reducing the velocity."
},
{
id: 23, level: "medium",
question: "The gravitational force between two objects is directly proportional to:",
options: ["Sum of their masses", "Product of their masses", "Difference of their masses", "Square of their masses"],
answer: 1,
explanation: "Newton's law: F = G×mâ‚×mâ‚‚/d². Force is directly proportional to the product of the two masses."
},
{
id: 24, level: "medium",
question: "The escape velocity on the Moon (M = 7.34×10²² kg, R = 1.74×10ⶠm) is approximately:",
options: ["11.2 km/s", "5.6 km/s", "2.37 km/s", "0.5 km/s"],
answer: 2,
explanation: "v_esc = √(2GM/R) = √(2×6.67×10â»Â¹Â¹Ã—7.34×10²²/1.74×10â¶) ≈ 2.37 km/s"
},
{
id: 25, level: "medium",
question: "Who first experimentally measured the value of G?",
options: ["Isaac Newton", "Johannes Kepler", "Henry Cavendish", "Galileo Galilei"],
answer: 2,
explanation: "The value of G was first experimentally measured by Henry Cavendish."
},
{
id: 26, level: "medium",
question: "The value of g on the Moon is about how much compared to Earth?",
options: ["1/2 of Earth", "1/4 of Earth", "1/6 of Earth", "Equal to Earth"],
answer: 2,
explanation: "The acceleration due to gravity on the Moon is about 1/6th of that on the Earth."
},
{
id: 27, level: "medium",
question: "High and low tides in the ocean are caused by:",
options: ["Earth's rotation alone", "Gravitational force of the Moon", "Solar winds", "Atmospheric pressure changes"],
answer: 1,
explanation: "Tides occur due to the gravitational force exerted by the Moon on Earth's water."
},
{
id: 28, level: "medium",
question: "True free fall is possible only in:",
options: ["Water", "Air at high altitude", "Vacuum", "Dense atmosphere"],
answer: 2,
explanation: "During free fall, air friction and buoyant forces act. True free fall (only gravitational force) is possible only in vacuum."
},
{
id: 29, level: "medium",
question: "If one mass in Newton's law of gravitation is doubled, the force between the objects:",
options: ["Remains the same", "Doubles", "Becomes half", "Becomes four times"],
answer: 1,
explanation: "F ∠mâ‚×mâ‚‚. If one mass doubles, F doubles."
},
{
id: 30, level: "medium",
question: "Einstein predicted the existence of gravitational waves in:",
options: ["1905", "1916", "1945", "1960"],
answer: 1,
explanation: "Einstein predicted the existence of gravitational waves in 1916. They were detected 100 years later."
},
// ===== DIFFICULT (31-50) =====
{
id: 31, level: "difficult",
question: "Newton derived the inverse square law of gravitation using Kepler's Third Law. The centripetal force on a planet in circular orbit is F = mv²/r. Using v = 2πr/T and T²/r³ = K, what is the correct expression for F?",
options: ["F = 4mπ²r/T²", "F = 4mπ²/r²K", "F ∠1/r²", "All of the above are steps leading to F ∠1/r²"],
answer: 3,
explanation: "F = mv²/r = m(2πr/T)²/r = 4mπ²r/T². Using T²=Kr³, F = 4mπ²/(Kr²). Since 4mπ²/K is constant, F ∠1/r²."
},
{
id: 32, level: "difficult",
question: "Using conservation of energy, escape velocity is derived as v_esc = √(2GM/R). This is also equal to:",
options: ["√(g/R)", "√(2gR)", "2g/R", "√(GM/R)"],
answer: 1,
explanation: "Since g = GM/R² on Earth's surface, GM = gR². So 2GM/R = 2gR², and v_esc = √(2gR²/R) = √(2gR)."
},
{
id: 33, level: "difficult",
question: "An object is at a distance 2R from Earth's centre (R = radius). The value of g there compared to surface is:",
options: ["Same as surface", "Half of surface value", "Quarter of surface value", "Double the surface value"],
answer: 2,
explanation: "g = GM/r². At r=2R: g' = GM/(2R)² = GM/4R² = g/4. So g' is one-quarter of the surface value."
},
{
id: 34, level: "difficult",
question: "A planet is at distance 2R from a star with period T. According to Kepler's Third Law, if it moves to distance 2R, the new period is:",
options: ["2T", "4T", "2√2 T", "√8 T"],
answer: 3,
explanation: "T²âˆr³. (T'/T)² = (2R/R)³ = 8. So T'/T = √8 = 2√2. Therefore T' = 2√2·T = √8·T."
},
{
id: 35, level: "difficult",
question: "The gravitational force between Earth (6×10²ⴠkg) and Moon (7.4×10²² kg) at 3.84×10ⵠkm is approximately:",
options: ["2×10²ⰠN", "2×10¹ⵠN", "2×10²ⵠN", "2×10¹ⰠN"],
answer: 0,
explanation: "F = G×M×m/r² = 6.7×10â»Â¹Â¹ × 6×10²ⴠ× 7.4×10²² / (3.84×10â¸)² ≈ 2×10²ⰠN"
},
{
id: 36, level: "difficult",
question: "Why does a heavier object NOT fall faster than a lighter object despite experiencing greater gravitational force?",
options: ["The gravitational force is the same on all objects", "The greater force on a heavier mass is exactly offset by its greater inertia (F=ma → a=g for all)", "Air resistance equalises the fall", "The earth moves towards heavier objects"],
answer: 1,
explanation: "g = F/m = (GMm/R²)/m = GM/R². Mass cancels out, so g is independent of the object's mass. Higher mass → higher force, but also higher inertia."
},
{
id: 37, level: "difficult",
question: "A ball is thrown upward with u = 9 m/s (g = 10 m/s²). What maximum height does it reach?",
options: ["4.05 m", "0.9 m", "81 m", "9 m"],
answer: 0,
explanation: "v² = u² + 2as → 0 = 81 + 2(−10)s → s = 81/20 = 4.05 m"
},
{
id: 38, level: "difficult",
question: "If Earth's mass were doubled and its radius halved, the new value of g on its surface would be:",
options: ["Same as before", "2 times current g", "4 times current g", "8 times current g"],
answer: 3,
explanation: "g = GM/R². New g = G(2M)/(R/2)² = G(2M)/(R²/4) = 8GM/R² = 8g. So g becomes 8 times."
},
{
id: 39, level: "difficult",
question: "Weightlessness in a spacecraft occurs because:",
options: ["There is no gravity in space", "The value of g is zero at that height", "The spacecraft and everything in it are in free fall with the same acceleration", "The mass of astronauts becomes zero"],
answer: 2,
explanation: "Weightlessness is due to free fall. The spacecraft and astronauts fall with the same gravitational acceleration, so there is no relative force between them."
},
{
id: 40, level: "difficult",
question: "An object is thrown vertically upward with velocity u. The time to go up equals time to come down. Using equations of motion, when going up with −g, the time taken is:",
options: ["t = u/2g", "t = 2u/g", "t = u/g", "t = √(2u/g)"],
answer: 2,
explanation: "Going up: v = u − gt = 0 → t = u/g. Coming down from height h = u²/2g with u=0: same time t = u/g. Both are equal."
},
{
id: 41, level: "difficult",
question: "The unit of G (Universal Gravitational Constant) in SI units is Newton m² kgâ»Â². This can be verified because F = Gmâ‚mâ‚‚/d². Rearranging for G gives:",
options: ["G = F·d²/(mâ‚mâ‚‚), units = N·m²/kg²", "G = F·mâ‚mâ‚‚/d², units = N·kg²/m²", "G = F/(mâ‚mâ‚‚d²), units = N/(kg²·m²)", "G = mâ‚mâ‚‚d²/F, units = kg²m²/N"],
answer: 0,
explanation: "G = Fd²/(mâ‚mâ‚‚). Units = [N × m²] / [kg × kg] = N·m²·kgâ»Â². This confirms G is in N m² kgâ»Â²."
},
{
id: 42, level: "difficult",
question: "A ball falls off a table and reaches the ground in 1 s (g = 10 m/s²). The height of the table is:",
options: ["10 m", "20 m", "5 m", "1 m"],
answer: 2,
explanation: "s = ½gt² = ½ × 10 × 1² = 5 m. Speed on reaching ground = gt = 10 × 1 = 10 m/s."
},
{
id: 43, level: "difficult",
question: "The gravitational force between Earth and Sun is 3.5×10²² N, Earth's mass is 6×10²ⴠkg, and distance is 1.5×10¹¹ m. Mass of Sun is approximately:",
options: ["1.96×10³Ⱐkg", "1.96×10²ⵠkg", "3.5×10²² kg", "6×10²ⴠkg"],
answer: 0,
explanation: "M_sun = F×d²/(G×M_earth) = 3.5×10²² × (1.5×10¹¹)² / (6.7×10â»Â¹Â¹ × 6×10²â´) ≈ 1.96×10³Ⱐkg"
},
{
id: 44, level: "difficult",
question: "At the centre of the Earth, why is g = 0?",
options: ["Because r = 0 in g = GM/r², making g infinite", "Because all mass around pulls equally in all directions, net force = 0", "Because temperature is too high", "Because the earth's rotation cancels gravity"],
answer: 1,
explanation: "At the centre, all parts of Earth pull the object equally in all directions. The net gravitational force is zero, hence g = 0."
},
{
id: 45, level: "difficult",
question: "The gravitational potential energy at height h from Earth's surface is −GMm/(R+h). For small h compared to R, this approximates to:",
options: ["−GMm/R (constant)", "mgh (using mgh approximation)", "Zero", "GMm/h"],
answer: 1,
explanation: "For small h, 1/(R+h) ≈ (1/R)(1 − h/R). So PE ≈ −GMm/R + GMmh/R² = constant + mgh. The change in PE is mgh."
},
{
id: 46, level: "difficult",
question: "Planet B has radius twice that of planet A and same surface gravity g. What is the mass of B in terms of mass of A?",
options: ["Same as A", "2 times A", "4 times A", "8 times A"],
answer: 2,
explanation: "g = GM/R². If g is same and R_B = 2R_A: M_B = gR_B²/G = g(2R_A)²/G = 4gR_A²/G = 4M_A."
},
{
id: 47, level: "difficult",
question: "An object thrown vertically upward reaches 500 m height (g = 10 m/s²). Total time to return to Earth is:",
options: ["10 s", "100 s", "20 s", "50 s"],
answer: 2,
explanation: "v² = u² − 2gs → 0 = u² − 2×10×500 → u = 100 m/s. Time up = u/g = 10 s. Total = 20 s."
},
{
id: 48, level: "difficult",
question: "If g suddenly became twice its value, pulling a heavy object along the floor would become twice as difficult because:",
options: ["The object's mass doubles", "The normal force (weight) doubles, increasing friction proportionally", "The gravitational constant G doubles", "The object's velocity doubles"],
answer: 1,
explanation: "Friction force = μN = μmg. If g doubles, normal force N = mg doubles, so friction doubles, making it twice as hard to pull."
},
{
id: 49, level: "difficult",
question: "LIGO (Laser Interferometric Gravitational Wave Observatory) detected gravitational waves from an astronomical source after how many years of Einstein's prediction?",
options: ["50 years", "75 years", "100 years", "25 years"],
answer: 2,
explanation: "Einstein predicted gravitational waves in 1916. LIGO detected them exactly 100 years later, with significant contribution from Indian scientists."
},
{
id: 50, level: "difficult",
question: "The radius of planet A is half the radius of planet B. If mass of A is M_A, what must be the mass of B so that g on B is half the g on A?",
options: ["M_A/2", "M_A", "2M_A", "4M_A"],
answer: 2,
explanation: "g_A = GM_A/R_A², g_B = GM_B/R_B² = GM_B/(2R_A)². For g_B = g_A/2: GM_B/4R_A² = GM_A/2R_A² → M_B = 2M_A."
}
];
const levelColors = {
easy: { bg: "#d1fae5", text: "#065f46", badge: "#10b981" },
medium: { bg: "#fef3c7", text: "#92400e", badge: "#f59e0b" },
difficult: { bg: "#fee2e2", text: "#7f1d1d", badge: "#ef4444" }
};
export default function GravitationQuiz() {
const [currentQ, setCurrentQ] = useState(0);
const [selected, setSelected] = useState(null);
const [showExplanation, setShowExplanation] = useState(false);
const [score, setScore] = useState(0);
const [answers, setAnswers] = useState({});
const [filter, setFilter] = useState("all");
const [quizFinished, setQuizFinished] = useState(false);
const [startScreen, setStartScreen] = useState(true);
const [reviewMode, setReviewMode] = useState(false);
const [reviewIndex, setReviewIndex] = useState(0);
const filtered = filter === "all" ? questions : questions.filter(q => q.level === filter);
const q = reviewMode ? filtered[reviewIndex] : filtered[currentQ];
const total = filtered.length;
const answered = Object.keys(answers).filter(k => filtered.find(q => q.id === parseInt(k))).length;
function handleAnswer(idx) {
if (selected !== null) return;
setSelected(idx);
setShowExplanation(true);
const newAnswers = { ...answers, [q.id]: idx };
setAnswers(newAnswers);
if (idx === q.answer) setScore(s => s + 1);
}
function handleNext() {
if (reviewMode) {
if (reviewIndex < filtered.length - 1) setReviewIndex(i => i + 1);
else setReviewMode(false);
setSelected(answers[filtered[reviewMode ? reviewIndex + 1 : reviewIndex]?.id] ?? null);
setShowExplanation(false);
return;
}
if (currentQ < total - 1) {
setCurrentQ(i => i + 1);
const nextQ = filtered[currentQ + 1];
setSelected(answers[nextQ?.id] ?? null);
setShowExplanation(answers[nextQ?.id] !== undefined);
} else {
setQuizFinished(true);
}
}
function handlePrev() {
if (reviewMode) {
if (reviewIndex > 0) setReviewIndex(i => i - 1);
return;
}
if (currentQ > 0) {
setCurrentQ(i => i - 1);
const prevQ = filtered[currentQ - 1];
setSelected(answers[prevQ?.id] ?? null);
setShowExplanation(answers[prevQ?.id] !== undefined);
}
}
function restart() {
setCurrentQ(0); setSelected(null); setShowExplanation(false);
setScore(0); setAnswers({}); setQuizFinished(false);
setReviewMode(false); setReviewIndex(0);
}
function startQuiz() { setStartScreen(false); }
function changeFilter(f) {
setFilter(f); setCurrentQ(0);
setSelected(null); setShowExplanation(false);
setScore(0); setAnswers({}); setQuizFinished(false);
setReviewMode(false); setReviewIndex(0);
}
const easyScore = questions.filter(q => q.level === "easy" && answers[q.id] === q.answer).length;
const medScore = questions.filter(q => q.level === "medium" && answers[q.id] === q.answer).length;
const hardScore = questions.filter(q => q.level === "difficult" && answers[q.id] === q.answer).length;
const styles = {
app: {
minHeight: "100vh",
background: "linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%)",
fontFamily: "'Georgia', 'Times New Roman', serif",
padding: "20px",
display: "flex",
flexDirection: "column",
alignItems: "center"
},
card: {
background: "rgba(255,255,255,0.05)",
backdropFilter: "blur(20px)",
border: "1px solid rgba(255,255,255,0.15)",
borderRadius: "20px",
padding: "32px",
width: "100%",
maxWidth: "780px",
boxShadow: "0 20px 60px rgba(0,0,0,0.4)"
},
title: {
fontSize: "2.2rem",
fontWeight: "bold",
color: "#fff",
textAlign: "center",
marginBottom: "8px",
letterSpacing: "-0.5px",
textShadow: "0 0 30px rgba(168,130,255,0.5)"
},
subtitle: {
color: "rgba(255,255,255,0.55)",
textAlign: "center",
fontSize: "1rem",
marginBottom: "28px",
fontStyle: "italic"
},
filterRow: {
display: "flex",
gap: "10px",
justifyContent: "center",
marginBottom: "24px",
flexWrap: "wrap"
},
filterBtn: (active, lv) => ({
padding: "8px 18px",
borderRadius: "50px",
border: "2px solid",
borderColor: lv === "easy" ? "#10b981" : lv === "medium" ? "#f59e0b" : lv === "difficult" ? "#ef4444" : "#a78bfa",
background: active ? (lv === "easy" ? "#10b981" : lv === "medium" ? "#f59e0b" : lv === "difficult" ? "#ef4444" : "#a78bfa") : "transparent",
color: active ? "#fff" : (lv === "easy" ? "#10b981" : lv === "medium" ? "#f59e0b" : lv === "difficult" ? "#ef4444" : "#a78bfa"),
fontWeight: "600",
cursor: "pointer",
fontSize: "0.85rem",
transition: "all 0.2s",
letterSpacing: "0.5px"
}),
progressBar: {
height: "6px",
background: "rgba(255,255,255,0.1)",
borderRadius: "99px",
marginBottom: "24px",
overflow: "hidden"
},
progressFill: {
height: "100%",
background: "linear-gradient(90deg, #a78bfa, #60a5fa)",
borderRadius: "99px",
transition: "width 0.4s ease",
width: `${((currentQ + 1) / total) * 100}%`
},
levelBadge: (lv) => ({
display: "inline-block",
padding: "4px 12px",
borderRadius: "50px",
background: levelColors[lv]?.badge || "#6b7280",
color: "#fff",
fontSize: "0.75rem",
fontWeight: "700",
letterSpacing: "1px",
textTransform: "uppercase",
marginBottom: "14px"
}),
qNum: {
color: "rgba(255,255,255,0.45)",
fontSize: "0.85rem",
marginBottom: "8px"
},
question: {
fontSize: "1.15rem",
color: "#fff",
lineHeight: "1.7",
marginBottom: "24px",
fontWeight: "500"
},
optionBtn: (idx, q, selected) => {
let bg = "rgba(255,255,255,0.06)";
let border = "1px solid rgba(255,255,255,0.12)";
let color = "rgba(255,255,255,0.85)";
if (selected !== null) {
if (idx === q.answer) { bg = "rgba(16,185,129,0.2)"; border = "1.5px solid #10b981"; color = "#6ee7b7"; }
else if (idx === selected && selected !== q.answer) { bg = "rgba(239,68,68,0.18)"; border = "1.5px solid #ef4444"; color = "#fca5a5"; }
else { bg = "rgba(255,255,255,0.03)"; color = "rgba(255,255,255,0.4)"; }
}
return {
display: "flex", alignItems: "flex-start", gap: "12px",
width: "100%", textAlign: "left",
background: bg, border, color,
borderRadius: "12px", padding: "14px 18px",
cursor: selected !== null ? "default" : "pointer",
marginBottom: "10px", transition: "all 0.2s",
fontSize: "0.97rem", lineHeight: "1.5"
};
},
optionLabel: {
minWidth: "24px", height: "24px",
borderRadius: "50%",
display: "flex", alignItems: "center", justifyContent: "center",
background: "rgba(255,255,255,0.12)",
fontSize: "0.8rem", fontWeight: "700", flexShrink: 0,
fontFamily: "monospace"
},
explanation: {
background: "rgba(167,139,250,0.1)",
border: "1px solid rgba(167,139,250,0.3)",
borderRadius: "12px", padding: "16px 20px",
color: "#c4b5fd", fontSize: "0.93rem",
lineHeight: "1.65", marginTop: "18px"
},
navRow: {
display: "flex", justifyContent: "space-between",
alignItems: "center", marginTop: "26px", gap: "12px"
},
btn: (variant) => ({
padding: "11px 24px",
borderRadius: "50px",
border: "none",
background: variant === "primary" ? "linear-gradient(90deg, #a78bfa, #60a5fa)" :
variant === "ghost" ? "rgba(255,255,255,0.08)" : "rgba(255,255,255,0.1)",
color: "#fff",
fontWeight: "700",
cursor: "pointer",
fontSize: "0.9rem",
letterSpacing: "0.3px",
transition: "all 0.2s"
}),
scoreCard: {
textAlign: "center"
},
bigScore: {
fontSize: "5rem",
fontWeight: "900",
background: "linear-gradient(90deg, #a78bfa, #60a5fa)",
WebkitBackgroundClip: "text",
WebkitTextFillColor: "transparent",
lineHeight: 1
},
breakdownRow: {
display: "flex", justifyContent: "center", gap: "16px",
marginTop: "20px", flexWrap: "wrap"
},
breakdownCard: (lv) => ({
background: "rgba(255,255,255,0.06)",
border: `1.5px solid ${levelColors[lv].badge}`,
borderRadius: "14px", padding: "14px 20px",
textAlign: "center", minWidth: "100px"
}),
startHero: {
textAlign: "center"
}
};
// START SCREEN
if (startScreen) return (
);
// RESULTS SCREEN
if (quizFinished && !reviewMode) {
const pct = Math.round((score / total) * 100);
const grade = pct >= 90 ? "Excellent! ðŸ†" : pct >= 70 ? "Good Work! 🌟" : pct >= 50 ? "Keep Practising 📚" : "Needs More Study 💡";
return (
);
}
// QUIZ / REVIEW SCREEN
const displayQ = reviewMode ? filtered[reviewIndex] : filtered[currentQ];
const displaySelected = reviewMode ? (answers[displayQ?.id] ?? null) : selected;
const displayShow = reviewMode ? true : showExplanation;
if (!displayQ) return null;
return (
);
}
ðŸª
Gravitation MCQ Quiz
Class 10 Science — Chapter 1
{[["🟢 10 Easy", "easy"], ["🟡 20 Medium", "medium"], ["🔴 20 Difficult", "difficult"]].map(([label, lv]) => (
{label}
))}
50 Multiple Choice Questions covering
Gravitation, Kepler's Laws, Newton's Law,
g, Escape Velocity, Free Fall & more.
Gravitation, Kepler's Laws, Newton's Law,
g, Escape Velocity, Free Fall & more.
{[["all", "All 50"], ["easy", "Easy (10)"], ["medium", "Medium (20)"], ["difficult", "Difficult (20)"]].map(([val, label]) => (
))}
Quiz Complete!
{score}/{total}
{grade}
{pct}% correct
{[["Easy", "easy", easyScore, 10], ["Medium", "medium", medScore, 20], ["Difficult", "difficult", hardScore, 20]].map(([lbl, lv, sc, tot]) => (
))}
{lbl}
{sc}/{tot}
{/* Header */}
{/* Filter Row */}
{!reviewMode &&
{/* Level Badge & Q Number */}
🪠Gravitation Quiz
{reviewMode ? `Review ${reviewIndex+1}/${total}` : `${currentQ+1} / ${total}`}
{[["all","All"], ["easy","Easy"], ["medium","Medium"], ["difficult","Hard"]].map(([val, label]) => (
))}
}
{/* Progress */}
{displayQ.level}
Q{displayQ.id}
{!reviewMode && Score: {score}}
{/* Question */}
{displayQ.question}
{/* Options */}
{["A","B","C","D"].map((letter, idx) => (
))}
{/* Explanation */}
{displayShow && (
💡 Explanation:
{displayQ.explanation}
)}
{/* Nav */}
{!reviewMode && displaySelected === null && (
Select an answer
)}
{(displaySelected !== null || reviewMode) && (
)}