Undo is limited to three per run
Every run gives you exactly three undos, and the button shows how many you have left before greying out at zero. Only moves that actually changed the board can be undone - a move into a wall that shifted nothing costs you nothing.
The count survives a page reload, so refreshing is not a way to top it back up. Starting a new run is what refills it. This matters more than it sounds: the temptation is to burn all three early recovering from small mistakes, which leaves nothing for the position that actually decides the run.
You can also undo out of a finished game. If the board fills and you still have an undo in hand, stepping back one move sometimes reveals a merge you missed, so it is worth checking before accepting the loss.