<div style="margin-top: 10px">

<style>
.slotarea {
    height: 800px;
    overflow:auto;
    width: 100%; 
    display: grid; 
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 40px;
}

.gameitem {
    padding: 6px;
    text-align: center;
}

.gameitem img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 5px;
}

.gameitem p {
    margin-top: 8px;
    font-size: 14px;
    color: #fff;
}

.play-btn {
    margin-top: 5px;
    padding: 5px 10px;
    background-color: #f90;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #000;
    font-weight: bold;
}
.play-btn:hover {
    background-color: #ffb84d;
}

@media only screen and (max-width: 500px) {
    .slotarea {
        grid-template-columns: repeat(2, 1fr); /* 2 kolom di mobile */
        height: auto; /* biar menyesuaikan konten */
    }
}
</style>



<h2 style="margin-bottom:20px;">Pragmatic Play</h2>

<div class="slotarea" style="display:flex; flex-wrap:wrap; gap:15px;">
<?php
// ====================
// Pastikan koneksi ada
// ====================
if (!isset($conn)) {
    $servername = "localhost"; // ganti sesuai server
    $username = "kopeoctc";     // ganti sesuai username
    $password = "dodokgagah12";     // ganti sesuai password
    $database = "kopeoctc_4d";     // ganti sesuai nama database

    $conn = mysqli_connect($servername, $username, $password, $database);
    if (!$conn) {
        die("Koneksi gagal: " . mysqli_connect_error());
    }
}

// ====================
// Tampilkan game Pragmatic Play saja
// ====================
$provider = 'PRAGMATIC';

$sql = "SELECT * FROM tb_game 
        WHERE UPPER(provider_code) = UPPER('$provider') 
        AND status = 1 
        ORDER BY id ASC";

$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo '<div class="gameitem">';
        echo '<img src="'.$row['banner'].'" alt="'.htmlspecialchars($row['game_name']).'" />';
        echo '<p>'.htmlspecialchars($row['game_name']).'</p>';
        echo '<button class="play-btn" onclick="playGame(\''.htmlspecialchars($row['game_code']).'\')">Main</button>';
        echo '</div>';
    }
} else {
    echo "<p style='text-align:center; color:#fff;'>⚠️ Tidak ada game Pragmatic Play.</p>";
}
?>
</div>

<script>
function playGame(gameCode) {
    alert("Mainkan game: " + gameCode);
    // Tambahkan logika membuka game sebenarnya di sini
}
</script>


</div>