/* ===== AUDIO FEEDBACK LAYER (RESTORED) ===== */ const AudioCtx = new (window.AudioContext || window.webkitAudioContext)(); function ping(freq=600, dur=0.08, type="sine", vol=0.15){ const o = AudioCtx.createOscillator(); const g = AudioCtx.createGain(); o.type = type; o.frequency.value = freq; o.connect(g); g.connect(AudioCtx.destination); const t = AudioCtx.currentTime; g.gain.value = vol; o.start(t); g.gain.exponentialRampToValueAtTime(0.0001, t + dur); o.stop(t + dur); } /* Required for mobile browsers */ window.addEventListener("click", ()=>AudioCtx.resume(), { once:true }); window.addEventListener("touchstart", ()=>AudioCtx.resume(), { once:true }); d.onclick = () => { ping(760, 0.06, "triangle", 0.18); load(k); }; document.getElementById("assign").onclick = () => { if(!active) return; ping(520, 0.08, "square", 0.18); active.status = "IN_PROGRESS"; BackLayer.seal("MISSION_ASSIGN", active.name); log("Mission initialized"); }; document.getElementById("complete").onclick = () => { if(!active || active.status !== "IN_PROGRESS") { ping(220, 0.08, "square", 0.2); return; } const gain = Math.floor(40 + Math.random()*60); xp += gain; xpEl.textContent = xp; ping(880, 0.12, "sawtooth", 0.22); active.status = "COMPLETE"; BackLayer.seal("MISSION_COMPLETE", {name: active.name, xp: gain}); if(Math.random() > .85) log(BackLayer.drop()); log(`Completed ${active.name} +${gain} XP`); }; document.getElementById("stress").onclick = () => { const lvl = Math.random() > .7 ? "CRITICAL" : "NOMINAL"; ping(lvl === "CRITICAL" ? 200 : 420, 0.09, "square", 0.2); BackLayer.seal("STRESS", lvl); log(`Stress level: ${lvl}`); }; document.getElementById("hint").onclick = () => { if(!active) return; ping(600, 0.08, "sine", 0.15); log(`Hint: ${active.hint}`); };