{"asset_map": {"grass_field_texture": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/grass_field_texture_ac10ed7e-f7a9-4f68-bc81-01fa8db8cfd7.webp", "type": "image", "prompt": "Generate a seamless tileable grass texture for a top-down view game. Bright green color #7EC850 with subtle shade variations. Simple cartoon style, featuring small stylized grass blades and tiny colorful flowers scattered throughout. Clean, vibrant, and cheerful aesthetic for a casual mobile game, repeating perfectly in both horizontal and vertical directions.", "description": "A seamless tileable bright green grass texture for the farm floor.", "subtype": "ground", "aspect_ratio": [1024, 1024], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "egg_white": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/egg_white_bd6e76d2-083c-4715-879c-c6e5b41a0864.webp", "type": "image", "prompt": "Generate a top-down view of a single white chicken egg. Oval shape, cream white color #F5F5DC with very subtle brown speckles. Simple cartoon style with soft shading to indicate roundness. Clean silhouette on a transparent background, high resolution, game-ready.", "description": "A simple white chicken egg viewed from a top-down perspective.", "subtype": "object", "aspect_ratio": [625, 813], "compression_suggestion": "high", "duration_secs": null, "loop": null, "animation": null}, "chick_yellow": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/chick_yellow_e53e41d3-ffd2-4173-a3b2-7f3607fc9aaa.webp", "type": "image", "prompt": "Generate a top-down view illustration of an adorable baby chick. Round, fluffy bright yellow body #FFD700. Small orange beak and two tiny black dots for eyes visible from above. Cute cartoon style, simple readable shapes, soft edges. High quality, transparent background.", "description": "An adorable small yellow baby chick viewed from above.", "subtype": "character", "aspect_ratio": [961, 898], "compression_suggestion": "high", "duration_secs": null, "loop": null, "animation": null}, "chicken_adult_white": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/chicken_adult_white_a5d85668-b92f-4c4a-9eec-e091d075718d.webp", "type": "image", "prompt": "Generate a top-down view of an adult chicken. Round white body #FFFFFF with a prominent red comb on top of the head. Simple cartoon style, clean bold shapes, two small black dots for eyes. Standing illustration, transparent background, high resolution.", "description": "An adult white chicken viewed from a top-down perspective.", "subtype": "character", "aspect_ratio": [686, 765], "compression_suggestion": "medium", "duration_secs": null, "loop": null, "animation": null}, "fox_running": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/fox_running_e34c6a8d-b138-468c-8f8c-4a534893f251.webp", "type": "image", "prompt": "Generate a top-down view of a cartoon fox running horizontally, facing right. Orange-red body #FF6347 with a white-tipped bushy tail. Pointed ears visible from above, legs in a running motion. Friendly but mischievous expression. Clean cartoon style, transparent background.", "description": "A cartoon fox running horizontally, viewed from above.", "subtype": "character", "aspect_ratio": [1349, 682], "compression_suggestion": "medium", "duration_secs": null, "loop": null, "animation": null}, "golden_egg": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/golden_egg_a7338ca9-6bdc-44ee-ad29-ee5ca8efc229.webp", "type": "image", "prompt": "Generate a top-down view of a magical golden egg. Shiny metallic gold color #FFD700 with bright highlights and small sparkle effects. Slightly larger than a standard egg, exaggerated shine, high-quality cartoon style. Transparent background.", "description": "A shiny, magical golden egg for special events.", "subtype": "object", "aspect_ratio": [826, 1074], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "chicken_coop_small": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/chicken_coop_small_dfd96018-05a5-4657-8d8e-02532d67a25b.webp", "type": "image", "prompt": "Generate a top-down view of a small decorative chicken coop. Simple red barn-style structure with white trim and a triangular roof. Cute cartoon style, clean and cozy look, non-detailed but recognizable. Transparent background.", "description": "A decorative red chicken coop for the field corner.", "subtype": "object", "aspect_ratio": [808, 890], "compression_suggestion": "high", "duration_secs": null, "loop": null, "animation": null}, "hatch_button_base": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/hatch_button_base_6145320a-25ba-4228-b041-30c2762a21cd.webp", "type": "image", "prompt": "Generate a UI asset: a large circular button for a mobile game. Warm brown color #8B4513 with a thick yellow border. The word 'HATCH' is written in the center in bold, white, sans-serif, clearly readable letters. Cartoon style with a subtle 3D depth effect, highlights, and shadows. Transparent background.", "description": "A large UI button labeled 'HATCH' for player interaction.", "subtype": "ui", "aspect_ratio": [888, 890], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "egg_crack_sfx": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/egg_crack_sfx_3f9401b5-7196-4ec2-b3b4-33baa9877a7f.mp3", "type": "audio", "prompt": "A cute, cartoonish egg hatching sound effect. Starts with a light, crisp shell-cracking noise followed by a soft, satisfying 'pop' sound. High-frequency, clean, and cheerful. Suitable for a casual mobile game, non-realistic, playful texture.", "description": "A crisp and cute egg cracking sound followed by a soft pop for the hatching mechanic.", "subtype": "effect", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 1.6206575963718821, "loop": false, "animation": null}, "chicken_cluck_sfx": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/chicken_cluck_sfx_5629a35e-9eb3-45f1-8979-83d2f780ce25.mp3", "type": "audio", "prompt": "A friendly, short 'cluck-cluck' sound effect. Stylized cartoon chicken voice, cheerful and upbeat. High-pitched and bouncy, not realistic. Perfect for a casual farm game UI or character feedback.", "description": "A short, happy cartoon chicken cluck for adult chicken interactions.", "subtype": "effect", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 2, "loop": false, "animation": null}, "fox_scare_sfx": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/fox_scare_sfx_ecee9349-9bdf-413b-ba16-889f8803657d.mp3", "type": "audio", "prompt": "Comedic fox yelp sound effect, high-pitched 'yip!' of surprise. Playful, funny, and startled tone. Cartoon aesthetic, quick decay, sounds like a small animal scurrying away in a humorous way.", "description": "A comedic, high-pitched fox yelp for when the fox is tapped and scared away.", "subtype": "effect", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 1.68, "loop": false, "animation": null}, "golden_egg_chime": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/golden_egg_chime_18c2455e-b853-4292-825d-1d09884c5b00.mp3", "type": "audio", "prompt": "Magical reward chime, bright sparkly bell tones with an ascending melodic scale. Shimmering texture, sounds like collecting treasure or a power-up. Cheerful, high-quality, digital synth bells with a clean reverb tail.", "description": "A magical, sparkly chime used when the player collects a rare golden egg.", "subtype": "effect", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 1.48, "loop": false, "animation": null}, "win_fanfare": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/win_fanfare_e5f4d413-06b9-4732-8264-389d865c0c3d.mp3", "type": "audio", "prompt": "Short victory fanfare, celebratory and triumphant melody. Bright trumpets, orchestral bells, and a happy major-key resolution. High energy, 120 BPM, classic game-win feel, loud and proud, lasting 3 seconds.", "description": "A triumphant, upbeat musical sting for reaching the 30-chicken population goal.", "subtype": "music", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 3, "loop": false, "animation": null}, "background_music_farm": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/sounds/effect/background_music_farm_9f337fd2-b458-48f7-97cd-ecf62d3b4d8a.mp3", "type": "audio", "prompt": "Cheerful, relaxing acoustic background music for a casual farm game. Features a bouncy ukulele rhythm, playful xylophone melodies, and light woodblock percussion. 110 BPM, C major, happy and sun-drenched vibe. Seamless loop, constant energy, no heavy bass or vocals.", "description": "Playful and relaxing farm-themed background music featuring ukulele and xylophone.", "subtype": "music", "aspect_ratio": null, "compression_suggestion": "original", "duration_secs": 30, "loop": true, "animation": null}, "egg_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/egg_v2_5a48a6cc-6bf9-4886-a73a-18e673a93174.webp", "type": "image", "prompt": "Generate a clean, simple white chicken egg viewed from a top-down perspective. Smooth texture, polished cartoon style with subtle soft shading for 3D dimension. Professional game-ready asset, isolated on a transparent background, matching the art style of image 1.", "description": "A refined, clean white chicken egg from a top-down perspective for the game field.", "subtype": "object", "aspect_ratio": [832, 1082], "compression_suggestion": "high", "duration_secs": null, "loop": null, "animation": null}, "chick_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/chick_v2_ad90b111-d2a4-43ba-93e1-fc14a7b7ac15.webp", "type": "image", "prompt": "Generate a top-down view of an adorable, small, fluffy yellow baby chick. Round body, tiny orange beak, and small wings on the sides. Cute cartoon style, bright colors, clean lines, professional game asset, isolated on a transparent background. Match the perspective and art style of image 1.", "description": "An adorable, fluffy yellow baby chick viewed from a top-down perspective.", "subtype": "character", "aspect_ratio": [828, 804], "compression_suggestion": "medium", "duration_secs": null, "loop": null, "animation": null}, "hen_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/hen_v2_87baf7a3-006d-4c09-8481-b7c936cee391.webp", "type": "image", "prompt": "Generate a full-body, top-down view of a friendly adult white chicken. Features include a bright red comb, a large orange beak with a visible smiling mouth, small tail feathers, and visible wings tucked to the sides. Polished cartoon style with clean lines and bright colors, matching the aesthetic of chick_v2 and egg_v2. High resolution, professional game asset, isolated on a transparent background.", "description": "An adult white chicken character for the farm, viewed from a top-down perspective with a friendly expression.", "subtype": "character", "aspect_ratio": [827, 1047], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "golden_hen_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/golden_hen_v2_fb57842f-259c-4b5e-943c-27aa1bea3f9f.webp", "type": "image", "prompt": "Generate a top-down view of a large, plump golden hen with a distinct fat body silhouette. The hen features shimmering golden feathers, large decorative tail feathers, and wings larger than a standard hen. Add a subtle magical golden glow effect around the body. Friendly cartoon style matching the aesthetic of image 1, high resolution, detailed, professional quality game asset, isolated on a transparent background.", "description": "A large, plump magical golden hen with shimmering feathers and a fat silhouette, viewed from a top-down perspective.", "subtype": "character", "aspect_ratio": [719, 1031], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "chicken_king_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/chicken_king_v2_582266d4-3298-4be9-8657-4759d6e698ce.webp", "type": "image", "prompt": "Generate a top-down view of a giant, majestic chicken king. The chicken is wearing a shiny golden crown with small jewels and a regal red royal cape draped over its back. It features very large, decorative tail feathers and a powerful, plump silhouette. A subtle golden aura glow surrounds the character. Style should match the friendly cartoon aesthetic of the other chickens. Full body illustration, top-down perspective, front-facing, high resolution, detailed, professional quality, isolated on a transparent background.", "description": "A majestic giant chicken king with a crown and cape, the most impressive character in the game.", "subtype": "character", "aspect_ratio": [709, 1039], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}, "rainbow_hen_v2": {"url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/rainbow_hen_v2_940c6007-82e4-47a2-8f56-016f7966ad4e.webp", "type": "image", "prompt": "Generate a large, plump hen viewed from a top-down perspective, matching the fat silhouette and body shape of image 1. The hen has vibrant, shimmering rainbow-colored feathers with a magical sparkling effect. Features large decorative tail feathers and visible wings. Friendly cartoon style, high resolution, professional quality game asset, isolated on a transparent background.", "description": "A large, fat-bodied hen with shimmering rainbow feathers and a magical sparkle effect, viewed from a top-down perspective.", "subtype": "character", "aspect_ratio": [829, 1199], "compression_suggestion": "low", "duration_secs": null, "loop": null, "animation": null}}, "game_code": "<!DOCTYPE html>\n<html>\n<head>\n    <title>Chicken Panic</title>\n    <style>\n        @import url('https://fonts.googleapis.com/css2?family=Chewy&family=Inter:wght@400;600;700&display=swap');\n\n        :root {\n            /* Animation Timings */\n            --transition-fast: 150ms;\n            --transition-normal: 300ms;\n            --transition-slow: 500ms;\n\n            /* Easing Functions */\n            --ease-out: cubic-bezier(0.0, 0, 0.2, 1);\n            --ease-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);\n\n            /* Spacing Scale (8px grid) */\n            --space-xs: 8px;\n            --space-sm: 16px;\n            --space-md: 24px;\n            --space-lg: 32px;\n            --space-xl: 48px;\n        }\n\n        /* CSS Reset */\n        * {\n            margin: 0;\n            padding: 0;\n            box-sizing: border-box;\n        }\n\n        body, html {\n            width: 100%;\n            height: 100%;\n            overflow: hidden;\n            touch-action: none;\n            -ms-touch-action: none;\n            font-family: 'Inter', sans-serif;\n        }\n\n        /* Main Game Container */\n        #game-world {\n            position: relative;\n            width: 100%;\n            height: 100%;\n            background-color: #7EC850;\n            background-image: url('');\n            background-size: 128px 128px;\n            overflow: hidden;\n        }\n\n        /* Canvas for game objects */\n        #game-canvas {\n            position: absolute;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            touch-action: none;\n        }\n\n        /* UI Overlay - pass through pointer events */\n        #ui-overlay {\n            position: absolute;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            pointer-events: none;\n            z-index: 10;\n        }\n\n        .ui-overlay > * {\n            pointer-events: auto;\n        }\n\n        /* Top Stats Bar */\n        #stats {\n            position: absolute;\n            top: var(--space-sm);\n            left: var(--space-sm);\n            right: var(--space-sm);\n            display: flex;\n            justify-content: space-between;\n            gap: var(--space-sm);\n        }\n\n        .stat-box {\n            background: rgba(139, 69, 19, 0.9);\n            color: #FFD700;\n            padding: var(--space-sm) var(--space-md);\n            border-radius: 16px;\n            font-size: 24px;\n            font-weight: 700;\n            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);\n            border: 3px solid #FFD700;\n            pointer-events: none;\n        }\n\n        /* Controls Container */\n        #controls {\n            position: absolute;\n            bottom: var(--space-lg);\n            left: 50%;\n            transform: translateX(-50%);\n            pointer-events: none;\n            z-index: 20;\n        }\n\n        .controls > * {\n            pointer-events: auto;\n        }\n\n        /* Get Egg Button */\n        #spawn-button {\n            width: 200px;\n            height: 200px;\n            border-radius: 50%;\n            background: linear-gradient(135deg, #A0522D 0%, #8B4513 50%, #6B3410 100%);\n            border: 6px solid #FFD700;\n            color: #FFFFFF;\n            font-family: 'Chewy', cursive;\n            font-size: 40px;\n            text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.6);\n            cursor: pointer;\n            user-select: none;\n            pointer-events: auto;\n            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);\n            transition: transform var(--transition-fast) var(--ease-out);\n        }\n\n        #spawn-button:hover {\n            transform: scale(1.05);\n        }\n\n        #spawn-button:active,\n        #spawn-button.pressed {\n            transform: scale(0.95);\n            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);\n        }\n\n        /* Win Screen */\n        #win-screen {\n            position: absolute;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            background: rgba(0, 0, 0, 0.8);\n            display: none;\n            flex-direction: column;\n            justify-content: center;\n            align-items: center;\n            gap: var(--space-xl);\n            z-index: 100;\n        }\n\n        #win-screen.show {\n            display: flex;\n        }\n\n        .win-title {\n            font-family: 'Chewy', cursive;\n            font-size: 60px;\n            color: #FFD700;\n            text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.8);\n            animation: bounce 0.6s var(--ease-bounce);\n        }\n\n        .win-score {\n            font-size: 32px;\n            color: #FFFFFF;\n            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);\n        }\n\n        .restart-button {\n            padding: var(--space-md) var(--space-xl);\n            font-size: 32px;\n            font-family: 'Chewy', cursive;\n            background: linear-gradient(135deg, #7EC850 0%, #6BB040 100%);\n            color: #FFFFFF;\n            border: 4px solid #FFD700;\n            border-radius: 16px;\n            cursor: pointer;\n            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);\n            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);\n            transition: transform var(--transition-fast) var(--ease-out);\n        }\n\n        .restart-button:hover {\n            transform: scale(1.05);\n        }\n\n        .restart-button:active {\n            transform: scale(0.95);\n        }\n\n        /* Edit Mode Overlay */\n        .edit-overlay {\n            position: absolute;\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            pointer-events: none;\n            z-index: 5;\n        }\n\n        .selection-ring {\n            position: absolute;\n            border: 3px dashed #FFD700;\n            border-radius: 50%;\n            pointer-events: none;\n            animation: rotate 2s linear infinite;\n        }\n\n        @keyframes bounce {\n            0%, 100% { transform: scale(1); }\n            50% { transform: scale(1.1); }\n        }\n\n        @keyframes rotate {\n            from { transform: rotate(0deg); }\n            to { transform: rotate(360deg); }\n        }\n\n        @keyframes pulse {\n            0%, 100% { opacity: 1; }\n            50% { opacity: 0.6; }\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n            * {\n                animation-duration: 0.01ms !important;\n                animation-iteration-count: 1 !important;\n                transition-duration: 0.01ms !important;\n            }\n        }\n    </style>\n</head>\n<body>\n    <div id=\"game-world\">\n        <canvas id=\"game-canvas\"></canvas>\n        <div id=\"ui-overlay\">\n            <div id=\"stats\">\n                <div class=\"stat-box\" id=\"chicken-count\">\ud83d\udc14 0</div>\n                <div class=\"stat-box\" id=\"level-display\">Level 1</div>\n                <div class=\"stat-box\" id=\"score\">\u2b50 0</div>\n            </div>\n        </div>\n        <div id=\"controls\">\n            <button id=\"spawn-button\">GET EGG</button>\n        </div>\n        <div id=\"win-screen\">\n            <div class=\"win-title\">FARM FULL!</div>\n            <div class=\"win-score\" id=\"final-score\">Final Score: 0</div>\n            <button class=\"restart-button\" onclick=\"location.reload()\">PLAY AGAIN</button>\n        </div>\n    </div>\n\n    <script>\n        /**\n         * CHICKEN PANIC: MERGE EVOLUTION\n         * \n         * A merge game where players evolve chickens from eggs to the Golden Hen.\n         * Drag and drop identical objects to merge them into the next tier.\n         * Higher-tier chickens automatically lay eggs to help your farm grow!\n         */\n\n        const TIERS = [\n            { id: 'egg', asset: 'egg_v2', name: 'Egg', size: 70, spawnRate: Infinity },\n            { id: 'chick', asset: 'chick_v2', name: 'Chick', size: 85, spawnRate: Infinity },\n            { id: 'hen', asset: 'hen_v2', name: 'Hen', size: 110, spawnRate: 12 },\n            { id: 'golden_hen', asset: 'golden_hen_v2', name: 'Golden Hen', size: 140, spawnRate: 4, hasGlow: true }\n        ];\n\n        async function run(mode) {\n            const gameWorld = document.getElementById('game-world');\n            const canvas = document.getElementById('game-canvas');\n            const ctx = canvas.getContext('2d');\n\n            function resizeCanvas() {\n                canvas.width = gameWorld.clientWidth;\n                canvas.height = gameWorld.clientHeight;\n            }\n            resizeCanvas();\n            window.addEventListener('resize', resizeCanvas);\n\n            const audioContext = new (window.AudioContext || window.webkitAudioContext)();\n            const audioBuffers = {};\n            const assetCache = {};\n            let assetsLoaded = false;\n\n            async function preloadAssets(assetIds) {\n                const promises = assetIds.map(async id => {\n                    const assetInfo = lib.getAsset(id);\n                    if (!assetInfo) return;\n                    if (assetInfo.type === 'image') {\n                        return new Promise((resolve, reject) => {\n                            const img = new Image();\n                            img.onload = () => { assetCache[id] = img; resolve(); };\n                            img.onerror = reject;\n                            img.src = assetInfo.url;\n                        });\n                    } else if (assetInfo.type === 'audio') {\n                        try {\n                            const response = await fetch(assetInfo.url);\n                            const arrayBuffer = await response.arrayBuffer();\n                            const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);\n                            audioBuffers[id] = audioBuffer;\n                        } catch (e) { console.error(e); }\n                    }\n                });\n                await Promise.all(promises);\n                assetsLoaded = true;\n                const grassAsset = lib.getAsset('grass_field_texture');\n                if (grassAsset) gameWorld.style.backgroundImage = `url(${grassAsset.url})`;\n            }\n\n            function playSound(soundId) {\n                if (!audioBuffers[soundId]) return;\n                const source = audioContext.createBufferSource();\n                source.buffer = audioBuffers[soundId];\n                source.connect(audioContext.destination);\n                source.start(0);\n            }\n\n            let musicSource = null;\n            function startBackgroundMusic() {\n                if (!audioBuffers['background_music_farm'] || musicSource) return;\n                musicSource = audioContext.createBufferSource();\n                musicSource.buffer = audioBuffers['background_music_farm'];\n                musicSource.loop = true;\n                const gainNode = audioContext.createGain();\n                gainNode.gain.value = 0.3;\n                musicSource.connect(gainNode);\n                gainNode.connect(audioContext.destination);\n                musicSource.start(0);\n            }\n\n            await preloadAssets([\n                'grass_field_texture', 'egg_v2', 'chick_v2', 'hen_v2',\n                'golden_hen_v2', 'chicken_coop_small', 'fox_running',\n                'egg_crack_sfx', 'chicken_cluck_sfx', 'golden_egg_chime', 'fox_scare_sfx',\n                'win_fanfare', 'background_music_farm'\n            ]);\n\n            lib.showGameParameters({\n                name: \"Merge & Fox Settings\",\n                params: {\n                    \"Hen Spawn Rate (s)\": { key: \"spawnRates.hen\", type: \"slider\", min: 5, max: 30, step: 1 },\n                    \"Golden Hen Spawn Rate (s)\": { key: \"spawnRates.golden_hen\", type: \"slider\", min: 1, max: 15, step: 1 },\n                    \"Fox Interval (s)\": { key: \"foxInterval\", type: \"slider\", min: 5, max: 40, step: 1 },\n                    \"Max Objects\": { key: \"maxObjects\", type: \"slider\", min: 20, max: 80, step: 5 },\n                    \"Win Goal (Chickens)\": { key: \"winGoal\", type: \"slider\", min: 10, max: 50, step: 5 }\n                }\n            });\n\n            // Ensure config exists\n            window.gameConfig.spawnRates = window.gameConfig.spawnRates || {\n                hen: 15, golden_hen: 8\n            };\n            window.gameConfig.foxInterval = window.gameConfig.foxInterval || 15;\n            window.gameConfig.maxObjects = window.gameConfig.maxObjects || 40;\n            window.gameConfig.winGoal = window.gameConfig.winGoal || 30;\n\n            const gameState = {\n                objects: [],\n                particles: [],\n                foxes: [],\n                nextFoxTimer: 3,\n                score: 0,\n                gameWon: false,\n                draggingObject: null,\n                dragOffset: { x: 0, y: 0 },\n                lastTimestamp: 0,\n                eggSpawningPaused: false,\n                level: 1,\n                levelTimer: 30\n            };\n\n            function spawnObject(tierIndex, x, y) {\n                if (gameState.objects.length >= window.gameConfig.maxObjects) return null;\n\n                // Egg limit logic: Max 20 eggs. Pause until < 16.\n                if (tierIndex === 0) {\n                    const eggCount = gameState.objects.filter(o => o.tierIndex === 0 && !o.isBones).length;\n                    if (gameState.eggSpawningPaused) {\n                        if (eggCount >= 16) return null;\n                        gameState.eggSpawningPaused = false;\n                    } else if (eggCount >= 20) {\n                        gameState.eggSpawningPaused = true;\n                        return null;\n                    }\n                }\n\n                const obj = {\n                    tierIndex,\n                    x: x || canvas.width / 2,\n                    y: y || canvas.height / 2,\n                    id: Math.random().toString(36).substr(2, 9),\n                    timeSinceLastEgg: 0,\n                    bobOffset: Math.random() * Math.PI * 2,\n                    scale: 0.1,\n                    targetScale: 1,\n                    targetX: null,\n                    targetY: null,\n                    waitTimer: Math.random() * 2,\n                    lastVx: (Math.random() - 0.5),\n                    lifespan: tierIndex === 3 ? 30 : null, // 30s for Golden Hen\n                    isBones: false,\n                    bonesTaps: 0\n                };\n                gameState.objects.push(obj);\n                return obj;\n            }\n\n            if (mode === 'play') {\n                spawnObject(0, canvas.width / 2, canvas.height / 2);\n                startBackgroundMusic();\n            }\n\n            const spawnButton = document.getElementById('spawn-button');\n            const scoreEl = document.getElementById('score');\n            const chickenCountEl = document.getElementById('chicken-count');\n            const levelDisplayEl = document.getElementById('level-display');\n            const winScreen = document.getElementById('win-screen');\n            const finalScoreEl = document.getElementById('final-score');\n\n            function updateUI() {\n                const count = gameState.objects.filter(o => o.tierIndex >= 2).length;\n                chickenCountEl.textContent = `\ud83d\udc14 ${count}`;\n                scoreEl.textContent = `\u2b50 ${gameState.score}`;\n                levelDisplayEl.textContent = gameState.level > 10 ? \"Endless Mode\" : `Level ${gameState.level}`;\n            }\n\n            function spawnFox() {\n                const types = ['normal', 'golden', 'sleeping', 'greedy'];\n                const type = types[Math.floor(Math.random() * types.length)];\n                \n                let x, y;\n                const side = Math.floor(Math.random() * 4);\n                if (side === 0) { x = -100; y = Math.random() * canvas.height; }\n                else if (side === 1) { x = canvas.width + 100; y = Math.random() * canvas.height; }\n                else if (side === 2) { x = Math.random() * canvas.width; y = -100; }\n                else { x = Math.random() * canvas.width; y = canvas.height + 100; }\n\n                const adultCount = gameState.objects.filter(o => o.tierIndex >= 2).length;\n                const levelBoost = (gameState.level - 1) * 0.1;\n                const speedBoost = 1.2 + (adultCount * 0.08) + levelBoost; // Faster base and faster scaling with level\n                \n                let maxTaps = 1;\n                if (type === 'greedy') maxTaps = 1;\n                if (type === 'golden') maxTaps = 1;\n                if (type === 'sleeping') maxTaps = 1;\n\n                gameState.foxes.push({\n                    id: Math.random().toString(36).substr(2, 9),\n                    type, x, y,\n                    speed: (type === 'golden' ? 240 : 170) * speedBoost,\n                    state: 'searching',\n                    stolenObjects: [],\n                    maxSteal: type === 'greedy' ? 3 : 1,\n                    taps: 0,\n                    maxTaps: maxTaps,\n                    angle: 0,\n                    sleepTimer: 0,\n                    attackCooldown: 0\n                });\n            }\n\n            function getFoxAt(x, y) {\n                for (let i = gameState.foxes.length - 1; i >= 0; i--) {\n                    const f = gameState.foxes[i];\n                    const dist = Math.sqrt((x - f.x) ** 2 + (y - f.y) ** 2);\n                    if (dist < 100) return f;\n                }\n                return null;\n            }\n\n            function updateFoxes(deltaTime) {\n                const eggCount = gameState.objects.filter(o => o.tierIndex === 0 && !o.isBones).length;\n                \n                // Fox balancing logic:\n                // 0\u20133 eggs = 0 fox\n                // 4\u20137 eggs = 1 fox\n                // 8\u201311 eggs = 2 foxes\n                // 12\u201315 eggs = 3 foxes\n                // 16\u201320 eggs = 4 foxes\n                let desiredFoxes = 0;\n                if (eggCount >= 4 && eggCount <= 7) desiredFoxes = 1;\n                else if (eggCount >= 8 && eggCount <= 11) desiredFoxes = 2;\n                else if (eggCount >= 12 && eggCount <= 15) desiredFoxes = 3;\n                else if (eggCount >= 16) desiredFoxes = 4;\n\n                gameState.nextFoxTimer -= deltaTime;\n                if (gameState.nextFoxTimer <= 0) {\n                    if (gameState.foxes.filter(f => f.state !== 'escaping' && f.state !== 'fleeing').length < desiredFoxes) {\n                        spawnFox();\n                        gameState.nextFoxTimer = 3; // Delay between spawns\n                    } else {\n                        gameState.nextFoxTimer = 1; // Check again soon\n                    }\n                }\n\n                // If egg count dropped, extra foxes should escape\n                let activeFoxes = gameState.foxes.filter(f => f.state === 'searching' || f.state === 'sleeping');\n                if (activeFoxes.length > desiredFoxes) {\n                    let toRemove = activeFoxes.length - desiredFoxes;\n                    for (let f of activeFoxes) {\n                        if (toRemove <= 0) break;\n                        f.state = 'escaping';\n                        toRemove--;\n                    }\n                }\n\n                for (let i = gameState.foxes.length - 1; i >= 0; i--) {\n                    const f = gameState.foxes[i];\n                    if (f.attackCooldown > 0) f.attackCooldown -= deltaTime;\n\n                    // PRE-CHECK: Collision with Golden Chickens\n                    let touchedGolden = false;\n                    for (const obj of gameState.objects) {\n                        if (obj.isBones || obj.tierIndex < 3) continue;\n                        const distToObj = Math.sqrt((obj.x - f.x)**2 + (obj.y - f.y)**2);\n                        if (distToObj < 70) {\n                            touchedGolden = true;\n                            break;\n                        }\n                    }\n\n                    if (touchedGolden) {\n                        createParticles(f.x, f.y, '#FFFFFF', 20, \"POOF!\"); \n                        createParticles(f.x, f.y, '#FFD700', 15);\n                        playSound('fox_scare_sfx');\n                        gameState.foxes.splice(i, 1);\n                        continue;\n                    }\n                    \n                    if (f.state === 'searching') {\n                        if (f.attackCooldown > 0) {\n                            // Roam while on cooldown\n                            f.x += Math.cos(f.angle) * f.speed * 0.4 * deltaTime;\n                            f.y += Math.sin(f.angle) * f.speed * 0.4 * deltaTime;\n                            if (Math.random() < 0.02) f.angle += (Math.random() - 0.5);\n                            \n                            // Bounds check for roaming\n                            if (f.x < 50 || f.x > canvas.width - 50 || f.y < 50 || f.y > canvas.height - 450) {\n                                f.angle += Math.PI;\n                            }\n                            continue;\n                        }\n\n                        // Priority: Hen > Chick > Egg\n                        let target = null;\n                        let minDist = Infinity;\n                        \n                        // Priority 1: Adult Hen\n                        for (const obj of gameState.objects) {\n                            if (obj.isBones || obj.tierIndex < 2) continue;\n                            const d = Math.sqrt((obj.x - f.x) ** 2 + (obj.y - f.y) ** 2);\n                            if (d < minDist) { minDist = d; target = obj; }\n                        }\n                        \n                        // Priority 2: Chick\n                        if (!target) {\n                            for (const obj of gameState.objects) {\n                                if (obj.isBones || obj.tierIndex !== 1) continue;\n                                const d = Math.sqrt((obj.x - f.x) ** 2 + (obj.y - f.y) ** 2);\n                                if (d < minDist) { minDist = d; target = obj; }\n                            }\n                        }\n                        \n                        // Priority 3: Egg\n                        if (!target) {\n                            for (const obj of gameState.objects) {\n                                if (obj.isBones || obj.tierIndex !== 0) continue;\n                                const d = Math.sqrt((obj.x - f.x) ** 2 + (obj.y - f.y) ** 2);\n                                if (d < minDist) { minDist = d; target = obj; }\n                            }\n                        }\n                        \n                        if (target) {\n                            const angle = Math.atan2(target.y - f.y, target.x - f.x);\n                            f.angle = angle;\n                            const distToTarget = Math.sqrt((target.x - f.x)**2 + (target.y - f.y)**2);\n                            const dashSpeed = distToTarget < 220 ? 1.8 : 1.0;\n                            f.x += Math.cos(angle) * f.speed * dashSpeed * deltaTime;\n                            f.y += Math.sin(angle) * f.speed * dashSpeed * deltaTime;\n                            \n                            for (let j = gameState.objects.length - 1; j >= 0; j--) {\n                                const obj = gameState.objects[j];\n                                if (obj.isBones) continue; \n                                \n                                const distToObj = Math.sqrt((obj.x - f.x)**2 + (obj.y - f.y)**2);\n                                const collideDist = (obj.tierIndex >= 2) ? 65 : 45; \n                                \n                                if (distToObj < collideDist) {\n                                    f.attackCooldown = 6; // Attack cooldown\n\n                                    if (obj.tierIndex >= 2) {\n                                        gameState.objects.splice(j, 1);\n                                        createParticles(obj.x, obj.y, '#FFFFFF', 20);\n                                        playSound('chicken_cluck_sfx');\n                                        f.state = 'escaping'; \n                                        createParticles(f.x, f.y, '#FF0000', 5);\n                                        break;\n                                    } else if (f.stolenObjects.length < f.maxSteal) {\n                                        f.stolenObjects.push(obj);\n                                        gameState.objects.splice(j, 1);\n                                        if (f.stolenObjects.length >= f.maxSteal) f.state = 'escaping';\n                                        createParticles(f.x, f.y, '#FF0000', 5);\n                                        break;\n                                    }\n                                }\n                            }\n                        } else {\n                            // No targets, might as well wander or escape\n                            if (Math.random() < 0.01) f.state = 'escaping';\n                        }\n                        \n                        if (f.type === 'sleeping' && Math.random() < 0.005) {\n                            f.state = 'sleeping';\n                            f.sleepTimer = 2 + Math.random() * 2;\n                        }\n                    } else if (f.state === 'escaping' || f.state === 'fleeing') {\n                        let speedMultiplier = 2.5;\n                        const targetX = f.state === 'fleeing' ? f.x + Math.cos(f.angle) * 500 : (f.x < canvas.width/2 ? -200 : canvas.width + 200);\n                        const targetY = f.y;\n                        f.angle = Math.atan2(targetY - f.y, targetX - f.x);\n                        \n                        f.x += Math.cos(f.angle) * f.speed * speedMultiplier * deltaTime;\n                        f.y += Math.sin(f.angle) * f.speed * speedMultiplier * deltaTime;\n                        \n                        f.stolenObjects.forEach((obj, idx) => {\n                            obj.x = f.x - Math.cos(f.angle) * (40 + idx * 30);\n                            obj.y = f.y - Math.sin(f.angle) * (40 + idx * 30);\n                        });\n\n                        if (f.x < -300 || f.x > canvas.width + 300 || f.y < -300 || f.y > canvas.height + 300) {\n                            gameState.foxes.splice(i, 1);\n                        }\n                    } else if (f.state === 'sleeping') {\n                        f.sleepTimer -= deltaTime;\n                        if (f.sleepTimer <= 0) f.state = 'searching';\n                    }\n                }\n            }\n\n            spawnButton.addEventListener('click', () => {\n                if (mode !== 'play') return;\n                const margin = 100;\n                const x = margin + Math.random() * (canvas.width - margin * 2);\n                const y = margin + Math.random() * (canvas.height - 450);\n                if (spawnObject(0, x, y)) {\n                    playSound('egg_crack_sfx');\n                    updateUI();\n                }\n            });\n\n            function getObjectAt(x, y) {\n                for (let i = gameState.objects.length - 1; i >= 0; i--) {\n                    const obj = gameState.objects[i];\n                    const tier = TIERS[obj.tierIndex];\n                    const dist = Math.sqrt((x - obj.x) ** 2 + (y - obj.y) ** 2);\n                    const size = obj.isBones ? 80 : tier.size;\n                    if (dist < size / 1.5) return obj;\n                }\n                return null;\n            }\n\n            function handleInputStart(x, y) {\n                if (mode === 'play') {\n                    const fox = getFoxAt(x, y);\n                    if (fox && fox.state !== 'fleeing' && fox.state !== 'scared') {\n                        fox.taps++;\n                        createParticles(x, y, '#FFFFFF', 10);\n                        if (fox.taps >= fox.maxTaps) {\n                            fox.state = 'fleeing';\n                            fox.stolenObjects.forEach(obj => {\n                                obj.x = fox.x + (Math.random() - 0.5) * 60;\n                                obj.y = fox.y + (Math.random() - 0.5) * 60;\n                                gameState.objects.push(obj);\n                            });\n                            fox.stolenObjects = [];\n                            gameState.score += (fox.type === 'golden' ? 500 : 200);\n                            playSound('fox_scare_sfx');\n                        }\n                        return;\n                    }\n                }\n                const obj = getObjectAt(x, y);\n                if (obj) {\n                    if (obj.isBones) {\n                        obj.bonesTaps++;\n                        createParticles(x, y, '#DDD', 5);\n                        if (obj.bonesTaps >= 5) {\n                            const idx = gameState.objects.indexOf(obj);\n                            gameState.objects.splice(idx, 1);\n                            playSound('fox_scare_sfx'); // Use a relevant sound\n                        }\n                        return;\n                    }\n                    gameState.draggingObject = obj;\n                    gameState.dragOffset = { x: x - obj.x, y: y - obj.y };\n                    const idx = gameState.objects.indexOf(obj);\n                    gameState.objects.splice(idx, 1);\n                    gameState.objects.push(obj);\n                }\n            }\n\n            function handleInputMove(x, y) {\n                if (gameState.draggingObject) {\n                    gameState.draggingObject.x = Math.max(50, Math.min(canvas.width - 50, x - gameState.dragOffset.x));\n                    gameState.draggingObject.y = Math.max(50, Math.min(canvas.height - 50, y - gameState.dragOffset.y));\n                }\n            }\n\n            function handleInputEnd() {\n                if (!gameState.draggingObject) return;\n                const obj = gameState.draggingObject;\n                gameState.draggingObject = null;\n\n                if (mode === 'play') {\n                    for (let i = gameState.objects.length - 2; i >= 0; i--) {\n                        const other = gameState.objects[i];\n                        if (other === obj || other.isBones) continue;\n                        const tier = TIERS[obj.tierIndex];\n                        const dist = Math.sqrt((obj.x - other.x) ** 2 + (obj.y - other.y) ** 2);\n                        if (dist < tier.size && obj.tierIndex === other.tierIndex && obj.tierIndex < TIERS.length - 1) {\n                            const newTier = obj.tierIndex + 1;\n                            const mergeX = (obj.x + other.x) / 2;\n                            const mergeY = (obj.y + other.y) / 2;\n                            gameState.objects.splice(gameState.objects.indexOf(obj), 1);\n                            gameState.objects.splice(gameState.objects.indexOf(other), 1);\n                            spawnObject(newTier, mergeX, mergeY);\n                            gameState.score += (newTier + 1) * 10;\n                            playSound(newTier >= 2 ? 'chicken_cluck_sfx' : 'egg_crack_sfx');\n                            createParticles(mergeX, mergeY, '#FFFFFF', 15);\n                            updateUI();\n                            return;\n                        }\n                    }\n                }\n            }\n\n            canvas.addEventListener('mousedown', e => handleInputStart(e.offsetX, e.offsetY));\n            window.addEventListener('mousemove', e => {\n                const rect = canvas.getBoundingClientRect();\n                handleInputMove(e.clientX - rect.left, e.clientY - rect.top);\n            });\n            window.addEventListener('mouseup', handleInputEnd);\n\n            canvas.addEventListener('touchstart', e => {\n                const rect = canvas.getBoundingClientRect();\n                const touch = e.touches[0];\n                handleInputStart(touch.clientX - rect.left, touch.clientY - rect.top);\n            }, { passive: false });\n            window.addEventListener('touchmove', e => {\n                const rect = canvas.getBoundingClientRect();\n                const touch = e.touches[0];\n                handleInputMove(touch.clientX - rect.left, touch.clientY - rect.top);\n            }, { passive: false });\n            window.addEventListener('touchend', handleInputEnd);\n\n            function createParticles(x, y, color, count, text = null) {\n                if (text) {\n                    gameState.particles.push({\n                        x, y, vx: 0, vy: -1, color: '#FFFFFF', life: 1, size: 25, text\n                    });\n                }\n                for (let i = 0; i < count; i++) {\n                    const angle = Math.random() * Math.PI * 2;\n                    const speed = 2 + Math.random() * 4;\n                    const isStar = color === '#FFD700' && Math.random() > 0.5;\n                    gameState.particles.push({\n                        x, y, vx: Math.cos(angle) * speed, vy: Math.sin(angle) * speed,\n                        color, life: 1, size: (isStar ? 6 : 3) + Math.random() * 5,\n                        isStar\n                    });\n                }\n            }\n\n            function drawParticle(p) {\n                if (p.text) {\n                    ctx.save();\n                    ctx.globalAlpha = Math.min(1, p.life * 2);\n                    ctx.fillStyle = '#FFD700';\n                    ctx.strokeStyle = '#000000';\n                    ctx.lineWidth = 3;\n                    const size = p.vx === 0 ? 50 : 25; // Larger for level messages\n                    ctx.font = 'bold ' + size + 'px Chewy';\n                    ctx.textAlign = 'center';\n                    ctx.strokeText(p.text, p.x, p.y);\n                    ctx.fillText(p.text, p.x, p.y);\n                    ctx.restore();\n                    return;\n                }\n                ctx.fillStyle = p.color;\n                ctx.globalAlpha = p.life;\n                if (p.isStar) {\n                    // Draw a simple 4-point star\n                    ctx.beginPath();\n                    for (let i = 0; i < 4; i++) {\n                        ctx.lineTo(p.x + Math.cos(i * Math.PI / 2) * p.size, p.y + Math.sin(i * Math.PI / 2) * p.size);\n                        ctx.lineTo(p.x + Math.cos(i * Math.PI / 2 + Math.PI / 4) * p.size / 2, p.y + Math.sin(i * Math.PI / 2 + Math.PI / 4) * p.size / 2);\n                    }\n                    ctx.closePath();\n                    ctx.fill();\n                } else {\n                    ctx.beginPath();\n                    ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);\n                    ctx.fill();\n                }\n                ctx.globalAlpha = 1;\n            }\n\n            function drawObject(obj) {\n                const tier = TIERS[obj.tierIndex];\n                const img = assetCache[tier.asset];\n                \n                if (obj.isBones) {\n                    ctx.save();\n                    ctx.translate(obj.x, obj.y);\n                    ctx.fillStyle = '#EEE';\n                    ctx.strokeStyle = '#999';\n                    ctx.lineWidth = 2;\n                    // Draw a pile of bones\n                    for (let i = 0; i < 3; i++) {\n                        ctx.rotate(Math.PI / 3);\n                        ctx.beginPath();\n                        ctx.roundRect(-20, -5, 40, 10, 5);\n                        ctx.fill();\n                        ctx.stroke();\n                        ctx.beginPath();\n                        ctx.arc(-20, 0, 6, 0, Math.PI * 2);\n                        ctx.arc(20, 0, 6, 0, Math.PI * 2);\n                        ctx.fill();\n                        ctx.stroke();\n                    }\n                    ctx.restore();\n\n                    // Draw UI text separately to avoid mirroring/rotation\n                    ctx.save();\n                    ctx.setTransform(1, 0, 0, 1, 0, 0); // Reset transform for UI elements\n                    ctx.fillStyle = '#333';\n                    ctx.font = 'bold 20px Arial';\n                    ctx.textAlign = 'center';\n                    ctx.fillText(`TAP ${5 - obj.bonesTaps}`, obj.x, obj.y + 35);\n                    ctx.restore();\n                    return;\n                }\n\n                if (!img) return;\n\n                ctx.save();\n                ctx.translate(obj.x, obj.y);\n                const bob = Math.sin(obj.bobOffset) * 3;\n                ctx.translate(0, bob);\n                \n                const flipX = (obj.lastVx < 0) ? -1 : 1;\n                ctx.scale(obj.scale * flipX, obj.scale);\n\n                if (tier.hasGlow) {\n                    ctx.shadowBlur = 20;\n                    ctx.shadowColor = '#FFD700';\n                }\n\n                const size = tier.size;\n                ctx.drawImage(img, -size / 2, -size / 2, size, size);\n                ctx.shadowBlur = 0;\n                ctx.restore();\n\n                // Draw timer for Golden Hen\n                if (obj.tierIndex === 3 && mode === 'play' && !obj.isBones) {\n                    ctx.save();\n                    ctx.setTransform(1, 0, 0, 1, 0, 0);\n                    ctx.fillStyle = '#FFF';\n                    ctx.strokeStyle = '#000';\n                    ctx.lineWidth = 3;\n                    ctx.font = 'bold 24px Arial';\n                    ctx.textAlign = 'center';\n                    const timeStr = Math.ceil(obj.lifespan) + 's';\n                    ctx.strokeText(timeStr, obj.x, obj.y - size/2 - 10);\n                    ctx.fillText(timeStr, obj.x, obj.y - size/2 - 10);\n                    ctx.restore();\n                }\n\n                if (mode === 'play' && tier.spawnRate !== Infinity) {\n                    ctx.save();\n                    ctx.setTransform(1, 0, 0, 1, 0, 0);\n                    const rate = window.gameConfig.spawnRates[tier.id] || tier.spawnRate;\n                    const progress = obj.timeSinceLastEgg / rate;\n                    ctx.fillStyle = 'rgba(0,0,0,0.3)';\n                    ctx.fillRect(obj.x - 25, obj.y + size/2 + 5, 50, 8);\n                    ctx.fillStyle = '#FFD700';\n                    ctx.fillRect(obj.x - 25, obj.y + size/2 + 5, 50 * Math.min(1, progress), 8);\n                    ctx.restore();\n                }\n            }\n\n            function gameLoop(timestamp) {\n                let deltaTime = (timestamp - gameState.lastTimestamp) / 1000;\n                gameState.lastTimestamp = timestamp;\n                if (deltaTime > 0.1) deltaTime = 0.1;\n\n                ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n                if (assetsLoaded && assetCache['chicken_coop_small']) {\n                    ctx.drawImage(assetCache['chicken_coop_small'], 20, 20, 150, 150);\n                }\n\n                if (mode === 'play') {\n                    // Level Transition System\n                    gameState.levelTimer -= deltaTime;\n                    if (gameState.levelTimer <= 0) {\n                        gameState.levelTimer = 30;\n                        gameState.level++;\n                        const msg = gameState.level > 10 ? \"Endless Mode\" : `Level ${gameState.level} UP!`;\n                        createParticles(canvas.width / 2, canvas.height / 2, '#FFD700', 0, msg);\n                        playSound('win_fanfare');\n                    }\n\n                    updateFoxes(deltaTime);\n                    for (let i = gameState.objects.length - 1; i >= 0; i--) {\n                        const obj = gameState.objects[i];\n                        const tier = TIERS[obj.tierIndex];\n                        \n                        // Handle Lifespan for Golden Hen\n                        if (obj.tierIndex === 3 && !obj.isBones) {\n                            obj.lifespan -= deltaTime;\n                            if (obj.lifespan <= 0) {\n                                obj.isBones = true;\n                                obj.bonesTaps = 0;\n                                obj.targetX = null; // Stop moving\n                                createParticles(obj.x, obj.y, '#DDD', 15);\n                            }\n                        }\n\n                        // Wandering logic (exclude bones)\n                        if (obj.tierIndex > 0 && gameState.draggingObject !== obj && !obj.isBones) {\n                            if (obj.targetX === null || obj.waitTimer > 0) {\n                                obj.waitTimer -= deltaTime;\n                                if (obj.waitTimer <= 0) {\n                                    obj.targetX = 50 + Math.random() * (canvas.width - 100);\n                                    obj.targetY = 50 + Math.random() * (canvas.height - 450);\n                                    obj.waitTimer = 0;\n                                }\n                            } else {\n                                const dx = obj.targetX - obj.x;\n                                const dy = obj.targetY - obj.y;\n                                const dist = Math.sqrt(dx * dx + dy * dy);\n                                if (dist < 10) {\n                                    obj.waitTimer = 1 + Math.random() * 3;\n                                    obj.targetX = null;\n                                } else {\n                                    const walkSpeed = 25 + (obj.tierIndex * 5); \n                                    const vx = (dx / dist) * walkSpeed;\n                                    const vy = (dy / dist) * walkSpeed;\n                                    obj.x += vx * deltaTime;\n                                    obj.y += vy * deltaTime;\n                                    obj.lastVx = vx;\n                                }\n                            }\n                        }\n\n                        // Egg laying (exclude bones)\n                        if (tier.spawnRate !== Infinity && !obj.isBones) {\n                            const rate = window.gameConfig.spawnRates[tier.id] || tier.spawnRate;\n                            obj.timeSinceLastEgg += deltaTime;\n                            if (obj.timeSinceLastEgg >= rate) {\n                                obj.timeSinceLastEgg = 0;\n                                const angle = Math.random() * Math.PI * 2;\n                                const dist = 80 + Math.random() * 40;\n                                const nx = Math.max(50, Math.min(canvas.width - 50, obj.x + Math.cos(angle) * dist));\n                                const ny = Math.max(50, Math.min(canvas.height - 450, obj.y + Math.sin(angle) * dist));\n                                if (spawnObject(0, nx, ny)) {\n                                    playSound('egg_crack_sfx');\n                                    createParticles(nx, ny, '#FFF', 5);\n                                }\n                            }\n                        }\n                    }\n                }\n\n                for (let i = gameState.particles.length - 1; i >= 0; i--) {\n                    const p = gameState.particles[i];\n                    p.x += p.vx; p.y += p.vy; \n                    const fadeRate = p.text ? 1.0 : 2.0;\n                    p.life -= deltaTime * fadeRate;\n                    if (p.life <= 0) gameState.particles.splice(i, 1);\n                }\n\n                for (const obj of gameState.objects) {\n                    obj.bobOffset += deltaTime * 2;\n                    if (obj.scale < obj.targetScale) obj.scale += deltaTime * 5;\n                    drawObject(obj);\n                }\n\n                for (const f of gameState.foxes) {\n                    const img = assetCache['fox_running'];\n                    if (!img) continue;\n                    ctx.save();\n                    ctx.translate(f.x, f.y);\n                    \n                    // Corrected flipping logic: if moving left, flip horizontally\n                    if (Math.abs(f.angle) > Math.PI / 2) {\n                        ctx.scale(1, -1);\n                    }\n                    ctx.rotate(f.angle);\n                    \n                    if (f.type === 'golden') ctx.filter = 'brightness(1.5) sepia(1) saturate(3)';\n                    if (f.state === 'sleeping') ctx.filter = 'grayscale(0.5) opacity(0.7)';\n                    ctx.drawImage(img, -50, -50, 100, 100);\n                    ctx.filter = 'none';\n                    \n                    ctx.restore();\n                    \n                    // Draw fox UI text after restoring context to ensure it's not flipped/rotated\n                    if (f.taps > 0 && f.state !== 'fleeing') {\n                        ctx.save();\n                        ctx.setTransform(1, 0, 0, 1, 0, 0);\n                        ctx.fillStyle = '#FF0000';\n                        ctx.font = 'bold 24px Arial';\n                        ctx.textAlign = 'center';\n                        ctx.fillText(`\ud83d\udca2 ${f.taps}/${f.maxTaps}`, f.x, f.y - 60);\n                        ctx.restore();\n                    }\n                    if (f.state === 'sleeping') {\n                        ctx.save();\n                        ctx.setTransform(1, 0, 0, 1, 0, 0);\n                        ctx.fillStyle = '#FFFFFF';\n                        ctx.font = 'bold 24px Arial';\n                        ctx.textAlign = 'center';\n                        ctx.fillText('Zzz...', f.x, f.y - 55);\n                        ctx.restore();\n                    }\n                    \n                    f.stolenObjects.forEach(obj => drawObject(obj));\n                }\n\n                for (const p of gameState.particles) {\n                    drawParticle(p);\n                }\n\n                if (gameState.draggingObject) {\n                    const obj = gameState.draggingObject;\n                    const tier = TIERS[obj.tierIndex];\n                    ctx.strokeStyle = '#FFD700';\n                    ctx.lineWidth = 3;\n                    ctx.setLineDash([5, 5]);\n                    ctx.beginPath();\n                    ctx.arc(obj.x, obj.y, tier.size / 1.5, 0, Math.PI * 2);\n                    ctx.stroke();\n                    ctx.setLineDash([]);\n                }\n\n                updateUI();\n                requestAnimationFrame(gameLoop);\n            }\n            requestAnimationFrame(gameLoop);\n        }\n    </script>\n</body>\n</html>", "game_config": "{\n  \"hatchSpeedMultiplier\": 10,\n  \"eggLayingInterval\": 15,\n  \"chickGrowthTime\": 30,\n  \"foxSpawnInterval\": 20,\n  \"foxTapRequirement\": 3,\n  \"maxChickens\": 40,\n  \"fieldColor\": \"#7EC850\",\n  \"chickenColor\": \"white\",\n  \"chickColor\": \"yellow\",\n  \"initialEggHatchTime\": 3,\n  \"spawnRates\": {\n    \"hen\": 5,\n    \"goldenHen\": 10,\n    \"rainbowHen\": 6,\n    \"golden_hen\": 4\n  },\n  \"maxObjects\": 50,\n  \"foxInterval\": 10\n}", "game_design_document": "## Core Game Loop and Mechanics\n\n**Chicken Panic** is a casual, top-down incremental game where players watch their chicken farm grow from a single egg into a bustling flock of 30 chickens.\n\n### Main Gameplay Loop\n1. Player starts with 1 egg in the center of the field\n2. Player presses and holds the HATCH button to accelerate egg growth\n3. Egg hatches into a chick after sufficient time/button holding\n4. Chick automatically grows into an adult chicken after a set duration\n5. Adult chickens automatically lay new eggs at intervals\n6. New eggs spawn near their parent chicken\n7. Process repeats, creating an exponentially growing visible flock\n8. Game continues until 30 chickens are on screen\n9. When 30 chickens reached: \"FARM FULL\" message appears and player wins\n\n### Growth Mechanics\n- **Eggs**: Start as white oval objects, shake/wiggle as they approach hatching\n- **Hatching**: Holding HATCH button speeds up egg growth by 3x\n- **Chicks**: Yellow, round, small - grow automatically over 15 seconds\n- **Adult Chickens**: White, round, larger - lay eggs every 20 seconds\n- **Egg Laying**: Each adult chicken lays 1 egg near itself at regular intervals\n- **Maximum Population**: Hard cap at 30 chickens (not counting eggs/chicks)\n\n### Fox Event (Bonus Challenge)\n- Every 20 seconds, a fox sprite runs across the screen horizontally\n- Fox enters from left or right edge, moves at moderate speed\n- Player must tap the fox 5 times before it exits the screen\n- **Success**: Fox runs away faster, player gets +50 bonus points\n- **Failure**: Fox exits screen, no penalty, no chickens stolen\n- Fox is purely a bonus scoring opportunity\n\n### Mystery Golden Egg Event\n- Randomly spawns a golden/shiny egg (10% chance every 30 seconds)\n- Golden egg appears in a random location on the field\n- Player taps the golden egg to activate\n- **Rewards** (random selection):\n  - Instantly spawn 3 adult chickens\n  - Instantly hatch all current eggs into chicks\n  - +100 bonus points\n\n### Win Condition\n- Reach 30 adult chickens on screen\n- Display \"FARM FULL!\" message with final score\n- Show restart button to play again\n\n### Lose Condition\n- None - this is a relaxing, no-fail experience\n\n## Starting Scope\n\n**First Implementation Must Include:**\n- Single grass field (720x1280 viewport)\n- 1 starting egg in center\n- HATCH button that speeds up egg growth when held\n- Egg \u2192 Chick \u2192 Chicken growth cycle\n- Adult chickens laying new eggs automatically\n- Visible spawning of all eggs, chicks, and chickens as individual objects\n- Chicken counter showing current count\n- Score counter\n- Fox event every 20 seconds with tap-to-scare mechanic\n- Win condition at 30 chickens\n- Simple particle effects for hatching\n\n**Future Iterations Can Add:**\n- Mystery golden egg events\n- More elaborate animations\n- Sound effects for each action\n- Background music\n- Visual polish and juice\n\n## Game Perspective\n\n**Top-down view** - Bird's eye perspective looking down at a grass field. All chickens, eggs, and chicks are viewed from above as simple, round shapes.\n\n## Game World and Level Design\n\n### Field Layout\n- Single screen, no scrolling (fixed-screen)\n- 720x1280 pixel viewport\n- Grass field fills the entire play area\n- Small decorative chicken coop in top-left corner (visual only, non-functional)\n- Objects spawn and move freely within the field boundaries\n\n### Object Placement\n- Starting egg spawns at center (360, 640)\n- New eggs spawn within 80-120 pixels of their parent chicken\n- Eggs/chicks/chickens should not overlap excessively\n- Simple collision avoidance: if spawn location is occupied, offset by 40 pixels in random direction\n- Objects stay within field boundaries (50px margin from edges)\n\n### Visual Zones\n- **Top Zone (0-200px)**: UI area - chicken count, score, decorative coop\n- **Middle Zone (200-1000px)**: Main play area where chickens roam\n- **Bottom Zone (1000-1280px)**: HATCH button and controls\n\n## Edit Mode Design\n\nPlayers can customize these aspects in edit mode:\n\n### Editable Properties\n- **Hatch Speed Multiplier** (1x - 5x): How much faster eggs hatch when button is held\n- **Chicken Egg Laying Interval** (10-40 seconds): How often adult chickens lay eggs\n- **Chick Growth Time** (5-30 seconds): How long chicks take to become adults\n- **Fox Spawn Interval** (10-60 seconds): How often foxes appear\n- **Fox Tap Requirement** (3-10 taps): Taps needed to scare away fox\n- **Max Chickens** (20-50): Population cap for winning\n- **Field Color**: Grass color (light green, dark green, yellow-green)\n- **Chicken Color**: White, brown, or speckled\n- **Chick Color**: Yellow, orange, or light brown\n\n### Constraints\n- Minimum 1 starting egg (cannot start with 0)\n- Hatch speed must be at least 1x\n- Max chickens cannot exceed 50 (performance limit)\n- All timing values must be positive numbers\n\n## Control Design\n\n### Mobile (Touch) Controls\n- **Tap**: Interact with foxes and golden eggs\n- **Press and Hold**: Hold HATCH button to speed up egg growth\n- **Multi-tap**: Rapid tapping on fox to scare it away (5 taps required)\n\n### Desktop (Keyboard/Mouse) Controls\n- **Mouse Click**: Same as tap - interact with foxes and golden eggs\n- **Mouse Hold**: Hold HATCH button with mouse to speed up egg growth\n- **Spacebar Hold**: Alternative to holding HATCH button\n\n### Control Implementation\n- HATCH button is a large circular button (200x200px) at bottom center\n- Button shows visual feedback when pressed (scale down slightly, color change)\n- Fox hitbox should be generous (entire fox sprite is tappable)\n- Golden egg hitbox should be generous (entire egg sprite is tappable)\n- No complex gestures needed - just tap and hold\n\n## Art Style and Visual Theme\n\n### Overall Style\n- **Cute cartoon style** with simple, bold shapes\n- **Bright and cheerful** color palette\n- **Top-down perspective** for all game objects\n- **Large, readable characters** suitable for mobile screens\n- **Minimal detail** - focus on clear silhouettes and shapes\n\n### Color Palette\n- **Grass Field**: Bright green (#7EC850) with subtle texture\n- **Eggs**: White/cream (#F5F5DC) with subtle speckles\n- **Chicks**: Bright yellow (#FFD700) with small orange beak\n- **Adult Chickens**: White (#FFFFFF) with red comb, simple round body\n- **Fox**: Orange-red (#FF6347) with white-tipped tail\n- **Golden Egg**: Shiny gold (#FFD700) with sparkle effect\n- **UI Elements**: Warm browns and yellows for buttons\n\n### Asset Sizes (relative to 720x1280 viewport)\n- **Egg**: 40x50px\n- **Chick**: 50x50px (round)\n- **Adult Chicken**: 80x80px (round with comb)\n- **Fox**: 120x80px (horizontal sprite)\n- **Golden Egg**: 50x60px\n- **Chicken Coop**: 150x150px (decorative, top-left)\n- **HATCH Button**: 200x200px (bottom center)\n\n### Visual Effects\n- Eggs should wiggle/shake when close to hatching\n- Hatching should have a small burst of particles (white/yellow)\n- Chickens should have subtle idle animation (bob up and down)\n- Fox should have running animation\n- Golden egg should have sparkle/glow effect\n- HATCH button should pulse gently when not pressed\n\n### Rendering Approach\n- **Generate assets for**: Chickens, chicks, eggs, fox, golden egg, chicken coop\n- **Code rendering for**: Grass field (CSS background), UI elements (HTML/CSS), particle effects (Canvas)", "persistent_storage_config": null, "game_metadata": {"game_id": "01KTDPS6H3H4BG35VGQGSJCV0Q", "title": "Chicken Panic", "description": "Hatch eggs, grow chicks into chickens, and fill your farm with 30 clucking birds in this adorable top-down tapping game!", "thumbnail_url": "https://d2oir5eh8rty2e.cloudfront.net/assets/images/thumbnail_19248c21-3a5c-411f-b2e0-7bafbe082839.webp", "created_at": 1780724055, "updated_at": 1780826633393.127, "art_style": null}, "task_plan": null}