:root {
  color-scheme: light;
  --zf-bg: #eef1f7;
  --zf-panel: #ffffff;
  --zf-ink: #1c2333;
  --zf-muted: #64708a;
  --zf-line: #d9dfeb;
  --zf-blue: #3b5bfd;
  --zf-blue-dark: #2743d6;
  --zf-green: #17a463;
  --zf-red: #e5484d;
  --zf-gold: #f5b301;
  --zf-shadow: 0 10px 30px rgba(28, 35, 51, 0.14);
  --zf-radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% -5%, rgba(59, 91, 253, 0.14), transparent 30rem),
    radial-gradient(circle at 110% 20%, rgba(245, 179, 1, 0.1), transparent 24rem),
    var(--zf-bg);
  color: var(--zf-ink);
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
}

.zf-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 14px;
}

/* ---------- fake corporate header ---------- */

.zf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 10px;
}

.zf-logo {
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: -0.01em;
}

.zf-logo b {
  font-weight: 800;
  color: var(--zf-blue);
}

.zf-plus {
  display: inline-block;
  margin-left: 2px;
  color: var(--zf-gold);
  font-weight: 900;
  transform: rotate(8deg);
}

.zf-fake-nav {
  display: none;
  gap: 18px;
  color: var(--zf-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.zf-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd166, #ff9f68);
  font-size: 1.2rem;
}

@media (min-width: 620px) {
  .zf-fake-nav {
    display: flex;
  }
}

/* ---------- HUD ---------- */

.hud {
  position: sticky;
  top: 8px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border: 1px solid var(--zf-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(28, 35, 51, 0.1);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.hud-face {
  font-size: 1.25rem;
}

.patience-wrap {
  flex: 1;
  max-width: 220px;
  height: 12px;
  border-radius: 999px;
  background: #e4e8f2;
  overflow: hidden;
}

.patience-bar {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #17a463, #7bd88f);
  transition: width 400ms ease, background 400ms ease;
}

.patience-bar.mid {
  background: linear-gradient(90deg, #f5b301, #ffd166);
}

.patience-bar.low {
  background: linear-gradient(90deg, #e5484d, #ff7b7f);
}

.hud-step {
  color: var(--zf-muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.hud-timer {
  min-width: 44px;
  color: var(--zf-ink);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hud.shake {
  animation: hud-shake 350ms ease;
}

@keyframes hud-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ---------- stage & scenes ---------- */

.stage {
  flex: 1;
  padding: 22px 0 30px;
}

.scene {
  animation: scene-in 320ms ease;
}

@keyframes scene-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  border: 1px solid var(--zf-line);
  border-radius: var(--zf-radius);
  background: var(--zf-panel);
  box-shadow: var(--zf-shadow);
  padding: 24px 20px;
}

.card + .card {
  margin-top: 16px;
}

.scene h1,
.scene h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.scene .lede {
  margin: 0 0 18px;
  color: var(--zf-muted);
  font-size: 0.98rem;
}

.fine-print {
  margin-top: 14px;
  color: #97a0b5;
  font-size: 0.72rem;
}

/* ---------- buttons ---------- */

.btn-mega {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--zf-blue), var(--zf-blue-dark));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(59, 91, 253, 0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn-mega.green {
  background: linear-gradient(135deg, #1db673, #128a54);
  box-shadow: 0 8px 20px rgba(23, 164, 99, 0.35);
}

.btn-mega:hover {
  transform: translateY(-1px);
}

.btn-corp {
  display: inline-block;
  padding: 11px 18px;
  border: 1px solid var(--zf-line);
  border-radius: 10px;
  background: #fff;
  color: var(--zf-ink);
  font-weight: 700;
  font-size: 0.95rem;
  transition: border-color 120ms ease, transform 120ms ease;
}

.btn-corp:hover {
  border-color: var(--zf-blue);
  transform: translateY(-1px);
}

.btn-corp:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-danger {
  border-color: rgba(229, 72, 77, 0.4);
  color: var(--zf-red);
}

.tiny-link {
  background: none;
  border: 0;
  padding: 4px;
  color: #a5adc2;
  font-size: 0.74rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tiny-link:hover {
  color: var(--zf-ink);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* ---------- modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 22, 36, 0.55);
  animation: overlay-in 220ms ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(430px, 100%);
  border-radius: var(--zf-radius);
  background: #fff;
  box-shadow: 0 24px 60px rgba(10, 14, 28, 0.4);
  padding: 24px 20px;
  text-align: center;
  position: relative;
  animation: modal-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal.wiggle {
  animation: modal-wiggle 400ms ease;
}

@keyframes modal-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

.modal .big-emoji {
  font-size: 3.4rem;
  line-height: 1;
  display: block;
  margin-bottom: 10px;
}

.fake-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  color: #b8bfd2;
  font-size: 1.1rem;
  padding: 6px;
}

/* ---------- step 1 dashboard ---------- */

.dash-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 6px;
}

.dash-tile {
  border: 1px solid var(--zf-line);
  border-radius: 12px;
  padding: 16px 14px;
  background: linear-gradient(180deg, #fbfcff, #f2f5fc);
  text-align: left;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 120ms ease, border-color 120ms ease;
}

.dash-tile:hover {
  transform: translateY(-2px);
  border-color: var(--zf-blue);
}

.dash-tile small {
  display: block;
  margin-top: 4px;
  color: var(--zf-muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.dash-footer {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--zf-line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
}

/* ---------- step 3 runaway ---------- */

.arena {
  position: relative;
  height: 320px;
  margin-top: 16px;
  border: 1px dashed var(--zf-line);
  border-radius: 12px;
  background:
    linear-gradient(rgba(59, 91, 253, 0.03), rgba(59, 91, 253, 0.03)),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(28, 35, 51, 0.04) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(28, 35, 51, 0.04) 39px 40px);
  overflow: hidden;
  touch-action: manipulation;
}

.runaway {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 20px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--zf-blue), var(--zf-blue-dark));
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 8px 18px rgba(59, 91, 253, 0.4);
  transition: left 180ms ease, top 180ms ease;
  white-space: nowrap;
}

.runaway.tired {
  transition: left 420ms ease, top 420ms ease;
}

.runaway.asleep {
  background: linear-gradient(135deg, #8b93ab, #667092);
  box-shadow: 0 6px 14px rgba(28, 35, 51, 0.3);
}

.arena .decoy {
  position: absolute;
  right: 14px;
  bottom: 12px;
}

/* ---------- step 4 offer ---------- */

.offer-price {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--zf-green);
  margin: 4px 0 0;
}

.offer-price s {
  font-size: 1.2rem;
  color: var(--zf-muted);
  font-weight: 600;
  margin-right: 8px;
}

.swap-note {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--zf-muted);
}

.swap-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.swap-btn {
  padding: 15px 10px;
  border: 2px solid var(--zf-line);
  border-radius: 11px;
  background: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  transition: border-color 150ms ease;
}

.swap-btn:hover {
  border-color: var(--zf-blue);
}

/* ---------- step 5 popups ---------- */

.popup-stack {
  position: relative;
  min-height: 340px;
  margin-top: 14px;
}

.popup {
  position: absolute;
  width: min(330px, 92%);
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--zf-line);
  box-shadow: 0 18px 44px rgba(10, 14, 28, 0.28);
  overflow: hidden;
  animation: modal-pop 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: linear-gradient(180deg, #2c3552, #1d2540);
  color: #dce3f5;
  font-size: 0.8rem;
  font-weight: 700;
}

.popup-bar .real-x {
  border: 0;
  background: none;
  color: #aeb9d6;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
}

.popup-bar .real-x:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.popup-body {
  padding: 16px 16px 18px;
  text-align: center;
  font-size: 0.92rem;
}

.popup-body .big-emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 6px;
}

.fake-x {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 18px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #ff5f6d, #ffc371);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 6px 16px rgba(255, 95, 109, 0.4);
}

/* ---------- step 6 captcha ---------- */

.captcha-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.captcha-tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--zf-line);
  border-radius: 10px;
  background: #f6f8fd;
  font-size: 2rem;
  transition: border-color 120ms ease, background 120ms ease;
}

.captcha-tile[aria-pressed="true"] {
  border-color: var(--zf-blue);
  background: #e7ecff;
}

.captcha-hint {
  margin: 10px 0 0;
  color: var(--zf-red);
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 1.2em;
}

/* ---------- step 7 chat ---------- */

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  max-height: 380px;
  overflow-y: auto;
  padding: 6px 2px;
  margin-top: 12px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.93rem;
  animation: scene-in 240ms ease;
}

.msg.bot {
  align-self: flex-start;
  background: #eef1f8;
  border-bottom-left-radius: 4px;
}

.msg.me {
  align-self: flex-end;
  background: var(--zf-blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.typing {
  color: var(--zf-muted);
  font-style: italic;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 9px 14px;
  border: 1.5px solid var(--zf-blue);
  border-radius: 999px;
  background: #fff;
  color: var(--zf-blue);
  font-weight: 700;
  font-size: 0.86rem;
}

.chip:hover {
  background: #eef1ff;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat-input-row input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--zf-line);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
}

.chat-input-row input:focus {
  outline: 2px solid var(--zf-blue);
  border-color: transparent;
}

/* ---------- step 8 terms ---------- */

.terms-box {
  height: 260px;
  overflow-y: auto;
  border: 1px solid var(--zf-line);
  border-radius: 10px;
  background: #fafbfe;
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 0.86rem;
  color: #454f66;
}

.terms-box h3 {
  font-size: 0.9rem;
  margin: 14px 0 4px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.check-row input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--zf-blue);
}

/* ---------- step 9 hold ---------- */

.hold-zone {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.hold-progress {
  height: 18px;
  border-radius: 999px;
  background: #e4e8f2;
  overflow: hidden;
}

.hold-progress > div {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--zf-blue), #7d94ff);
}

.hold-btn {
  padding: 22px 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--zf-red), #c73a3f);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(229, 72, 77, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hold-btn:active {
  transform: scale(0.985);
}

.hold-decoy {
  padding: 22px 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #e5484d, #c73a3f);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(229, 72, 77, 0.35);
}

/* ---------- step 10 final ---------- */

.riddle {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.45;
  margin: 14px 0 4px;
}

.riddle-count {
  color: var(--zf-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.verdict {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.verdict.good {
  color: var(--zf-green);
}

.verdict.bad {
  color: var(--zf-red);
}

.final-progress {
  margin-top: 16px;
}

.final-progress .hold-progress > div {
  transition: width 300ms ease;
}

.progress-label {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--zf-muted);
  text-align: center;
}

.speedup {
  display: block;
  margin: 14px auto 0;
  animation: pulse-glow 900ms ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 8px 20px rgba(229, 72, 77, 0.3); }
  50% { box-shadow: 0 8px 32px rgba(229, 72, 77, 0.65); }
}

/* ---------- win / fail ---------- */

.win-cert {
  border: 3px double var(--zf-gold);
  border-radius: var(--zf-radius);
  background: linear-gradient(180deg, #fffdf4, #fff8e2);
  padding: 30px 20px;
  text-align: center;
}

.win-cert h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.win-rank {
  display: inline-block;
  margin: 10px 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--zf-ink);
  color: var(--zf-gold);
  font-weight: 800;
  font-size: 1rem;
}

.win-stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 16px 0 4px;
  flex-wrap: wrap;
}

.win-stats div {
  min-width: 80px;
}

.win-stats b {
  display: block;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.win-stats span {
  color: var(--zf-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fail-card {
  text-align: center;
  padding: 40px 20px;
}

.fail-card .big-emoji {
  font-size: 3.6rem;
  display: block;
  margin-bottom: 8px;
}

/* ---------- confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  top: -4vh;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100% - 28px));
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: 11px;
  background: #1c2333;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(10, 14, 28, 0.35);
  animation: toast-in 260ms ease;
}

.toast.tip {
  background: #2743d6;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.out {
  opacity: 0;
  transition: opacity 300ms ease;
}

/* ---------- footer ---------- */

.zf-footer {
  padding: 18px 2px 26px;
  color: var(--zf-muted);
  font-size: 0.78rem;
  text-align: center;
}

.zf-footer a {
  color: var(--zf-ink);
  font-weight: 700;
}

.noscript-note {
  margin: 40px auto;
  max-width: 480px;
  text-align: center;
  font-weight: 600;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .runaway {
    transition: none;
  }
}
