# Game theme contract

The Theme page edits an `images.game-theme/1` document associated with a restyle batch. The neutral base has a separate profile. Settings are saved in this browser under the authenticated owner's cache namespace, with an atomic revision check to prevent stale tabs from overwriting changes. They are not automatically synchronized to other devices. Export the package to deliver it to another module.

## Contents

Complete reviewed exports add `manifest.gameTheme = {schema, file, sha256}` pointing to `theme.json`. Existing exports without a saved profile remain compatible. Settings-only exports contain `theme.json`, fonts, font licenses and imported media, but no atlas pages. They are explicitly labeled as settings exports.

All media paths are relative to `theme.json`. Verify each `media[].sha256` before use. Font faces reference media IDs; uploaded sounds and textures reference the same catalog. Bundle the font files when importing the theme into another module. System font options depend on the target platform. Cinzel and Source Sans 3 are bundled under the SIL Open Font License; their original license files are included in exports. `fonts/sources.json` records the upstream sources and checksums.

## Style hierarchy

This is a game schema inspired by WordPress Global Styles, not a WordPress `theme.json` replacement.

1. `styles.typography` and `styles.color` provide global defaults.
2. `styles.elements.heading` applies to H1–H6; their individual role settings override it. Paragraph, button, caption and link have their own roles.
3. For each component from outermost to innermost, apply `styles.blocks[component]`, its heading and text-role settings, then the selected variant and state.

Typography stores family IDs, font size in CSS pixels, weight, style, unitless line height, letter spacing in pixels and letter case. Colors reference semantic palette IDs or six-digit hex values. Render text separately from the raster. IDs for components, variants and states come from the Design bindings in the atlas manifest.

## Surfaces

`surfaces.page`, `panel` and `inset` each declare a fallback color, optional texture ID, placement (`tile`, `cover`, `contain`) and tile size in CSS pixels. A component can override its own surface with `styles.blocks[component].background`.

Render in this order: solid color, optional texture, raster frame, live text and content. A texture ID can refer to an atlas material tile or imported texture media. Material tiles must be cropped using source atlas coordinates; do not tile an entire spritesheet. Opaque raster pixels can cover the surface. Text contrast must be checked against the combined result; the editor's numeric contrast ratio describes solid colors only.

The original dummy used page `#111715`, panel `#1e2622`, inset `#151c19`, Georgia headings and Segoe UI body text. None of those backgrounds was a texture. Saved themes now explicitly define these values. Defaults use Cinzel headings and Source Sans 3 body text.

## Audio and effects

`sounds` binds hover, press, confirm, cancel, error, notification and ambient cues to optional audio media IDs and a 0–1 volume. Unassigned cues are silent. The dummy requires the user to enable audio; the editor's Play buttons are explicit playback requests. Audio stops when disabled or when the account changes.

`effects` binds hover, press, modal, notification, success and error to none/glow/pulse/fade/rise, duration in milliseconds, palette color and intensity. These are portable UI feedback parameters, not particle systems or generated VFX artwork. Respect `prefers-reduced-motion` and equivalent platform accessibility settings. No sound generation or additional image generation occurs when saving a theme.

## Review and ownership

Draft raster sheets can be inspected in the Theme page and dummy before approval. Complete exports still require all sheets to be approved in Restyle. Changing settings does not submit an Images job, alter a draft's approval or overwrite generation progress. Imported files are limited to 20 MiB each and 64 MiB total. Private settings, fonts, media URLs and previews are disposed on session change. Neither credentials nor style reference images are exported.


## Raster control corrections

Theme presentation version 2 supplies six original CC0 PCM cues (ambient remains silent), plus subtle canvas/paper/leather backgrounds. Texture opacity is a 0–1 surface property. Legacy presets receive these defaults once; custom textures and assigned audio remain unchanged. The demo starts with interaction audio enabled, plays only after a gesture, and offers a mute checkbox. Imported and built-in audio are included in the package with checksums.

The Design 0.18.0 coverage report lists all 79 component IDs, anatomy, states, and shared raster recipes. This is recipe coverage, not a certificate of generated artwork quality. Display controls reuse icon-button surfaces; learned subtitles can use the speaker strip while their text stays live. The demo route uses system-map mounts with consumer-owned positions, not graph auto-layout.

Before applying a source silhouette, unreviewed provider originals can recover a whole-sheet translation/uniform scale when alpha overlap strongly improves. Ambiguous reordering is not silently accepted as corrected. Existing reviewed sheets are never reprocessed automatically. No image generation or approval is performed by recovery. Alignment provenance is included in export receipts.

## Expandable surfaces and control geometry

Presentation version 3 separates 9-slice frame edges from their tiled interior. Material crops use only the central region, mirrored in both axes for exactly matching opposite edges. Tile size stays fixed when panels grow. The legacy Ashen Road preset migrates to a black page and warm neutral text; custom palette colors are retained.

Checkbox and radio alpha comes from the authored source masks, with generated button material providing the finish. The radio hole and outside corners remain transparent. Module export bakes these controls and seamless materials into their original atlas rectangles, clears expandable surface centers, and updates file hashes. Dividers preserve end caps and repeat their middle strip at arbitrary widths. No provider regeneration is required for these corrections.

## UI styles

The UI workspace has two main sections: Themes and Styles. Themes opens with the complete atlas overview; theme settings and the working demo are secondary views of the selected theme. Existing deep links remain valid.

UI styles are separate from generated themes and from the Images style library. A version 1 UI style stores a snapshot of its parent image style, optional UI direction/references, and optional group direction/references. Effective requests combine image, UI, then group guidance, with more specific instructions taking precedence. Empty levels inherit. Each atlas belongs to exactly one group. Logo direction is retained for future logo assets; current atlases do not generate logos.

Styles are stored in IndexedDB per authenticated cache namespace in the current browser. They are not server-synchronized. Parent image styles can be loaded from the shared Images style library; saving a UI style does not edit its parent. Runs retain their UI style snapshot for deterministic recovery. Style reuse is based on effective per-page direction and reference hashes, not the user-facing style name. Reference limits are checked for every page before submission. No style save initiates a paid generation.
