# Phase 4: Polish + Audio - Context
**Gathered:** 2026-03-29 (assumptions mode)
**Status:** Ready for planning
## Phase Boundary
Visuell und auditiv angenehmes Erlebnis, bereit zum Testen mit dem Kind. Umfasst: Sound-Effekte (Web Audio API), Sprachausgabe (Web Speech API), sanfte Animationen (Blätter-Fall, Sternenstaub, Avatar-Schweben), Responsive bis 700px, globaler Error-Handler, Export/Import/Reset im Elternbereich. Keine neuen Features — rein Polish auf bestehendem Spielerlebnis.
## Implementation Decisions
### Audio System
- **D-01:** Ein Modul `src/audio/sounds.ts` mit Web Audio API. Shared `AudioContext`, procedural Sounds (Oszillatoren, Noise Buffers). Exportiert: `playCorrectSound()` (800Hz, 0.1s), `playRewardSound()` (aufsteigende Tonfolge, 0.8s), `playForestElementSound()` (gefiltertes weisses Rauschen, 0.5s). Alle prüfen `audioEnabled` aus Settings Store.
- **D-02:** AudioContext wird bei erster User-Interaktion erstellt/resumed (Auto-Play Policy Compliance). Lazy initialization Pattern.
- **D-03:** Mute-Button als fixed-position Element in `` ausserhalb aller `
## Canonical References
**Downstream agents MUST read these before planning or implementing.**
- `SPEC.md` section 11 — Audio-Details (Frequenzen, Dauern, Web Audio API)
- `SPEC.md` section 7.2 — Animationen (sanft, langsam, keine schnellen Blitze)
- `SPEC.md` section 12 — Responsive, Error-Handler
- `src/styles/main.css` — Bestehende Animationen (letter-float, falling-letter--dissolve, forest-element-appear)
- `src/ui/screens.ts` — Lesson screen (touch points für Audio + Animationen)
- `src/forest/reward.ts` — Reward screen (touch point für Belohnungs-Sound)
- `src/forest/scene.ts` — Forest scene (touch point für Waldelement-Sound)
- `src/ui/parent.ts` — Parent area (Export/Import/Reset einbauen)
- `src/storage/db.ts` — IndexedDB Stores (Export liest, Import schreibt, Reset löscht)
- `src/types.ts` — Settings Interface (audioEnabled existiert, speechEnabled hinzufügen)
- `src/main.ts` — Entry point (Error-Handler hier)
- `index.html` — Mute-Button ausserhalb Screens
## Existing Code Insights
### Reusable Assets
- `Settings.audioEnabled: boolean` existiert in types.ts, Parent-Screen hat Toggle, DB-Methoden fertig
- `getSettings()`/`saveSettings()` in db.ts ready
- Bestehende CSS Animationen: `letter-float`, `falling-letter--dissolve`, `forest-element-appear`, `companion-float` (teilweise)
- `getProgress()`/`saveProgress()` für Export ready
- Parent-Screen HTML/CSS existiert mit Settings-Section
### Established Patterns
- Settings Store für Persistenz (audioEnabled Pattern wiederverwendbar für speechEnabled)
- CSS `@keyframes` für alle Animationen
- IndexedDB Promise-Wrapper Pattern in db.ts
### Integration Points
- `screens.ts` Zeile ~214 (result.correct Branch) → `playCorrectSound()`
- `reward.ts` initRewardScreen → `playRewardSound()` + `speakText(comment)`
- `scene.ts` forest element appear → `playForestElementSound()`
- `app.ts` greeting → `speakText(greeting)`
- `parent.ts` → Export/Import/Reset Buttons
- `main.ts` → Error-Handler
- `index.html` `` → Mute-Button
## Specific Ideas
No specific requirements — open to standard approaches
## Deferred Ideas
None — analysis stayed within phase scope