Skip to content
VibeCodeBench
Back to the app

The code

The Most Uncomfortable Web Page by Claude Haiku 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.)23.8 KB · 726 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">
<meta name="color-scheme" content="light dark">
<title>The Patience Test</title>
<style>
:root {
  --bg: #f5f0e6;
  --ink: #262433;
  --card: #fffdf8;
  --accent: #4f5bd5;
  --accent-ink: #ffffff;
  --alt: #fffdf8;
  --line: #d8cfbd;
  --muted: #6b6479;
  --shadow: rgba(40, 30, 60, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1b23;
    --ink: #f0ece3;
    --card: #27252f;
    --accent: #8d97f5;
    --accent-ink: #15142a;
    --alt: #2b2934;
    --line: #45424f;
    --muted: #aaa3b8;
    --shadow: rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #1c1b23;
  --ink: #f0ece3;
  --card: #27252f;
  --accent: #8d97f5;
  --accent-ink: #15142a;
  --alt: #2b2934;
  --line: #45424f;
  --muted: #aaa3b8;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 0 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-weight: 600; font-size: 15px;
}
h1 { font-size: clamp(26px, 6.5vw, 34px); line-height: 1.15; margin: 12px 0; }
p { margin: 0 0 12px; }
.note { color: var(--muted); min-height: 1.5em; font-size: 16px; }

.screen { display: none; }
.screen.active { display: block; animation: fadein 0.35s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .screen.active { animation: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; min-width: 140px; padding: 0 22px;
  border: 2px solid var(--accent); border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 700; font-size: 18px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 16px var(--shadow);
}
.btn:active { filter: brightness(0.94); }
.btn.alt { background: var(--alt); color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn.big { display: flex; width: 100%; min-height: 64px; font-size: 20px; margin: 8px 0; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }

.arena {
  position: relative; width: 100%; height: 180px; margin: 16px 0;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--card);
  overflow: hidden; touch-action: manipulation;
}
.arena.tall { height: 250px; }
.arena .btn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  transition: left 0.3s ease, top 0.3s ease, transform 0.3s ease;
}

.bar {
  height: 30px; margin: 18px 0 8px; border: 2px solid var(--line);
  border-radius: 999px; background: var(--card); overflow: hidden;
}
.fill { height: 100%; width: 0; background: var(--accent); transition: width 0.9s ease; }
.pct { font-size: 28px; font-weight: 700; }

.offpx { display: block; font-size: 22px; font-weight: 600; transform: translate(1px, -1px); margin: 16px 0; }

.tidy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.tile {
  display: flex; align-items: center; justify-content: center; min-height: 76px; padding: 6px;
  text-align: center; font-weight: 600; background: var(--card);
  border: 2px solid var(--line); border-radius: 14px; box-shadow: 0 4px 10px var(--shadow);
  transition: transform 0.6s ease; user-select: none;
}

.cookie {
  position: fixed; left: 50%; width: min(420px, calc(100vw - 32px)); padding: 14px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 30px var(--shadow);
  transform: translateX(-50%) rotate(var(--r, 0deg));
  z-index: 100;
}
.cookie p { font-size: 16px; margin: 0 0 10px; }
.cookie-row { display: flex; gap: 10px; }
.cookie-btn { flex: 1; min-width: 0; min-height: 50px; padding: 0 8px; font-size: 16px; }

.card {
  background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  padding: 16px; margin: 16px 0;
}
.stats { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }

.demo-badge {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line); color: var(--muted);
  font-size: 14px; text-align: center; box-shadow: 0 6px 16px var(--shadow); z-index: 300;
}
</style>
</head>
<body>
<div class="wrap">
  <div class="top">
    <span>The Patience Test</span>
    <span id="step">Step 1 of 6</span>
  </div>

  <section class="screen" id="s-welcome">
    <h1>Welcome to the Patience Test</h1>
    <p>Please get comfortable. This will be quick. (It will not be quick.)</p>
    <p class="note" id="returning" hidden></p>
    <div class="arena" id="arenaStart">
      <button class="btn" id="startBtn" type="button">Start</button>
    </div>
    <p class="note" id="startNote">Tap Start to begin.</p>
  </section>

  <section class="screen" id="s-load">
    <h1>Loading your patience</h1>
    <p>Please keep tapping. The bar is doing its best.</p>
    <div class="bar"><div class="fill" id="fill"></div></div>
    <p class="pct"><span id="pct">0</span>%</p>
    <p class="note" id="loadNote"></p>
    <button class="btn big" id="loadBtn" type="button">Load more</button>
  </section>

  <section class="screen" id="s-pixel">
    <h1>A quick visual check</h1>
    <p>Everything on this page is perfectly aligned.</p>
    <p class="offpx">Are you sure? Look again.</p>
    <p>Can you see that it is one pixel off?</p>
    <div class="row">
      <button class="btn" type="button" data-ans="yes">Yes</button>
      <button class="btn alt" type="button" data-ans="no">No</button>
      <button class="btn alt" type="button" data-ans="maybe">Maybe</button>
    </div>
    <p class="note" id="pixelNote"></p>
    <button class="btn" id="pixelNext" type="button" hidden>Continue</button>
  </section>

  <section class="screen" id="s-cookies">
    <h1>Almost there</h1>
    <p>Please review our terms. Also our cookies.</p>
    <p class="note" id="cookieNote"></p>
  </section>

  <section class="screen" id="s-close">
    <h1>Ready to leave?</h1>
    <p>This page would like to close. Please confirm by clicking Close.</p>
    <div class="arena tall" id="closeArena"></div>
    <p class="note" id="closeNote"></p>
  </section>

  <section class="screen" id="s-tidy">
    <h1>Tidy up</h1>
    <p>Please line everything up. It will only take a moment.</p>
    <div class="tidy-grid" id="tidyGrid"></div>
    <div class="row">
      <button class="btn" id="tidyBtn" type="button">Straighten up</button>
      <button class="btn" id="tidyNext" type="button" hidden>Continue</button>
    </div>
    <p class="note" id="tidyNote"></p>
  </section>

  <section class="screen" id="s-thanks">
    <h1>Thank you for your patience.</h1>
    <p>It has been recorded. Nowhere, but we are sure it counts.</p>
    <div class="card">
      <p>Patience score: <strong id="score">100</strong> / 100</p>
      <p class="note" id="scoreNote"></p>
      <ul class="stats">
        <li>Dodges: <span id="stDodges">0</span></li>
        <li>Slips at 99%: <span id="stSlips">0</span></li>
        <li>Cookie notices: <span id="stCookies">0</span></li>
        <li>Close clicks: <span id="stCloses">0</span></li>
        <li>Things straightened: <span id="stAligns">0</span></li>
      </ul>
    </div>
    <button class="btn" id="againBtn" type="button">Start over</button>
  </section>
