Changed around line 1
+ const questions = document.querySelectorAll('.question');
+ const options = document.querySelectorAll('.options button');
+ const nextBtn = document.querySelector('.next-btn');
+ const progressBar = document.querySelector('.progress');
+ const resultsSection = document.querySelector('.results-section');
+ const resultMeter = document.querySelector('.result-meter');
+ const needle = document.querySelector('.needle');
+ const resultText = document.querySelector('.result-text');
+ const retryBtn = document.querySelector('.retry-btn');
+
+ let currentQuestion = 0;
+ let totalScore = 0;
+
+ options.forEach(option => {
+ option.addEventListener('click', () => {
+ const score = parseInt(option.dataset.score);
+ totalScore += score;
+
+ // Disable all options
+ option.parentElement.querySelectorAll('button').forEach(btn => {
+ btn.disabled = true;
+ });
+
+ // Enable next button
+ nextBtn.disabled = false;
+ });
+ });
+
+ nextBtn.addEventListener('click', () => {
+ if (currentQuestion < questions.length - 1) {
+ questions[currentQuestion].classList.remove('active');
+ currentQuestion++;
+ questions[currentQuestion].classList.add('active');
+
+ // Update progress bar
+ const progress = ((currentQuestion + 1) / questions.length) * 100;
+ progressBar.style.width = `${progress}%`;
+
+ // Disable next button
+ nextBtn.disabled = true;
+ } else {
+ showResults();
+ }
+ });
+
+ function showResults() {
+ document.querySelector('.quiz-section').classList.add('hidden');
+ resultsSection.classList.add('visible');
+
+ const averageScore = totalScore / questions.length;
+ const rotation = (averageScore / 5) * 180 - 90;
+
+ needle.style.transform = `rotate(${rotation}deg)`;
+
+ if (averageScore < 2) {
+ resultText.textContent = "Maybe marriage isn't the right path for you right now.";
+ } else if (averageScore < 4) {
+ resultText.textContent = "You might want to wait and work on some things first.";
+ } else {
+ resultText.textContent = "You're ready! Marriage could be a great choice for you!";
+ }
+ }
+
+ retryBtn.addEventListener('click', () => {
+ location.reload();
+ });