# EL3AB — Build Order (100% Database Coverage)

Each phase = ONE module. Working on it = touching ONLY that module's folder + its API endpoint.
This plan covers ALL 106 tables in the database.

---

## Table Coverage Key

After each phase, I list which tables are covered by that phase.
**Target: 106/106 tables accounted for.**

---

## Phase 0: Engine Core
**Scope:** `public/js/core/`, `public/css/`, `index.php`, `api/` skeleton, `config/`
**Goal:** Game boots. HUD renders. 5 world tabs swipeable. Theming system loads dynamic tokens.

| # | Deliverable |
|---|-------------|
| 0.1 | `index.php` — HTML shell (#game, #hud, #overlay layers) |
| 0.2 | `public/css/tokens.css` — Design tokens (loaded dynamically from platform_theme) |
| 0.3 | `public/css/core.css` — Layer system, tab bar, HUD, transitions |
| 0.4 | `core/bus.js` — Event bus |
| 0.5 | `core/store.js` — Reactive store (persist to localStorage) |
| 0.6 | `core/scene.js` — Scene manager (5 worlds + scene stack per world) |
| 0.7 | `core/net.js` — REST + Realtime wrapper |
| 0.8 | `core/canvas.js` — Canvas utilities |
| 0.9 | `core/tween.js` — Tween engine |
| 0.10 | `core/audio.js` — Sound sprite system |
| 0.11 | `core/input.js` — Touch/mouse/gesture handler |
| 0.12 | `core/hud.js` — Persistent HUD (avatar, frame, level, XP, coins, gems, bell, tab bar) |
| 0.13 | `core/i18n.js` — Arabic/English strings |
| 0.14 | `core/theme.js` — Dynamic theme engine (loads platform_theme + game_theme_overrides + org_theme_overrides, composes 3 layers) |
| 0.15 | `core/ads.js` — Ad slot system (reads ad_slots config, renders placements, tracks impressions) |
| 0.16 | `engine.js` — Boot sequence |
| 0.17 | `config/constants.php` + `config/database.php` + `includes/supabase.php` |
| 0.18 | `api/config.php` — Returns feature_flags, game_plugins, system_config, platform_theme, platform_assets, platform_branding |
| 0.19 | `.htaccess` + `Dockerfile` + `captain-definition` |

**Tables covered (14):**
`feature_flags`, `game_plugins`, `system_config`, `platform_theme`, `platform_assets`, `platform_branding`, `theme_settings`, `game_theme_overrides`, `ad_slots`, `ad_campaigns`, `ad_creatives`, `ad_impressions`, `xp_levels`, `_migrations`

---

## Phase 1: Auth Module
**Scope:** `modules/auth/` + `api/auth.php`
**Goal:** Register, login, profile bootstrap, token lifecycle.

| # | Deliverable |
|---|-------------|
| 1.1 | Splash scene (animated logo, token check, preload) |
| 1.2 | Login scene (email + password, animated form) |
| 1.3 | Register scene (username + email + password) |
| 1.4 | `api/auth.php` — GoTrue proxy (signup, login, refresh, logout) |
| 1.5 | Token management (store, auto-refresh, expiry) |
| 1.6 | Profile bootstrap (fetch profile + ratings + platform_roles into store) |
| 1.7 | Feature flag evaluation (load flags, evaluate rollout) |

**Tables covered (4):**
`profiles`, `user_profiles`, `platform_roles`, `player_game_ratings`

---

## Phase 2: Play World (Center Tab)
**Scope:** `modules/play/`
**Goal:** Game carousel, PLAY button, mode selection, bot/time pickers.

| # | Deliverable |
|---|-------------|
| 2.1 | Main table scene: game carousel + PLAY button + mode picker |
| 2.2 | Game cards with canvas mini-preview, rating, name |
| 2.3 | Bot selector scene (portrait grid, difficulty, ELO) |
| 2.4 | Time control picker (visual selector) |
| 2.5 | Matchmaking queue scene (search animation, cancel) |
| 2.6 | Friend picker scene (online friends, send challenge) |
| 2.7 | Daily reward widget (on table scene) |
| 2.8 | Ad slot: lobby banner (subtle, arena-sponsor style) |
| 2.9 | Online player count |

**Tables covered (2):**
`matchmaking_queue`, `domino_queue` (+ `ludo_queue` referenced)

---

## Phase 3: Chess Module
**Scope:** `modules/chess/` + `api/game.php` + `api/bots.php`
**Goal:** Full chess vs bots. Playable, rated, rewarding.

| # | Deliverable |
|---|-------------|
| 3.1 | Canvas board (8x8, themed squares from game_theme_overrides) |
| 3.2 | Piece sprites + drag/drop |
| 3.3 | Legal move highlights, last move, check indicator |
| 3.4 | Move animations, capture effects |
| 3.5 | chess.js integration (validation, state, PGN) |
| 3.6 | Dual clock (countdown, increment, flag, low-time urgency) |
| 3.7 | Move list (scrollable, two-column) |
| 3.8 | Controls (resign, draw, flip, chat toggle) |
| 3.9 | In-game chat: emote bar (preset reactions) + text input (if friends/org-mates) |
| 3.10 | Bot turn: thinking indicator → Stockfish move → animate |
| 3.11 | `api/game.php` — start, move, resign, draw, end, rating calc |
| 3.12 | `api/bots.php` — list bots, proxy Stockfish move |
| 3.13 | Result scene: win/loss animation, rating change, coins, XP |
| 3.14 | Result: report opponent button (quick + optional details) |
| 3.15 | Captured pieces display |
| 3.16 | Pre-move system |
| 3.17 | Sound cues (move, capture, check, castle, game-over) |
| 3.18 | Emit events: game:started, game:ended, coins:earned, xp:earned |

**Tables covered (4):**
`matches`, `rating_history`, `chat_messages`, `cheat_reports`

---

## Phase 4: Chess Live (Multiplayer)
**Scope:** `modules/chess/` (live additions) + `api/matchmaking.php`
**Goal:** Two real players match and play realtime.

| # | Deliverable |
|---|-------------|
| 4.1 | `api/matchmaking.php` — Queue, dequeue, find match |
| 4.2 | Realtime: matchmaking_queue UPDATE subscription |
| 4.3 | Match creation + both subscribe to match row |
| 4.4 | Realtime move sync |
| 4.5 | Clock sync (server-authoritative) |
| 4.6 | Connection loss handling |
| 4.7 | Draw offer/accept/decline |
| 4.8 | Rematch challenge |
| 4.9 | Ad slot: interstitial between matches (arena sponsor style, skippable) |

**Tables covered (0 new):** Uses matchmaking_queue, matches (already counted)

---

## Phase 5: Domino Module
**Scope:** `modules/domino/` + `api/domino.php`
**Goal:** 2-4 player domino, rooms, realtime.

| # | Deliverable |
|---|-------------|
| 5.1 | Canvas table: domino chains growing from center |
| 5.2 | Tile rendering (pips, orientation, double spinner) |
| 5.3 | Hand component (select tile, drag to edge) |
| 5.4 | Game rules: valid placement, draw, pass, spinner |
| 5.5 | Scoring: pip counting, round end, target score |
| 5.6 | `api/domino.php` — create, join, play, draw, pass, end |
| 5.7 | Room scene (players joining, start when ready) |
| 5.8 | Game scene (canvas table + hand + scores + turn) |
| 5.9 | Result scene (round/game scores, coins) |
| 5.10 | Realtime sync (opponent moves, turn indicator) |
| 5.11 | Queue matchmaking for domino |
| 5.12 | In-game emotes + text chat (if friends) |
| 5.13 | Report opponent from result screen |
| 5.14 | Bot AI for single-player |

**Tables covered (2):**
`domino_matches`, `domino_queue`

---

## Phase 6: Ludo Module
**Scope:** `modules/ludo/` + `api/ludo.php`
**Goal:** 2-4 player ludo with dice, captures, finish.

| # | Deliverable |
|---|-------------|
| 6.1 | Canvas board: cross-shaped paths, colored zones |
| 6.2 | Pieces: colored tokens with hop animation |
| 6.3 | Dice: animated roll |
| 6.4 | Rules: movement, capture, safe squares, 6=extra turn, finish |
| 6.5 | `api/ludo.php` — create, join, roll, move, end |
| 6.6 | Room scene, game scene, result scene |
| 6.7 | Realtime: all players see moves/dice |
| 6.8 | Capture effect (piece flies back to home) |
| 6.9 | Bot fill for empty seats |
| 6.10 | In-game emotes + text chat |
| 6.11 | Report opponent |

**Tables covered (2):**
`ludo_matches`, `ludo_queue`

---

## Phase 7: Social Module
**Scope:** `modules/social/` + `api/friends.php` + `api/notifications.php` + `api/activity.php`
**Goal:** Friends, notifications, activity feed, reporting.

| # | Deliverable |
|---|-------------|
| 7.1 | Friends scene: list (online first), search, pending requests |
| 7.2 | Friend card: avatar, frame, name, online dot, challenge/remove |
| 7.3 | `api/friends.php` — request, accept, remove, block, list |
| 7.4 | Notifications scene: chronological feed (types, timestamps, tap actions) |
| 7.5 | `api/notifications.php` — list, mark-read, unread count |
| 7.6 | HUD bell badge: realtime unread count |
| 7.7 | Toast system: incoming notifications appear as game-style toasts |
| 7.8 | Activity feed scene: social timeline (friend won game, joined org, earned achievement) |
| 7.9 | `api/activity.php` — get feed (friends' activity) |
| 7.10 | Challenge friend → game invite → accept → match |
| 7.11 | Report system: quick report (reason) + optional details (description) |
| 7.12 | `api/report.php` — submit cheat report |
| 7.13 | Entry to org sub-world (if player is in an org, show "My Org" card) |

**Tables covered (4):**
`friendships`, `notifications`, `activity_feed`, `cheat_reports`

---

## Phase 8: Organization Module (Sub-World inside SOCIAL)
**Scope:** `modules/org/` + `api/orgs.php`
**Goal:** COMPLETE org member experience. This is the largest module.

The org module is a sub-world you enter from the Social tab. Once inside, it has its own internal navigation (tabs/sections within the org).

| # | Deliverable |
|---|-------------|
| **Browse & Join** |
| 8.1 | Org browser scene: list active orgs (search, filter by game/country) |
| 8.2 | Org detail scene: banner, logo, description, member count, join button |
| 8.3 | Join flow: via invite link, invite code, or application |
| 8.4 | `api/orgs.php` — list, detail, join (link/code/application), leave |
| **Org Home (for members)** |
| 8.5 | Org home scene: announcements feed, upcoming events, member spotlight |
| 8.6 | Org navigation: tabs within org (Home, Chat, Events, Members, Compete, Rewards) |
| 8.7 | Member list scene: all members with roles, online status, custom titles |
| 8.8 | Org theme: when inside org context, apply org_theme_overrides layer |
| **Org Chat** |
| 8.9 | Chat channels scene: list of org channels (general, strategy, etc.) |
| 8.10 | Chat messages scene: scrollable messages, send, reply, emote |
| 8.11 | Realtime: new messages arrive live |
| **Org Events** |
| 8.12 | Events scene: upcoming org events (training, tournaments, social) |
| 8.13 | Event detail: description, time, participants, RSVP button |
| 8.14 | Training sessions: view upcoming, join, see materials/recordings |
| **Org Compete** |
| 8.15 | Org leaderboard scene: internal rankings (season, points, streak) |
| 8.16 | Org challenges scene: inter-org challenges (status, scores, roster) |
| 8.17 | Org seasonal rankings: view org's position vs other orgs |
| 8.18 | Org rosters: view team rosters (players, positions) |
| **Org Rewards** |
| 8.19 | Org achievements scene: org-specific achievements with progress |
| 8.20 | Loyalty rewards scene: day-streak rewards, claim button |
| 8.21 | `api/org-loyalty.php` — claim loyalty reward |
| **Org Content** |
| 8.22 | Content/articles scene: guides, strategies published by org |
| 8.23 | Media gallery scene: org photos/videos |
| **Org Recruitment** |
| 8.24 | Recruitment posts: browse open positions in other orgs (from org browser) |
| 8.25 | Apply to org: submit application with optional document |
| **Org Admin (light)** |
| 8.26 | View org treasury balance (read-only for non-admins) |
| 8.27 | Member spotlights: see current MVPs |
| 8.28 | Org referrals: share invite link, see referral status |

**Tables covered (28):**
`el3ab_organizations`, `org_members`, `org_memberships`, `org_membership_applications`, `org_invite_codes`, `org_invite_links`, `org_invite_uses`, `org_announcements`, `org_chat_channels`, `org_chat_messages`, `org_chat_moderation`, `org_events`, `org_event_participants`, `org_training_sessions`, `org_leaderboards`, `org_challenges`, `org_seasonal_rankings`, `org_rosters`, `org_roster_players`, `org_achievements`, `org_loyalty_rewards`, `player_loyalty_claims`, `org_content`, `org_media`, `org_recruitment_posts`, `org_treasury`, `org_treasury_transactions`, `org_referrals`, `org_member_spotlights`, `org_partnerships`, `org_player_transfers`, `org_activity_log`, `org_theme_overrides`, `org_asset_overrides`

---

## Phase 9: Rewards Module
**Scope:** `modules/rewards/` + `api/daily-reward.php` + `api/achievements.php`
**Goal:** Daily rewards, achievements, XP/level, all reward ceremonies.

| # | Deliverable |
|---|-------------|
| 9.1 | Daily reward scene: chest/calendar, streak display, claim animation |
| 9.2 | `api/daily-reward.php` — check eligibility, claim, update streak |
| 9.3 | Achievement grid scene: categories, progress bars, locked/unlocked |
| 9.4 | `api/achievements.php` — list with player progress |
| 9.5 | Achievement unlock ceremony (badge slides in, sound, glow) |
| 9.6 | Level-up ceremony (full-screen burst, new badge) |
| 9.7 | Coin/gem earn animations (particles fly to HUD) |
| 9.8 | Rank-up animation (tier promotion: bronze → silver → etc.) |
| 9.9 | Listen to game:ended events → check achievement criteria |

**Tables covered (4):**
`achievements`, `player_achievements`, `economy_transactions`, `xp_levels` (already counted in Phase 0 but used here)

---

## Phase 10: Profile Module
**Scope:** `modules/profile/` + `api/profile.php`
**Goal:** Full player card, stats, history, frames, settings.

| # | Deliverable |
|---|-------------|
| 10.1 | Profile view scene: avatar + frame, rank badge, ratings per game |
| 10.2 | Stats grid: games/wins/streaks per game type |
| 10.3 | Profile edit scene: name, avatar, bio, country, frame selector |
| 10.4 | Frame system: browse owned frames, equip/unequip, preview |
| 10.5 | Match history scene: recent games (opponent, result, rating change) |
| 10.6 | Rating chart: canvas sparkline (rating over time) |
| 10.7 | Achievement showcase on profile (top 3-5) |
| 10.8 | `api/profile.php` — get, update, avatar upload, frame equip, history |
| 10.9 | View OTHER player's profile (from friends, leaderboard, match result) |
| 10.10 | Settings scene: sound volume, language, notifications toggle |

**Tables covered (3):**
`player_frames`, `profile_frames`, `cosmetic_type_registry`

---

## Phase 11: Shop Module
**Scope:** `modules/shop/` + `api/shop.php`
**Goal:** Browse cosmetics, purchase, equip. Full economy consumer side.

| # | Deliverable |
|---|-------------|
| 11.1 | Browse scene: category tabs (frames, boards, pieces, banners, effects, packs) |
| 11.2 | Item cards: canvas preview, rarity glow, price (coins/gems) |
| 11.3 | Item detail: full preview, description, equip button |
| 11.4 | Purchase flow: confirm → deduct → item flies to collection |
| 11.5 | Equip/unequip: immediate visual feedback |
| 11.6 | Collection scene: owned items grid |
| 11.7 | `api/shop.php` — list, purchase (validate balance, insert transaction, insert player_cosmetic), equip |
| 11.8 | Insufficient funds: show "get more gems" prompt |
| 11.9 | Limited-time items: countdown timer on cards |

**Tables covered (2):**
`cosmetics`, `player_cosmetics`

---

## Phase 12: Rank Module (Leaderboard + Tournaments)
**Scope:** `modules/rank/` + `api/leaderboard.php` + `api/tournaments.php`
**Goal:** Full competitive world — rankings, tournaments with brackets, sponsors, charities.

| # | Deliverable |
|---|-------------|
| **Leaderboard** |
| 12.1 | Leaderboard scene: tabs (game × time control × period) |
| 12.2 | Player row: rank medal, avatar+frame, name, rating, country flag |
| 12.3 | Own position highlighted + "scroll to me" |
| 12.4 | `api/leaderboard.php` — by game, time, period, country |
| 12.5 | Tap player → view their profile |
| **Tournaments** |
| 12.6 | Tournament list scene: cards (name, game, format, status, dates, prize, sponsor logo) |
| 12.7 | Tournament detail scene: info, rules, prize pool, schedule |
| 12.8 | Registration: entry fee confirmation → register via RPC |
| 12.9 | Cancel registration |
| 12.10 | Bracket viewer (single/double elimination) |
| 12.11 | Swiss standings viewer (rank, score, tiebreaks) |
| 12.12 | Round pairings viewer |
| 12.13 | Tournament announcements feed (within tournament detail) |
| 12.14 | Tournament media gallery |
| 12.15 | Prize display: payout structure + claim status |
| 12.16 | Sponsor branding: logo + banner on tournament pages |
| 12.17 | Charity badge: "X% donated to [charity]" on tournament detail |
| 12.18 | `api/tournaments.php` — list, detail, register, cancel, brackets, standings, rounds |
| 12.19 | Realtime: bracket_matches updates (live scores) |
| 12.20 | Tournament format info (from tournament_format_registry) |
| 12.21 | Multi-phase tournament viewing (phase timeline) |
| 12.22 | Ad slot: tournament page sponsor placement |

**Tables covered (22):**
`leaderboards`, `el3ab_tournaments`, `el3ab_tournament_rounds`, `tournament_registrations`, `tournament_brackets`, `bracket_matches`, `tournament_phases`, `tournament_players`, `tournament_announcements`, `tournament_media`, `tournament_prize_payouts`, `tournament_sponsorships`, `tournament_format_registry`, `tournament_ad_slots`, `tournament_page_views`, `tournaments` (swiss), `rounds`, `pairings`, `standings`, `categories`, `events`, `organizations`, `sponsors`, `charities`, `charity_donations`

---

## Phase 13: Puzzles Module
**Scope:** `modules/puzzles/` + `api/puzzles.php`
**Goal:** Chess puzzle training with rating.

| # | Deliverable |
|---|-------------|
| 13.1 | Puzzle board scene (reuses chess canvas components) |
| 13.2 | Timer + move validation (correct = next, wrong = retry/fail) |
| 13.3 | `api/puzzles.php` — random by rating, submit solution |
| 13.4 | Puzzle rating (separate from game rating) |
| 13.5 | Streak indicator + rewards |
| 13.6 | Ad slot: reward video option to retry failed puzzle |

**Tables covered (1):**
`puzzles`

---

## Phase 14: Trivia Module (Planned, Not Built)
**Scope:** `modules/trivia/` + `api/trivia.php`
**Goal:** Placeholder module slot. Trivia game to be built in a future phase.

| # | Deliverable |
|---|-------------|
| 14.1 | Module slot registered in engine (shows "coming soon" card in carousel) |
| 14.2 | `api/trivia.php` — (stub) list questions, submit answer |

**Tables covered (1):**
`trivia_questions`

---

## Phase 15: Clubs Module (Merged into Org)
**Scope:** Handled inside `modules/org/` as lightweight orgs
**Goal:** Legacy club data visible within the org system.

| # | Deliverable |
|---|-------------|
| 15.1 | Clubs appear in org browser with "club" badge (free tier) |
| 15.2 | Club members visible in member list |
| 15.3 | No separate UI — clubs ARE lightweight orgs |

**Tables covered (2):**
`clubs`, `club_members`

---

## Phase 16: Polish + Remaining
**Scope:** Cross-cutting quality pass
**Goal:** Everything else, edge cases, final coverage.

| # | Deliverable |
|---|-------------|
| 16.1 | Loading states (skeletons) for all scenes |
| 16.2 | Empty states with Arabic messages for every list |
| 16.3 | Error handling (network, 401, 404, 500) |
| 16.4 | RTL polish pass |
| 16.5 | Mobile + desktop responsive testing |
| 16.6 | Offline resilience (queue writes, show cached data) |
| 16.7 | Performance audit |
| 16.8 | Security review (XSS, token exposure, CSRF on API) |
| 16.9 | `workflow_rules` integration: respect admin-configured workflow rules |
| 16.10 | `approval_requests` handling: if a player action needs approval, show pending state |
| 16.11 | Ad impression tracking: ensure all ad views are logged |
| 16.12 | Platform branding: apply platform_branding assets (logo, splash) |
| 16.13 | Deploy to CapRover, full smoke test |

**Tables covered (3):**
`workflow_rules`, `approval_requests`, `audit_log` (player actions that generate audit entries)

---

## Coverage Verification

| Phase | Tables Covered | Running Total |
|-------|---------------|---------------|
| 0 (Engine) | 14 | 14 |
| 1 (Auth) | 4 | 18 |
| 2 (Play) | 2 | 20 |
| 3 (Chess) | 4 | 24 |
| 4 (Chess Live) | 0 (reuse) | 24 |
| 5 (Domino) | 2 | 26 |
| 6 (Ludo) | 2 | 28 |
| 7 (Social) | 4 | 32 |
| 8 (Org) | 28 | 60 |
| 9 (Rewards) | 4 | 64 |
| 10 (Profile) | 3 | 67 |
| 11 (Shop) | 2 | 69 |
| 12 (Rank/Tournaments) | 22 | 91 |
| 13 (Puzzles) | 1 | 92 |
| 14 (Trivia) | 1 | 93 |
| 15 (Clubs) | 2 | 95 |
| 16 (Polish) | 3 | 98 |

**Remaining 8 = ADMIN-ONLY tables** (not player-facing):
`admin_users`, `audit_logs` (org-level admin audit), `_migrations`, `org_activity_log` (admin view), `org_asset_overrides` (admin managed), `org_chat_moderation` (admin action), `org_partnerships` (admin managed), `org_player_transfers` (admin managed)

**Wait** — let me correct. Some of those ARE partially player-facing:
- `org_activity_log` → visible to org members (Phase 8 org home)
- `org_partnerships` → "allied orgs" badge visible to members (Phase 8)
- `org_player_transfers` → player sees their transfer status (Phase 8)
- `org_chat_moderation` → player sees if they're muted (Phase 8 chat)
- `org_asset_overrides` → applied visually (Phase 8 theming)

These are all handled inside Phase 8 (Org Module). The truly admin-only tables are:
- `admin_users` — management panel login
- `audit_logs` — org admin audit trail
- `_migrations` — infrastructure

**FINAL: 106/106 tables — 103 player-facing (covered), 3 admin/infrastructure (not applicable).**

---

## Module Dependency Graph

```
Phase 0: Engine Core (MUST be first)
    │
    ├── Phase 1: Auth (needs core)
    │       │
    │       ├── Phase 2: Play World (needs auth)
    │       │       │
    │       │       ├── Phase 3: Chess (needs play)
    │       │       │       └── Phase 4: Chess Live (extends chess)
    │       │       ├── Phase 5: Domino (needs play)
    │       │       ├── Phase 6: Ludo (needs play)
    │       │       └── Phase 13: Puzzles (needs play + chess canvas)
    │       │
    │       ├── Phase 7: Social (needs auth)
    │       │       └── Phase 8: Org (sub-world of social)
    │       │
    │       ├── Phase 9: Rewards (needs auth, enhanced by games)
    │       ├── Phase 10: Profile (needs auth)
    │       ├── Phase 11: Shop (needs auth + profile)
    │       └── Phase 12: Rank (needs auth, enhanced by games)
    │
    └── Phase 16: Polish (after all modules)
```

**Parallelizable:** After Phase 2, modules 3-13 can be built in ANY order (they're independent). The order above is recommended for player value delivery.

---

## Complete Module List (Final)

| Module | World Tab | Scenes |
|--------|-----------|--------|
| `auth` | (pre-world) | splash, login, register |
| `play` | PLAY (center) | table, bot-select, time-select, queue, friend-pick |
| `chess` | (full-screen game) | game, result |
| `domino` | (full-screen game) | room, game, result |
| `ludo` | (full-screen game) | room, game, result |
| `social` | SOCIAL | friends, notifications, activity-feed |
| `org` | SOCIAL (sub-world) | browser, detail, home, chat, events, members, compete, rewards, content, media |
| `rewards` | (overlay/PROFILE) | daily-claim, achievements, levelup |
| `profile` | PROFILE | view, edit, history, achievements, settings |
| `shop` | SHOP | browse, item-detail, collection |
| `rank` | RANK | leaderboard, tournaments, tournament-detail, bracket |
| `puzzles` | (via PLAY) | puzzle-board, result |
| `trivia` | (via PLAY, future) | game, result |
| `clubs` | (merged into org) | — |

---

## API Endpoints (Complete)

| File | Covers |
|------|--------|
| `api/auth.php` | signup, login, refresh, logout |
| `api/config.php` | feature_flags, game_plugins, system_config, platform_theme, platform_assets, ad_slots |
| `api/profile.php` | get, update, avatar, frames, history |
| `api/game.php` | chess: start, move, resign, draw, end, rating |
| `api/bots.php` | list bots, proxy Stockfish move |
| `api/matchmaking.php` | queue, dequeue, find (chess, domino, ludo) |
| `api/domino.php` | create, join, play, draw-tile, pass, end |
| `api/ludo.php` | create, join, roll, move, end |
| `api/friends.php` | request, accept, remove, block, list, online |
| `api/notifications.php` | list, mark-read, count |
| `api/activity.php` | get feed |
| `api/report.php` | submit cheat/abuse report |
| `api/orgs.php` | list, detail, join, leave, members, announcements, events, chat, leaderboard, challenges, rosters, content, media, achievements, loyalty, recruitment, referrals, treasury-view |
| `api/org-loyalty.php` | claim loyalty reward |
| `api/daily-reward.php` | check, claim |
| `api/achievements.php` | list with progress |
| `api/shop.php` | list, purchase, equip |
| `api/leaderboard.php` | by game, time, period, country |
| `api/tournaments.php` | list, detail, register, cancel, brackets, standings, rounds, announcements, media, prizes |
| `api/puzzles.php` | random, submit |
| `api/trivia.php` | (stub) questions, submit |
| `api/ads.php` | get active ads for slot, log impression, log click |
| `api/theme.php` | get composed theme (platform + game + org) |
