export default class GameOver extends Phaser.Scene {
    constructor() {
        super({ key: 'GameOver' });
    }

    init(data) {
        this.level = data.level || 1;
    }

    create() {
        const cx = 800, cy = 450;

        this.add.text(cx, 340, 'GAME OVER', {
            fontSize: '96px', fontFamily: 'monospace',
            color: '#ff0000', stroke: '#550000', strokeThickness: 6,
        }).setOrigin(0.5);

        this.add.text(cx, 470, `You reached Level ${this.level}`, {
            fontSize: '36px', fontFamily: 'monospace', color: '#aaaaaa',
        }).setOrigin(0.5);

        const prompt = this.add.text(cx, 580, 'PRESS SPACE OR CLICK TO RESTART', {
            fontSize: '28px', fontFamily: 'monospace', color: '#ffffff',
        }).setOrigin(0.5);

        this.tweens.add({ targets: prompt, alpha: 0, duration: 600, yoyo: true, repeat: -1 });

        this.input.keyboard.once('keydown-SPACE', () => this.scene.start('MainMenu'));
        this.input.once('pointerdown', () => this.scene.start('MainMenu'));
    }
}
