How should I prevent duplicate animation loops and input listeners when restarting a small HTML canvas brick-breaker game? Give a minimal lifecycle pattern, list the game state that must reset, and provide four checks that expose restart bugs. Do not produce a complete game or claim the pattern has been run.
Four restart checks: Restart ten times, then press Left once: paddle movement must be identical to a fresh load. Compare ball speed after each restart: it must not accelerate from multiple loops. Pause/restart during active power-ups: no old timer may alter the new game. Lose the final life, restart, then verify score, brick count, lives, and key state all match a new round. These are recommended lifecycle checks, not tested behavior.


