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

// CAMBIO CLAVE: Añadimos 'google_id' a la consulta para que los enlaces funcionen
$sql = "SELECT google_id, name, picture_url, custom_pic, xp FROM users ORDER BY xp DESC LIMIT 5";
$result = $conn->query($sql);
$ranking = [];

if ($result) {
    while($row = $result->fetch_assoc()) {
        $ranking[] = $row;
    }
}

echo json_encode($ranking);
$conn->close();
?>
