<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mini App with Glowing Ring</title>
    <link href="https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-image: url('background.jpg');
            background-size: cover;
            font-family: 'Rubik', sans-serif;
            color: white;
            text-align: center;
            overflow: hidden;
        }

        .circle-button {
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background-color: #1f2e72;
            border: 3px solid #00ffd5;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            color: white;
            cursor: pointer;
            margin-bottom: 20px;
            position: absolute;
            opacity: 0; /* Initially hidden */
            transition: opacity 0.6s ease-out;
            box-shadow: 0 0 20px rgba(0, 255, 213, 0.8), 0 0 10px #00ffd5;
            animation: glowRing 2s linear infinite; /* Glowing effect */
        }

        .number {
            font-size: 48px;
            transition: opacity 0.5s ease-in-out;
            opacity: 1;
        }

        .signal-button, .play-button {
            width: 220px;
            padding: 10px;
            margin: 10px 0;
            border: none;
            border-radius: 30px;
            font-size: 20px;
            background-color: #6c52f5;
            color: white;
            cursor: pointer;
            transition: transform 0.3s, background-color 0.3s, box-shadow 0.3s;
            box-shadow: 0 0 20px rgba(108, 82, 245, 0.7), 0 0 10px #6c52f5;
        }

        .signal-button:hover, .play-button:hover {
            transform: scale(1.05);
            background-color: #4a3bbb;
            box-shadow: 0 0 30px rgba(74, 59, 187, 0.9), 0 0 15px #4a3bbb;
        }

        .notification {
            display: none;
            margin-top: 20px;
            font-size: 18px;
            background-color: rgba(108, 82, 245, 0.9);
            color: white;
            padding: 10px;
            border-radius: 5px;
            position: absolute;
            opacity: 0;
            transition: opacity 0.5s ease-in-out;
        }

        img {
            max-width: 100%;
            height: auto;
            transition: transform 0.6s ease-out;
        }

        .button-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            z-index: 1;
            transition: transform 0.6s ease-out;
        }

        .moved-down {
            transform: translateY(225px); /* Move buttons down */
        }

        .logo-move-up {
            transform: translateY(-75px); /* Move logo up */
        }

        .loading-bar {
            width: 220px; /* Match width of signal button */
            height: 5px; /* Thin bar */
            background-color: #444;
            margin-top: 40px;
            border-radius: 5px;
            opacity: 0; /* Initially hidden */
            transition: opacity 0.5s ease-out;
        }

        .loading-progress {
            height: 100%;
            width: 0;
            background-color: #00ffd5;
            border-radius: 5px;
            transition: width 1s linear;
        }

        .countdown {
            margin-top: 10px;
            font-size: 24px;
            color: #00ffd5;
            opacity: 0;
            transition: opacity 0.5s ease-in-out;
        }

        /* Glowing ring animation */
        @keyframes glowRing {
            0% {
                box-shadow: 0 0 20px rgba(0, 255, 213, 0), 0 0 40px rgba(0, 255, 213, 0);
            }
            25% {
                box-shadow: 0 0 20px rgba(0, 255, 213, 0.5), 0 0 40px rgba(0, 255, 213, 0.5);
            }
            50% {
                box-shadow: 0 0 20px rgba(0, 255, 213, 0.8), 0 0 60px rgba(0, 255, 213, 0.8);
            }
            75% {
                box-shadow: 0 0 30px rgba(0, 255, 213, 1), 0 0 80px rgba(0, 255, 213, 1);
            }
            100% {
                box-shadow: 0 0 20px rgba(0, 255, 213, 0), 0 0 40px rgba(0, 255, 213, 0);
            }
        }
    </style>
</head>
<body>
    <img src="lucky-jet.svg" alt="Lucky Jet" style="width: 300px; margin-bottom: 20px;" id="logo">
    <div class="button-container" id="buttonContainer">
        <button class="signal-button" id="signalButton" onclick="generateSignal()">ПОЛУЧИТЬ СИГНАЛ</button>
        <button class="play-button" onclick="window.location.href='https://example.com'">ИГРА ТУТ</button>
    </div>
    <div class="circle-button" id="signalCircle">
        <div class="number" id="numberDisplay"></div>
    </div>
    <div class="notification" id="notification">Раунд ещё не закончился</div>
    <div class="notification" id="newRoundNotification">Новый раунд скоро начнётся</div>

    <div class="loading-bar" id="loadingBar">
        <div class="loading-progress" id="loadingProgress"></div>
    </div>
    <div class="countdown" id="countdownDisplay"></div>

    <audio id="notificationSound" src="Notify.mp3" preload="auto"></audio>

    <script>
        let isGenerating = false;
        let cooldownTime = 0;
        let lastCoefficient = null;
        let countdownInterval;

        function generateSignal() {
            if (isGenerating) {
                showNotification('notification');
                return;
            }

            // Move logo up
            const logo = document.getElementById('logo');
            logo.classList.add('logo-move-up'); // Move the logo up

            // Move buttons down
            const buttonContainer = document.getElementById('buttonContainer');
            buttonContainer.classList.add('moved-down');

            // Show the circle button after delay
            const signalCircle = document.getElementById('signalCircle');
            setTimeout(() => {
                signalCircle.style.opacity = '1'; // Make the circle appear after the buttons move
            }, 600);

            // Show loading bar
            const loadingBar = document.getElementById('loadingBar');
            loadingBar.style.opacity = '1'; // Make loading bar visible
            const loadingProgress = document.getElementById('loadingProgress');
            const countdownDisplay = document.getElementById('countdownDisplay');
            countdownDisplay.style.opacity = '1';

            isGenerating = true;
            const numberDisplay = document.getElementById('numberDisplay');
            const min = 1.5;
            const max = 5.0;
            let coefficient;

            do {
                coefficient = (Math.random() * (max - min) + min).toFixed(2);
            } while (coefficient === lastCoefficient);

            lastCoefficient = coefficient;
            numberDisplay.style.opacity = '0';

            setTimeout(() => {
                numberDisplay.textContent = 'x' + coefficient;
                numberDisplay.style.opacity = '1';

                cooldownTime = 60; // Set to 60 seconds

                let timeLeft = cooldownTime;
                countdownDisplay.textContent = timeLeft + " секунд";

                countdownInterval = setInterval(() => {
                    timeLeft--;
                    countdownDisplay.textContent = timeLeft + " секунд";
                    loadingProgress.style.width = ((cooldownTime - timeLeft) / cooldownTime) * 100 + "%";

                    if (timeLeft <= 0) {
                        clearInterval(countdownInterval);
                        showNotification('newRoundNotification');
                        playNotificationSound();

                        // Reset after cooldown
                        setTimeout(() => {
                            isGenerating = false;
                            loadingBar.style.opacity = '0'; // Hide loading bar
                            countdownDisplay.style.opacity = '0';
                        }, 500);
                    }
                }, 1000);
            }, 500);
        }

        function showNotification(notificationId) {
            const notification = document.getElementById(notificationId);
            notification.style.display = 'block';
            notification.style.opacity = '1';
            setTimeout(() => {
                notification.style.opacity = '0';
                setTimeout(() => {
                    notification.style.display = 'none';
                }, 500);
            }, 2000);
        }

        function playNotificationSound() {
            const notificationSound = document.getElementById('notificationSound');
            notificationSound.play();
        }
    </script>
</body>
</html>
