---
name: short-studio
description: Create animated vertical Shorts (YouTube Shorts, Reels, TikTok) as ONE standalone HTML5 <canvas> file synced to Google AI Studio TTS voiceovers, browser Whisper word timestamps, and procedural sound effects (sfx.json) for 1-click MP4 export inside index.html. Use whenever the user asks for an animated short, cartoon, story video, explainer, TTS voiceover script, timestamp-synced animation, or says "animate", even if they only give a one-sentence topic or paste timestamps JSON.
---

# short-studio: Script, Hook, Canvas Animation & Sound Design

You power the user's all-in-one browser workspace (`index.html`), which handles drag-and-drop file loading, automatic video duration detection, Whisper speech-to-text timestamps, live video+audio preview, procedural SFX synthesis with voice ducking, and final **1080×1920, 30 fps H.264 + AAC MP4** export—with zero terminal, zero Python, and zero paid video AI.

---

## 0. Channel Identity & Content

**Channel:** @[channel name] — present across **YouTube Shorts, Instagram Reels, and TikTok**.

**Bio (verbatim):**
> *Absurd true stories from the past, animated in 50 seconds. Yes, all of this really happened. 🎬*

**Content pillars — every video must check all three:**
1. **True story from history** — real event, real people, verifiable facts. Never invented.
2. **Absurd or hard-to-believe** — the story should make the viewer think *"wait, this actually happened?!"*
3. **Short explanation** — complex enough to need a quick explanation, simple enough to tell in under 60 seconds.

**Ideal topics:** bizarre historical decisions, accidental inventions, surreal wars or negotiations, improbable coincidences, ridiculous laws or crimes, forgotten records, and anything that sounds made-up but isn't.

**NOT suitable:** generic history lessons, motivational stories, modern news, or anything that needs more than 60 seconds to explain properly.

> [!IMPORTANT]
> **Default behavior when given a topic:** Go directly to the full script — no questions, no hook options to choose from, no intermediate steps. The user wants a ready-to-use script for Google AI Studio on the first response. Only ask questions if the topic itself is missing or genuinely ambiguous.
>
> **Exception:** If the user explicitly asks for *topic ideas* or *what to make next*, provide a list of 5–8 absurd true story ideas (title + one-line premise each) and wait for them to pick one before writing the script.

## 1. Workflow Inside `index.html`

1. **Ask once if missing (or proceed directly with defaults if only a topic is given):** Ask in ONE short message only if the topic is missing; otherwise use these defaults unless the user specifies otherwise:
   - **Language (DEFAULT: English):** Write the script, voiceover, on-screen text, and captions in **English** by default (only switch if the user explicitly requests another language).
   - **Voiceover mode:** **with voiceover** (Google AI Studio TTS + SFX) by default, or **visual-only** if requested.
   - **Optimal Length (DEFAULT: 45–55 seconds):** Target **45–55 seconds** as the optimal duration (max **60 s**). Structure longer videos cleanly using reusable helper functions per scene and ensure `DURATION` matches the full audio.
2. **Stage A — Script for Google AI Studio TTS (when voiceover is requested):**
   - Write a tight spoken script in **English** (by default) sized for **45–55 seconds** (~115–160 words at ~2.5–3 words/second), following the **Scriptwriting Method** below.
   - If the user provides their own script/text, keep it as-is without rewriting or stripping facts (only flag if a fact looks false).
   - Tell the user: generate the audio in **Google AI Studio TTS**, drag it into Step 1 of `index.html`, click **Extreure Timestamps (Whisper AI)** -> **Copiar timestamps.json**, and paste that JSON back here.
3. **Stage B — Animation (`short.html`) + Sound Cues (`sfx.json`):**
   - When the user pastes the timestamps JSON (or immediately if visual-only), plan **12–18+ beats** (2.5–4 s each for a 45–55 s short, or scaled to match the audio) synced strictly to the spoken word/segment timestamps. Set `DURATION` to cover the full audio (+~0.4 s tail).
   - Deliver **two complete artifacts**:
     1) **`short.html`** — complete standalone `<canvas id="c" width="1080" height="1920" data-duration="SECONDS">` animation exposing `window.__SHORT_DURATION = DURATION;` so `index.html` detects the exact video duration automatically.
     2) **`sfx.json`** — sound-effect cue list synced to the exact second of every entry, impact, and transition.
   - Tell the user: drag or paste `short.html` and `sfx.json` into Step 2 of `index.html` -> click **Preview (Vídeo + Àudio)** to check sync -> click **Exportar MP4 Final** to download `final_short.mp4`.

---

## Scriptwriting Method (Visual-First Storytelling)

Nobody opens Shorts/Reels to study—they open it to be surprised. A video gets watched to the end if every sentence teaches something unexpected, and shared if by the end the viewer understands something they didn't before. Every sentence is written **already picturing what happens on screen**:

1. **The 5 Story Ingredients (Verify Facts First):**
   - **One central sentence:** Define what the video is about in one line; cut anything that doesn't serve it.
   - **The surprise:** What clashes with common intuition or seems impossible.
   - **The broken belief:** What anyone would normally assume, and why that assumption makes sense.
   - **The causal chain:** Step-by-step mechanism, each cause leading to its effect in order.
   - **Tangible numbers & 2–3 household comparisons:** Concrete scales (*"the size of a lentil"*, *"weighs as much as a car"*, *"like a pressure cooker"*). Never invent or guess facts—if a number is doubtful, drop it.
