I'll build this step by step. Let me first check the existing project structure.
Now let me check the existing files and read the utility file:
Now I'll build the complete game. Let me start with the CSS, then the main game component.
Now the main game component:
Let me fix the TypeScript errors:
Let me build to check for any remaining issues:
The build succeeds! Let me now review the game logic and fix some issues I noticed — score calculation, timing, and game-over flow need refinement. Let me also make it more polished:
Let me rewrite the entire game with improved logic and more polish:
Build successful! Let me now make a few improvements to ensure the game feels more polished and responsive. Let me check the current state:
Let me now build the final version:
The game builds successfully at 250KB (inlined single file). Let me do a final review of all the files to make sure everything is complete:
The game is complete and builds successfully! Here's a summary of everything that was built:
🧠 Double Decision — UFOV Training Game
Files Created/Modified
| File | Description |
|---|
index.html | Updated title to "Double Decision - UFOV Training Game" |
src/index.css | Full custom CSS with 12+ keyframe animations, glass-morphism utilities, responsive sizing, and game-specific styles |
src/App.tsx | Complete 865-line game component with all logic, UI, and state management |
Game Mechanics ✅
- Dual-task paradigm: Central vehicle identification (🚗 🚌 🚛 🏍️) + peripheral flash localization (8 radial positions)
- Distractors: Dim dots at the 7 non-target peripheral positions during stimulus flash
- Adaptive difficulty: Display duration starts at 600ms, decreases by 30ms every 2 correct answers (down to 50ms), increases by 50ms on mistakes
- 5 lives system: Lose a life on each wrong answer, game over at 0 lives
Visual Polish & Juice ✨
- Screen shake — CSS keyframe animation on wrong answers
- Particle burst — 22 particles fly outward in random directions on correct answers, using CSS custom properties (
--dx, --dy)
- Bounce-in / slide-up / flash-in — Phase transitions feel smooth and responsive
- Combo fire — Glowing text animation for 3+ streaks
- Heartbeat — Life icons pulse when lost
- Score pop — Score number scales up briefly on change
- Wrong flash — Red pulsing border overlay on mistakes
- Glass-morphism —
backdrop-blur cards and buttons throughout
Controls ⌨️👆
- Touch/Mouse: Tap vehicle buttons (bottom row) and peripheral position circles (ring)
- Keyboard:
1-4 for vehicles, 1-8 for positions, Esc/P for pause
- Pause overlay: Blurred backdrop with resume button
States & Data Flow 🔄
| Screen | Features |
|---|
| Start | Animated logo, instructions, high scores table, gradient play button |
| Game | Score/combo bar, level/speed indicator, lives display, 7 game phases (ready→fixation→stimulus→centralChoice→peripheralChoice→feedback→next trial) |
| Paused | Overlay with glass card, prevents timer progression |
| Game Over | Stats grid (score/level/accuracy), trial breakdown, updated high scores, instant restart |
Technical Highlights 🏗️
- Refs for timing:
aliveRef, pausedRef, durationRef prevent stale closure issues in setTimeout callbacks
- No memory leaks: All timers cleared on unmount, game over, and restart
- localStorage persistence: Top 10 high scores saved across sessions
- 60fps ready: DOM-based rendering with CSS transforms/opacity (GPU composited), no layout thrashing
- Mobile-first:
touch-action: manipulation, overscroll-behavior: none, responsive sizing with min(100vw, 600px), large tap targets (48px+)
- Single file build: vite-plugin-singlefile inlines everything into
dist/index.html (250KB gzipped to 73KB)
Files built: index.html, src/index.css, src/App.tsx