:root {
  color-scheme: dark;
  --ink: #f0f0e8;
  --muted: #92968b;
  --ground: #10110f;
  --panel: #171915;
  --line: #393d34;
  --acid: #c4ff3d;
  --critical: #ff553d;
  --danger: 0;
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 34%, rgba(196, 255, 61, calc(var(--danger) * 0.055)), transparent 38%),
    var(--ground);
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255, 255, 255, 0.018) 3px 4px);
  mix-blend-mode: screen;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

#noise {
  position: fixed;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: calc(0.025 + var(--danger) * 0.14);
  image-rendering: pixelated;
  mix-blend-mode: screen;
}

.game-shell {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(100%, 560px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  flex-direction: column;
}

.masthead,
.footer,
.turn-meta,
.meter-heading,
.dose-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.wordmark i {
  color: var(--acid);
  font-style: normal;
  text-transform: none;
}

.sound-button,
.text-button {
  border: 0;
  padding: 6px 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.sound-button span {
  color: var(--ink);
}

.screen {
  width: 100%;
  margin: auto 0;
  padding: 42px 0;
}

.start-screen,
.result-screen {
  text-align: left;
}

.intro-mark {
  display: grid;
  width: 84px;
  aspect-ratio: 1;
  margin-bottom: 40px;
  padding: 8px;
  border: 1px solid var(--acid);
  grid-template: auto 1fr auto / auto 1fr;
  color: var(--acid);
}

.intro-mark span,
.sample-number {
  font-size: 0.62rem;
}

.intro-mark b {
  grid-column: 1 / -1;
  align-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.intro-mark small {
  grid-column: 1 / -1;
  font-size: 0.45rem;
  letter-spacing: 0.16em;
}

.kicker,
.instruction,
.turn-meta,
.meter-heading,
.dose-line,
.field-note,
.fine-print,
.footer {
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.kicker {
  margin: 0 0 12px;
  color: var(--acid);
  font-size: 0.67rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.8rem, 12vw, 5.2rem);
  font-weight: 650;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.lede,
.result-copy {
  max-width: 43ch;
  margin: 24px 0 32px;
  color: #c4c6bd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 3.8vw, 1.16rem);
  line-height: 1.55;
}

.form-block {
  margin-top: 30px;
}

.form-block label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-block label span {
  color: #62675d;
  font-size: 0.56rem;
  letter-spacing: 0.08em;
}

.identity-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
}

.identity-fields > div {
  min-width: 0;
}

.form-block input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #62675b;
  border-radius: 0;
  padding: 14px 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.15rem;
  outline: none;
}

.form-block input::placeholder {
  color: #565a50;
}

.form-block input:focus {
  border-color: var(--acid);
}

.primary-button,
.secondary-button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--acid);
  border-radius: 0;
  padding: 0 17px;
  background: var(--acid);
  color: #11130e;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-decoration: none;
}

.form-block .primary-button {
  margin-top: 18px;
}

.primary-button:hover {
  background: #d2ff69;
}

.secondary-button {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--ink);
}

.fine-print,
.field-note {
  color: #6f7369;
  font-size: 0.56rem;
  line-height: 1.55;
}

.fine-print {
  margin: 20px 0 0;
}

.field-note {
  margin: 9px 0 0;
}

.form-error,
.share-status {
  min-height: 1.1em;
  margin: 8px 0 0;
  color: var(--critical);
  font-size: 0.75rem;
}

.holding-screen {
  padding: 26px 0 34px;
}

.turn-meta {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
}

.sample-wrap {
  display: grid;
  place-items: center;
  margin: clamp(26px, 6vh, 50px) auto clamp(22px, 5vh, 40px);
}

