---
name: clutch-hp-illusion
description: Engineer dramatic low-HP clutch comeback ("丝血反杀") feel using 3 player-psychology dark-box mechanics: a nonlinear visual HP bar (25% true HP rendered as a 10% red sliver), one-shot protection (clamping a lethal hit at 1 HP once per fight while slowing the Boss's next windup by 1.65x), and a 120 BPM crimson heartbeat warning that flips into a high-impact comeback release. Use in action, roguelike, souls-like, or boss-fight games where players should feel heroic narrow escapes instead of sudden unfair one-shots.
---

# Clutch Comeback ("丝血反杀") Dark-Box Contract

Great action games rarely give cold linear fairness — they engineer the **emotional illusion of surviving by a single thread**.

## 1. The 3 Mandatory Mechanics

1. **Nonlinear Visual HP Curve (`mapVisualHpPercent`)**:
   - Keep `trueHp` strictly authoritative in combat logic, and apply a piecewise display transform **only to the HUD bar**:
     - `trueRatio >= 0.25` -> maps linearly to `[10%, 100%]` visual width.
     - `trueRatio < 0.25` -> maps linearly to `[0%, 10%]` visual width.
   - Result: at `25%` real health, the player's eye sees a terrifying `10%` red sliver, yet they secretly hold a `+15%` buffer capable of absorbing 2–3 more strikes.
2. **One-Shot Protection (OSP) + Boss Telegraph Slowdown**:
   - Once per encounter (or refreshed after healing above `50%`), if the player has `trueHp > maxHp * 0.20` and receives a lethal blow (`damage >= trueHp`):
     - Clamp surviving HP to **`1 HP`** instead of killing the player.
     - Trigger a sharp metallic survive cue + multiply the Boss's immediate follow-up windup duration by **`1.65×`** (e.g. `650ms -> 1070ms`), creating a legible parry / shield / heal counter window.
   - Never trigger OSP repeatedly at `1 HP` — true danger must remain real after the single save.
3. **120 BPM Tension-to-Release Feedback**:
   - Once visual HP drops `<= 22%`, fade in a subtle crimson edge vignette pulsing at `120 BPM` (`500ms` lub-dub heartbeat).
   - When the player lands a defensive counter or shield burst during the clutch window, instantly drop the crimson alarm and reward them with golden impact lighting + rising chime SFX.

## 2. Verification Checklist
- [ ] `mapVisualHpPercent(25, 100, true)` returns exactly `10`; `mapVisualHpPercent(100, 100, true)` returns `100`; `0` returns `0`.
- [ ] A lethal hit from `>= 25%` true HP clamps to `1 HP` exactly once and increases `bossWindupMs` by `1.65×`.
- [ ] A second lethal hit while already at `1 HP` defeats the player cleanly (no accidental god-mode loop).
- [ ] Heartbeat audio respects mute toggles and unlocks cleanly on first user pointer gesture (iOS WebView safe).
