Game: Tower Defense
Theme: Cyberpunk
Map: Single Path
Date: 2026-04-03

## Prompt

Create a complete single-file 3D tower defense game called "Firewall" — a cyberpunk-themed strategic defense game using Three.js (no external images, all programmatic 3D geometry).

### THEME & STORY
The city's digital infrastructure is under siege. Infected drones and corrupted bots are racing through the network grid to breach the Core Firewall. Deploy countermeasure towers (neural suppressors, plasma turrets, EMP emitters) to defend the last line of defense.

### TECHNICAL SETUP
- Single HTML file with embedded CSS and JavaScript
- Three.js via CDN: https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js
- No external images, no external models
- All 3D geometry built programmatically from Three.js primitives
- Camera: Perspective at 45-60 degrees, isometric-ish view with zoom and pan controls
- Lighting: Ambient (0x404040) + Directional with shadows + point lights on towers
- Skybox: Dark gradient (near-black to deep blue/purple)
- Grid ground: 20x20 grid with neon cyan lines on dark surface

### MAP DESIGN
- Single winding path (no branching) in an S-curve pattern
- Path tiles are visually distinct: dark grey with subtle glow vs buildable grid tiles
- Core Firewall at path end: large glowing cylinder with pulsing effect
- Spawn point at opposite end: dark portal with particle effect
- 20x20 grid, path occupies ~30% of tiles
- Path corners are rounded for visual appeal

### TOWER TYPES (6 total)
All towers are 3D constructs made of cylinders, boxes, spheres, and emissive elements.

1. **Pulse Turret (Basic)**
   - Cost: 80 gold
   - Stats: 15 damage, 2.0 range, 1.2 shots/sec
   - Visual: Octagonal base, rising turret with rotating barrel
   - Projectile: Small glowing cyan sphere
   - Upgrade L2: +40% damage, +10% range, glowing bands on barrel
   - Upgrade L3: +100% damage, +25% range, gains PIERCING (hits 2 enemies), second barrel appears

2. **Sniper Node (Sniper)**
   - Cost: 150 gold
   - Stats: 80 damage, 5.0 range, 0.4 shots/sec
   - Visual: Tall thin tower with narrow barrel, targeting laser
   - Projectile: Elongated cyan cylinder, fast travel
   - Upgrade L2: +40% damage, +10% range, larger dish on top
   - Upgrade L3: +100% damage, +25% range, gains CRITICAL HITS (2x damage, 25% chance), triple dish array

3. **EMP Cannon (Splash)**
   - Cost: 200 gold
   - Stats: 30 damage, 2.5 range, 0.6 shots/sec, 1.5 blast radius
   - Visual: Heavy hexagonal base with large domed top
   - Projectile: Blue pulsing sphere that explodes into shockwave ring
   - Upgrade L2: +40% damage, +10% range, +0.2 blast radius, crackling energy on dome
   - Upgrade L3: +100% damage, +25% range, +0.3 blast radius, gains BURN DOT (10 damage/sec for 3 sec), dome becomes translucent with energy core visible

4. **Cryo Suppressor (Slow)**
   - Cost: 120 gold
   - Stats: 5 damage, 2.2 range, 1.0 shots/sec, 30% slow for 2 sec
   - Visual: Crystalline tower with blue ice shards, mist emitter
   - Projectile: White-blue sphere with frost trail
   - Upgrade L2: +40% damage, +10% range, 40% slow, larger ice formations
   - Upgrade L3: +100% damage, +25% range, gains FREEZE (complete stop for 1.5 sec), crystal core glows intensely

5. **Rapid Relay (Rapid)**
   - Cost: 110 gold
   - Stats: 6 damage, 1.8 range, 4.0 shots/sec
   - Visual: Multi-barrel rotating cluster, energy conduits
   - Projectile: Small fast green bolts
   - Upgrade L2: +40% damage, +10% range, barrels glow, spin faster
   - Upgrade L3: +100% damage, +25% range, gains DOUBLE BARREL (2 projectiles per shot), becomes quad-barrel design

6. **Neural Siphon (Special)**
   - Cost: 180 gold
   - Stats: 20 damage, 2.0 range, 0.8 shots/sec, chains to 2 nearby enemies
   - Visual: Tesla-coil style tower with sparking energy nodes
   - Projectile: Purple lightning arc that jumps between targets
   - Upgrade L2: +40% damage, +10% range, chains to 3 enemies, more nodes
   - Upgrade L3: +100% damage, +25% range, gains OVERLOAD (damages ALL nearby enemies when primary target dies), massive energy field

### ENEMY TYPES (6 total)
All enemies are geometric shapes with distinct colors and sizes.

1. **Scout Drone (Scout)**
   - HP: 30, Speed: 2.5, Armor: None, Bounty: 5 gold
   - Visual: Small yellow octahedron, rapid jittering movement
   - Ability: Appears in large swarms (20+)

2. **Infantry Bot (Soldier)**
   - HP: 80, Speed: 1.5, Armor: Light (10% reduction), Bounty: 10 gold
   - Visual: Medium red cube with corner chamfer
   - Ability: Standard threat, most common

3. **Tank Mech (Tank)**
   - HP: 300, Speed: 0.7, Armor: Heavy (30% reduction), Bounty: 25 gold
   - Visual: Large blue box with tread-like base attachments
   - Ability: Absorbs massive damage, takes 3 lives if reaches core

