# Game Design Document v0.1

## Player Promise and Audience

Switchrush promises a readable, satisfying dispatch decision every few seconds: drag one switch, see the exact route, release, and watch a tiny train either complete the plan or reveal the mistake. The target player is a casual mobile player aged 13+ who wants a short portrait game while waiting, with enough order-planning depth to reward a second attempt. A first session should communicate the complete loop in under 45 seconds, with no account, network connection, or text-heavy setup.

The game is a 2D hypercasual route-planning arcade game. A normal level lasts 20-60 seconds and contains 3-8 trains. The player can restart instantly. The game is designed for one-thumb use in portrait orientation and for silent play; sound and haptics add confirmation but are never required to distinguish a route.

## Design Pillars

- **P-01 Readable pressure:** The active switch, three branch sockets, train destination, timer, and route preview are always visually distinct.
- **P-02 One meaningful gesture:** Drag and release is the only required input. The player never draws track, steers a moving train, or manages a menu during a decision.
- **P-03 Consequences stay visible:** A delivered dock seals and the used branch shows its cooldown. The yard state makes the next decision harder in an observable way.
- **P-04 Fast retry:** A failed route pauses on the cause, then exposes Retry without a forced ad or long result sequence.

Switchrush is not a freeform track builder, train collection game, idle game, narrative game, multiplayer game, level editor, or gacha economy. It does not add power-ups that bypass route reading. Cosmetic depot badges may grow over time, but they never change rules.

## Design Pillars and Non-Goals

The four pillars above are binding design targets. Non-goals are freeform track building, train collection, idle progression, narrative, multiplayer, level editing, gacha economy, and power-ups that bypass route reading.

## Player-Facing Fingerprint

- Input: Drag the active lever to one of three branch sockets, inspect the deterministic route preview, and release to commit.
- Decision: Serve the current train while preserving enough open track for the remaining order.
- Objective: Route every train into its matching numbered dock before the timer expires.
- Failure: Wrong dock, closed branch, collision, or timeout with a train still moving.
- State change: Every committed route moves a train, seals a matched dock, occupies the used branch for its cooldown, and advances the junction pattern.
- Progression: Six chapters introduce matching, branch cooldowns, train order, cyclic junctions, hazards, and mastery combinations without new verbs.
- Content: Authored route graphs, train sequences, dock mappings, branch cooldowns, hazard placements, and timers.
- Presentation: Portrait 2D toy rail yard using safety orange, warm enamel white, graphite, acid lime, and signal red; no paper, navy, cyan-line, or serif-heading house-style bundle.
- Metagame: Cosmetic route tiles and depot badges only; no gameplay power progression.

## Core Loop and Player Verbs

1. The level shows the active train, its destination number, the current switch, three branch sockets, the yard timer, and sealed/cooldown markers.
2. The player drags the lever to a legal branch socket.
3. The preview highlights the exact path, arrival dock, and any conflict or failure marker.
4. The player releases to commit or lifts outside a socket to cancel.
5. The train traverses the selected path. A correct delivery seals its dock; the route state updates.
6. The next train arrives with the updated junction pattern. All trains delivered produces Success; any failure condition produces Failure.

Stable verbs:

- **M-01 Inspect:** Read train number, dock number, open branches, cooldown dots, and route preview.
- **M-02 Drag:** Move the lever between its current rail and a branch socket.
- **M-03 Commit:** Release inside a legal socket to route the train.
- **M-04 Cancel:** Lift outside a socket before release to return the lever without state change.
- **M-05 Retry:** Restart the current level from its authored initial state.
- **M-06 Pause:** Open the pause overlay; the simulation clock stops and no route resolves.

## Deterministic Rules

### Level model

Each level is an authored route graph. It contains `levelId`, `chapter`, `timerSeconds`, `trainSequence`, `dockMap`, `junctionPattern`, `branchCooldowns`, `hazards`, and `solutionDepth`. A train has an immutable `trainNumber`, `spawnOrder`, `currentNode`, `destinationDock`, and `status`. A dock has an immutable number and a status of `open`, `sealed`, or `failed`. No level uses random generation, network state, device time, or hidden physics.

