import { Game } from './game.js'; import { UI } from './ui.js'; const game = new Game(); const ui = new UI(game); window.__empire = { game, ui }; ui.init(); // Auto-save when the tab is closed or backgrounded. window.addEventListener('beforeunload', () => { if (game.state && !game.state.isOver) game.save(); }); document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden' && game.state && !game.state.isOver) game.save(); });