      id: QUIZ_ID,
      answers: answers,
      _csrf: CSRF
    });

    showQuizResults(res);
  } catch(e) {
    showToast('Error submitting quiz: ' + e.message, 'error');
    document.getElementById('btnSubmit').disabled = false;
    document.getElementById('btnSubmit').textContent = 'Submit Answers';
  }
}

function showQuizResults(res) {
  // Show feedback on each question
  res.details.forEach(detail => {
