:root {
  color-scheme: dark;
  --ink: #f0eee7;
  --muted: #99988f;
  --dim: #54544f;
  --ground: #0a0a0b;
  --panel: #111113;
  --line: rgba(240, 238, 231, 0.18);
  --line-strong: rgba(240, 238, 231, 0.42);
  --signal: #d7ff43;
  --violet: #786cff;
  --hot: #ff5c35;
  --pointer-x: 50vw;
  --pointer-y: 50vh;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--ground);
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--ground);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.12;
  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='.95' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.attention {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    420px circle at var(--pointer-x) var(--pointer-y),
    rgba(120, 108, 255, 0.13),
    transparent 68%
  );
}

.site-header {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 1fr auto;
  align-items: start;
  min-height: 104px;
  border-bottom: 1px solid var(--line-strong);
}

.wordmark,
.header-meta,
.sound-toggle {
  min-height: 104px;
  padding: 22px 24px;
}

.wordmark {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: max-content;
  max-width: 100%;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.wordmark span:last-child {
  color: var(--signal);
}

.header-meta {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: var(--muted);
  font: 0.75rem/1.2 "Courier New", monospace;
  letter-spacing: 0.08em;
}

.sound-toggle {
  min-width: 150px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 0.75rem/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  text-align: right;
}

.sound-toggle:hover {
  color: var(--signal);
}

main {
  min-height: calc(100dvh - 145px);
}

.prologue {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 8fr) 2fr;
  min-height: calc(100dvh - 145px);
  padding: clamp(52px, 8vh, 96px) 24px 72px;
  overflow: hidden;
}

.prologue::after {
  position: absolute;
  right: -7vw;
  bottom: -26vw;
  width: 52vw;
  height: 52vw;
  border: 1px solid var(--violet);
  border-radius: 50%;
  box-shadow:
    0 0 0 8vw rgba(120, 108, 255, 0.035),
    0 0 0 18vw rgba(120, 108, 255, 0.02);
  content: "";
  pointer-events: none;
}

.prologue-index {
  color: var(--signal);
  font: 0.75rem/1 "Courier New", monospace;
}

.prologue-copy {
  position: relative;
  z-index: 1;
  max-width: 1020px;
}

.eyebrow {
  margin: 0 0 30px;
  color: var(--signal);
  font: 0.76rem/1 "Courier New", monospace;
  letter-spacing: 0.13em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 1020px;
  margin-bottom: 40px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.1rem, 7.6vw, 8.4rem);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: -0.065em;
}

h1 span {
  display: block;
  color: var(--muted);
  font-style: italic;
}

.prologue-note {
  max-width: 570px;
  margin: 0 0 42px auto;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
}

.begin-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 570px);
  min-height: 68px;
  margin-left: auto;
  padding: 0 20px;
  border: 1px solid var(--signal);
  background: var(--signal);
  color: #090a07;
  font: 700 0.8rem/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  transition: background 180ms ease, color 180ms ease;
}

.begin-button:hover {
  background: transparent;
  color: var(--signal);
}

.begin-button span:last-child {
  font-size: 1.35rem;
}

.prologue-footnote {
  align-self: end;
  justify-self: end;
  margin: 0;
  color: var(--dim);
  font: 0.72rem/1.6 "Courier New", monospace;
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

.workbench {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) minmax(230px, 22vw);
  min-height: calc(100dvh - 145px);
}

.process-rail,
.margin {
  padding: 28px 24px;
}

.process-rail {
  border-right: 1px solid var(--line);
}

.rail-title,
.margin-heading {
  color: var(--muted);
  font: 0.7rem/1 "Courier New", monospace;
  letter-spacing: 0.1em;
}

.process-rail ol {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 52px 0 0;
  padding: 0;
  list-style: none;
}

.process-rail li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  color: var(--dim);
  font: 0.68rem/1.2 "Courier New", monospace;
  letter-spacing: 0.06em;
  transition: color 220ms ease;
}

.process-rail li::before {
  content: "○";
}

.process-rail li.active {
  color: var(--signal);
}

.process-rail li.active::before {
  content: "●";
}

.process-rail li.complete {
  color: var(--ink);
}

