
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Lucky Spin Casino</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #5a0e0e;
            color: #fff;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background-image: url('https://images.unsplash.com/photo-1568430462989-44163eb1752f?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
            background-size: cover;
            background-position: center;
            background-blend-mode: overlay;
        }

        .container {
            background-color: rgba(90, 14, 14, 0.95);
            border-radius: 15px;
            padding: 25px;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
            width: 100%;
            max-width: 500px;
            border: 3px solid #ffd700;
            position: relative;
        }

        h1 {
            color: #ffd700;
            text-align: center;
            margin: 0 0 20px 0;
            font-size: 2rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
        }

        .info-box {
            background-color: rgba(139, 0, 0, 0.7);
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 15px;
            text-align: center;
            font-size: 1.1rem;
            border: 2px solid #ffd700;
            width: calc(100% - 28px);
        }

        .info-box span {
            color: #ffd700;
            font-weight: bold;
        }

        .wheel-container {
            position: relative;
            width: 280px;
            height: 280px;
            margin: 0 auto 20px;
        }

        .wheel {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            position: relative;
            overflow: hidden;
            border: 5px solid #ffd700;
            box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
            transition: transform 3s cubic-bezier(0.17, 0.67, 0.12, 0.99);
            background-color: #000;
        }

        .wheel-section {
            position: absolute;
            width: 50%;
            height: 50%;
            transform-origin: bottom right;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.75rem;
            color: #fff;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
        }

        .pointer {
            position: absolute;
            top: -15px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 15px solid transparent;
            border-right: 15px solid transparent;
            border-top: 30px solid #ff0000;
            z-index: 10;
            filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.7));
        }

        .bet-controls {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 15px;
        }

        .bet-amount {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .bet-amount input {
            width: 60%;
            padding: 10px;
            border-radius: 5px;
            border: 2px solid #ffd700;
            background-color: rgba(139, 0, 0, 0.7);
            color: #fff;
            font-size: 1rem;
        }

        .bet-buttons {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .bet-btn {
            padding: 8px 10px;
            border: none;
            border-radius: 5px;
            background-color: #ff0000;
            color: #ffd700;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 0.85rem;
            flex: 1;
            min-width: 50px;
            text-align: center;
        }

        .bet-btn:hover {
            background-color: #ff3333;
            transform: translateY(-2px);
        }

        .bet-btn:active {
            transform: translateY(0);
        }

        .place-bet {
            background-color: #ff0000;
            color: #ffd700;
            padding: 12px;
            border: none;
            border-radius: 5px;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            width: 100%;
            border: 2px solid #ffd700;
        }

        .place-bet:hover {
            background-color: #ff3333;
            transform: translateY(-2px);
        }

        .place-bet:disabled {
            background-color: #7f8c8d;
            cursor: not-allowed;
            transform: none;
        }

        .result {
            text-align: center;
            font-size: 1.1rem;
            margin: 15px 0;
            min-height: 40px;
            color: #ffd700;
            font-weight: bold;
            padding: 10px;
            background-color: rgba(139, 0, 0, 0.7);
            border-radius: 5px;
            border: 1px solid #ffd700;
        }

        .history {
            display: flex;
            gap: 6px;
            justify-content: center;
            margin-top: 15px;
            flex-wrap: wrap;
        }

        .history-item {
            background-color: rgba(139, 0, 0, 0.7);
            border: 1px solid #ffd700;
            border-radius: 50%;
            width: 25px;
            height: 25px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.7rem;
            color: #ffd700;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        .pulse {
            animation: pulse 0.5s infinite;
        }

        .game-phase {
            text-align: center;
            margin-bottom: 10px;
            font-size: 1rem;
            color: #ffd700;
            font-weight: bold;
            height: 20px;
        }

        .section-title {
            color: #ffd700;
            margin: 15px 0 8px 0;
            font-size: 1rem;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Lucky Spin Casino</h1>
        
        <div class="info-box">
            Balance: <span id="balance">1000.00</span> Rs
        </div>
        
        <div class="game-phase" id="gamePhase">Place your bets!</div>
        
        <div class="info-box">
            Time left: <span id="timer">25</span> seconds
        </div>
        
        <div class="wheel-container">
            <div class="pointer"></div>
            <div class="wheel" id="wheel"></div>
        </div>
        
        <div class="result" id="result"></div>
        
        <div class="section-title">Place Your Bet</div>
        <div class="bet-controls">
            <div class="bet-amount">
                <input type="number" id="betAmount" placeholder="Enter bet amount" min="0.01" step="0.01">
            </div>
            
            <div class="bet-buttons">
                <button class="bet-btn" data-amount="10">10</button>
                <button class="bet-btn" data-amount="50">50</button>
                <button class="bet-btn" data-amount="100">100</button>
                <button class="bet-btn" data-amount="500">500</button>
                <button class="bet-btn" data-amount="1000">1000</button>
            </div>
            
            <button class="place-bet" id="placeBet">Place Bet</button>
        </div>
        
        <div class="section-title">Recent Results</div>
        <div class="history" id="history"></div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Game state
            const multipliers = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 50, 100];
            const colors = [
                '#e74c3c', '#c0392b', '#d35400', '#e67e22', 
                '#f39c12', '#f1c40f', '#2ecc71', '#27ae60', 
                '#1abc9c', '#16a085', '#3498db', '#2980b9', 
                '#9b59b6', '#8e44ad', '#34495e', '#2c3e50',
                '#e74c3c', '#c0392b', '#d35400', '#e67e22'
            ];
            
            let balance = 1000.00;
            let currentBet = 0;
            let gamePhase = 'betting'; // 'betting' or 'result'
            let timeLeft = 25;
            let timer;
            let spinTimeout;
            let history = [];
            
            // DOM elements
            const balanceElement = document.getElementById('balance');
            const wheelElement = document.getElementById('wheel');
            const timerElement = document.getElementById('timer');
            const betAmountElement = document.getElementById('betAmount');
            const placeBetButton = document.getElementById('placeBet');
            const resultElement = document.getElementById('result');
            const historyElement = document.getElementById('history');
            const gamePhaseElement = document.getElementById('gamePhase');
            
            // Initialize the wheel with equal-sized sections
            function initWheel() {
                wheelElement.innerHTML = '';
                const sectionAngle = 360 / multipliers.length;
                
                multipliers.forEach((multiplier, index) => {
                    const section = document.createElement('div');
                    section.className = 'wheel-section';
                    section.style.backgroundColor = colors[index];
                    section.style.transform = `rotate(${index * sectionAngle}deg)`;
                    
                    const innerText = document.createElement('div');
                    innerText.style.transform = `rotate(${sectionAngle / 2}deg)`;
                    innerText.textContent = `${multiplier}x`;
                    innerText.style.width = '100%';
                    innerText.style.textAlign = 'center';
                    section.appendChild(innerText);
                    
                    wheelElement.appendChild(section);
                });
            }
            
            // Update timer display
            function updateTimer() {
                timerElement.textContent = timeLeft;
                
                if (gamePhase === 'betting') {
                    gamePhaseElement.textContent = 'Place your bets!';
                    placeBetButton.disabled = false;
                } else {
                    gamePhaseElement.textContent = 'Spinning...';
                    placeBetButton.disabled = true;
                }
            }
            
            // Start the game timer
            function startTimer() {
                clearInterval(timer);
                timer = setInterval(updateGameTimer, 1000);
            }
            
            function updateGameTimer() {
                timeLeft--;
                updateTimer();
                
                if (timeLeft <= 0) {
                    if (gamePhase === 'betting') {
                        // Switch to result phase
                        gamePhase = 'result';
                        timeLeft = 5;
                        spinWheel();
                    } else {
                        // Switch back to betting phase
                        gamePhase = 'betting';
                        timeLeft = 25;
                        resultElement.textContent = '';
                        currentBet = 0;
                        betAmountElement.value = '';
                    }
                }
            }
            
            // Spin the wheel
            function spinWheel() {
                // Deduct the bet if one was placed
                if (currentBet > 0 && currentBet <= balance) {
                    balance = parseFloat((balance - currentBet).toFixed(2));
                    updateBalance();
                }
                
                // Randomly select a multiplier
                const randomIndex = Math.floor(Math.random() * multipliers.length);
                const selectedMultiplier = multipliers[randomIndex];
                
                // Calculate spin rotation (multiple full rotations plus the selected section)
                const sectionAngle = 360 / multipliers.length;
                const targetAngle = 360 * 5 + (360 - (randomIndex * sectionAngle + sectionAngle / 2));
                
                // Apply spin animation
                wheelElement.style.transform = `rotate(${targetAngle}deg)`;
                
                // Show result after spin completes
                clearTimeout(spinTimeout);
                spinTimeout = setTimeout(() => {
                    if (currentBet > 0 && currentBet <= balance) {
                        const winningAmount = parseFloat((currentBet * selectedMultiplier).toFixed(2));
                        
                        // Add winnings to balance
                        balance = parseFloat((balance + winningAmount).toFixed(2));
                        updateBalance();
                        
                        // Display result
                        if (selectedMultiplier < 1) {
                            resultElement.textContent = `You lost ${(currentBet - winningAmount).toFixed(2)} Rs (${selectedMultiplier}x)`;
                        } else if (selectedMultiplier === 1) {
                            resultElement.textContent = `You got your ${currentBet.toFixed(2)} Rs back`;
                        } else {
                            resultElement.textContent = `You won ${winningAmount.toFixed(2)} Rs (${selectedMultiplier}x)`;
                            resultElement.classList.add('pulse');
                            setTimeout(() => {
                                resultElement.classList.remove('pulse');
                            }, 2000);
                        }
                    } else {
                        // Show the result even if no bet was placed
                        resultElement.textContent = `Landed on ${selectedMultiplier}x`;
                        if (selectedMultiplier > 1) {
                            resultElement.classList.add('pulse');
                            setTimeout(() => {
                                resultElement.classList.remove('pulse');
                            }, 2000);
                        }
                    }
                    
                    // Add to history
                    addToHistory(selectedMultiplier);
                }, 3000);
            }
            
            // Update balance display
            function updateBalance() {
                balanceElement.textContent = balance.toFixed(2);
            }
            
            // Add result to history
            function addToHistory(multiplier) {
                history.unshift(multiplier);
                if (history.length > 12) history.pop();
                
                historyElement.innerHTML = '';
                history.forEach((item, index) => {
                    const historyItem = document.createElement('div');
                    historyItem.className = 'history-item';
                    historyItem.textContent = `${item}x`;
                    historyItem.style.backgroundColor = colors[multipliers.indexOf(item)];
                    historyElement.appendChild(historyItem);
                });
            }
            
            // Event listeners
            document.querySelectorAll('.bet-btn').forEach(button => {
                button.addEventListener('click', function() {
                    const amount = parseFloat(this.getAttribute('data-amount'));
                    betAmountElement.value = amount.toFixed(2);
                });
            });
            
            placeBetButton.addEventListener('click', function() {
                const betAmount = parseFloat(betAmountElement.value);
                
                if (isNaN(betAmount) || betAmount <= 0) {
                    alert('Please enter a valid bet amount greater than 0');
                    return;
                }
                
                if (betAmount > balance) {
                    alert('You don\'t have enough balance');
                    return;
                }
                
                currentBet = parseFloat(betAmount.toFixed(2));
                alert(`Bet placed: ${currentBet.toFixed(2)} Rs`);
            });
            
            // Initialize the game
            initWheel();
            updateTimer();
            startTimer();
        });
    </script>
</body>
</html>