2. **The Hook (Pass All 5 Tests & Avoid the Blacklist):**
   - **5 Tests:** (1) Names the real subject immediately (never *"this"* or *"this machine"*); (2) Starts at frame 0 in its most dramatic, moving moment; (3) Opens a curiosity question without answering it yet; (4) Understood on the first listen in everyday words; (5) Relates to something the viewer knows or addresses *"you / your"*.
   - **NEVER in the hook:** Dates, places, or *"X years ago"* upfront; *"according to experts"* / *"a study revealed"*; news-anchor tone; announcing instead of intriguing (*"In this video..."*, *"Let me tell you..."*, *"Watch this"*); talking about the creator; *"one of the most..."*.
   - Pick the strongest hook and use it directly — do not offer alternatives or ask the user to choose.
3. **The Body & Payoff (Every Sentence Must Be Visualizable):**
   - **Spoken rhythm:** Short sentences linked with *"so"*, *"that's why"*, *"but"*—clear enough for a 10-year-old. Always use the **exact same name** for each thing throughout the video.
   - **Curiosity thread:** Each sentence answers the gap left by the previous one and opens the next; save the full answer for the end.
   - **Every sentence shows action:** Something drops, breaks, grows, fills, or compares to an everyday object. If you can't picture it happening on screen, rewrite or cut it.
   - **Mid-video "wait, what?!" moment:** Place a second mini-twist halfway through (~20–30 s), right when viewers usually swipe away.
   - **Full-circle twist ending:** Completely answers the hook's question, flips what the viewer assumed, and loops naturally back to the opening image.
   - **1 key word per sentence:** Choose 1 highlight word per sentence for the blue caption pill; reading just the highlighted words in sequence should summarize the story.
4. **Read-Aloud Quality Check Before Delivering:**
   - *"At which sentence would a hurried viewer swipe away?"* -> Add visual action there.
   - *"Does any part sound like a textbook or news broadcast?"* -> Make it shorter and conversational.
   - *"Is it 115–160 words (45–55 s)?"* -> Trim filler so every second earns its place.

---

## 2. Engineering an Explosive Hook (0.00 – 0.65 s) — CRITICAL

Scroll retention is decided in the first **0.5 seconds**. **Never start Beat 1 with the main subject sitting statically in the center of the frame.** Build every opening hook with these four layers firing together:

1. **Fast Physical Entry (`0.02 – 0.55 s`):** Start the hero subject completely off-screen (or plunging from extreme foreground/close-up) and rocket it into place with fast deceleration (`easeOut3`). Add momentum cues: diagonal speed streaks, trailing smoke/dust, water spray, or flying birds.
   - *Example:* In a naval scene, the ship blasts in from `x = -1080` to `0` over `0.53 s`, kicking up giant bow foam and pitching dynamically (`-3.2° -> +1.4° -> 0°`) as it brakes.
2. **Aggressive Camera Hook:** Pair the subject's entry with a **whip-pan or crash-zoom** (e.g., camera starts tightly framed at `scale 1.40–1.50` tracking the incoming trajectory, then whips smoothly back to `1.04` as the subject locks into center). Always paint backgrounds/seas across wide overscan bounds (`-260..1340`, `-260..2200`) so rapid camera sweeps and shakes never expose empty borders.
3. **Impact Lock & Micro-Shake (`~0.42 – 0.78 s`):** Trigger a short decaying camera shake (`±10–14 px`) when the hero locks into place, synced with a `whoosh` (`0.02 s`) followed by a punchy `boom` / `horn` / `pop` (`~0.45 s`) in `sfx.json`.
4. **Instant Hook Caption (`<= 0.12 s`):** Pop the opening words onto screen within the first 0.15 s so motion, text, and audio hit together.

---

## 3. Visual Style: Flat Illustrated Cartoon (Initial Reference Standard)

Match the clean, cinematic **Flat Illustrated Cartoon** style established by the initial reference (`agents/illustration.html` — *"Paris, 1925: a con man sells the Eiffel Tower"*), translated into crisp HTML5 `<canvas>` rendering so `index.html` captures every frame:

