${fmt(Math.floor(cps()))}/спассив
`; async function loadTop(){try{ function tick(){const now=Date.now();const dt=Math.min(5,(now-lastTick)/1000);lastTick=now;
$('#setPart').onclick=()=>{S.particles=!S.particles;save();refreshSettings();document.body.classList.toggle('noparticles',!S.particles);};
${S.stats.casino||0}игр в казино
${SKINS.map((s,i)=>{const un=s.c(S); if(now-lastPush>15000){lastPush=now;push();}
👥 Топ игроков
function openSettings(){refreshSettings();$('#ovlSet').classList.add('on');} $$('.skin').forEach(el=>el.onclick=()=>{const i=+el.dataset.s;if(SKINS[i].c(S)){S.skin=i;save();renderHeader();renderMe();sfx(760,.08)}else toast('Скин ещё закрыт 🔒')}); /* ================= НАСТРОЙКИ ================= */ $('#startBtn').onclick=()=>{S.name=($('#nameInput').value.trim()||'Хомяк').slice(0,20); const rk=['🥇','🥈','🥉']; $$('#gameSeg button').forEach(b=>b.onclick=()=>{ else S.energy=Math.min(maxEn(),S.energy+regEn()*dt); } $('#hbtn').addEventListener('contextmenu',e=>e.preventDefault()); setInterval(tick,100); d.style.animationDuration=(13+Math.random()*14)+'s';d.style.animationDelay=(-Math.random()*20)+'s';
Лига: ${L.n}
👑
🪙 ${fmt(p.earned)}
`).join(''):'
Пока никого нет — будь первым!
'; /* ================= ЦИКЛ ================= */ $$('nav button').forEach(b=>b.onclick=()=>{ $('#wSpin').onclick=spinWheel; const esc=s=>s.replace(/[<>&"]/g,c=>({'<':'<','>':'>','&':'&','"':'"'}[c])); if(now{S.sound=!S.sound;save();refreshSettings();$('#sndBtn').textContent=S.sound?'🔊':'';}; $('#tapzone').style.display=(b.dataset.t==='games')?'none':'';
Сервер: ${serverOk?'🟢 онлайн, топ общий':'🔴 офлайн, играем локально'}. Прогресс хранится на твоём устройстве.
sfx(500,.04);});
${fmt(S.taps)}тапов
$$('#seg1 button,#seg2 button').forEach(b=>b.onclick=()=>{buyMode=b.dataset.m;
${expedTotal()}походов
$('#nickSave').onclick=()=>{const v=$('#nickIn').value.trim()||'Хомяк';S.name=v.slice(0,20);save();push();renderHeader();renderMe();toast('Ник сохранён ✔')}; const r=await fetch(SERVER_URL+'/api/top',{cache:'no-store'}); checkDay();
$('#setReset').onclick=()=>{if(confirm('Точно сбросить ВЕСЬ прогресс?')){if(confirm('Последний шанс! Уверен?')){localStorage.removeItem(LS_KEY);location.reload()}}}; return `
if(dirty&&Math.random()<.05)save();}
Загрузка…
loadTop();} function refreshSettings(){[['#setSound',S.sound],['#setVibra',S.vibra],['#setPart',S.particles]].forEach(([sel,v])=>{ S.seenIntro=true;$('#ovlIntro').classList.remove('on');save();renderHeader();showDailyModal();}; $('#topList').innerHTML=list.length?list.map((p,i)=>`
$$('#gameSeg button').forEach(x=>x.classList.remove('on'));b.classList.add('on'); tradeTick(); catch(e){serverOk=false;$('#topList').innerHTML='
Сервер недоступен — топ появится после подключения.
'; $('#sndBtn').onclick=()=>{S.sound=!S.sound;$('#sndBtn').textContent=S.sound?'🔊':'';save();}; setInterval(()=>{if(dirty)save()},10000); $('#bgfx').appendChild(d);}})();
${nxt?`До лиги «${nxt.n}»: ${fmt(nxt.t-S.earned)}`:'Максимальная лига!'}
Перерождение · сейчас ×${mult().toFixed(1)}
serverOk=true;$('#dot').classList.add('on'); let lastTick=Date.now(),lastPush=0; $$('nav button').forEach(x=>x.classList.remove('on'));b.classList.add('on'); $('#wClose').onclick=()=>$('#ovlWheel').classList.remove('on'); function payload(){return JSON.stringify({name:S.name,earned:S.earned,rebirth:S.rebirth,league:leagueIdx()})} d.style.left=Math.random()*100+'vw';d.style.fontSize=(12+Math.random()*14)+'px'; if(b.dataset.g==='trade')drawTrade(); $('#setVibra').onclick=()=>{S.vibra=!S.vibra;save();refreshSettings();}; ({shop:renderShop,biz:renderBiz,exped:renderExped,boost:renderBoosts,games:renderGames,tasks:renderTasks,me:renderMe})[b.dataset.t]();
$('#hbtn').addEventListener('pointerdown',e=>{e.preventDefault();doTap(e.clientX,e.clientY);});
${fmt(S.earned)}заработано
$$('#seg1 button,#seg2 button').forEach(x=>x.classList.toggle('on',x.dataset.m===buyMode));renderShop();renderBiz();});
${S.stats.trades||0}сделок
$('#rebBtn').onclick=()=>{if(S.earned>=req)openRebirth()}; const list=await r.json(); const c=cps();if(c>0)addCoins(c*dt);
🎭 Скины
$('#setClose').onclick=()=>$('#ovlSet').classList.remove('on');
🔗 Скинь брату
${un?s.e:'❓'}
${s.n}
${s.d}
`;}).join('')}
📊 Статистика
/* ================= ТАБЫ / СОБЫТИЯ ================= */ function updCan(){$$('.buy[data-cost]').forEach(b=>{b.classList.toggle('can',S.coins>=+b.dataset.cost)})} const b=$(sel);if(!b)return;b.textContent=v?'ВКЛ':'ВЫКЛ';b.classList.toggle('on',v);});}
${rk[i]||i+1}
${esc(p.name)} ${'⭐'.repeat(Math.min(p.rebirth||0,5))}
$$('#p-games .game').forEach(g=>g.style.display='none'); const oc=$('#onlineCount');if(oc)oc.classList.remove('on');}} $('#gearBtn').onclick=openSettings;
🏆
Нужно ${fmt(req)} заработанного · у тебя ${fmt(S.earned)}
const oc=$('#onlineCount');if(oc&&list.length>0){oc.textContent='🟢 '+list.length;oc.classList.add('on');} $$('.panel').forEach(p=>p.classList.remove('on'));$('#p-'+b.dataset.t).classList.add('on'); async function push(){try{await fetch(SERVER_URL+'/api/push',{method:'POST',headers:{'Content-Type':'application/json'},body:payload()}); if(b.dataset.g==='plinko')drawPlinko(performance.now()); sfx(500,.04);});
(function(){const em=['🪙','✨','🌻','⭐'];for(let i=0;i<14;i++){const d=document.createElement('div'); /* ================= СТАРТ ================= */ load(); initAssets(); if(S.trade.active&&Date.now()>=S.trade.end)resolveTrade(); checkDay(); (function init(){ const now=Date.now();const away=(now-(S.last||now))/1000; const capH=4+2*S.rebirth;const c=cps(); let offGain=0; if(S.seenIntro&&away>60&&c>0){offGain=Math.floor(c*Math.min(away,capH*3600));addCoins(offGain);} if(S.seenIntro)S.energy=Math.min(maxEn(),S.energy+regEn()*Math.min(away,3600)); $('#sndBtn').textContent=S.sound?'🔊':''; document.body.classList.toggle('noparticles',S.particles===false); renderHeader();renderHUD();renderShop(); if(!S.seenIntro){$('#ovlIntro').classList.add('on');} else{ if(offGain>0){$('#offTxt').textContent=`Твои бизнесы работали ${Math.floor(away/60)} мин (лимит офлайн-дохода: ${capH} ч, растёт с перерождениями).`; $('#offCoins').textContent='+'+fmt(offGain);$('#ovlOff').classList.add('on'); $('#offBtn').onclick=()=>{$('#ovlOff').classList.remove('on');if(S.daily.last!==dateStr())showDailyModal();};} else if(S.daily.last!==dateStr())showDailyModal();} if(S.exped.id!==null){const def=EXPED.find(e=>e.id===S.exped.id); if(def&&(Date.now()-S.exped.start)/1000>=def.dur)toast('🗺 Поход завершён! Забери награду');} scheduleGolden(); push(); })(); addEventListener('visibilitychange',()=>{if(document.hidden)save();else lastTick=Date.now();}); addEventListener('pagehide',()=>{save();try{navigator.sendBeacon(SERVER_URL+'/api/push',payload())}catch(e){}}); addEventListener('beforeunload',()=>{save();}); addEventListener('freeze',()=>{save();});