# AZCHESS Project Plan (Source of Truth)

## Goals
- Keep current UI design, but make live game page lighter and more stable.
- Fix broken gameplay actions: draw (offer/accept/decline), rematch (same clock, swap colors), premove.
- Mobile-first: main action buttons always visible and large.

## Non-goals (for now)
- No engine analysis during live games.
- No big redesign.

## Key decisions
- Keep Chessground for now; isolate/contain it later for performance.
- Use Lichess board API via existing server routes under `app/api/lichess/...`.
- Authentication currently uses `lichess_token` cookie (set by OAuth callback) or env token fallback.

## Testing checklist (every checkpoint)
1. Draw: offer/accept/decline both directions.
2. Rematch: works both directions; same clock; swapped colors.
3. Premove: set on opponent turn; executes instantly on your turn; works on mobile.
4. Build/TypeScript: no runtime errors on page load.

## Upcoming checkpoints
- B: Draw UX + correctness + always-visible buttons.
- C: Rematch + premove reliability.
- D: End-game modal stability + Analyse button (opens Lichess analysis).
- E: Performance refactor (split stream/board/UI) without UI changes.
