Crosswords.
9 mini crosswords in one 11×11 grid. Black lines split the board into nine 3×3 blocks. Each block is its own little crossword — 3 across, 3 down. Click a cell, type a letter, Tab / click to switch direction.
Across
Down
The 11×11 board is 9 blocks. Example top-left block: Across = FAR / ARE / TED, Down = FAT / ARE / RED. Type with keyboard. Arrows move. Backspace clears. Click the number box to jump to that word. Click the clue text to strike it through when done — click again to undo.
Crosswords Backend — Proposed Architecture
Right now this page is local-only — puzzles live in JS (blocks + clueMap), the solution ships to the browser in sol, progress lives in memory, and the timer is client-side. This is the map to make it real: same 11×11 board, same nine 3×3 blocks, same clues — but puzzles live on the server, the solution never ships to the browser, and progress / solves / leaderboard are saved server-side.
01 / Files to create
api/crosswords/list_puzzles.php GET /api/crosswords/list_puzzles
api/crosswords/get_puzzle.php GET /api/crosswords/get_puzzle?id={puzzle_id}
api/crosswords/save_progress.php POST /api/crosswords/save_progress
api/crosswords/submit_solve.php POST /api/crosswords/submit_solve
api/crosswords/leaderboard.php GET /api/crosswords/leaderboard?id={puzzle_id}
sql/crosswords_tables.sql
Keep the tinyfiles PHP pattern: each endpoint loads /api/bootstrap.php, uses json_in() / json_out(), member session for auth, prepared PDO statements.
02 / Database tables
-- sql/crosswords_tables.sql
crossword_puzzles
id VARCHAR(40) PRIMARY KEY -- e.g. 'xw-001'
title VARCHAR(80) NOT NULL
difficulty ENUM('easy','medium','hard') NOT NULL DEFAULT 'easy'
blocks JSON NOT NULL -- 3x3 blocks, each block 3 across words, like blocks[][][] in this page
clues JSON NOT NULL -- word -> clue map, like clueMap in this page
created_at DATETIME NOT NULL
crossword_progress
member VARCHAR(80) NOT NULL
puzzle_id VARCHAR(40) NOT NULL
player_grid JSON NOT NULL -- 11x11 player letters, '' for blank
selected_row TINYINT NOT NULL DEFAULT 0
selected_col TINYINT NOT NULL DEFAULT 0
direction ENUM('across','down') NOT NULL DEFAULT 'across'
updated_at DATETIME NOT NULL
PRIMARY KEY (member, puzzle_id)
FOREIGN KEY (puzzle_id) REFERENCES crossword_puzzles(id)
crossword_solves
id BIGINT AUTO_INCREMENT PRIMARY KEY
member VARCHAR(80) NOT NULL
puzzle_id VARCHAR(40) NOT NULL
time_seconds INT NOT NULL -- server-measured: completed_at - started_at, not client timer
mistakes INT NOT NULL DEFAULT 0
completed_at DATETIME NOT NULL
started_at DATETIME NOT NULL
UNIQUE KEY (member, puzzle_id) -- one best solve per member per puzzle; update if faster
FOREIGN KEY (puzzle_id) REFERENCES crossword_puzzles(id)
Store blocks + clues as JSON so a new puzzle is one row, no schema change. Never store the solution as a separate client-visible field — the server derives it from blocks.
03 / API endpoints & request flow
GET /api/crosswords/list_puzzles
- returns id, title, difficulty, created_at — no solution, no blocks answers
GET /api/crosswords/get_puzzle?id=xw-001
- returns blocks skeleton (black / white cells) + clues only
- never returns sol / full answers
- starts (or resumes) a server-side timer: started_at = NOW() if no solve yet
POST /api/crosswords/save_progress
{ "puzzle_id": "xw-001", "player_grid": [[...11x11...]], "selected": [0,0], "direction": "across" }
- upserts into crossword_progress, debounced from the front-end on each keystroke
- on reload, front-end loads progress and restores grid + selection
POST /api/crosswords/submit_solve
{ "puzzle_id": "xw-001", "player_grid": [[...11x11...]] }
- server rebuilds sol from blocks, compares cell-by-cell
- if all correct: time_seconds = completed_at - started_at, INSERT / UPDATE crossword_solves
- if wrong: returns { "ok": false, "wrong": 3 } — same as current Check, but counted server-side
- returns { "ok": true, "time_seconds": 214, "mistakes": 0, "is_best": true }
GET /api/crosswords/leaderboard?id=xw-001
- top 20 by time_seconds ASC, then mistakes ASC, then completed_at ASC
Front-end contract stays the same: render() draws from the puzzle + progress payload, checkXW() calls submit_solve in check-only mode, revealXW() is never a server call — it stays local-only and disqualifies that run from the leaderboard.
04 / Validation & anti-cheat
// Server owns the truth. Browser submits intent only. - Validate a block on save: each block must be 3 across words, each 3 letters, and each column must also be a 3-letter word in the word list. Blocks in this page pass: e.g. FAR / ARE / TED across, FAT / ARE / RED down. - Validate player_grid: 11x11, only A-Z or '', black cells (row 3,7 / col 3,7) must be null. - Never trust the client timer: time comes from started_at on the server. - Reveal / Clear are local-only. A revealed run never writes to crossword_solves. - Check counts mistakes server-side, so a tampered client cannot fake a 0-mistake solve. - Rate-limit save_progress (1/sec per member) and submit_solve (1/5s) to stop brute-force.
05 / Puzzle format & generation
// Same format this page already uses, now as a DB row:
{
"id": "xw-001",
"title": "First Nine",
"difficulty": "easy",
"blocks": [
[[ "FAR","ARE","TED" ],[ "CAR","ARE","TED" ],[ "BAT","ARE","RED" ]],
[[ "CAT","ARE","RED" ],[ "FAT","ARE","RED" ],[ "BAR","ARE","TED" ]],
[[ "CAP","ARE","PEN" ],[ "ARE","RUG","EGG" ],[ "CAR","API","RIB" ]]
],
"clues": { "FAR": "Not near", "ARE": "You ___", "TED": "Bear's name, briefly" }
}
// Separator rows/cols are always 3 and 7. Grid = br*4+r, bc*4+c, same as today.
// To add a puzzle: insert one row, front-end list picks it up automatically.
New puzzles need no code change — one row in crossword_puzzles is a new puzzle. The 11×11 builder, clue numbering, and keyboard handling stay exactly as they are.