The yard is shown in a fixed 360x640 logical portrait canvas. The active junction has three branch sockets: left, center, and right. The current `junctionPattern[turnIndex]` maps those sockets to graph edges. A branch is legal only when its edge exists, is not marked `closed`, does not point to a sealed dock, and does not produce a collision in the preview.

### Timing and ordering

The level clock begins at the first gameplay frame after the player starts, not while the home or onboarding screens are visible. The decision window is 1.4 seconds from the train entering the decision ring. The player may start dragging before the ring opens, but the release is ignored until the train is active. The train travel animation is 0.8 seconds and route resolution occurs at its end. The next train cannot be committed until the prior train resolves. Pause freezes both clock and animation.

The authoritative order for a commit is: validate release position; evaluate the selected graph edge; evaluate closed-branch and sealed-dock constraints; evaluate wrong-dock and hazard constraints; evaluate collision against occupied train nodes; then apply the route. A failed evaluation ends the level before any partial state is applied. A successful evaluation moves the train, seals a matching dock, applies the selected branch cooldown, increments `turnIndex`, and loads the next train.

Branch cooldown is an integer number of future commits. When a branch is selected with cooldown `k`, it is closed for the next `k` train decisions, then becomes open. If a branch is already closed, selecting it is not legal. A level can set `k=0` for the introductory chapter. Sealed docks are never reopened in that level. A train may not use a branch that terminates at its own already sealed dock.

### Input and preview

The lever snaps to the nearest socket only for visual preview; the authoritative choice is the socket containing the release point inside a 28dp hit radius. A drag beginning outside the lever does nothing. A release outside every socket cancels with no state change. The preview runs the same pure route resolver as commit, so it cannot disagree with the result. Red preview means the selected branch would fail; the player may still release it to learn the failure, but no penalty is hidden.

Undo exists only as pre-commit cancel. There is no post-commit undo, rewind, or random rescue. Restart restores the exact authored initial state and resets the clock. A reload or new visit starts at onboarding again and never restores a completed level, gameplay state, or FTUE flag.

### Win and loss

Success occurs after the final train resolves at its matching open dock. The level records a star result in memory for the current session only, then shows Success. Failure occurs immediately on wrong dock, closed branch, hazard, collision, or timeout. The failure panel states the concrete cause, shows the last selected branch, and offers Retry and Home. There is no life system.

### Edge cases

- If two sockets are equidistant, the preview remains on the prior socket until the pointer crosses the midpoint; release uses the same midpoint rule.
- If a finger leaves the window, the current drag cancels and the train remains active.
- If the app loses focus, gameplay pauses and resumes only after the player taps Resume.
- If a level asset is missing or malformed, the game loads a local error state with Retry and Home rather than entering a partial level.
- If the timer expires on the same frame as a valid commit, the commit wins when the release timestamp is at or before the displayed zero boundary; otherwise timeout wins. The test harness fixes timestamps to make this deterministic.
- Reduced-motion mode replaces train travel with a 120ms position swap while preserving the same resolve order and feedback.

## Failure, Consequence, and State Change

The main consequence is route availability, not a score-only penalty. A correct delivery removes one destination from the open set and starts a branch cooldown. The next train therefore sees a visibly different legal choice set. An incorrect choice is immediately attributable: the route preview and failure label name the wrong dock, closed branch, collision, hazard, or timeout. Because train order is authored, learning a failed level means changing route order rather than waiting for luck.

The success state shows the completed parade and a small route summary. The failure state leaves the yard visible behind the cause card so the player can compare the chosen route with the next attempt. There is no concealed damage, health, or monetized continuation.

## Progression and Content Grammar

The launch grammar is 60 authored levels, ten per chapter:

