:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --ink-soft: #2a2a2a;
  --line: #0a0a0a;
  --ring: rgba(10, 10, 10, 0.18);
  --hover: #f2f2f2;
  --veil: rgba(255, 255, 255, 0.72);
  --type-size: clamp(2.5rem, 7.2vw, 5.75rem);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--comic);
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  padding: 0 16px;
  overflow-x: hidden;
}

/* Meteors streak behind everything */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

/* three.js layer (scene.js); the SVG figures stay as placeholders it lines up with */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.has-scene .sky { display: none; }
/* The SVG figures are a fallback: hidden until we know 3D can't run */
.god svg, .worshipper svg { visibility: hidden; }
.no-scene .god svg, .no-scene .worshipper svg { visibility: visible; }
.meteor {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(10, 10, 10, 0.5), rgba(10, 10, 10, 0));
}
.meteor::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
  transform: translateY(-50%);
}

main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(40px, 8vh, 72px);
  width: 100%;
}

/* The Fate God floats above the question */
.god { width: clamp(84px, 12vw, 120px); color: var(--ink); }
.god .cloud { fill: #fff; }
.god svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: float 3.4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }
.god .halo { animation: halo 2.4s ease-in-out infinite; }
@keyframes halo { 50% { opacity: 0.45; } }
.god .g-arm { transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.god .g-arm.l { transform-origin: 50px 46px; }
.god .g-arm.r { transform-origin: 70px 46px; }
.god.decree .g-arm.l { transform: rotate(22deg); }
.god.decree .g-arm.r { transform: rotate(-22deg); }
.god.decree svg { filter: drop-shadow(0 0 10px rgba(10, 10, 10, 0.22)); }

.question {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  column-gap: 0.28em;
  row-gap: 0.1em;
  font-size: var(--type-size);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.lead { white-space: pre; position: relative; }

/* Typewriter caret */
.caret {
  display: inline-block;
  width: 0.06em;
  height: 0.9em;
  margin-left: 0.04em;
  background: var(--ink);
  vertical-align: -0.08em;
  animation: blink 1s steps(1) infinite;
}
.caret[hidden] { display: none; }
@keyframes blink { 50% { opacity: 0; } }

.blank {
  display: inline-flex;
  align-items: baseline;
}

.field {
  position: relative;
  display: inline-block;
}

.field input {
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
  caret-color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  padding: 0 0.04em 0.06em;
  text-align: center;
  width: var(--w, 4.5em);
  min-width: 3.5em;
  max-width: calc(100vw - 32px - 0.6em);
  transition: width 180ms var(--ease-out);
}

/* The blank's underline, drawn left → right */
.field::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: max(2px, 0.045em);
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 900ms var(--ease-out);
}
.field.drawn::after { transform: scaleX(1); }

.mirror {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font: inherit;
  letter-spacing: inherit;
  pointer-events: none;
}

.qmark { white-space: pre; margin-left: 0.04em; }

.ask {
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--bg);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: 0 36px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 500ms var(--ease-out),
    transform 500ms var(--ease-out),
    background-color 200ms ease,
    box-shadow 200ms ease;
}
.ask.shown { opacity: 1; transform: none; pointer-events: auto; }
.ask:hover { background: var(--ink-soft); }
.ask:active { transform: scale(0.97); transition-duration: 100ms; }
.ask:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--ring); }

/* Button and answer share one slot, so nothing shifts */
.stage { position: relative; display: grid; place-items: center; min-height: 1.2em; font-size: clamp(2rem, 5vw, 3.5rem); }
.stage > * { grid-area: 1 / 1; }

.answer {
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  white-space: pre;
}

/* Follow-up choices hang below the answer so nothing above moves */
.choices {
  position: absolute;
  top: calc(100% + 32px);
  left: 50%;
  display: flex;
  gap: 12px;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.choices.shown { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.pill {
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border-radius: 999px;
  min-height: 48px;
  padding: 0 24px;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease, transform 100ms ease, opacity 200ms ease;
}
.pill:active { transform: scale(0.97); }
.pill:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--ring); }
.pill.solid { color: var(--bg); background: var(--ink); border: 0; }
.pill.solid:hover { background: var(--ink-soft); }
.pill.ghost { color: var(--ink); background: var(--bg); border: 1.5px solid var(--ink); }
.pill.ghost:hover { background: var(--hover); }

