Krua Niran is a mobile game for learning spoken Thai by cooking in a small Bangkok restaurant. The player is Mali, 16, helping her mother Niran run the kitchen. Choose a recipe, buy the ingredients at a ten-stall market in Thai, pay in real bahts, then cook it step by step while Niran reads out each instruction aloud. Ten recipes, a hundred cooking steps, ten market stalls, sixty ingredients, about 450 voice clips, 125 kitchen images, roughly 4,300 lines of game code.

This is the full account of how it was built: the concept and what the MVP actually kept, the reasoning behind the interface, the React architecture underneath it, a layout that holds from an iPhone SE to an iPad to a folding phone without a single device-specific file, and the method that generated every character, stall, dish, voice line and sound effect by AI without the result looking like four hundred unrelated pieces.

Play Krua Niran →

1. The starting concept

The founding document is a one-paragraph pitch, written the same night as the recipe list and the vendor names: a visual novel for learning spoken Thai. The player is Mali, helping her mother Niran run a small neighborhood restaurant in Bangkok. Every day, Niran announces the dish of the day, Mali walks to the market to buy the ingredients in Thai, pays in bahts, then comes home to learn the recipe. The learning happens through real situations: greeting someone, asking a price, counting money, following cooking instructions.

Audience and tone. Beginners (A0 to A1) who want to speak, not just read. Adult, warm, lived-in, never childish, with the same art direction as the market itself: stylized painted 3D, the direct light of Bangkok.

The structural decisions made on day one:

  • A screen split in two, in portrait: the scene and characters on top, the interactive panel below.
  • Every line of Thai in three stackable layers: Thai script, romanization, English.
  • A minimal HUD: a baht wallet, a shopping list, a sound button on every line.
  • An eleven-screen journey: the city map, arriving at the restaurant, the dish of the day, the shopping list, the market, a stall conversation, payment, a listening challenge, returning to the restaurant, the cooking lesson, the end of the lesson.
  • A ten-stall market, each stall with a strongly characterized vendor and a memorable name (Noi Noodles, Sabai Ploy).
  • A day-by-day progression: a new dish, new stalls, harder sentences.

Planned learning mechanics: a sentence builder using word tokens, a listening challenge, real coin and bill denominations (1, 2, 5, 10 baht coins, 20, 50, 100 baht notes), spoken repetition with voice recognition, spaced review, and politeness particles (kha / ka) taught in context.

Concept versus what actually shipped

Planned in the conceptIn the MVP
City map, restaurant, marketYes
Ten market stalls with speaking vendorsYes, with real voices
Three text layersYes
Stall dialogue and paying in bahtYes: Mali states her need, asks the price, pays with coins and bills
Step-by-step cooking lessonYes, for 10 recipes instead of a single daily dish
Voice on every lineYes (~450 clips)
Sentence builderNo, built only as a design-system component, never wired into a screen
Separate listening challengeNo (the price is heard directly at the stall)
Repetition with voice recognitionNo
Spaced review, score, XP, daily progressionNo

The MVP kept the sensory core, see, hear, repeat in context, and left scoring and progression mechanics for later. Several other things drifted quietly between the concept and the shipped build, without ever being written down as a decision: the three text layers are always visible now, there's no toggle for them. The sound button exists only in the design system; in the game, voice plays automatically with every line, and tapping the instruction card replays it. "Dish of the day" became "choose any recipe, or let Niran suggest one," a randomRecipe() call standing in for the daily rotation. None of this is a regression, it's what a concept document looks like after it meets a real build: some things get cut on purpose, some things get replaced by something simpler that works better, and most of that second kind never makes it back into the docs.

A composition board before a single line of code

Before writing any code, the first image generated was a composition board: all eleven screens of the player's journey laid out side by side, with flow arrows, purely to judge the top/bottom split.

Composition board laying out all eleven screens of the journey

The Thai text on this board was invented by the image model and contains errors, it's a layout mockup. The actual game uses a real font and the text written into its own data. The board itself came together in a single image-generation call, about four minutes after the concept document and the Vite scaffold were created. Everything else, the design-system page, the first layout component, every screen, came after it.

What the board got right and what it didn't turn out to matter much: the wallet balance printed on different cells of the board doesn't agree with itself (500 at the map, 300 later, 265 at the recap), because a still image has no state to keep consistent. That's exactly the kind of problem a composition board is cheap to have and a working build can't afford, so it's one of the clearest arguments for making the mockup before the code rather than after it.


2. The method: a vertical-slice MVP

A few principles, visible in the order things were built and in the shape of the code, carried the project from a blank page to a finished build in a few weeks of evening and weekend work.

2.1 One complete recipe before the other nine

The first vertical slice was Som Tum: one full recipe, end to end, from its recipe card to its ending screen, with its own images, voices, and steps. It served as the test bed for tone, pacing, and finish. Once it held up, the other nine recipes were produced from the same template. Adding a recipe today needs almost no code, everything comes from data files (recipes.js, lessons.js, ingredients.js).

2.2 Content is data

Recipes, ingredients, stalls, dialogue, and vendor lines all live in game/src/data/. Screens contain only presentation. That has concrete consequences: a dialogue line added to the data is automatically picked up by the voice-generation list; a load-time check (assertRecipesComplete) refuses to boot if a recipe needs an ingredient no stall actually sells; and the #/design-system route is the single source of truth for every interface component, colors, buttons, tiles, bubbles, built there before it's ever used on a real screen.

