# Build: Arena Shooter (top-down tank combat web game)

Create a complete, polished **single-file HTML5 canvas game** called **Arena Shooter** (or split into HTML/CSS/JS if preferred, but one playable page is fine). No frameworks. Vanilla JS + Canvas 2D + Web Audio. Mobile landscape + desktop. Dark neon military / arcade aesthetic.

## Product vision
A retro-modern top-down arena tank shooter with:
- Local duel (2P keyboard + Solo vs AI)
- Long Story Mode campaign (500 levels)
- Boss Mode, Survival, Time Attack, Defend Base
- Toggleable arena threats and skill power-ups
- Skins, primary-weapon gear, themes, achievements, encrypted saves
- Touch controls for phones

Feel: fast tank combat, destructible/themed walls, pickups, hazards, bosses with specials, comic story briefings between worlds.

## Tech constraints
- Canvas resolution: **960×600** (scale CSS to fit viewport; max ~960 wide)
- HUD band ~108px at top of canvas
- Fonts: **Orbitron** (titles) + **Rajdhani** (UI) from Google Fonts
- Colors: deep navy backgrounds, cyan/red tanks, glowing accents
- Pseudo-3D rendering: extruded walls/tanks, shadows, Y-sort depth
- Continuous facing (smooth turn) for players, AI, enemies
- Screen shake, particles, announcements
- Settings: master volume, mute SFX, mute music, screen shake, colorblind mode, reduce motion
- Portrait phones: show “Rotate to Landscape” blocker
- Mobile: virtual stick + FIRE button + pause; letterbox controls; multitouch
- Desktop: P pause, R restart; Esc where sensible
- Optional: Cloudflare/Arvan-style edge worker that serves the HTML as a string

## Core combat
- Tanks move freely in 2D; collide with solid walls; slide along edges
- Shoot projectiles with cooldown (default ~0.3s; rapid ~0.11s)
- Player HP: **20** in most modes; **50** in Story Mode
- Tank radius ~22
- Status effects: burn DoT, slow, freeze, invulnerability after spawn/portal, mine immunity
- Power-up durations roughly:
  - Speed / Rapid: 7s
  - Rocket / Fire / Ice / Electric: 8s
  - Mine Guard: 12s
  - Burn ~4s, Slow ~3.5s, Freeze ~2.2s
- Primary gear (chosen in Match Setup; Story unlocks):
  - **Normal**: classic shot, 1 hit
  - **Laser** (unlock ~level 10): 2 hits
  - **Downpour** (unlock ~25): 4-way spread ±5°/±15°, 1 hit each
  - **Stream** (unlock ~50): beam, 4 hits
- Temporary skill weapons override primary while active (rocket splash, fire/ice/electric splash, seeking missiles)
- Homing / One-Shot / Homing-Electric use **ammo charges** from pickups (not infinite)

### Tank skins (cosmetic)
- Scout, Assault (default P1), Heavy (unlock ~40), Stealth (~10), Flame (~15 / default P2 look)
- Force high-contrast P1 vs P2 colors

## Arena themes (cycle or picker)
Order: classic, jungle, desert, industrial, snow, space, lego  
Each theme defines: bg gradients, wall palette, grid/accent, weather, terrain patch rolls.

### Terrain kinds
- **heavy**: solid, indestructible, blocks tanks + bullets
- **medium**: blocks both, HP 5
- **soft**: blocks both, HP 2
- **water**: blocks tanks only (bullets pass)
- **mud**: passable, speed ×0.4

Theme-specific wall pools + mud/water patches. Weather (rain/snow/sand/embers) with subtle speed effects. Space/lego unlock via Story progress (~40 / ~60).

Procedural wall layout each round/remap; avoid spawning players inside walls.

## Game modes

### 1) Story Mode (campaign)
- **500 levels**, labeled `world-stage` (1-1 … 100-5), **5 levels per world**, **100 worlds**
- **5 lives** per run; lose a life on death; game over at 0
- Persist progress: current level, lives, kills this level
- Early levels: more enemy HP so multiple hits matter
- Wave kill goals; spawn exactly as many enemy tanks as the kill goal
- Every 5th level is a **world boss** matching that world’s roster boss
- Late campaign can include dual-boss fights / scaled difficulty curves
- Arena threats unlock by Story level (not manually toggleable in Story Match Setup):
  - Fire Mines ≥1, Ice ≥10, Helicopter ≥20, Crushers/Lasers ≥30, Jets ≥40, Electric Mines ≥50, Portals ≥60
- Skills/power-ups still configurable where unlocked
- Each world opens with a **comic-strip briefing** (unique text per archetype/world) then Deploy
- Themes: one theme per world; advance after world boss cleared
- Track best campaign level; “Continue” vs “New Run”

### 2) Boss Mode
- Fight all **100 bosses** in order (same roster as Story world bosses)
- 5 lives; progress saved (index, defeated count, lives)
- Bosses taunt above tank at fight start
- Archetypes cycle: Bruiser, Assault, Fortress, Raider, Heavy, Inferno (then named variants with prefixes/suffixes)
- Stats scale with world/tier (HP, speed, fire rate, size)
- Specials by archetype: charge, volley, shield, dash, mortar, fire ring
- **Rage phase** at ≤50% HP
- Win: clear all bosses; lose: lives depleted (keep best)

