(function(){
var B='https://baccikid.b-cdn.net/Z%20New/',T=B+'01%20Chopsticks%20Assets/00.1%20Final/01.1%20True%20Final/',
SP=T+'01_Gold_Spoon.png',C1=T+'02_Gold_Chopstick_1.png',C2=T+'03_Gold_Chopstick_2.png',
FD=B+'00.1%20Food/Fried-Tofu.png',BX=B+'00.1%20Bento/V1%20Designer/15-Champagne-Cushion-Bento.png';
var BOWL='<svg viewBox="0 0 100 70" aria-hidden="true"><ellipse cx="50" cy="22" rx="46" ry="12" fill="#fff8f2"/><path d="M4 22q4 44 46 46q42-2 46-46z" fill="#e8cdf7"/><ellipse cx="50" cy="22" rx="38" ry="8" fill="#7fb8b8"/></svg>';
var STAMP='<svg viewBox="0 0 100 100" aria-hidden="true"><circle cx="50" cy="50" r="46" fill="#0b0a26e6" stroke="#d4ab5a" stroke-width="4"/><circle cx="50" cy="50" r="38" fill="none" stroke="#f8e7b0" stroke-width="1.2" stroke-dasharray="4 4"/><text x="50" y="40" font-family="Arial" font-size="9" font-weight="700" text-anchor="middle" fill="#f8e7b0" letter-spacing="2">BACCI KID</text><text x="50" y="58" font-family="Georgia" font-size="14" font-weight="700" text-anchor="middle" fill="#fff">BEGINNER</text><text x="50" y="72" font-family="Arial" font-size="8" font-weight="700" text-anchor="middle" fill="#b6f2e1" letter-spacing="2">CHOPSTICKS</text></svg>';
/* [title, line 1, line 2, Bacci's bubble] */
var S=[['Meet Sujeo','A spoon and chopsticks make a team called sujeo (수저).','Spoon for soup. Chopsticks for bites.','Hi, team sujeo!'],
['Know Your Chopsticks','Two sticks. Tips level.','Tap the tips on the table so they line up.','Tap, tap, level!'],
['Choose Your Hand','Left or right, use the hand you control best.','Tap the side that feels right.','Your best hand!'],
['Anchor the Lower Stick','Rest it at the base of your thumb, on your ring finger.','It stays still.','Steady as stone!'],
['Control the Upper Stick','Hold the upper stick like a pencil.','Only this one moves.','Just like a pencil!'],
['Open Close Rhythm','Open. Close. Open again.','Ten gentle tries.','Open, close, wow!'],
['Practice Lab','Pick up something soft and big.','Lift. Count to three. Set it down.','Lift and count!'],
['Manners Mode','Rest chopsticks on a holder between bites.','Never stand them up in rice.','So polite!'],
['Restaurant Mode','Spoon for soup, chopsticks for bites.','Grown-ups use separate tongs at the hot grill.','Table pro!'],
['Beginner Portal Unlocked','You did it!','Play the game and earn your stamp.','Stamp time!']];
function im(src,cls,st){return '<img src="'+src+'" class="'+cls+'" style="'+st+'" alt="">'}
function lb(t,st,m){return '<span class="lb'+(m?' m':'')+'" style="'+st+'">'+t+'</span>'}
function dt(st,a){return '<i class="dt" style="'+st+(a||'')+'"></i>'}
var cs=function(src,st,cls){return im(src,'cs '+(cls||''),st)};
var SC=[
function(){return '<div class="pl"></div>'+im(SP,'sp','left:24%;top:12%;height:76%;animation:flo 3.4s ease-in-out infinite')+cs(C1,'left:56%;top:16%;height:70%;rotate:-3deg;animation:flo 3.4s .4s ease-in-out infinite')+cs(C2,'left:64%;top:16%;height:70%;rotate:3deg;animation:flo 3.4s .7s ease-in-out infinite')+lb('Spoon','left:32%;top:5%')+lb('Chopsticks','left:67%;top:5%')},
function(){return '<div class="ln" style="top:82%"></div>'+cs(C1,'left:42%;animation:tap 1.8s ease-in-out infinite')+cs(C2,'left:51%;animation:tap 1.8s .12s ease-in-out infinite')+dt('left:49%;top:82%')+dt('left:58%;top:82%')+lb('Tips level','left:50%;bottom:6%',1)},
function(){return '<div class="side" id="g-L" style="left:2%">'+cs(C1,'left:36%;top:10%;height:62%')+cs(C2,'left:52%;top:10%;height:62%')+'<b>LEFT</b></div><div class="side" id="g-R" style="right:2%">'+cs(C1,'left:36%;top:10%;height:62%')+cs(C2,'left:52%;top:10%;height:62%')+'<b>RIGHT</b></div>'},
function(){return cs(C1,'left:43%','g')+cs(C2,'left:52%','dim')+dt('left:50%;top:34%')+dt('left:50%;top:61%')+lb('Thumb base','left:29%;top:31%')+lb('Ring finger','left:28%;top:58%')+lb('Stays still','left:50%;bottom:6%',1)},
function(){return cs(C1,'left:43%','dim')+cs(C2,'left:52%;animation:piv 1.6s ease-in-out infinite','g')+lb('Still','left:30%;top:48%')+lb('Moves','left:74%;top:40%',1)},
function(){return cs(C1,'left:43%','g')+cs(C2,'left:52%;animation:piv 1.3s ease-in-out infinite','g')+'<div class="rg" style="left:52%;top:84%;animation:ring 1.3s ease-out infinite"></div>'+lb('Open. Close.','left:50%;bottom:6%',1)},
function(){return '<div style="inset:0;animation:lift 4.4s ease-in-out infinite">'+cs(C1,'left:43%;top:0;height:70%')+cs(C2,'left:52%;top:0;height:70%;rotate:-5deg')+im(FD,'fd','left:41%;top:62%;width:20%')+'</div>'+dt('left:76%;top:74%;animation:dts 4.4s infinite')+dt('left:82%;top:74%;animation:dts 4.4s .5s infinite')+dt('left:88%;top:74%;animation:dts 4.4s 1s infinite')+lb('Lift. Count to 3.','left:50%;bottom:6%',1)},
function(){return '<div class="pl" style="width:min(62%,96cqh)"></div><div class="hd" style="top:66%;left:40%;width:22%"></div>'+cs(C1,'left:43%;top:16%;transform-origin:50% 50%;rotate:90deg;animation:lay 1.4s cubic-bezier(.3,1.3,.5,1) both')+cs(C2,'left:43%;top:22%;transform-origin:50% 50%;rotate:90deg;animation:lay 1.4s .15s cubic-bezier(.3,1.3,.5,1) both')+lb('Rest between bites','left:50%;bottom:6%',1)},
function(){return '<div class="bw" style="left:8%;top:44%">'+BOWL+'</div>'+im(SP,'sp','left:14%;top:2%;height:58%;rotate:-28deg;animation:flo 3.4s ease-in-out infinite')+im(BX,'bx','left:46%;top:46%')+cs(C1,'left:62%;top:6%;height:48%;rotate:16deg;animation:flo 3.4s .5s ease-in-out infinite')+cs(C2,'left:69%;top:6%;height:48%;rotate:16deg;animation:flo 3.4s .8s ease-in-out infinite')+lb('Soup','left:24%;bottom:7%')+lb('Bites','left:72%;bottom:7%')},
function(){return '<div class="pl" style="width:min(54%,84cqh);animation:orb 2.6s ease-in-out infinite"></div><div class="rg" style="left:50%;top:50%;width:60%;border-color:#f8e7b0;animation:ring 2.6s ease-out infinite"></div><div class="rg" style="left:50%;top:50%;width:60%;border-color:#f8e7b0;animation:ring 2.6s 1.3s ease-out infinite"></div><div class="stamp" id="g-st">'+STAMP+'</div>'}];
var R=document.getElementById('bkg10'),$=function(i){return document.getElementById('g-'+i)},sc=$('sc'),mv=$('mv'),pk=$('pk'),bub=$('bub'),h=$('h'),l1=$('l1'),l2=$('l2'),n=$('n'),prev=$('prev'),next=$('next'),fin=$('fin'),dots=$('dots'),card=$('card'),lm=$('lm'),hy=$('hy'),SS=window.speechSynthesis,i=0,tm,sx=0,sy=0,sw=0;
for(var k=0;k<10;k++){var d=document.createElement('i');d.dataset.i=k;dots.appendChild(d)}
dots.onclick=function(e){var t=e.target.dataset.i;if(t!=null)go(+t-i)};
function lo(){return R.classList.contains('lo')}
function show(d){var s=S[i];sc.innerHTML=SC[i]();h.textContent=s[0];l1.textContent=s[1];l2.textContent=s[2];bub.textContent=s[3];n.textContent=(i+1)+' / 10';prev.disabled=!i;next.disabled=i==9;fin.hidden=i!=9;hy.hidden=i==9;
[].forEach.call(dots.children,function(e,k){e.className=k==i?'on':k<i?'d':''});
if(i==2){['L','R'].forEach(function(z){$(z).onclick=function(){$('L').classList.toggle('on',z=='L');$('R').classList.toggle('on',z=='R');[].forEach.call(sc.querySelectorAll('.cs'),function(c){c.classList.remove('g')});[].forEach.call($(z).querySelectorAll('.cs'),function(c){c.classList.add('g')});bub.textContent=(z=='L'?'Left':'Right')+' hand, yes!';pk.classList.remove('pop');void pk.offsetWidth;pk.classList.add('pop')}})}
if(i==9){setTimeout(function(){var st=$('st');if(st)st.classList.add('in')},120)}
stop();
if(d&&!lo()){mv.classList.remove('l','r');pk.classList.remove('pop');void mv.offsetWidth;mv.classList.add(d>0?'r':'l');pk.classList.add('pop');if(i==9)conf()}}
function go(d){var j=Math.max(0,Math.min(9,i+d));if(j==i)return;d=j>i?1:-1;i=j;show(d)}
prev.onclick=function(){go(-1)};next.onclick=function(){go(1)};
document.addEventListener('keydown',function(e){if(/INPUT|TEXTAREA|SELECT/.test(e.target.tagName))return;if(e.key=='ArrowRight')go(1);else if(e.key=='ArrowLeft')go(-1)});
card.addEventListener('pointerdown',function(e){sx=e.clientX;sy=e.clientY;sw=1});
card.addEventListener('pointerup',function(e){if(!sw)return;sw=0;var dx=e.clientX-sx,dy=e.clientY-sy;if(Math.abs(dx)>40&&Math.abs(dx)>Math.abs(dy)*1.2)go(dx<0?1:-1)});
card.addEventListener('pointercancel',function(){sw=0});
function stop(){clearTimeout(tm);R.classList.remove('talk');if(SS)SS.cancel()}
function fb(ms){clearTimeout(tm);tm=setTimeout(stop,ms)}
function voice(){var v=SS.getVoices(),j,b=null;for(j=0;j<v.length;j++){if(!/^en/i.test(v[j].lang))continue;if(/Samantha|Google US|Aria|Karen|Natural/.test(v[j].name))return v[j];if(!b)b=v[j]}return b}
hy.onclick=function(){var s=S[i],t=s[0]+'. '+s[1].replace(/\s*\([^)]*\)/,'')+' '+s[2];stop();R.classList.add('talk');
if(!SS||!window.SpeechSynthesisUtterance){fb(3200);return}
var u=new SpeechSynthesisUtterance(t),v=voice();if(v)u.voice=v;u.lang='en-US';u.rate=.92;u.pitch=1.08;u.onend=stop;u.onerror=function(e){if(!/interrupt|cancel/.test(e.error||''))fb(3000)};
tm=setTimeout(function(){if(!SS.speaking)fb(1800)},1400);SS.speak(u)};
function setLo(on){R.classList.toggle('lo',on);lm.setAttribute('aria-pressed',on);try{localStorage.bkLo=on?1:''}catch(e){}}
var pre=false;try{pre=!!localStorage.bkLo}catch(e){}
setLo(pre||matchMedia('(prefers-reduced-motion:reduce)').matches);
lm.onclick=function(){setLo(!lo())};
function conf(){var f=$('cf'),C=['#f8e7b0','#d4ab5a','#b6f2e1','#e8cdf7','#6b4fd8'];f.innerHTML='';for(var k=0;k<40;k++){var e=document.createElement('i');e.style.left=Math.random()*100+'%';e.style.background=C[k%5];e.style.animationDelay=Math.random()*.8+'s';f.appendChild(e)}setTimeout(function(){f.innerHTML=''},3800)}
show(0)})();