<?php
session_start();
if (!isset($_SESSION['user'])) {
  header("Location: login.php");
  exit();
}

$user = $_SESSION['user']; // id, username, role
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MainBoard</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>

<div class="container">
  <header class="header">
    <div class="user-info">
      <div class="avatar"><?php echo strtoupper(substr($user['username'], 0, 1)); ?></div>
      <div>
        <h2><?php echo $user['username']; ?> 
          <?php if ($user['role'] === 'admin') echo "👑"; ?>
        </h2>
        <p><?php echo $user['role'] === 'admin' ? "Administrator" : "Player"; ?></p>
      </div>
    </div>

    <div class="btn-group">
      <button onclick="location.href='leaderboard.php'">🏆 Leaderboard</button>
      <button onclick="location.href='logout.php'">🚪 Logout</button>
    </div>
  </header>

  <h1>🎮 Memory Card Game</h1>
  <p>Pilih tingkat kesulitan untuk memulai permainan</p>

  <div class="stage-grid">
    <button class="stage" onclick="window.location.href='gameboard-easy.html'">
      <h3>Easy Mode</h3>
      <p>Grid 3x4 (12 kartu)</p>
    </button>

    <button class>"stage" onclick="selectStage('medium')">
      <h3>Medium Mode</h3>
      <p>Grid 4x4 (16 kartu)</p>
    </button>

    <button class="stage" onclick="selectStage('hard')">
      <h3>Hard Mode</h3>
      <p>Grid 5x4 (20 kartu)</p>
    </button>
    </div>
</div>

