import { useState, useEffect } from "react"; export default function Home() { const [score, setScore] = useState(0); const [timeLeft, setTimeLeft] = useState(30); const [target, setTarget] = useState({ top: "50%", left: "50%" }); const [gameOver, setGameOver] = useState(false); // Countdown timer useEffect(() => { if (timeLeft <= 0) { setGameOver(true); return; } const timer = setTimeout(() => setTimeLeft(timeLeft - 1), 1000); return () => clearTimeout(timer); }, [timeLeft]); // Move target when clicked const handleClick = () => { if (gameOver) return; setScore(score + 1); const top = Math.floor(Math.random() * 90) + "%"; const left = Math.floor(Math.random() * 90) + "%"; setTarget({ top, left }); }; return (

🎯 Click the Target!

Time Left: {timeLeft}s

Score: {score}

{!gameOver ? (
) : (
Game Over! Final Score: {score}
)}
); }