// Tab navigation and initialization controller. document.addEventListener("DOMContentLoaded", () => { const tabs = document.querySelectorAll(".tab-btn"); const panels = document.querySelectorAll(".tab-panel"); tabs.forEach(btn => { btn.addEventListener("click", () => { const target = btn.dataset.tab; tabs.forEach(t => t.classList.remove("active")); panels.forEach(p => p.classList.remove("active")); btn.classList.add("active"); document.getElementById("tab-" + target).classList.add("active"); // Lazy-init on first access if (target === "browser" && typeof initViewer === "function") { initViewer(); } if (target === "leaderboard" && typeof initLeaderboard === "function") { initLeaderboard(); } }); }); // Initialize leaderboard on page load if (typeof initLeaderboard === "function") { initLeaderboard(); } });