Lava lamp v1 · Claude Code25.11.2026 11:59

Source Inkling 2 Mini, Medium effort

index.html · 21.3 KB · 703 lines. Exactly as the agent wrote it.

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="theme-color" content="#120d18"><title>Lava Lamp</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='34' y='10' width='32' height='12' rx='6' fill='%23c0934c'/%3E%3Ccircle cx='50' cy='58' r='26' fill='%23ff8a38'/%3E%3C/svg%3E"><style>  :root {    --bar-bg: #17111f;    --text: #e8ddd0;    --amber: #ffb04a;  }  * { box-sizing: border-box; margin: 0; padding: 0; }  html, body { height: 100%; }  body {    background: #120d18;    color: var(--text);    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;    display: flex;    justify-content: center;    overflow: hidden;    -webkit-tap-highlight-color: transparent;    user-select: none;  }  .app {    width: 100%;    max-width: 480px;    height: 100vh;    height: 100dvh;    display: flex;    flex-direction: column;    border-left: 1px solid #ffffff10;    border-right: 1px solid #ffffff10;  }  .stage {    flex: 1;    position: relative;    min-height: 0;  }  canvas {    position: absolute;    inset: 0;    width: 100%;    height: 100%;    display: block;  }  .bar {    display: flex;    align-items: center;    justify-content: center;    gap: 14px;    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));    background: var(--bar-bg);    border-top: 1px solid #ffffff12;  }  .status {    font-size: 11px;    font-weight: 700;    letter-spacing: 0.22em;    opacity: 0.75;    min-width: 46px;    text-align: center;    transition: color 0.3s, opacity 0.3s, text-shadow 0.3s;  }  .status.on {    color: var(--amber);    opacity: 1;    text-shadow: 0 0 12px #ff9a3c88;  }  .switch {    position: relative;    width: 74px;    height: 40px;    display: inline-block;    touch-action: manipulation;    cursor: pointer;  }  .switch input {    position: absolute;    opacity: 0;    width: 100%;    height: 100%;    margin: 0;    cursor: pointer;    z-index: 2;  }  .track {    position: absolute;    inset: 0;    border-radius: 999px;    background: #2a2233;    border: 1px solid #ffffff1a;    box-shadow: inset 0 2px 6px #00000080;    transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;  }  .knob {    position: absolute;    top: 4px;    left: 4px;    width: 32px;    height: 32px;    border-radius: 50%;    background: linear-gradient(160deg, #f4e7d7, #b8a58e);    box-shadow: 0 2px 5px #00000090, inset 0 1px 1px #ffffff90;    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s;  }  .switch input:checked ~ .track {    background: linear-gradient(180deg, #ff8a2e, #e05e12);    border-color: #ffb04a88;    box-shadow: inset 0 2px 4px #7a2d0840, 0 0 18px #ff8a2e55;  }  .switch input:checked ~ .track .knob {    transform: translateX(34px);    background: linear-gradient(160deg, #fff3e2, #ffcf8f);  }  .switch input:focus-visible ~ .track {    outline: 2px solid #ffb04a;    outline-offset: 3px;  }  @media (prefers-reduced-motion: reduce) {    .knob, .track { transition: none; }  }</style></head><body><div class="app">  <div class="stage">    <canvas id="scene"></canvas>  </div>  <div class="bar">    <span class="status" id="status">OFF</span>    <label class="switch" aria-label="Toggle lava lamp">      <input type="checkbox" id="lampSwitch" checked>      <span class="track"><span class="knob"></span></span>    </label>    <span class="status" id="lampWord" style="opacity:.45">LAMP</span>  </div></div><script>'use strict';(() => {  const canvas = document.getElementById('scene');  const ctx = canvas.getContext('2d');  const switchInput = document.getElementById('lampSwitch');  const statusEl = document.getElementById('status');  const TAU = Math.PI * 2;  let W = 0, H = 0, dpr = 1;  let lampOn = true;  let light = 1;           // animated glow level 0..1  let t = 0;               // scene clock (seconds)  let blobs = [];  let geom = null;  const rand = (a, b) => a + Math.random() * (b - a);  const clamp = (v, a, b) => v < a ? a : (v > b ? b : v);  /* ---------- geometry ---------- */  function computeGeom() {    const cx = W / 2;    const deskY = H * 0.74;    const baseTop = deskY - H * 0.035;      // top of metal base    const neckY = H * 0.075;                // top of glass (neck)    const bw = Math.min(W * 0.30, 150);     // half-width of bulb    const nw = bw * 0.34;                   // half-width of neck    const cornerR = W * 0.055;    geom = {      cx, deskY, baseTop, neckY, bw, nw, cornerR,      gh: baseTop - neckY,      splitR: bw * 0.44,      maxR: bw * 0.62,    };    geom.baseR = bw;    geom.minBlobR = bw * 0.16;  }  function halfWidth(y) {    // conservative interior half-width used for wall clamping    const { nw, bw, neckY, gh } = geom;    if (y <= neckY) return nw;    const t0 = clamp((y - neckY) / (gh * 0.20), 0, 1);    const s = t0 * t0 * (3 - 2 * t0);      // smoothstep flare    let r = nw + (bw - nw) * s;    // rounded bottom corners: shrink slightly near the floor    const over = geom.baseTop - y;    if (over < geom.cornerR) r = Math.min(r, Math.max(nw * 0.7, r - (geom.cornerR - over) * 0.5));    return r * 0.94;  }  /* ---------- glass path ---------- */  function glassPath() {    const { cx, neckY, baseTop, bw, nw, gh, cornerR } = geom;    const flareBot = neckY + gh * 0.16;    ctx.beginPath();    ctx.moveTo(cx - nw, neckY);    ctx.bezierCurveTo(cx - nw, neckY + gh * 0.10, cx - bw, neckY + gh * 0.055, cx - bw, flareBot);    ctx.lineTo(cx - bw, baseTop - cornerR);    ctx.quadraticCurveTo(cx - bw, baseTop, cx - bw + cornerR, baseTop);    ctx.lineTo(cx + bw - cornerR, baseTop);    ctx.quadraticCurveTo(cx + bw, baseTop, cx + bw, baseTop - cornerR);    ctx.lineTo(cx + bw, flareBot);    ctx.bezierCurveTo(cx + bw, neckY + gh * 0.055, cx + nw, neckY + gh * 0.10, cx + nw, neckY);    ctx.closePath();  }  /* ---------- colors ---------- */  function lerpColor(a, b, k) {    const ca = [parseInt(a.slice(1, 3), 16), parseInt(a.slice(3, 5), 16), parseInt(a.slice(5, 7), 16)];    const cb = [parseInt(b.slice(1, 3), 16), parseInt(b.slice(3, 5), 16), parseInt(b.slice(5, 7), 16)];    const m = ca.map((v, i) => Math.round(v + (cb[i] - v) * k));    return `rgb(${m[0]},${m[1]},${m[2]})`;  }  function blobGradient(b) {    const temp = b.temp;    const light = lerpColor('#a67a58', '#ffe08a', temp);    const mid = lerpColor('#6e3b2c', '#ff8a38', temp);    const edge = lerpColor('#3f1f1c', '#d8401a', temp);    const g = ctx.createRadialGradient(b.x - b.r * 0.28, b.y - b.r * 0.32, b.r * 0.12, b.x, b.y, b.r * 1.25);    g.addColorStop(0, light);    g.addColorStop(0.45, mid);    g.addColorStop(1, edge);    return g;  }  /* ---------- physics ---------- */  function spawnBlobs() {    blobs = [];    const top = geom.neckY + geom.gh * 0.25;    const bot = geom.baseTop - geom.gh * 0.12;    const n = 7;    for (let i = 0; i < n; i++) {      const y = top + (bot - top) * (i / (n - 1)) + rand(-14, 14);      const r = geom.baseR * rand(0.20, 0.30);      blobs.push({        x: geom.cx + rand(-geom.baseR * 0.45, geom.baseR * 0.45),        y,        vy: rand(-12, 12),        vx: rand(-8, 8),        r,        temp: rand(0.45, 0.95),        phase: rand(0, TAU),        cooldown: rand(0, 2),      });    }  }  function step(dt) {    t += dt;    const target = lampOn ? 1 : 0;    light += (target - light) * Math.min(1, 3.2 * dt);    const { neckY, baseTop } = geom;    for (const b of blobs) {      b.phase += dt * (1.6 + b.temp * 3.0);      b.cooldown = (b.cooldown ?? 0) - dt;      // temperature: warm near the base, cool toward the top      const heatProx = clamp((b.y - neckY) / (baseTop - neckY), 0, 1);      let net;      if (lampOn) {        net = 0.12 + 0.5 * heatProx - (0.28 * (1 - heatProx) + 0.06);      } else {        net = -0.15;      }      b.temp = clamp(b.temp + net * dt, 0, 1);      // buoyancy      const targetVy = -(b.temp - 0.45) * 115;      b.vy += (targetVy - b.vy) * Math.min(1, 4.2 * dt);      // gentle horizontal drift      b.vx += (Math.sin(t * 0.9 + b.phase * 1.7) * 16 - b.vx) * Math.min(1, 1.6 * dt);      b.y += b.vy * dt;      b.x += b.vx * dt;      // wall / floor / ceiling clamp      const hw = halfWidth(b.y) - b.r * 0.9;      const minX = geom.cx - hw, maxX = geom.cx + hw;      if (b.x < minX) { b.x = minX; b.vx = Math.abs(b.vx) * 0.35; }      else if (b.x > maxX) { b.x = maxX; b.vx = -Math.abs(b.vx) * 0.35; }      const topLimit = neckY + 8 + b.r * 0.85;      const botLimit = baseTop - 8 - b.r * 0.8;      if (b.y < topLimit) { b.y = topLimit; if (b.vy < 0) b.vy = 0; }      else if (b.y > botLimit) { b.y = botLimit; if (b.vy > 0) b.vy = 0; }    }    mergePass();    splitPass(dt);    // safety clamp: nothing escapes the glass    for (const b of blobs) {      b.r = Math.min(b.r, geom.maxR);      const topLimit = neckY + 8 + b.r * 0.85;      const botLimit = baseTop - 8 - b.r * 0.8;      if (b.y < topLimit) b.y = topLimit;      if (b.y > botLimit) b.y = botLimit;      const hw = halfWidth(b.y) - b.r * 0.9;      b.x = clamp(b.x, geom.cx - hw, geom.cx + hw);    }  }  function mergePass() {    const n = blobs.length;    const dead = new Set();    for (let i = 0; i < n; i++) {      if (dead.has(i)) continue;      const a = blobs[i];      for (let j = i + 1; j < n; j++) {        if (dead.has(j)) continue;        const b = blobs[j];        const dx = b.x - a.x, dy = b.y - a.y;        const rr = (a.r + b.r) * 0.72;        if (dx * dx + dy * dy < rr * rr) {          const A = a.r * a.r + b.r * b.r;          a.x = (a.x * a.r * a.r + b.x * b.r * b.r) / A;          a.y = (a.y * a.r * a.r + b.y * b.r * b.r) / A;          a.temp = (a.temp * a.r * a.r + b.temp * b.r * b.r) / A;          a.vy = (a.vy * a.r * a.r + b.vy * b.r * b.r) / A;          a.vx = (a.vx * a.r * a.r + b.vx * b.r * b.r) / A;          a.r = Math.sqrt(A);          a.phase = (a.phase + b.phase) * 0.5;          a.cooldown = Math.max(a.cooldown ?? 0, 0.6);          dead.add(j);        }      }    }    if (dead.size) blobs = blobs.filter((_, i) => !dead.has(i));  }  function splitPass(dt) {    if (blobs.length >= 16) return;    for (let i = 0; i < blobs.length; i++) {      const b = blobs[i];      if (b.cooldown <= 0 && b.temp > 0.55 && b.r > geom.splitR) {        const childR = b.r / Math.SQRT2;        b.r = childR;        b.temp *= 0.95;        b.cooldown = 1.4;        b.x -= childR * 0.55;        const child = {          x: b.x + childR * 1.15,          y: b.y + rand(-8, 8),          vx: rand(-28, 28),          vy: b.vy * 0.4 + rand(-16, 16),          r: childR,          temp: clamp(b.temp * rand(0.78, 0.92), 0, 1),          phase: rand(0, TAU),          cooldown: 1.1,        };        blobs.push(child);        return; // one split per frame is enough      }    }  }  /* ---------- drawing ---------- */  function drawWall() {    const g = ctx.createLinearGradient(0, 0, 0, geom.deskY);    g.addColorStop(0, '#171221');    g.addColorStop(0.6, '#211627');    g.addColorStop(1, '#2a1a2a');    ctx.fillStyle = g;    ctx.fillRect(0, 0, W, geom.deskY + 2);    // warm bloom behind the lamp when on    if (light > 0.01) {      const rg = ctx.createRadialGradient(geom.cx, H * 0.42, 10, geom.cx, H * 0.42, W * 0.95);      rg.addColorStop(0, `rgba(255,128,52,${0.20 * light})`);      rg.addColorStop(0.5, `rgba(255,110,45,${0.07 * light})`);      rg.addColorStop(1, 'rgba(255,110,45,0)');      ctx.fillStyle = rg;      ctx.fillRect(0, 0, W, geom.deskY + 2);    }  }  function drawDesk() {    const g = ctx.createLinearGradient(0, geom.deskY, 0, H);    g.addColorStop(0, '#5b3a28');    g.addColorStop(0.08, '#4a2d1e');    g.addColorStop(1, '#241309');    ctx.fillStyle = g;    ctx.fillRect(0, geom.deskY, W, H - geom.deskY);    // back edge sheen    ctx.fillStyle = 'rgba(255,214,170,0.16)';    ctx.fillRect(0, geom.deskY, W, 2);    // wood grain streaks    ctx.strokeStyle = 'rgba(0,0,0,0.14)';    ctx.lineWidth = 1;    for (let i = 0; i < 4; i++) {      const y = geom.deskY + (H - geom.deskY) * (0.25 + i * 0.2);      ctx.beginPath();      ctx.moveTo(0, y);      ctx.bezierCurveTo(W * 0.3, y + 3, W * 0.7, y - 3, W, y + 2);      ctx.stroke();    }    // warm light pool on the desk when on    if (light > 0.01) {      const rg = ctx.createRadialGradient(geom.cx, geom.baseTop + 6, 6, geom.cx, geom.baseTop + 6, geom.bw * 2.3);      rg.addColorStop(0, `rgba(255,150,60,${0.38 * light})`);      rg.addColorStop(1, 'rgba(255,150,60,0)');      ctx.fillStyle = rg;      ctx.fillRect(0, geom.deskY, W, H - geom.deskY);    }    // lamp shadow    ctx.save();    ctx.translate(geom.cx, geom.baseTop + 10);    ctx.scale(1, 0.22);    const sg = ctx.createRadialGradient(0, 0, 4, 0, 0, geom.bw * 1.35);    sg.addColorStop(0, 'rgba(0,0,0,0.5)');    sg.addColorStop(1, 'rgba(0,0,0,0)');    ctx.fillStyle = sg;    ctx.beginPath();    ctx.arc(0, 0, geom.bw * 1.35, 0, TAU);    ctx.fill();    ctx.restore();  }  function drawBase() {    const { cx, bw, baseTop } = geom;    const w = bw + 15;    const h = H * 0.062;    const y = baseTop + 2;    const g = ctx.createLinearGradient(0, y, 0, y + h);    g.addColorStop(0, '#e9c47e');    g.addColorStop(0.35, '#b98a44');    g.addColorStop(1, '#6d4a20');    ctx.fillStyle = g;    roundRect(cx - w, y, w * 2, h, 9);    ctx.fill();    ctx.strokeStyle = 'rgba(0,0,0,0.45)';    ctx.lineWidth = 1.5;    ctx.stroke();    // top lip    ctx.fillStyle = 'rgba(255,235,190,0.5)';    roundRect(cx - w + 4, y + 2.5, w * 2 - 8, 3, 2);    ctx.fill();    // pilot dot (lit when on)    ctx.beginPath();    ctx.arc(cx, y + h * 0.55, 4.5, 0, TAU);    if (light > 0.05) {      ctx.fillStyle = `rgba(255,214,120,${0.35 + 0.65 * light})`;      ctx.shadowColor = 'rgba(255,170,60,0.9)';      ctx.shadowBlur = 12 * light;    } else {      ctx.fillStyle = '#3a2f22';      ctx.shadowBlur = 0;    }    ctx.fill();    ctx.shadowBlur = 0;  }  function drawGlass() {    const { cx, neckY, baseTop, bw, nw, gh, cornerR } = geom;    // liquid    glassPath();    const lg = ctx.createLinearGradient(0, neckY, 0, baseTop);    lg.addColorStop(0, 'rgba(64,22,38,0.82)');    lg.addColorStop(0.55, 'rgba(74,26,32,0.78)');    lg.addColorStop(1, 'rgba(88,32,30,0.85)');    ctx.fillStyle = lg;    ctx.fill();    // clipped region: contents    ctx.save();    glassPath();    ctx.clip();    // heating element glow at the base of the liquid    if (light > 0.02) {      const rg = ctx.createRadialGradient(cx, baseTop - 6, 4, cx, baseTop - 6, bw * 1.5);      rg.addColorStop(0, `rgba(255,140,45,${0.55 * light})`);      rg.addColorStop(0.55, `rgba(255,110,40,${0.22 * light})`);      rg.addColorStop(1, 'rgba(255,110,40,0)');      ctx.fillStyle = rg;      ctx.fillRect(cx - bw - 2, neckY, bw * 2 + 4, baseTop - neckY);    }    // blobs    const sorted = [...blobs].sort((a, b) => a.r - b.r); // small ones in front    for (const b of sorted) drawBlob(b);    // bottom inner shading    const bsh = ctx.createLinearGradient(0, baseTop - gh * 0.18, 0, baseTop);    bsh.addColorStop(0, 'rgba(0,0,0,0)');    bsh.addColorStop(1, 'rgba(0,0,0,0.34)');    ctx.fillStyle = bsh;    ctx.fillRect(cx - bw - 2, baseTop - gh * 0.2, bw * 2 + 4, gh * 0.2 + 2);    // glass highlights    const hl = ctx.createLinearGradient(cx - bw * 0.78, 0, cx - bw * 0.30, 0);    hl.addColorStop(0, 'rgba(255,255,255,0)');    hl.addColorStop(0.5, 'rgba(255,255,255,0.20)');    hl.addColorStop(1, 'rgba(255,255,255,0)');    ctx.fillStyle = hl;    ctx.fillRect(cx - bw * 0.95, neckY, bw * 0.7, baseTop - neckY);    const edge = ctx.createLinearGradient(cx + bw * 0.45, 0, cx + bw, 0);    edge.addColorStop(0, 'rgba(0,0,0,0)');    edge.addColorStop(1, 'rgba(0,0,0,0.30)');    ctx.fillStyle = edge;    ctx.fillRect(cx + bw * 0.4, neckY, bw, baseTop - neckY);    // neck shading    const neck = ctx.createLinearGradient(0, neckY, 0, neckY + gh * 0.06);    neck.addColorStop(0, 'rgba(0,0,0,0.42)');    neck.addColorStop(1, 'rgba(0,0,0,0)');    ctx.fillStyle = neck;    ctx.fillRect(cx - nw - 2, neckY, nw * 2 + 4, gh * 0.06);    ctx.restore();    // glass rim stroke    glassPath();    ctx.strokeStyle = 'rgba(255,255,255,0.34)';    ctx.lineWidth = 2;    ctx.stroke();    // specular line down the left shoulder    ctx.beginPath();    ctx.moveTo(cx - bw * 0.62, neckY + gh * 0.22);    ctx.bezierCurveTo(cx - bw * 0.78, neckY + gh * 0.4, cx - bw * 0.74, neckY + gh * 0.6, cx - bw * 0.70, baseTop - cornerR * 2);    ctx.strokeStyle = 'rgba(255,255,255,0.30)';    ctx.lineWidth = 3;    ctx.lineCap = 'round';    ctx.stroke();  }  function drawBlob(b) {    const temp = b.temp;    // soft glow behind a hot blob    if (temp > 0.45 && light > 0.03) {      const rg = ctx.createRadialGradient(b.x, b.y, b.r * 0.4, b.x, b.y, b.r * 2.4);      rg.addColorStop(0, `rgba(255,130,45,${0.20 * temp * light})`);      rg.addColorStop(1, 'rgba(255,130,45,0)');      ctx.fillStyle = rg;      ctx.beginPath();      ctx.arc(b.x, b.y, b.r * 2.4, 0, TAU);      ctx.fill();    }    blobPath(b);    ctx.fillStyle = blobGradient(b);    ctx.fill();    // wax rim    ctx.strokeStyle = `rgba(60,15,10,${0.40 - temp * 0.15})`;    ctx.lineWidth = 1.2;    ctx.stroke();    // inner sheen    ctx.beginPath();    ctx.ellipse(b.x - b.r * 0.30, b.y - b.r * 0.34, b.r * 0.34, b.r * 0.20, -0.5, 0, TAU);    ctx.fillStyle = `rgba(255,240,215,${0.30 + temp * 0.30})`;    ctx.fill();  }  function blobPath(b) {    const N = 10;    const pts = [];    for (let i = 0; i < N; i++) {      const a = (i / N) * TAU;      const rr = b.r * (1 + 0.10 * Math.sin(a * 3 + b.phase) + 0.06 * Math.sin(a * 5 - b.phase * 1.6));      pts.push([b.x + Math.cos(a) * rr, b.y + Math.sin(a) * rr * 0.92]);    }    ctx.beginPath();    const p0 = pts[0], pn = pts[N - 1];    ctx.moveTo((pn[0] + p0[0]) / 2, (pn[1] + p0[1]) / 2);    for (let i = 0; i < N; i++) {      const p = pts[i];      const q = pts[(i + 1) % N];      ctx.quadraticCurveTo(p[0], p[1], (p[0] + q[0]) / 2, (p[1] + q[1]) / 2);    }    ctx.closePath();  }  function drawCap() {    const { cx, neckY, nw } = geom;    const w = nw + 10;    const h = Math.max(22, H * 0.032);    const y = neckY - h * 0.62;    const g = ctx.createLinearGradient(0, y, 0, y + h);    g.addColorStop(0, '#f0cd8a');    g.addColorStop(0.4, '#c0934c');    g.addColorStop(1, '#66441e');    ctx.fillStyle = g;    roundRect(cx - w, y, w * 2, h, h * 0.4);    ctx.fill();    ctx.strokeStyle = 'rgba(0,0,0,0.5)';    ctx.lineWidth = 1.5;    ctx.stroke();    ctx.fillStyle = 'rgba(255,240,205,0.55)';    roundRect(cx - w + 5, y + 3, w * 2 - 10, 3, 2);    ctx.fill();  }  function roundRect(x, y, w, h, r) {    const rr = Math.min(r, w / 2, h / 2);    ctx.beginPath();    ctx.moveTo(x + rr, y);    ctx.arcTo(x + w, y, x + w, y + h, rr);    ctx.arcTo(x + w, y + h, x, y + h, rr);    ctx.arcTo(x, y + h, x, y, rr);    ctx.arcTo(x, y, x + w, y, rr);    ctx.closePath();  }  function render() {    ctx.clearRect(0, 0, W, H);    drawWall();    drawDesk();    drawBase();    drawGlass();    drawCap();  }  /* ---------- main loop ---------- */  const reducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;  let burst = 0; // frames of animation to run after a toggle in reduced-motion mode  let last = performance.now();  function frame(now) {    const dt = Math.min((now - last) / 1000, 0.05);    last = now;    step(dt);    render();    if (!reducedMotion || burst > 0) {      if (burst > 0) burst--;      requestAnimationFrame(frame);    }  }  /* ---------- wiring ---------- */  switchInput.addEventListener('change', () => {    lampOn = switchInput.checked;    statusEl.textContent = lampOn ? 'ON' : 'OFF';    statusEl.classList.toggle('on', lampOn);    if (reducedMotion) burst = 45;  });  statusEl.textContent = lampOn ? 'ON' : 'OFF';  statusEl.classList.toggle('on', lampOn);  function resize() {    const rect = canvas.getBoundingClientRect();    dpr = Math.min(window.devicePixelRatio || 1, 2);    W = Math.max(1, rect.width);    H = Math.max(1, rect.height);    canvas.width = Math.round(W * dpr);    canvas.height = Math.round(H * dpr);    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);    computeGeom();  }  window.addEventListener('resize', () => {    resize();    for (const b of blobs) {      b.r = Math.min(b.r, geom.maxR);      b.x = clamp(b.x, geom.cx - geom.bw * 0.8, geom.cx + geom.bw * 0.8);      b.y = clamp(b.y, geom.neckY + b.r, geom.baseTop - b.r);    }    if (reducedMotion) render();  });  resize();  computeGeom();  spawnBlobs();  if (reducedMotion) {    step(1 / 60);    render();  } else {    requestAnimationFrame(frame);  }})();</script></body></html>