3D Pokémon Maze Game Creator

Build a full 3D Pokémon game in one file with battles, catching, and exploring a large maze. Learning to read in the proces.

ProgrammingEducationLanguage

Prompt

Act as an expert web game developer. Create a fully functional, feature-rich 3D Pokémon-inspired maze game within a SINGLE HTML file. The file must contain all HTML, Tailwind CSS (via CDN), Three.js (via CDN for 3D rendering), and vanilla JavaScript. Do not use external assets other than PokeAPI for sprites. 

Here are the strict requirements and features you MUST implement:

1. CORE ARCHITECTURE & VISUALS
- Use Three.js to render a 3D first-person maze. The maze must be procedurally generated on a 51x51 grid.
- Walls must have a custom generated canvas texture (brick pattern) and black EdgeGeometries for clear depth perception. The floor is green.
- Implement a Minimap (top-left) with a "Fog of War" effect. It only reveals areas within a 2.5 tile radius of the player as they explore. Show walls, paths, the player (red dot), and health stations (green dots).
- Controls: WASD/Arrow keys for PC, and an on-screen transparent D-Pad (W/A/S/D) for mobile/iPad. Allow pressing 'Space' (or an on-screen interaction button) to interact with nearby entities.

2. GAME ENTITIES & SPAWNING
- Wild Pokémon: Spawn up to 40 wild Pokémon dynamically in the maze using `THREE.Sprite`. Use PokeAPI (`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${id}.png`) for textures. Ensure CSS `image-rendering: pixelated` is used for sharp sprites.
- Wild Pokémon level should scale based on their distance from the spawn point. Despawn Pokémon that are too far away and respawn new ones nearby to keep the world alive.
- Health Stations: Spawn 1 at the exact starting location and up to 3 hidden in the maze. Render them as 3D objects (a grey cylinder pedestal with a glowing, floating, rotating green Octahedron crystal). Interacting heals and revives the entire team.

3. RPG SYSTEM & DATABASE
- Build a JavaScript database for at least 20 Pokémon (including Starters, Pidgey, Rattata, Zubat, Geodude, Gastly, Snorlax, Mewtwo, etc.).
- Include base stats (HP, Atk), types (Grass, Fire, Water, Normal, Electric, Poison, Flying, Dark, Psychic), evolution levels, and learnsets (specific moves learned at specific levels).
- Build a Moves database containing power and type for moves like Tackle, Water Gun, Ember, Vine Whip, Thunderbolt, Confusion, etc.

4. BATTLE SYSTEM
- Turn-based 2D battle UI overlaying the 3D canvas. Show the Player's Pokémon on the left (Back sprite) and Enemy on the right (Front sprite) with HP bars and levels.
- Do NOT use browser `alert()` or `confirm()`. Build a custom, async DOM-based modal system for all messages, choices, and yes/no prompts.
- Integrated Move Menu: Show up to 4 moves directly on the battle screen with their Type and Power.
- Combat Math: Implement Type Effectiveness (e.g., Water is 2x vs Fire, 0.5x vs Grass). Calculate damage using a mix of Atk stat and Move Power. Show "It's super effective!" messages.
- Attack Animations: When attacking, animate a specific emoji (e.g., 🔥 for fire, 💧 for water, 💥 for normal) flying from the attacker's sprite to the defender's sprite.
- Options: Fight, Catch, Switch, Run. Running has a chance to fail based on level difference; if it fails, the enemy gets a free attack.
- Fainting: If the player's Pokémon dies, prompt them to switch to the next alive Pokémon. If all die, wipe the player back to the maze start and fully heal.

5. CATCHING MINIGAME
- Only allow catching if the enemy HP is < 50% and the player's level is close enough.
- When catching, show a CSS-animated Pokeball flying from the bottom of the screen towards the enemy sprite.
- Then, transition to an Anagram Minigame: Show the enemy sprite and scrambled letters of its name. The player must click the letters in the correct order to spell the name. Correct = caught, Incorrect = escapes from battle.

6. PROGRESSION (EXP, LEVELING & EVOLUTION)
- Winning a battle gives EXP. Reaching thresholds levels up the Pokémon, increasing Max HP and Attack.
- Move Learning: If a Pokémon learns a new move but already knows 4, use a custom modal to ask the player which move to forget.
- Evolution: If a Pokémon reaches its evolve level, show a Yes/No prompt. If yes, evolve them (change name, sprite ID, massive stat boost).

7. TEAM & STORAGE MANAGEMENT
- Backpack holds a maximum of 8 Pokémon. If a 9th is caught, it goes to the PC Storage automatically.
- Build a Backpack UI to view stats, HP, and set the active battle Pokémon.
- Build a PC Storage UI (Pokédex) to freely swap Pokémon between the 8-slot backpack and unlimited storage.
- Support pressing 'Escape' to close any open menus or custom modals.

8. AUDIO & MULTIMEDIA
- Web Audio API: Create a synthesizer function using oscillators to generate retro sound effects for hitting, throwing, success, level-ups, healing, and errors.
- Text-to-Speech: Add a speaker icon (🔊) next to the enemy's name in the battle and catch screens. Clicking it uses `window.speechSynthesis` to speak the Pokémon's name out loud.

Ensure all CSS is handled by Tailwind classes or minimal `<style>` tags. Write clean, async-await driven logic for the battle flow to handle animations and modals pausing the game loop correctly. Ensure the final file ends with .