@font-face { font-family: 'Comic Neue'; src: url(/fonts/comic-neue-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Comic Neue'; src: url(/fonts/comic-neue-700.woff2) format('woff2'); font-weight: 700 900; font-display: swap; }
@font-face { font-family: 'Black Ops One'; src: url(/fonts/black-ops-one.woff2) format('woff2'); font-display: block; }

:root {
  --bg: #ecebe6; --ink: #1f1d1a; --muted: #6b675f; --line: #d3d1ca;
  --brand: #4b3bbf; --brand-2: #3a2d9a; --gold: #f2b705; --red: #d62839; --green: #2b8a3e;
  --comic: 'Comic Sans MS', 'Comic Neue', 'Chalkboard SE', cursive;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column; align-items: center;
  padding: max(20px, 6vh) 12px 24px; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
#app { width: 100%; max-width: 400px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- home widget ---------- */
.widget {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 78px;
  padding: 10px 12px 10px 14px; background: #f9f9f7; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .08);
}
.check { display: flex; align-items: center; gap: 12px; padding: 8px 0; border: 0; background: none; font-size: 15px; text-align: left; cursor: pointer; }
.cb { flex: none; width: 28px; height: 28px; border: 2px solid #b9b6ae; border-radius: 3px; background: #fff; }
.check:hover .cb { border-color: #8f8b82; }
.check.busy .cb { border: 3px solid var(--brand); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.brand { display: grid; justify-items: center; gap: 1px; text-align: center; color: var(--muted); }
.brand b { font-size: 11px; letter-spacing: .08em; color: var(--ink); }
.brand small { font-size: 9px; }
.mark { display: block; width: 28px; height: 28px; }
.home { margin-top: 12vh; }
.global { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.note { margin: 0 0 12px; padding: 10px 12px; font-size: 14px; background: #fff7d6; border: 1px solid #f0d77a; border-radius: 6px; }

/* ---------- captcha card ---------- */
.cap {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  box-shadow: 0 2px 12px rgb(0 0 0 / .08); rotate: var(--tilt, 0deg);
}
.cap-head { padding: 14px 16px 16px; background: var(--brand); color: #fff; }
.cap-head small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.cap-head h1 { margin: 4px 0 0; font-size: 22px; line-height: 1.2; font-weight: 600; outline: none; overflow-wrap: anywhere; }
.cap-head h1 b { font-weight: 800; }
.cap-sub { margin: 6px 0 0; font-size: 13px; opacity: .85; }
.cap-body { padding: 12px; animation: in .25s ease both; }
.cap-msg { min-height: 1.4em; margin: 0; padding: 0 14px 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.cap-msg.bad { color: var(--red); }
.cap-msg.good { color: var(--green); }
.cap-foot { padding: 10px 12px 12px; border-top: 1px solid #eeede9; }
.bar { height: 6px; overflow: hidden; background: #ece9f8; border-radius: 3px; }
.bar i { display: block; width: 0; height: 100%; background: var(--brand); transition: width .5s; }
.cap-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; margin: 6px 0 10px; font-size: 12px; color: var(--muted); }
.cap-actions { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.locked .cap-body, .locked .cap-actions { pointer-events: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 12px 22px;
  border: 0; border-radius: 4px; font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-2); }
.btn.ghost { background: #f1f0ec; border: 1px solid var(--line); color: var(--ink); }
.btn.big { flex: 1; padding: 16px 28px; font-size: 20px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.wa { background: #1f8f4e !important; }
.row { display: flex; gap: 8px; }
.row.center { justify-content: center; }
.field { width: 100%; padding: 12px; font: inherit; font-size: 18px; background: #fff; border: 1px solid #bdb9b0; border-radius: 4px; }
.field:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.field.big { font-size: 32px; font-weight: 700; letter-spacing: .1em; text-align: center; }

/* ---------- levels ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; border: 0; background: #efe9dc; cursor: pointer; touch-action: manipulation; }
.tile > * { transition: scale .12s; }
.tile .potato { width: 82%; }
.tile[aria-pressed='true'] { box-shadow: inset 0 0 0 3px var(--brand); }
.tile[aria-pressed='true'] > * { scale: .8; }
.tile[aria-pressed='true']::after {
  content: '✓'; position: absolute; top: 4px; left: 4px; display: grid; place-items: center; width: 22px; height: 22px;
  font-size: 14px; font-weight: 800; color: #fff; background: var(--brand); border-radius: 50%;
}
.emoji .tile span { font-size: clamp(36px, 11vw, 52px); line-height: 1; }
.deal .tile { animation: pop .3s ease both; }

.arena {
  position: relative; height: 230px; overflow: hidden; touch-action: none; border: 1px dashed var(--line); border-radius: 6px;
  background: repeating-linear-gradient(45deg, #faf9f6 0 10px, #f4f2ec 10px 20px);
}
.runner {
  position: absolute; display: flex; align-items: center; gap: 10px; padding: 12px 14px; white-space: nowrap; cursor: pointer;
  background: #f9f9f7; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 1px 2px rgb(0 0 0 / .1);
  transition: left .18s ease, top .18s ease;
}
.runner .cb { width: 24px; height: 24px; }
.runner[aria-checked='true'] .cb { background: var(--green); border-color: var(--green); }
.runner.tired { animation: pant 1s ease-in-out infinite; }

.distort { height: 90px; margin-bottom: 10px; overflow: hidden; border-radius: 4px; background: linear-gradient(135deg, #dcd7ca, #efe9dc 40%, #d5cfc0); }
.distort svg { display: block; width: 100%; height: 100%; }
.distort path { fill: none; stroke: #7c7668; stroke-width: 1.6; opacity: .55; }

.tapper {
  display: grid; place-content: center; gap: 2px; width: 100%; height: 200px; border: 0; border-radius: 12px; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #6d5ce0, var(--brand)); color: #fff;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.tapper b { font-size: 72px; line-height: 1; font-variant-numeric: tabular-nums; }
.tapper small { font-size: 16px; opacity: .8; }

.rotor { display: grid; place-items: center; height: 200px; touch-action: none; cursor: grab; background: radial-gradient(circle, #f6f2e8 0 58%, transparent 59%); }
.spin { width: 170px; transition: rotate .08s; }
.spin .potato { display: block; width: 100%; }
.rotor + .row .btn { font-size: 22px; padding: 8px 20px; }

.still { display: grid; place-items: center; padding: 18px 0; }
.ring { --p: 0deg; display: grid; place-items: center; width: 150px; height: 150px; border-radius: 50%; background: conic-gradient(var(--brand) var(--p), #ece9f8 0); }
.ring b { display: grid; place-items: center; width: 120px; height: 120px; font-size: 56px; background: #fff; border-radius: 50%; font-variant-numeric: tabular-nums; }

.slider { padding: 18px 4px 6px; }
.slider input { width: 100%; height: 36px; accent-color: var(--brand); }
.scale { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.slider output { display: block; margin-top: 14px; font-size: 18px; font-weight: 700; text-align: center; }

.final p { margin: 10px 0 18px; font-size: 30px; font-weight: 800; text-align: center; }

/* ---------- the end ---------- */
.log { margin: 0 0 6px; padding: 0; list-style: none; font: 13px/1.6 ui-monospace, Menlo, monospace; color: var(--muted); }
.log li { animation: in .3s both; }
.nick { display: grid; gap: 8px; margin-top: 10px; }
.prelim { margin: 4px 0 6px; font-size: 18px; }
.nick label { font-size: 14px; font-weight: 700; }
.nick label small { font-weight: 400; color: var(--muted); }
.nick .cap-msg { padding: 0; }
.ts:empty { display: none; }

.cert .cap-head { background: #262230; }
.cert-body { padding: 18px 16px 6px; text-align: center; }
.stamp-wrap { display: grid; place-items: center; padding: 8px 0 4px; }
.stamp {
  padding: 10px 18px 8px; font: clamp(34px, 11vw, 46px)/.95 'Black Ops One', Impact, 'Arial Black', sans-serif;
  letter-spacing: .04em; text-transform: uppercase; color: var(--red); rotate: -9deg; mix-blend-mode: multiply;
  border: 5px solid currentColor; border-radius: 8px; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.9'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.9'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stamp.slam { animation: slam .5s cubic-bezier(.2, .8, .3, 1.15) both; }
.awarded { margin: 14px 0 4px; font-size: 14px; color: var(--muted); }
.awarded b { display: block; font-size: 18px; color: var(--ink); overflow-wrap: anywhere; }
.score { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
.score b { font-size: 72px; font-weight: 900; line-height: 1; letter-spacing: -.03em; }
.score span { font-size: 13px; font-weight: 700; color: var(--muted); text-align: left; }
.rank { display: inline-block; margin: 8px 0 14px; padding: 6px 12px; font-size: 15px; font-weight: 800; background: #fff4cc; border: 1px solid #f0d77a; border-radius: 999px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.facts div { padding: 8px 6px; background: #f6f5f1; border-radius: 6px; }
.facts dt { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 800; }
.worst-stat { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.vs { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 6px; padding: 12px; background: #f1effb; border-radius: 8px; }
.vs div { display: grid; min-width: 90px; }
.vs small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.vs b { font-size: 40px; line-height: 1.1; }
.vs span { font-weight: 800; color: var(--muted); }
.verdict { margin: 6px 0 14px; font-weight: 700; }
.cap-actions.stack { display: grid; gap: 8px; padding: 12px 16px 16px; }
.stack .row > * { flex: 1; }

.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 28px; font-size: 12px; color: var(--muted); }
#sound { padding: 6px 10px; background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }

/* ---------- chaos: boring at level 1, unhinged by level 10 ---------- */
body[data-chaos='4'] { --tilt: -.5deg; }
body[data-chaos='5'] { --tilt: .8deg; }
body[data-chaos='6'] { --tilt: -1.2deg; }
body[data-chaos='7'] { --tilt: 1.5deg; --wobble: 4s; }
body[data-chaos='8'] { --tilt: -1.5deg; --wobble: 3s; }
body[data-chaos='9'] { --tilt: 2deg; --wobble: 2.4s; }
body[data-chaos='10'] { --tilt: -2.5deg; --wobble: 1.8s; background-image: radial-gradient(#c8915a33 18%, transparent 19%); background-size: 28px 28px; }
body[data-chaos='7'] .cap, body[data-chaos='8'] .cap, body[data-chaos='9'] .cap, body[data-chaos='10'] .cap { animation: wobble var(--wobble) ease-in-out infinite; }
body[data-chaos='8'] .cap, body[data-chaos='9'] .cap, body[data-chaos='10'] .cap { font-family: var(--comic); }
body[data-chaos='9'] .cap-head, body[data-chaos='10'] .cap-head { background: linear-gradient(100deg, var(--brand), var(--red) 60%, var(--gold)); }
body[data-chaos='10'] .cap-head h1 { font-size: 24px; font-weight: 800; }
.shake { animation: shake .35s; }

@keyframes in { from { opacity: 0; translate: 0 6px; } }
@keyframes pop { from { opacity: 0; scale: .6; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes pant { 50% { scale: .95; } }
@keyframes wobble { 0%, 100% { transform: rotate(-.8deg); } 50% { transform: rotate(.8deg); } }
@keyframes shake { 20% { translate: -8px 0; } 40% { translate: 7px 0; } 60% { translate: -5px 0; } 80% { translate: 3px 0; } }
@keyframes slam { 0% { opacity: 0; scale: 3.2; } 65% { opacity: 1; scale: .93; } 100% { opacity: 1; scale: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
