:root {
  --paper: #f6f3ec;
  --paper-2: #efeadf;
  --line: #ddd5c4;
  --ink: #1b2a63;
  --ink-soft: #4a5679;
  --blue: #3461a8;
  --sky: #5b8fc6;
  --sky-wash: #e3ecf7;
  --amber: #e8892b;
  --error: #b3261e;
  --radius: 14px;
  --hand: 'Caveat', 'Bradley Hand', cursive;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 400 16px/1.5 var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  /* faint graph-paper dots */
  background-image: radial-gradient(circle, rgba(27, 42, 99, .09) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
main { flex: 1; width: 100%; max-width: 460px; margin: 0 auto; padding: 20px 16px 8px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- Shared ---------- */
.brand svg { display: block; width: min(260px, 72vw); height: auto; margin: 0 0 22px -2px; }
.brand.small svg { width: 190px; }
.title {
  font-size: clamp(30px, 8.6vw, 38px);
  line-height: 1.08;
  letter-spacing: -.02em;
  font-weight: 700;
  margin: 0 0 12px;
}
.scribble {
  position: relative;
  white-space: nowrap;
  /* hand-drawn underline */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M3 9 C 40 3, 90 4, 130 7 S 185 10, 197 5' fill='none' stroke='%235b8fc6' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") bottom / 100% .32em no-repeat;
  padding-bottom: .12em;
}
.lede { color: var(--ink-soft); margin: 0 0 22px; }
.note { font-family: var(--hand); font-size: 22px; line-height: 1; color: var(--blue); }
.center { text-align: center; }
.fineprint { font-size: 13.5px; color: var(--ink-soft); margin: 14px 0 0; }

/* ---------- Form ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span:first-child { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
input[type="email"], input:not([type]) {
  width: 100%;
  font: inherit;
  font-size: 17px; /* ≥16px stops iOS zoom */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px var(--sky-wash); }
input[aria-invalid="true"] { border-color: var(--error); }

.email-wrap { position: relative; display: block; }
.email-wrap input { padding-right: 86px; }
.email-suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: 17px; pointer-events: none;
}
.email-wrap.full .email-suffix { display: none; }
.email-wrap.full input { padding-right: 14px; }

.check { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; cursor: pointer; font-size: 15.5px; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  border: 1.5px solid var(--line); background: #fff;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box::after {
  content: ''; width: 6px; height: 11px; margin-top: -2px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.check input:focus-visible + .box { box-shadow: 0 0 0 4px var(--sky-wash); }

.error { color: var(--error); font-size: 14.5px; margin: 10px 0 0; }

.level-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 26px 0 10px; flex-wrap: wrap; }
.level-head h2 { font-size: 18px; margin: 0; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 16px 12px 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform .08s, box-shadow .08s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.level:nth-child(2) { box-shadow: 3px 3px 0 var(--blue); border-color: var(--blue); }
.level:nth-child(3) { box-shadow: 3px 3px 0 var(--sky); border-color: var(--sky); }
.level:active, .level.busy { transform: translate(3px, 3px); box-shadow: 0 0 0 transparent; }
.level:disabled { cursor: default; opacity: .55; }
.level.busy { opacity: 1; background: var(--sky-wash); }
.level-name { font-weight: 700; font-size: 17px; }
.level-sub { font-family: var(--hand); font-size: 19px; color: var(--ink-soft); line-height: 1.1; }

/* ---------- Question ---------- */
.q-top { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; }
.pill {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 5px 10px; border-radius: 99px; background: var(--ink); color: #fff;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
.timer.low { color: var(--amber); }
.timebar { height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; margin-bottom: 26px; }
.timebar span { display: block; height: 100%; width: 100%; background: var(--blue); border-radius: inherit; transform-origin: left; }
.timebar.low span { background: var(--amber); }
.question { font-size: clamp(22px, 6.2vw, 26px); line-height: 1.25; margin: 0 0 22px; letter-spacing: -.01em; }
.options { display: grid; gap: 10px; margin-bottom: 18px; }
.option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px; text-align: left; font-size: 17px;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.option:active { background: var(--sky-wash); }
.option .key {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: var(--paper-2);
}
.option.picked { border-color: var(--ink); background: var(--sky-wash); }
.option.picked .key { background: var(--ink); color: #fff; }
.options.locked .option:not(.picked) { opacity: .45; }

/* ---------- Result (volunteer-facing) ---------- */
body.on-result { background: var(--ink); }
body.on-result .foot { display: none; }
body.on-result main { max-width: none; padding: 0; }
.result { position: relative; min-height: 100dvh; overflow: hidden; color: #fff; display: flex; }
.result-bg {
  position: absolute; inset: -50%;
  /* chevron stripes from the logo, always moving so screenshots are obvious */
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.07) 0 26px, transparent 26px 64px);
  animation: drift 3s linear infinite;
}
.result.one { background: var(--amber); color: #2b1600; }
.result.one .result-bg { background: repeating-linear-gradient(-45deg, rgba(255,255,255,.18) 0 26px, transparent 26px 64px); }
.result.two { background: var(--ink); }
@keyframes drift { to { transform: translate(90.5px, 0); } }
.result-inner {
  position: relative; width: 100%; max-width: 460px; margin: auto;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}
.result-kicker { font-family: var(--hand); font-size: 30px; margin: 0 0 4px; line-height: 1.1; }
.choc { font-size: 72px; line-height: 1.1; letter-spacing: 6px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.result-count { font-size: clamp(40px, 13vw, 58px); font-weight: 700; letter-spacing: -.02em; line-height: 1; margin: 8px 0 6px; text-transform: uppercase; }
.result-show { margin: 0 0 22px; opacity: .85; }
.live {
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums; font-size: 15px;
  padding: 8px 14px; border-radius: 99px; background: rgba(0,0,0,.18);
  margin-bottom: 22px;
}
.live b { letter-spacing: .12em; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #5fe08f; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.hold {
  position: relative; overflow: hidden; display: block; width: 100%;
  padding: 18px 16px; border: 0; border-radius: var(--radius);
  background: #fff; color: var(--ink); font-weight: 700; font-size: 16px;
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.result.one .hold { color: #2b1600; }
.hold-fill { position: absolute; inset: 0; background: #5fe08f; transform: scaleX(0); transform-origin: left; }
.hold.holding .hold-fill { transform: scaleX(1); transition: transform 1s linear; }
.hold-label { position: relative; }

.answer { margin-top: 20px; text-align: left; background: rgba(0,0,0,.16); border-radius: var(--radius); padding: 12px 16px; }
.answer summary { cursor: pointer; font-weight: 500; }
.answer p { margin: 8px 0 0; }

/* ---------- Done ---------- */
.event {
  position: relative; background: #fff; border: 1.5px solid var(--ink);
  border-radius: var(--radius); padding: 22px 18px 16px; margin: 6px 0 18px;
  box-shadow: 4px 4px 0 var(--sky);
}
.event .tilt { position: absolute; top: -14px; left: 14px; background: var(--paper); padding: 0 6px; transform: rotate(-3deg); }
.event h3 { margin: 0 0 6px; font-size: 20px; }
.event p { margin: 2px 0; color: var(--ink-soft); }
.btn {
  display: block; text-align: center; text-decoration: none; font-weight: 700;
  background: var(--ink); color: #fff; padding: 15px; border-radius: var(--radius);
}
.link { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; cursor: pointer; font-size: inherit; }

.loading { text-align: center; color: var(--ink-soft); margin-top: 30vh; }

/* ---------- Footer ---------- */
.foot { text-align: center; font-size: 12.5px; color: var(--ink-soft); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.foot p { margin: 2px 0; }

/* ---------- Motion ---------- */
.screen:not(.result) { animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .screen:not(.result), .choc { animation: none; }
  .result-bg { animation-duration: 8s; } /* keep it moving: it's the anti-screenshot signal */
}
