<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wheel of Fortune Game</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
font-family: Arial, sans-serif;
}
#wheel-container {
position: relative;
width: 300px;
height: 300px;
}
#wheel {
width: 100%;
height: 100%;
border-radius: 50%;
border: 10px solid #333;
position: relative;
transform: rotate(0deg);
transition: transform 4s ease-out;
}
.segment {
position: absolute;
width: 50%;
height: 50%;
background-color: #ddd;
border: 2px solid #fff;
transform-origin: 100% 100%;
}
.segment:nth-child(1) { transform: rotate(0deg); background-color: #ffeb3b; }
.segment:nth-child(2) { transform: rotate(45deg); background-color: #ff9800; }
.segment:nth-child(3) { transform: rotate(90deg); background-color: #f44336; }
.segment:nth-child(4) { transform: rotate(135deg); background-color: #9c27b0; }
.segment:nth-child(5) { transform: rotate(180deg); background-color: #3f51b5; }
.segment:nth-child(6) { transform: rotate(225deg); background-color: #2196f3; }
.segment:nth-child(7) { transform: rotate(270deg); background-color: #4caf50; }
.segment:nth-child(8) { transform: rotate(315deg); background-color: #8bc34a; }
#spin-button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#pointer {
position: absolute;
top: -10px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 20px solid red;
}
</style>
</head>
<body>
<div id="wheel-container">
<div id="wheel">
<div class="segment">Prize 1</div>
<div class="segment">Prize 2</div>
<div class="segment">Prize 3</div>
<div class="segment">Prize 4</div>
<div class="segment">Prize 5</div>
<div class="segment">Prize 6</div>
<div class="segment">Prize 7</div>
<div class="segment">Prize 8</div>
</div>
<div id="pointer"></div>
</div>
<button id="spin-button">Spin the Wheel!</button>
<script>
const wheel = document.getElementById('wheel');
const spinButton = document.getElementById('spin-button');
spinButton.addEventListener('click', () => {
const randomDegree = Math.floor(Math.random() * 3600) + 360; // Rotate up to 10 full turns
wheel.style.transform = `rotate(${randomDegree}deg)`;
});
</script>
</body>
</html>