window.MagicBot = {
    socket: null,
    events: new EventTarget(),
    state: {
        coins: 0,
        garden: {},
        inventory: {},
        playerId: null
    },
    // Helper to dispatch events
    emit: (name, detail) => {
        window.MagicBot.events.dispatchEvent(new CustomEvent(name, { detail }));
    },
    // Helper to listen
    on: (name, callback) => {
        window.MagicBot.events.addEventListener(name, (e) => callback(e.detail));
    }
};
console.log('[MagicBot] Core loaded.');
