:root {
  color-scheme: dark;
  --ink: #111218;
  --paper: #e8e3d7;
  --dim: #777982;
  --acid: #d8ff54;
  --coral: #ff5b4d;
  --blue: #6c88ff;
  --rule: rgba(232, 227, 215, .16);
  --top: 68px;
  --bottom: 70px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

button:focus-visible,
.phrase:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 4px;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .1;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.94' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar,
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  align-items: center;
  min-width: 0;
  padding-left: max(22px, env(safe-area-inset-left));
  padding-right: max(22px, env(safe-area-inset-right));
  background: rgba(17, 18, 24, .88);
  backdrop-filter: blur(12px);
}

.topbar {
  top: 0;
  height: var(--top);
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: .19em;
  font-size: 11px;
  font-weight: 700;
}

.brand-mark {
  width: 11px;
  height: 11px;
  border: 1px solid var(--paper);
  border-radius: 50%;
  box-shadow: inset 4px 0 0 var(--coral);
}

.field-index {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--dim);
}

.field-index strong {
  color: var(--paper);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.text-button,
.icon-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 9px;
  font-weight: 700;
}

.topbar > .text-button { justify-self: end; }
.text-button:hover { color: var(--acid); }

#stage {
  position: fixed;
  inset: var(--top) 0 var(--bottom);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 82% 24%, rgba(108, 136, 255, .08), transparent 29%),
    linear-gradient(135deg, rgba(255,255,255,.018), transparent 50%);
}

#trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.field-copy {
  position: absolute;
  z-index: 1;
  width: min(1040px, 82vw);
  margin: 0;
  color: rgba(232, 227, 215, .72);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(38px, 5.45vw, 83px);
  line-height: .965;
  letter-spacing: -.047em;
  text-wrap: pretty;
  user-select: text;
  -webkit-user-select: text;
  transition: opacity .35s ease, transform .55s cubic-bezier(.2,.8,.2,1);
}

.field-copy.layout-one { left: 7vw; top: 9%; }
.field-copy.layout-two { right: 7vw; top: 7%; width: min(880px, 75vw); text-align: right; }
.field-copy.layout-three { left: 9vw; top: 9%; width: min(980px, 78vw); }

.field-copy.entering { opacity: 0; transform: translateY(20px); }

.field-copy p {
  display: inline;
  margin: 0;
}

.phrase {
  position: relative;
  border-radius: 3px;
  cursor: text;
  transition: color .16s ease;
}

.phrase:nth-child(3n + 1) { color: rgba(232, 227, 215, .9); }
.phrase:hover { color: var(--paper); }

.field-copy::selection,
.field-copy *::selection {
  color: var(--ink);
  background: var(--acid);
}

.solids {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.solid {
  position: absolute;
  min-width: 8px;
  border-bottom: 3px solid var(--acid);
  border-radius: 2px 2px 0 0;
  background: linear-gradient(to top, rgba(216, 255, 84, .34), rgba(216, 255, 84, .055));
  box-shadow: 0 5px 14px rgba(216, 255, 84, .12);
  transform-origin: left bottom;
  animation: harden .28s cubic-bezier(.2,.8,.2,1) both;
}

.solid::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  opacity: .5;
  background: repeating-linear-gradient(90deg, var(--acid) 0 3px, transparent 3px 7px);
}

.solid.expiring { animation: vanish .42s ease forwards; }

@keyframes harden {
  from { opacity: 0; transform: scaleX(.1); }
  to { opacity: 1; transform: scaleX(1); }
}

@keyframes vanish {
  to { opacity: 0; filter: blur(3px); transform: translateY(5px); }
}

.runner {
  --runner-size: 18px;
  position: absolute;
  z-index: 5;
  width: var(--runner-size);
  height: var(--runner-size);
  margin: calc(var(--runner-size) / -2) 0 0 calc(var(--runner-size) / -2);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(255, 91, 77, .12), 0 0 22px rgba(255, 91, 77, .65);
  pointer-events: none;
  will-change: transform;
}

