Overlays don't compete with a z-index: the browser's top layer puts them above everything, inside any scroll area or card.
ModalDialogs and alert dialogs – native <dialog> with showModal(); the page behind is locked and inert
top layer + ::backdrop
OverlaysMenus, popovers, tooltips, hover cards, pickers – the popover attribute; nothing on the page can cut them off
top layer
ToastsFixed to a corner of the window, above the page and below an open dialog
position: fixed
Inside a componentSticky heads, line numbers, a dragged thumb – small steps that never leave the item
z-index: 1–6
PageEverything else – no z-index at all
auto