2.3 Assets produced by scripts, not by hand

Thirty-six generate-*.mjs scripts at the repository root produce every image, voice line, sound effect, and music track. They're replayable, a file that already exists is skipped, and self-documenting, the prompt that made an asset lives in the script that calls for it. Redoing an asset means editing a prompt and deleting a file. That's how roughly 450 voice clips and 125 kitchen images got made without ever opening an image or audio editor by hand.

2.4 A short loop, on a real device

The game is tested the way it will actually be used: installed as a PWA on an iPhone, mirrored over QuickTime to watch it live, plus a browser preview for quick checks. Real hardware corrected wrong assumptions more than once (section 6): the safe area, Safari's own chrome, haptic feedback, pinch-zoom, the system rail on a folding iPhone in landscape. The loop was almost always the same shape: a complaint ("that button sits too far left"), a targeted fix, a check in the browser, another pass on the device.

2.5 Measure before committing

Every expensive direction got tested small before being scaled up: animated videos were tried on one step, then fifteen, before being dropped (section 8); voices were checked by automatic transcription; ingredient pop-out animations were reworked several times based on what actually looked right on the device, not in theory.

2.6 Timeline

WhenWhat happened
October 25, midnight to 3amThe lists (recipes, vendors), the concept, then the entire art direction: the style sheet, 10 stalls, the composition board, the design-system page, full-body characters, the map and street, textures, dialogues, stall logos, the restaurant image. The first Split layout component and the first version of the service worker also land this night.
October 25, daytimeRecipe data, plates and the 10 dishes, the Mali-and-Niran hug scene, the feast spread, Niran cooking in flames, the first ingredient icons. The first real screen components, ShoppingList and Buy, are written about ten hours after the composition board.
November 3The top-down kitchen stations (cutting board, mortar, seasoning, pass, and later wok, pot, steamer, dessert), a quality test on the first station, then the 19 step images for Som Tum.
November 7The other nine playable recipes (lessons and step images), Niran's, Mali's, and the vendors' voices, interface sounds, music, haptic feedback, the app logo and icon, the ingredient pop-out animation.
November 9 to 10The full market dialogue (chained voice clips for prices and quantities), animated scenes for the city, market, and restaurant, a performance pass (textures and backgrounds to webp), safe-area work for iPhone and the folding-phone format, the desktop frame.
November 11The loading screen with the logo, a test of generated step videos (later abandoned).
November 15The 9:16 teaser poster, this documentation.

Almost the entire visual world was laid down in a single night (October 25). That was only possible because the method in section 4 was already in place before that night started: a style sheet, references, and scripts built to be replayed.


3. Designing the game

3.1 Three text layers, for a reason

Every displayed sentence exists in three layers: Thai script, its romanization, and English. The Tri component renders all three together, at different sizes depending on context. Romanization is the layer read first, so it's the main line; Thai and English sit around it. The concept document describes these layers as individually toggleable; in the shipped game they're always shown together, the toggle exists only as a prop on the design-system page. One place where three layers don't fit: the recipe menu's action buttons show only an English hint, there simply isn't room for three lines on a button.

3.2 Voice first

The game is built for the ear: every line of dialogue, every cooking instruction, every ingredient name is spoken aloud.

  • Dialogue types out exactly for the duration of its own audio clip. The player reads what they hear, not ahead of it.
  • Cooking instructions: the romanization types out at the voice's pace, then Thai rises and English settles below it, then the word to remember highlights in yellow across all three lines, with a small "ploc" for each.
  • Prices are assembled from audio fragments: "ห้าสิบบาท" (ha sip baht, 50 baht) is spoken by chaining the clips for "ห้า," "สิบ," and "บาท." Numbers from 1 to 1000 are built this way, which avoids recording every possible price by hand.
  • Ingredients: touching one speaks its name and quantity ("1 head of garlic"), assembling the noun, the number, and the correct Thai classifier (ถุง for a bag, ขวด for a bottle…).

3.3 The market as a small role-play

