<?php
session_start();

// Cek apakah user sudah login
if (!isset($_SESSION['users'])) {
    header("Location: login.php");
    exit;
}
?>
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="GameStyle.css" />
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Coral+Pixels&family=Jacquarda+Bastarda+9&family=Pixelify+Sans:wght@400..700&display=swap"
      rel="stylesheet"
    />
  </head>
  <body>
    <!-- header -->
    <header>
      <div class="centered">
        <div class="icon"></div>
        <h1>Snake - <?php echo htmlspecialchars($_SESSION['users']['nama']); ?></h1>
      </div>
    </header>

    <!-- main konten -->
    <div class="HalamanFull">
      <canvas width="1056" height="480" id="game"></canvas>
      <div id="gameover-overlay" class="starting" style="display: none">
        <div class="popAwal">
          <h1 style="color: red" id="gameover-title">YOU DIED</h1>
          <p id="gameover-score">Score: 0</p>
          <button id="ulangi" class="modegame">Main lagi?</button>
          <a href="index.php">
            <button id="keluar" class="">Keluar?</button>
          </a>
        </div>
      </div>
      <div id="gameover" class="gameover"></div>
      <div id="start" class="starting">
        <div class="popAwal">
          <h1>Start Game?</h1>
          <p>Silakan Pilih Mode</p>
          <button id="mode-normal" class="modegame">Normal</button>
          <button id="mode-tambahan" class="modegame">Normal++</button>
        </div>
      </div>
      <div>
        <div id="text" class="text"></div>
      </div>
    </div>

    <!-- footer -->
    <footer class="centered">
      <div class="centered">
        <p></p>
      </div>
    </footer>
    <!-- akhir html body -->
    <script src="GameLogic.js"></script>
  </body>
</html>