.sample {
  position: relative;
  display: grid;
  width: clamp(116px, 31vw, 148px);
  aspect-ratio: 1;
  padding: 14px;
  border: 1px solid #66724b;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 42%),
    #1b1e18;
  box-shadow:
    0 0 calc(12px + var(--danger) * 42px) rgba(196, 255, 61, calc(0.16 + var(--danger) * 0.32)),
    inset 0 0 30px rgba(196, 255, 61, 0.035);
  color: var(--acid);
  transform: translate(calc((var(--danger) - 0.72) * var(--jitter-x, 0px)), calc((var(--danger) - 0.72) * var(--jitter-y, 0px)));
}

.sample strong {
  align-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.5rem, 15vw, 4.9rem);
  font-weight: 400;
  line-height: 0.8;
  text-align: center;
}

.sample small {
  align-self: end;
  font-size: 0.54rem;
  letter-spacing: 0.12em;
}

.sample-caption {
  margin-top: 12px;
  color: #7f8476;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.warning-copy {
  text-align: center;
}

.instruction {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.warning-copy h1 {
  color: color-mix(in srgb, var(--acid), var(--critical) calc(var(--danger) * 80%));
  font-size: clamp(1.75rem, 8vw, 3.1rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.meter-block {
  margin: clamp(28px, 6vh, 48px) 0 0;
}

.meter-heading,
.dose-line {
  font-size: 0.6rem;
  font-weight: 700;
}

.meter-heading strong {
  color: var(--acid);
  font-size: 0.78rem;
}

.meter {
  height: 5px;
  margin: 10px 0 12px;
  overflow: hidden;
  background: #292c26;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--acid);
  transition: width 180ms linear;
}

.dose-line {
  color: #70756a;
}

.dose-line span:last-child {
  color: var(--ink);
}

.pass-form {
  margin-top: clamp(28px, 6vh, 46px);
}

.result-glyph {
  margin: 0 0 42px;
  color: var(--critical);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 5rem;
  line-height: 0.7;
}

.result-glyph.safe,
body.won .result-glyph,
body.won .kicker {
  color: var(--acid);
}

.opening-note {
  margin: -8px 0 26px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.opening-note b {
  color: var(--ink);
}

.share-actions {
  display: grid;
  gap: 9px;
}

.share-status {
  color: var(--acid);
}

.text-button.new-game-button {
  margin-top: 28px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.result-stats {
  margin: 36px 0;
  border-top: 1px solid var(--line);
}

.result-stats div {
  display: flex;
  padding: 13px 0;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.result-stats dt {
  color: var(--muted);
}

.result-stats dd {
  margin: 0;
  font-weight: 700;
}

.chain-block {
  margin: 0 0 30px;
}

.section-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.chain-list {
  display: flex;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
}

.chain-list li {
  border: 1px solid var(--line);
  padding: 7px 9px;
  color: #c4c6bd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
}

.chain-list li:last-child {
  border-color: var(--acid);
  color: var(--ink);
}

.chain-list span {
  margin-right: 6px;
  color: #666b60;
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.55rem;
}

.initiator-note {
  margin: 0 0 30px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.initiator-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.initiator-note p + p {
  margin-top: 4px;
}

.initiator-note strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.initiator-note .secondary-button {
  margin-top: 16px;
}

.footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: #55594f;
  font-size: 0.48rem;
}

body.critical .game-shell {
  animation: tension 130ms steps(2, end) infinite;
}

body.dead {
  --danger: 1;
}

body.dead::after {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  background: white;
  animation: flash-out 520ms ease-out forwards;
}

@keyframes tension {
  0% { transform: translate(0, 0); }
  50% { transform: translate(1px, -1px); }
  100% { transform: translate(-1px, 1px); }
}

@keyframes flash-out {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

@media (min-width: 600px) {
  .game-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .start-screen,
  .result-screen {
    padding-top: 60px;
    padding-bottom: 60px;
  }
}

@media (max-height: 760px) {
  .sample-wrap {
    margin-top: 18px;
    margin-bottom: 18px;
  }

  .sample {
    width: 106px;
  }

  .meter-block,
  .pass-form {
    margin-top: 22px;
  }
}

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

  .sample {
    transform: none;
  }
}
