:root {
  --bg: #05070d;
  --panel: rgba(10, 14, 24, 0.72);
  --text: #e8eef7;
  --muted: #8a97ab;
  --blue: #3fd0ff;
  --blue-deep: #0a84ff;
  --amber: #ffb454;
  --danger: #ff5c5c;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: 'Saira Extra Condensed', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* Exposed as custom properties so JS can read the safe-area insets. */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  background: radial-gradient(ellipse at 50% 120%, #0b1326 0%, var(--bg) 60%);
}

.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
}

/* Screens stack on top of each other and crossfade. */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 24px) calc(var(--sal) + 16px);
  opacity: 0;
  visibility: hidden;
  touch-action: manipulation;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.screen.is-active { opacity: 1; visibility: visible; }

/* Console look (intro and shutdown) */
.console {
  position: relative;
  width: min(100%, 420px);
  padding: 20px 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 180, 84, 0.25);
  border-radius: 6px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: var(--mono);
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.6;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255, 180, 84, 0.35);
}
.console::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
}
.console__title { margin: 0 0 10px; font-weight: 500; letter-spacing: 0.18em; min-height: 1.6em; }
.console__line { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; min-height: 1.6em; }
.bar { flex: 1; height: 8px; overflow: hidden; border: 1px solid rgba(255, 180, 84, 0.5); border-radius: 2px; }
.bar__fill { display: block; width: 0; height: 100%; background: var(--amber); transition: width 1.2s linear; }
.console__fields { display: grid; grid-template-columns: max-content 1fr; column-gap: 12px; row-gap: 4px; margin: 0; }
.console__fields dt { margin: 0; color: rgba(255, 180, 84, 0.7); }
.console__fields dd { margin: 0; min-height: 1.6em; color: var(--text); text-shadow: none; }
.console__prompt { margin: 18px 0 0; text-align: center; color: var(--muted); animation: pulse 1.6s ease-in-out infinite; }
.console--danger { color: var(--danger); border-color: rgba(255, 92, 92, 0.4); text-shadow: 0 0 12px rgba(255, 92, 92, 0.4); }
.caret::after { content: '▍'; animation: blink 1s steps(1) infinite; }

