// Boot — set up scaling/input, wait for fonts, wire HTML controls.
window.BootScene = class BootScene extends Phaser.Scene {
  constructor() { super('Boot'); }

  create() {
    // Cap pixelRatio at 1 for locked 60fps (never 2).
    this.scale.setGameSize(window.GAME.WIDTH, window.GAME.HEIGHT);

    // Unlock audio on the very first user gesture (pointer or key).
    const unlock = () => window.Audio.unlock();
    this.input.once('pointerdown', unlock);
    this.input.keyboard.once('keydown', unlock);

    // Wire the HTML control cluster (mute / restart) to the game once.
    if (window.UI && window.UI.wireControls) window.UI.wireControls(this.game);

    // Reflect the document title into the stage header + Phaser title.
    if (window.UI && window.UI.setStageTitle) window.UI.setStageTitle(window.GAME.TITLE);

    // Wait for the design-system fonts so they render inside the canvas,
    // then start. Falls through immediately if the API is unavailable.
    const ready = window.__fontsReady || Promise.resolve();
    ready.then(() => this.scene.start('Preload'));
  }
};
