y {
        mediaStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
        localVideo.srcObject = mediaStream;
        permissionScreen.style.display = 'none';
        showNotification('Camera & Mic access granted! Starting chat...');
        startChat();
    } catch(e) {
        showNotification('Error accessing camera/mic');
        console.error(e);
    }
}

function takePicture() {
    if(!mediaStream) return;
    const canvas = document.createElement('canvas');
    canva