/* Try again runs away */
.pill.dodging {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  transition: transform 520ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease, opacity 200ms ease;
}
.spacer { visibility: hidden; }

/* Each Oops! fades in, lingers, then fades out */
.oops {
  position: absolute;
  z-index: 1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  /* Solid backing so passing meteors don't cover it */
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 0 0 6px var(--bg);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: oops 1600ms var(--ease-out) forwards;
}
@keyframes oops {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18%, 65% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

/* Hand pointing at the way out */
.finger {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 36px;
  height: 36px;
  pointer-events: none;
  opacity: 0;
  transition: transform 480ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease;
}
.finger.shown { opacity: 1; }
.finger svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--bg);
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: tap 900ms ease-in-out infinite;
}
@keyframes tap { 50% { transform: translateY(-7px); } }

/* Presses left before Try again gives up, with a stick figure praying to it */
.altar {
  position: fixed;
  z-index: 1;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 0.1em;
  font-size: clamp(4rem, 22vw, 8.25rem);
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.altar.shown { opacity: 1; transform: none; }

.count {
  font-weight: 600;
  line-height: 0.8;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  transform-origin: 100% 100%;
}
.count.tick { animation: tick 300ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes tick {
  0% { transform: translateY(-0.12em) scale(1.12); opacity: 0.35; }
  100% { transform: none; opacity: 1; }
}

.figure svg {
  display: block;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.figure text { fill: currentColor; stroke: none; font-weight: 600; font-size: 20px; }

/* Kneeling, facing left toward the god, hands raised */
.worshipper svg { width: 0.67em; height: 0.8em; }
.worshipper .upper { transform-origin: 60px 84px; }
.worshipper .arms { transform-origin: 58px 57px; }

/* Swaying while it prays */
.altar.shown .upper { animation: sway 1.1s ease-in-out infinite; }
.altar.shown .arms { animation: wave 0.55s ease-in-out infinite alternate; }
@keyframes sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(4deg); } }
@keyframes wave { from { transform: rotate(-10deg); } to { transform: rotate(8deg); } }

/* One bow toward the god per press */
.altar.shown .worshipper.bow .upper { animation: bow 460ms var(--ease-out); }
.altar.shown .worshipper.bow .arms { animation: none; }
@keyframes bow {
  45% { transform: rotate(-62deg); }
  100% { transform: none; }
}

/* Popups */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 0 16px;
  background: var(--veil);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade 300ms ease;
}
.modal[hidden] { display: none; }
.modal:focus { outline: none; }
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  animation: win-in 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.card p { font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

.nudge p { font-size: clamp(1.5rem, 3.6vw, 2.5rem); max-width: 16em; }

/* Share card for giving up */
.share-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(360px, 100%);
  padding: 32px 28px 24px;
  background: var(--bg);
  border: 1.5px solid var(--ink);
  border-radius: 24px;
}
.share-card .share-q { font-size: 1.25rem; }
.share-card .share-a { font-size: 3rem; }
.share-card .share-line { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.35; }
.share-card .share-brand { font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; opacity: 0.55; }
.share-fig { color: var(--ink); }
.share-fig svg { width: 52px; height: auto; }

.win #winText { font-size: clamp(2rem, 5.6vw, 4.25rem); max-width: 12em; }
/* The reward lands a beat after the joke */
.win-reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: reward 600ms var(--ease-out) 1400ms both;
}
.win .win-sub { font-size: clamp(1.125rem, 2.4vw, 1.5rem); font-weight: 500; letter-spacing: -0.01em; }
@keyframes reward { from { opacity: 0; transform: translateY(10px); } }