Each stall has a vendor, older or younger, with a speaking pace that follows their age, and a greeting. At the point of buying:

  1. Mali says what she needs ("I want two tomatoes"), or says she doesn't need something.
  2. She asks "how much does that cost?"
  3. The vendor states the price.
  4. The player pays by tapping coins and bills.
  5. Mali says "here you go," the vendor thanks her, she thanks them back.
  6. If the player asks for more than needed, Mali says so. If she doesn't need an ingredient, the vendor just says "let me know if you need anything else."

    Payment itself only accepts exact change: underpaying gets "Not enough yet," overpaying gets "That's too much," and bills or coins larger than what's left in the wallet grey out in the palette so they can't even be tried. The game never makes change, on purpose, the design note in the code credits a mobile cashier game as the inspiration. The trade-off is real: the player practices addition and denominations, but never gets to receive change back, a step a real market transaction almost always has. For a first version, exact payment was the simpler and clearer rule to teach.

    3.4 A framework that guides without punishing

    • A recipe can't start without the shopping: the "Start cooking" button stays greyed out. Tap it three times anyway, and a prompt offers to skip the shopping, so the ingredients and the lesson can still be reviewed without paying.
    • Nothing fails: there's no score, no timer. The MVP bets entirely on listening and repetition.

    3.5 Sound, touch, and motion

    • 14 interface sounds (tap, page turn, coin, announcement, confirmation…) fire on finger-down, not on release.
    • One music track per place (city, market, kitchen), with a recipe-completion jingle that ducks the music under it.
    • Light haptic feedback on buttons, a real vibration on Android, and on iPhone a hidden HTML switch trick (iOS 17.4 and newer), since the Web Vibration API doesn't exist there.
    • Ingredients "pop out" of their grid, land centered on a square card, wiggle, and return to place when tapped.

    4. The image-generation method

    4.1 The tooling

    • Model: gpt-image-2.5-sunburst, through OpenAI's image API.
    • Primary call: images.edit with multiple reference images (up to about a dozen) plus a prompt. images.generate is used only for the mannequin pose and the empty plate, which have no reference at all.
    • Formats: square 1024×1024 for most things, 1536×1024 for wide shots (the style sheet, the composition board, the wide kitchen view, the feast), 1024×1536 for full-body characters, 1152×2048 for the 9:16 poster.
    • Quality: high for the style sheet, the stalls, characters, dialogues, stations, and recipe states; max for standalone illustrations (the street, the kitchen, plates and dishes, stall logos, the hug, Niran cooking); low for the 60 ingredient icons, numerous and small, viewed at around 100px.
    • Background: background: "transparent" for isolated objects, ingredients, plates, cut-out characters.
    • Production: one script per image family, at the repository root (generate-*.mjs). Batch scripts skip files that already exist, several retry up to three times with backoff on error, and batches run a few generations in parallel.

    4.2 The principles

    1. A style sheet is the reference for everything. Before the first real game image exists, one board fixes the look: a sunlit market with Mali and Niran, material swatches (wood, corrugated metal, bamboo, cobblestone), a six-color palette, a lighting sample, and both characters in full-body style. Every later image receives it as reference #1, with the instruction "STRICT art direction."
    2. References are numbered in the prompt. "Reference images: 1) the style sheet, 2) Mali, 3) Niran, 4) the kitchen…" The model then knows exactly what each image represents, and what it should or shouldn't copy from it.
    3. State what doesn't change, and what does. "Keep the same camera, counter, materials, lighting," then "Show the station in this state: …"
    4. Work in layers. General images (an empty station, a dish on an empty plate) serve as a base, and specific images (one step, a plated dish) are built on top of them with the base image as an exact reference.
    5. Chain states. The image for one step also receives the previous state of the same station, so bowls, pots, and their positions stay consistent from one step to the next.
    6. The game's own text drives the images. Each step's state and its ingredients are fields in the game's data file, the same data that renders the on-screen instructions. Change a recipe, and its images change on the next generation run.
    7. Originals stay out of the game. The game loads reduced webp files; the generated PNGs stay in separate folders.
    8. 4.3 The reference chain, mapped for one recipe step

      For Som Tum's "peel the papaya" step, the model receives: the empty station (camera, materials, lighting), the previous state of that station (the loaded cutting board), the ingredient's own icon (so the papaya matches the one used everywhere else in the game), and a sentence describing what changes.

      Reference chain: empty station, previous state, ingredient icon, result

      Left to right: the empty station, the previous state, the papaya icon from the game, the generated image for the step.


      5. Family by family

      5.1 The map, the street, and the market

      • The city map (generate-assets.mjs): an aerial view of a Bangkok street, the restaurant on one side (a wooden shophouse, a red-and-cream awning, lanterns, a chef's-hat-shaped sign) and the market on the other (turquoise, red, and orange stall awnings, a crowd), a canal, palm trees, a golden temple in the distance. The prompt explicitly forbids any interface element ("NO UI, NO text, NO map pins").
      • The wide street (generate-street.mjs): the same street at a wide angle, the style sheet as a strict reference for rendering, and a real photo used "ONLY for layout." This is the background image of the game's city screen.

      Two map versions, a reference photo, the stylized street

      5.2 The style sheet

      Generated first (generate-images.mjs sheet, 1536×1024), from actual photos of Mali and Niran. It contains a market alley with both characters, material swatches, the palette, a lighting sample, and the full-body character style.

      The style sheet

      A night version exists (00-style-sheet-night.png) but isn't used; the game stays in daylight throughout.

      5.3 The ten stalls

      generate-images.mjs uses a shared style block (an adult narrative game, explicitly "NOT photorealistic," hand-painted, late-morning light, saturated turquoise, chili red, mango yellow, grass green, warm wood) and describes each stall through three elements: the sign (readable, hand-painted), the vendor (age, build, props), and the goods.

      Each stall is generated with the style sheet and three character photos as references. Mali and Niran appear in the foreground, facing the stall, without blocking its sign.

      The ten stalls

      Khao Good, Sabai Sabai, Galangal Gang, Sanuk, Moo Moo Gai, Hook Line & Goong, Phet Phet, Go Coco, Nam Pla Nation, Tao Hu Too.

      5.4 Full-body characters

      generate-characters.mjs extracts each character (Mali, Niran, the ten vendors) from a stall image or a photo, then redraws them full-body, head to shoes, in a neutral pose, facing the camera, on a pure white background. Each character has a written description (age, hair, clothing, shoes) to keep the same traits in every later image. Format 1024×1536.

      The twelve full-body characters

      5.5 Dialogues: three images per character

      Every vendor has a conversation scene with Mali, Sims-style: Mali on the left, the vendor on the right, face to face, inside their own stall's setting. generate-dialogue.mjs produces three images per character:

      1. The scene: both characters in the setting. References: the style sheet, a mannequin pose (two grey silhouettes in conversation, to fix camera and posture), Mali's full-body reference, the vendor's full-body reference, the stall's background.
      2. The background: the same scene with no one in it, pixel for pixel.
      3. The characters: both characters alone on a transparent background, at the same position and scale.
      4. The game layers the last two images: the background stays fixed, the characters slide in on top.

        Scene, empty background, cut-out characters

        Two details matter a great deal here:

        • Real sizes. A table gives each character's height in centimeters (Niran 162cm, Noi 148cm, Pla 182cm…) and the prompt compares each one to Mali (158cm): "clearly TALLER than Mali by about 24cm." The proportions of these conversations are credible because of this.
        • Don't copy the people already in the setting. The stall's reference image already contains other people in the background. The prompt states: "use image 5 ONLY for the decor, and do NOT copy those people."

        The pose itself comes from a separate image, generated with no reference at all: two neutral grey mannequins, arms at their sides, hands out of pockets (the prompt insists: "NO hands in pockets, no hand gestures").

        The mannequin pose and the resulting scene

        5.6 Stall logos

        generate-logos.mjs: one icon per stall, a steaming bowl of noodles, a sprig of basil, a galangal root with a red bandana, a smiling mango, a pig, a shrimp, a chili in flames, a coconut, a fish sauce bottle, a block of tofu. Each icon has its own color palette. These are the logos shown on the market's stall tiles.

        Logos for the ten stalls

        5.7 Textures

        • Wood: a dark plank texture, traced from the "Where to?" panel already visible on the composition board, used as the interactive area's background. No objects, no interface elements.
        • Thai beige: a handmade cream paper with a very subtle lai thai pattern (flowers, flames, lotus petals), traced from the dialogue bubble background. The pattern stays subtle enough that text placed on it remains perfectly legible. This is the texture for the game's cards and buttons.

        Wood texture and Thai beige texture

        5.8 Plates, the ten dishes, and the feast

        • The empty plate is generated alone (no reference, transparent background, a 60-degree view, a very light contact shadow). This is the exact base for everything that follows.
        • An empty bowl on a plate, for soups and curries, built from the plate.
        • The ten dishes: each one receives the plate (or the plate and bowl) as an exact base and is asked to be plated onto it, with "same camera angle, same lighting, same centered framing and size." The result is dishes of identical size and angle, interchangeable in the menus.
        • The feast: the ten dishes serve as references for one large table image, composed with small side dishes, rice, sauces, limes, chilies, chopsticks. This illustrates Niran's "Browse recipes" screen.

        Empty plate, plate with bowl, two dishes

        The ten dishes

        The feast

        5.9 Ingredient icons

        60 icons (generate-ingredients.mjs), one per ingredient sold at the market. Each ingredient is described exactly as it would be sold at a stall: an open cloth sack of jasmine rice, a bundle of vermicelli tied with red ribbon, a bunch of holy basil tied with string.

        • Style: the style sheet as reference, a centered object filling about 80% of the frame, viewed from three-quarters above, transparent background, a very soft contact shadow, nothing else around it.
        • Quality low, 4 generations in parallel: there are a lot of these, small (100 to 150px in the game), and the detail that matters is silhouette and color.
        • Every PNG is reduced to a 384px webp for the game.

        All sixty ingredient icons

        5.10 Mali and Niran, the relationship scenes

        A handful of images exist purely to tell the characters' story. Each one has the style sheet and both characters as references.

        • The hug (generate-hug.mjs): Niran and her daughter, full-body, leaning toward each other. Heights are specified (162cm and 158cm). Used as the illustration on the city screen.
        • Niran cooking (generate-niran-cooking.mjs): full-body, knees bent, a wok in one hand, a burst of flame and suspended ingredients. Transparent background.
        • Mali walking through the market (generate-mali-market.mjs): full-body, a cloth bag over her shoulder. The game's market screen displays this scene. generate-walking-split.mjs split it the same way as the dialogues, into an empty scene and Mali alone on a transparent background.
        • Arriving at the kitchen (generate-kitchen-arrival.mjs): Niran at the wok in full flame, her team around her, Mali at the doorway.
        Mali in the market: scene, empty background, Mali alone Niran in the flames, the hug, the intro, and the end of the lesson

        5.11 The restaurant and the kitchen

        • The restaurant (generate-kitchen.mjs): the kitchen's service counter, composed exactly like the stall images (front view, centered, wide angle, the sign up top, characters in the foreground), with "Krua Niran" written in both English and Thai.
        • The wide first-person view (generate-kitchen-wide.mjs, 1536×1024): an ultra-wide (14mm) establishing shot of the kitchen, at Mali's own eye height (158cm), taking in the counters, shelves, and the large stainless-steel island all at once. This image fixes the kitchen for everything generated after it.

        The restaurant, the wide kitchen view, Mali arriving

        5.12 Kitchen stations (level 1)

        For the kitchen, the camera angle changes: the counter is viewed from above, roughly how Mali would see it leaning over, about 70 degrees, a touch of perspective, no hands in frame. Each station is photographed empty and tidy:

        #StationContents
        1Cutting boardwooden board, chef's knife, peeler, three small bowls, a scrap bowl, a checkered towel
        2Mortar and pestleterracotta mortar, wooden pestle, a large spoon, a small board
        3Seasoningsmall bowls, a citrus press, measuring spoons, a tray of jars
        4Pass and platingstainless counter, a ticket rail, a service cloche, a white plate
        5 to 8Wok, pot, steamer, dessertadded on November 7 for the other recipes

        Quality tested first. Before running the full series, the cutting-board station was generated at several quality tiers (generate-station-test.mjs) to decide what was actually worth the cost. Stations 2 through 8 were then generated using station 1 as an exact reference for camera, scale, materials, and lighting.

        Quality test: medium, high, max The eight stations

        5.13 Recipe states (level 2)

        For each step, one image shows the station's state after the action. For Som Tum, the 19 images are described in a planning file, then generated by generate-som-tum.mjs: for every step, the station, the icons of the ingredients involved, and a sentence describing the state.

        "the green papaya is peeled, pale green flesh on the cutting board, long green peel strips lie beside it and the peeler rests on the board. The other ingredients are out of the frame, the bowls are empty."

        Five of the planning steps for Som Tum

        For the nine other recipes, generate-lessons.mjs reads the lesson data directly and produces, per recipe:

        • a "mise en place" image, all ingredients laid out on the counter, built from the station and every ingredient's icon;
        • one image per step, built from that step's station, the previous state of the same station, the relevant ingredient icons, and the step's described state;
        • an ending image (the plated dish), built from the dish's own photo.

        Four recipes run in parallel. In total, 125 kitchen images ship in the game, at 8 to 15 steps per recipe.

        The "all ingredients" image for all ten recipes

        5.14 Identity: logo, icon, poster

        • The wide logo (generate-logo-restaurant.mjs): faithfully reproduces the restaurant's own sign, same wooden plank, same hand-painted red lettering, same bowl with flames, chilies, and garlic, on a transparent background. The text "Krua Niran ครัวนิรัญ" comes directly from the restaurant image.
        • The square icon (generate-logo-icon.mjs): reorganizes the wide logo into a square and adds Niran's head, always as the chef, never casual, toque and a white jacket with gold trim. This is the app's icon on an iPhone's home screen.
        • The teaser poster (generate-poster.mjs, 1152×2048, true 9:16): Mali and Niran in the kitchen, the logo up top, Thai dishes and kitchen props, a "Learn Thai by cooking" banner. The top 12% and bottom 18% are deliberately kept free of text or detail, since a story's own interface covers them. References: Mali, Niran, the logo, the kitchen.

        Wide logo, square icon, poster

        5.15 The step-video experiment, and its lesson about references

        To try a more animated V2, videos were generated from start frames tightly focused on the action, the food and the utensil, before the gesture. That experiment, later abandoned, revealed a real flaw in how references behave.

        Start frame with a food reference versus start/end frames with no food reference at all

        Left: the start frame generated with the peeled papaya image as reference, the fruit's shape got contaminated by it. Right: start and end frames generated from the empty station alone.

        The same fix applied to the recipe's "all ingredients" image: regenerated with no food image as reference at all, the ingredients described only in text instead.

        With ingredient icons as reference (the game) versus with no food reference at all (the video test)


        6. Images inside the game

        • Conversion: the game only loads reduced webp files. Ingredient icons are reduced to 384px, kitchen images become webp, the wood and beige textures are reduced to roughly 100KB and 15KB. The first screen lost over 3MB of payload from this conversion alone.
        • Originals (the generated PNGs) stay in the repository's own folders, outside the game's build.
        • Dialogue scenes: one background and one transparent character layer per vendor, served from a per-character folder and loaded on demand. Characters slide in on top of the fixed background.
        • Framing: every image is a square that covers the visuals area. A parameter decides which part stays visible, the top during a dialogue, the center otherwise.
        • Animation: the city, market, and restaurant are animated with 4 or 5 key frames that cross-fade, one image every 3 seconds, extracted from 10-to-15-second source videos.
        • Preloading: the loading screen with the logo loads what the first screens need; a lesson's images load only when that recipe is opened.

        7. What the generation process taught us

        1. The style sheet is what makes 400 images coherent. Without it, every image drifts a little from the last. With it, the market, the kitchen, the characters, and the dishes all read as coming from the same game.
        2. A reference is a strong instruction, including for what you don't want. A setting reference that contains other people will make those people reappear (hence "do NOT copy those people"). A food reference will make that food's exact shape reappear (hence generating video start frames with no food reference at all).
        3. Chained states beat independent states. Giving each step the previous state of the same station keeps bowls and pots where they should be.
        4. An exact base template matters. The empty plate for dishes, the empty station for steps, the mannequin pose for dialogues, everything built on these bases keeps the same framing.
        5. Real sizes prevent wrong proportions. Stating each character's height in centimeters is what makes conversations between them look credible.
        6. Test quality before producing at scale. The three-tier station test avoided paying for maximum quality on a hundred images that didn't need it. Icons run at low for the same reason.
        7. Transparent backgrounds are requested directly for a single object, and built in three passes for a scene (the scene, the empty background, the extracted characters).
        8. Text inside images is a risk. It's accepted for a sign or a logo (and proofread), avoided everywhere else. The Thai on mockups is invented by the model; the actual game writes its own text in a real font.
        9. Scripts need to be resumable. "Skip it if the file already exists" for batches, and repeated retries with backoff, make it possible to resume an interrupted series or regenerate a single image by just deleting its file.
        10. Review every batch by eye. Every series gets reviewed visually, and failed images are regenerated one at a time.
        11. Known limits

          • Images within the same recipe can drift slightly (a papaya a touch larger from one step to the next); chaining states reduces drift without eliminating it.
          • The Thai text drawn into logos and signs needs review by a native speaker, including the spelling of "นิรัญ" on the logo itself.
          • A given quality setting isn't guaranteed identical between runs; a failed image just gets regenerated.

          8. The other assets: voice, sound, music

          The audio side follows the same logic of replayable scripts, built with ElevenLabs.

          Voice. generate-voices.mjs calls the eleven_v4 model with language_code: "th", a fixed seed per retry, and a per-line speed. Four voices cover the whole cast: Niran, Mali, and one generic female and one generic male voice shared across all ten vendors, with speed following the character's age (slower past 60, faster under 30). Delivery cues like [warmly] or [cheerfully] are prefixed onto lines as tags, never meant to be read aloud; ElevenLabs' Scribe model transcribes every tagged clip, and if the tag gets spoken as text instead of performed, the clip regenerates with a new seed. Leading and trailing silence is trimmed with ffmpeg so clips chain cleanly end to end.

          That chaining is how prices and quantities work without recording every possible number by hand: numbers from 0 to 999 are built by concatenating word-level clips with the right classifiers, so "fifty baht" is three existing files played back to back, not a fourth recording. The result is a manifest, game/src/data/voices.json, mapping each Thai sentence to its audio file, 429 entries. A handful of generated files never made it into that manifest, about ten extra Niran clips sit on disk unused; the loader still ships them (it globs every file in the voice folder), they just never play.

          Sound effects. generate-sfx.mjs calls ElevenLabs' sound-effects model for 14 short, distinct effects, a tap, a page turn, a coin, a confirmation, an error. Som Tum's own step sounds are instead baked into their voice clips as inline cues, generated as part of the speech rather than as separate files.

          Music. generate-music.mjs calls ElevenLabs' music model for one instrumental loop per place (street and restaurant, market, kitchen) plus a short finishing jingle. Each loop is stitched seamless with an ffmpeg crossfade from its own tail back into its head, so a roughly three-minute generated track becomes a clean loop with no audible seam.

          In total, 457 audio files ship in the built game: 439 voice clips, 14 sound effects, 4 music tracks.


          9. From mockup to playable screen

          The composition board gave a shape to judge, not a blueprint to implement literally. Comparing the board's eleven cells against what actually shipped shows exactly where a still image stops being useful and a working interaction has to take over.

          A few things changed outright. "Dish of the day," shown on the board as a daily banner with tappable word chips and a tooltip explaining a Thai word, became a recipe menu with free choice and a "chef's suggestion" button instead, since a real daily rotation needs a server and a calendar, neither of which an offline PWA has reason to carry. The flat, two-column shopping list on the board became a bottom sheet, grouped by stall, that opens from the HUD on demand, because a list of sixty possible ingredients doesn't belong permanently on screen. The post-shopping recap the board sketched ("8/8 items, 235 spent, 6 new words") never got built; a two-line exchange with Niran and a full-screen announcement carry that beat instead. The planned sentence-builder and listening-challenge screens, both marked "no" in the MVP table from the start, simply don't exist as screens, their components live only on the design-system page, ready for a version that needs them.

          Other things the board couldn't show at all had to be invented once the screens were real: what state to keep (the wallet, what's already in the bag, which recipe is open, a soft lock after three taps on "start cooking" with a skip option), the timing of a stall exchange against its voice clips, haptic feedback, per-place music, the sliding character layer over a fixed background, and the frame-by-frame animation on recipe steps. None of that is visible on a static board; all of it is what makes the difference between a picture of an app and an app.

          The split ratio is its own small story. The concept and the board both call for 55% visuals on top, 45% interactive panel below. The shipped CSS default is an even 50/50, dropping to 42/58 only on short phones, where the visuals area has to give up room for the interactive panel to fit without scrolling. Nobody wrote down the decision to move off 55/45, it's simply what the layout settled into once it had to work across real phone heights instead of one mockup's frame.


          10. Technical architecture

          Stack. React 19.3 and Vite 8, with lucide-react for icons and nothing else, no game engine, no state library, no router. The whole interactive journey runs through App.jsx's own small hash-route check and one hub component.

          game/
            src/
              data/        the content: recipes, ingredients, stalls, dialogue, lessons, voices
              layout/      Split (the two-pane template), FrameAnim (the animated scenes)
              screens/     CityMap (city, restaurant, market, payment), Cook (the lesson), Buy, ShoppingList
              ui/          the components (Button, Tile, Sheet, Announce, dialogue bubbles…)
              loader/      the loading screen and asset preloading
              voice.js     voice playback and clip-chaining (Web Audio)
              music.js     music tracks and the jingle
              sfx.js       interface sounds and the "ploc"
              haptic.js    haptic feedback
              tokens.css   colors, spacing, safe areas
          

          Routing is a hash check, not a router. App.jsx listens for hashchange and returns one of a handful of routes: #/design-system, a few test harnesses (#/debug, #/haptic, #/kitchen-anim), #/cook/<id> for a deep link straight into a lesson, and otherwise the main hub. Inside that hub, CityMap.jsx holds a single place state (city | restaurant | mom | recipes | recipe | market | stall | buy) that drives almost the whole journey, with money, inventory, the chosen recipe, and the open shopping sheet all living as local React state. Nothing persists between sessions except whether the sound is muted. Every screen shares one layout component, Split: a visuals pane (background, sliding characters, frame animation, dialogue bubbles, HUD) and an interactive pane (header, scrolling content, sidebar).

          Content stays data, assets stay globbed. Recipes, ingredients, stalls, and dialogue are plain JS modules under src/data/, not JSON, not a CMS. Images and audio are pulled in through Vite's import.meta.glob, keyed by filename convention, so adding an asset is adding a file in the right folder rather than editing an import list anywhere. Voice lookup goes through a generated manifest, voices.json, keyed by the Thai sentence itself.

          Why Web Audio instead of <audio>. Every sound in the game, voice, music, effects, plays through the Web Audio API rather than an HTML <audio> element. The reason is iOS-specific and easy to miss without testing on a real phone: an <audio> element shows up in the Dynamic Island and on the lock screen, which is exactly the kind of system chrome a game doesn't want fighting for the player's attention. The audio context unlocks on the very first tap, as iOS requires.

          Build and deploy. vite.config.js sets a base path so the game can be served from a subfolder rather than a domain root, and explicitly disables inlining audio files as base64, so voice and music load on demand instead of bloating the first script bundle. The production build is a static dist/ folder, a few hundred hashed files. A hand-written service worker caches everything under /assets/ (hashed, so safe to cache forever) and falls back to the network first for everything else. It only registers in production, never during development.


          11. One layout for every screen

          This is the part of the build that took the most iteration, and the part a static mockup genuinely cannot test: the exact same interface has to work on an iPhone SE, a current iPhone with a Dynamic Island, an iPad, a folding phone opened into a near-square screen, and a mouse-driven desktop browser, with no per-device file anywhere in the code.

          11.1 The principles

          1. Two panes that recompose. The Split template cuts the screen into visuals and interactive content. In portrait they stack top to bottom; in landscape they sit side by side. On a near-square screen, a folded-open phone or a tablet, the same rule naturally produces two balanced halves.
          2. Each screen recomposes against its own box. The interactive area is a CSS container, and screens inside it use container queries, sized against the shape of that box, not the shape of the screen. A recipe card stacks its image above its text in a tall box, sits them side by side in a wide one, and goes compact in a short one.
          3. Grids count their own columns. The ingredient grid and the stall grid measure their real width and choose a column count from it (a roughly 116px ideal tile, 84px on a small phone, 2 to 5 columns, never wider than 148px per tile), with the tiles centered, including on a half-empty last row.
          4. Safe areas are tokens. --inset-top, --inset-right, --inset-bottom, --inset-left feed the whole layout. The wood texture of the interactive pane runs underneath the notch and the status bar, but content and buttons stay inside the safe zone. A few elements, the top bar's buttons, the landscape "next" button, deliberately ignore the side safe area so they sit a constant distance from the screen's edge instead.
          5. Scene images recrop themselves. Every background is a square that covers the visuals pane, with a parameter choosing which part stays visible, the top during a dialogue (to keep faces in frame above the bubble), the center otherwise.
          6. A compact mode for small screens. Below roughly 720px of page height in portrait (an iPhone SE, or Safari's own chrome eating into a taller phone's viewport), the split moves to 42% visuals / 58% interactive, margins and type tighten, button pairs go side by side, and the ingredient grid drops to 3 columns.
          7. A frame for desktop. With a mouse, and only then, past an iPad Pro's size, the game stays inside a 16:10 frame capped at 1440×900, set against the Thai pattern, with the logo above it sized to 12% of the frame's own height so it scales with the game instead of racing off the top of a bigger monitor.
          8. 11.2 What real devices taught that no emulator did

            • Safari and the installed app don't share a page. In a Safari tab, the page is genuinely smaller, Safari's own bars eat into it, than the same page installed as a home-screen app, which runs edge to edge and under the notch. The layout uses lvh for the game area and svh for how the two panes split, so the interface sits correctly whether or not the browser's chrome is currently stealing space.
            • The folding phone's own system rail. Installed, the game gets a landscape page about 867px wide on that device, not the screen's full physical width, because the system reserves a rail alongside it that nothing can draw under. The layout doesn't fight this, it just treats 867px as the real screen width and moves on.
            • Pinch-zoom survives user-scalable=no on iOS. The meta tag alone doesn't stop it; the game cancels gesturestart and two-finger touchmove directly in code.
            • Haptic feedback has no clean API on iPhone. The Web Vibration API doesn't exist there, so the trick is a hidden HTML switch element, clicked inside the user's own tap gesture, which iOS happens to accompany with a system click sensation.

            11.3 Why one layout holds on any screen

            The layout contains no device list at all. It only ever asks: orientation, page height (compact or not), the shape of each container, a grid's real width, whether a mouse is present, and the safe-area tokens. A new device, an unreleased foldable, an iPad mini, falls into one of those existing rules without anyone having to add a case for it.

            The same screen, portrait on a phone and framed on a desktop:

            The city screen on an iPhone SE, in portrait

            The same city screen on a desktop, inside the 16:10 frame


            12. The game, screen by screen

            A short tour through the actual shipped build, captured on an iPhone 15 Pro, inside the installed app. Play it yourself here, it runs entirely in the browser, no install needed.

            The city screen: the restaurant on one side, the market on the other

            Niran greeting Mali at the restaurant, the dialogue bubble typing out at the voice's own pace

            The shopping list, opened as a sheet over the market screen, grouped by stall

            The market: ten stalls, each with its own logo and vendor

            A stall conversation: Mali and the vendor face to face, the greeting spoken aloud

            Payment: coins and bills in a tray, exact change only

            Mise en place: every ingredient for the recipe laid out, each one speaking its own name on tap

            A cooking step: the station's current state, the instruction typing in sync with the voice, the verb to remember highlighted

            The end of a lesson


            13. Performance and loading

            • Loading screen: the logo and a progress bar load only what the first screens actually need, around 10MB, textures, backgrounds, animated scenes, dish photos, ingredient icons, interface sounds, the menu's own music track. Voice clips and the remaining music load in the background after that; a lesson's own images load only once its recipe is opened.
            • Weight: the wood texture went from 1.7MB to 0.1MB (PNG to webp), the beige texture from 230KB to 15KB, backgrounds the same way. The main JavaScript bundle compresses to roughly 140KB.
            • Code splitting: the cooking lesson and the test pages load only when they're actually opened, not with the first screen.
            • Offline cache: the service worker serves every uniquely-named (hashed) file straight from cache, no network round-trip needed.
            • Economical animation: the animated scenes only redraw during their own crossfades, to go easy on battery the rest of the time.

            14. Abandoned paths, and what they taught

            PathWhy it was droppedWhat was kept
            Generated video for each cooking step (image to video)The gesture itself often rendered poorly, the camera drifted between clips, and small errors compounded as steps chained together.A roughly $3 test instead of a full run of a hundred videos. The pipeline, start frames tightly focused on the action, extracting a final frame, stays in the repository for later.
            Food photos as generation referencesA reference image contaminated the food's exact shape (a peeled papaya kept reappearing peeled in later frames).Start frames generate from the empty station alone; the ingredient is described in text, never shown as an image.
            Interactive steps from the original concept (swipe to peel, tap in rhythm)Too much development for an MVP centered on spoken Thai.Replaced by read-and-listen steps. The original action-by-step plan still exists and now feeds directly into the planned V2 (next section).

            15. What's next: an interactive V2

            The idea: turn each cooking step into a small gesture-based mini-game, in the spirit of a game like Cooking Mama, while keeping spoken Thai at the center rather than making it decorative.

            36 action verbs, about ten gestures. Grouping verbs by the physical gesture they share cuts the production work down: one reusable mini-game per gesture, with the ingredient as a parameter, replaces what would otherwise be dozens of bespoke screens.

            Touch gestureVerbs
            Swipe back and forthหั่น cut, ซอย shred/slice, สับ chop, ปอก peel
            Tap in rhythmตำ pound, ทุบ smash, ตอก crack
            Circular motionผัด stir-fry, คน stir, ผสม mix, คลุก toss
            Pour (tilt or drag)เท pour, ราด pour over, ตัก ladle
            Pressบีบ squeeze, กด press
            Drag and dropใส่ put in, วาง place, จัดจาน plate, เสิร์ฟ serve
            Measureตวง measure, ปรุง season, ชิม taste
            Wait and watchต้ม boil, นึ่ง steam, ทอด fry, ลวก blanch

            The principle meant to keep Thai central rather than decorative: Niran gives the instruction in Thai first, the player has to understand the verb to perform the right gesture, the on-screen text is a hint, not the primary channel. Getting a gesture wrong repeats the instruction, which brings the word to remember right back around instead of just penalizing the miss.

            The plan is to prototype a single gesture, peeling or pounding, on one Som Tum step, to judge how it actually feels under a thumb before committing to building the whole V2 around it. Before any of this ships publicly, every Thai sentence in the game, written by AI from the start, needs a native speaker's review, spelling of the restaurant's own name on the logo included.


            16. Replaying the production

            Scripts run from the repository root, with an OpenAI key in the environment (OPENAI_API_KEY). An existing file is never regenerated, it has to be deleted first to redo it.

            WhatCommand
            Style sheetnode generate-images.mjs sheet
            The 10 stalls (or just one)node generate-images.mjs · node generate-images.mjs 3
            Full-body charactersnode generate-characters.mjs · node generate-characters.mjs mali moo
            Dialogues (three images each)node generate-dialogue.mjs · node generate-dialogue.mjs noi
            Stall logosnode generate-logos.mjs
            Ingredient icons (missing ones)node generate-ingredients.mjs · node generate-ingredients.mjs lime
            Plates, dishes, feastnode generate-plate.mjs · generate-plate-bowl.mjs · generate-dishes.mjs · generate-spread.mjs
            Kitchen stationsnode generate-stations.mjs · node generate-new-stations.mjs
            Som Tum, step by stepnode generate-som-tum.mjs
            The other 9 recipesnode generate-lessons.mjs · node generate-lessons.mjs pad-thai
            Wide logo, square iconnode generate-logo-restaurant.mjs · node generate-logo-icon.mjs
            9:16 posternode generate-poster.mjs
            A recipe's start image with no food referencenode generate-ingredients-start.mjs <recipe>
            Voicesnode generate-voices.mjs
            Interface soundsnode generate-sfx.mjs
            Musicnode generate-music.mjs

            None of this is a trick specific to a cooking game about Thailand. It's a method for building a small, finished product end to end: cut the concept down to its sensory core before writing code, test the interface's shape as a cheap picture before building it for real, let one layout answer to the device instead of writing one per device, and generate every asset, visual or audio, inside a system of references and data instead of treating each piece as if nothing came before it.