### user
You are a coding expert, please use your professional knowledge to generate accurate, professional responses. Be sure to create executable code for demonstration where possible. Design a small web game for fifth-graders to practice English vocabulary.
### assistant · thinking
The user wants a small web game for fifth-graders to practice English vocabulary. I should create an executable, complete HTML/CSS/JS game. Let me design something engaging and educational.
Design considerations for 5th graders (about 10-11 years old):
- Simple, colorful UI
- Vocabulary appropriate for that level
- Fun mechanics: maybe a "word catcher" or "quiz" game
- Immediate feedback, sounds (Web Audio API), animations
- Score, lives, levels
- No external dependencies (single file, works offline)
Let me design: "Word Pop!" — A falling-word game? Or a quiz game where a picture/definition is shown and you pick the word?
Better idea: A game with multiple modes, but keep it focused. Let me do "Vocabulary Rocket" or "Word Match".
I'll build: **Word Ninja / Word Pop** — Words fall from the top, and a definition/emoji hint is shown. Player clicks/taps the correct word before it hits the bottom. That's fun but tricky with reading.
Alternative that's more pedagogically solid and easier to implement well: **Quiz game with 3 rounds** where each round has a different task type:
1. Picture/emoji → choose the word
2. Definition → choose the word
3. Fill in the blank sentence → choose the word
That covers vocabulary in multiple contexts. With lives, timer, score, sound effects, animations, and a final results screen.
Actually, let me make it more game-like: falling words is more engaging. Hmm. But for a web game demo, a polished quiz with juicy feedback is reliable.
Let me do a hybrid: **"Word Pop!"** — a bubble-popping game. Bubbles float up with words, a prompt shows "Which word means ___?" or an emoji hint. Player clicks the right bubble. Bubbles rise; if the right bubble escapes, you lose a life. Actually that's pressure-heavy.
Let me simplify but keep it fun: Canvas-free, DOM-based with CSS animations.
**Game: "Word Pop Arcade"**
- Each round: a prompt card shows either an emoji + "Choose the word" or a definition, or a sentence with a blank.
- 4 bubbles with words floating around (gentle CSS animation).
- Click correct → bubble pops with particle effect, +points, streak bonus.
- Click wrong → shake, lose a life, show correct answer highlighted.
- 10 questions per game, timer per question (15s), score with time bonus.
- Levels: score thresholds.
- Sound via Web Audio API (no assets).
- Progress bar, lives (3 hearts).
- Final screen with score, accuracy, and a "play again".
- Word list of ~40 grade-5 appropriate words.
Also add speech synthesis to hear the word pronounced — nice for vocabulary learning! `speechSynthesis`. That's a good touch: click a speaker to hear the word.
Let me write clean code.
Structure:
- HTML: header (score, lives, question counter), main area (prompt card, bubble field), overlays (start screen, end screen), feedback toast.
- CSS: playful, rounded, gradients, responsive, animations.
- JS: word bank, question generation, game state, event handling.
Word bank: each entry: word, emoji (or hint), definition, sentence with blank, part of speech maybe.
Let me create ~30 words suitable for 5th grade:
1. enormous — 🐘 — "very, very big" — "The elephant was ___."
2. curious — 🧐 — "wanting to know more" — "The ___ kitten peeked in every box."
3. brave — 🦁 — "not afraid of danger" — "The ___ firefighter ran into the building."
4. ancient — 🏺 — "very old" — "We saw ___ ruins in the desert."
5. generous — 🎁 — "happy to give to others" — "She was ___ and shared her lunch."
6. fragile — 🥚 — "easily broken" — "Handle the ___ glass carefully."
7. furious — 😡 — "very angry" — "Dad was ___ when we broke the window."
8. delighted — 😄 — "very pleased" — "I was ___ to see my friends."
9. exhausted — 😴 — "very tired" — "After the race, we were ___."
10. peculiar — 🤪 — "strange or unusual" — "That's a ___ smell!"
11. swift — ⚡ — "very fast" — "The ___ runner won the race."
12. silent — 🤫 — "making no sound" — "The library was completely ___."
13. magnificent — 🌟 — "extremely beautiful or grand" — "The castle was ___."
14. stubborn — 🐴 — "refusing to change your mind" — "He was too ___ to say sorry."
15. cautious — ⚠️ — "careful to avoid danger" — "Be ___ near the busy road."
16. vanish — 💨 — "to disappear suddenly" — "The magician made the rabbit ___."
17. sturdy — 🌳 — "strong and not easily broken" — "The ___ bridge held the truck."
18. shimmer — ✨ — "to shine with a soft light" — "The stars ___ in the night sky."
19. grasp — 🤝 — "to hold on tightly / understand" — "She ___ the rope with both hands."
20. voyage — 🚢 — "a long journey" — "The sailors began a long ___."
21. habitat — 🏞️ — "the natural home of an animal" — "The forest is the bear's ___."
22. predict — 🔮 — "to say what will happen next" — "Can you ___ the ending?"
23. observe — 🔍 — "to watch carefully" — "Scientists ___ the birds each day."
24. respect — 🙇 — "to treat someone with care and honor" — "We ___ our teachers."
25. invent — 💡 — "to create something new" — "He wanted to ___ a flying car."
26. courage — 🛡️ — "being brave when things are hard" — "It took ___ to speak in front of the class."
27. attempt — 🎯 — "to try" — "I will ___ the math problem again."
28. necessary — ✅ — "needed" — "Water is ___ for life."
29. crowded — 👥 — "full of people" — "The market was very ___."
30. delightful — 🍰 — "very pleasant" — "What a ___ surprise!"
31. translate — 🌐 — "to change words into another language" — "Can you ___ this into Spanish?"
32. tremble — 🥶 — "to shake slightly" — "Her hands ___ in the cold."
33. glide — 🛝 — "to move smoothly" — "The skater ___ across the ice."
34. precious — 💎 — "very valuable" — "This ring is ___ to me."
35. echo — 🔊 — "a sound that bounces back" — "We heard an ___ in the cave."
Good. Now question types:
- Type "definition": prompt shows definition, choose the word.
- Type "sentence": prompt shows sentence with blank, choose the word.
- Type "emoji": prompt shows emoji, choose the word. Maybe combine emoji with definition for hint. Let's have emoji shown always as a small hint, plus either definition or sentence.
Distractors: pick 3 other random words. For sentence type, ideally same part of speech, but all our words are mostly adjectives/verbs/nouns mixed. Could just pick random others. Good enough. Maybe try to match the first letter difference... no, keep simple but avoid same-word.
Actually for a better challenge, pick distractors that are plausible. Random is fine for 5th grade.
Game flow:
- Start screen with title, instructions, "Start" button, and a "Practice Mode" toggle? Keep it simple. Maybe difficulty: 8 questions.
- Timer bar per question: 15 seconds. Points: 100 base + time bonus (up to 50) + streak bonus (streak * 10, capped).
- Lives: 3. Wrong answer or timeout → lose a life.
- Game over when lives = 0 or all questions answered.
Bubbles: I'll place 4 answer "cards" in a grid, styled as floating bubbles with a gentle bob animation. On hover, scale up. On click correct: pop animation + confetti particles. On wrong: shake + red flash.
Speech: on correct answer, speak the word. Also a small speaker button on the prompt to hear the word? No — that'd give it away for definition questions. Instead, after answering, show the word and let them hear it.
Hmm, actually for definition questions hearing the word would give away... no it wouldn't, hearing the word IS the answer. So only speak after answering. Good.
Also add "Read aloud" for the definition/sentence? Could be nice for accessibility. Let's add a small 🔊 button on the prompt that reads the prompt text. That's helpful and doesn't spoil.
Sound effects with Web Audio API: correct = ascending arpeggio, wrong = low buzz, tick? Keep it simple: correct, wrong, gameover, pop.
Let me write the code.
```html
Word Pop! — 5th Grade Vocabulary Game
...
```
CSS design:
- Background: gradient sky with floating shapes.
- Font: system fonts, rounded.
- Colors: bright but not garish.
Let me write it carefully.
```css
:root{
--bg1:#1b2a6b;
--bg2:#4a2f8f;
...
}
```
Maybe a bright friendly theme: sky blue to purple gradient, white cards.
Let's go with:
- body background: linear-gradient(160deg, #2b1a5e, #4b2ea8 40%, #1f7bb8)
- Actually for kids, brighter: linear-gradient(160deg,#5b8def,#8e6bff 45%, #ff7ac0)? Too much. Let's do a night-sky arcade with neon accents — appealing and readable.
I'll use: background: radial-gradient(circle at 20% 10%, #3b2a86, #17123a 60%), plus animated stars.
Cards: white with dark text — good contrast.
Let me now write the HTML structure.
```html
Score0
Question1/10
Streak0
❤️❤️❤️
🎁
Which word means…
…
...
...
```
Now JS.
State:
```js
const state = {
score: 0, lives: 3, streak: 0, best: 0,
qIndex: 0, totalQ: 10,
questions: [],
current: null,
locked: false,
timeLeft: 0, timerId: null,
correctCount: 0
};
```
Question generation: shuffle word bank, take 10, for each decide type cycling through ['definition','sentence','emoji'].
Actually "emoji" type: show emoji large, ask "Which word matches this picture?" — but emojis are ambiguous. Better: emoji + short hint. Hmm. Let me just use two types: definition and sentence, with the emoji shown as a decorative hint on the prompt card. That's cleaner and less ambiguous. But then 3 types would add variety...
Let me do: type A = definition ("Which word means: very, very big?"), type B = fill-in-the-blank sentence. Both show the emoji as a visual cue. Good.
Distractors: shuffle other words, take 3. To make it a bit fairer, try to pick distractors whose definition isn't too similar. Random is fine.
Timer: 15 seconds. Use requestAnimationFrame or setInterval(50ms). I'll use setInterval with 100ms and track elapsed.
Actually simpler: use a CSS transition on the timer bar width and setTimeout for the timeout. But pausing etc. Let's use setInterval(100) updating timeLeft.
On answer:
- lock
- stop timer
- if correct: score += 100 + timeBonus + streakBonus; streak++; play sound; pop animation; speak word; after 900ms next question.
- if wrong: lives--; streak = 0; shake the chosen bubble; highlight correct; show correct word; after 1600ms next.
Timeout: treat as wrong (lose life), highlight correct.
Let me write the pop animation: on correct bubble, add class 'pop' → scale up and fade with a burst of particles. I'll create particles as absolutely positioned divs.
Confetti: simple.
Let me write helper `shuffle(arr)`.
Sound with Web Audio:
```js
let audioCtx;
function initAudio(){ if(!audioCtx) audioCtx = new (window.AudioContext||window.webkitAudioContext)(); }
function tone(freq, start, dur, type='sine', gain=0.15){
const osc = audioCtx.createOscillator();
const g = audioCtx.createGain();
osc.type = type; osc.frequency.value = freq;
g.gain.setValueAtTime(0, audioCtx.currentTime+start);
g.gain.linearRampToValueAtTime(gain, audioCtx.currentTime+start+0.01);
g.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime+start+dur);
osc.connect(g); g.connect(audioCtx.destination);
osc.start(audioCtx.currentTime+start);
osc.stop(audioCtx.currentTime+start+dur+0.02);
}
function sfxCorrect(){ [523.25,659.25,783.99,1046.5].forEach((f,i)=>tone(f,i*0.07,0.18,'triangle',0.12)); }
function sfxWrong(){ tone(220,0,0.18,'sawtooth',0.1); tone(160,0.14,0.28,'sawtooth',0.1); }
function sfxGameOver(){ [659,523,392,261].forEach((f,i)=>tone(f,i*0.16,0.35,'sine',0.12)); }
```
Speech synthesis:
```js
function speak(text){
if(!('speechSynthesis' in window)) return;
speechSynthesis.cancel();
const u = new SpeechSynthesisUtterance(text);
u.rate = 0.9; u.lang='en-US';
speechSynthesis.speak(u);
}
```
Add a mute toggle for sound.
Now, the prompt card and bubbles layout. Bubbles: 2x2 grid on desktop, 1 column on mobile? 2x2 on mobile too but smaller text. Words like "magnificent" are long. Use font-size clamp.
Let me write CSS.
```css
* { box-sizing: border-box; margin:0; padding:0; }
body{
font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
min-height:100vh;
background: radial-gradient(circle at 15% 0%, #3a2b8c 0%, #1a1240 45%, #0d0a26 100%);
color:#fff;
display:flex; align-items:center; justify-content:center;
padding:16px;
overflow-x:hidden;
}
```
Add star field via body::before with radial-gradient dots? Or use a few absolutely positioned divs. I'll do a CSS-only starfield with box-shadow trick — or just skip and use soft blobs.
I'll add floating blobs with keyframes for atmosphere.
Layout: `.app { width:min(900px,100%); }` with the HUD, prompt card, bubbles.
Let me write everything out now.
For the bubbles, each is a button:
```html
```
CSS:
```css
.bubbles{
display:grid;
grid-template-columns: repeat(2, 1fr);
gap: 14px;
margin-top: 16px;
}
.bubble{
position:relative;
padding: 22px 12px;
border:none;
border-radius: 22px;
font-size: clamp(1rem, 2.6vw, 1.45rem);
font-weight: 700;
letter-spacing:.3px;
cursor:pointer;
color:#241a55;
background: linear-gradient(160deg,#ffffff,#dfe6ff);
box-shadow: 0 8px 0 #a9b4e8, 0 14px 26px rgba(0,0,0,.35);
transition: transform .12s ease, box-shadow .12s ease, background .2s;
animation: bob 3s ease-in-out infinite;
}
```
With nth-child animation delays.
Hover: translateY(-4px), brighter.
Active: translateY(4px), shadow smaller.
Correct: background green gradient, pop.
Wrong: red, shake.
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
But hover transform conflicts with animation. Use a wrapper? Simpler: put the bob animation on the button and on hover set `animation-play-state: paused` — but transform is overridden by animation. Hmm. Animation wins over the transform property in the cascade (animations override normal declarations).
Solution: wrap each button in a `.bubble-wrap` div that has the bob animation, and the button inside handles hover transforms. Let's do that.
```html
```
Good.
Pop effect: add class `popped` to button → animation: popOut .5s forwards.
Particles: create span elements in the wrap at random positions.
OK. Let's also handle the "correct answer reveal": add class `correct` to the right button.
Now writing the full code.
Question generation detail:
```js
function buildQuestions(){
const pool = shuffle([...WORDS]).slice(0, state.totalQ);
return pool.map((w, i) => {
const type = i % 2 === 0 ? 'definition' : 'sentence';
const others = shuffle(WORDS.filter(x => x.word !== w.word)).slice(0,3);
const options = shuffle([w, ...others]);
return { target: w, type, options };
});
}
```
But `shuffle(WORDS.filter(...))` each time is fine (35 words).
Rendering a question:
```js
function renderQuestion(){
const q = state.current;
state.locked = false;
// prompt
promptEmoji.textContent = q.target.emoji;
if(q.type === 'definition'){
promptLabel.textContent = 'Which word means…';
promptText.textContent = q.target.definition;
} else {
promptLabel.textContent = 'Choose the word that fits:';
promptText.textContent = q.target.sentence; // contains ___
}
// bubbles
bubblesEl.innerHTML = '';
q.options.forEach((w, i) => { ... });
// timer
startTimer();
}
```
Sentence: "The elephant was ___." — the blank should be visible. I'll render the sentence with the blank as a styled span. Use innerHTML with the sentence where `___` is replaced by `?`. But the definition is plain text. Fine — I control the content, no user input, so innerHTML is safe here. Actually let's use textContent for definition and innerHTML for sentence (built from trusted data).
Hmm, careful: I'll build the sentence string and replace '___' with ''.
Timer:
```js
const QUESTION_TIME = 15000;
function startTimer(){
clearInterval(state.timerId);
state.timeLeft = QUESTION_TIME;
updateTimerBar();
state.timerId = setInterval(()=>{
state.timeLeft -= 100;
if(state.timeLeft <= 0){ state.timeLeft = 0; updateTimerBar(); handleTimeout(); }
else updateTimerBar();
}, 100);
}
function updateTimerBar(){
const pct = state.timeLeft / QUESTION_TIME * 100;
timerFill.style.width = pct + '%';
timerFill.style.background = pct > 50 ? 'linear-gradient(90deg,#4ade80,#22d3ee)' : pct > 25 ? 'linear-gradient(90deg,#fbbf24,#f97316)' : 'linear-gradient(90deg,#f87171,#ef4444)';
}
```
handleAnswer(buttonEl, word):
```js
function handleAnswer(btn, word){
if(state.locked) return;
state.locked = true;
clearInterval(state.timerId);
const q = state.current;
const isCorrect = word === q.target.word;
if(isCorrect){
state.correctCount++;
state.streak++;
const timeBonus = Math.round(state.timeLeft / 1000) * 5;
const streakBonus = Math.min(state.streak - 1, 5) * 20;
const gained = 100 + timeBonus + streakBonus;
state.score += gained;
btn.classList.add('popped');
burst(btn.parentElement);
sfxCorrect();
showToast(`+${gained} ${state.streak > 1 ? '🔥 Streak x' + state.streak : ''}`, 'good');
speak(q.target.word);
setTimeout(nextQuestion, 1000);
} else {
state.streak = 0;
state.lives--;
btn.classList.add('wrong');
sfxWrong();
// reveal correct
[...bubblesEl.querySelectorAll('.bubble')].forEach(b=>{ if(b.dataset.word === q.target.word) b.classList.add('correct'); });
showToast(`Not quite — "${q.target.word}" means ${q.target.definition}`, 'bad');
setTimeout(()=>{ if(state.lives<=0) endGame(); else nextQuestion(); }, 1800);
}
updateHUD();
}
```
Careful: after a wrong answer, lives might be 0 → end game.
Timeout: same as wrong but no button.
nextQuestion: qIndex++, if qIndex >= totalQ → endGame else renderQuestion.
Wait, I'm using `state.qIndex` to index into `state.questions`. Let me store `state.questions` array and `state.qIndex`.
Actually simpler: keep a queue. Let me just use the array.
Let me restructure:
```js
function startGame(){
state.score=0; state.lives=3; state.streak=0; state.qIndex=0; state.correctCount=0;
state.questions = buildQuestions();
updateHUD();
showScreen(null);
renderQuestion();
}
```
renderQuestion uses `state.questions[state.qIndex]`.
nextQuestion: `state.qIndex++; if(state.qIndex >= state.questions.length) endGame(); else renderQuestion();`
HUD: score, question `qIndex+1 / total`, streak, lives hearts.
Lives display: render ❤️ for remaining, 🖤 for lost.
End screen:
- Title: "Game Over!" or "Great job!"
- Score, correct/total, accuracy, best score (localStorage).
- Buttons: Play Again.
Let me also add a "Perfect!" special message.
localStorage might not be available in some sandboxes; wrap in try/catch.
Now, the start screen: title "Word Pop!", subtitle "5th Grade Vocabulary Challenge", how to play list, Start button. Also a "Sound on/off" toggle.
Let me write it.
Also, accessibility: buttons with aria-labels, keyboard support (buttons are natively focusable; add number keys 1-4 to select). Nice touch.
Let me now write the final code.
One more consideration: `speak()` on correct answer — if sound is muted, don't speak. Toggle.
Let me write the CSS in full.
```css
:root{
--card:#ffffff;
--ink:#221a4a;
--good:#22c55e;
--bad:#ef4444;
}
```
Star background: I'll add `.stars` div with multiple box-shadows generated in JS? Overkill. Use CSS radial-gradients:
```css
body::before{
content:'';
position:fixed; inset:0;
background-image:
radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.8), transparent),
radial-gradient(1.5px 1.5px at 70% 15%, rgba(255,255,255,.7), transparent),
...
pointer-events:none;
}
```
Fine, I'll include a handful.
Let me write the whole thing now, carefully.
Also responsive: on small screens, bubbles grid stays 2 columns; font shrinks.
Overlay screens: fixed, backdrop blur, centered card.
I'll write the code.
```html
Word Pop! · 5th Grade Vocabulary
Score0
Word1/10
Streak0
Lives❤️❤️❤️
🎁
Which word means…
…
🫧
Word Pop!
5th Grade Vocabulary Challenge
📖 Read the clue or the sentence.
🫧 Tap the bubble with the right word.
⚡ Answer fast for bonus points!
❤️ You have 3 lives. Good luck!
🏆
Nice work!
You popped 8 of 10 words.
0Score
0%Accuracy
0Best
```
The review section: list the words missed with definitions. That's a nice educational touch. Let me track missed words.
I'll keep a `state.missed = []` of word objects.
Review rendering: show up to 5 missed words: "enormous — very, very big".
Now the JS.
Let me write it fully and double-check logic.
```js
const WORDS = [ ... ];
```
Each: {word, emoji, definition, sentence}
Sentence format: "The elephant was ___." I'll replace `___` with a blank span.
Let me make sure each sentence has exactly one `___`.
Writing out all 35 words... that's fine.
Now code:
```js
const $ = (id) => document.getElementById(id);
const els = {
score: $('scoreVal'),
qcount: $('qVal'),
streak: $('streakVal'),
lives: $('livesVal'),
timerFill: $('timerFill'),
promptEmoji: $('promptEmoji'),
promptLabel: $('promptLabel'),
promptText: $('promptText'),
speakBtn: $('speakBtn'),
bubbles: $('bubbles'),
toast: $('toast'),
startScreen: $('startScreen'),
endScreen: $('endScreen'),
...
};
```
Game constants:
```js
const TOTAL_QUESTIONS = 10;
const QUESTION_TIME = 15000; // ms
```
State object.
Let me write `shuffle`:
```js
const shuffle = (a) => { const r = a.slice(); for(let i=r.length-1;i>0;i--){ const j = Math.floor(Math.random()*(i+1)); [r[i],r[j]]=[r[j],r[i]]; } return r; };
```
buildQuestions:
```js
function buildQuestions(){
const picks = shuffle(WORDS).slice(0, TOTAL_QUESTIONS);
return picks.map((w, i) => {
const type = i % 2 === 0 ? 'definition' : 'sentence';
const distractors = shuffle(WORDS.filter(x => x.word !== w.word)).slice(0, 3);
return { target: w, type, options: shuffle([w, ...distractors]) };
});
}
```
renderQuestion:
```js
function renderQuestion(){
const q = state.questions[state.qIndex];
state.current = q;
state.locked = false;
els.promptEmoji.textContent = q.target.emoji;
if(q.type === 'definition'){
els.promptLabel.textContent = 'Which word means…';
els.promptText.textContent = q.target.definition;
} else {
els.promptLabel.textContent = 'Which word belongs in the blank?';
els.promptText.innerHTML = q.target.sentence.replace('___', '');
}
els.bubbles.innerHTML = '';
q.options.forEach((w, i) => {
const wrap = document.createElement('div');
wrap.className = 'bubble-wrap';
wrap.style.animationDelay = (i * 0.35) + 's';
const btn = document.createElement('button');
btn.className = 'bubble';
btn.type = 'button';
btn.dataset.word = w.word;
btn.textContent = w.word;
btn.addEventListener('click', () => handleAnswer(btn, w.word));
wrap.appendChild(btn);
els.bubbles.appendChild(wrap);
});
updateHUD();
startTimer();
}
```
Wait: updateHUD needs qIndex+1. Fine.
handleAnswer as above.
For the correct-answer reveal in the wrong case, I need to find the button: `els.bubbles.querySelector('[data-word="' + CSS.escape(...) + '"]')`. Words are simple, so just template it. Use `[...document.querySelectorAll('.bubble')].find(b => b.dataset.word === q.target.word)`.
Note: if the same word appears twice? No, options are unique.
burst(container): create ~10 particle spans.
```js
function burst(container){
const colors = ['#ffd166','#06d6a0','#ef476f','#4cc9f0','#b5179e','#ffffff'];
for(let i=0;i<14;i++){
const p = document.createElement('span');
p.className = 'particle';
const angle = Math.random()*Math.PI*2;
const dist = 50 + Math.random()*80;
p.style.setProperty('--x', Math.cos(angle)*dist + 'px');
p.style.setProperty('--y', Math.sin(angle)*dist + 'px');
p.style.background = colors[i % colors.length];
p.style.width = p.style.height = (5 + Math.random()*7) + 'px';
container.appendChild(p);
setTimeout(()=>p.remove(), 700);
}
}
```
CSS:
```css
.particle{
position:absolute; left:50%; top:50%; border-radius:50%;
pointer-events:none;
animation: fly .65s ease-out forwards;
}
@keyframes fly{
from{ transform: translate(-50%,-50%) scale(1); opacity:1; }
to{ transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0); opacity:0; }
}
```
Container needs `position: relative` — the .bubble-wrap is relative. Good, and overflow visible.
Now the toast:
```js
let toastTimer;
function showToast(msg, kind){
els.toast.textContent = msg;
els.toast.className = 'toast show ' + (kind || '');
clearTimeout(toastTimer);
toastTimer = setTimeout(()=>{ els.toast.className = 'toast'; }, 1800);
}
```
Careful: for the wrong answer, the message is long. Make the toast wide and wrapping.
Hmm, the toast for wrong answers shows the definition which is helpful. But it also might spoil for... no, it's after the answer. Fine.
Actually, better: on wrong answer, show the correct word + definition as a small banner. Let's keep the toast.
But wait — the toast for correct is "+150 🔥 Streak x3" — short. For wrong it's longer. Both fine.
Position toast: fixed at top center, below HUD? Let's put it at the top center of the screen, above everything (z-index high), and let it not block clicks (pointer-events:none).
endGame:
```js
function endGame(){
clearInterval(state.timerId);
state.locked = true;
els.bubbles.innerHTML = '';
const total = state.questions.length;
const answered = state.qIndex + (state.correctCount ... )
```
Hmm, computing "answered" — let me track `state.answered` count.
Simpler: correctCount and total questions. Accuracy = correctCount / answeredCount. Let me track `state.answered`.
Actually let's just compute: accuracy = correctCount / Math.max(1, state.answered).
I'll increment state.answered in both handleAnswer and handleTimeout.
End screen:
- If lives <= 0: title "Out of Lives!", emoji "💔"
- Else if correctCount === total: "Perfect Score!" emoji "🏆"
- Else: "Great Job!" emoji "🎉"
Best score in localStorage.
Review: show missed words. `state.missed` array of word objects (unique).
```js
function renderReview(){
if(!state.missed.length){ els.review.innerHTML = '
`
).join('');
}
```
Now the timer bar and `handleTimeout`.
```js
function handleTimeout(){
if(state.locked) return;
state.locked = true;
clearInterval(state.timerId);
state.streak = 0;
state.lives--;
state.answered++;
state.missed.push(state.current.target);
revealCorrect();
sfxWrong();
showToast(`⏰ Time's up! "${state.current.target.word}" means ${state.current.target.definition}`, 'bad');
updateHUD();
setTimeout(()=>{ state.lives <= 0 ? endGame() : nextQuestion(); }, 1900);
}
```
And handleAnswer wrong does the same. Let me refactor into `missAnswer(btn)`.
```js
function missAnswer(btn){
state.locked = true;
clearInterval(state.timerId);
state.streak = 0;
state.lives--;
state.answered++;
state.missed.push(state.current.target);
if(btn) btn.classList.add('wrong');
revealCorrect();
sfxWrong();
updateHUD();
showToast(...);
setTimeout(...);
}
```
Then handleAnswer:
```js
function handleAnswer(btn, word){
if(state.locked) return;
const q = state.current;
if(word === q.target.word){
// correct path
} else {
missAnswer(btn);
}
}
```
Correct path:
```js
state.locked = true;
clearInterval(state.timerId);
state.answered++;
state.correctCount++;
state.streak++;
const timeBonus = Math.round(state.timeLeft/1000) * 5;
const streakBonus = Math.min(state.streak - 1, 5) * 20;
const gained = 100 + timeBonus + streakBonus;
state.score += gained;
btn.classList.add('popped');
burst(btn.parentElement);
sfxCorrect();
speak(q.target.word);
updateHUD();
showToast(...);
setTimeout(nextQuestion, 1100);
```
Also add class 'correct' to the popped button for color.
updateHUD:
```js
function updateHUD(){
els.score.textContent = state.score;
els.qcount.textContent = Math.min(state.qIndex+1, state.questions.length) + '/' + state.questions.length;
els.streak.textContent = state.streak;
els.lives.textContent = '❤️'.repeat(Math.max(0,state.lives)) + '🖤'.repeat(Math.max(0,3-state.lives));
}
```
nextQuestion:
```js
function nextQuestion(){
state.qIndex++;
if(state.qIndex >= state.questions.length || state.lives <= 0){ endGame(); return; }
renderQuestion();
}
```
Careful: if lives hit 0 on the last question, endGame is called twice (once from timeout, once from nextQuestion). Let me guard endGame with a flag or just have missAnswer's setTimeout call nextQuestion which checks lives.
In missAnswer setTimeout: `if(state.lives <= 0){ endGame(); } else { nextQuestion(); }` — and nextQuestion also checks. Let me just always call nextQuestion() and let it handle: if qIndex >= length || lives <= 0 → endGame(). That's cleaner.
But then endGame might be called when qIndex is still < length but lives = 0. Fine.
Add a guard in endGame: `if(state.over) return; state.over = true;`
Set state.over = false in startGame.
Now `speak` and sound toggle.
```js
let soundOn = true;
function setSound(on){ soundOn = on; els.soundBtn.textContent = on ? '🔊 Sound: On' : '🔇 Sound: Off'; if(!on) speechSynthesis?.cancel(); }
```
In sfx functions check soundOn.
Also need to resume AudioContext on user gesture — create it on first click.
Now keyboard support: numbers 1-4 select the nth bubble.
```js
document.addEventListener('keydown', e => {
if(state.locked || els.startScreen.classList.contains('show')) return;
const n = parseInt(e.key, 10);
if(n >= 1 && n <= 4){
const btns = els.bubbles.querySelectorAll('.bubble');
if(btns[n-1]) btns[n-1].click();
}
});
```
Also Escape? Not needed.
Let me also make the prompt "Read aloud" button work: reads the prompt label + text.
```js
els.speakBtn.addEventListener('click', () => {
const q = state.current;
if(!q) return;
const text = q.type === 'definition' ? q.target.definition : q.target.sentence.replace('___','blank');
speak(text);
});
```
Now let's write the CSS in detail.
```css
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent;}
body{
font-family:"Trebuchet MS","Segoe UI",system-ui,-apple-system,sans-serif;
min-height:100dvh;
background:#0e0a24;
color:#fff;
display:flex; justify-content:center; align-items:flex-start;
padding:14px;
overflow-x:hidden;
}
.sky{
position:fixed; inset:0; z-index:-1;
background:
radial-gradient(900px 600px at 12% -5%, #4a2fa8 0%, transparent 60%),
radial-gradient(800px 600px at 95% 10%, #1b6fb5 0%, transparent 55%),
radial-gradient(700px 700px at 50% 110%, #8e2f8a 0%, transparent 60%),
linear-gradient(180deg,#150f33,#0b0820 70%);
}
.sky::after{
content:""; position:absolute; inset:0;
background-image:
radial-gradient(1.5px 1.5px at 15% 20%, #fff9, transparent),
radial-gradient(1.5px 1.5px at 42% 8%, #fff7, transparent),
radial-gradient(1px 1px at 68% 25%, #fff8, transparent),
radial-gradient(1.5px 1.5px at 85% 12%, #fff6, transparent),
radial-gradient(1px 1px at 30% 45%, #fff5, transparent),
radial-gradient(1px 1px at 78% 55%, #fff5, transparent),
radial-gradient(1.5px 1.5px at 55% 70%, #fff4, transparent),
radial-gradient(1px 1px at 8% 72%, #fff5, transparent);
animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle{ from{opacity:.55} to{opacity:1} }
```
App container:
```css
.app{
width:min(880px,100%);
display:flex; flex-direction:column; gap:12px;
padding-bottom:20px;
}
```
HUD:
```css
.hud{
display:grid; grid-template-columns: repeat(4,1fr); gap:8px;
}
.hud-box{
background:rgba(255,255,255,.08);
border:1px solid rgba(255,255,255,.14);
border-radius:14px;
padding:8px 6px;
text-align:center;
backdrop-filter: blur(6px);
}
.hud-label{display:block; font-size:.65rem; letter-spacing:1.5px; text-transform:uppercase; color:#b9b3e6;}
.hud-value{display:block; font-size:1.05rem; font-weight:800; margin-top:2px;}
```
Timer:
```css
.timer-track{
height:12px; border-radius:99px; overflow:hidden;
background:rgba(255,255,255,.1);
border:1px solid rgba(255,255,255,.12);
}
.timer-fill{
height:100%; width:100%; border-radius:99px;
background:linear-gradient(90deg,#4ade80,#22d3ee);
transition: width .1s linear, background .3s;
}
```
Prompt card:
```css
.prompt-card{
position:relative;
background:linear-gradient(160deg,#ffffff,#eef1ff);
color:#241a55;
border-radius:22px;
padding:20px 18px 16px;
text-align:center;
box-shadow:0 16px 34px rgba(0,0,0,.4);
min-height:170px;
display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px;
}
.prompt-emoji{font-size:2.6rem; line-height:1; filter:drop-shadow(0 4px 8px rgba(0,0,0,.15));}
.prompt-label{font-size:.72rem; text-transform:uppercase; letter-spacing:1.6px; color:#7b74ad; font-weight:700;}
.prompt-text{font-size:clamp(1.1rem,3.4vw,1.5rem); font-weight:800; line-height:1.35; max-width:34ch;}
.blank{
display:inline-block; min-width:72px; border-bottom:3px dashed #7c6cf0; vertical-align:-4px; margin:0 4px;
}
```
Read aloud button:
```css
.ghost-btn{
margin-top:8px;
background:rgba(36,26,85,.08);
color:#4a3fa0;
border:1.5px solid rgba(74,63,160,.3);
border-radius:99px;
padding:6px 14px;
font:inherit; font-size:.8rem; font-weight:700;
cursor:pointer;
transition:.15s;
}
.ghost-btn:hover{background:rgba(74,63,160,.16); transform:translateY(-1px);}
```
Bubbles:
```css
.bubbles{
display:grid; grid-template-columns:1fr 1fr; gap:12px;
}
.bubble-wrap{
position:relative;
animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob{ 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }
.bubble{
width:100%;
padding:20px 10px;
border:none; border-radius:20px;
font-family:inherit;
font-size:clamp(1rem,3vw,1.35rem);
font-weight:800; letter-spacing:.4px;
color:#241a55;
cursor:pointer;
background:linear-gradient(165deg,#ffffff,#dbe2ff);
box-shadow:0 7px 0 #9aa6e0, 0 14px 22px rgba(0,0,0,.35);
transition:transform .1s ease, box-shadow .1s ease, background .2s ease;
}
.bubble:hover{ transform:translateY(-3px); box-shadow:0 10px 0 #9aa6e0, 0 18px 26px rgba(0,0,0,.4); }
.bubble:active{ transform:translateY(3px); box-shadow:0 3px 0 #9aa6e0, 0 6px 12px rgba(0,0,0,.35); }
.bubble.correct{
background:linear-gradient(165deg,#5ee88a,#16a34a);
color:#06301a;
box-shadow:0 7px 0 #0f7a37, 0 0 0 4px rgba(94,232,138,.35);
}
.bubble.wrong{
background:linear-gradient(165deg,#ff8a8a,#dc2626);
color:#fff;
animation:shake .4s;
box-shadow:0 7px 0 #991b1b;
}
@keyframes shake{
0%,100%{transform:translateX(0)}
20%{transform:translateX(-9px)}
40%{transform:translateX(9px)}
60%{transform:translateX(-6px)}
80%{transform:translateX(6px)}
}
.bubble.popped{
animation:popOut .55s ease-out forwards;
pointer-events:none;
}
@keyframes popOut{
0%{transform:scale(1)}
40%{transform:scale(1.12); background:linear-gradient(165deg,#5ee88a,#16a34a); color:#06301a;}
100%{transform:scale(.55); opacity:0;}
}
```
Hmm, the popped animation includes background change but the transition on background may conflict; it's fine since animation overrides.
Also `.bubble:disabled`? Not using disabled.
Particles:
```css
.particle{
position:absolute; left:50%; top:50%;
width:8px; height:8px; border-radius:50%;
pointer-events:none; z-index:5;
animation:fly .65s ease-out forwards;
}
@keyframes fly{
from{ transform:translate(-50%,-50%) scale(1); opacity:1; }
to{ transform:translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(.2); opacity:0; }
}
```
Toast:
```css
.toast{
position:fixed; left:50%; top:14px; transform:translate(-50%,-140%);
background:rgba(20,14,50,.92);
border:1px solid rgba(255,255,255,.18);
color:#fff;
padding:10px 18px;
border-radius:14px;
font-weight:700;
font-size:.9rem;
max-width:min(560px,92vw);
text-align:center;
box-shadow:0 12px 30px rgba(0,0,0,.5);
transition:transform .3s cubic-bezier(.2,1.3,.5,1), opacity .3s;
opacity:0; pointer-events:none; z-index:50;
}
.toast.show{ transform:translate(-50%,0); opacity:1; }
.toast.good{ border-color:#4ade80; box-shadow:0 0 24px rgba(74,222,128,.35); }
.toast.bad{ border-color:#f87171; box-shadow:0 0 24px rgba(248,113,113,.3); }
```
Overlay:
```css
.overlay{
position:fixed; inset:0; z-index:100;
display:flex; align-items:center; justify-content:center;
padding:18px;
background:rgba(8,5,24,.82);
backdrop-filter:blur(8px);
opacity:0; pointer-events:none;
transition:opacity .3s;
}
.overlay.show{ opacity:1; pointer-events:auto; }
.panel{
width:min(520px,100%);
max-height:92dvh; overflow-y:auto;
background:linear-gradient(165deg,#241a55,#150f33);
border:1px solid rgba(255,255,255,.15);
border-radius:26px;
padding:26px 22px;
text-align:center;
box-shadow:0 30px 70px rgba(0,0,0,.6);
animation:panelIn .4s cubic-bezier(.2,1.2,.4,1);
}
@keyframes panelIn{ from{transform:scale(.9) translateY(18px); opacity:0} to{transform:none; opacity:1} }
.panel-emoji{font-size:3rem;}
.panel h1{font-size:clamp(1.7rem,6vw,2.4rem); margin:6px 0 4px; letter-spacing:.5px;
background:linear-gradient(90deg,#ffd166,#4cc9f0,#b5179e); -webkit-background-clip:text; background-clip:text; color:transparent;}
.tagline{color:#b9b3e6; font-size:.95rem; margin-bottom:14px;}
.how{ list-style:none; text-align:left; display:inline-block; margin:0 auto 18px; color:#ded9ff; font-size:.92rem; line-height:1.9;}
.primary-btn{
display:block; width:100%;
padding:15px;
border:none; border-radius:16px;
font-family:inherit; font-size:1.1rem; font-weight:800; letter-spacing:.5px;
color:#0e0a24; cursor:pointer;
background:linear-gradient(160deg,#ffd166,#ff9f1c);
box-shadow:0 6px 0 #b76e00, 0 12px 24px rgba(255,159,28,.35);
transition:transform .1s, box-shadow .1s;
}
.primary-btn:hover{ transform:translateY(-2px); box-shadow:0 8px 0 #b76e00, 0 16px 28px rgba(255,159,28,.45); }
.primary-btn:active{ transform:translateY(3px); box-shadow:0 2px 0 #b76e00; }
```
The panel's ghost-btn needs different colors since the panel is dark:
```css
.panel .ghost-btn{ color:#cfc9ff; border-color:rgba(207,201,255,.35); background:rgba(255,255,255,.06); margin-top:10px; }
.panel .ghost-btn:hover{ background:rgba(255,255,255,.14); }
```
Stats:
```css
.stats{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:14px 0; }
.stat{ background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.12); border-radius:16px; padding:12px 6px; }
.stat span{ display:block; font-size:1.4rem; font-weight:800; color:#ffd166; }
.stat small{ display:block; font-size:.68rem; letter-spacing:1.2px; text-transform:uppercase; color:#a9a2d8; margin-top:2px;}
```
Review:
```css
.review{ text-align:left; margin:6px 0 16px; }
.review-title{ font-size:.8rem; text-transform:uppercase; letter-spacing:1.4px; color:#a9a2d8; margin-bottom:8px; text-align:center;}
.review-item{ display:flex; flex-direction:column; background:rgba(255,255,255,.06); border-left:3px solid #4cc9f0; border-radius:10px; padding:8px 12px; margin-bottom:7px; }
.review-item strong{ color:#7ee0ff; font-size:.95rem;}
.review-item span{ font-size:.82rem; color:#cfc9ff;}
```
Responsive:
```css
@media (max-width:420px){
.hud-value{font-size:.92rem;}
.bubble{padding:16px 8px;}
.prompt-card{min-height:150px; padding:16px 12px;}
}
```
Also `@media (prefers-reduced-motion: reduce)` to disable animations.
Now let me assemble everything. I need to be careful the code is complete and correct.
One thing: `state.over` guard, and `state.answered`.
Also on the end screen, the "qcount" HUD.
Also when the game ends, the HUD shows the final state.
Also I should stop the timer on endGame.
Let me also handle: the start screen shows initially with `.show`.
`startGame()` hides the start screen and end screen.
```js
function startGame(){
initAudio();
state = {...} // reassign properties
}
```
Since state is `const state = {...}`, mutate properties.
Let me write:
```js
const state = {
score: 0, lives: 3, streak: 0, qIndex: 0, answered: 0, correctCount: 0,
questions: [], current: null, locked: true, timeLeft: 0, timerId: null,
missed: [], over: false
};
```
startGame:
```js
function startGame(){
initAudio();
Object.assign(state, {
score:0, lives:3, streak:0, qIndex:0, answered:0, correctCount:0,
questions: buildQuestions(), current:null, locked:true,
timeLeft:0, missed:[], over:false
});
clearInterval(state.timerId);
els.startScreen.classList.remove('show');
els.endScreen.classList.remove('show');
renderQuestion();
}
```
renderQuestion sets locked=false.
Note: `els.qcount` uses `state.questions.length`.
Edge case: `updateHUD` called in renderQuestion after building bubbles — state.qIndex is correct.
Now let me finalize the word list with sentences. Ensure each has `___`.
I'll write them out.
Let me double check a few definitions for 5th-grade accuracy.
Now, one more feature: after a correct answer, speak the word. Good for pronunciation.
Let's write the final code.
Also add `` maybe. Not needed.
Let me write out the JS word array:
```js
const WORDS = [
{ word:"enormous", emoji:"🐘", definition:"very, very big", sentence:"The elephant was ___ — it filled the whole truck!" },
{ word:"curious", emoji:"🧐", definition:"wanting to know or learn more", sentence:"The ___ kitten peeked inside every box." },
{ word:"brave", emoji:"🦁", definition:"not afraid, even when things are scary", sentence:"The ___ firefighter ran into the burning house." },
{ word:"ancient", emoji:"🏺", definition:"very old, from long ago", sentence:"We explored ___ ruins in the desert." },
{ word:"generous", emoji:"🎁", definition:"happy to give and share with others", sentence:"She was ___ and shared her lunch with me." },
{ word:"fragile", emoji:"🥚", definition:"easily broken or damaged", sentence:"Please carry the ___ glass vase carefully." },
{ word:"furious", emoji:"😡", definition:"extremely angry", sentence:"Dad was ___ when we broke the window." },
{ word:"delighted", emoji:"😄", definition:"very pleased and happy", sentence:"I was ___ to see my best friend at the party." },
{ word:"exhausted", emoji:"😴", definition:"very tired, with no energy left", sentence:"After the long race, we were completely ___." },
{ word:"peculiar", emoji:"🤪", definition:"strange or unusual", sentence:"That's a ___ smell — what is it?" },
{ word:"swift", emoji:"⚡", definition:"very fast", sentence:"The ___ runner won the race easily." },
{ word:"silent", emoji:"🤫", definition:"making no sound at all", sentence:"The library was completely ___." },
{ word:"magnificent", emoji:"🌟", definition:"extremely beautiful or grand", sentence:"From the hill we saw a ___ view of the city." },
{ word:"stubborn", emoji:"🐴", definition:"refusing to change your mind", sentence:"He was too ___ to admit he was wrong." },
{ word:"cautious", emoji:"⚠️", definition:"careful to avoid danger", sentence:"Be ___ when you cross the busy road." },
{ word:"vanish", emoji:"💨", definition:"to disappear suddenly", sentence:"The magician made the rabbit ___ into thin air." },
{ word:"sturdy", emoji:"🌳", definition:"strong and not easily broken", sentence:"The ___ bridge held the heavy truck." },
{ word:"shimmer", emoji:"✨", definition:"to shine with a soft, unsteady light", sentence:"The stars ___ in the night sky." },
{ word:"grasp", emoji:"🤝", definition:"to hold on to something tightly", sentence:"She ___ the rope with both hands." },
{ word:"voyage", emoji:"🚢", definition:"a long journey, especially by sea", sentence:"The sailors set out on a long ___ across the ocean." },
{ word:"habitat", emoji:"🏞️", definition:"the natural home of a plant or animal", sentence:"The forest is the bear's natural ___." },
{ word:"predict", emoji:"🔮", definition:"to say what you think will happen", sentence:"Can you ___ how the story will end?" },
{ word:"observe", emoji:"🔍", definition:"to watch something carefully", sentence:"Scientists ___ the birds every morning." },
{ word:"invent", emoji:"💡", definition:"to create something brand new", sentence:"He wanted to ___ a car that could fly." },
{ word:"courage", emoji:"🛡️", definition:"being brave when something is hard", sentence:"It took ___ to speak in front of the whole class." },
{ word:"attempt", emoji:"🎯", definition:"to try to do something", sentence:"I will ___ the math problem one more time." },
{ word:"necessary", emoji:"✅", definition:"needed; very important to have", sentence:"Water is ___ for all living things." },
{ word:"crowded", emoji:"👥", definition:"full of people or things", sentence:"The market was so ___ that we could hardly move." },
{ word:"translate", emoji:"🌐", definition:"to change words into another language", sentence:"Can you ___ this sentence into Spanish?" },
{ word:"tremble", emoji:"🥶", definition:"to shake slightly", sentence:"Her hands began to ___ in the cold wind." },
{ word:"glide", emoji:"🛝", definition:"to move smoothly and easily", sentence:"The skater seemed to ___ across the ice." },
{ word:"precious", emoji:"💎", definition:"very valuable and important", sentence:"This old ring is ___ to our family." },
{ word:"echo", emoji:"🔊", definition:"a sound that bounces back to you", sentence:"We heard our voices ___ through the cave." },
{ word:"drowsy", emoji:"🥱", definition:"sleepy and ready to rest", sentence:"The warm room made everyone feel ___." },
{ word:"gigantic", emoji:"🦕", definition:"extremely large; huge", sentence:"A ___ dinosaur skeleton stood in the museum." }
];
```
35 words. Good.
Note: "echo" sentence uses "echo" as a verb, but the definition is a noun. Minor mismatch. Let me change definition to "a sound that bounces back" and sentence "We heard our voices ___ through the cave." — as a verb "echo" works: "our voices echo through the cave". Slight mismatch but acceptable. Better: change sentence to "An ___ bounced back from the canyon walls." That makes it a noun. Let's do that.
Similarly check "attempt" — definition "to try", sentence "I will ___ the math problem one more time." — verb. Good.
"grasp" — "to hold on to something tightly", sentence "She ___ the rope with both hands." Good.
"tremble" — verb, sentence "Her hands began to ___ in the cold wind." Good.
"observe" — verb. Good.
"predict" — verb. Good.
"invent" — verb. Good.
"translate" — verb. Good.
"glide" — verb. Good.
"shimmer" — verb. Good.
"vanish" — verb. Good.
"courage" — noun. "It took ___ to speak..." Good.
"voyage" — noun. Good.
"habitat" — noun. Good.
"attempt" — hmm, could be noun too. Fine.
"necessary" — adjective. Good.
"crowded" — adjective. Good.
"precious" — adjective. Good.
"drowsy" — adjective. Good.
"gigantic" — adjective. Good.
OK.
Now, the distractors: random. For sentence type, a verb distractor in an adjective slot would be obviously wrong. That's fine for 5th grade — actually it makes it easier. Acceptable. But to make it slightly better, I could match part of speech. Let me add a `pos` field and prefer distractors with the same pos when possible.
Let me add pos: 'adj', 'verb', 'noun'.
- enormous adj
- curious adj
- brave adj
- ancient adj
- generous adj
- fragile adj
- furious adj
- delighted adj
- exhausted adj
- peculiar adj
- swift adj
- silent adj
- magnificent adj
- stubborn adj
- cautious adj
- vanish verb
- sturdy adj
- shimmer verb
- grasp verb
- voyage noun
- habitat noun
- predict verb
- observe verb
- invent verb
- courage noun
- attempt verb
- necessary adj
- crowded adj
- translate verb
- tremble verb
- glide verb
- precious adj
- echo noun
- drowsy adj
- gigantic adj
Distractor selection: same pos first, then fill with others if not enough.
```js
function pickDistractors(target){
const same = shuffle(WORDS.filter(w => w.word !== target.word && w.pos === target.pos));
const other = shuffle(WORDS.filter(w => w.word !== target.word && w.pos !== target.pos));
return [...same, ...other].slice(0,3);
}
```
Good. But then for adjectives, all 4 options are adjectives — harder and better pedagogically. For nouns, there are only 4 nouns (voyage, habitat, courage, echo) — so distractors would include 3 others = all 4 nouns together. That's fine.
Hmm, but that means noun questions always have the same 4 options. Acceptable. Maybe add a couple more nouns to the bank. Let me add:
- "journey" noun — "a trip from one place to another" — "Our ___ to the mountains took six hours." But "voyage" is similar. Fine, adds challenge.
- "wisdom" noun — "good sense learned from experience" — "The old woman shared her ___ with us."
- "talent" noun — "a natural skill" — "She has a ___ for drawing."
Let me add a few more nouns to balance: journey, wisdom, talent. And maybe "silence" noun.
Actually let's keep it manageable. I'll add: journey, wisdom, talent. Now 7 nouns.
Also verbs: vanish, shimmer, grasp, predict, observe, invent, attempt, translate, tremble, glide = 10 verbs. Good.
Adjectives: 18. Good.
Total: 18 + 10 + 7 = 35. Wait, I had 35 originally; adding 3 makes 38. Let me recount.
Original list of 35:
adj: enormous, curious, brave, ancient, generous, fragile, furious, delighted, exhausted, peculiar, swift, silent, magnificent, stubborn, cautious, sturdy, necessary, crowded, precious, drowsy, gigantic = 21
verb: vanish, shimmer, grasp, predict, observe, invent, attempt, translate, tremble, glide = 10
noun: voyage, habitat, courage, echo = 4
Total = 35. ✓
Adding journey, wisdom, talent → nouns = 7, total = 38.
Now TOTAL_QUESTIONS = 10. Fine.
Let me finalize.
Now writing the code. I'll be thorough.
One more detail: `speak()` — cancel before speaking to avoid queue buildup.
Also, speech synthesis may not be available; guard.
Let me write out the final answer with explanation.
Also, I should make sure clicking during the locked state does nothing — handled by `state.locked`.
Also, buttons should be disabled visually? Not necessary.
Let me write the endGame function:
```js
function endGame(){
if(state.over) return;
state.over = true;
clearInterval(state.timerId);
state.locked = true;
els.bubbles.innerHTML = '';
const total = state.questions.length;
const acc = state.answered ? Math.round((state.correctCount / state.answered) * 100) : 0;
let best = 0;
try { best = parseInt(localStorage.getItem('wordpop_best') || '0', 10) || 0; } catch(e){}
if(state.score > best){ best = state.score; try{ localStorage.setItem('wordpop_best', String(best)); }catch(e){} }
let emoji = '🎉', title = 'Great job!';
if(state.lives <= 0){ emoji = '💔'; title = 'Out of lives!'; }
else if(state.correctCount === total){ emoji = '🏆'; title = 'Perfect score!'; }
else if(state.correctCount >= total * 0.7){ emoji = '🌟'; title = 'Well done!'; }
els.endEmoji.textContent = emoji;
els.endTitle.textContent = title;
els.endSub.textContent = `You got ${state.correctCount} of ${total} words right.`;
els.endScore.textContent = state.score;
els.endAcc.textContent = acc + '%';
els.endBest.textContent = best;
renderReview();
els.endScreen.classList.add('show');
sfxGameOver();
}
```
Hmm, `state.answered` may be less than total if lives ran out early. Then endSub "You got X of TOTAL right" is a bit off. Let's say `You answered ${state.answered} questions and got ${state.correctCount} right.`
Better.
sfxGameOver only if not a perfect score? Just play it.
Also: if the player has lives left and finishes all 10, title is based on score.
Alright.
One more: `renderReview` uses `state.missed`.
Let me write it all out now.
I also want the bubbles to not be re-created with the bob animation restarting weirdly — fine.
Potential issue: `els.promptText.innerHTML` with the sentence — the sentence contains `___`, replaced by the span. Good.
For the "Read aloud" of a sentence, replace `___` with "blank".
Let me write the final code.
Also need to handle `initAudio` — call it on start button click.
```js
let audioCtx = null;
function initAudio(){
if(!audioCtx){
const AC = window.AudioContext || window.webkitAudioContext;
if(AC) audioCtx = new AC();
}
if(audioCtx && audioCtx.state === 'suspended') audioCtx.resume();
}
```
tone function guards `if(!audioCtx || !soundOn) return;`
OK writing now.
Final check on the layout: `.app` has `display:flex; flex-direction:column`. The stage contains prompt-card and bubbles.
Let me write `main.stage` with `display:flex; flex-direction:column; gap:14px;`.
Alright, writing the complete file.
I'll also add a subtle instruction line under the bubbles? Not needed.
Let me produce the final answer with a brief intro, the full code, and notes on how to use/extend.
### assistant · answer
Here's a complete, ready-to-run HTML game that helps fifth graders practice English vocabulary by matching words to clues or fill-in-the-blank sentences.
```html
Word Pop! · 5th Grade Vocabulary
Score0
Word1/10
Streak0
Lives❤️❤️❤️
🎁
Which word means…
…
🫧
Word Pop!
5th Grade Vocabulary Challenge
📖 Read the clue or the sentence.
🫧 Tap the bubble with the right word.
⚡ Answer fast for bonus points!
🔥 Build a streak for even more points.
❤️ You have 3 lives. Good luck!
🏆
Nice work!
0Score
0%Accuracy
0Best
```
### Gameplay & Learning Mechanics
This vocabulary game turns quiz practice into a fast, playful bubble-popping challenge.
- **Question flow:** Each round shows either a definition ("very, very big") or a sentence with a blank, along with four word bubbles. Players tap the correct word before the timer runs out.
- **Scoring & streaks:** Correct answers earn base points plus time and streak bonuses. Wrong answers or timeouts cost one of three lives, and the game ends when all lives are gone or all ten questions are answered.
- **Immediate feedback:** Correct picks trigger green pops, confetti, a cheerful chime, and spoken pronunciation. Wrong picks reveal the correct answer and explain the meaning in a toast message.
- **Review & replay:** The end screen shows score, accuracy, best score, and a list of missed words for quick review, with a button to play again.
The game also supports keyboard shortcuts (1–4) and a sound toggle.
---
**Optimization Tip:** You can adjust `TOTAL_QUESTIONS`, `QUESTION_TIME`, or `START_LIVES` near the top of the script to change round length, difficulty, or number of lives. The `WORDS` array is easy to replace with your own vocabulary list.