<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>parahat.info</title>
    <style>
        body { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; font-family: sans-serif; background: #f4f4f4; }
        .btn { width: 80px; height: 80px; cursor: pointer; border: none; margin: 15px; border-radius: 8px; transition: transform 0.1s; }
        .btn:active { transform: scale(0.95); }
        .game-container { display: flex; flex-wrap: wrap; justify-content: center; }
        .green-text { color: green; }
        .blue-text { color: blue; }
        #message { margin-bottom: 20px; text-align: center; }
    </style>
</head>
<body>
    <div id="message">
        <h2>сайт parahat.info приветствует Вас</h2>
        <p>Вы – это Вы? Нажмите <span class="green-text"><b>зелёную</b></span> кнопку:</p>
    </div>

    <div class="game-container" id="container">
                    <button class="btn" style="background-color: blue;" onclick="check('blue')"></button>
                    <button class="btn" style="background-color: green;" onclick="check('green')"></button>
                    <button class="btn" style="background-color: red;" onclick="check('red')"></button>
            </div>

    <script>
    function passAndGo() {
        // Добавляем флаг прохождения прямо к той странице, на которую заходил пользователь
        var separator = window.location.href.indexOf('?') !== -1 ? '&' : '?';
        window.location.href = window.location.href + separator + "check_passed=1";
    }

    function check(color) {
        if (color === 'green') {
            passAndGo();
        } else {
            document.getElementById('message').innerHTML = 
                "<h2>Вы ошиблись.</h2>" +
                "<p>Нажмите <span class='blue-text'><b>синюю</b></span> кнопку для повторной проверки:</p>";
            
            const container = document.getElementById('container');
            const buttons = Array.from(container.children);
            buttons.sort(() => Math.random() - 0.5);
            buttons.forEach(btn => container.appendChild(btn));
            
            buttons.forEach(btn => {
                const colorVal = btn.style.backgroundColor;
                btn.setAttribute('onclick', `checkSecond('${colorVal}')`);
            });
        }
    }

    function checkSecond(color) {
        if (color === 'blue') {
            passAndGo();
        } else {
            document.body.innerHTML = "<h1>Вы снова ошиблись. До свидания!</h1>";
            setTimeout(() => { window.location.href = 'https://www.google.com'; }, 2000);
        }
    }
    </script>
</body>
</html>