- **Color, Light & Atmosphere:** Multi-stop sky and interior gradients (e.g. twilight `#191642 -> #5d2d6b -> #c4526e -> #f28f57 -> #ffd285`; cold night `#030712 -> #0b1a36 -> #183862`; warm salon `#1d4a4c -> #2a6260`), radial sun/sconce/flare glows, diagonal light beams, soft haze bands, edge vignette (`rgba(4,8,18,0.52)`), and brief impact flashes (`0.2–0.45` alpha).
- **3-Plane Depth & Parallax:** Always layer **Background** (twinkling stars, sun/moon, clouds, far silhouettes scrolling slowly), **Midground Hero** (main subject large—at least 40% of frame width—centered in `y: 550..1350`), and **Dark Foreground Silhouettes** (scrolling faster in front: piers, spectators, waves, lifeboats, rooftops, curtains, or table edges).
- **Cartoon Characters & Props:** Draw all props in code with crisp vector primitives (`roundRect`, `quadraticCurveTo`, `arc`). **Every human character** (protagonists, guards, background crowds) MUST follow the exact **Human Character Anatomical & Technical Standard** below (`drawHumanCharacter`, `drawArticulatedLegs`, `drawArticulatedArm`) with reactive expressions and continuous idle life (breathing, bobbing, blinking).
- **Continuous Camera & Impact Per Beat:** Never leave the camera still—use slow drift/push-in during holds and whip-zooms into transitions. Every beat needs one unmistakable impact (scale punch, camera shake, stamp slam, shatter, or flash).
- **Captions & Safe Area (Estilo Casa — CRITICAL RULES):**
  - **Ubicación fija:** Mantén todos los subtítulos centrados en la zona segura superior `x: 140..940`, `y ≈ 340..420` (centrado en `x = 540`). Nunca tapes la cara de los personajes ni invadas el margen inferior de la UI.
  - **Tipografía y Colores Estilo Casa:** Usa siempre `Figtree` (`700`, `74 px`, interlineado `84 px`). Texto activo en color crema `#f3ead8`, contorno oscuro grueso `#14202b` (`12 px`, `lineJoin: round`) y palabras ya dichas atenuadas a `#8796a3`.
  - **REGLA ESTRICTA 1 — Cero mezcla de frases:** Un bloque de subtítulos jamás debe contener palabras de dos frases distintas. Cuando una frase termina (con punto `.`, `!`, `?` o cambio de frase en el guion), el bloque se cierra inmediatamente. La nueva frase debe empezar obligatoriamente en un bloque nuevo.
  - **REGLA ESTRICTA 2 — Máximo 1 palabra destacada por bloque:** En un mismo bloque de subtítulos **nunca puede haber más de una palabra destacada simultáneamente**. Como máximo una sola palabra clave por bloque llevará la pastilla de fondo azul petróleo (`#2a8fb0`) con texto blanco `#ffffff`. Si dos palabras estuvieran marcadas cerca, solo se resalta la más importante; la otra se dibuja como texto estándar.
  - **Bloques cortos (golpes):** Agrupa en golpes de máximo 2 a 4 palabras (y no más de 22 caracteres).
  - **Posición fija por bloque:** Las posiciones `(x, y)` de cada palabra se calculan de antemano y quedan fijas desde que entra el bloque. Las palabras nunca cambian de sitio ni se mueven cuando saltan las siguientes.
  - **Sincronización:** Cada palabra salta con `0.06 s` de adelanto respecto al audio y un rebote elástico (`rebota(u)`). Se dibujan directamente en el Canvas dentro de `renderAt(t)`.

### Paris 1925 Style Reference (Canvas 2D Pattern)

```js
// Layered sunset + Eiffel silhouette + flat-cartoon character (Paris 1925 style)
function drawBackdropAndTower() {
  const sky = ctx.createLinearGradient(0, -260, 0, 2200);
  sky.addColorStop(0, '#1c1d4f'); sky.addColorStop(0.5, '#b9507a'); sky.addColorStop(1, '#ffd99a');
  ctx.fillStyle = sky; ctx.fillRect(-260, -260, 1600, 2460);
  const sun = ctx.createRadialGradient(800, 1430, 0, 800, 1430, 330);
  sun.addColorStop(0, '#fff3c4'); sun.addColorStop(1, 'rgba(255,176,112,0)');
  ctx.fillStyle = sun; ctx.beginPath(); ctx.arc(800, 1430, 330, 0, Math.PI * 2); ctx.fill();
  ctx.fillStyle = '#2a1740';
  ctx.beginPath(); ctx.moveTo(480, 1472); ctx.quadraticCurveTo(540, 1258, 600, 1472); ctx.fill();
  ctx.fillStyle = '#1a0d24'; ctx.fillRect(-260, 1680, 1600, 520);
}
```

### Human Character Anatomical & Technical Standard (MANDATORY FOR ALL HUMANS)

1. **Golden Rule of Anatomical Integrity:** Every human (protagonists, side characters, guards, background crowds) MUST have a complete, connected 2D rig body:
   - **STRICTLY FORBIDDEN:** Floating busts or waist-cut characters; hiding legs/arms behind edges to skip drawing them; Rayman-style floating hands disconnected from sleeves; circle-only feet without boot/shoe shape.
   - **Required Rig:** 2 articulated legs (`hip -> knee -> ankle`), 2 boot/shoe feet with soles facing the character's direction, 1 trapezoidal torso with rounded shoulders + connected neck, 2 articulated arms (`shoulder -> elbow -> wrist`), 2 hands with elliptical palm + thumb aligned to forearm angle, and 1 round head with ear, crescent face shadow, and expressive face.
2. **Coordinate System & Canonical Proportions:** Local origin `(0, 0)` is always the pelvis/hip center, transformed via `ctx.translate(x, y); ctx.scale(s * facing, s);` (`s = 1.0` ≈ `280 px` tall; `facing`: `1` = right, `-1` = left).
   - **Vertical Height Map (local Y relative to hip `Y = 0`):** Hat/hair crown `Y = -210..-185` | Head center `(0, -152)` (`r = 38`) | Neck `Y = -124..-102` (`w = 24`) | Shoulders `Y = -110` (back `X = +28`, front `X = -32`) | Torso `Y = -110..+18` (or `+75` for long coat/robe) | Hips `Y = +5` (`X = -22, +22`) | Knees `Y = +52` | Ankles `Y = +100` (`legLen = 95`) | Shoe soles / ground `Y = +114`.
