โ† back to the bees

๐Ÿ beelieve.html

a design document โ€” how beelieveInYourself was built, what broke, and how we fixed it

// what is this project

beelieveInYourself is a GitHub Pages website that renders the entire Bee Movie script word by word, filling the screen with alternating yellow and black text while a text-to-speech voice reads it aloud. It has a progress bar with 15 collectible milestones mapped to exact moments in the script, and a start screen where you can configure voice, pitch, and speed.

It was built entirely through a conversation with Claude (AI), iterating on bugs, ideas, and vibes. This document is a record of that process.

HTML CSS JavaScript Web Speech API GitHub Pages the bee movie (2007)

// tl;dr

// how it started

If you had the bee movie script could we somehow make it play each word one by one and fill up the entire page? You go there and hit start and then the words of the bee movie will run and fill the webpage. Make a new folder for this project called beelieveInYourself.

The initial idea was simple: word by word, filling the screen. The bee movie script was sourced locally from the Downloads folder. The first build used fetch() to load a script.txt file, with a speed slider and a start button.

// build timeline

1. the first build

Basic HTML page. Words appended one at a time using setInterval. Speed slider (1โ€“10). Auto-scroll to bottom. Dark background, yellow text.

2. visual redesign

The background should be grey and the words should alternate between yellow and black.