4. **Surge Runner (Sprinter)**
   - HP: 45, Speed: 4.0, Armor: None, Bounty: 8 gold
   - Visual: Elongated green capsule, leaves speed trail
   - Ability: Very fast, rushes past defenses, 2x damage from all sources

5. **Repair Node (Healer)**
   - HP: 120, Speed: 1.2, Armor: Light (10% reduction), Bounty: 15 gold
   - Visual: Purple sphere with orbiting repair drones (small spheres)
   - Ability: Heals nearby enemies by 10 HP every 2 seconds

6. **Virus Prime (Boss)**
   - HP: 2000 + 15% per wave, Speed: 0.5, Armor: Heavy (40% reduction), Bounty: 100 gold
   - Visual: Massive black spiked sphere with red energy core, pulses ominously
   - Ability: Takes 5 lives if reaches core, immune to slow, 50% resistance to splash

### WAVE SYSTEM (20 waves)
Starting gold: 450 (enough for 2-3 basic towers or 1 advanced)

Wave composition pattern:
- Waves 1-4: Scouts and Infantry, increasing count
- Waves 5: Boss #1 (Virus Prime) + 10 Infantry escort
- Waves 6-9: Mixed forces with Tanks appearing
- Wave 10: Boss #2 + Sprinter swarm
- Waves 11-14: Healers appear, making groups harder to kill
- Wave 15: Boss #3 with Healer support
- Waves 16-19: Full enemy roster, massive counts
- Wave 20: Final Boss + 5 Tanks + 20 Infantry + 10 Surge Runners

HP scaling: +15% per wave (compounding)
Speed scaling: +5% per wave, capped at +50% (wave 10+)

Inter-wave break: 15 seconds (skip button available)
Wave preview: Show next wave's composition in UI

### ECONOMY
- Starting gold: 450
- Interest: 3% of unspent gold between waves
- Tower sell: 60% of total investment returned
- No inflation: Bounties scale with difficulty

### BASE / LIVES
- Core HP: 20 lives
- Scout/Infantry/Sprinter/Healer: -1 life each
- Tank: -3 lives each
- Boss: -5 lives each
- Victory: Survive wave 20
- Game Over: 0 lives remaining

### 3D RENDERING REQUIREMENTS
- All towers rotate to face target
- Projectiles have visible flight paths
- Enemy health bars: Billboard sprites above each unit
- Death effects: Explosion particle bursts themed to killer tower
- Range indicator: Semi-transparent cylinder when placing or selecting tower
- Dynamic lighting: Projectile impacts flash, towers have point lights
- Camera controls: Mouse wheel zoom, right-click drag to pan
- Mobile: Pinch zoom, two-finger pan, touch buttons

### UI OVERLAY (DOM HTML/CSS)
Dark translucent panels with neon cyan accents.

**HUD (always visible):**
- Gold: "₿ 450" with pulsing icon
- Lives: "⚡ 20" with core icon
- Wave: "WAVE 1/20"
- Timer: "15s until next wave"
- Speed: 1x/2x/3x toggle buttons

**Tower Panel (bottom bar):**
- 6 tower buttons with icons, names, costs
- Greyed out if unaffordable
- Selected tower shows stats overlay

**Tower Selection UI (when clicking existing tower):**
- Current level display
- Upgrade button (shows cost, new stats)
- Sell button (shows refund amount)
- Range indicator on map

**Game States:**
- Start Screen: Title "FIREWALL", tagline "The grid defends itself", Start Game button, difficulty select
- Building: Full HUD, tower panel, wave preview
- Wave Active: Full HUD, wave progress bar, enemy counter
- Paused: Semi-transparent overlay, resume/restart
- Game Over: Final stats, Play Again
- Victory: Celebration, final stats, endless mode option

### AUDIO (Web Audio API, procedural)
- Tower fire: Short oscillators (type varies by tower)
- Enemy death: Quick frequency sweep down
- Wave start: Alert tone (rising)
- Boss incoming: Low rumble sustained
- Game over: Descending tones
- Victory: Major chord arpeggio
- Mute button in HUD

### PERFORMANCE TARGETS
- 60fps with 20+ enemies + 15+ towers on screen
- Object pooling for projectiles and particles
- InstancedMesh for identical enemy types where possible
- Max 1000 particles on screen at once

### CODING REQUIREMENTS
- No trimming, no abbreviations, no "etc" or "similar to above"
- Write every tower definition, enemy type, wave composition, upgrade path
- Use Three.js primitives only (BoxGeometry, SphereGeometry, CylinderGeometry)
- Single file, all inline, target 1200-2500 lines
- Clean, readable code with comments for major sections

## Notes

Balance philosophy: Player should feel challenged but never overwhelmed by wave 5. By wave 10, they need to have built a diverse defense. By wave 20, every tower type should be employed strategically.

Visual theme: Cyberpunk means neon on dark. Cyan for friendly/tech, red for enemy damage, green for money, purple for special effects. All emissive materials at night-time intensity.

Map flow: The S-curve creates natural chokepoints where splash towers excel. Cryo towers at corners to maximize slow coverage. Snipers at long straight sections.

Upgrade path design: Each tower becomes meaningfully more powerful at L3, not just stat increases. The special abilities (Piercing, Critical, Burn, Freeze, Double, Overload) create satisfying power spikes.