### 3) Survival
- Endless waves, scaling difficulty; track best wave
- Unlock after Story ~level 15

### 4) Time Attack
- Timed run (default 180s, configurable); maximize kills; track best
- Unlock ~level 25

### 5) Defend Base
- Protect a player fortress through escalating waves; base HP; fail if base destroyed
- Unlock ~level 35
- Track best wave

### 6) Solo vs AI (duel)
- 1v1 against bot
- AI difficulty: easy / normal / hard (reaction, shoot chance, speed, retreat/approach bias)
- Match rules: First-to-N (default 5) or Timed match (default 90s)
- Round KO → round-end overlay with Tekken-style scoreboard → remap or match end

### 7) 2 Player (desktop only)
- Shared keyboard: P1 WASD+Space, P2 Arrows+Enter
- Same duel rules as AI duel

**Mode unlocks** (Story progress): Boss 5, Survival 15, Time Attack 25, Defend Base 35.

## Match Setup screen
Before start (and for Continue):
- Mode label
- Enable all / Disable all for features
- **Match Rules** (mode-dependent): win mode, win score, duration, AI difficulty, Time Attack duration, map pick (random or unlocked theme)
- **Skin picker** P1 (and P2 for 2P)
- **Gear picker** P1/P2
- **Arena Features** toggles (disabled/locked in Story — auto by level)
- **Skills & Power-ups** toggles with rarity legend:
  - Common: Health, Speed, Rapid, Mine Guard
  - Rare: Rocket, Fire Launcher, Ice Launcher, Remap (unlock Story 7-5 / ~35)
  - Epic: Electric (3-5 / ~15), Homing (4-5 / ~20), One Shot Kill (5-5 / ~25), Homing Electric (10-5 / ~50)
- Locked items show unlock condition; announce when unlocked on Story clear

### Arena feature behaviors
- **Fire Mines**: red, heavy damage + burn
- **Ice Mines**: blue, lighter damage + slow
- **Electric Mines**: purple, freeze in blast
- **Helicopter**: flies across, rains bullets
- **Crushers & Lasers**: moving crushers + laser beams
- **Jet Strike**: 3 jets (2 L→R, 1 R→L), each drops 1 bomb ≈ half tank HP
- **Portals**: linked pairs teleport tanks (cooldown + brief invuln)

Pickup rarity weights: common 50%, rare 35%, epic 15%.

## UI overlays
Main menu: brand **Arena Shooter**, mode tiles (Story+Boss top; Survival/Time Attack/Defend bottom; Duels column), Settings / Stats / Achievements, version chip → Changelog, control hints.

Also: Pause (Resume / Restart / Options / Main Menu), Round End, Game Over, Campaign comic, Match Setup, Settings, Stats, Achievements, Secret Unlock vault popup.

HUD: scores/HP bars, power-up timers, wave/level/boss name, lives pips for Story/Boss, announcements.

## Progression & meta
- Achievements examples: First Blood, World One (1-5), World Five (5-5), Boss Hunter (10 bosses), Wave Rider (surv 10), Iron Wave (20), Clock Crusher (30 TA kills), Fort Keeper (defend wave 5), Untouchable (clear world boss without taking damage that world), Duelist (5 duel wins)
- Stats: kills, deaths, K/D, time played, best survival wave, best TA kills, best defend wave, duel wins, boss best, campaign best
- **Secret unlock**: tap main-menu buttons in order Stats, Stats, Settings, Settings, Settings, Achievements → unlock all locked modes/skills/skins/themes/gear; funny one-liner joke
- Local save encrypted with **AES-GCM** (Web Crypto); migrate legacy plaintext once; tampered save hard-resets
- Persist: features, skins, gear, match rules, campaign/boss progress, stats, achievements, settings, unlocks

## Audio (procedural, no asset files)
- Web Audio oscillators/noise: shoot, hit, explode, pickup, UI, mine, portal, boss taunt cues
- Generative music bed with kick/hat/bass beat; mood shifts by arena theme
- Respect mute/volume settings

## Polish expectations
- Smooth 60fps game loop with dt
- Responsive mobile landscape UX (scrollable Match Setup / comics)
- Colorblind hue shifts for mode tiles if enabled
- Reduce motion dampens shake/particles/weather
- Fullscreen button on mobile
- Changelog entries for version history
- Ship as a **complete playable game**, not a stub: all modes, features, unlocks, and saves working end-to-end

## Implementation plan (suggested for the agent)
1. Scaffold HTML/CSS shell + canvas + overlay structure
2. Implement tank movement, shooting, walls, collision, rendering (pseudo-3D)
3. Themes + terrain + procedural maps
4. Duel 2P + AI + round/match flow
5. Power-ups, mines, heli, jets, hazards, portals
6. Story Mode waves + bosses + comics + lives
7. Boss Mode, Survival, Time Attack, Defend Base
8. Match Setup, unlocks, achievements, stats, settings
9. Touch + mobile UX
10. Audio + encrypted save + secret unlock
11. Balance pass and bugfix (spawn counts, wall spawn fails, continue-after-wipe, etc.)

## Non-goals
- Online multiplayer / networking
- External engines (Phaser, Unity, etc.)
- Heavy asset pipelines (keep procedural graphics/SFX)

Build the full game. Prefer readable modular JS inside one file (or a few modules) with clear constants for tuning.
