Back to the app
The code
The Most Uncomfortable Web Page by Claude Opus 5.5
Exactly as the AI wrote it. Shown as text, so nothing runs on this page.
index.html
works · auto-checked (Checked by an automated pass. Not hand-played yet.)<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Perfectly Normal Page</title>
<style>
:root{--k:1;--bg:#f4f0e8;--ink:#2b2a33;--ink2:#5f5c68;--card:#fffdf9;--line:#e5ddcf;--acc:#3b6ef5;--acc2:#2a55cc;--ok:#22a06b;--sh:0 12px 30px rgba(60,45,20,.12),0 2px 6px rgba(60,45,20,.08);color-scheme:light}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;overflow-x:hidden}
body{background:var(--bg) linear-gradient(rgba(0,0,0,.028) 1px,transparent 1px) 0 0/100% 32px;color:var(--ink);font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;-webkit-tap-highlight-color:transparent}
body.straight{--k:0}
.t{transform:rotate(calc(var(--r,0deg)*var(--k)));transition:transform 1.4s cubic-bezier(.3,1.5,.5,1)}
.px,.pl{position:relative;transition:top 1s,left 1s}
.px{top:calc(1px*var(--k))}
.pl{left:calc(1px*var(--k))}
.wide{letter-spacing:calc(.05em*var(--k))}
.odd{font-family:Georgia,"Times New Roman",serif}
body.straight .odd{font-family:inherit}
#app{max-width:620px;margin:0 auto;padding:10px 16px 70px}
header{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;padding:6px 0 16px}
.logo{display:flex;align-items:center;gap:8px;font-weight:800;font-size:19px;letter-spacing:-.01em}
.logo sup{font-size:10px;margin-left:-6px}
.mark{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;color:#fff;font-weight:900;background:linear-gradient(135deg,#3b6ef5,#7b5cff);box-shadow:0 3px 0 #2a55cc}
.chip{font-family:inherit;font-size:13px;font-weight:600;color:var(--ink2);background:#fff;border:1px solid var(--line);border-radius:999px;padding:8px 12px;min-height:36px;display:inline-flex;align-items:center}
#steps{margin-left:auto}
#mus{cursor:pointer;min-height:40px;touch-action:manipulation}
.scene{opacity:0;transform:translateY(10px);transition:opacity .35s,transform .35s}
.scene.in{opacity:1;transform:none}
.card{position:relative;background:var(--card);border:1px solid var(--line);border-radius:20px;box-shadow:var(--sh);padding:22px 20px}
h1{font-size:clamp(26px,7vw,38px);line-height:1.12;letter-spacing:-.02em;margin:0 0 12px}
h1::after{content:"";display:block;width:68px;height:4px;border-radius:2px;background:var(--acc);margin-top:12px;position:relative;left:calc(3px*var(--k));transition:left 1s}
p{margin:0 0 12px;color:var(--ink2)}
.badge{display:inline-block;background:#fff1c2;color:#7a5800;font-size:13px;font-weight:800;border-radius:999px;padding:4px 11px;margin-bottom:12px}
.btn{font-family:inherit;font-weight:800;font-size:18px;min-height:54px;padding:12px calc(22px - 2px*var(--k)) 12px calc(22px + 3px*var(--k));border:0;border-radius:14px;background:var(--acc);color:#fff;box-shadow:0 4px 0 var(--acc2),0 10px 18px rgba(59,110,245,.25);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-user-select:none}
.btn:active{transform:translateY(3px) rotate(calc(var(--r,0deg)*var(--k)));box-shadow:0 1px 0 var(--acc2)}
.btn.g{background:#fff;color:var(--ink);border:1px solid var(--line);box-shadow:0 4px 0 #dcd3c2}
.btn.ok{background:var(--ok);color:#fff;border-color:transparent;box-shadow:0 4px 0 #17815a}
.btn.tired{background:#8190b8;box-shadow:0 4px 0 #64729a}
.btn.sm{font-size:15px;min-height:46px;padding-top:8px;padding-bottom:8px}
.btn.pulse{animation:breathe 1.8s ease-in-out infinite}
@keyframes breathe{50%{scale:1.05}}
button:focus-visible{outline:3px solid #ffbf47;outline-offset:3px}
.zone{position:relative;height:230px;margin:16px 0 10px;border:2px dashed #e0d6c3;border-radius:16px;background:repeating-linear-gradient(45deg,rgba(0,0,0,.018) 0 10px,transparent 10px 20px)}
.zl{position:absolute;left:12px;top:6px;font-size:11px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;color:#aaa294}
#start{position:absolute;left:0;top:0;white-space:nowrap;transition:left .3s cubic-bezier(.2,.9,.3,1.3),top .3s cubic-bezier(.2,.9,.3,1.3),transform .3s,background .3s}
.row2{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 10px}
.link{font-family:inherit;font-size:14px;background:none;border:0;color:var(--acc);text-decoration:underline;text-underline-offset:calc(3px + 2px*var(--k));min-height:44px;padding:0 4px;cursor:pointer}
.tiny{font-size:12.5px;color:#9d968a}
.feats{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:18px}
.feat{background:#fff;border:1px solid var(--line);border-radius:12px;padding:9px 14px;font-weight:700;font-size:14px;box-shadow:0 2px 0 #e6dece}
.feat.low{position:relative;top:calc(4px*var(--k));transition:top 1s,transform 1.4s}
.cookie{width:64px;height:64px;border-radius:50%;margin:0 0 12px;background:radial-gradient(circle at 30% 34%,#5b3416 0 3.5px,transparent 4.5px),radial-gradient(circle at 62% 28%,#5b3416 0 3px,transparent 4px),radial-gradient(circle at 55% 66%,#5b3416 0 3.5px,transparent 4.5px),radial-gradient(circle at 26% 70%,#5b3416 0 2.5px,transparent 3.5px),radial-gradient(circle at 78% 55%,#5b3416 0 2.5px,transparent 3.5px),#d9a35a;box-shadow:inset -4px -5px 0 rgba(0,0,0,.12);-webkit-mask:radial-gradient(circle at 90% 14%,transparent 0 12px,#000 13px);mask:radial-gradient(circle at 90% 14%,transparent 0 12px,#000 13px)}
.count{font-weight:700;color:var(--ink)}
#layer{position:fixed;inset:0;z-index:20;pointer-events:none;overflow:hidden}
#layer>*{pointer-events:auto}
.ck{position:absolute;width:min(300px,calc(100vw - 32px));background:#fff;border:1px solid var(--line);border-radius:16px;box-shadow:var(--sh);padding:14px 14px 12px;font-size:14.5px;color:var(--ink2);transition:opacity .4s,transform .4s;animation:pop .45s cubic-bezier(.2,1.3,.4,1)}
.ck b{display:block;color:var(--ink);font-size:16px;margin-bottom:2px}
.ck .row{display:flex;gap:8px;margin-top:12px}
.ck .btn{flex:1}
.ck.out{opacity:0;transform:scale(.85);pointer-events:none}
.ck.big{text-align:center}
.ck.big .cookie{margin:0 auto 8px}
@keyframes pop{from{opacity:0;transform:translateY(14px) scale(.94) rotate(calc(var(--r,0deg)*var(--k)))}}
@keyframes fade{from{opacity:0}}
.track{position:relative;height:36px;border-radius:999px;background:#ebe4d6;overflow:hidden;box-shadow:inset 0 2px 4px rgba(0,0,0,.08);margin:18px 0 6px}
.fill{height:100%;width:0;border-radius:999px;background:repeating-linear-gradient(-45deg,#5584ff 0 12px,#3b6ef5 12px 24px);background-size:34px 34px;animation:stripes 1.4s linear infinite}
@keyframes stripes{to{background-position:34px 0}}
.pct{position:absolute;inset:0;display:grid;place-items:center;font-weight:800;color:#1f2d57;font-variant-numeric:tabular-nums;transform:translate(calc(1px*var(--k)),calc(1px*var(--k)))}
.status{min-height:3em;font-weight:700;color:var(--ink);margin:10px 0 0}
.acts{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}
.acts .btn{flex:1 1 180px}
.dim{position:absolute;inset:0;background:rgba(43,42,51,.32);animation:fade .4s}
.modal{position:absolute;left:50%;top:45%;width:min(340px,calc(100vw - 32px));background:#fff;border-radius:18px;box-shadow:var(--sh);padding:20px 18px 86px;transform:translate(-50%,-50%) rotate(calc(var(--r,0deg)*var(--k)));animation:fade .4s}
.modal b{display:block;font-size:20px;line-height:1.25;margin-bottom:8px}
.modal p{font-size:14.5px;margin:0}
.env{width:58px;height:40px;border-radius:8px;margin-bottom:12px;background:conic-gradient(from -45deg at 50% 60%,#c3d1ff 0 90deg,#e4ebff 0)}
.cls{position:absolute;white-space:nowrap;font-size:16px;min-height:48px;padding:10px 16px;background:#2b2a33;box-shadow:0 4px 0 #111,0 8px 16px rgba(0,0,0,.18);animation:pop .35s cubic-bezier(.2,1.3,.4,1);transition:opacity .3s,background-color .3s,transform 1.4s}
.cls .x{font-size:1.25em;line-height:0;vertical-align:-1px}
.cls.dead{opacity:.5;background:#a8a3ae;box-shadow:0 3px 0 #8e8995;pointer-events:none}
.cls.real{background:var(--ok);box-shadow:0 4px 0 #17815a}
#layer.bye>*{opacity:0!important;transition:opacity .5s!important;pointer-events:none!important}
.skel{height:12px;border-radius:6px;background:#ece5d8;margin:12px 0;width:92%}
.skel.s2{width:74%;margin-left:calc(2px*var(--k))}
.skel.s3{width:86%}
.skel.s4{width:40%}
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;max-width:320px;margin:14px auto 4px}
.tile{aspect-ratio:1/1;border:3px solid transparent;border-radius:14px;display:grid;place-items:center;position:relative;cursor:pointer;padding:0;font:inherit;touch-action:manipulation}
.tile.sel{border-color:var(--acc);box-shadow:0 0 0 3px rgba(59,110,245,.2)}
.tile i{display:block;width:42%;height:42%;background:rgba(43,42,51,.5)}
.tile i.k1{border-radius:50%}
.tile i.k2{border-radius:5px}
.tile i.k3{width:0;height:0;background:none;border-left:18px solid transparent;border-right:18px solid transparent;border-bottom:30px solid rgba(43,42,51,.5)}
.tile i.k4{width:34%;height:34%;border-radius:4px;transform:rotate(45deg)}
.tile em{position:absolute;left:0;right:0;bottom:3px;font-size:11px;font-style:normal;font-weight:800;color:var(--ink)}
.cert{border:3px double #d1ad57;border-radius:16px;background:#fffaf0;padding:18px 14px 14px;text-align:center}
.cert small{display:block;font-size:12px;font-weight:800;letter-spacing:.22em;text-transform:uppercase;color:#a8812c}
.cert h1{font-family:Georgia,"Times New Roman",serif;font-size:clamp(38px,11vw,56px);margin:0 0 10px}
.cert h1::after{margin:8px auto 0;background:#d1ad57}
.seal{width:76px;height:76px;margin:0 auto 8px;border-radius:50%;display:grid;place-items:center;font-weight:900;font-size:15px;color:#8a5a00;background:radial-gradient(circle,#ffe08a 0 54%,#f0bf45 55% 62%,#ffe08a 63%);box-shadow:0 3px 0 #d39f2a}
.stats{list-style:none;margin:12px 0 0;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:6px;text-align:left;font-size:13.5px}
.stats li{background:#fff;border:1px solid #efe2bf;border-radius:10px;padding:6px 10px;color:var(--ink2)}
.stats b{color:var(--ink);font-size:17px;margin-right:3px}
body.straight .stats li:last-child{grid-column:1/-1;text-align:center}
#confetti{position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:5}
#confetti i{position:absolute;top:0;width:8px;height:13px;border-radius:2px;opacity:.85;animation:fall 9s linear infinite}
body.straight #confetti i{animation-name:fall2}
@keyframes fall{from{transform:translate(0,-6vh) rotate(var(--a))}to{transform:translate(var(--x),106vh) rotate(calc(var(--a) + 240deg))}}
@keyframes fall2{from{transform:translateY(-6vh)}to{transform:translateY(106vh)}}
footer{margin-top:28px;text-align:center;font-size:12.5px;color:#9d968a}
footer u{text-underline-offset:3px}
#toast{position:fixed;left:50%;top:10px;z-index:40;max-width:calc(100vw - 32px);background:#2b2a33;color:#fff;font-size:14px;font-weight:600;padding:10px 16px;border-radius:12px;box-shadow:var(--sh);transform:translate(-50%,-160%);transition:transform .5s cubic-bezier(.2,1.2,.4,1);pointer-events:none}
#toast.on{transform:translate(-50%,0) rotate(calc(-1deg*var(--k)))}
#speck{position:fixed;width:30px;height:30px;z-index:15;display:grid;place-items:center;cursor:pointer;transition:left .7s,top .7s,opacity 1s}
#speck::after{content:"";width:3px;height:3px;border-radius:50%;background:rgba(40,40,40,.6)}
body.straight #speck{opacity:0;pointer-events:none}
#finger{position:fixed;left:-80px;top:-80px;width:46px;height:46px;margin:-23px 0 0 -23px;border-radius:50%;background:rgba(59,110,245,.2);border:3px solid rgba(59,110,245,.75);z-index:60;pointer-events:none;display:none;transition:left .3s ease,top .3s ease,transform .12s}
#finger.tap{transform:scale(.7)}
#demoTag{position:fixed;left:50%;bottom:14px;transform:translateX(-50%);z-index:59;background:rgba(43,42,51,.9);color:#fff;font-size:13px;font-weight:700;padding:8px 14px;border-radius:999px;pointer-events:none;display:none;white-space:nowrap}
@media (prefers-reduced-motion:reduce){.t,.scene,#start,.ck,.cls,#toast{transition-duration:.01s!important}.fill,.btn.pulse{animation:none}#confetti{display:none}}
</style>
</head>
<body>
<div id="app">
<header>
<div class="logo"><span class="mark t" data-r="5">c</span><span class="o1">ComfyPage</span><sup>™</sup></div>
<span class="chip t" id="steps">Step 1 of 5</span>
<span class="chip t" id="clock">--:--</span>
<button class="chip t" id="mus" type="button">♪ Hold music: off</button>
</header>
<main id="stage"></main>
<footer class="o1">© 2026 ComfyPage Inc. · All rights reversed · <u>Privacy</u> · <u>Terms</u> · <u>Tems</u></footer>
</div>
<div id="confetti" aria-hidden="true"></div>
<div id="speck" aria-hidden="true"></div>
<div id="layer"></div>
<div id="toast" role="status" aria-live="polite"></div>
<div id="finger" aria-hidden="true"></div>
<div id="demoTag">Demo · touch anywhere to try it yourself</div>
<script>
(()=>{
'use strict';
const $=(s,r=document)=>r.querySelector(s),$$=(s,r=document)=>Array.from(r.querySelectorAll(s));
const R=(a,b)=>a+Math.random()*(b-a),pick=a=>a[Math.floor(Math.random()*a.length)];
const sleep=ms=>new Promise(r=>setTimeout(r,ms));
const body=document.body,stage=$('#stage'),layer=$('#layer'),finger=$('#finger'),tag=$('#demoTag'),speck=$('#speck');
const S={stage:0,t0:Date.now(),dodges:0,cookies:0,closes:0,slips:0};
const demo={on:false,tok:0};
let gen=0;const timers=[],offs=[];
function later(fn,ms){const g=gen;timers.push(setTimeout(()=>{if(g===gen)fn();},ms));}
function on(t,ev,fn){t.addEventListener(ev,fn);offs.push(()=>t.removeEventListener(ev,fn));}
function kill(){gen++;timers.splice(0).forEach(clearTimeout);offs.splice(0).forEach(f=>f());}
/* everything tidy, everything slightly crooked */
function tilt(root){$$('.t',root).forEach(el=>{if(el.style.getPropertyValue('--r'))return;const d=el.dataset.r;el.style.setProperty('--r',(d!=null?+d:(Math.random()<.5?-1:1)*R(.35,1.15)).toFixed(2)+'deg');});}
/* one letter, one pixel off */
function offify(root){$$('.o1',root).forEach(el=>{if(el.dataset.done)return;el.dataset.done='1';const w=document.createTreeWalker(el,NodeFilter.SHOW_TEXT),ns=[];let n;while((n=w.nextNode()))if(/[a-z]/i.test(n.data))ns.push(n);if(!ns.length)return;const t=pick(ns),ix=[];for(let i=0;i<t.data.length;i++)if(/[a-z]/i.test(t.data[i]))ix.push(i);const a=t.splitText(pick(ix));a.splitText(1);const sp=document.createElement('span');sp.className=Math.random()<.5?'px':'pl';sp.textContent=a.data;a.replaceWith(sp);});}
let tT=0;
function toast(m){const t=$('#toast');t.textContent=m;t.classList.add('on');clearTimeout(tT);tT=setTimeout(()=>t.classList.remove('on'),2800);}
function clock(){const d=new Date(),off=body.classList.contains('straight')?0:1;d.setMinutes(d.getMinutes()+off);let s;try{s=d.toLocaleTimeString([],{hour:'numeric',minute:'2-digit'});}catch(e){s=d.getHours()+':'+String(d.getMinutes()).padStart(2,'0');}$('#clock').textContent=s+(off?' (ish)':'');}
function moveSpeck(){speck.style.left=R(16,Math.max(20,innerWidth-46))+'px';speck.style.top=R(110,Math.max(120,innerHeight-70))+'px';}
speck.addEventListener('click',()=>{moveSpeck();if(!demo.on)toast(pick(['That was not dust. Probably.','It moved. It does that.','Still there? Hard to say.']));});
let visits=1;try{visits=(+localStorage.getItem('comfy-visits')||0)+1;localStorage.setItem('comfy-visits',String(visits));}catch(e){}
const STEPS=['Step 1 of 5','Step 2 of 4','Step 3 of 7','Step 4 of 4½','Step 5 of 5 (probably)','Step 6 of 5'];
const SC=[];
function go(n){
kill();layer.innerHTML='';layer.className='';S.stage=n;S.P=null;
$('#steps').textContent=STEPS[n];
const sc=document.createElement('div');sc.className='scene';
stage.innerHTML='';stage.appendChild(sc);
SC[n](sc);tilt(sc);offify(sc);
requestAnimationFrame(()=>requestAnimationFrame(()=>sc.classList.add('in')));
try{window.scrollTo(0,0);}catch(e){}
}
/* 0 - the button that dodges */
SC[0]=sc=>{
sc.innerHTML=`<div class="card t"><span class="badge t">New & improved*</span>
<h1 class="o1">Welcome to the most <span class="wide">comfortable</span> page on the internet</h1>
<p class="o1">Everything here is perfectly normal and <span class="odd">completely</span> aligned. To begin, simply press the big friendly button.</p>
<div class="zone" id="zone"><span class="zl o1">Button parking area</span><button class="btn t" id="start" type="button">Start</button></div>
<div class="row2"><button class="link" id="skip" type="button">Skip intro</button><span class="tiny o1">${visits>1?`Visit #${visits}. We remember you (a normal amount).`:'*Improvements not guaranteed (some assembly required'}</span></div>
</div><div class="feats"><span class="feat t">Fast</span><span class="feat t">Reliable</span><span class="feat t low">Perfectly aligned</span></div>`;
const zone=$('#zone',sc),b=$('#start',sc),need=demo.on?3:5,say=['Nope','Too slow','Almost!','Hehe','Whoosh'];
let n=0,tired=false,lastD=0,ign=0;
const place=(x,y)=>{b.style.left=x+'px';b.style.top=y+'px';};
requestAnimationFrame(()=>place((zone.clientWidth-b.offsetWidth)/2,(zone.clientHeight-b.offsetHeight)/2+8));
function dodge(){
if(tired)return;const now=Date.now();if(now-lastD<230)return;lastD=now;
n++;S.dodges++;
if(n>=need){tired=true;b.textContent='Fine. Press me.';b.classList.add('tired');b.style.setProperty('--r','-2.5deg');}
else{b.textContent=say[(n-1)%say.length];b.style.setProperty('--r',R(-10,10).toFixed(1)+'deg');}
const W=Math.max(8,zone.clientWidth-b.offsetWidth-8),H=Math.max(26,zone.clientHeight-b.offsetHeight-8),cx=b.offsetLeft,cy=b.offsetTop;
let x,y,k=0;do{x=R(8,W);y=R(26,H);k++;}while(k<40&&Math.hypot(x-cx,y-cy)<Math.min(110,W*.45));
place(x,y);
}
on(document,'pointermove',e=>{if(e.pointerType!=='mouse'||tired||demo.on)return;const r=b.getBoundingClientRect();if(Math.abs(e.clientX-(r.left+r.width/2))<r.width/2+36&&Math.abs(e.clientY-(r.top+r.height/2))<r.height/2+36)dodge();});
b.addEventListener('pointerdown',e=>{if(e.pointerType!=='mouse'&&!tired){dodge();ign=Date.now()+700;}});
b.addEventListener('click',()=>{if(Date.now()<ign)return;if(!tired){dodge();return;}b.textContent='Thank you';b.disabled=true;later(()=>go(1),380);});
$('#skip',sc).addEventListener('click',e=>{e.currentTarget.textContent='There is no intro.';});
};
/* 1 - the cookie notice that multiplies */
const CK=[['We use cookies','to make this page slightly worse for everyone, equally.'],['We also use cookies','to remember that you accepted our cookies.'],['Cookie notice','This notice about cookies is powered by cookies.'],['Quick question','Do you accept that you accepted?'],['Our 847 partners','would each like one small cookie. Just one.'],['More cookies','These ones are oatmeal raisin. We are sorry.'],['Legally required','to inform you about the previous notice.']];
SC[1]=sc=>{
sc.innerHTML=`<div class="card t"><div class="cookie t"></div><h1 class="o1">Before we continue</h1><p class="o1">We value your privacy a normal amount. Please review our cookie notice. You may see it more than once.</p><p class="count o1">Cookies accepted: <b id="cc">0</b></p></div>`;
S.ck=0;S.ckN=0;later(()=>spawnCookie(true),350);
};
function spawnCookie(first){
const d=document.createElement('div'),c=CK[S.ckN++%CK.length];d.className='ck t';
d.innerHTML=`<b>${c[0]}</b><span>${c[1]}</span><div class="row"><button class="btn sm" type="button">Accept</button><button class="btn sm g" type="button">Also accept</button></div>`;
layer.appendChild(d);
const w=d.offsetWidth,h=d.offsetHeight,vw=innerWidth,vh=innerHeight;
d.style.left=(first?(vw-w)/2:R(8,Math.max(8,vw-w-8)))+'px';
d.style.top=(first?Math.max(70,vh-h-16):R(64,Math.max(64,vh-h-12)))+'px';
d.style.setProperty('--r',(first?-.8:R(-4.5,4.5)).toFixed(1)+'deg');
$$('button',d).forEach(x=>x.addEventListener('click',()=>acceptCookie(d)));
}
function acceptCookie(d){
if(d.dataset.gone)return;d.dataset.gone='1';S.ck++;S.cookies++;
const cc=$('#cc');if(cc)cc.textContent=S.ck;
d.classList.add('out');later(()=>d.remove(),420);
if(S.ck<(demo.on?3:5)){spawnCookie(false);later(()=>spawnCookie(false),160);}
else{$$('.ck',layer).forEach(x=>{x.dataset.gone='1';x.classList.add('out');});later(finalCookie,520);}
}
function finalCookie(){
layer.innerHTML='';const d=document.createElement('div');d.className='ck big t';d.dataset.r='1.2';
d.innerHTML=`<div class="cookie"></div><b>All done!</b><span>You have accepted 2,048 cookies. Your device is now 4% biscuit.</span><div class="row"><button class="btn sm" type="button">Lovely</button></div>`;
layer.appendChild(d);tilt(layer);
d.style.left=(innerWidth-d.offsetWidth)/2+'px';d.style.top=Math.max(64,(innerHeight-d.offsetHeight)/2)+'px';
$('button',d).addEventListener('click',()=>{if(d.dataset.gone)return;d.dataset.gone='1';d.classList.add('out');later(()=>go(2),320);});
}
/* 2 - the progress bar that slides back at 99 */
SC[2]=sc=>{
sc.innerHTML=`<div class="card t"><h1 class="o1">Loading the next step</h1><p class="o1">This will only take a moment. Please do not refresh, blink, or think about the number 100.</p>
<div class="track t" data-r="-.5"><div class="fill" id="fill"></div><div class="pct" id="pct">0%</div></div>
<p class="status" id="st">Warming up the pixels…</p>
<div class="acts"><button class="btn" id="help" type="button">Help it along</button></div></div>`;
const D=demo.on,P={p:0,mode:'run',slips:0},need=D?2:3,tg=D?[72,58]:[64,23,91];S.P=P;
const fill=$('#fill',sc),pct=$('#pct',sc),st=$('#st',sc),help=$('#help',sc);
const msg=['Oops. It slipped.','It got nervous and backed away.','So close. It panicked a little.'];
const stat=['Warming up the pixels…','Reticulating splines…','Ironing the margins…','Counting to 99. Twice.','Aligning things (roughly)…','Asking the last percent nicely…'];
const rate=D?95:13,g=gen;let last=performance.now(),acc=0,si=0,from=0,to=0,t0=0;
function frame(now){
if(g!==gen)return;
const dt=Math.min(.05,Math.max(0,(now-last)/1000));last=now;
if(P.mode==='run'){
P.p+=rate*dt*((P.p>90&&!D)?0.4:1);
if((acc+=dt)>1.8){acc=0;st.textContent=stat[++si%stat.length];}
if(P.p>=99){P.p=99;
if(P.slips<need){P.mode='hold';st.textContent='99%! Here it comes…';
later(()=>{P.mode='slide';from=99;to=tg[P.slips];t0=performance.now();st.textContent=msg[P.slips];P.slips++;S.slips++;},D?250:900);}
else{P.mode='stuck';st.textContent='Stuck at 99%. Classic. One more push?';help.textContent='Push gently';help.classList.add('pulse');}}
}else if(P.mode==='slide'){const k=Math.min(1,(now-t0)/(D?550:1200)),e=1-Math.pow(1-k,3);P.p=from+(to-from)*e;if(k>=1){P.mode='run';acc=0;}}
fill.style.width=P.p+'%';pct.textContent=Math.floor(P.p)+'%';
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
help.addEventListener('click',()=>{
if(P.mode==='run')P.p=Math.min(99,P.p+7);
else if(P.mode==='stuck'){P.mode='done';P.p=100;st.textContent='It did it! The last 1% is always the hardest.';help.textContent='Continue';help.classList.remove('pulse');help.classList.add('ok');}
else if(P.mode==='done'){P.mode='gone';go(3);}
else if(P.mode!=='gone')st.textContent="Please don't touch it while it's upset.";
});
};
/* 3 - the Close button that spawns another Close button */
const CL=['Close','Close','Close (this one)','Clothes','C l o s e','close, but lowercase','Close?','Cløse'];
const DEAD=['decoy','nope','nice try','not this one','that was a door','warmer…','so close'];
SC[3]=sc=>{
sc.innerHTML=`<div class="card t"><h1 class="o1">Almost there</h1><p class="o1">Just one tiny message from our sponsor. You can close it whenever you like.</p><div class="skel"></div><div class="skel s2"></div><div class="skel s3"></div><div class="skel s4"></div></div>`;
S.cl=0;S.clNeed=demo.on?2:6;
later(()=>{
layer.innerHTML=`<div class="dim"></div><div class="modal" style="--r:-1.4deg"><div class="env"></div><b class="o1">Subscribe to our newsletter about patience?</b><p class="o1">Weekly tips on waiting, delivered whenever we get around to it.</p></div>`;
offify(layer);spawnClose(true);
},450);
};
function spawnClose(first){
const real=S.cl>=S.clNeed,b=document.createElement('button');
b.type='button';b.className='btn cls t'+(real?' real':'');
b.innerHTML=`<span class="x">×</span> ${real?'Close (the real one, promise)':CL[S.cl%CL.length]}`;
if(!first&&!real)b.style.fontSize=pick([13,15,18,21])+'px';
layer.appendChild(b);
const bw=b.offsetWidth,bh=b.offsetHeight,m=$('.modal',layer);let x,y;
if(first&&m){const r=m.getBoundingClientRect();x=r.right-bw-16;y=r.bottom-bh-16;}
else{x=R(8,Math.max(8,innerWidth-bw-8));y=R(64,Math.max(64,innerHeight-bh-12));}
b.style.left=x+'px';b.style.top=y+'px';
b.style.setProperty('--r',(first?-1.5:R(-8,8)).toFixed(1)+'deg');
b.addEventListener('click',()=>{
if(b.classList.contains('dead')||layer.classList.contains('bye'))return;
S.closes++;
if(real){layer.classList.add('bye');toast('Newsletter declined. We will ask again later.');later(()=>go(4),600);return;}
b.classList.add('dead');b.textContent=DEAD[S.cl%DEAD.length];S.cl++;spawnClose(false);
});
}
/* 4 - select the straight squares (there are none) */
SC[4]=sc=>{
sc.innerHTML=`<div class="card t"><h1 class="o1">Quick security check</h1><p class="o1">To prove you are human, please select every square that is perfectly straight.</p><div class="grid" id="grid"></div><p class="status" id="st">Take your time. We are timing you.</p><div class="acts"><button class="btn g" id="none" type="button">None of them</button></div></div>`;
const grid=$('#grid',sc),st=$('#st',sc),none=$('#none',sc),cols=['#ffd9b0','#cfe6ff','#d7f3d7','#ffd3dd','#e6dcff','#fff0b0'];let taps=0;
for(let i=0;i<9;i++){
const a=Math.abs((Math.random()<.5?-1:1)*R(.6,3.4)).toFixed(1),sg=Math.random()<.5?'-':'',t=document.createElement('button');
t.type='button';t.className='tile t';t.style.setProperty('--r',sg+a+'deg');t.style.background=cols[i%6];
t.innerHTML=`<i class="k${1+Math.floor(Math.random()*4)}"></i><em></em>`;
t.addEventListener('click',()=>{const s=t.classList.toggle('sel');$('em',t).textContent=s?a+'° off':'';st.textContent=s?`Hmm. That one is ${a}° crooked.`:'Unselected. Good instinct.';if(++taps>=3)none.classList.add('pulse');});
grid.appendChild(t);
}
none.addEventListener('click',()=>{if(none.disabled)return;none.disabled=true;none.classList.remove('pulse');none.classList.add('ok');none.textContent='Correct!';st.textContent='Correct! Nothing on this page is straight. We are working on it.';later(()=>go(5),1400);});
};
/* 5 - thank you for your patience */
function confetti(){const box=$('#confetti'),cols=['#3b6ef5','#ff7a8a','#22a06b','#f2b632','#7b5cff'];box.innerHTML='';for(let i=0;i<26;i++){const p=document.createElement('i'),d=R(7,12);p.style.cssText=`left:${R(0,100).toFixed(1)}%;background:${pick(cols)};animation-duration:${d.toFixed(1)}s;animation-delay:${(-R(0,d)).toFixed(1)}s;--a:${R(0,360).toFixed(0)}deg;--x:${R(-40,40).toFixed(0)}px`;box.appendChild(p);}}
SC[5]=sc=>{
const s=Math.max(1,Math.round((Date.now()-S.t0)/1000)),tm=Math.floor(s/60)+':'+String(s%60).padStart(2,'0');
sc.innerHTML=`<div class="card t"><div class="cert t" data-r="1.3"><div class="seal t" data-r="-9">100%</div><small class="o1">Certificate of</small><h1 class="o1">Patience</h1>
<p class="o1">Thank you for your patience. Truly. You reached the end of the most comfortable page on the internet.</p>
<ul class="stats"><li><b>${S.dodges}</b> dodges endured</li><li><b>${S.cookies}</b> cookies accepted</li><li><b>${S.closes}</b> close buttons pressed</li><li><b>${S.slips}</b> progress relapses</li><li><b>${tm}</b> of your life, well spent</li></ul></div>
<p class="status" id="st">Something still feels a little off, doesn't it?</p>
<div class="acts"><button class="btn" id="fix" type="button">Straighten everything</button><button class="btn g" id="again" type="button">Start over</button></div></div>`;
confetti();
const fix=$('#fix',sc),st=$('#st',sc);
fix.addEventListener('click',()=>{if(body.classList.contains('straight'))return;body.classList.add('straight');st.textContent='Ahh. Everything is perfectly straight now. You earned this.';fix.textContent='Much better';fix.classList.add('ok');$('#steps').textContent='Step 6 of 6';clock();toast('Everything has been straightened. Breathe out.');});
$('#again',sc).addEventListener('click',resetAll);
};
function resetAll(){body.classList.remove('straight');Object.assign(S,{t0:Date.now(),dodges:0,cookies:0,closes:0,slips:0});$('#confetti').innerHTML='';moveSpeck();go(0);clock();}
/* gentle, optional, slightly out-of-tune hold music */
const M={on:false,ctx:null,out:null,next:0,i:0,iv:0};
const MEL=[0,4,7,11,9,7,4,2,0,4,7,12,11,9,7,-99,5,9,12,16,14,12,9,7,5,4,2,-1,0,-99,-99,-99],BASS=[0,-3,5,7];
function note(t,n,d,type,v){const c=M.ctx,o=c.createOscillator(),g=c.createGain();o.type=type;o.frequency.value=261.63*Math.pow(2,n/12);if(M.i%13===6)o.detune.value=38;g.gain.setValueAtTime(.0001,t);g.gain.linearRampToValueAtTime(v,t+.04);g.gain.exponentialRampToValueAtTime(.0001,t+d);o.connect(g);g.connect(M.out);o.start(t);o.stop(t+d+.05);}
function tick(){const c=M.ctx;if(!c)return;while(M.next<c.currentTime+.3){const n=MEL[M.i%MEL.length],b=.26*(M.i%8===7?1.16:1);if(n>-50)note(M.next,n,b*1.5,'triangle',.3);if(M.i%8===0)note(M.next,BASS[(M.i>>3)%4]-12,b*7,'sine',.35);M.next+=b;M.i++;}}
function music(){
try{
if(!M.ctx){const AC=window.AudioContext||window.webkitAudioContext;if(!AC){toast('No hold music available. Enjoy the silence.');return;}M.ctx=new AC();M.out=M.ctx.createGain();M.out.gain.value=0;const f=M.ctx.createBiquadFilter();f.type='lowpass';f.frequency.value=1600;M.out.connect(f);f.connect(M.ctx.destination);}
const c=M.ctx,g=M.out.gain;if(c.state==='suspended')c.resume();
M.on=!M.on;g.cancelScheduledValues(c.currentTime);g.setValueAtTime(g.value,c.currentTime);g.linearRampToValueAtTime(M.on?.06:0,c.currentTime+(M.on?2:.8));
clearInterval(M.iv);if(M.on){M.next=c.currentTime+.15;M.iv=setInterval(tick,80);}
$('#mus').textContent=M.on?'♪ Hold music: on':'♪ Hold music: off';
if(M.on)toast('Your call is important to us.');
}catch(e){}
}
$('#mus').addEventListener('click',music);
/* polite, pointless notifications */
const AMB=['Your changes have been saved.','No changes were made. Saved anyway.','We have updated our privacy policy. Slightly.','Reminder: you are doing great. Mostly.','Someone near you is also waiting.','Tip: patience is free.'];
function ambient(){if(!demo.on&&S.stage<5)toast(pick(AMB));setTimeout(ambient,R(24000,40000));}
/* #demo: hands-free loop, any real touch ends it */
const isDemo=()=>location.hash==='#demo'||/#demo$/.test(location.href);
async function runDemo(){
const tk=++demo.tok;demo.on=true;finger.style.display='block';tag.style.display='block';
const w=async ms=>{await sleep(ms);if(!demo.on||tk!==demo.tok)throw 0;};
const until=async(f,max=8000)=>{const t=Date.now();while(!f()){if(Date.now()-t>max)throw 1;await w(100);}};
const tap=async get=>{const el=typeof get==='function'?get():get;if(!el||!el.isConnected){await w(200);return;}let r=el.getBoundingClientRect();if(r.top<0||r.bottom>innerHeight){el.scrollIntoView({block:'center'});await w(250);r=el.getBoundingClientRect();}finger.style.left=r.left+r.width/2+'px';finger.style.top=r.top+r.height/2+'px';await w(320);finger.classList.add('tap');await w(110);finger.classList.remove('tap');el.click();await w(90);};
for(;;){
try{
resetAll();finger.style.left=innerWidth/2+'px';finger.style.top=innerHeight*.78+'px';
await w(650);
for(let i=0;i<6&&S.stage===0&&$('#start')&&!$('#start').disabled;i++)await tap(()=>$('#start'));
await until(()=>S.stage===1);await w(450);
for(let i=0;i<8&&S.stage===1;i++){const b=$$('.ck:not([data-gone]) .btn',layer);if(b.length)await tap(b[b.length-1]);else await w(200);}
await until(()=>S.stage===2);await w(400);
await tap(()=>$('#help'));
await until(()=>S.P&&S.P.mode==='stuck',9000);await w(250);
await tap(()=>$('#help'));await w(450);
await tap(()=>$('#help'));
await until(()=>S.stage===3);await until(()=>$('.cls',layer),3000);await w(250);
for(let i=0;i<7&&S.stage===3;i++){const b=$$('.cls:not(.dead)',layer);if(b.length&&!layer.classList.contains('bye'))await tap(b[b.length-1]);else await w(200);}
await until(()=>S.stage===4);await w(450);
await tap(()=>$$('.tile')[4]);await w(300);
await tap(()=>$('#none'));
await until(()=>S.stage===5,4000);await w(1000);
await tap(()=>$('#fix'));await w(2000);
}catch(e){if(e===0)return;}
}
}
function stopDemo(){demo.on=false;demo.tok++;finger.style.display='none';tag.style.display='none';resetAll();toast('Demo over. Your turn. Good luck!');}
let swallow=0;
addEventListener('pointerdown',e=>{if(e.isTrusted&&demo.on){stopDemo();swallow=Date.now()+650;e.preventDefault();e.stopPropagation();}},true);
addEventListener('click',e=>{if(e.isTrusted&&Date.now()<swallow){e.preventDefault();e.stopPropagation();}},true);
addEventListener('hashchange',()=>{if(isDemo()&&!demo.on)runDemo();});
tilt(document.querySelector('header'));offify(document.querySelector('header'));offify(document.querySelector('footer'));
resetAll();setInterval(clock,10000);setTimeout(ambient,18000);
if(isDemo())runDemo();
})();
</script>
</body>
</html>
