# Switchrush UX Contract

## Screen Inventory

- `SCR-ONBOARDING`: one interactive miniature yard. The player drags a large orange lever to the lime-highlighted socket, sees the numbered route preview, releases, and watches the dock stamp shut. The next branch is shown once, then the player can Continue or Skip after the first step. Accessibility opens without leaving the tutorial.
- `SCR-HOME`: Switchrush mark, Start/Continue, chapter strip, current cosmetic depot badge, Settings, Accessibility shortcut, Legal, and a quiet offline label only when needed. No login or permission prompt.
- `SCR-GAMEPLAY`: top-left timer capsule, top-right train number and matching dock plate, full yard graph, three branch sockets, lever basin in the lower thumb zone, visible dock seals/cooldown hatches, pause button, and one-line route result preview. No decorative element crosses a rail or socket.
- `SCR-PAUSE`: Resume, Retry, Settings, Home. Clock and route resolver freeze; the active preview is canceled when the modal opens so no hidden commit can occur.
- `SCR-SUCCESS`: completed parade, delivered count, route order summary, cosmetic depot badge/tile, Next, Replay, Home. No ad or purchase blocks the first result.
- `SCR-FAILURE`: exact cause label (“Wrong dock”, “Branch closed”, “Collision”, “Maintenance gate”, or “Time out”), highlighted decisive route, Retry, Home, and optional Inspect. No purchase or ad prompt.
- `SCR-SETTINGS`: sound, haptics, reduced motion, text size, high contrast, tutorial replay, Restore Purchases, Privacy, Terms, Credits, Support.
- `SCR-ACCESSIBILITY`: live preview of numbered trains, hatch patterns, thick outlines, text scale, reduced-motion preview, haptic toggle, and assistive-label summary.
- `SCR-LEGAL`: locally cached privacy, terms, licenses, credits, support contact, consent details, and last-updated label. Network failure leaves the last cached version visible and offers Retry.

## State Inventory

`ST-FRESH` loads the exact authored graph, zero committed routes, full timer, and first-train focus hint. `ST-ACTIVE` contains idle, drag, preview, and commit-candidate sub-states; preview is a pure read-only projection. `ST-PAUSED` freezes clock and animation with focus trapped. `ST-SUCCESS` disables gameplay input while the final parade plays, then enables result controls. `ST-FAILURE` freezes the yard at the cause and keeps the chosen branch visible. `ST-ERROR` is a recoverable local/optional-service problem with Retry and Home and never fabricates progress.

## Transitions and Back Behavior

Every new visit starts at onboarding. `FTUE-01` contains one real route action; Skip becomes available after the first teaching step and opens Home without marking tutorial completion. Home Start opens `ST-FRESH`. `UX-BACK` maps Android/system Back in gameplay to Pause, Back in Pause to Resume, and Back from Settings/Accessibility/Legal to the caller; Back on Home exits through the platform's normal confirmation. Retry always reloads the authored initial state and timer.

## Orientation and Safe Areas

The logical canvas is 360x640 portrait. Top safe inset is `max(device inset, 24px)`, bottom is `max(device inset, 20px)`, and side insets are `max(device inset, 16px)`. The top HUD occupies y=24-92, the route yard y=108-490, and the lever/action zone y=506-620. The lever, three sockets, pause button, and result buttons are at least 48x48 with 8px separation. The lever basin sits in the lower-middle thumb zone; branch socket hit areas extend 12px beyond the visible plate. No required drag begins at a system-edge gesture region.

## Touch and Reachability

Dragging starts only from the lever. Crossing the midpoint between sockets updates the preview; releasing outside all sockets cancels. If the finger leaves the app, focus changes, or a modal opens, the drag cancels with no state change. A release timestamp exactly on the timer boundary follows the GDD tie-break rule. There is no two-finger gesture, long press, edge swipe, or precision angle requirement.

## Overlays, Loading, and Errors

Level JSON is decoded and solver-checked before entering `ST-FRESH`; a short inline skeleton appears inside the home/start surface. A malformed level shows `ST-ERROR` with a category, Retry, and Home. Optional analytics, entitlement, and remote content failures are silent or shown as a small home badge; local play continues. Interstitial ads, if used, can appear only after Success/Failure controls are available and never during onboarding, active gameplay, pause, or an error. An opt-in hint shows information without auto-committing a route.

## Accessibility Matrix

- Trains have large numbers and silhouette differences; docks repeat number and shape. Color is never the only match signal.
- Open branches use solid rail and lime arrowheads; cooldown branches use hatch plates and a lock glyph; hazards use red diagonal stripes and a warning icon.
- High contrast adds black outlines and opaque panels. Essential text targets 4.5:1 contrast.
- Text scale supports 100/125/150% with the yard reflowing labels rather than clipping them. A compact route summary is available to assistive technology.
- Reduced motion removes camera shake, glow sweeps, and long train travel; it keeps the same route resolution and timing semantics.
- Audio and haptics have independent toggles. Visual route previews and text causes remain complete when either is off.
- Focus order is heading → timer → train/dock → yard summary → lever → primary result action → secondary action → navigation. Modal focus returns to its opener.

## Visual and interaction timing

Screen transitions use a 140ms opacity change plus 6px vertical motion; reduced motion removes the translation. Lever snap is 90ms, route preview appears within one frame of the pointer crossing a midpoint, train travel is 800ms in default mode and 120ms in reduced motion, dock seal is 180ms, and failure cause appears immediately on resolve. Effects are never longer than the result state needs and never obscure the next route.
