Changed around line 1
+ const ball = document.querySelector('.ball');
+ const player1Score = document.querySelector('.player-score span');
+ const player2Score = document.querySelector('.player-score:nth-child(2) span');
+ const kickLeft = document.getElementById('kick-left');
+ const kickRight = document.getElementById('kick-right');
+ const quizContainer = document.querySelector('.quiz-container');
+ const questionElement = document.querySelector('.question');
+ const optionsElement = document.querySelector('.options');
+ const nextButton = document.querySelector('.next-button');
+
+ let player1 = 0;
+ let player2 = 0;
+ let currentQuestion = 0;
+
+ const questions = [
+ {
+ question: "Which country won the 2018 FIFA World Cup?",
+ options: ["Brazil", "Germany", "France", "Spain"],
+ answer: "France"
+ },
+ {
+ question: "Who is the all-time top scorer in the UEFA Champions League?",
+ options: ["Lionel Messi", "Cristiano Ronaldo", "Raul", "Robert Lewandowski"],
+ answer: "Cristiano Ronaldo"
+ },
+ {
+ question: "Which club has won the most UEFA Champions League titles?",
+ options: ["Real Madrid", "Barcelona", "Bayern Munich", "AC Milan"],
+ answer: "Real Madrid"
+ }
+ ];
+
+ function moveBall(direction) {
+ ball.style.transition = 'all 0.5s ease';
+ if (direction === 'left') {
+ ball.style.left = '10%';
+ setTimeout(() => {
+ if (Math.random() > 0.5) {
+ player1++;
+ player1Score.textContent = player1;
+ }
+ resetBall();
+ }, 500);
+ } else {
+ ball.style.left = '90%';
+ setTimeout(() => {
+ if (Math.random() > 0.5) {
+ player2++;
+ player2Score.textContent = player2;
+ }
+ resetBall();
+ }, 500);
+ }
+ }
+
+ function resetBall() {
+ ball.style.transition = 'none';
+ ball.style.left = '50%';
+ }
+
+ function showQuiz() {
+ quizContainer.style.display = 'block';
+ loadQuestion();
+ }
+
+ function loadQuestion() {
+ const currentQuiz = questions[currentQuestion];
+ questionElement.textContent = currentQuiz.question;
+ optionsElement.innerHTML = '';
+ currentQuiz.options.forEach(option => {
+ const button = document.createElement('button');
+ button.textContent = option;
+ button.addEventListener('click', () => selectAnswer(option));
+ optionsElement.appendChild(button);
+ });
+ }
+
+ function selectAnswer(selected) {
+ const currentQuiz = questions[currentQuestion];
+ if (selected === currentQuiz.answer) {
+ alert('Correct!');
+ } else {
+ alert('Wrong!');
+ }
+ }
+
+ nextButton.addEventListener('click', () => {
+ currentQuestion++;
+ if (currentQuestion < questions.length) {
+ loadQuestion();
+ } else {
+ alert('Quiz completed!');
+ quizContainer.style.display = 'none';
+ }
+ });
+
+ kickLeft.addEventListener('click', () => moveBall('left'));
+ kickRight.addEventListener('click', () => moveBall('right'));
+
+ setTimeout(() => {
+ if (player1 < player2) {
+ showQuiz();
+ }
+ }, 30000); // Show quiz after 30 seconds