.confused { color: var(--ink); }
.confused svg { width: clamp(80px, 12vw, 120px); height: auto; }
.confused .c-head { transform-origin: 36px 30px; animation: tilt 1.6s ease-in-out infinite alternate; }
.confused .c-scratch { transform-origin: 36px 38px; animation: scratch 0.28s ease-in-out infinite alternate; }
.confused .q1 { animation: puzzle 1.8s ease-in-out infinite; }
.confused .q2 { animation: puzzle 1.8s ease-in-out 0.9s infinite; }
@keyframes tilt { from { transform: rotate(-14deg); } to { transform: rotate(6deg); } }
@keyframes scratch { to { transform: rotate(-8deg); } }
@keyframes puzzle {
  0%, 100% { opacity: 0; transform: translateY(6px); }
  30%, 70% { opacity: 1; transform: none; }
}

.qbit {
  position: fixed;
  left: 50%;
  top: 50%;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  pointer-events: none;
}
@keyframes fade { from { opacity: 0; } }
@keyframes win-in { from { transform: scale(0.3); opacity: 0; } }

.shake { animation: shake 360ms var(--ease-out); }
@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@media (max-width: 640px) {
  .lead { flex-basis: 100%; text-align: center; }
  .field input { max-width: calc(100vw - 32px - 0.8em); }
}

@media (prefers-reduced-motion: reduce) {
  .field::after, .ask, .field input, .choices { transition: none; }
  .caret { animation: none; }
  .shake, .modal, .card, .win-reward, .finger svg, .count.tick { animation: none; }
  .oops { animation-duration: 1ms; animation-delay: 900ms; opacity: 1; }
  .finger, .altar { transition: none; }
  .pill.dodging { transition: none; }
  .god svg, .god .halo, .worshipper *, .confused * { animation: none !important; }
  .god .g-arm { transition: none; }
}

/* Comic book look */
:root { --pop: #ffd23f; --comic: "Bangers", Impact, sans-serif; }
body {
  background-image: radial-gradient(rgba(10, 10, 10, 0.1) 1.2px, transparent 1.7px);
  background-size: 14px 14px;
}
.ask, .pill.solid, .pill.ghost {
  border: 2.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.ask, .pill.solid { color: var(--ink); background: var(--pop); }
.ask:hover, .pill.solid:hover { background: #ffdf6b; }
.ask:active, .pill:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.ask:focus-visible, .pill:focus-visible { box-shadow: 4px 4px 0 var(--ink), 0 0 0 4px var(--bg), 0 0 0 7px var(--ring); }
.answer, .oops { font-family: var(--comic); font-weight: 400; letter-spacing: 0.03em; }
.answer {
  font-size: 1.3em;
  color: #e63946;
  -webkit-text-stroke: 0.035em var(--ink);
  text-shadow: 0.07em 0.07em 0 var(--ink);
}
.oops {
  font-size: 1.25rem;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--pop);
  box-shadow: 3px 3px 0 var(--ink);
}
.share-card { border-width: 2.5px; box-shadow: 6px 6px 0 var(--ink); }

/* Comic lettering everywhere: Bangers has one weight, so no faux bold,
   and it wants open tracking instead of the tight Inter spacing */
body { font-synthesis: none; letter-spacing: 0.03em; }
.question, .field input, .card p, .count, .ask, .pill, .share-card p, .win .win-sub { font-weight: 400; letter-spacing: 0.03em; }
.ask, .pill { font-size: 1.25rem; }
.share-card .share-brand { letter-spacing: 0.08em; }
.count {
  color: var(--pop);
  -webkit-text-stroke: 0.03em var(--ink);
  text-shadow: 0.05em 0.05em 0 var(--ink);
}

/* Comic-drawn SVG figures: flat fills with ink outlines */
.figure svg.toon { stroke: var(--ink); stroke-width: 3; }
.figure svg.toon text {
  font-family: var(--comic);
  font-weight: 400;
  font-size: 30px;
  fill: var(--pop);
  stroke: var(--ink);
  stroke-width: 2.5;
  paint-order: stroke;
}
.confused .c-head { transform-origin: 60px 56px; }
.confused .c-scratch { transform-origin: 76px 66px; }
.share-fig svg.toon { width: 72px; }