.runner::before {
  content: '';
  position: absolute;
  top: 7px;
  right: 12px;
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 91, 77, .64));
  transform-origin: right center;
  transform: rotate(var(--trail-angle, 0deg));
}

.runner.waiting span {
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(255, 91, 77, .55);
  border-radius: 50%;
  animation: wait-ring 1.6s ease-out infinite;
}

@keyframes wait-ring {
  to { opacity: 0; transform: scale(1.8); }
}

.goal {
  position: absolute;
  z-index: 4;
  width: 82px;
  height: 120px;
  color: var(--dim);
  transform: translate(-50%, -50%);
  transition: color .25s ease, filter .25s ease;
}

.goal-gate {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(232, 227, 215, .25);
  border-right: 0;
}

.goal-gate::before,
.goal-gate::after {
  content: '';
  position: absolute;
  right: -1px;
  width: 18px;
  height: 1px;
  background: currentColor;
}

.goal-gate::before { top: 0; }
.goal-gate::after { bottom: 0; }

.goal-label {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  text-align: right;
  font-size: 8px;
  line-height: 1.3;
  letter-spacing: .16em;
  font-weight: 700;
}

.goal.open {
  color: var(--blue);
  filter: drop-shadow(0 0 9px rgba(108, 136, 255, .55));
}

.coordinate {
  position: absolute;
  z-index: 0;
  opacity: .23;
  pointer-events: none;
}

.coordinate-x {
  left: 0;
  right: 0;
  top: 62%;
  border-top: 1px dashed rgba(232,227,215,.18);
}

.coordinate-y {
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px dashed rgba(232,227,215,.12);
}

.field-flash {
  position: absolute;
  z-index: 8;
  width: 120px;
  height: 120px;
  border: 1px solid var(--acid);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.25);
  pointer-events: none;
}

.field-flash.active { animation: flash .52s ease-out; }

@keyframes flash {
  0% { opacity: .9; transform: translate(-50%, -50%) scale(.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
}

.bottombar {
  bottom: 0;
  min-height: var(--bottom);
  padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: 1fr auto 1fr;
  gap: 22px;
  border-top: 1px solid var(--rule);
}

.bottombar p {
  margin: 0;
  max-width: 430px;
  color: #a2a1a0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  font-style: italic;
}

.impact-meter {
  display: grid;
  grid-template-columns: repeat(2, 24px) auto;
  align-items: center;
  gap: 5px;
}

.impact-meter span {
  display: block;
  height: 5px;
  border: 1px solid #575963;
  border-radius: 999px;
}

.impact-meter span.hit { border-color: var(--coral); background: var(--coral); }

.impact-meter b {
  margin-left: 5px;
  font-size: 8px;
  letter-spacing: .14em;
  font-weight: 700;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.footer-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 44px;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.intro,
.ending {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  align-items: center;
  padding: clamp(28px, 6vw, 90px);
  background: var(--paper);
  color: var(--ink);
  transition: opacity .48s ease, visibility .48s;
}

.intro.dismissed { opacity: 0; visibility: hidden; }
.intro[hidden] { display: none; }

.intro-copy { max-width: 720px; }

.eyebrow {
  margin: 0 0 20px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 10px;
  font-weight: 700;
}

.intro h1,
.ending h2 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(52px, 8.2vw, 126px);
  line-height: .82;
  letter-spacing: -.065em;
  font-weight: 400;
}

.intro-copy > p:not(.eyebrow):not(.input-note),
.ending > p:not(.eyebrow) {
  max-width: 560px;
  margin: 30px 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(16px, 1.65vw, 23px);
  line-height: 1.4;
}

.begin-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 50px;
  min-width: min(340px, 100%);
  min-height: 58px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 10px;
  font-weight: 700;
}

.begin-button:hover { background: var(--ink); color: var(--paper); }

.input-note {
  margin: 16px 0 0;
  color: #66645f;
  font-size: 10px;
  line-height: 1.5;
}

.intro-shape {
  position: relative;
  justify-self: center;
  width: min(470px, 36vw);
  height: min(420px, 46vw);
}

.intro-shape i {
  position: absolute;
  left: 0;
  height: 26%;
  border-bottom: 7px solid var(--ink);
  background: var(--acid);
  opacity: .86;
}

.intro-shape i:nth-child(1) { top: 3%; width: 91%; }
.intro-shape i:nth-child(2) { top: 35%; width: 73%; left: 17%; }
.intro-shape i:nth-child(3) { top: 67%; width: 52%; left: 39%; }
.intro-shape b {
  position: absolute;
  left: 63%;
  top: 26%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 9px rgba(255,91,77,.16);
}

.interlude {
  position: fixed;
  inset: var(--top) 0 var(--bottom);
  z-index: 25;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 30px;
  background: var(--blue);
  color: var(--ink);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s;
}

.interlude.visible { opacity: 1; visibility: visible; }

.interlude p {
  margin: 0 0 18px;
  font-size: 9px;
  letter-spacing: .19em;
  font-weight: 700;
}

.interlude strong {
  max-width: 780px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(38px, 6vw, 84px);
  line-height: .94;
  letter-spacing: -.05em;
  font-weight: 400;
}

.ending {
  display: block;
  padding-top: clamp(70px, 11vh, 130px);
  background: var(--acid);
}

.ending[hidden] { display: none; }
.ending h2 { max-width: 1000px; }
.ending .begin-button { margin-top: 34px; }

.help-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--paper);
  background: var(--ink);
  color: var(--paper);
}