3. **Strict Painter's Layer Order (Back-to-Front):**
   - **Layer 1:** Ground contact shadow (dark semi-transparent ellipse at `Y = legLen + 14`).
   - **Layer 2:** Full back arm (`shoulder -> elbow -> wrist -> hand with thumb`).
   - **Layer 3:** Articulated legs (back leg + front leg) with both boots/shoes.
   - **Layer 4:** Torso, coat/clothing, left-side `rgba(0,0,0,0.12)` shading band, lapels/buttons/belt.
   - **Layer 5:** Neck and shirt collar.
   - **Layer 6:** Head base, crescent facial shadow (`rgba(180, 95, 50, 0.22)`), ear, eyes (tracking `lookX, lookY`), eyebrows, nose, mouth/mustache, hat.
   - **Layer 7:** Held object (if any) + Full front arm (`shoulder -> elbow -> wrist -> hand with thumb`) in front of torso.
4. **Double-Pass Round Stroke & Limb Construction:**
   - Always set `ctx.lineCap = 'round'; ctx.lineJoin = 'round';` and draw 3-point kinematic paths (`moveTo -> lineTo -> lineTo`).
   - **Pass 1 (Outer `#140e0a` outline):** `lineWidth = fillWidth + 10` (`32` for legs, `thickness + 10` for arms).
   - **Pass 2 (Inner sleeve/pant fill):** `lineWidth = fillWidth` (`22` for legs, `24` default for arms).
   - **Legs (`walkPhase`):** Idle = `0.25`; walking = `t * speed`. `stride1 = Math.sin(walkPhase) * 24`, `stride2 = -stride1`; `lift1 = Math.max(0, -Math.cos(walkPhase)) * 12`, `lift2 = Math.max(0, Math.cos(walkPhase)) * 12`. Knee bends forward (`kx = hipX + stride * 0.55 + 4`, `ky = 5 + legLen * 0.50 - lift * 0.4`); ankle at `(hipX + stride, 5 + legLen - lift)`. Boot rotates by `stride * 0.006` with heel `X = -16`, toe `X = +32`, flat sole `Y = +14`, `#140e0a` `5 px` border + inner sole line `(-15, 11) -> (31, 11)`.
   - **Arms & Hands:** Forearm angle `angle = Math.atan2(wy - ey, wx - ex)` rotates the wrist cuff (`-6, -thickness * 0.48`, `w = 10`) and hand (`(10, 0)` ellipse `r = (13, 10)`, `4.5 px` stroke + thumb at `(6, -9)`, `r = 5.5`, `4 px` stroke).

#### Mandatory Base Human Character Code (USE VERBATIM — DO NOT ALTER)

