function completeHabit(habitId) {
    fetch("../api/habits.php", {
        method: "POST",
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
        body: "habit_id=" + habitId
    })
    .then(res => res.json())
    .then(data => {
        if (data.success) {
            alert(
                data.champion + " earned " + data.xp + " XP!"
            );

            // Remove or fade out the habit card
            document.getElementById("habit-" + habitId).style.opacity = 0.4;
        } else {
            alert("Error: " + data.error);
        }
    });
}