const ANIMALES=[["perro","🐶"],["gato","🐱"],["vaca","🐮"],["cerdo","🐷"],["pato","🦆"],["oveja","🐑"],["caballo","🐴"],["conejo","🐰"],["rana","🐸"],["pez","🐟"],["león","🦁"],["oso","🐻"],["mono","🐵"],["pollito","🐤"],["ratón","🐭"],["tortuga","🐢"]]; const COLORES=[["rojo","#e53935"],["azul","#1e63d6"],["amarillo","#fdd835"],["verde","#2e9e44"],["naranja","#fb8c00"],["morado","#7b3fb0"],["rosa","#f48fb1"],["marrón","#7a4a26"],["negro","#1a1a1a"],["blanco","#ffffff"],["gris","#9e9e9e"]]; const PALABRAS=[["sol","☀️"],["luna","🌙"],["casa","🏠"],["pato","🦆"],["mano","✋"],["pelota","⚽"],["tomate","🍅"],["moto","🛵"],["foca","🦭"],["uva","🍇"],["pera","🍐"],["piña","🍍"],["nube","☁️"],["flor","🌸"],["árbol","🌳"],["pan","🍞"],["queso","🧀"],["leche","🥛"],["mesa","🪑"],["llave","🔑"],["rosa","🌹"],["dedo","☝️"],["pie","🦶"],["gato","🐱"]]; const COSAS=["🍎","⭐","🐟","🌸","🚗","🎈","🍓","🐞","⚽","🦆"]; const GAMES=[ {id:"animales",s:"lengua",t:1,pic:"🐮",name:"Une los animales",area:"Vocabulario y lectura",type:"match",help:"Toca un animal y después su nombre."}, {id:"colores",s:"lengua",t:1,pic:"🎨",name:"Los colores",area:"Vocabulario y lectura",type:"match",help:"Toca un color y después su nombre."}, {id:"silabas",s:"lengua",t:1,pic:"👏",name:"Forma la palabra",area:"Conciencia silábica",type:"silabas",help:"Toca las sílabas en orden para formar la palabra."}, {id:"lee",s:"lengua",t:2,pic:"📖",name:"Lee y elige",area:"Lectura de palabras",type:"quiz",help:"Lee la palabra y toca su dibujo."}, {id:"cuantos",s:"mates",t:1,pic:"🔢",name:"¿Cuántos hay?",area:"Contar hasta 10",type:"quiz",help:"Cuenta los dibujos y toca el número."}, {id:"sumas",s:"mates",t:1,pic:"➕",name:"Sumas hasta 10",area:"Sentido numérico",type:"quiz",help:"Suma las manzanas y toca el resultado."}, {id:"sentidos",s:"naturales",t:1,pic:"👂",name:"Los cinco sentidos",area:"El cuerpo humano",type:"quiz",help:"¿Qué sentido usamos?"}, {id:"english",s:"english",t:0,pic:"🌈",name:"Colours and numbers",area:"Vocabulary",type:"quiz",help:"Look and choose the word."} ]; const SENTIDOS=[["Oler una flor","🌸","olfato"],["Oler el pan recién hecho","🍞","olfato"],["Escuchar música","🎵","oído"],["Oír el timbre","🔔","oído"],["Ver el arcoíris","🌈","vista"],["Mirar las estrellas","⭐","vista"],["Probar un helado","🍦","gusto"],["Saborear un limón","🍋","gusto"],["Acariciar a un gato","🐱","tacto"],["Notar que el agua está fría","💧","tacto"]]; const SENS={vista:"👀 vista",oído:"👂 oído",olfato:"👃 olfato",gusto:"👅 gusto",tacto:"✋ tacto"}; const EN_COL=[["red","#e53935"],["blue","#1e63d6"],["yellow","#fdd835"],["green","#2e9e44"],["orange","#fb8c00"],["pink","#f48fb1"],["black","#1a1a1a"],["white","#ffffff"],["purple","#7b3fb0"],["brown","#7a4a26"]]; const EN_NUM=["one","two","three","four","five","six","seven","eight","nine","ten"]; const SILABAS=[["pa-to","🦆"],["ga-to","🐱"],["lu-na","🌙"],["ca-sa","🏠"],["me-sa","🪑"],["pe-lo-ta","⚽"],["to-ma-te","🍅"],["mo-to","🛵"],["fo-ca","🦭"],["pe-ra","🍐"],["pi-ña","🍍"],["nu-be","☁️"],["ma-no","✋"],["le-che","🥛"],["que-so","🧀"],["ra-na","🐸"],["va-ca","🐮"],["o-so","🐻"],["co-ne-jo","🐰"],["pe-rro","🐶"],["ca-ba-llo","🐴"],["ra-tón","🐭"],["tor-tu-ga","🐢"],["pa-lo-ma","🕊️"],["ja-món","🍖"],["za-pa-to","👞"]]; const RELLENO=["mi","su","lo","ta","bo","fe","di","ne","pu","ri"]; const $=s=>document.querySelector(s); const board=$("#board"); const rand=(a,b)=>a+Math.floor(Math.random()*(b-a+1)); const shuffle=a=>{a=[...a];for(let i=a.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[a[i],a[j]]=[a[j],a[i]]}return a}; const esc=s=>String(s).replace(/[&<>"]/g,c=>({"&":"&","<":"<",">":">",'"':"""}[c])); let current="animales", soundOn=true, actx=null; function tone(ok){ if(!soundOn) return; try{ actx=actx||new (window.AudioContext||window.webkitAudioContext)(); const notes=ok?[660,880]:[220]; notes.forEach((f,i)=>{const o=actx.createOscillator(),g=actx.createGain();o.type="sine";o.frequency.value=f; const t=actx.currentTime+i*.11;g.gain.setValueAtTime(.0001,t);g.gain.exponentialRampToValueAtTime(.18,t+.02);g.gain.exponentialRampToValueAtTime(.0001,t+.25); o.connect(g).connect(actx.destination);o.start(t);o.stop(t+.27)}); }catch(e){} } function shake(el){el.classList.remove("shake");void el.offsetWidth;el.classList.add("shake")} const SUBJ=[{id:"lengua",name:"Lengua"},{id:"mates",name:"Matemáticas"},{id:"naturales",name:"Ciencias de la Naturaleza"},{id:"english",name:"English"}]; const TRIM=["Todo el curso","1.er trimestre","2.º trimestre","3.er trimestre"]; let trim=0; function renderNav(){ $("#trims").innerHTML=TRIM.map((t,k)=>``).join(""); document.querySelectorAll("#trims button").forEach(b=>b.onclick=()=>{trim=+b.dataset.t;renderNav()}); $("#games").innerHTML=SUBJ.map(s=>{const gs=GAMES.filter(g=>g.s===s.id&&(!trim||g.t===0||g.t===trim)).sort((a,b)=>a.t-b.t); return `
Nada este trimestre
`}${g.help}
${parts.length} sílabas: ¡dad ${parts.length} palmadas!
${msg}
${esc(t)}
`,answer:SENS[k],opts,small:true}; } if(id==="english"){ if(Math.random()<.5){const [w,c]=EN_COL[rand(0,EN_COL.length-1)]; return {scene:`What colour is it?
`,answer:w,opts:shuffle([w,...shuffle(EN_COL.filter(x=>x[0]!==w)).slice(0,2).map(x=>x[0])]),small:true};} const n=rand(1,10),e=COSAS[rand(0,COSAS.length-1)]; return {scene:`How many?
`,answer:EN_NUM[n-1],opts:shuffle([EN_NUM[n-1],...shuffle(EN_NUM.filter((_,k)=>k!==n-1)).slice(0,2)]),small:true}; } if(id==="sumas"){ const a=rand(1,8), b=rand(1,10-a), r=a+b; const scene=`${a} + ${b} = ?
`; return {scene,answer:String(r),opts:numOpts(r,0,10)}; } if(id==="cuantos"){ const n=rand(1,10), e=COSAS[rand(0,COSAS.length-1)]; return {scene:`¿Cuántos hay?
`,answer:String(n),opts:numOpts(n,1,10)}; } const [w,e]=PALABRAS[rand(0,PALABRAS.length-1)]; const others=shuffle(PALABRAS.filter(p=>p[0]!==w&&p[1]!==e)).slice(0,2).map(p=>p[1]); return {scene:`${esc(w)}
`,answer:e,opts:shuffle([e,...others]),emoji:true}; } function numOpts(r,min,max){ const s=new Set([r]); while(s.size<3){const c=r+rand(-3,3);if(c>=min&&c<=max)s.add(c)} return shuffle([...s]).map(String); } function playQuiz(g){ let i=0, score=0; const res=[]; const next=()=>{ if(i===ROUNDS) return winScreen(g,score,ROUNDS); const q=makeQ(g.id); const dots=Array.from({length:ROUNDS},(_,k)=>``).join(""); board.innerHTML=head(g,`