- **C1, Levels 1-10 — Match:** three trains, no cooldown, one obviously safe branch; teach number matching and preview reading.
- **C2, Levels 11-20 — Close:** branch cooldowns of one commit; teach that a delivered route changes the next choice.
- **C3, Levels 21-30 — Order:** four to five trains share branch families; teach delivery order and sealed docks.
- **C4, Levels 31-40 — Cycle:** the junction pattern rotates among three incoming lanes; teach state changes that cannot be solved by repeating the same socket.
- **C5, Levels 41-50 — Hazard:** red maintenance gates and collision nodes add visible failure routes; teach route rejection.
- **C6, Levels 51-60 — Rush:** combine all prior variables with shorter clocks and one optional mastery branch; test fluency without a new verb.

Difficulty variables are train count, solution depth, cooldown length, number of legal-looking wrong branches, junction cycle length, hazard proximity, and timer margin. Every level has at least one deterministic solution and one authored `solutionDepth`; the validator rejects a level with no solution or with a solution that requires an unavailable socket. Replays use the same level data and do not generate new layouts.

## First Session and FTUE

Every visit starts at `onboarding-fresh` before Home, with no persisted completion flag. The onboarding uses one level-like miniature yard and four short steps: (1) finger icon drags the lever to the highlighted socket; (2) route preview appears; (3) release sends the train to the numbered dock; (4) the dock seals and the next choice changes. The player must perform one real drag and release; a Skip button is available after the first step and opens Home without granting completion credit. A Replay tutorial action remains in Settings.

Home shows the title, Start, chapter tile, sound and haptic toggles, Accessibility, Legal, and a small cosmetic depot badge. Start opens Level 1. No account or permission is required. The first success uses the same Success screen as later levels, then returns to Home with the next chapter tile still locked until the current chapter's authored levels are cleared.

## Economy and Monetization Boundaries

There is no soft currency, premium currency, energy, lives, or gameplay inventory. Clearing levels grants a cosmetic route tile and chapter badge in memory; a production build may sync this cosmetic collection only after explicit opt-in, but local play must work without it. Ads, if shipped, may appear only after a completed or failed level and never during a decision, onboarding, pause, or error. A rewarded ad may reveal a non-solving route hint only if the player requests it, with a visible “No thanks” action; it cannot auto-commit a route. Purchases are limited to an ad-removal entitlement and cosmetic theme bundles. Restore Purchases is available in Settings. No dark pattern, forced ad after repeated failure, or purchase gate is allowed.

## UX, Accessibility, Audio, and VFX

Required screens and states are specified in `06-ux/screen-inventory.json`. All interactive targets are at least 44x44dp with an 8dp spacing minimum. The active lever is reachable in the lower-middle zone; the timer and train number remain in the upper safe area. Gameplay does not require a swipe starting near the cutout or system gesture edge.

Color is never the only signal: trains use large numbers and distinct silhouettes; docks use numbers and shape badges; open/closed branches use rail occupancy and hatch patterns; hazards use a striped warning frame and icon; success/failure use text and motion/audio cues. A high-contrast mode adds black outlines and removes translucent overlays. Color-blind mode uses shape/number pairs unchanged from default. Reduced motion shortens travel and removes camera shake. Haptics are optional and map to preview snap, commit, success, and failure.

Audio is a small local set: lever tick, route preview chirp, rolling loop, dock chime, and failure buzzer. Muting removes all audio with no gameplay change. VFX are limited to route highlight, branch cooldown pulse, dock seal stamp, and a short parade confetti burst; they never obscure the route graph or imply a mechanic not in this GDD.

Back behavior: on Home it exits or returns to the platform; in gameplay it opens Pause; in Pause it returns to gameplay; in Settings or Legal it returns to the previous screen. The pause overlay blocks gameplay input and contains Resume, Retry, Settings, and Home. Loading and error states preserve safe-area padding and expose Retry plus Home.

## Technical Constraints