```js
// --- 1. FUNCION UNIVERSAL PARA BRAZO Y MANO ARTICULADOS ---
function drawArticulatedArm(sx, sy, ex, ey, wx, wy, sleeveCol, skinCol, thickness = 24) {
  ctx.save();
  ctx.lineCap = 'round';
  ctx.lineJoin = 'round';

  // Pasada 1: Contorno exterior oscuro del brazo
  ctx.strokeStyle = '#140e0a';
  ctx.lineWidth = thickness + 10;
  ctx.beginPath();
  ctx.moveTo(sx, sy);
  ctx.lineTo(ex, ey);
  ctx.lineTo(wx, wy);
  ctx.stroke();

  // Pasada 2: Relleno interior de la manga
  ctx.strokeStyle = sleeveCol;
  ctx.lineWidth = thickness;
  ctx.beginPath();
  ctx.moveTo(sx, sy);
  ctx.lineTo(ex, ey);
  ctx.lineTo(wx, wy);
  ctx.stroke();

  // Orientacion del antebrazo para alinear puno y mano
  const angle = Math.atan2(wy - ey, wx - ex);
  ctx.translate(wx, wy);
  ctx.rotate(angle);

  // Puno de la manga en la muneca
  roundRect(-6, -thickness * 0.48, 10, thickness * 0.96, 4);
  ctx.fillStyle = sleeveCol;
  ctx.fill();
  ctx.lineWidth = 4;
  ctx.strokeStyle = '#140e0a';
  ctx.stroke();

  // Palma de la mano
  ctx.beginPath();
  ctx.ellipse(10, 0, 13, 10, 0, 0, Math.PI * 2);
  ctx.fillStyle = skinCol;
  ctx.fill();
  ctx.lineWidth = 4.5;
  ctx.strokeStyle = '#140e0a';
  ctx.stroke();

  // Dedo pulgar
  ctx.beginPath();
  ctx.arc(6, -9, 5.5, 0, Math.PI * 2);
  ctx.fillStyle = skinCol;
  ctx.fill();
  ctx.lineWidth = 4;
  ctx.strokeStyle = '#140e0a';
  ctx.stroke();

  ctx.restore();
}

// --- 2. FUNCION UNIVERSAL PARA PIERNAS Y BOTAS ARTICULADAS ---
function drawArticulatedLegs(walkPhase, pantCol = '#2a3342', shoeCol = '#1d1612', legLen = 95) {
  const stride1 = Math.sin(walkPhase) * 24;
  const stride2 = -stride1;
  const lift1 = Math.max(0, -Math.cos(walkPhase)) * 12;
  const lift2 = Math.max(0, Math.cos(walkPhase)) * 12;

  const legs = [
    { hipX: -22, stride: stride1, lift: lift1 },
    { hipX: 22,  stride: stride2, lift: lift2 }
  ];

  for (let i = 0; i < legs.length; i++) {
    const L = legs[i];
    const kx = L.hipX + L.stride * 0.55 + 4;
    const ky = 5 + legLen * 0.50 - L.lift * 0.4;
    const ax = L.hipX + L.stride;
    const ay = 5 + legLen - L.lift;

    ctx.save();
    ctx.lineCap = 'round';
    ctx.lineJoin = 'round';

    // Pasada 1: Contorno exterior oscuro de la pierna
    ctx.strokeStyle = '#140e0a';
    ctx.lineWidth = 32;
    ctx.beginPath();
    ctx.moveTo(L.hipX, 5);
    ctx.lineTo(kx, ky);
    ctx.lineTo(ax, ay);
    ctx.stroke();

    // Pasada 2: Relleno del pantalon
    ctx.strokeStyle = pantCol;
    ctx.lineWidth = 22;
    ctx.beginPath();
    ctx.moveTo(L.hipX, 5);
    ctx.lineTo(kx, ky);
    ctx.lineTo(ax, ay);
    ctx.stroke();

    // Bota / Zapato anclado al tobillo
    ctx.translate(ax, ay);
    ctx.rotate(L.stride * 0.006);
    ctx.beginPath();
    ctx.moveTo(-14, -4);
    ctx.lineTo(18, -4);
    ctx.quadraticCurveTo(32, -4, 32, 10);
    ctx.lineTo(32, 14);
    ctx.lineTo(-16, 14);
    ctx.closePath();
    ctx.fillStyle = shoeCol;
    ctx.fill();
    ctx.lineWidth = 5;
    ctx.strokeStyle = '#140e0a';
    ctx.stroke();

    // Linea de la suela
    ctx.beginPath();
    ctx.moveTo(-15, 11);
    ctx.lineTo(31, 11);
    ctx.strokeStyle = '#140e0a';
    ctx.lineWidth = 3;
    ctx.stroke();

    ctx.restore();
  }
}

// --- 3. FUNCION UNIVERSAL DE PERSONAJE HUMANO COMPLETO ---
function drawHumanCharacter(x, y, s, opts = {}) {
  const facing = opts.facing || 1;
  const coatCol = opts.coatCol || '#3a526b';
  const pantCol = opts.pantCol || '#253342';
  const skinCol = opts.skinCol || '#f7c49c';
  const hatType = opts.hatType || 'bowler'; // 'bowler' | 'kepi' | 'cap' | 'lady' | 'none'
  const hatCol = opts.hatCol || '#231b14';
  const walkPhase = opts.walkPhase !== undefined ? opts.walkPhase : 0.25;
  const expr = opts.expr || 'normal'; // 'normal' | 'shock' | 'panic' | 'smug'
  const lookX = opts.lookX || 0;
  const lookY = opts.lookY || 0;
  const legLen = opts.legLen || 95;

  ctx.save();
  ctx.translate(x, y);
  ctx.scale(s * facing, s);

  const swing = Math.sin(walkPhase) * 16;

  // Coordenadas por defecto de brazos (personalizables via opts.backArm y opts.frontArm)
  const bArm = opts.backArm || {
    sx: 28, sy: -92,
    ex: 38 - swing * 0.5, ey: -42,
    wx: 48 - swing, wy: 4
  };
  const fArm = opts.frontArm || {
    sx: -32, sy: -92,
    ex: -42 + swing * 0.5, ey: -40,
    wx: -30 + swing, wy: 8
  };

  // CAPA 1: Sombra en el suelo
  ctx.fillStyle = 'rgba(15, 10, 6, 0.24)';
  ctx.beginPath();
  ctx.ellipse(0, legLen + 14, 58, 13, 0, 0, Math.PI * 2);
  ctx.fill();

  // CAPA 2: Brazo trasero
  drawArticulatedArm(bArm.sx, bArm.sy, bArm.ex, bArm.ey, bArm.wx, bArm.wy, coatCol, skinCol, 22);

  // CAPA 3: Piernas y zapatos
  drawArticulatedLegs(walkPhase, pantCol, '#1d1612', legLen);

  // CAPA 4: Torso / Ropa
  ctx.beginPath();
  ctx.moveTo(-48, -110);
  ctx.lineTo(48, -110);
  ctx.quadraticCurveTo(58, -45, 54, 18);
  ctx.lineTo(-54, 18);
  ctx.quadraticCurveTo(-58, -45, -48, -110);
  ctx.closePath();
  ctx.fillStyle = coatCol;
  ctx.fill();

  // Sombra lateral del torso para dar volumen
  ctx.fillStyle = 'rgba(0,0,0,0.12)';
  ctx.beginPath();
  ctx.moveTo(-48, -110);
  ctx.lineTo(-18, -110);
  ctx.lineTo(-22, 18);
  ctx.lineTo(-54, 18);
  ctx.closePath();
  ctx.fill();

  // Contorno del torso
  ctx.lineWidth = 5;
  ctx.strokeStyle = '#140e0a';
  ctx.beginPath();
  ctx.moveTo(-48, -110);
  ctx.lineTo(48, -110);
  ctx.quadraticCurveTo(58, -45, 54, 18);
  ctx.lineTo(-54, 18);
  ctx.quadraticCurveTo(-58, -45, -48, -110);
  ctx.closePath();
  ctx.stroke();

  // CAPA 5: Cuello
  roundRect(-12, -124, 24, 22, 6);
  ctx.fillStyle = skinCol;
  ctx.fill();
  ctx.stroke();

  // CAPA 6: Cabeza y Rostro
  ctx.beginPath();
  ctx.arc(0, -152, 38, 0, Math.PI * 2);
  ctx.fillStyle = skinCol;
  ctx.fill();
  ctx.lineWidth = 5;
  ctx.strokeStyle = '#140e0a';
  ctx.stroke();

  // Sombra facial en media luna
  ctx.fillStyle = 'rgba(180, 95, 50, 0.22)';
  ctx.beginPath();
  ctx.arc(0, -152, 35, Math.PI * 0.55, Math.PI * 1.35);
  ctx.arc(8, -152, 32, Math.PI * 1.35, Math.PI * 0.55, true);
  ctx.closePath();
  ctx.fill();

  // Oreja
  ctx.beginPath();
  ctx.ellipse(-38, -150, 9, 13, 0, 0, Math.PI * 2);
  ctx.fillStyle = skinCol;
  ctx.fill();
  ctx.lineWidth = 5;
  ctx.strokeStyle = '#140e0a';
  ctx.stroke();

  // Ojos
  const eyePositions = [-2, 22];
  for (let i = 0; i < eyePositions.length; i++) {
    const ex = eyePositions[i];
    ctx.beginPath();
    ctx.ellipse(ex, -158, 8, expr === 'shock' || expr === 'panic' ? 12 : 9.5, 0, 0, Math.PI * 2);
    ctx.fillStyle = '#ffffff';
    ctx.fill();
    ctx.lineWidth = 3.5;
    ctx.strokeStyle = '#140e0a';
    ctx.stroke();

    ctx.beginPath();
    ctx.arc(ex + 2 + lookX * 3, -158 + lookY * 3, 4, 0, Math.PI * 2);
    ctx.fillStyle = '#140e0a';
    ctx.fill();

    ctx.beginPath();
    ctx.arc(ex + 3.5 + lookX * 3, -160 + lookY * 3, 1.5, 0, Math.PI * 2);
    ctx.fillStyle = '#ffffff';
    ctx.fill();
  }

  // Cejas
  ctx.strokeStyle = '#231b14';
  ctx.lineWidth = 5.5;
  ctx.lineCap = 'round';
  const browLift = (expr === 'shock' || expr === 'panic') ? -7 : 0;
  ctx.beginPath();
  ctx.moveTo(-11, -172 + browLift);
  ctx.lineTo(5, -174 + browLift);
  ctx.moveTo(14, -174 + browLift);
  ctx.lineTo(31, -171 + browLift);
  ctx.stroke();

  // Nariz
  ctx.beginPath();
  ctx.moveTo(10, -155);
  ctx.quadraticCurveTo(23, -150, 12, -143);
  ctx.strokeStyle = '#140e0a';
  ctx.lineWidth = 4;
  ctx.stroke();

  // Boca
  ctx.beginPath();
  if (expr === 'shock' || expr === 'panic') {
    ctx.ellipse(12, -132, 7, 9, 0, 0, Math.PI * 2);
    ctx.fillStyle = '#7a1c1c';
    ctx.fill();
    ctx.lineWidth = 3.5;
    ctx.strokeStyle = '#140e0a';
    ctx.stroke();
  } else {
    ctx.arc(10, -134, 8, 0.15, Math.PI - 0.3);
    ctx.lineWidth = 3.5;
    ctx.strokeStyle = '#140e0a';
    ctx.stroke();
  }

  // Sombrero (segun hatType)
  if (hatType === 'bowler') {
    ctx.fillStyle = hatCol;
    ctx.beginPath();
    ctx.arc(0, -180, 36, Math.PI, 0);
    ctx.closePath();
    ctx.fill();
    ctx.stroke();
    roundRect(-48, -184, 96, 10, 5);
    ctx.fillStyle = hatCol;
    ctx.fill();
    ctx.stroke();
  } else if (hatType === 'cap') {
    ctx.fillStyle = hatCol;
    ctx.beginPath();
    ctx.moveTo(-36, -176);
    ctx.quadraticCurveTo(-5, -206, 36, -182);
    ctx.lineTo(50, -175);
    ctx.lineTo(-36, -174);
    ctx.closePath();
    ctx.fill();
    ctx.stroke();
  }

  // CAPA 7: Brazo delantero (siempre delante del torso)
  drawArticulatedArm(fArm.sx, fArm.sy, fArm.ex, fArm.ey, fArm.wx, fArm.wy, coatCol, skinCol, 22);

  ctx.restore();
}
```

