Corrected z-index calculation