As expected, this doesn't work with non-standard browser window sizes and is butchered on mobile in horizontal mode.

But since the original implementation is also broken, I guess that's OK?

We really have a low bar for quality these days. I hope this won't be used anywhere that's relevant.