The implementation is 2D and offline-first. Level JSON is versioned and validated at build time. The route resolver is a pure function with no time, random, network, or render dependencies; a replay record stores level ID, train index, socket choices, and result cause. The default target is 60fps on 2019 mid-tier iOS and Android phones with a 30fps fallback, 360x640 logical portrait layout, under 150MB installed and 250MB peak memory.

Gameplay UI is native/vector or runtime-drawn from the declared 2D kit; generated raster reference frames are not production UI. No runtime generative dependency is allowed. Analytics are optional and buffered locally; they never block owned play. No gameplay progress, FTUE completion, board state, or results may be stored in browser storage or a server for the prototype.

## Risks, Falsifiers, and Acceptance Criteria

Risks include players missing the route consequence, the timer feeling unfair, the train animation hiding the next branch, and the category reading as a static train puzzle. The concept is falsified if a first-time player cannot route the tutorial train after one explanation, if more than 20% of observed retries are attributed to unclear feedback rather than a deliberate wrong choice, or if a tester can solve every level by always choosing the visually shortest branch.

Acceptance checks:

- A fresh visit always shows onboarding before Home and never restores FTUE or level progress.
- A valid drag preview and the committed resolver produce identical destination and failure cause.
- At least one level demonstrates a correct first delivery that closes the obvious branch and requires a different second choice.
- Every failure names one deterministic cause and offers immediate Retry.
- Level 1 can be completed in under 45 seconds by a new player; a mastery level lasts no longer than 60 seconds.
- All branch, dock, train, timer, pause, safe-area, and accessibility signals remain legible at 360x640 portrait.
- The content validator proves 60 authored levels have a solution and no malformed route reference.
- No monetization prompt appears before the first real success or during an active decision.

## Source and Truth Labels

This document is the authoritative player-facing contract for concept `switchrush`. The owner brief is CONFIRMED. Rules, UX, scope, cost, and content counts are DESIGN TARGETS until prototype or player evidence exists. Originality, demand, retention, CPI, and revenue are assessed in later gates and remain uncertain here. The exact player promise is: drag one switch, beat the clock, and route every tiny train through a yard changed by the last choice.

## Fantasy, Promise, Audience, and Genre

Genre: deterministic route-order hypercasual arcade puzzle. Fantasy: be the quick, precise dispatcher of a miniature industrial rail yard. Store promise: every switch changes the next route, so the right answer is an order of fast visible decisions. Audience: casual mobile players aged 13+ who want one-thumb sessions and train/puzzle fans who enjoy cause-and-effect planning. The first-session value is one real drag, one matching dock delivery, and one visible branch cooldown in under 45 seconds.

## Camera, Dimension, and Controls

The product uses portrait-only 2D with a fixed orthographic camera and a 360x640 logical gameplay canvas. The full `ENV-YARD` stays visible between `UI-TOPBAR` and the lower thumb zone. One-finger drag begins on `UI-LEVER`, crosses toward one of three `UI-SOCKET` plates, shows `M-PREVIEW`, and release commits `M-03`. Lifting outside a socket cancels. Gameplay never uses camera rotation, pan, zoom, multi-touch, free-angle input, or perspective-dependent route rules.

## State and Content Inventory

Screens are `SCR-ONBOARDING`, `SCR-HOME`, `SCR-GAMEPLAY`, `SCR-PAUSE`, `SCR-SUCCESS`, `SCR-FAILURE`, `SCR-SETTINGS`, `SCR-ACCESSIBILITY`, and `SCR-LEGAL`. Important states are `ST-FRESH`, `ST-ACTIVE`, `ST-PAUSED`, `ST-SUCCESS`, `ST-FAILURE`, and `ST-ERROR`. Mechanics are `M-01` inspect, `M-02` drag, `M-03` commit, `M-04` cancel, `M-05` retry, and `M-06` pause. Entities are `E-TRAIN`, `E-DOCK`, `E-SWITCH`, `E-BRANCH`, and `E-HAZARD`; environments are `ENV-YARD`, `ENV-DEPOT`, and `ENV-MAINTENANCE`; UI is `UI-TOPBAR`, `UI-LEVER`, `UI-SOCKET`, `UI-RESULT`, `UI-TOGGLE`, `UI-MODAL`, and `UI-BADGE`; accessibility IDs are `A-COLOR`, `A-TEXT`, `A-MOTION`, `A-HAPTIC`, `A-CONTRAST`, `A-TOUCH`, `A-FOCUS`, and `A-ASSISTIVE`; VFX are `V-PREVIEW`, `V-SEAL`, `V-COOLDOWN`, `V-FAIL`, `V-PARADE`, and `V-TRANSITION`.