.process-rail li.complete::before {
  content: "×";
  color: var(--violet);
}

.composition {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px clamp(24px, 4vw, 72px) 60px;
}

.stage-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-strong);
}

.stage-heading .eyebrow {
  margin-bottom: 8px;
}

.stage-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 3.2rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.05em;
}

.stage-heading > p {
  max-width: 260px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.trace {
  display: flex;
  flex-direction: column;
  justify-content: end;
  min-height: clamp(180px, 30vh, 340px);
  padding: 44px 0 32px;
}

.trace p {
  margin: 0;
}

.empty-trace {
  color: var(--dim);
  font: 0.72rem/1 "Courier New", monospace;
  letter-spacing: 0.1em;
}

.trace-line {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) minmax(170px, 0.28fr);
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 1040px;
  padding: 7px 0;
  color: var(--ink);
  transform-origin: left center;
  animation: line-arrives 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.trace-index {
  color: var(--violet);
  font: 0.75rem/1 "Courier New", monospace;
}

.trace-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.8vw, 1.55rem);
  line-height: 1.16;
}

.trace-score {
  min-width: 0;
}

.vector-bar {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 5px;
  margin-bottom: 7px;
}

.vector-segment {
  min-width: 2px;
  background: rgba(120, 108, 255, 0.28);
  transform: scaleX(0);
  transform-origin: left;
  animation: vector-arrives 620ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.vector-segment:nth-child(2) {
  animation-delay: 70ms;
}

.vector-segment:nth-child(3) {
  animation-delay: 140ms;
}

.vector-segment.selected {
  background: var(--signal);
}

.vector-meta {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  color: var(--dim);
  font: 0.75rem/1 "Courier New", monospace;
  letter-spacing: 0.03em;
}

.vector-meta .resolution-method {
  color: var(--muted);
}

@keyframes vector-arrives {
  to {
    transform: scaleX(1);
  }
}

.score-key {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  margin: -20px 0 24px;
  color: var(--dim);
  font: 0.7rem/1.2 "Courier New", monospace;
  letter-spacing: 0.05em;
}

@keyframes line-arrives {
  from {
    opacity: 0;
    transform: translateY(14px) skewX(-4deg);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.field-instruction {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  color: var(--dim);
  font: 0.65rem/1.2 "Courier New", monospace;
  letter-spacing: 0.08em;
}

.choices {
  border-top: 1px solid var(--line-strong);
}

.field-resolve {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font: 0.7rem/1 "Courier New", monospace;
  letter-spacing: 0.08em;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.field-resolve:hover,
.field-resolve:focus-visible {
  border-color: var(--signal);
  background: rgba(215, 255, 67, 0.04);
  color: var(--signal);
}

.field-resolve:disabled {
  cursor: default;
  opacity: 0.35;
}

.choice {
  --heat: 0;
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 54px;
  align-items: center;
  width: 100%;
  min-height: 80px;
  padding: 13px 0;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(
      90deg,
      rgba(120, 108, 255, calc(var(--heat) * 0.34)),
      transparent calc(18% + var(--heat) * 42%)
    ),
    transparent;
  text-align: left;
  transition: color 160ms ease, opacity 280ms ease, transform 420ms ease;
}

.choice::after {
  position: absolute;
  bottom: 0;
  left: 0;
  width: calc(var(--heat) * 100%);
  height: 1px;
  background: var(--signal);
  content: "";
  transition: width 90ms linear;
}

.choice:hover,
.choice:focus-visible {
  color: var(--signal);
}

.choice-number,
.choice-probability {
  color: var(--muted);
  font: 0.68rem/1 "Courier New", monospace;
  letter-spacing: 0.06em;
}

.choice-text {
  padding-right: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.85vw, 1.5rem);
  line-height: 1.15;
}

.choice-probability {
  text-align: right;
}

.choice.chosen {
  z-index: 2;
  color: var(--signal);
  transform: translateX(10px);
}

.choice.rejected {
  opacity: 0;
  transform: translateX(-32px);
}

.margin {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
}

.margin-heading {
  display: flex;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.margin-heading p {
  margin: 0;
}

.discarded {
  display: flex;
  flex-direction: column-reverse;
  gap: 0;
  padding-top: 8px;
}

.margin-empty {
  margin-top: 16px;
  color: var(--dim);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-style: italic;
}

.discard-group {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  animation: discard-arrives 500ms ease both;
}

.discard-group small {
  display: block;
  margin-bottom: 9px;
  color: var(--violet);
  font: 0.64rem/1 "Courier New", monospace;
}

.discard-group p {
  margin: 0 0 8px;
  color: var(--dim);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  line-height: 1.25;
  text-decoration: line-through;
  text-decoration-color: rgba(215, 255, 67, 0.35);
}

@keyframes discard-arrives {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
}

.ending {
  margin-top: auto;
  padding: 34px 0 10px;
  border-top: 1px solid var(--line-strong);
  animation: line-arrives 700ms ease both;
}

.ending .eyebrow {
  margin-bottom: 16px;
}

.ending h2 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.06em;
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.ending-actions button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font: 0.7rem/1 "Courier New", monospace;
  letter-spacing: 0.07em;
}

.ending-actions button:first-child {
  border-color: var(--signal);
  background: var(--signal);
  color: var(--ground);
}

.ending-actions button:hover {
  border-color: var(--signal);
  color: var(--signal);
}

.ending-actions button:first-child:hover {
  background: transparent;
  color: var(--signal);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  min-height: 41px;
  padding: 13px 24px;
  border-top: 1px solid var(--line-strong);
  color: var(--dim);
  font: 0.62rem/1.2 "Courier New", monospace;
  letter-spacing: 0.06em;
}

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

@media (max-width: 950px) {
  .workbench {
    grid-template-columns: 128px minmax(0, 1fr);
  }

  .process-rail {
    grid-row: 1 / span 2;
  }

  .margin {
    display: block;
    grid-column: 2;
    padding: 32px clamp(24px, 4vw, 72px) 56px;
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .prologue {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .prologue-footnote {
    display: none;
  }
}

@media (max-width: 680px) {
  .site-header {
    grid-template-columns: 1fr auto;
    min-height: 82px;
  }

  .wordmark,
  .sound-toggle {
    min-height: 82px;
    padding: 18px 16px;
  }

  .header-meta {
    display: none;
  }

  .sound-toggle {
    min-width: auto;
  }

  main {
    min-height: calc(100dvh - 123px);
  }

  .prologue {
    display: block;
    min-height: calc(100dvh - 123px);
    padding: 42px 16px 54px;
  }

  .prologue-index {
    margin-bottom: 44px;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 5rem);
    line-height: 0.92;
  }

  .prologue-note,
  .begin-button {
    margin-left: 0;
  }

  .prologue::after {
    right: -30vw;
    bottom: -15vw;
    width: 90vw;
    height: 90vw;
  }

  .workbench {
    display: block;
    min-height: calc(100dvh - 123px);
  }

  .process-rail {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 10, 11, 0.96);
    backdrop-filter: blur(10px);
  }

  .margin {
    padding: 28px 16px 48px;
  }

  .rail-title {
    display: none;
  }

  .process-rail ol {
    flex-direction: row;
    gap: 18px;
    width: max-content;
    margin: 0;
  }

  .process-rail li {
    grid-template-columns: auto 1fr;
  }

  .composition {
    padding: 24px 16px 52px;
  }

  .stage-heading {
    align-items: start;
  }

  .stage-heading > p {
    max-width: 138px;
    font-size: 0.78rem;
  }

  .trace {
    min-height: 260px;
    padding-top: 32px;
  }

  .trace-line {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 7px 8px;
    padding: 9px 0;
  }

  .trace-text {
    font-size: 1.05rem;
  }

  .trace-score {
    grid-column: 2;
  }

  .score-key {
    justify-content: flex-start;
    gap: 8px 16px;
    margin-top: -18px;
  }

  .score-key span:nth-child(2) {
    display: none;
  }

  .field-instruction span:last-child {
    display: none;
  }

  .choice {
    grid-template-columns: 36px minmax(0, 1fr) 44px;
    min-height: 90px;
  }

  .choice-text {
    font-size: 1rem;
  }

  footer {
    padding-inline: 16px;
  }

  footer span:last-child {
    display: none;
  }
}

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

  .attention {
    display: none;
  }
}
