The `<dialog>` element is now supported everywhere. Using it would considerably simplify the code. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog