async function signup() {
    const username = document.getElementById("username").value;
    const password = document.getElementById("password").value;
  
    const res = await fetch("/api/signup", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ username, password })
    });
  
    const data = await res.json();
  
    if (res.ok) {
      document.getElementById("message").textContent = "登録完了！ログインしてください。";
    } else {
      document.getElementById("message").textContent = data.error || "登録失敗";
    }
  }
  