/* Ask panel */
.panel {
  width: min(100%, 440px);
  padding: 28px 24px 24px;
  border: 1px solid rgba(63, 208, 255, 0.18);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(63, 208, 255, 0.05), 0 20px 60px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-align: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.panel.is-leaving { opacity: 0; transform: scale(0.96); }
.panel.is-glitching { animation: glitch 0.6s linear 1; }
.panel__headline { margin: 0 0 14px; min-height: 1.2em; font-size: clamp(26px, 7vw, 34px); font-weight: 600; letter-spacing: -0.01em; }
.panel__body { margin: 0 0 28px; font-size: clamp(16px, 4.3vw, 18px); line-height: 1.5; color: #c9d3e0; }
.choices { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px; min-height: 72px; }

.btn {
  appearance: none;
  margin: 0;
  border: 0;
  border-radius: 999px;
  min-width: 48px;
  min-height: 48px;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.btn[hidden] { display: none; }

.btn--yes {
  --yes-scale: 1;
  width: min(100%, 320px);
  min-height: 64px;
  padding: 0 44px;
  background: linear-gradient(180deg, #46c8ff 0%, var(--blue-deep) 100%);
  color: #04101f;
  font-size: 20px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 0 24px rgba(63, 208, 255, 0.45), 0 0 60px rgba(10, 132, 255, 0.35);
  transform: scale(var(--yes-scale));
  transition: transform 0.25s ease;
}
.btn--yes:active:not(:disabled) { filter: brightness(1.1); }
.btn--yes:disabled { opacity: 0.35; box-shadow: none; cursor: default; }
.btn--yes.is-pulsing { animation: breathe 2.2s ease-in-out infinite; }

.btn--no {
  --goo: 0;
  position: relative;
  height: 48px;
  padding: 0 22px;
  overflow: visible;
  border: 1px solid rgba(138, 151, 171, 0.45);
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  max-width: calc(100vw - 16px);
}
/* Once it has dodged, it floats over everything and is positioned by --nx/--ny. */
.btn--no.btn--loose {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5;
  will-change: transform;
  transform: translate3d(var(--nx, 0px), var(--ny, 0px), 0);
}
.btn__label { position: relative; z-index: 2; }
.btn-spacer { display: inline-block; }

/* Protomolecule goo */
.goo {
  position: absolute;
  inset: -6px;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transform: scale(var(--goo));
  transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.btn--no.is-gooey .goo { opacity: 1; }
.goo i {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #bff1ff 0%, var(--blue) 35%, var(--blue-deep) 70%, rgba(10, 132, 255, 0) 100%);
  box-shadow: 0 0 18px rgba(63, 208, 255, 0.8), 0 0 40px rgba(10, 132, 255, 0.5);
  animation: crawl 3s ease-in-out infinite alternate;
}
.goo i:nth-child(1) { left: -8%; top: -12%; width: 46%; height: 120%; animation-delay: -0.4s; }
.goo i:nth-child(2) { left: 24%; top: 10%; width: 38%; height: 100%; animation-delay: -1.1s; }
.goo i:nth-child(3) { left: 50%; top: -6%; width: 42%; height: 110%; animation-delay: -2s; }
.goo i:nth-child(4) { left: 76%; top: 20%; width: 30%; height: 80%; animation-delay: -0.7s; }

.shards { position: absolute; inset: -10px; z-index: 3; pointer-events: none; opacity: 0; transition: opacity 0.4s ease; }
.btn--no.is-crystal .shards { opacity: 1; }
.shards i {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 18px solid #bff1ff;
  filter: drop-shadow(0 0 6px var(--blue));
}
.shards i:nth-child(1) { left: 12%; top: -14px; transform: rotate(-20deg); }
.shards i:nth-child(2) { left: 48%; top: -18px; transform: rotate(8deg); }
.shards i:nth-child(3) { left: 78%; top: -10px; transform: rotate(28deg); }

.bits { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.bits i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 1px;
  background: #bff1ff;
  box-shadow: 0 0 8px var(--blue);
  opacity: 0;
}
.bits i:nth-child(1) { --dx: -70px; --dy: -40px; }
.bits i:nth-child(2) { --dx: 70px; --dy: -40px; }
.bits i:nth-child(3) { --dx: -80px; --dy: 10px; }
.bits i:nth-child(4) { --dx: 80px; --dy: 10px; }
.bits i:nth-child(5) { --dx: -50px; --dy: 50px; }
.bits i:nth-child(6) { --dx: 50px; --dy: 50px; }
.bits i:nth-child(7) { --dx: -10px; --dy: -60px; }
.bits i:nth-child(8) { --dx: 15px; --dy: 65px; }

.btn--no.is-consumed { pointer-events: none; border-color: transparent; color: transparent; animation: pulseBlue 0.6s ease-in-out 2; }
.btn--no.is-crumbling { animation: crumble 0.9s ease-in forwards; }
.btn--no.is-crumbling .bits i { animation: bit 0.9s ease-out forwards; }
.btn--no.is-gone { display: none; }

.abort {
  display: block;
  margin: 22px auto 0;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: rgba(138, 151, 171, 0.55);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-decoration: underline dotted;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0.8s;
}
.abort.is-visible { opacity: 1; visibility: visible; }

/* Burn */
.burn { position: fixed; inset: 0; z-index: 3; display: none; pointer-events: none; }
.burn.is-active { display: block; }
.burn__ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40vmin;
  height: 40vmin;
  margin: -20vmin 0 0 -20vmin;
  border: 6px solid #bff1ff;
  border-radius: 50%;
  box-shadow: 0 0 30px 6px rgba(63, 208, 255, 0.9), 0 0 90px 30px rgba(10, 132, 255, 0.6), inset 0 0 40px rgba(63, 208, 255, 0.6);
  opacity: 0;
  transform: scale(0);
}
.burn.is-active .burn__ring { animation: ring 1.4s cubic-bezier(0.5, 0, 0.9, 0.4) 0.6s forwards; }
.burn__flash { position: absolute; inset: 0; background: #dff6ff; opacity: 0; }
.burn.is-active .burn__flash { animation: flash 0.4s ease-out 1.7s forwards; }

/* Reveal */
.screen--reveal { flex-direction: column; text-align: center; }
.reveal { position: relative; z-index: 2; width: min(100%, 460px); }
.reveal__eyebrow { margin: 0 0 6px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--muted); }
.reveal__lead { margin: 0 0 16px; font-size: clamp(16px, 4.3vw, 18px); color: #c9d3e0; }
.reveal__line { margin: 16px 0 0; font-size: clamp(16px, 4.3vw, 18px); color: #c9d3e0; }
.reveal .btn--yes { margin-top: 20px; }

/* The two titles she picks between */
.options { display: grid; gap: 12px; }
.options[hidden] { display: none; }
.option {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid rgba(63, 208, 255, 0.22);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}
.option:active { transform: scale(0.98); }
.option.is-picked {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(63, 208, 255, 0.35) inset, 0 0 28px rgba(63, 208, 255, 0.35);
}
.options.has-pick .option:not(.is-picked) { opacity: 0.5; }
.option__title {
  display: block;
  padding-left: 0.14em;
  font-family: var(--display);
  font-size: clamp(30px, 8.5vw, 46px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 18px rgba(63, 208, 255, 0.5);
}
.option__subtitle { display: block; margin-top: 6px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; color: var(--blue); }
.option__line { display: block; margin-top: 6px; font-size: 15px; line-height: 1.4; color: #c9d3e0; }
.reveal__confirmed { margin: 26px 0 0; font-size: 18px; }
.reveal__confirmed[hidden] { display: none; }
.ship { position: absolute; left: 0; bottom: calc(var(--sab) + 40px); width: 180px; height: auto; opacity: 0.9; animation: fly 42s linear infinite; }
.ship__plume { animation: flicker 0.18s steps(2) infinite alternate; }

/* Shutdown */
.screen--shutdown { flex-direction: column; background: transparent; transition: opacity 0.5s ease, visibility 0.5s, background 0.8s ease; }
.screen--shutdown.is-dark { background: #000; }
.screen--shutdown .console { transition: opacity 0.8s ease; }
.screen--shutdown.is-dark .console { opacity: 0; }
.ended { position: absolute; margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; color: rgba(138, 151, 171, 0.6); opacity: 0; transition: opacity 1s ease; }
.ended.is-visible { opacity: 1; }

.noscript { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; font-family: var(--mono); color: var(--amber); }

@media (min-width: 700px) {
  .panel { padding: 36px 40px 32px; }
  .reveal { width: min(100%, 640px); }
  .options { grid-template-columns: 1fr 1fr; gap: 16px; }
  .option { padding: 20px 18px 22px; }
}

@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 0 24px rgba(63, 208, 255, 0.45), 0 0 60px rgba(10, 132, 255, 0.35); }
  50% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset, 0 0 40px rgba(63, 208, 255, 0.8), 0 0 100px rgba(10, 132, 255, 0.6); }
}
@keyframes crawl { from { transform: translate(0, 0) scale(1); } to { transform: translate(3px, -2px) scale(1.12); } }
@keyframes pulseBlue { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }
@keyframes crumble {
  0% { transform: translate3d(var(--nx, 0px), var(--ny, 0px), 0) scale(1) rotate(0deg); opacity: 1; }
  40% { transform: translate3d(var(--nx, 0px), var(--ny, 0px), 0) scale(0.92) rotate(-3deg); opacity: 1; }
  100% { transform: translate3d(var(--nx, 0px), var(--ny, 0px), 0) scale(0.5) rotate(6deg); opacity: 0; }
}
@keyframes bit { 0% { opacity: 1; transform: translate(0, 0); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(90deg); } }
@keyframes ring { 0% { opacity: 0; transform: scale(0); } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: scale(12); } }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 0.9; } 100% { opacity: 0; } }
@keyframes fly { from { transform: translateX(-200px); } to { transform: translateX(calc(100vw + 40px)); } }
@keyframes flicker { from { opacity: 0.7; } to { opacity: 1; } }
@keyframes glitch {
  0% { transform: translate(0); clip-path: inset(0 0 0 0); text-shadow: none; }
  20% { transform: translate(-6px, 2px); clip-path: inset(10% 0 55% 0); text-shadow: 2px 0 var(--danger), -2px 0 var(--blue); }
  40% { transform: translate(5px, -3px); clip-path: inset(50% 0 10% 0); }
  60% { transform: translate(-3px, 1px); clip-path: inset(20% 0 40% 0); text-shadow: -2px 0 var(--danger), 2px 0 var(--blue); }
  80% { transform: translate(4px, 2px); clip-path: inset(70% 0 5% 0); }
  100% { transform: translate(0); clip-path: inset(0 0 0 0); text-shadow: none; }
}

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