Programming the game to rewind time seems simple, but it's more like programming a game that runs backwards like in the movie Tenet (there's not enough memory to store everything on the screen for every previous moment, so you have to reconstruct what happened from the limited data you have).
Anyway, I'm just testing the undo routine right now, which is why I used the easiest way to implement it in the game. I'll use a different approach later.