nt.body.style.overflow = 'auto';
            // Stop any playing media
            const mediaContent = modal.querySelector('video, audio');
            if (mediaContent) {
                mediaContent.pause();
                mediaContent.src = ''; // Detach source
            }
        }

        if (modal && modalCloseButton) {
            modalCloseButton.onclick = closeModal;

            modal.onclick = function(event) {
                if (event.target === modal) {
                    c