{
/* ---------- iPhone: Web Audio is muted by the silent switch unless the page asks for "playback" audio ---------- */
let AC=null,silentEl=null,master=null;
function iosUnlock(){
try{if(navigator.audioSession&&navigator.audioSession.type!=='playback')navigator.audioSession.type='playback';}catch(e){}
if(!('audioSession' in navigator)){
try{
if(!silentEl){silentEl=new Audio('audio/silence.mp3');silentEl.loop=true;silentEl.setAttribute('playsinline','');}
const p=silentEl.play();if(p&&p.catch)p.catch(()=>{});
}catch(e){}
}
}
function wake(){
iosUnlock();
if(AC&&AC.state!=='running'){try{const p=AC.resume();if(p&&p.catch)p.catch(()=>{});}catch(e){}}
}
['pointerdown','touchend','click','keydown'].forEach(ev=>document.addEventListener(ev,wake,{passive:true,capture:true}));
document.addEventListener('visibilitychange',()=>{if(!document.hidden)wake();});
function initAudio(){
iosUnlock();
if(AC){wake();return;}
try{AC=new(window.AudioContext||window.webkitAudioContext)();try{AC.resume();}catch(e){}
audioGraph();
}catch(e){AC=null;}
}
window.__audio=()=>AC;window.__iosUnlock=iosUnlock;
/* ---------- inline looks: data-s is applied through the style object, so no inline style attributes are needed ---------- */
const applyS=root=>{if(root.nodeType!==1)return;const list=root.matches&&root.matches('[data-s]')?[root,...root.querySelectorAll('[data-s]')]:root.querySelectorAll('[data-s]');for(const el of list){el.style.cssText=el.getAttribute('data-s');el.removeAttribute('data-s');}};
new MutationObserver(ms=>{for(const m of ms)for(const n of m.addedNodes)applyS(n);}).observe(document.documentElement,{childList:true,subtree:true});
const SITE_LINKS='All games · How it was made';
/* ---------- state and saving ---------- */
let muted=false;
const KEY='iack-v1';
const fresh=()=>({school:{},lvl:0,unlocked:1,stars:{},swords:[],inv:{fruit:0,muffin:0,donut:0,pretzel:0},points:0,hero:'Nova'});
let P=fresh();
try{const s=JSON.parse(localStorage.getItem(KEY)||'null');if(s&&s.unlocked)P=Object.assign(fresh(),s);muted=localStorage.getItem(KEY+'m')==='1';}catch(e){}
function save(){try{localStorage.setItem(KEY,JSON.stringify(P));localStorage.setItem(KEY+'m',muted?'1':'0');}catch(e){}}
/* ---------- sounds: soft synth (sine and triangle only, gentle attack, low-pass), quieter while the voice talks ---------- */
let fxBus=null;
function audioGraph(){
const comp=AC.createDynamicsCompressor();comp.threshold.value=-18;comp.ratio.value=4;comp.connect(AC.destination);
master=AC.createGain();master.gain.value=muted?0:1;master.connect(comp);
const lp=AC.createBiquadFilter();lp.type='lowpass';lp.frequency.value=2800;lp.Q.value=.3;lp.connect(master);
fxBus=AC.createGain();fxBus.gain.value=.32;fxBus.connect(lp);
}
let musBus=null,musT=0,musStep=0,musOn=true;
function duck(on){if(!fxBus)return;try{fxBus.gain.setTargetAtTime(on?.1:.32,AC.currentTime,.05);if(musBus)musBus.gain.setTargetAtTime(on?.035:.09,AC.currentTime,.12);}catch(e){}}
/* a cheerful 8-bar tune in C major (bells over a soft bass), scheduled a little ahead */
const TUNE=[[523,659],[0,784],[659,0],[784,880],[880,0],[784,659],[659,0],[523,0],[587,698],[0,784],[698,0],[880,784],[784,0],[698,587],[659,0],[0,0]];
const BASS=[131,0,196,0,175,0,196,0,147,0,196,0,131,0,196,0];
function music(){
if(!AC||!fxBus)return;
if(!musBus){musBus=AC.createGain();musBus.gain.value=.09;const lp=AC.createBiquadFilter();lp.type='lowpass';lp.frequency.value=2200;musBus.connect(lp);lp.connect(master);musT=AC.currentTime+.2;}
const beat=60/112/2;
while(musT Created and directed by two young players ${SITE_LINKS} Read the clock. Win light sabers. Knock out silly villains. Collect snacks from the chocolate river. Player 2 plays as ${sel==='Nova'?'Blaze':'Nova'}. ${coop?'Take turns reading the clock, then fight side by side. Team points!':'Take turns. Most points wins!'} Start in Clock School! Six short games teach the hour and the minutes with light sabers. Every hour is a mission. Tap a number! Progress saves on this device. Tap Restart at the top to start over. Read the clock to get your light saber. The minutes pick your challenge!Clock Knockout
No sound? Turn the volume up with the side buttons and tap the screen once. It plays even when an iPhone is on silent.
Game controller (PS5 and others): D-pad or left stick moves, ✕ picks, ✕ is POW in battles, Options goes to the map. A second controller is player 2.${n===1?'Pick your hero':'Player 1, pick your hero'}
New to clocks?
The Clock World
Mission ${H}: ${m.name}
${m.intro}Mission ${H}
${turnHTML()}${dotsHTML()}Light saber unlocked!
${swordSVG(SW[H-1][1]).replace('
Minute ${G.q.m} → ${CH[ch]}
`,[['Fight!','',go]]); }else{ modal(`Minute ${G.q.m} picked this challenge.
${ch==='super'?'SUPER POWER: every hit counts double!
':''}`,[['Go!','',go]]); } } function battle(kind){ clearT(); const H=G.H,m=M[H-1],boss=kind==='boss',sup=kind==='super'; let hp=4+Math.floor(H/3)+(boss?3:0)+(G.coop?4:0);const max=hp;let hits=0,over=false;const dmg=(sup?2:1)+P.lvl; app.innerHTML=`Tap POW or tap the villain as fast as you can!
`; if(sup||P.lvl)$('#heroA').classList.add('glowp'); speak(rnd(m.lines)); const ar=$('#ar'),vil=$('#vil'),hero=$('#heroA'); const strike=e=>{ if(over)return;hits++; hero.classList.remove('lunge');void hero.getBoundingClientRect();hero.classList.add('lunge'); if(!sup&&hits%4===0&&Math.random()<.6){SFX.block();pop('BLOCKED!',e);$('#vb').textContent=rnd(m.lines);return;} SFX.pow();hp-=dmg;vil.classList.remove('hit');void vil.getBoundingClientRect();vil.classList.add('hit'); pop(rnd(POWS),e);$('#hpb').style.width=Math.max(0,hp/max*100)+'%'; if(hits%3===0)$('#vb').textContent=rnd(m.lines); if(hp<=0){over=true;vil.classList.remove('hit');vil.classList.add('ko');SFX.ko();$('#vb').textContent=m.ko;talk(T.knockout,m.ko); $('#hit').textContent='KNOCKOUT!';if($('#hit2'))$('#hit2').textContent='KNOCKOUT!';G.pl[G.turn].pts+=50;P.points+=50;const f=boss?3:1;P.inv.fruit+=f;save(); later(()=>roundDone(`KNOCKOUT! +50 points and ${f} fruit${f>1?'s':''}.`),1700);} }; const pop=(t,e)=>{const d=document.createElement('div');d.className='pow';d.textContent=t;const r=ar.getBoundingClientRect(); let x=r.width*.62,y=r.height*.25;if(e&&e.clientX&&e.currentTarget===ar){x=e.clientX-r.left-40;y=e.clientY-r.top-40;} d.style.left=(x+Math.random()*40-20)+'px';d.style.top=(y+Math.random()*30-15)+'px';ar.appendChild(d);setTimeout(()=>d.remove(),800);}; $('#hit').onclick=strike;if($('#hit2'))$('#hit2').onclick=strike;ar.addEventListener('pointerdown',strike); } const KINDS=[['fruit','apple'],['fruit','banana'],['fruit','orange'],['fruit','grapes'],['fruit','straw'],['fruit','melon'],['muffin','muffin'],['donut','donut'],['pretzel','pretzel']]; function drawItem(c,k,x,y,r){ c.save();c.translate(x,y);c.lineCap='round'; const circ=(cx,cy,rr,col)=>{c.fillStyle=col;c.beginPath();c.arc(cx,cy,rr,0,7);c.fill();}; switch(k){ case 'apple':circ(0,3,r,'#ff3b3b');c.strokeStyle='#6b3a1f';c.lineWidth=4;c.beginPath();c.moveTo(0,-r+4);c.lineTo(4,-r-8);c.stroke();c.fillStyle='#2fbf55';c.beginPath();c.ellipse(12,-r-6,9,4,-.4,0,7);c.fill();circ(-r*.4,-r*.2,r*.2,'#ffffff88');break; case 'banana':c.strokeStyle='#ffd23f';c.lineWidth=r*.7;c.beginPath();c.arc(0,-r*.6,r,0.3,Math.PI-.3);c.stroke();c.strokeStyle='#6b3a1f';c.lineWidth=4;c.beginPath();c.moveTo(r*.85,-r*.25);c.lineTo(r*1.05,-r*.35);c.stroke();break; case 'orange':circ(0,0,r,'#ff8a00');circ(0,-r+3,3,'#2fbf55');break; case 'grapes':[[0,-12],[-10,-2],[10,-2],[0,8],[-8,16],[8,16],[0,24]].forEach(([a,b])=>circ(a*r/28,b*r/28-4,r*.36,'#8e44ad'));break; case 'straw':c.fillStyle='#ff2d55';c.beginPath();c.moveTo(-r,-r*.4);c.quadraticCurveTo(0,-r*1.1,r,-r*.4);c.quadraticCurveTo(r*.6,r,0,r*1.1);c.quadraticCurveTo(-r*.6,r,-r,-r*.4);c.fill();c.fillStyle='#ffe';for(let i=0;i<6;i++){c.fillRect(-r*.5+(i%3)*r*.45,-r*.1+Math.floor(i/3)*r*.5,3,4);}c.fillStyle='#2fbf55';c.beginPath();c.ellipse(0,-r*.75,r*.6,r*.2,0,0,7);c.fill();break; case 'melon':c.fillStyle='#2fbf55';c.beginPath();c.arc(0,-r*.3,r*1.1,0,Math.PI);c.fill();c.fillStyle='#ff4f6d';c.beginPath();c.arc(0,-r*.3,r*.9,0,Math.PI);c.fill();c.fillStyle='#222';[-.4,0,.4].forEach(a=>c.fillRect(a*r-2,0,4,6));break; case 'muffin':c.fillStyle='#c9a26b';c.beginPath();c.moveTo(-r*.8,0);c.lineTo(r*.8,0);c.lineTo(r*.55,r);c.lineTo(-r*.55,r);c.fill();c.fillStyle='#d08a3a';c.beginPath();c.ellipse(0,0,r*1.1,r*.75,0,Math.PI,0);c.fill();c.strokeStyle='#a87e48';c.lineWidth=2;for(let i=-2;i<=2;i++){c.beginPath();c.moveTo(i*r*.25,2);c.lineTo(i*r*.18,r);c.stroke();}circ(-r*.35,-r*.4,3.5,'#3a1c0c');circ(r*.3,-r*.5,3.5,'#3a1c0c');circ(0,-r*.15,3.5,'#3a1c0c');break; case 'donut':c.fillStyle='#e0a060';c.beginPath();c.arc(0,0,r,0,7);c.arc(0,0,r*.36,0,7,true);c.fill('evenodd');c.fillStyle='#ff6fb8';c.beginPath();c.arc(0,0,r*.85,0,7);c.arc(0,0,r*.4,0,7,true);c.fill('evenodd');c.strokeStyle='#fff';c.lineWidth=3;[[.6,0],[-.5,.3],[0,-.6],[.2,.62],[-.55,-.4]].forEach(([a,b])=>{c.beginPath();c.moveTo(a*r,b*r);c.lineTo(a*r+5,b*r+3);c.stroke();});break; case 'pretzel':c.strokeStyle='#a0612a';c.lineWidth=r*.32;c.beginPath();c.moveTo(-r*.5,r*.9);c.quadraticCurveTo(-r*1.3,-r*.2,-r*.5,-r*.8);c.quadraticCurveTo(0,-r*1.1,0,-r*.1);c.quadraticCurveTo(0,-r*1.1,r*.5,-r*.8);c.quadraticCurveTo(r*1.3,-r*.2,r*.5,r*.9);c.moveTo(-r*.7,r*.3);c.lineTo(r*.7,r*.3);c.stroke();circ(-r*.4,-r*.5,2,'#fff');circ(r*.4,-r*.3,2,'#fff');break; } c.restore(); } function collect(){ clearT(); const H=G.H;let got={fruit:0,muffin:0,donut:0,pretzel:0},n=0,left=12,items=[],t0=performance.now(),last=0,over=false; app.innerHTML=`Tap the fruits, muffins, donuts and pretzels before they float away!
`; talk(T.snacks); const cv=$('#cv'),c=cv.getContext('2d');let W=0,Hh=0; const size=()=>{const r=cv.getBoundingClientRect(),d=Math.min(2,window.devicePixelRatio||1);W=r.width;Hh=r.height;cv.width=W*d;cv.height=Hh*d;c.setTransform(d,0,0,d,0,0);};size(); const ro=new ResizeObserver(size);ro.observe(cv); const spawn=()=>{const [cat,k]=rnd(KINDS);items.push({cat,k,x:-40,y:70+Math.random()*(Hh-120),v:45+Math.random()*35+H*3,ph:Math.random()*6,r:32,got:0});}; const grabAt=(x,y,rad,pi)=>{if(over)return; for(const it of items){if(!it.got&&Math.hypot(it.x-x,it.y-y)${msg}
${G.mode===2?`Next turn: ${G.pl[G.turn].w}
`:''}`,[['Next clock','',question]]); }else{ const H=G.H,st=Math.max(1,G.first);P.stars[H]=Math.max(P.stars[H]||0,st);if(P.unlocked<=H)P.unlocked=H+1;save();SFX.win(); if(G.mode===2)G.turn=1-G.turn; const champ=H===12; const lead=G.mode===2?(G.pl[0].pts===G.pl[1].pts?'It is a tie!':`${(G.pl[0].pts>G.pl[1].pts?G.pl[0]:G.pl[1]).w} is winning!`):''; modal(`${msg}
${M[H-1].v} is knocked out!${H<12?` Mission ${H+1} is open.`:' You beat all 12 hours!'}
${lead?`${lead}
`:''}`, H<12?[['Next mission','',()=>startMission(H+1)],['Map','ghost',map]]:[['Map','',map]]); speak(champ?'You are the clock champion!':'Mission complete!'); } } function upgrade(){ const cost=(P.lvl+1)*8,have=Object.values(P.inv).reduce((a,b)=>a+b,0); if(haveYou have ${have}. You need ${cost}. Win snacks in the chocolate river and in battles.
`,[['OK','',null]]);return;} let left=cost;['fruit','pretzel','muffin','donut'].forEach(k=>{const t=Math.min(left,P.inv[k]);P.inv[k]-=t;left-=t;}); P.lvl++;save();SFX.saber(); modal(`