Background changed to grey. Every even-indexed word renders yellow (#f5c800), every odd word renders near-black (#111). The script file was renamed to vibes.txt to match what was already in the folder.

3. pushing to github pages

The repo was created manually on GitHub and pushed via git. During this process we hit a diverged history problem โ€” the README was created on GitHub directly, which conflicted with local commits. A force push resolved it.

๐Ÿ› bug โ€” file picker opening on start The fetch() call to load vibes.txt was failing silently when opening the file directly in a browser via file:// protocol. The fallback code opened a file picker dialog instead of just starting.
โœ… fix Removed the file picker fallback entirely. fetch() works correctly on GitHub Pages (HTTP), just not locally via file://. Replaced the fallback with a simple alert.

4. bigger speed slider + milestone markers

Can you make the slider bigger so there are more speed options? Also there should be milestones in the progress bar if you can find some of those.

Speed slider expanded from 1โ€“10 to 1โ€“50. Progress bar upgraded from a plain bar to one with 14 milestone dot markers. Each dot has a hover label. A toast notification pops up at the top of the screen when a milestone is reached.

5. text-to-speech added

Let's do the Web Speech API โ€” I'd also like that before you press start you set the pitch and voice.

Added the browser's built-in window.speechSynthesis API. No library, no API key, works entirely in the browser. The start screen gained a pitch slider and a voice dropdown populated from the browser's installed voices. The speed slider now also controls the TTS rate.

๐Ÿ› bug โ€” text speed and voice speed out of sync The setInterval word timer ran independently from the TTS, so words appeared on screen at a different rate than the voice was speaking them.
โœ… fix โ€” TTS drives the display Removed setInterval entirely. Words now appear when the voice speaks them, using utterance.onend to chain to the next word. The voice became the clock.

6. natural speech chunks

Can we make it more human by saying 4 words at a time? Or if the end is less than 4 words, it finishes a sentence to make it sound more human.

Switched from single-word utterances to sentence-aware chunks. The engine collects up to 4 words, then peeks ahead up to 3 more to find the nearest sentence-ending punctuation (. ! ?) and extends to it. This made the TTS sound dramatically more natural.

7. eliminating the gap between chunks

Once it's finished speaking there is still a pause. Can you make it 67% less of a pause?
๐Ÿ› bug โ€” audible pause between utterances Each chunk finished speaking, then the browser overhead of creating the next SpeechSynthesisUtterance caused a noticeable gap before the next chunk started.
โœ… fix โ€” pipeline queuing via onstart Instead of queuing the next utterance in onend of the current one, the next utterance is queued inside onstart of the current one. This means by the time chunk N finishes, chunk N+1 is already loaded and waiting โ€” eliminating most of the gap.

8. pre-rendering + onboundary lighting

What if we render the whole script as grey as the background and then once the voice says it it goes black or yellow? That way the voice is reading in a flow with commas and periods.

Complete architectural rethink. All 9,157 words are pre-rendered to the page as grey <span> elements (same colour as background, so invisible) the moment you press start. The TTS now speaks full sentences rather than 4-word chunks. The onboundary event fires at each word boundary mid-speech and lights up the corresponding span yellow or black in real time. The page scrolls to follow the current word.

A fallback in onend catches any words that onboundary missed (some browsers fire it inconsistently).

9. milestone positions corrected

The milestones don't seem to add up. The yellow and black one is too late compared to where it is in the movie.
๐Ÿ› bug โ€” milestone positions were estimated, not measured The original milestone percentages were rough guesses based on line numbers. "Yellow, black." was set at 2% when it actually appears at word 47 out of 9,157 โ€” just 0.5%.
โœ… fix โ€” PowerShell word search Used PowerShell to scan the actual text and find the exact word index of each iconic phrase. All 15 milestones were remapped to their real positions. A word-positions.txt file was added to the repo with the full breakdown.

10. english-only voices

Can you get rid of the German speakers?

The voice dropdown was filtered to only show voices where lang.startsWith('en'). No more accidentally selecting a German synthesiser to read the bee movie script.

// milestone map

There are 15 milestones. Here's where they actually fall in the script:

# milestone word # %
1๐Ÿ Yellow, black. Yellow, black.470.5%
2๐ŸŽ“ Graduation Day2983.3%
3๐ŸŒป Pollen Jocks!6927.6%
4๐ŸŒธ She saved my life2,18723.9%
5๐ŸŽท You like jazz?2,25124.6%
6๐Ÿง  Thinking bee!3,11834.1%
7๐Ÿฏ Honey Farms discovered3,76041.1%
8โš–๏ธ The trial begins4,99854.6%
9๐ŸŽค Mr. Sting takes the stand5,39558.9%
10โœŠ FREE THE BEES!6,81774.4%
11๐Ÿ† The bees win!6,83374.6%
12๐ŸŒบ Flowers are dying...7,28479.5%
13โœˆ๏ธ Barry flies the plane8,14288.9%
14๐Ÿ›ฌ Barry, we did it!8,75995.7%
15๐ŸŽฌ No rehearsal for that.9,157100%

// architecture overview

files in the repo

how the display works

  1. On start, all 9,157 words are rendered as grey <span> elements โ€” invisible against the background
  2. The script is split into sentences by punctuation
  3. Sentences are fed to SpeechSynthesisUtterance one at a time
  4. Each sentence pre-queues the next in its onstart handler to minimise gaps
  5. The onboundary event fires at each spoken word, lighting the matching span yellow or black
  6. The page scrolls to follow the current word
  7. Milestone dots on the progress bar light up as their percentage is crossed

11. leaderboard

Now let's add a leaderboard. Before you hit start you enter a name, this name gets recorded and scored by how many words they listened to. You should be able to see the leaderboard on the left side of the screen.

GitHub Pages is static hosting โ€” it can't write to files. We used JSONBin.io as a free JSON storage backend. Scores are stored as {"scores": [{name, score, date}]}. A name input was added to the start screen. Score = number of words lit up by the voice. Saves on pause, on finish, and on tab close via beforeunload. Top 50 scores kept, top 10 shown.

The API key and Bin ID are stored in a config.js file that is listed in .gitignore so it is never committed to the repo.

๐Ÿ› bug โ€” CONFIG not defined on GitHub Pages config.js was gitignored, so it didn't exist on GitHub Pages. The page threw ReferenceError: CONFIG is not defined and nothing worked.
โœ… fix Inlined the config directly into the HTML. The gitignored file still exists locally for clean separation, but the live site has the values baked in.
๐Ÿ› bug โ€” voices not loading on start screen speechSynthesis.getVoices() returns an empty array on first call in Chrome โ€” voices load asynchronously. The dropdown showed "loading voices..." forever.
โœ… fix Added a retry loop that polls every 300ms up to 10 times alongside the onvoiceschanged event handler. Whichever fires first populates the dropdown.

12. infinite recursion bug kills TTS

๐Ÿ› bug โ€” no voice, no word lighting after leaderboard added To hook score-saving into the end of the script, a wrapper function was written: const _orig = speakSentence; function speakSentence(si) { _orig(si); }. JavaScript hoists function declarations to the top of scope, so _orig ended up pointing at the wrapper itself โ€” instant infinite recursion. The whole TTS system crashed silently before a single word was spoken.
โœ… fix Removed the wrapper entirely. The saveScore() call was placed directly inside the real speakSentence function at the point where si >= sentences.length โ€” the natural finish condition.

13. bees

bee.png is in the project folder. Can you add a bunch moving across the screen at all times?

22 <img> elements are spawned via JS on page load. Each gets a random size (108โ€“324px after two rounds of "BIGGER"), random vertical position, random direction (left or right, flipped via scaleX(-1)), random speed (6โ€“24s per pass), staggered negative animation delay so they're already mid-flight on load, and a wobble keyframe animation so they bob up and down as they fly.

14. fixed gameplay header + display modes

We need to make a save progress button when you start. This button should be at the top left as a header. We also need a few more buttons in the header. The way the text is being read right now is called LIST and it's on by default. Also add a text mode where once it's read after 3 seconds the text falls to the bottom of the page and collects at the bottom with physics.

A fixed 44px header bar was added that appears once the script starts. It contains a SAVE button, display mode buttons (LIST / FALL / FLOAT / BOUNCE), and color mode buttons (BEE / RAINBOW / MATRIX / CHAOS). Four display modes were built:

๐Ÿ› bug โ€” scrollIntoView fighting user scroll in FALL/FLOAT/BOUNCE The auto-scroll that follows the current word in LIST mode was still running in other modes, constantly fighting the user's manual scroll.
โœ… fix Wrapped scrollIntoView() in a if (displayMode === 'list') check.
๐Ÿ› bug โ€” FALL words destroyed when scrolling up The scroll listener moved the Matter.js ground body to track the viewport bottom. When the user scrolled back up, the ground moved above the fallen pile, causing Matter.js to violently resolve all the bodies that were now below it.
โœ… fix Added a guard: if (ny <= fallFloorY) return; โ€” the ground only ever moves downward.

15. color modes

We need to make it so that the username is the same... Also what other types of 'funny' text options can we build? Can we make a rainbow text option?

Four color modes were added, selectable via header buttons. A getWordColor(i) function dispatches based on colorMode:

Also fixed in this pass: username deduplication on the leaderboard. Previously the same name accumulated multiple entries. Fixed by filtering out the existing entry for a name before pushing the new one.

16. bee catching + bee respawn

We need to make it so that the bees respawn so there's always 22 on the screen. Also if you click a bee you collect a bee. At the top show 'Bees Collected' and track this on the leaderboard.

Bees became interactive. A catchBee(bee) function was extracted and shared between click handlers and the later virtual mouse system. When caught, a bee scales to zero and fades out, then a new one spawns 800โ€“2000ms later via a spawnBee() function. An activeBeeCount counter keeps the total at 22.

beesCollected tracks session catches. The header shows a live count. The leaderboard entry was extended with a bees field.

17. achievements system

Can we add achievements that store locally? Bee catching milestones: 1, 50, 100, 1k, 10k, 50k, 100k, 1M. Time listening: 1 minute, 10 minutes, 1 hour, 10 hours, 24 hours, 72 hours, 1 week. Mode discovery achievements, one per display/color mode.

A full achievement system was added. All data lives in localStorage under a single beelieve_progress key as a JSON object. The ACHIEVEMENTS array defines every achievement with an id, cat, threshold, icon, name, and desc.

A toast notification slides in from the bottom-right when an achievement unlocks. An achievements modal (opened from the header or landing page) shows all achievements in a grid, locked ones dimmed, with progress bars for threshold-based ones.

18. cookie-clicker shop + BPS

Make this like cookie clicker. We need next to the bee collected a shop icon. Buy upgrades with the total bees collected. One of the upgrades should be a virtual mouse that zooms around the screen and clicks on bees. We also need bees per second (BPS) as a tracker.

A full idle-game economy was built around honey (๐Ÿฏ) as currency:

The Virtual Mouse upgrade spawns animated ๐Ÿ–ฑ๏ธ cursor elements that visually hunt bees โ€” they transition to a random bee's position every ~700ms, trigger a click animation, and call catchBee() on whatever bee they reach. They freeze when paused.

๐Ÿ› bug โ€” TDZ crash: can't access 'fallBodies' before initialization (ร—2) The masterRAF IIFE ran immediately at parse time and referenced fallBodies and bouncingWords, which were declared with let further down in the script. JavaScript's temporal dead zone (TDZ) throws a ReferenceError for let before its declaration. The same issue appeared later with syncVirtualMice() referencing running.
โœ… fix Moved all let fallBodies, let bouncingWords declarations to before the IIFE. Moved syncVirtualMice() call to after the let running = false declaration.

19. mobile + iOS Safari support

We now need a solid mobile update so it works on mobile. Currently going to the site on Safari on my iPhone doesn't do anything โ€” no text gets read or changed to colors.

iOS Safari has several specific restrictions on the Web Speech API and touch handling:

๐Ÿ› bug โ€” speech never starts on iOS Safari speechSynthesis.speak() on iOS must be called synchronously within a direct user gesture. The start button handler did await fetch(SCRIPT_FILE) before calling speakSentence(). The await breaks the gesture context โ€” iOS blocks the speech call as non-user-initiated.
โœ… fix โ€” gesture priming A silent SpeechSynthesisUtterance('') is spoken and immediately cancelled synchronously at the very top of the click handler, before any await. This primes the browser's gesture context, allowing the real speech to start later.
๐Ÿ› bug โ€” onboundary never fires on iOS Safari iOS Safari does not fire onboundary events at all. Without them, no words light up.
โœ… fix โ€” character-rate fallback timer Added a fallback: when onstart fires and no boundary has ever been seen, a scheduleFallback() function advances words one at a time using a timer calculated from (charLen / charsPerSec) * 1000. If real boundary events start arriving, the fallback cancels itself.
๐Ÿ› bug โ€” iOS speech silently stalls after ~30 seconds A known iOS Safari bug causes speechSynthesis to silently pause mid-playback, with speaking still returning true.
โœ… fix โ€” watchdog interval A 5-second interval checks if speechSynthesis.paused is true while it should be playing, and calls .resume(). Also detects if no boundary event has fired in over 8 seconds and nudges the synthesiser.

Additional mobile fixes: header scrolls horizontally instead of wrapping; all interactive elements got touch-action: manipulation and -webkit-tap-highlight-color: transparent; bees got a touchstart handler with preventDefault for instant tap response; overlay, leaderboard, and shop panel use min(X, 90vw) for small screens.

20. start fresh / resume + completion tracking

On the landing page show two buttons โ€” either start from beginning or resume from last session. Track how many times they completed the script as an achievement: 1, 10, 100, 1000 times.

progress.savedLitCount stores the last word index in localStorage every 10 seconds while listening, and immediately when the home button is pressed. On the landing page, if savedLitCount > 0, a RESUME button appears alongside START FRESH.

Resuming lights all previously-heard words instantly (no speech), then finds the correct sentence index and calls speakSentence(si) to pick up from there.

When the script finishes, progress.completions increments, savedLitCount resets to 0, and four new achievements are checked: You Watched It (1ร—), Bee On Repeat (10ร—), Hive Mind (100ร—), According to All Known Laws (1,000ร—).

21. daily login bonus

Can you add a daily login bonus of 69 honey that doubles each day you log in? Today it's 69, tomorrow 138, next day 276, etc.

On page load, the script compares today's date (new Date().toISOString().slice(0,10)) against progress.lastLoginDate. If it's a new day, and yesterday matches the last login date, the streak increments. Otherwise it resets to 1. Bonus = 69 ร— 2^(streak โˆ’ 1) added directly to progress.beesTotal. A toast pops up 800ms after page load showing the bonus amount and current streak day.

22. leaderboard โ€” coming soon

The original leaderboard used JSONBin.io as a free REST JSON store. Scores were saved on pause, finish, tab close (beforeunload with keepalive: true), and every 30 seconds via setInterval. The leaderboard score was migrated from "words read" to "total bees ever caught" (stored in progress.beesCaught) so spending honey in the shop can't lower your rank.

The JSONBin backend was removed and the leaderboard stubbed with a "coming soon" placeholder. A Supabase database integration is planned as the replacement. All local progress (honey, bees, shop, achievements, streak) continues to persist in localStorage.

23. username persistence + speed "Normal" label

It should save the username you use. We should rename the 12 next to speed to Normal just so it's easy to find.

The player name input now saves to localStorage under beelieve_username on every keystroke and is auto-filled on page load. No more re-entering your name every visit.

The speed slider's value label shows "Normal" when set to 12 (the default TTS rate), and a number for everything else. In the gameplay HUD, the speed label turns green when you're at Normal speed. Value 12 maps to a TTS rate of roughly 1ร— โ€” the most natural-sounding pace.

24. ElevenLabs TTS integration

Is there an API users could plug in for a text to speech they could use themselves?

An optional ElevenLabs API key field was added to the landing page. When a key is present, speech is routed through the ElevenLabs streaming TTS API instead of the browser's built-in voice. The audio is fetched as an ArrayBuffer, decoded via the Web Audio API (AudioContext.decodeAudioData), and played through a BufferSource node. Since ElevenLabs returns raw audio with no word boundary events, the existing character-rate fallback timer lights words as the audio plays.

If the API key is invalid or the request fails, the system shows a toast and automatically falls back to browser TTS. The key is saved to localStorage so it only needs to be entered once.

A ? help button sits next to the label. Hovering it opens a tooltip with step-by-step instructions for getting an ElevenLabs key, including a direct signup link. The tooltip stays open when you move the mouse onto it (120ms grace period) so you can click the link without it disappearing.

25. daily rewards calendar

Can you add a daily login bonus of 69 honey that doubles each day you log in? The icon should be a book and clicking on it should open like a book and show a calendar with checkmarks if you claimed that day's daily gift.

A ๐Ÿ“– DAILY REWARDS button sits on the landing page. When today's reward is unclaimed it gains a dark honey background and a pulsing red notification dot. Clicking it opens a panel with a CSS 3D book-open animation (perspective(800px) rotateY(-90deg โ†’ 0deg)).

The panel shows a 7-day calendar grid (6 past days + today + tomorrow locked). Each cell shows its state: โœ… claimed ยท ๐Ÿฏ claimable today ยท ๐Ÿ“บ missed (watch ad) ยท ๐Ÿ”’ future.

Clicking CLAIM starts a 3-second countdown bar โ€” the reward button only activates once it completes, preventing accidental instant claims.

Claimed dates are stored as an array of ISO date strings in progress.claimedDates. Streak is calculated by counting consecutive claimed days ending at today. Bonus = 69 ร— 2^(streak โˆ’ 1).

๐Ÿ› bug โ€” daily bonus banner never showed after first deploy The original implementation auto-granted the bonus and set lastLoginDate = today on load. On next visit the date check saw today was already set and skipped the bonus entirely โ€” the banner was invisible because _dailyBonus was 0.
โœ… fix Replaced the auto-grant model with a claimedDates array. The bonus is only credited when the user explicitly clicks CLAIM and survives the countdown. Old loginStreak and lastLoginDate data is migrated into claimedDates on first load.

26. ad-watch for missed days

If you hover over a past day, you can click and watch an ad to get the reward. If I watched an ad I would get 138 honey, then if I watched an ad for the day before that, I get double 138?

Missed past days (unclaimed and not ad-claimed) show a ๐Ÿ“บ icon in the calendar. Hovering reveals a tooltip: "โ–ถ watch ad ยท +X ๐Ÿฏ". Clicking starts a 5-second countdown that simulates an ad view. When the countdown completes, a โœ“ CLAIM button appears and the honey is credited on click.

The ad reward doubles the further back in time: yesterday = 138, 2 days ago = 276, 3 days ago = 552, and so on (138 ร— 2^(daysBack โˆ’ 1)). Each day can only be ad-claimed once โ€” tracked in progress.adDays.

The countdown is currently simulated (no real ad SDK). To integrate a real ad network (e.g. Google AdSense Rewarded, AdMob Web), replace the showCountdown() call with the ad SDK's show method and invoke the onComplete callback in the ad's reward event handler.

27. header layout + polish

The buttons and text options need to be moved so that CHAOS is touching the right side of the header.

A flex: 1 spacer div was inserted between the BPS display and the SHOP button. This pushes all mode/color buttons to the right edge so CHAOS sits flush against it, while ๐Ÿ, honey count, and BPS stay anchored to the left.

28. shop flash fix + in-place rendering

When we open the shop, we hover over what we want to buy and we can't click because it's flashing like we are clicking when we are not. We need to change that ASAP so it only flashes when we click and that it lets us buy upgrades.
๐Ÿ› bug โ€” shop items flash on hover and freeze on click Every purchase called renderShop() which wiped innerHTML and rebuilt all items from scratch. The full DOM teardown/rebuild caused a visible flash. On mobile, touch states were also triggering the hover style on items that couldn't be bought.
โœ… fix โ€” in-place DOM update renderShop(initial) now uses data-upg attributes to find existing item elements and only updates their cost and count text. Items are created once and reused. The :hover style was scoped to :not(.unaffordable) so grey/locked items never highlight. A brief .buying class (150ms) gives tactile feedback on actual clicks without a full re-render.

29. landing page stats panel

On the landing page see our total amount of honey and our honey per second as well as a % of how far we are in the script.

A dark stats panel was added to the landing page controls, sitting above the Daily Rewards button. It displays three live values read from progress on load:

Progress is 0% if there is no saved session. All values are calculated via the existing fmtN() and calcBPS() helpers, so they use the same formatting (k/M/B suffixes) as the in-game HUD.

30. uniform landing button styles + hover tooltips

Resume, achievements, and how this was made should all be the same width and style as the other buttons. When hovering you should see an info box appear so the user gets more info as to what the button does.

All landing page buttons โ€” Daily Rewards, Resume, Achievements, How Was This Made, and Start Fresh โ€” were unified to the same style: transparent background ยท 1px solid #f5c80066 border ยท full width ยท centered text. Resume was previously a thicker-border standout button; it now matches the others. The "how was this made?" link was restyled to look like a button while remaining an <a> tag.

Each button was wrapped in a .landing-btn-wrap relative container. On hover, the container shows a .landing-tip tooltip above the button with a title and description:

Hovering any button triggers a scale(1.03) + box-shadow glow identical to the Start Fresh button's existing expand effect. All buttons shrink on click with scale(0.97).

๐Ÿ› bug โ€” resume button wrapper hidden state The Resume button's display:none was moved to its wrapper div so the tooltip and hover effect don't appear for a button that isn't visible. JS was updated to show/hide the wrapper by ID (resume-wrap) rather than the button itself.
โœ… fix Added id="resume-wrap" to the wrapper and updated both JS call sites (home-btn handler and initial load check) to target the wrapper.

31. ๐ŸŽฐ bee casino

Next to the shop button I need you to make a casino button please >:D time to gamble honey.

A ๐ŸŽฐ CASINO button was added to the header next to SHOP. It opens a purple-themed slide-in panel (same pattern as the shop, but styled with deep purple/violet accents) containing three gambling mini-games:

All games share quick-bet buttons: fixed amounts (10, 50, 100) and percentage bets (10%, 50%, ALL IN). The ALL IN button sets the bet input to your entire current balance. Bets are floor'd to whole numbers, and the bet is deducted before the animation plays โ€” no double-spending possible. The casino balance display stays live via updateCurrencyDisplay(). Opening the casino auto-closes the shop and vice versa.

32. landing page fixes โ€” start fresh style, leaderboard removal, scroll lock

Two bugs on the landing page: the start fresh button should match the rest of the website buttons. Also remove the leaderboard entirely from the site, and move the header down by 40 pixels, it's cut off from the top of the website.

Three issues addressed in one pass:

34. casino replacement โ€” blackjack & roulette

Remove all casino games (BEE SLOTS, HONEY FLIP, HIGH OR LOW) and replace with blackjack and roulette ported from a React/TypeScript demo. Use honey instead of money. Style to match bee theme. Blackjack should bet honey per hand slot via chips. Splitting and doubling should cost honey. Natural blackjack pays 3:1. Insurance when dealer shows Ace with auto-decline toggle. Gambling blocked while script is paused.

Ported both games from blackjack-play-demo/src/routes/blackjack.tsx and roulette.tsx to vanilla JS with no framework dependencies. The casino panel was widened from 320px to 480px to fit the 360px SVG roulette wheel. A casinoBlocked() helper gates all bet/spin entry points on running && !paused.

Blackjack: 6-deck shoe with Fisher-Yates shuffle; reshuffle at <20 cards remaining. Before dealing, 3 hand slots accept chip bets (click to add, "clear" to remove); each slot with honey becomes an active hand. Hit / Stand / Double (deducts same bet again, doubles stake) / Split (deducts again, inserts second hand; limit raised to 8 hands). Animated deal-in via @keyframes bj-deal-in; hole card reveal via @keyframes bj-flip. Card animation bug fixed with bjRenderedCards Set โ€” already-rendered cards get animation:none so only the new card animates on hit. bjRender() called before bjStartDealerTurn() so double-down face-down card is visible before dealer sequence starts. Insurance prompts when dealer shows Ace; takes half total bet at 2:1 payout; auto-decline checkbox skips the prompt. Natural blackjack pays 3:1 (returns 4ร— bet).

Roulette: SVG wheel generated from RL_WHEEL_ORDER array with sector paths computed in JS. Full CSS-grid betting table: 37 numbers, 2:1 column buttons, dozens, outside bets (red/black/even/odd/high/low). Split (17:1), corner (8:1), and street (11:1) bets placed via hover crossroad dots positioned as grid items in the split columns/rows. Spin uses CSS transition: transform 4s cubic-bezier(โ€ฆ) on the wheel disc; transitionend event triggers payout. Canvas particle fireworks on any winning spin. Honey balance deducted before spin, winnings added after.

Outside-click bug fix: Betting buttons rebuild panel HTML via innerHTML, detaching the clicked element from the DOM. The old panel.contains(e.target) check returned false for detached nodes, closing the casino on every click inside it. Fixed by adding e.stopPropagation() at the panel level so clicks inside never reach the document-level close handler.

Chips: 25 / 50 / 100 / 500 / 1000. Max 10,000 honey per hand slot. Cards wrap to a new row when a hand overflows the panel width.

33. auto-scroll pause on user scroll

Scrolling up when I'm listening to the script will push me back down to where the voice is saying words.

In LIST mode, lightWord() calls scrollIntoView({block:'center',behavior:'smooth'}) on every lit word. This fought any manual scroll โ€” the page immediately snapped back to the current word.

Fixed with a userScrolled flag. A wheel listener sets the flag when deltaY < 0 (scroll up). A touchmove listener sets it when the touch Y increases (finger moving down = page scrolling up). A scroll listener resets a 4-second debounce timer; when the timer fires, userScrolled is cleared and auto-scroll resumes. lightWord() skips the scrollIntoView call while userScrolled is true, so the user can freely read ahead or back without the page fighting them.

// local storage schema

All persistent progress lives under the key beelieve_progress in localStorage:

// tech stack

HTML CSS JavaScript Web Speech API Matter.js (physics) localStorage GitHub Pages Web Audio API ElevenLabs TTS (optional) Supabase (coming soon) the bee movie (2007)

// things that were tried and changed