Skip to content
VibeCodeBench
Back to the app

The code

Pelican on a Bike by Claude Opus 5.5

Exactly as the AI wrote it. Shown as text, so nothing runs on this page.

Try 1 · index.html

worksshown14.4 KB · 192 lines · no libraries
Download
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Pelican Promenade</title>
<style>
html,body{margin:0;height:100%;overflow:hidden;background:#bfe6f5;font-family:system-ui,sans-serif;touch-action:manipulation}
svg{position:absolute;inset:0;width:100%;height:100%;display:block}
#ui{position:absolute;left:0;right:0;bottom:0;display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;padding:10px;background:rgba(255,255,255,.75);backdrop-filter:blur(4px)}
button{min-width:48px;min-height:48px;border:0;border-radius:24px;background:#fff;box-shadow:0 2px 6px rgba(0,0,0,.2);font-size:18px;padding:0 14px;cursor:pointer}
label{display:flex;align-items:center;gap:6px;font-size:15px;min-height:48px}
input[type=range]{width:min(40vw,220px);height:44px}
#ptr{position:absolute;width:26px;height:26px;border-radius:50%;border:3px solid #e33;background:rgba(255,255,255,.5);pointer-events:none;display:none;transform:translate(-50%,-50%);transition:left .6s,top .6s;z-index:5}
#tip{position:absolute;top:8px;left:0;right:0;text-align:center;font-size:14px;color:#245;pointer-events:none}
</style></head><body>
<svg id="s" viewBox="0 0 800 450" preserveAspectRatio="xMidYMid slice">
<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#8fd3f4"/><stop offset="1" stop-color="#fde8c8"/></linearGradient></defs>
<rect width="800" height="450" fill="url(#sky)"/>
<circle cx="650" cy="80" r="34" fill="#ffe27a"/>
<g id="clouds"></g>
<rect y="200" width="800" height="110" fill="#3b8fc4"/>
<g id="waves"></g>
<g id="boats"></g>
<rect y="300" width="800" height="18" fill="#c9b18a"/>
<rect y="318" width="800" height="132" fill="#e2d2b0"/>
<g id="lamps"></g>
<g id="ground"></g>
<g id="rider"></g>
</svg>
<div id="tip">Tap anywhere to flap!</div>
<div id="ptr"></div>
<div id="ui">
<label>Speed <input id="spd" type="range" min="0" max="10" step="0.1" value="4"></label>
<button id="bell">🔔 Bell</button>
<button id="mute">🔊</button>
<button id="rst">↺ Restart</button>
</div>
<script>
(function(){
const NS='http://www.w3.org/2000/svg';
function el(t,a,p){const e=document.createElementNS(NS,t);for(const k in a)e.setAttribute(k,a[k]);if(p)p.appendChild(e);return e;}
function rng(s){return function(){s|=0;s=s+0x6D2B79F5|0;let t=Math.imul(s^s>>>15,1|s);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
const R=rng(42);
const $=id=>document.getElementById(id);
const W=1600;
// Scenery layers: each has two copies of a W-wide tile
function layer(g,build){const a=el('g',{},g),b=el('g',{},g);build(a);build(b);b.setAttribute('data-o',W);return [a,b];}
function cloudTile(g){for(let i=0;i<6;i++){const x=R()*W,y=30+R()*110,s=.6+R()*.8,c=el('g',{transform:`translate(${x},${y}) scale(${s})`,fill:'#fff',opacity:.9},g);el('ellipse',{cx:0,cy:0,rx:40,ry:16},c);el('ellipse',{cx:-20,cy:-10,rx:20,ry:16},c);el('ellipse',{cx:15,cy:-14,rx:24,ry:18},c);}}
const cR=R; // same seq per copy -> use fixed seed per layer
function seeded(seed,fn){return g=>{const r=rng(seed);fn(g,r);};}
const L={
clouds:layer($('clouds'),seeded(7,(g,r)=>{for(let i=0;i<6;i++){const x=r()*W,y=30+r()*110,s=.6+r()*.8,c=el('g',{transform:`translate(${x},${y}) scale(${s})`,fill:'#fff',opacity:.9},g);el('ellipse',{cx:0,cy:0,rx:40,ry:16},c);el('ellipse',{cx:-20,cy:-10,rx:20,ry:16},c);el('ellipse',{cx:15,cy:-14,rx:24,ry:18},c);}})),
waves:layer($('waves'),seeded(3,(g,r)=>{for(let i=0;i<40;i++){el('path',{d:`M${r()*W} ${215+r()*85} q8 -5 16 0 q8 5 16 0`,stroke:'#cfeaff',fill:'none','stroke-width':2,opacity:.7},g);}})),
boats:layer($('boats'),seeded(11,(g,r)=>{const cols=['#e85d4a','#f4c542','#fff','#5bb06a'];for(let i=0;i<4;i++){const x=150+i*400+r()*150,y=230+r()*40,s=.6+r()*.5,b=el('g',{transform:`translate(${x},${y}) scale(${s})`},g);el('path',{d:'M-40 0 L40 0 L28 16 L-28 16Z',fill:cols[i%4],stroke:'#333','stroke-width':1.5},b);el('line',{x1:0,y1:0,x2:0,y2:-60,stroke:'#555','stroke-width':3},b);el('path',{d:'M3 -58 L3 -4 L36 -4Z',fill:'#fff',stroke:'#999'},b);el('path',{d:'M-3 -50 L-3 -6 L-28 -6Z',fill:'#f6f6f6',stroke:'#999'},b);}})),
lamps:layer($('lamps'),seeded(5,(g,r)=>{for(let i=0;i<5;i++){const x=i*320+80,l=el('g',{transform:`translate(${x},0)`},g);el('rect',{x:-3,y:205,width:6,height:110,fill:'#2f3e4f'},l);el('rect',{x:-9,y:308,width:18,height:10,fill:'#2f3e4f'},l);el('path',{d:'M0 208 q0 -14 16 -14',stroke:'#2f3e4f','stroke-width':5,fill:'none'},l);el('path',{d:'M8 194 h18 l-4 12 h-10z',fill:'#ffe9a0',stroke:'#2f3e4f','stroke-width':2},l);el('rect',{x:-30,y:300,width:2,height:0},l);}
for(let x=0;x<W;x+=40)el('rect',{x:x,y:296,width:4,height:22,fill:'#fff',opacity:.85},g);el('rect',{x:0,y:296,width:W,height:4,fill:'#fff',opacity:.85},g);})),
ground:layer($('ground'),seeded(9,(g,r)=>{for(let x=0;x<W;x+=60)el('rect',{x:x,y:385,width:30,height:4,fill:'#c8b48c'},g);for(let i=0;i<30;i++)el('circle',{cx:r()*W,cy:340+r()*100,r:1.5+r()*2,fill:'#bfa77e'},g);}))
};
const speeds={clouds:.08,waves:.25,boats:.35,lamps:.7,ground:1};

// ---------- Bike + pelican ----------
const rider=$('rider');
const RW={x:300,y:330},FW={x:470,y:330},WR=52,BB={x:385,y:334},CR=15,SP=7.5;
const ST={x:362,y:250},HT={x:452,y:256},HB={x:446,y:232};
el('ellipse',{cx:385,cy:384,rx:150,ry:8,fill:'rgba(0,0,0,.18)'},rider);
const legFar=el('g',{},rider);
function wheel(c){const g=el('g',{},rider);el('circle',{cx:c.x,cy:c.y,r:WR,fill:'none',stroke:'#222','stroke-width':7},g);el('circle',{cx:c.x,cy:c.y,r:WR-4,fill:'none',stroke:'#888','stroke-width':1.5},g);const sp=el('g',{},g);for(let i=0;i<16;i++){const a=i*Math.PI/8;el('line',{x1:c.x,y1:c.y,x2:c.x+Math.cos(a)*(WR-4),y2:c.y+Math.sin(a)*(WR-4),stroke:'#aaa','stroke-width':1.2},sp);}el('circle',{cx:c.x+WR-11,cy:c.y,r:3,fill:'#e33'},sp);el('circle',{cx:c.x,cy:c.y,r:4,fill:'#555'},g);return sp;}
const rSp=wheel(RW),fSp=wheel(FW);
// chain
function tangents(){const top=`M${RW.x} ${RW.y-SP} L${BB.x} ${BB.y-CR}`;}
const chainD=`M${RW.x} ${RW.y-SP} L${BB.x} ${BB.y-CR} A${CR} ${CR} 0 0 1 ${BB.x} ${BB.y+CR} L${RW.x} ${RW.y+SP} A${SP} ${SP} 0 0 1 ${RW.x} ${RW.y-SP}Z`;
el('path',{d:chainD,fill:'none',stroke:'#444','stroke-width':3.5},rider);
const chain=el('path',{d:chainD,fill:'none',stroke:'#bbb','stroke-width':2,'stroke-dasharray':'3 3'},rider);
const spr=el('g',{},rider);el('circle',{cx:RW.x,cy:RW.y,r:SP,fill:'#777',stroke:'#333'},spr);el('line',{x1:RW.x-SP,y1:RW.y,x2:RW.x+SP,y2:RW.y,stroke:'#333','stroke-width':2},spr);
// frame (diamond)
const fc='#1f8a8a',fw=6;
[[RW,BB],[RW,ST],[ST,BB],[ST,HT],[HT,BB],[HT,FW]].forEach(([a,b])=>el('line',{x1:a.x,y1:a.y,x2:b.x,y2:b.y,stroke:fc,'stroke-width':fw,'stroke-linecap':'round'},rider));
el('line',{x1:HT.x,y1:HT.y,x2:HB.x,y2:HB.y,stroke:'#555','stroke-width':5},rider);
el('path',{d:`M${HB.x-4} ${HB.y} L${HB.x+18} ${HB.y-4} q8 0 6 10`,stroke:'#333','stroke-width':5,fill:'none','stroke-linecap':'round'},rider);
el('line',{x1:ST.x,y1:ST.y,x2:ST.x-4,y2:ST.y-12,stroke:'#555','stroke-width':5},rider);
el('path',{d:`M${ST.x-24} ${ST.y-14} q20 -8 40 2 q-20 6 -40 -2z`,fill:'#3a2a1f'},rider);
const ring=el('g',{},rider);el('circle',{cx:BB.x,cy:BB.y,r:CR,fill:'#ccc',stroke:'#444','stroke-width':2},ring);for(let i=0;i<5;i++){const a=i*Math.PI*2/5;el('line',{x1:BB.x,y1:BB.y,x2:BB.x+Math.cos(a)*CR,y2:BB.y+Math.sin(a)*CR,stroke:'#666','stroke-width':2},ring);}
const crankFar=el('line',{stroke:'#333','stroke-width':5,'stroke-linecap':'round'},legFar);
const pedFar=el('rect',{width:14,height:5,fill:'#333'},legFar);
// legs
function legEls(p,col){return{th:el('line',{stroke:col,'stroke-width':8,'stroke-linecap':'round'},p),sh:el('line',{stroke:col,'stroke-width':6,'stroke-linecap':'round'},p),ft:el('path',{fill:col},p)};}
const lf=legEls(legFar,'#d98b2b');
// body
const bird=el('g',{},rider);
el('path',{d:'M310 225 L280 210 L292 232Z',fill:'#e9e9e9',stroke:'#999'},bird);
el('ellipse',{cx:360,cy:215,rx:58,ry:38,fill:'#f7f7f4',stroke:'#aaa','stroke-width':2},bird);
const neck=el('path',{d:'M395 200 C430 180 405 140 428 120',stroke:'#f7f7f4','stroke-width':22,fill:'none','stroke-linecap':'round'},bird);
const head=el('g',{},bird);
el('ellipse',{cx:432,cy:115,rx:20,ry:16,fill:'#fafaf5',stroke:'#aaa','stroke-width':1.5},head);
el('path',{d:'M425 100 q8 -14 20 -6',stroke:'#f2e2a0','stroke-width':4,fill:'none'},head);
const pouch=el('path',{fill:'#f3a54a',stroke:'#c97a20','stroke-width':1.5},head);
el('path',{d:'M444 108 L540 120 L546 126 L446 120Z',fill:'#f6c048',stroke:'#c98a20','stroke-width':1.5},head);
el('circle',{cx:437,cy:111,r:3.5,fill:'#111'},head);el('circle',{cx:438,cy:110,r:1,fill:'#fff'},head);
const legNear=el('g',{},rider);
const crankNear=el('line',{stroke:'#222','stroke-width':6,'stroke-linecap':'round'},legNear);
const pedNear=el('rect',{width:16,height:6,fill:'#222'},legNear);
const ln=legEls(legNear,'#f0a040');
el('circle',{cx:BB.x,cy:BB.y,r:4,fill:'#222'},legNear);
const wing=el('g',{},rider);
const wingP=el('path',{fill:'#ececec',stroke:'#888','stroke-width':2},wing);
const wingT=el('path',{fill:'#333'},wing);

const HIP={x:358,y:236},TH=58,SH=58;
function leg(L,crankEl,pedEl,a){
 const px=BB.x+Math.cos(a)*24,py=BB.y+Math.sin(a)*24;
 crankEl.setAttribute('x1',BB.x);crankEl.setAttribute('y1',BB.y);crankEl.setAttribute('x2',px);crankEl.setAttribute('y2',py);
 pedEl.setAttribute('x',px-7);pedEl.setAttribute('y',py-3);
 const dx=px-HIP.x,dy=py-HIP.y,d=Math.min(Math.hypot(dx,dy),TH+SH-1);
 const base=Math.atan2(dy,dx),k=Math.acos((TH*TH+d*d-SH*SH)/(2*TH*d));
 const kx=HIP.x+Math.cos(base-k)*TH,ky=HIP.y+Math.sin(base-k)*TH; // knee forward
 L.th.setAttribute('x1',HIP.x);L.th.setAttribute('y1',HIP.y);L.th.setAttribute('x2',kx);L.th.setAttribute('y2',ky);
 L.sh.setAttribute('x1',kx);L.sh.setAttribute('y1',ky);L.sh.setAttribute('x2',px);L.sh.setAttribute('y2',py);
 L.ft.setAttribute('d',`M${px-6} ${py-2} L${px+16} ${py-6} L${px+12} ${py+2} L${px+18} ${py+4} L${px-4} ${py+4}Z`);
}
function drawWing(f){ // f: 0..1 flap amount
 const sx=385,sy=200,lift=f*120;
 const tx=HB.x+20-f*40,ty=HB.y-2-lift;
 const mx=(sx+tx)/2-10,my=(sy+ty)/2-25-f*60;
 wingP.setAttribute('d',`M${sx-30} ${sy-10} Q${mx} ${my} ${tx} ${ty} Q${(sx+tx)/2} ${(sy+ty)/2+22-f*20} ${sx-20} ${sy+22}Z`);
 wingT.setAttribute('d',`M${tx-14} ${ty-6} Q${tx} ${ty-8} ${tx+4} ${ty} Q${tx-4} ${ty+6} ${tx-16} ${ty+5}Z`);
}

// ---------- state ----------
let dist=0,speed=4,flapT=-1,last=performance.now(),muted=false,ac=null,demo=false,demoT=0,fpsAcc=0,fpsN=0,low=false;
const spd=$('spd');spd.oninput=()=>{speed=+spd.value;};
function audio(){if(!ac){try{ac=new (window.AudioContext||window.webkitAudioContext)();}catch(e){}}if(ac&&ac.state==='suspended')ac.resume();return ac;}
function ringBell(){const a=audio();if(!a||muted)return;const t=a.currentTime;[[2100,0],[2100,.18]].forEach(([f,o])=>{[1,2.76,5.4].forEach((m,i)=>{const os=a.createOscillator(),g=a.createGain();os.type='sine';os.frequency.value=f*m/1.5;g.gain.setValueAtTime(0,t+o);g.gain.linearRampToValueAtTime(.25/(i+1),t+o+.005);g.gain.exponentialRampToValueAtTime(.0001,t+o+.6/(i+1));os.connect(g).connect(a.destination);os.start(t+o);os.stop(t+o+.7);});});bellShake=1;}
let bellShake=0;
function flap(){if(flapT<0)flapT=0;}
function reset(){dist=0;speed=4;spd.value=4;flapT=-1;}
function stopDemo(){if(demo){demo=false;$('ptr').style.display='none';}}
$('bell').addEventListener('pointerdown',e=>{e.stopPropagation();stopDemoReal(e);ringBell();});
$('mute').addEventListener('pointerdown',e=>{e.stopPropagation();stopDemoReal(e);muted=!muted;$('mute').textContent=muted?'🔇':'🔊';});
$('rst').addEventListener('pointerdown',e=>{e.stopPropagation();stopDemoReal(e);reset();});
spd.addEventListener('pointerdown',e=>{e.stopPropagation();stopDemoReal(e);});
$('ui').addEventListener('pointerdown',e=>e.stopPropagation());
function stopDemoReal(e){if(e.isTrusted)stopDemo();}
window.addEventListener('pointerdown',e=>{if(e.isTrusted)stopDemo();audio();flap();});
window.addEventListener('keydown',e=>{stopDemo();if(e.key===' '){flap();}else if(e.key==='b')ringBell();});

// demo
const ptr=$('ptr');
function ptrTo(elm,cb){const r=elm.getBoundingClientRect();ptr.style.left=(r.left+r.width/2)+'px';ptr.style.top=(r.top+r.height/2)+'px';}
function ptrXY(x,y){ptr.style.left=x+'px';ptr.style.top=y+'px';}
const script=[[0,()=>{ptrXY(innerWidth/2,innerHeight/3);}],[1.2,()=>flap()],[3,()=>ptrTo(spd)],[4,()=>{}],[8,()=>ptrTo($('bell'))],[9,()=>ringBell()],[11,()=>ptrXY(innerWidth*.3,innerHeight*.3)],[12,()=>flap()],[14,()=>ptrTo(spd)],[18,()=>ptrTo($('rst'))],[19.5,()=>reset()]];
let si=0;
function demoStep(dt){demoT+=dt;
 if(demoT>=3.5&&demoT<8)speed=4+(demoT-3.5)*1.2;
 if(demoT>=14.5&&demoT<18)speed=Math.max(1.5,9.4-(demoT-14.5)*2.2);
 spd.value=speed;
 while(si<script.length&&demoT>=script[si][0]){script[si][1]();si++;}
 if(demoT>20.5){demoT=0;si=0;}
}
if(location.hash==='#demo'){demo=true;ptr.style.display='block';}

let sent=false;
function frame(now){
 let dt=Math.min(.05,(now-last)/1000);last=now;
 if(demo)demoStep(dt);
 fpsAcc+=dt;fpsN++;if(fpsAcc>2){if(fpsN/fpsAcc<40&&!low){low=true;$('waves').style.display='none';$('clouds').setAttribute('opacity','.8');}fpsAcc=0;fpsN=0;}
 const v=speed*40; // px per second
 dist+=v*dt;
 for(const k in L){const off=(dist*speeds[k])%W;L[k][0].setAttribute('transform',`translate(${-off},0)`);L[k][1].setAttribute('transform',`translate(${W-off},0)`);}
 const wa=dist/WR; // radians, roll without slip
 const deg=wa*180/Math.PI;
 rSp.setAttribute('transform',`rotate(${deg} ${RW.x} ${RW.y})`);
 fSp.setAttribute('transform',`rotate(${deg} ${FW.x} ${FW.y})`);
 spr.setAttribute('transform',`rotate(${deg} ${RW.x} ${RW.y})`);
 const ca=wa*SP/CR; // chainring angle
 ring.setAttribute('transform',`rotate(${ca*180/Math.PI} ${BB.x} ${BB.y})`);
 chain.setAttribute('stroke-dashoffset',-(ca*CR));
 leg(ln,crankNear,pedNear,ca);leg(lf,crankFar,pedFar,ca+Math.PI);
 // flap
 let f=0;if(flapT>=0){flapT+=dt;f=Math.sin(Math.min(1,flapT/0.7)*Math.PI);if(flapT>0.7)flapT=-1;}
 drawWing(f);
 const bob=Math.sin(ca*2)*1.5-f*4;
 // pouch stretch
 const st=6+Math.sin(now/300)*3+speed*.8+f*6;
 pouch.setAttribute('d',`M446 120 Q490 ${130+st*1.6} 538 125 L446 120Z`);
 head.setAttribute('transform',`translate(0,${Math.sin(now/400)*2}) rotate(${Math.sin(now/700)*3+(bellShake>0?Math.sin(now/30)*6*bellShake:0)} 432 115)`);
 bellShake=Math.max(0,bellShake-dt*1.5);
 bird.setAttribute('transform',`translate(0,${bob})`);wing.setAttribute('transform',`translate(0,${bob*.5})`);
 if(!sent){sent=true;requestAnimationFrame(()=>{try{parent.postMessage({vcb:'ready'},'*');}catch(e){}});}
 requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
})();
</script>
</body></html>

Try 2 · index.html

works14.7 KB · 196 lines · no libraries
Download
<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Pelican Promenade</title>
<style>
html,body{margin:0;height:100%;overflow:hidden;background:#bfe6f5;font-family:system-ui,sans-serif;touch-action:manipulation;user-select:none;-webkit-user-select:none}
#scene{position:fixed;inset:0;width:100%;height:100%;display:block}
#ui{position:fixed;left:0;right:0;bottom:0;display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:rgba(255,255,255,.75);backdrop-filter:blur(6px)}
button{min-width:48px;min-height:48px;border:0;border-radius:24px;background:#1f5f8b;color:#fff;font-size:16px;font-weight:600;padding:0 16px;cursor:pointer}
button:active{transform:scale(.95)}
label{display:flex;align-items:center;gap:8px;font-weight:600;color:#123;min-height:48px}
input[type=range]{width:min(42vw,220px);height:44px;accent-color:#e8833a}
#hint{position:fixed;top:10px;left:0;right:0;text-align:center;color:#123;font-weight:600;font-size:15px;pointer-events:none;text-shadow:0 1px 0 #fff}
#ptr{position:fixed;width:26px;height:26px;margin:-13px 0 0 -13px;border-radius:50%;border:3px solid #fff;background:rgba(232,60,60,.6);box-shadow:0 0 6px #0006;pointer-events:none;display:none;z-index:9;transition:transform .12s}
#ptr.down{transform:scale(.7)}
</style></head><body>
<svg id="scene" viewBox="0 0 800 450" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#8fd3f0"/><stop offset="1" stop-color="#fbe7c6"/></linearGradient>
<linearGradient id="sea" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#3a8fb7"/><stop offset="1" stop-color="#2a6f96"/></linearGradient>
</defs>
<rect width="800" height="450" fill="url(#sky)"/>
<circle cx="640" cy="80" r="34" fill="#ffe08a"/>
<g id="clouds"></g>
<rect y="215" width="800" height="110" fill="url(#sea)"/>
<g id="waves"></g>
<g id="boats"></g>
<g id="rail"></g>
<rect y="325" width="800" height="125" fill="#d9c7a3"/>
<rect y="325" width="800" height="6" fill="#b9a27a"/>
<g id="pave"></g>
<g id="rider"></g>
</svg>
<div id="hint">Tap anywhere to make the pelican flap!</div>
<div id="ui">
<label>Speed <input id="speed" type="range" min="0" max="10" step="0.1" value="4" aria-label="Speed"></label>
<button id="bell" aria-label="Ring bell">🔔 Bell</button>
<button id="mute" aria-label="Mute">🔊</button>
<button id="reset" aria-label="Restart">↺ Restart</button>
</div>
<div id="ptr"></div>
<script>
(function(){
"use strict";
var NS="http://www.w3.org/2000/svg";
function el(t,a,p){var e=document.createElementNS(NS,t);for(var k in a)e.setAttribute(k,a[k]);if(p)p.appendChild(e);return e;}
function rng(s){return function(){s|=0;s=s+0x6D2B79F5|0;var t=Math.imul(s^s>>>15,1|s);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
var R=rng(20240611);
var $=function(id){return document.getElementById(id);};

// ---------- scenery (each layer: two 800px tiles) ----------
function makeLayer(g,build){for(var i=0;i<2;i++){var t=el("g",{transform:"translate("+(i*800)+",0)"},g);build(t);}}
var cloudSpec=[],boatSpec=[];
for(var i=0;i<5;i++)cloudSpec.push([R()*800,40+R()*110,0.6+R()*0.7]);
for(i=0;i<3;i++)boatSpec.push([80+i*260+R()*120,240+R()*55,0.6+R()*0.5,R()<.5?"#e85d4a":"#f2b632"]);
makeLayer($("clouds"),function(t){cloudSpec.forEach(function(c){var g=el("g",{transform:"translate("+c[0]+","+c[1]+") scale("+c[2]+")",fill:"#fff",opacity:.92},t);
 el("ellipse",{cx:0,cy:0,rx:42,ry:16},g);el("circle",{cx:-14,cy:-10,r:18},g);el("circle",{cx:14,cy:-14,r:22},g);});});
makeLayer($("waves"),function(t){for(var k=0;k<14;k++){var x=R()*800,y=225+R()*95;el("path",{d:"M"+x+","+y+" q8,-5 16,0 q8,-5 16,0",stroke:"#bfe8f7",fill:"none","stroke-width":2,opacity:.7,"stroke-linecap":"round"},t);}});
makeLayer($("boats"),function(t){boatSpec.forEach(function(b){var g=el("g",{transform:"translate("+b[0]+","+b[1]+") scale("+b[2]+")"},t);
 el("path",{d:"M-30,0 L30,0 L22,12 L-22,12Z",fill:"#7a4b2a"},g);el("line",{x1:0,y1:0,x2:0,y2:-52,stroke:"#553",["stroke-width"]:2},g);
 el("path",{d:"M2,-50 L2,-4 L30,-4Z",fill:"#fff"},g);el("path",{d:"M-2,-46 L-2,-4 L-24,-4Z",fill:b[3]},g);});});
makeLayer($("rail"),function(t){el("rect",{x:0,y:300,width:800,height:4,fill:"#5b6b78"},t);el("rect",{x:0,y:314,width:800,height:3,fill:"#5b6b78"},t);
 for(var x=0;x<800;x+=40)el("rect",{x:x,y:300,width:4,height:26,fill:"#5b6b78"},t);
 for(x=100;x<800;x+=400){el("rect",{x:x-3,y:190,width:6,height:136,fill:"#2f3e4a"},t);el("path",{d:"M"+(x-3)+",192 q0,-14 16,-14",stroke:"#2f3e4a","stroke-width":5,fill:"none"},t);
  el("path",{d:"M"+(x+6)+",178 h16 l-3,10 h-10z",fill:"#2f3e4a"},t);el("circle",{cx:x+14,cy:190,r:5,fill:"#ffe9a0"},t);}});
makeLayer($("pave"),function(t){for(var x=0;x<800;x+=50){el("line",{x1:x,y1:331,x2:x-30,y2:450,stroke:"#c7b38c","stroke-width":2},t);}
 el("line",{x1:0,y1:395,x2:800,y2:395,stroke:"#fff","stroke-width":4,"stroke-dasharray":"30 20",opacity:.6},t);});
var layers=[[$("clouds"),.08],[$("waves"),.2],[$("boats"),.3],[$("rail"),.65],[$("pave"),1]];

// ---------- bike + pelican ----------
var rider=$("rider");
var RW={x:320,y:340},FW={x:480,y:340},WR=48,BB={x:395,y:345},CR=18,RING=14,SPR=7;
var GROUND=WR+RW.y; // 388
el("ellipse",{cx:400,cy:GROUND+2,rx:130,ry:6,fill:"#0002"},rider);
var legFar=el("g",{},rider);
function wheel(c){var g=el("g",{},rider);el("circle",{cx:c.x,cy:c.y,r:WR,fill:"none",stroke:"#222","stroke-width":7},g);el("circle",{cx:c.x,cy:c.y,r:WR-4,fill:"none",stroke:"#888","stroke-width":2},g);
 var s=el("g",{},g);for(var i=0;i<16;i++){var a=i*Math.PI/8;el("line",{x1:c.x,y1:c.y,x2:c.x+Math.cos(a)*(WR-5),y2:c.y+Math.sin(a)*(WR-5),stroke:"#bbb","stroke-width":1.2},s);}
 el("circle",{cx:c.x,cy:c.y,r:4,fill:"#555"},s);el("line",{x1:c.x,y1:c.y-WR+8,x2:c.x,y2:c.y-WR+2,stroke:"#e44","stroke-width":3},s);return s;}
var rs=wheel(RW),fs=wheel(FW);
var chain=el("path",{d:"M395,331 L320,333 A7,7 0 0 0 320,347 L395,359 A14,14 0 0 0 395,331Z",fill:"none",stroke:"#444","stroke-width":2.5,"stroke-dasharray":"3 2.5"},rider);
var SEAT={x:380,y:272},HEAD={x:463,y:282},HB={x:470,y:300};
var fc="#1d8a6b";
function tube(a,b,w){el("line",{x1:a.x,y1:a.y,x2:b.x,y2:b.y,stroke:fc,"stroke-width":w||6,"stroke-linecap":"round"},rider);}
tube(BB,SEAT);tube(SEAT,HEAD);tube(BB,HB);tube(BB,RW,5);tube(SEAT,RW,4);tube({x:463,y:278},FW,5);
el("line",{x1:463,y1:278,x2:458,y2:258,stroke:"#333","stroke-width":5,"stroke-linecap":"round"},rider);
el("path",{d:"M452,256 L466,256 q8,0 8,8",stroke:"#333","stroke-width":5,fill:"none","stroke-linecap":"round"},rider);
el("circle",{cx:452,cy:257,r:4,fill:"#f4c430"},rider);
el("line",{x1:378,y1:274,x2:376,y2:264,stroke:"#333","stroke-width":4},rider);
el("path",{d:"M362,262 q16,-6 30,0 q-14,6 -30,0z",fill:"#3a2a20"},rider);
var ringG=el("g",{},rider);el("circle",{cx:BB.x,cy:BB.y,r:RING,fill:"none",stroke:"#666","stroke-width":3},ringG);
el("circle",{cx:RW.x,cy:RW.y,r:SPR,fill:"#666"},rider);
var crankA=el("line",{stroke:"#333","stroke-width":4,"stroke-linecap":"round"},rider);
var pedA=el("rect",{width:12,height:4,rx:1,fill:"#222"},rider);
// pelican body
var body=el("g",{},rider);
el("path",{d:"M340,250 q-10,-6 -22,-2 q12,6 22,12z",fill:"#e9ece8",stroke:"#9aa",["stroke-width"]:1},body); // tail
el("ellipse",{cx:385,cy:238,rx:44,ry:30,fill:"#f7f8f5",stroke:"#9aa","stroke-width":1.5},body);
var neck=el("path",{fill:"none",stroke:"#f7f8f5","stroke-width":16,"stroke-linecap":"round"},body);
var neckO=el("path",{fill:"none",stroke:"#9aa","stroke-width":1},body);
var headG=el("g",{},body);
el("circle",{cx:0,cy:0,r:15,fill:"#f7f8f5",stroke:"#9aa","stroke-width":1.5},headG);
el("path",{d:"M-6,-14 q4,-10 14,-8",stroke:"#f2d36b","stroke-width":4,fill:"none","stroke-linecap":"round"},headG);
var pouch=el("path",{fill:"#f5a85b",stroke:"#c97a3a","stroke-width":1.5},headG);
el("path",{d:"M8,-6 L86,4 q6,2 0,5 L10,4z",fill:"#f2b13c",stroke:"#c78a22","stroke-width":1.5},headG);
el("circle",{cx:86,cy:6,r:2.5,fill:"#d9672a"},headG);
var eye=el("circle",{cx:4,cy:-4,r:3.4,fill:"#123"},headG);el("circle",{cx:5,cy:-5,r:1,fill:"#fff"},headG);
var wing=el("path",{fill:"#e6e9e4",stroke:"#8a9696","stroke-width":1.5},rider);
var legNear=el("g",{},rider);
var crankB=el("line",{stroke:"#333","stroke-width":4,"stroke-linecap":"round"},rider);
var pedB=el("rect",{width:12,height:4,rx:1,fill:"#222"},rider);
function leg(g,col){return{th:el("line",{stroke:col,"stroke-width":7,"stroke-linecap":"round"},g),sh:el("line",{stroke:col,"stroke-width":5,"stroke-linecap":"round"},g),ft:el("path",{fill:col},g)};}
var LF=leg(legFar,"#d98a3a"),LN=leg(legNear,"#f0a04b");
// chain is drawn before far leg ordering is fine; move legFar behind body
var HIP={x:388,y:258},L1=52,L2=54;
function ik(h,p){var dx=p.x-h.x,dy=p.y-h.y,d=Math.min(Math.hypot(dx,dy),L1+L2-0.01),a=Math.atan2(dy,dx);var c=(L1*L1+d*d-L2*L2)/(2*L1*d);var b=Math.acos(Math.max(-1,Math.min(1,c)));var k=a-b;return{x:h.x+Math.cos(k)*L1,y:h.y+Math.sin(k)*L1};}
function setLeg(L,h,p,cr){var k=ik(h,p);
 L.th.setAttribute("x1",h.x);L.th.setAttribute("y1",h.y);L.th.setAttribute("x2",k.x);L.th.setAttribute("y2",k.y);
 L.sh.setAttribute("x1",k.x);L.sh.setAttribute("y1",k.y);L.sh.setAttribute("x2",p.x);L.sh.setAttribute("y2",p.y);
 L.ft.setAttribute("d","M"+(p.x-3)+","+(p.y-2)+" l20,1 l-4,4 l-4,-2 l-4,3 l-4,-2 l-6,3z");}
function setCrank(line,ped,a){var x=BB.x+Math.cos(a)*CR,y=BB.y+Math.sin(a)*CR;line.setAttribute("x1",BB.x);line.setAttribute("y1",BB.y);line.setAttribute("x2",x);line.setAttribute("y2",y);ped.setAttribute("x",x-6);ped.setAttribute("y",y-2);return{x:x,y:y-2};}

// ---------- state ----------
var speedEl=$("speed"),dist=0,wheelA=0,t=0,flap=0,lowQ=false,muted=false,ctx=null;
function reset(){dist=0;wheelA=0;flap=0;speedEl.value=4;}
var flapStart=-9;
function draw(){
 var crank=wheelA*SPR/RING; // ring drives sprocket: wheel turns RING/SPR times per crank turn
 var bob=Math.sin(crank*2)*1.2;
 rider.setAttribute("transform","translate(0,0)");
 var deg=wheelA*180/Math.PI;
 rs.setAttribute("transform","rotate("+deg+" "+RW.x+" "+RW.y+")");fs.setAttribute("transform","rotate("+deg+" "+FW.x+" "+FW.y+")");
 ringG.setAttribute("transform","rotate("+(crank*180/Math.PI)+" "+BB.x+" "+BB.y+")");
 chain.setAttribute("stroke-dashoffset",(crank*RING).toFixed(2));
 var pa=setCrank(crankA,pedA,crank+Math.PI),pb=setCrank(crankB,pedB,crank);
 var hip={x:HIP.x,y:HIP.y+bob*.3};
 setLeg(LF,hip,pa);setLeg(LN,hip,pb);
 body.setAttribute("transform","translate(0,"+bob.toFixed(2)+")");
 // neck & head
 var hx=438+Math.sin(t*1.3)*3,hy=170+bob+Math.sin(t*2.1)*2;
 neck.setAttribute("d","M405,225 Q440,215 "+(hx-8)+","+(hy+10));
 headG.setAttribute("transform","translate("+(hx)+","+(hy-bob)+") rotate("+(8+Math.sin(t*1.7)*3)+")");
 var sag=10+Math.sin(t*3)*5+(flap>0?8*Math.sin(flap*Math.PI):0);
 pouch.setAttribute("d","M10,3 Q40,"+(14+sag)+" 84,8 L10,4z");
 eye.setAttribute("ry",3.4);
 // wing: tip on handlebar unless flapping
 var f=t-flapStart,lift=f<0.9?Math.sin(f/0.9*Math.PI):0;
 var sx=395,sy=222+bob,tx=452+(-60*lift),ty=257-110*lift;
 var mx=(sx+tx)/2+4-20*lift,my=(sy+ty)/2-14-10*lift;
 wing.setAttribute("d","M"+(sx-30)+","+(sy+4)+" Q"+mx+","+(my-10)+" "+tx+","+ty+" l-6,6 l3,4 l-8,3 Q"+(mx-6)+","+(my+22)+" "+(sx-26)+","+(sy+24)+"z");
 for(var i=0;i<layers.length;i++){var o=-((dist*layers[i][1])%800);layers[i][0].setAttribute("transform","translate("+o.toFixed(1)+",0)");}
}

// ---------- audio ----------
function ac(){if(!ctx){try{ctx=new (window.AudioContext||window.webkitAudioContext)();}catch(e){}}if(ctx&&ctx.state==="suspended")ctx.resume();return ctx;}
function ring(){var c=ac();if(!c||muted)return;var n=c.currentTime;[0,0.18].forEach(function(d){[[2093,1],[2093*2.76,.35],[2093*5.4,.12]].forEach(function(p){var o=c.createOscillator(),g=c.createGain();o.frequency.value=p[0];o.type="sine";g.gain.setValueAtTime(0,n+d);g.gain.linearRampToValueAtTime(.25*p[1],n+d+.005);g.gain.exponentialRampToValueAtTime(.0001,n+d+.6);o.connect(g);g.connect(c.destination);o.start(n+d);o.stop(n+d+.65);});});}
function doFlap(){if(t-flapStart>0.9)flapStart=t;}

// ---------- input ----------
var demo=location.hash==="#demo",ptr=$("ptr");
function endDemo(e){if(demo&&e.isTrusted){demo=false;ptr.style.display="none";}}
window.addEventListener("pointerdown",endDemo,true);
window.addEventListener("keydown",endDemo,true);
$("bell").addEventListener("click",function(e){e.stopPropagation();ring();});
$("mute").addEventListener("click",function(e){muted=!muted;this.textContent=muted?"🔇":"🔊";this.setAttribute("aria-label",muted?"Unmute":"Mute");});
$("reset").addEventListener("click",reset);
$("scene").addEventListener("pointerdown",function(){ac();doFlap();$("hint").style.opacity=0;});
window.addEventListener("keydown",function(e){if(e.key===" "){doFlap();}if(e.key==="b"){ring();}});

// ---------- demo ----------
function ptrAt(id){var r=$(id).getBoundingClientRect();return{x:r.left+r.width/2,y:r.top+r.height/2};}
function sceneTap(){return{x:innerWidth*.5,y:innerHeight*.35};}
var demoT=0;
var script=[[0,function(){return sceneTap();},null],[1.5,sceneTap,"tap"],[3,function(){return ptrAt("speed");},null],[4,function(){return ptrAt("speed");},function(){speedEl.value=8;}],[7,function(){return ptrAt("bell");},null],[8,function(){return ptrAt("bell");},"bell"],[10,function(){return{x:innerWidth*.4,y:innerHeight*.3};},null],[11,null,"tap"],[13,function(){return ptrAt("speed");},null],[14,null,function(){speedEl.value=2;}],[16,function(){return ptrAt("speed");},function(){speedEl.value=5;}],[17.5,sceneTap,"tap"],[19.5,null,function(){reset();}]];
var pPos={x:0,y:0},pTarget={x:0,y:0},si=0;
function runDemo(dt){demoT+=dt;if(demoT>20){demoT=0;si=0;}
 while(si<script.length&&demoT>=script[si][0]){var s=script[si];if(s[1])pTarget=s[1]();var a=s[2];
  if(a){ptr.classList.add("down");setTimeout(function(){ptr.classList.remove("down");},150);
   if(a==="tap")doFlap();else if(a==="bell")ring();else a();}si++;}
 pPos.x+=(pTarget.x-pPos.x)*Math.min(1,dt*6);pPos.y+=(pTarget.y-pPos.y)*Math.min(1,dt*6);
 ptr.style.left=pPos.x+"px";ptr.style.top=pPos.y+"px";}
if(demo){ptr.style.display="block";pPos={x:innerWidth/2,y:innerHeight/2};}

// ---------- loop ----------
var last=performance.now(),ready=false,fpsAcc=0,fpsN=0;
function frame(now){var dt=Math.min(0.05,(now-last)/1000);last=now;t+=dt;
 if(demo)runDemo(dt);
 var v=parseFloat(speedEl.value)*30; // px per second
 dist+=v*dt;wheelA+=v*dt/WR; // rolling without slipping
 fpsAcc+=dt;fpsN++;if(fpsAcc>2){var fps=fpsN/fpsAcc;if(fps<40&&!lowQ){lowQ=true;$("waves").style.display="none";$("clouds").setAttribute("opacity",.8);}fpsAcc=0;fpsN=0;}
 draw();
 if(!ready){ready=true;try{parent.postMessage({vcb:"ready"},"*");}catch(e){}}
 requestAnimationFrame(frame);}
draw();requestAnimationFrame(frame);
})();
</script>
</body></html>