document.addEventListener('DOMContentLoaded', () => { const form = document.getElementById('register-form'); if (!form) return; form.addEventListener('submit', async (e) => { e.preventDefault(); const username = document.getElementById('username').value; const password = document.getElementById('password').value; try { await api.post('/auth/register', { username, password }); window.location.href = '/create-hero.html'; } catch (_) { // Error already shown via api() } }); });