.help-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.help-dialog form { position: relative; padding: clamp(28px, 5vw, 54px); }

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font-size: 28px;
}

.help-dialog h2 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(34px, 6vw, 60px);
  line-height: .94;
  font-weight: 400;
  letter-spacing: -.045em;
}

.help-dialog ol { list-style: none; padding: 0; margin: 36px 0 22px; }
.help-dialog li { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 15px 0; border-top: 1px solid var(--rule); font-size: 13px; line-height: 1.45; }
.help-dialog li span { color: var(--acid); font-size: 9px; letter-spacing: .14em; }
.help-small { margin: 0; color: #9b9ba0; font-family: Georgia, 'Times New Roman', serif; font-size: 13px; line-height: 1.5; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  :root { --top: 58px; --bottom: 92px; }
  .topbar { grid-template-columns: 1fr auto; }
  .field-index { display: none; }
  .topbar, .bottombar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .field-copy { width: 86vw; font-size: clamp(32px, 9.4vw, 48px); line-height: .97; }
  .field-copy.layout-one { left: 7vw; top: 8%; }
  .field-copy.layout-two { right: 7vw; top: 7%; width: 86vw; }
  .field-copy.layout-three { left: 7vw; top: 7%; width: 86vw; }
  .goal {
    left: auto !important;
    right: 8px;
    width: 72px;
    transform: translateY(-50%) scale(.78);
    transform-origin: right center;
  }
  .bottombar { grid-template-columns: 1fr auto; gap: 8px 12px; align-content: center; }
  .bottombar p { grid-column: 1 / -1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .impact-meter { justify-self: start; }
  .footer-actions { gap: 0; }
  .footer-actions .text-button { padding: 0 10px; }
  .intro, .ending { display: block; padding: 72px 24px 30px; overflow-y: auto; }
  .intro h1, .ending h2 { font-size: clamp(54px, 16vw, 78px); }
  .intro-copy > p:not(.eyebrow):not(.input-note), .ending > p:not(.eyebrow) { margin: 24px 0; font-size: 17px; }
  .intro-shape { display: none; }
  .begin-button { min-width: 0; width: 100%; }
  .input-note { padding-right: 48px; }
}

@media (max-height: 640px) and (min-width: 761px) {
  .field-copy { font-size: clamp(34px, 5vw, 64px); }
  .intro { padding-top: 50px; padding-bottom: 50px; }
  .intro h1 { font-size: clamp(54px, 8vw, 90px); }
  .intro-copy > p:not(.eyebrow):not(.input-note) { margin: 18px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .noise { display: none; }
}