---

## 4. Technical Rules & Canvas Skeleton for `short.html`

1. **Auto-Detectable Duration Metadata (REQUIRED):** Always set **all three** duration markers to the exact length in seconds so `index.html` reads it automatically without user input:
   - `<canvas id="c" width="1080" height="1920" data-duration="50"></canvas>`
   - `const DURATION = 50;`
   - `window.__SHORT_DURATION = DURATION;`
2. **Pure Deterministic `renderAt(t)`:** Because `index.html` steps a virtual clock frame-by-frame, every frame at time `t` must depend **only on `t`**. Precompute random arrays once via seeded `rng(seed)`—never call `Math.random()` inside `renderAt(t)`, never use CSS transitions/animations, and never use external images.
3. **True Offscreen Crossfade (`bufCanvas`):** Keep a hidden `1080×1920` canvas `bufCanvas`. During `0.30 s` scene overlaps, switch `ctx` to `bufCtx`, render the incoming scene, restore `ctx`, and composite `bufCanvas` with `globalAlpha` so internal `globalAlpha = 1` resets don't break transitions.
4. **Complete Code Only:** Always output the entire standalone HTML from `<!doctype html>` to `</html>` with zero placeholders (`...`).

```html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=1080, height=1920" />
<title>Short Title</title>
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@500;700;800&display=block" rel="stylesheet">
<style>
html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden;background:#050a18;display:flex;align-items:center;justify-content:center}
canvas{display:block;width:100%;height:100%;max-width:100vw;max-height:100vh;object-fit:contain;background:#050a18}
</style>
</head>
<body>
<canvas id="c" width="1080" height="1920" data-duration="50"></canvas>
<script>
(function(){
const DURATION = 50;
window.__SHORT_DURATION = DURATION;
const canvas = document.getElementById('c');
let ctx = canvas.getContext('2d');
const bufCanvas = document.createElement('canvas');
bufCanvas.width = 1080; bufCanvas.height = 1920;
const bufCtx = bufCanvas.getContext('2d');
if (!CanvasRenderingContext2D.prototype.roundRect) {
  CanvasRenderingContext2D.prototype.roundRect = function(x,y,w,h,r){
    const rr=Math.min(typeof r==='number'?r:(r&&r[0]||0), Math.abs(w)/2, Math.abs(h)/2);
    this.moveTo(x+rr,y); this.arcTo(x+w,y,x+w,y+h,rr); this.arcTo(x+w,y+h,x,y+h,rr);
    this.arcTo(x,y+h,x,y,rr); this.arcTo(x,y,x+w,y,rr); this.closePath();
  };
}
function roundRect(x,y,w,h,r){ctx.beginPath();ctx.roundRect(x,y,w,h,r);}
if (document.fonts && document.fonts.load) {
  document.fonts.load('700 74px "Figtree"').catch(()=>{});
}
function rng(a){return function(){a|=0;a=a+0x6D2B79F5|0;let t=Math.imul(a^a>>>15,1|a);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;}}

// --- SUBTÍTULOS ESTILO CASA (FÁBRICA DE PORQUÉS) ---
const SUB_CASA = {
  tam: 74,
  font: "700 74px 'Figtree', sans-serif",
  color: "#f3ead8",
  dicho: "#8796a3",
  contorno: "#14202b",
  grosorContorno: 12,
  colorPastilla: "#2a8fb0"
};
const ZONA_SUB = { izquierda: 140, ancho: 800, y: 360 };
const ADELANTO = 0.06;

function rebota(u) { return 1 + 2.8 * Math.pow(u - 1, 3) + 1.8 * Math.pow(u - 1, 2); }
function rango(t, a, b) { return Math.max(0, Math.min(1, (t - a) / (b - a))); }

// Prepara bloques: Cero mezcla de frases y MÁXIMO 1 palabra resaltada por bloque
function prepararSubtitulos(words, duracionTotal) {
  const golpes = [];
  let actual = [];
  let letras = 0;
  let tieneResaltada = false;

  for (let i = 0; i < words.length; i++) {
    const item = words[i];
    const dice = (item.w || item.dice || '').trim();
    if (!dice) continue;

    // Regla 1: Cortar inmediatamente si la palabra anterior cerró frase con puntuación (. ! ?)
    const anteriorCorta = actual.length > 0 && /[.!?…]$/.test(actual[actual.length - 1].dice);
    const limiteCaracteres = (letras + dice.length) > 22;
    const limitePalabras = actual.length >= 4;

    if (anteriorCorta || limitePalabras || limiteCaracteres) {
      if (actual.length) golpes.push({ palabras: actual });
      actual = [];
      letras = 0;
      tieneResaltada = false;
    }

    // Regla 2: Máximo una palabra destacada (pastilla azul) por bloque
    let resaltaEsta = !!(item.resalta || item.highlight || item.resaltada);
    if (resaltaEsta) {
      if (tieneResaltada) {
        resaltaEsta = false; // Ya hay una en este bloque: esta se dibuja normal
      } else {
        tieneResaltada = true;
      }
    }

    actual.push({ dice, desde: item.s ?? item.desde, hasta: item.e ?? item.hasta, resalta: resaltaEsta });
    letras += dice.length + 1;
  }
  if (actual.length) golpes.push({ palabras: actual });

  golpes.forEach((g, i) => {
    g.desde = Math.max(0, g.palabras[0].desde - ADELANTO);
    const sig = golpes[i + 1];
    g.hasta = sig ? Math.min(sig.palabras[0].desde - ADELANTO, g.palabras[g.palabras.length - 1].hasta + 0.65) : duracionTotal;
  });
  return golpes;
}

function colocarGolpe(ctx, g) {
  if (g.sitios) return g.sitios;
  ctx.font = SUB_CASA.font;
  const anchos = g.palabras.map(w => ctx.measureText(w.dice).width);
  const hueco = SUB_CASA.tam * 0.28;
  const total = anchos.reduce((acc, w, i) => acc + w + (i ? hueco : 0), 0);
  let x = ZONA_SUB.izquierda + (ZONA_SUB.ancho - total) / 2;
  g.sitios = g.palabras.map((w, i) => {
    const pos = { x, w: anchos[i], y: ZONA_SUB.y };
    x += anchos[i] + hueco;
    return pos;
  });
  return g.sitios;
}

function dibujarSubtitulos(ctx, t, listaGolpes) {
  const g = listaGolpes.find(x => t >= x.desde && t < x.hasta);
  if (!g) return;
  const sitios = colocarGolpe(ctx, g);

  ctx.save();
  ctx.setTransform(1, 0, 0, 1, 0, 0);
  ctx.textBaseline = "middle";
  ctx.lineJoin = "round";

  g.palabras.forEach((w, i) => {
    const sale = w.desde - ADELANTO;
    const u = rango(t, sale, sale + 0.14);
    if (u <= 0) return;

    const s = sitios[i];
    const sig = g.palabras[i + 1];
    const dicha = !w.resalta && sig && t >= sig.desde - ADELANTO;
    const k = 0.74 + 0.26 * rebota(u);

    // Pastilla redondeada estilo Casa (solo 1 palabra por bloque)
    if (w.resalta) {
      const uMarca = rango(t, sale + 0.03, sale + 0.22);
      const kP = 0.7 + 0.3 * rebota(uMarca);
      const pad = SUB_CASA.tam * 0.22, alto = SUB_CASA.tam * 1.1;
      ctx.save();
      ctx.translate(s.x + s.w / 2, s.y);
      ctx.scale(kP, kP);
      ctx.globalAlpha = Math.min(1, uMarca * 2);
      ctx.fillStyle = SUB_CASA.colorPastilla;
      ctx.beginPath();
      ctx.roundRect(-s.w / 2 - pad, -alto / 2, s.w + pad * 2, alto, alto / 2);
      ctx.fill();
      ctx.restore();
    }

    // Dibujar el texto
    ctx.save();
    ctx.translate(s.x + s.w / 2, s.y + (1 - u) * 16);
    ctx.scale(k, k);
    ctx.globalAlpha = Math.min(1, u * 1.6);
    ctx.font = SUB_CASA.font;

    if (!w.resalta && SUB_CASA.contorno) {
      ctx.strokeStyle = SUB_CASA.contorno;
      ctx.lineWidth = SUB_CASA.grosorContorno;
      ctx.strokeText(w.dice, -s.w / 2, 0);
    }
    ctx.fillStyle = w.resalta ? "#ffffff" : (dicha ? SUB_CASA.dicho : SUB_CASA.color);
    ctx.fillText(w.dice, -s.w / 2, 0);
    ctx.restore();
  });
  ctx.restore();
}

// Ejemplo de inicialización: const listaGolpes = prepararSubtitulos(WORDS_DATA, DURATION);
function renderAt(t){
  t = Math.max(0, Math.min(DURATION, t));
  const cw = canvas.width || 1080, ch = canvas.height || 1920;
  ctx.setTransform(cw/1080, 0, 0, ch/1920, 0, 0);
  ctx.clearRect(0, 0, 1080, 1920);
  const drawFade = (fn, alpha) => {
    if (alpha <= 0.001) return;
    if (alpha >= 0.999) { fn(t); return; }
    const mainCtx = ctx; ctx = bufCtx;
    ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, 1080, 1920);
    fn(t); ctx = mainCtx;
    ctx.save(); ctx.globalAlpha = alpha; ctx.drawImage(bufCanvas, 0, 0); ctx.restore();
  };
  /* Call scene functions via renderScene1(t) / drawFade(renderSceneN, alpha), draw vignette, flashes */
  /* Draw Casa-style subtitles on top: */
  dibujarSubtitulos(ctx, t, listaGolpes);
}
window.renderAt = renderAt;
window.addEventListener('hf-seek', e => { window.__hfControlled = true; renderAt(e.detail.time); });
renderAt(0);
let t0 = null;
function tick(now){
  const ts = (typeof now === 'number' && !Number.isNaN(now)) ? now : performance.now();
  if(t0 === null) t0 = ts;
  const elapsed = (ts - t0)/1000;
  const t = elapsed <= DURATION ? elapsed : (elapsed <= DURATION + 0.05 ? DURATION : elapsed % DURATION);
  if(!window.__hfControlled) renderAt(t);
  requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
})();
</script>
</body>
</html>
```

---

## 5. Sound Design (`sfx.json`)

Always deliver a matching `sfx.json` alongside `short.html`. Built-in procedural `kind` effects synthesized directly by `index.html`:
- **Motion & Impacts:** `whoosh`, `boom`, `impact_ice`, `pop`, `tick`, `glitch`
- **Atmosphere & Props:** `ocean`, `thunder`, `steam`, `horn`, `bell`, `chime`, `bubbles`

```json
{
  "duration": 50.0,
  "voice_gain": 1.0,
  "sfx_gain": 0.9,
  "events": [
    {"kind": "whoosh", "start": 0.02, "duration": 0.65, "gain": 0.85},
    {"kind": "boom", "start": 0.45, "duration": 1.1, "gain": 0.70}
  ]
}
```