export function setupHUD(root) { root.innerHTML = `
`; const panel = root.firstElementChild; const zoom = panel.querySelector('#hud-zoom'); zoom.addEventListener('input', () => { const z = parseFloat(zoom.value); window.setGameZoom?.(z); }); panel.querySelector('#hud-inv').onclick = () => { window.InventoryUI?.toggle(); }; panel.querySelector('#hud-craft').onclick = () => { window.CraftingUI?.toggle(); }; panel.querySelector('#hud-logout').onclick = async () => { await fetch('/api/logout', { method: 'POST' }); location.reload(); }; // functions for other modules to update XP window.updateXP = level => { const label = panel.querySelector('#xplabel'); label.textContent = `Lvl ${level}`; const fill = panel.querySelector('#xpfill'); const pct = Math.min(100, level); // dumb visual fill.style.width = `${pct}%`; }; }