(()=>{
const css=`#sandbar{position:fixed;top:8px;right:8px;z-index:99999;display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;font:13px system-ui}
#sandbar a,#sandbar button{background:rgba(10,16,32,.85);color:#f3e2b3;border:1px solid #c9a75d;border-radius:20px;padding:6px 11px;text-decoration:none;cursor:pointer;font:inherit}
#sandbar button.on{background:#c9a75d;color:#05070d}`;
const st=document.createElement('style');st.textContent=css;document.head.appendChild(st);
const bar=document.createElement('div');bar.id='sandbar';
bar.innerHTML=`β
One Listπ GhostπΈοΈ Spideyβ¬οΈ JumpπͺοΈ Stormπ Ganttπ» Drop`;
document.body.appendChild(bar);
const btn=document.getElementById('sandbtn');
let ctx,master,timer=null,step=0;
const BPM=96,S=60/BPM/2;
const hook=[62,0,69,66,0,64,62,0, 69,0,71,69,66,0,64,0, 62,0,69,66,0,64,66,0, 69,71,74,0,71,69,66,0];
const bass=[38,38,0,38,45,0,45,0, 43,43,0,43,40,0,40,0];
const f=m=>440*Math.pow(2,(m-69)/12);
function note(m,t,d,type,vol){const o=ctx.createOscillator(),g=ctx.createGain();o.type=type;o.frequency.value=f(m);
g.gain.setValueAtTime(0,t);g.gain.linearRampToValueAtTime(vol,t+.01);g.gain.exponentialRampToValueAtTime(.0001,t+d);o.connect(g).connect(master);o.start(t);o.stop(t+d+.05)}
function noise(sec){const b=ctx.createBuffer(1,ctx.sampleRate*sec,ctx.sampleRate),d=b.getChannelData(0);for(let i=0;i{e.stopPropagation();timer?stop():play()};
if(localStorage.sand!=='off'){
try{play();if(ctx.state!=='running'){clearInterval(timer);timer=null;btn.textContent='βΆ SAND';btn.classList.remove('on')}}catch(e){}
const unlock=()=>{if(localStorage.sand!=='off'&&!(timer&&ctx&&ctx.state==='running'))play();
['pointerdown','touchstart','keydown','scroll','wheel'].forEach(ev=>removeEventListener(ev,unlock,true))};
['pointerdown','touchstart','keydown','scroll','wheel'].forEach(ev=>addEventListener(ev,unlock,{capture:true,passive:true}));
}
})();