actualy, i think this is a bad behavior:
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
because its assumes that the aspect ratio will always be the same.
old monitors where 4:3, nowadays monitors are 16:9 and if your game is mobile, the user may hold it as landscape or portrait mode, breaking the proportions.