## Difficulty, Progression, and Economy

The six chapters and 60 authored levels introduce matching, cooldown, order, cyclic junctions, hazards, and combined mastery. Difficulty changes train count, cooldown length, misleading legal-looking branches, cycle length, hazard proximity, and timer margin. Every level has a solver-checked solution. Cosmetic depot badges and route tiles are the only progression; they do not alter route rules. There are no lives, energy, gameplay currency, or power inventory.

## Monetization Constraints

Ads, if shipped, occur only after a Success or Failure result is readable and never during onboarding, active gameplay, pause, or error. A requested rewarded hint may reveal the next branch consequence but may not auto-commit or bypass a failure. Purchases are limited to ad removal and cosmetic depot themes. Restore Purchases is available in Settings. No forced continuation, dark pattern, pay-to-solve action, or purchase gate may cover the core loop.

## UX and Accessibility

All screens and states are enumerated in `06-ux/screen-inventory.json` and `06-ux/ux-flow.md`. `A-COLOR` pairs colors with numbers, silhouettes, icons, and hatches; `A-TEXT` supports 100/125/150% scale; `A-MOTION` removes shake, long train travel, glow sweeps, and flashing; `A-HAPTIC` is independently optional; `A-CONTRAST` uses thick outlines and opaque panels; `A-TOUCH` guarantees 48x48 targets; `A-FOCUS` defines predictable modal focus; and `A-ASSISTIVE` names train, dock, branch, cooldown, and projected route. Safe areas, Back behavior, loading, error recovery, and reachability are first-class contracts.

## Audio and VFX

Audio is a local set of lever tick, preview chirp, dock chime, failure buzzer, and success roll. `V-PREVIEW` is a lime arrowed route ribbon, `V-SEAL` stamps a matching dock, `V-COOLDOWN` pulses its hatch and lock, `V-FAIL` marks the deterministic cause, `V-PARADE` completes a restrained train loop, and `V-TRANSITION` handles screen changes. Audio and haptics can be disabled without removing visual or text feedback. Reduced motion preserves resolve order and timing semantics.

## Analytics and Technical Constraints

The route resolver is a pure function of level data, current graph state, train index, socket choice, and timestamp boundary. Level JSON is versioned and build-time solver-validated. Optional analytics record tutorial completion, preview-to-commit choice, failure cause, retry, and success only after consent; analytics failure never blocks offline play. The target is 60fps on 2019 mid-tier phones with a 30fps fallback, under 150MB installed and 250MB peak memory. No runtime generative dependency is allowed.

## Risks and Falsifiers

Risks are rail-category sameness, unclear cooldown consequence, unfair timer pressure, and a visual preview that looks decorative instead of authoritative. The concept is falsified if a new player cannot route the tutorial train after one explanation, if testers mostly blame unclear feedback for retries, or if every level can be solved by choosing the shortest-looking branch. A failed first-play test requires revision before production.

## Acceptance Criteria

Fresh visits start onboarding; a valid preview and commit share the same resolver result; at least one level requires changing route order after a successful delivery; every failure names one cause and offers Retry; Level 1 completes under 45 seconds; mastery levels stay under 60 seconds; all states are legible at 360x640 portrait; 60 levels have solver evidence; and no monetization prompt appears before the first real success or during a live decision.
