どっちが大きい?
1️⃣
2️⃣
🎉おめでとう!クリア🎉
```html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🎉数字比較ゲーム🎉</title>
<style>
@keyframes pop {
0% { transform: scale(1); }
50% { transform: scale(1.2); }
100% { transform: scale(1); }
}
@keyframes disappear {
0% { opacity: 1; }
100% { opacity: 0; }
}
</style>
</head>
<body>
<div style="width: 400px; height: 400px; margin: auto; text-align: center; font-size: 24px; position: relative;">
<div id="game-area" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">
<div id="question" style="margin-bottom: 20px; font-weight: bold;">どっちが大きい?</div>
<div style="display: flex; justify-content: space-around;">
<div id="option1" style="width: 45%; background: #ffcccb; padding: 10px; border-radius: 10px; user-select: none; cursor: pointer;" onclick="choose(0)">1️⃣</div>
<div id="option2" style="width: 45%; background: #add8e6; padding: 10px; border-radius: 10px; user-select: none; cursor: pointer;" onclick="choose(1)">2️⃣</div>
</div>
</div>
<div id="overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center;">
🎉おめでとう!クリア🎉
</div>
</div>
<script>
const numbers = [
[Math.PI, 3.14],
[1/2, 0.5],
[Math.sqrt(2), 1.4],
[7/3, 2.3],
[1.2345, 1.23]
];
let currentQuestion = 0;
let correctStreak = 0;
let timer;
function loadQuestion() {
if (correctStreak >= 5) {
document.getElementById('overlay').style.display = 'flex';
document.getElementById('game-area').style.animation = 'disappear 1s forwards';
return;
}
const question = numbers[currentQuestion];
document.getElementById('option1').textContent = question[0];
document.getElementById('option2').textContent = question[1];
timer = setTimeout(() => {
alert('時間切れ!');
resetGame();
}, 15000);
}
function choose(optionIndex) {
clearTimeout(timer);
const question = numbers[currentQuestion];
const correctAnswer = question[0] > question[1] ? 0 : 1;
if (optionIndex === correctAnswer) {
correctStreak++;
document.getElementById('question').textContent = '正解!🎉';
document.getElementById('question').style.animation = 'pop 0.5s';
} else {
document.getElementById('question').textContent = '間違い!😢';
correctStreak = 0;
}
currentQuestion = (currentQuestion + 1) % numbers.length;
setTimeout(() => {
document.getElementById('question').textContent = 'どっちが大きい?';
document.getElementById('question').style.animation = '';
loadQuestion();
}, 1000);
}
function resetGame() {
correctStreak = 0;
currentQuestion = 0;
loadQuestion();
}
loadQuestion();
</script>
</body>
</html>
```