<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Access Verification</title>
    <link rel="stylesheet" href="styles.css">
    <style>
      body {
    background-color: royalblue;
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden; /* Prevents scrolling */
    position: relative; /* Ensures positioning context for absolute elements */
}

.container {
    position: relative; /* Stays in front of the canvas */
    z-index: 1; /* Places it above the canvas */
    background-color: rgba(0, 0, 0, 0.2);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 300px;
    border: 4px solid rgba(0, 0, 0, 0.5);
    color: white;
}

h1 {
    font-size: 26px;
    color: white;
    margin-bottom: 20px;
}

.input-field {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 5px;
    color: whitesmoke;
    border: 2px solid black;
    font-size: 16px;
    background-color: rgba(0, 0, 0, 0.0);
}

input::placeholder {
  color: white;
}

.verify-button, .get-key-button {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    color: #fff;
    background-color: blue;
    border: 2px solid black;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
    margin-top: 10px;
    margin-right: 5px;
}

.verify-button:hover, .get-key-button:hover {
    background-color: Royalblue;
}

.message {
    margin-top: 15px;
    font-size: 16px;
    color: red;
}

.loading-animation {
    width: 40px;
    height: 40px;
    border: 5px solid rgba(255, 255, 255, 0.9);
    border-top: 5px solid #ff6f61;
    border-radius: 50%;
    margin: 20px auto;
    animation: spin 1s linear infinite;
    position: absolute;
    left: 41%;
    top: 40%;
    transform: translate(-50%, -50%);
    z-index: 2; /* In front of the container */
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0; /* Behind all other elements */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
    </style>
</head>
<body>
    <!-- The particle canvas is positioned as the background -->
    <canvas id="particleCanvas"></canvas>
   
    <div class="container">
        <h1>Welcome to Caryon Mods Login</h1>
        <h3><p id="random-number">Your Access number is: </p></h3>
        <input type="text" id="user-key" placeholder="Enter your key" class="input-field">
        <button onclick="verifyKey()" class="verify-button">Verify Key</button>
        <div id="loading" class="loading-animation" style="display:none;"></div>
        <p id="message" class="message"></p>
        <!-- Get Your Key Button -->
        <a href="https://t.me/freehackwithjemsh" target="_blank" class="get-key-button">Get Your Key</a>
    </div>
    
    <script src="script.js"></script>
    <script src="nn.js"></script>
    <script>
      // script.js

// Function to get random number and save it in local storage
window.onload = function() {
    let randomNumber = localStorage.getItem('randomNumber');
    if (!randomNumber) {
        randomNumber = Math.floor(Math.random() * 21); // Generate random number between 0 to 20
        localStorage.setItem('randomNumber', randomNumber);
    }
    document.getElementById('random-number').innerText = "Your Access number is: " + randomNumber;
};

// Function to verify the key entered by the user
function verifyKey() {
    const randomNumber = localStorage.getItem('randomNumber');
    const userKey = document.getElementById('user-key').value;
    const correctKey = getKeyForNumber(randomNumber); // Function to get the correct key for the number
    const loadingElement = document.getElementById('loading');
    const messageElement = document.getElementById('message');

    // Show loading animation
    loadingElement.style.display = 'block';
    messageElement.innerText = '';
    
    setTimeout(() => {
        loadingElement.style.display = 'none'; // Hide loading animation

        // Verify the entered key
        if (userKey === correctKey) {
            messageElement.style.color = 'lightGreen';
            messageElement.innerText = 'Key Verified Successfully!';
            setTimeout(() => {
                window.location.href = 'index.html'; // Redirect to main.html after key verification
            }, 1000); // Wait 1 second before redirecting
        } else {
            messageElement.style.color = 'red';
            messageElement.innerText = 'Incorrect Key. Please try again.';
        }
    }, 1500); // Simulate loading delay of 1.5 seconds
}

// Function to generate the correct key for a given random number
function getKeyForNumber(number) {
    const keys = {
        0: "hy75gj6ji68jy7i6", 
        1: "T9g8J7h6B56ruu67", 
        2: "A3f4S5d6G63yegxh", 
        3: "U7y6T75t7t6tee56", 
        4: "Q2w3E4r5h75jyih6", 
        5: "Z1x2C3v4B75hit76", 
        6: "L3k4J5h6Goyohrfj", 
        7: "H7j8K9l0Zeufitgu", 
        8: "P5o4I3u75duurjju", 
        9: "N0m9B8v7361uwu47", 
        10: "V3b2N1m0828uriyy", 
        11: "F9d8S7a77ruutuiu", 
        12: "D2f3jy6ut678truh", 
        13: "C7v8B9n068425476", 
        14: "E6r5T4y3Uhiyfuuh", 
        15: "G5h6J7kG7JAKGSUU", 
        16: "M9n8BHHFU6585HJG", 
        17: "JEVID", 
        18: "K1l2J3h4G5YI44YI", 
        19: "O9p8I7TIG7866IIT", 
        20: "S0a1D209999DFWIQ"
    };
    return keys[number];
}
    </script>
</body>
</html>