<?php
// Start the session
session_start();

// Check if the user is logged in
if (!isset($_SESSION['paid_key'])) {
    header("Location: index.html");
    exit();
}

// Fetch session data
$game_mode = $_SESSION['game_mode'];
$game_version = $_SESSION['game_version'];
$paid_key = $_SESSION['paid_key'];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard</title>
    <style>
        /* Base Reset */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Background and Container Styles */
        body {
            background: url('bg.jpg') no-repeat center center/cover;
            position: relative;
            height: 100vh;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Arial', sans-serif;
        }

        #particles-js {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 1;
        }

        .container {
            position: relative;
            z-index: 2;
            background: rgba(0, 0, 0, 0.7);
            padding: 30px 40px;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
            width: 90%;
            max-width: 500px;
            text-align: center;
        }

        .container h1 {
            font-size: 20px;
            margin-bottom: 20px;
            text-transform: uppercase;
            letter-spacing: 3px;
            color: #ffffff;
            animation: glowText 2s infinite;
        }

        @keyframes glowText {
            0%, 100% { text-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff; }
            50% { text-shadow: 0 0 20px #ffffff, 0 0 40px #ffffff; }
        }

        .info-box {
            background-color: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.5);
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 10px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            font-size: 12px;
        }

        .info-box i {
            margin-right: 8px;
        }

        .info-box p {
            font-size: 12px;
            color: #fff;
        }

        .button {
            width: 100%;
            padding: 10px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(90deg, #00f7ff, #0077ff);
            color: white;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            margin-top: 20px;
            transition: all 0.3s ease;
            text-shadow: 0px 0px 10px #00f7ff, 0px 0px 20px #0077ff;
        }

        .button:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(0, 255, 255, 0.6);
        }

    </style>
</head>
<body>
    <div id="particles-js"></div>

    <div class="container">
        <h1>Welcome, <?php echo htmlspecialchars($user['username']); ?></h1>
        
        <!-- License Key, Game Mode, and Game Version -->
        <div class="info-box">
            <i class="fas fa-key"></i> 
            <p><strong>License Key:</strong> <?php echo $paid_key; ?></p>
        </div>
        
        <div class="info-box">
            <i class="fas fa-gamepad"></i>
            <p><strong>Game Mode:</strong> <?php echo $game_mode; ?></p>
        </div>
        
        <div class="info-box">
            <i class="fas fa-cogs"></i>
            <p><strong>Game Version:</strong> <?php echo $game_version; ?></p>
        </div>

        <!-- Open Game Button -->
        <a href="game.php" target="_blank"><button class="button">OPEN GAME</button></a>
    </div>

    <!-- Script to Load Particles.js -->
    <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js"></script>  <!-- Font Awesome Icons -->
    <script>
        particlesJS('particles-js', {
            particles: {
                number: { value: 50, density: { enable: true, value_area: 800 } },
                color: { value: "#808080" },
                shape: { type: "circle", stroke: { width: 1, color: "#d3d3d3" } },
                opacity: { value: 0.5 },
                size: { value: 3 },
                move: { enable: true, speed: 1 }
            },
            interactivity: {
                events: {
                    onhover: { enable: true, mode: "repulse" },
                    onclick: { enable: true, mode: "push" }
                },
                modes: { repulse: { distance: 100 } }
            },
            retina_detect: true
        });
    </script>
</body>
<html>