I replicated the bug. When playing, press ESC, and instead of the menu, you will see your mouse, and after pressing ESC again, you will be taken to the menu, and after pressing resume, your mouse will be captured again. So I assume the problem is with capturing mouse.
Ah ok, thanks for coming back to me on that. That's really helpful and I really appreciate you making the effort to help me out with this :)
I think that might be linked to how the browser handles the game, rather than the game itself, as the first ESC/Click don't get passed to the game to be handled as javascript inputs. They are consumed by the browser to focus/unfocus the iframe containing the HTML/Javascript version of the game. At least that's my understanding of how it is working, happy to be corrected if I'm wrong there though!