BUILD REQUEST - PL-165 Rope Snap Lab - please build this now I'm sending you this as my request: please build the one-file HTML app described below. Start now and do the whole build in your answer to this message. - This is a build job, not a document to summarize, review or discuss. Don't ask me anything first: if a detail is unclear, pick the most sensible option and keep going. - The spec is everything between the BEGIN SPEC and END SPEC lines. Follow all of it exactly. - If your tool can create files, also save the finished file as PL-165-rope-snap-lab.html. ===== BEGIN SPEC ===== ROPE SNAP LAB: Tensioned Cable Whip & Post Wrap HOOK OBJECT: window.__ropesnap Build "ROPE SNAP LAB": a high-contrast engineering test rig in Canvas 2D (no libraries) where a braided steel-and-hemp hawser wraps around cast-iron bollards under rising winch tension, glows along high-strain links, and whips violently across the test deck when cut or overloaded. Watching stored elastic energy convert into a supersonic snap-back wave around steel posts is the whole thrill. LOOK - Style: crisp maritime-engineering test bench with blueprint grid, palette slate deck #12171E, blueprint grid #1F2A38, iron bollard #4E5B6B, brass cap #D9A74A, resting rope #E4C997, medium strain amber #F59E0B, critical strain crimson #EF4444, spark gold #FFE082. - Subject: a 12 m x 7 m overhead test deck with 4 cylindrical steel bollards (two movable via drag), a geared winch drum on the left, a deadman anchor pin on the right, and a 72-node mass-spring rope wrapping around the bollards with visible braided strands and live per-segment tension color + strain gauge arc. - FIRST FRAME (t = 0, no input): the full test deck, geared winch, 4 bollards, and taut S-wrapped rope under 65% tension filling at least 60% of the screen height, with a crisp top-left telemetry pill outside the deck. MOTION / PLAY - Controls: drag the tension slider or press W/S to wind the winch up to 100%+ yield; click directly on any rope segment (or press Space / CUT) to sever that link instantly; drag the two center bollards to re-route the wrap angle; press R or RIG NEXT to load the next bollard wrap preset (S-WRAP, CAPSTAN DOUBLE, SLINGSHOT ARC). Camera setter setCamera(panX, panY, zoom) frames the deck. - Hand-written rope physics: sub-stepped Verlet / damped Hooke spring chain (72 nodes, real SI units, 16 sub-steps per frame so stiff tension never explodes to NaN). Every segment calculates real axial strain `(L - L0) / L0` and tension in kN; circular bollard collisions enforce exact tangent wrap and capstan friction. - Snap-back recoil: severing a tensioned segment splits the chain into two live ends that whip around the bollards, shed bright spark bursts on high-speed bollard slaps, and strike target foam bumpers along the deck edges. - ATTRACT MODE: with no input, a hands-free 28–30 s lab showcase runs on load: (1) winds S-WRAP to 88% and cuts mid-span for a dramatic whip recoil, (2) loads CAPSTAN DOUBLE and winds past 100% until an overloaded link snaps on its own, and (3) loads SLINGSHOT ARC for a high-velocity double-whip cut. Any input takes over; after 8 s idle the showcase resumes. SOUND - Winch winding -> mechanical ratchet clicks and rising low cable creak proportional to tension %. - Rope cut or overload snap -> sharp supersonic crack followed by a resonant metallic twang. - Whipping rope slapping a steel bollard -> bright metallic clank; bumper strike -> dull thud. COUNTERS stats() returns { fps, tensionKn, strainPct, cuts, autoSnaps, peakWhipMs, bollardHits }. - tensionKn: current peak axial tension across intact segments in kilonewtons. - strainPct: current peak percentage of yield strain (0–100+). - cuts: +1 only when a rope segment is severed manually or by the demo cutter. Never on load. - autoSnaps: +1 only when an intact segment exceeds 100% yield tension and breaks by itself. - peakWhipMs: highest measured node velocity in m/s after a snap. - bollardHits: +1 when a recoiling free rope end visibly slaps a bollard above 8 m/s. - On screen: top-left pill "TENSION NN kN · STRAIN NN% · WHIP NN m/s · SNAPS N", never over the rope. CHECKS for ?test=1 With ?test=1, run an accelerated self-test that measures real positions and real events (not self-set flags) and logs "TEST n PASS" or "TEST n FAIL: reason" to the console and to window.__testResults: 1. First frame: test deck, winch, bollards and S-wrapped rope fill at least 55% of screen height, 72 rope nodes exist, and zero nodes sit inside any bollard radius. 2. Elastic storage & recoil: winding to >= 80% strain then cutting mid-span increments cuts by 1, accelerates the severed ends past 18 m/s (peakWhipMs >= 18), and produces zero NaN coordinates over 3 s. 3. Bollard wrap integrity: during high-tension winding and recoil, no intact rope node penetrates deeper than 5% into any bollard cylinder. 4. Overload auto-snap: winding past 100% yield without calling cut breaks the highest-strain link automatically, increments autoSnaps by 1, and drops peak tension below 20% of yield within 1.5 s. 5. Attract showcase: advancing 30 s hands-free visits all 3 wrap presets, records cuts >= 1 and autoSnaps >= 1, and logs zero console errors. KEEP IT SHORT - Keep the whole file under about 1,500 lines (soft target) so you can write it in one pass and finish well inside 15 minutes. - Save lines with helpers, loops and instancing, not by dropping features. Everything above must really work: no placeholders, no TODOs. BUILD RULES (all required): - Deliver ONE self-contained HTML file: inline CSS and JS, no build step, no local assets. Libraries only from a CDN. If you use Three.js, use exactly this import map: {"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"}} - It must open straight from disk in desktop Chrome and on an iPhone (Safari), fill the full screen, handle resize and touch, and stay smooth (target 60 fps). - It must look stunning in the very FIRST frame: no black screen, no loading wait, no tiny subject. The main subject fills at least 50% of the screen height. - SOUND (required): all sound is made in code with Web Audio (no audio files). Show a small "🔊 TAP FOR SOUND" chip; on the first tap create ONE AudioContext, route everything through a master gain of 0.6 into a DynamicsCompressor, and hide the chip. Also expose enableAudio() on the hook object named at the top. - Expose the hook object named at the top with: setCameraOrbit(azimuthDeg, elevationDeg, distance) (or an equivalent camera setter), advance(seconds) that steps the simulation exactly that much for still captures, enableAudio(), and stats() returning {fps, ...the counters named above}. Use a fixed random seed of 360 so every run is the same. - Every on-screen counter must count a real event you can see happen. No fake numbers. - No text overlapping the subject; any label must be readable in a paused frame. - No brand logos, no real people, no copyrighted characters, brand names or logos. FAILURE MODES TO AVOID - Rope passing straight through bollards like a ghost instead of wrapping around the cylinder perimeter. - Stiff spring solver exploding to NaN on high tension or at the instant of cutting. - Canned whip animation instead of real Verlet elastic release of the two separated chains. - Fake painted red tension that doesn't respond to winch winding or drop when cut. - HUD covering the winch or bollards. - The same variable declared twice, or methods called on objects that don't exist yet. SELF-TEST LOOP - If you can run code: build the file, open it, read the console, run ?test=1, and take screenshots at 3 s, 10 s and 30 s at 1280x720 and 390x844. Look at the screenshots and fix what looks wrong. Fix and retest until all 5 checks pass with zero console errors. Mark anything you could not run as UNMEASURED; never invent results. - If you are chat-only: go through this prompt line by line, check your code against each line, and fix anything that would fail. Then write one corrected, complete file. - Final answer: ONE complete HTML file in ONE code block, then the 5 checks marked PASS, FAIL or UNMEASURED. No snippets, no "rest unchanged". ===== END SPEC ===== Now build it. Reply with ONE complete HTML file in ONE code block, then the 5 checks marked PASS, FAIL or UNMEASURED.