<?php
require_once 'config.php';
header('Content-Type: application/json');

try {
    global $pdo;
    $stmt = $pdo->query("SELECT * FROM games WHERE is_active = 1 ORDER BY display_order ASC");
    $games = $stmt->fetchAll();
    echo json_encode(['success' => true, 'data' => $games]);
} catch (Throwable $e) {
    echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}
?>