(()=>{'use strict';const canvas=document.getElementById('confetti'),ctx=canvas.getContext('2d'),start=document.getElementById('startButton'),encore=document.getElementById('encoreButton'),rapButton=document.getElementById('rapButton'),toast=document.getElementById('toast'),liveText=document.getElementById('liveText'),reduced=matchMedia('(prefers-reduced-motion: reduce)'),colors=['#ef2b2d','#f6ff00','#ffffff','#080808','#59c7ff'];let pieces=[],frame=null,toastTimer=null,rapTimer=null; function resize(){const d=Math.min(devicePixelRatio||1,2);canvas.width=innerWidth*d;canvas.height=innerHeight*d;canvas.style.width=innerWidth+'px';canvas.style.height=innerHeight+'px';ctx.setTransform(d,0,0,d,0,0)} function piece(x,y,i){const a=-Math.PI*.9+(i%50)/49*Math.PI*.8,s=7+Math.random()*14;return{x,y,vx:Math.cos(a)*s+(Math.random()-.5)*5,vy:Math.sin(a)*s-Math.random()*5,g:.18+Math.random()*.14,d:.988,r:Math.random()*6.28,spin:(Math.random()-.5)*.3,size:6+Math.random()*12,color:colors[i%colors.length],life:160+Math.random()*80,shape:i%3}} function burst(x=innerWidth/2,y=innerHeight*.7){if(reduced.matches)return;for(let i=0;i<220;i++)pieces.push(piece(x,y,i));if(!frame)animate()} function animate(){ctx.clearRect(0,0,innerWidth,innerHeight);pieces=pieces.filter(p=>p.life>0&&p.y{p.vx*=p.d;p.vy=p.vy*p.d+p.g;p.x+=p.vx;p.y+=p.vy;p.r+=p.spin;p.life--;ctx.save();ctx.translate(p.x,p.y);ctx.rotate(p.r);ctx.fillStyle=p.color;ctx.strokeStyle='#080808';ctx.lineWidth=1;if(p.shape===0){ctx.fillRect(-p.size/2,-p.size/4,p.size,p.size/2);ctx.strokeRect(-p.size/2,-p.size/4,p.size,p.size/2)}else if(p.shape===1){ctx.beginPath();ctx.moveTo(0,-p.size/2);ctx.lineTo(p.size/2,p.size/2);ctx.lineTo(-p.size/2,p.size/2);ctx.closePath();ctx.fill();ctx.stroke()}else{ctx.fillRect(-p.size/3,-p.size/2,p.size*.66,p.size)}ctx.restore()});if(pieces.length)frame=requestAnimationFrame(animate);else{frame=null;ctx.clearRect(0,0,innerWidth,innerHeight)}} function count(){document.querySelectorAll('[data-count]').forEach(el=>{const target=+el.dataset.count;if(+el.textContent===target)return;let v=0,step=Math.max(1,Math.ceil(target/55));function tick(){v=Math.min(target,v+step);el.textContent=v;if(vtoast.classList.remove('visible'),3200)} function launch(e){document.body.classList.add('started');liveText.textContent='TIESIOGINIS ETERIS';start.querySelector('span').textContent='ŠVENTĖ PALEISTA!';const r=e?.currentTarget?.getBoundingClientRect();burst(r?r.left+r.width/2:innerWidth/2,r?r.top:innerHeight*.7);count();showToast()} function rap(){clearInterval(rapTimer);const lines=[...document.querySelectorAll('#rapText span')];lines.forEach(x=>x.classList.remove('active'));let i=0;const next=()=>{if(i{rap();const r=e.currentTarget.getBoundingClientRect();burst(r.left+r.width/2,r.top)});addEventListener('resize',resize,{passive:true});resize();const observer=new IntersectionObserver(entries=>{if(entries.some(x=>x.isIntersecting)){count();observer.disconnect()}},{threshold:.3});observer.observe(document.querySelector('.numbers'));})();