</div>

<div class="demo-badge" id="demoBadge" hidden>Demo loop (about 20 seconds). Touch the screen to take over.</div>

<script>
(function () {
  'use strict';

  var ORDER = ['welcome', 'load', 'pixel', 'cookies', 'close', 'tidy', 'thanks'];
  var MAX_SLIPS = 3;
  var MAX_COOKIES = 11;
  var CLOSES_NEEDED = 5;
  var TIDY_NEEDED = 3;

  var START_LINES = [
    'Hm. It moved. Try again?',
    'Nope. It moved again.',
    'It really does not want to be clicked.',
    'Almost. Not quite.',
    'Okay. Fine. Tap it now.'
  ];
  var LOAD_LINES = [
    'Gathering patience...',
    'Almost there...',
    'Just a second...',
    'Still just a second...',
    'Loading. Loading. Loading.'
  ];
  var PIXEL_REPLIES = {
    yes: 'Liar. Nobody can see it. Nobody.',
    no: 'Look closer. It is there. Probably.',
    maybe: 'Correct. "Maybe" is the most honest answer.'
  };
  var COOKIE_LINES = [
    'We use cookies. Accept?',
    'Cookies are essential. Accept?',
    'Our cookies also use cookies.',
    'This notice has a notice. Accept?',
    'Please accept. Please.',
    'Cookies have been placed. Also these.',
    'Cookies, cookies, and more cookies.'
  ];
  var CLOSE_LABELS = ['Close', 'Close?', 'Close it', 'CLOSE', 'Close (really)', 'Close now'];
  var CLOSE_LINES = [
    'That made another Close. Click either one.',
    'They are multiplying. This is normal.',
    'Please keep closing.',
    'One more. We believe in you.',
    'Closed. Thank you for closing.'
  ];
  var TILE_NAMES = ['Inbox', 'Notes', 'Drafts', 'Photos', 'Music', 'Videos', 'Taxes', 'Recipes', 'Misc'];

  function $(sel) { return document.querySelector(sel); }
  function $$(sel) { return Array.prototype.slice.call(document.querySelectorAll(sel)); }
  function rand(a, b) { return a + Math.random() * (b - a); }
  function pick(arr) { return arr[Math.floor(Math.random() * arr.length)]; }

  var stats, cur = 0;
  var loadPct, slips, busy;
  var cookieSpawned, cookieLive, cookieDone;
  var closeClicks, closeDone;
  var aligns, tidyDone, tidyRevert = null;
  var timers = [];
  var demoOn = false, demoTimers = [];

  function later(fn, ms) {
    var id = setTimeout(fn, ms);
    timers.push(id);
    return id;
  }
  function clearTimers() {
    timers.forEach(function (id) { clearTimeout(id); });
    timers = [];
  }

  function freshState() {
    stats = { dodges: 0, slips: 0, cookies: 0, closes: 0, aligns: 0 };
    loadPct = 0; slips = 0; busy = false;
    cookieSpawned = 0; cookieLive = 0; cookieDone = false;
    closeClicks = 0; closeDone = false;
    aligns = 0; tidyDone = false;
  }

  var el = {
    step: $('#step'),
    arenaStart: $('#arenaStart'),
    startBtn: $('#startBtn'),
    startNote: $('#startNote'),
    returning: $('#returning'),
    fill: $('#fill'),
    pct: $('#pct'),
    loadNote: $('#loadNote'),
    loadBtn: $('#loadBtn'),
    pixelNote: $('#pixelNote'),
    pixelNext: $('#pixelNext'),
    cookieNote: $('#cookieNote'),
    closeArena: $('#closeArena'),
    closeNote: $('#closeNote'),
    tidyGrid: $('#tidyGrid'),
    tidyNote: $('#tidyNote'),
    tidyBtn: $('#tidyBtn'),
    tidyNext: $('#tidyNext'),
    score: $('#score'),
    scoreNote: $('#scoreNote'),
    stDodges: $('#stDodges'),
    stSlips: $('#stSlips'),
    stCookies: $('#stCookies'),
    stCloses: $('#stCloses'),
    stAligns: $('#stAligns'),
    againBtn: $('#againBtn'),
    demoBadge: $('#demoBadge')
  };

  var screens = {};
  ORDER.forEach(function (id) { screens[id] = document.getElementById('s-' + id); });

  // Moves a button to a random spot inside its arena, away from the pointer if given.
  function moveAway(btn, arena, px, py) {
    var aw = arena.clientWidth, ah = arena.clientHeight;
    var bw = btn.offsetWidth, bh = btn.offsetHeight;
    var maxX = Math.max(4, aw - bw - 4), maxY = Math.max(4, ah - bh - 4);
    var box = arena.getBoundingClientRect();
    var x = 4, y = 4;
    for (var i = 0; i < 40; i++) {
      x = rand(4, maxX);
      y = rand(4, maxY);
      if (px == null) break;
      var dx = x + bw / 2 - (px - box.left);
      var dy = y + bh / 2 - (py - box.top);
      if (Math.sqrt(dx * dx + dy * dy) > 120) break;
    }
    btn.style.transform = 'none';
    btn.style.left = Math.round(x) + 'px';
    btn.style.top = Math.round(y) + 'px';
  }

  // A button that dodges a finger or mouse a limited number of times, then gives up.
  function setupDodgy(btn, arena, max, onMove) {
    btn._max = max;
    btn._left = max;
    btn._last = 0;
    btn._attempt = function (px, py) {
      if (btn._left <= 0) return false;
      btn._left -= 1;
      stats.dodges += 1;
      moveAway(btn, arena, px, py);
      if (onMove) onMove(btn._max - btn._left);
      return true;
    };
    btn.addEventListener('pointerdown', function (e) {
      if (btn._attempt(e.clientX, e.clientY)) e.preventDefault();
    });
    btn.addEventListener('pointerenter', function (e) {
      if (e.pointerType !== 'mouse') return;
      var now = Date.now();
      if (now - btn._last < 900) return;
      btn._last = now;
      btn._attempt(e.clientX, e.clientY);
    });
  }
  function resetDodgy(btn) {
    btn._left = btn._max;
    btn.style.transform = '';
    btn.style.left = '';
    btn.style.top = '';
  }

  setupDodgy(el.startBtn, el.arenaStart, 5, function (used) {
    el.startNote.textContent = START_LINES[Math.min(used, START_LINES.length) - 1];
  });
  el.startBtn.addEventListener('click', function () { next(); });

  // Progress bar that slides back at 99%.
  function renderLoad() {
    el.fill.style.width = loadPct + '%';
    el.pct.textContent = String(loadPct);
  }
  function loadTick() {
    if (busy) return;
    loadPct = Math.floor(Math.min(100, loadPct + rand(9, 16)));
    if (loadPct >= 99 && slips >= MAX_SLIPS) loadPct = 100;
    if (loadPct >= 100) {
      busy = true;
      renderLoad();
      el.loadNote.textContent = 'Done. Thank you for your patience.';
      later(next, 1300);
      return;
    }
    if (loadPct >= 99) {
      busy = true;
      loadPct = 99;
      renderLoad();
      el.loadNote.textContent = '99%. So close. Hold on.';
      later(function () {
        slips += 1;
        stats.slips += 1;
        loadPct = Math.floor(rand(64, 80));
        renderLoad();
        el.loadNote.textContent = slips === 1
          ? 'Oops. Slipped back. It happens.'
          : (slips === 2 ? 'It slipped again. Same as before.' : 'Slipped back. The bar is like that now.');
        busy = false;
      }, 1100);
      return;
    }
    renderLoad();
    el.loadNote.textContent = LOAD_LINES[Math.min(LOAD_LINES.length - 1, Math.floor(loadPct / 25))];
  }
  el.loadBtn.addEventListener('click', loadTick);

  // One-pixel-off question.
  Array.prototype.forEach.call($$('[data-ans]'), function (b) {
    b.addEventListener('click', function () {
      el.pixelNote.textContent = PIXEL_REPLIES[b.getAttribute('data-ans')];
      el.pixelNext.hidden = false;
    });
  });
  el.pixelNext.addEventListener('click', function () { next(); });

  // Cookie notices that multiply.
  function spawnCookie() {
    cookieSpawned += 1;
    cookieLive += 1;
    stats.cookies += 1;
    var c = document.createElement('div');
    c.className = 'cookie';
    c.style.top = Math.round(rand(14, 58)) + 'vh';
    c.style.setProperty('--r', rand(-2.4, 2.4).toFixed(2) + 'deg');
    c.style.zIndex = String(100 + cookieSpawned);
    var p = document.createElement('p');
    p.textContent = pick(COOKIE_LINES) + ' (cookie #' + cookieSpawned + ')';
    var row = document.createElement('div');
    row.className = 'cookie-row';
    var yes = document.createElement('button');
    yes.type = 'button';
    yes.className = 'btn cookie-btn';
    yes.textContent = 'Accept';
    var no = document.createElement('button');
    no.type = 'button';
    no.className = 'btn alt cookie-btn';
    no.textContent = 'Decline';
    yes.addEventListener('click', function () { dismissCookie(c); });
    no.addEventListener('click', function () { dismissCookie(c); });
    row.appendChild(yes);
    row.appendChild(no);
    c.appendChild(p);
    c.appendChild(row);
    document.body.appendChild(c);
  }
  function dismissCookie(c) {
    if (c._gone || cookieDone) return;
    c._gone = true;
    if (c.parentNode) c.parentNode.removeChild(c);
    cookieLive -= 1;
    if (cookieSpawned < MAX_COOKIES) {
      spawnCookie();
      spawnCookie();
    }
    if (cookieLive <= 0) {
      cookieDone = true;
      el.cookieNote.textContent = 'All cookies accepted. Thank you.';
      later(next, 800);
    } else {
      el.cookieNote.textContent = cookieLive + ' cookie notice' + (cookieLive === 1 ? '' : 's') + ' still open.';
    }
  }
  function removeCookies() {
    $$('.cookie').forEach(function (c) {
      if (c.parentNode) c.parentNode.removeChild(c);
    });
  }

  // A Close button that spawns another Close button.
  function addCloseButton(label) {
    var b = document.createElement('button');
    b.type = 'button';
    b.className = 'btn close-btn';
    b.textContent = label;
    el.closeArena.appendChild(b);
    moveAway(b, el.closeArena);
    b.addEventListener('click', onCloseClick);
  }
  function onCloseClick() {
    if (closeDone) return;
    closeClicks += 1;
    stats.closes += 1;
    if (closeClicks >= CLOSES_NEEDED) {
      closeDone = true;
      el.closeNote.textContent = CLOSE_LINES[CLOSE_LINES.length - 1];
      later(next, 900);
      return;
    }
    el.closeNote.textContent = CLOSE_LINES[closeClicks - 1];
    addCloseButton(CLOSE_LABELS[closeClicks % CLOSE_LABELS.length]);
  }

  // Crooked tidy tiles.
  function crookedOf(t) {
    return 'translate(' + t._x + 'px, ' + t._y + 'px) rotate(' + t._r + 'deg)';
  }
  function buildTiles() {
    el.tidyGrid.innerHTML = '';
    TILE_NAMES.forEach(function (name) {
      var t = document.createElement('div');
      t.className = 'tile';
      t.textContent = name;
      t._x = rand(-3, 3).toFixed(1);
      t._y = rand(-3, 3).toFixed(1);
      t._r = ((Math.random() < 0.5 ? -1 : 1) * rand(1, 2.6)).toFixed(2);
      t.style.transform = crookedOf(t);
      el.tidyGrid.appendChild(t);
    });
  }
  function setTiles(straight) {
    Array.prototype.forEach.call(el.tidyGrid.children, function (t) {
      t.style.transform = straight ? 'none' : crookedOf(t);
    });
  }
  el.tidyBtn.addEventListener('click', function () {
    if (tidyDone) return;
    aligns += 1;
    stats.aligns += 1;
    clearTimeout(tidyRevert);
    setTiles(true);
    if (aligns >= TIDY_NEEDED) {
      tidyDone = true;
      el.tidyNote.textContent = 'They stay straight now. Please continue.';
      el.tidyBtn.hidden = true;
      el.tidyNext.hidden = false;
      return;
    }
    el.tidyNote.textContent = 'Straight! For 1.5 seconds. (' + (TIDY_NEEDED - aligns) + ' more to keep them.)';
    tidyRevert = later(function () {
      setTiles(false);
      el.tidyNote.textContent = 'They have slipped back. Try again.';
    }, 1500);
  });
  el.tidyNext.addEventListener('click', function () { next(); });

  el.againBtn.addEventListener('click', function () { resetAll(); });

  // Screen flow.
  var ENTER = {
    welcome: function () {
      resetDodgy(el.startBtn);
      el.startNote.textContent = 'Tap Start to begin.';
    },
    load: function () {
      loadPct = 0; slips = 0; busy = false;
      renderLoad();
      el.loadNote.textContent = LOAD_LINES[0];
    },
    pixel: function () {
      el.pixelNote.textContent = '';
      el.pixelNext.hidden = true;
    },
    cookies: function () {
      cookieSpawned = 0; cookieLive = 0; cookieDone = false;
      el.cookieNote.textContent = 'Please respond to the cookie notice.';
      spawnCookie();
    },
    close: function () {
      el.closeArena.innerHTML = '';
      closeClicks = 0; closeDone = false;
      el.closeNote.textContent = 'Click "Close" to close.';
      addCloseButton('Close');
    },
    tidy: function () {
      buildTiles();
      aligns = 0; tidyDone = false;
      el.tidyBtn.hidden = false;
      el.tidyNext.hidden = true;
      el.tidyNote.textContent = 'Please line everything up. Use the button.';
    },
    thanks: function () {
      var score = Math.max(42, 100 - stats.dodges * 2 - stats.slips * 4 - stats.closes * 2 - Math.floor(stats.cookies / 2));
      el.score.textContent = String(score);
      el.scoreNote.textContent = score === 100 ? 'A perfect score. Suspicious.'
        : (score === 42 ? 'Lowest score allowed. We are fair.'
        : (score >= 70 ? 'Very good. You waited well.' : 'Honest. You waited anyway.'));
      el.stDodges.textContent = String(stats.dodges);
      el.stSlips.textContent = String(stats.slips);
      el.stCookies.textContent = String(stats.cookies);
      el.stCloses.textContent = String(stats.closes);
      el.stAligns.textContent = String(stats.aligns);
    }
  };

  function removeCookiesAndShow(id) {
    clearTimers();
    clearTimeout(tidyRevert);
    removeCookies();
    cur = ORDER.indexOf(id);
    ORDER.forEach(function (k) { screens[k].classList.toggle('active', k === id); });
    el.step.textContent = id === 'thanks' ? 'Done' : 'Step ' + (cur + 1) + ' of ' + (ORDER.length - 1);
    window.scrollTo(0, 0);
    ENTER[id]();
  }
  function show(id) { removeCookiesAndShow(id); }
  function next() {
    if (cur < ORDER.length - 1) show(ORDER[cur + 1]);
  }
  function resetAll() {
    clearTimers();
    freshState();
    show('welcome');
  }

  // Hands-free demo loop for #demo.
  function demoClickCookie() {
    var list = $$('.cookie');
    if (!list.length) return;
    var btns = list[list.length - 1].querySelectorAll('.cookie-btn');
    if (btns.length > 1) btns[1].click();
  }
  function demoClickFirstClose() {
    var b = el.closeArena.querySelector('.close-btn');
    if (b) b.click();
  }
  function demoClickPixel(ans) {
    var b = document.querySelector('[data-ans="' + ans + '"]');
    if (b) b.click();
  }
  var DEMO_STEPS = [
    [600, function () { el.startBtn._attempt(); }],
    [1200, function () { el.startBtn._attempt(); }],
    [1800, function () { el.startBtn._attempt(); }],
    [2500, function () { el.startBtn.click(); }],
    [3100, function () { loadPct = 90; renderLoad(); el.loadBtn.click(); }],
    [4900, function () { next(); }],
    [5600, function () { demoClickPixel('no'); }],
    [6200, function () { el.pixelNext.click(); }],
    [6900, demoClickCookie],
    [7400, demoClickCookie],
    [7900, demoClickCookie],
    [8400, demoClickCookie],
    [8900, function () { next(); }],
    [9400, demoClickFirstClose],
    [9700, demoClickFirstClose],
    [10000, demoClickFirstClose],
    [10300, demoClickFirstClose],
    [10600, demoClickFirstClose],
    [11600, function () { el.tidyBtn.click(); }],
    [13200, function () { el.tidyBtn.click(); }],
    [14800, function () { el.tidyBtn.click(); }],
    [15800, function () { el.tidyNext.click(); }],
    [20000, function () { demoLoop(); }]
  ];
  function clearDemoTimers() {
    demoTimers.forEach(function (id) { clearTimeout(id); });
    demoTimers = [];
  }
  function demoLoop() {
    clearDemoTimers();
    if (!demoOn) return;
    resetAll();
    DEMO_STEPS.forEach(function (s) {
      demoTimers.push(setTimeout(function () {
        if (demoOn) s[1]();
      }, s[0]));
    });
  }
  function startDemo() {
    demoOn = true;
    el.demoBadge.hidden = false;
    demoLoop();
  }
  function endDemo() {
    if (!demoOn) return;
    demoOn = false;
    clearDemoTimers();
    el.demoBadge.hidden = true;
    resetAll();
  }
  function onRealTouch(e) {
    if (demoOn && e.isTrusted) endDemo();
  }
  window.addEventListener('pointerdown', onRealTouch, true);
  window.addEventListener('touchstart', onRealTouch, { capture: true, passive: true });

  function init() {
    freshState();
    var visits = 0;
    try {
      visits = (parseInt(window.localStorage.getItem('pt-visits') || '0', 10) || 0) + 1;
      window.localStorage.setItem('pt-visits', String(visits));
    } catch (err) {
      visits = 0;
    }
    if (visits > 1) {
      el.returning.textContent = 'Welcome back. This is visit ' + visits + '. We remember you. Please stay.';
      el.returning.hidden = false;
    }
    show('welcome');
    var wantDemo = false;
    try {
      wantDemo = /#demo$/i.test(window.location.href);
    } catch (err) {
      wantDemo = false;
    }
    if (wantDemo) startDemo();
  }

  init();
})();
</script>
</body>
</html>