:root {
  --paper: #eaff54;
  --ink: #171717;
  --pink: #ff4f87;
  --blue: #1a9fff;
  --violet: #7a54ff;
  --orange: #ff8b1f;
  --teal: #00a889;
  --white: #fffdf4;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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

body {
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100svh;
}

button, a { font: inherit; }

button:focus-visible, a:focus-visible, #field:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 4px;
}

#experience {
  position: relative;
  min-height: 100svh;
  padding: 24px 28px calc(18px + var(--safe-bottom));
  isolation: isolate;
}

#experience::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 17% 18%, rgba(255,255,255,.22) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 77% 68%, rgba(23,23,23,.055) 0 1px, transparent 2px);
  background-size: 31px 31px, 23px 23px;
}

#experience::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 0 48%, rgba(255,255,255,.16) 48% 49%, transparent 49% 100%);
}

.masthead {
  position: relative;
  z-index: 5;
  width: min(72vw, 950px);
}

.kicker, .readers-label, .chapter span, footer {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(3.2rem, 7.8vw, 8rem);
  font-weight: 1000;
  letter-spacing: -.082em;
  line-height: .76;
  text-transform: uppercase;
  text-wrap: balance;
}

.chapter {
  position: absolute;
  z-index: 5;
  top: 28px;
  right: 28px;
  width: min(230px, 25vw);
  border-top: 5px solid var(--ink);
  padding-top: 8px;
  display: grid;
  gap: 5px;
}

.chapter strong {
  font-size: clamp(.9rem, 1.5vw, 1.25rem);
  line-height: 1;
  text-transform: uppercase;
}

.instruction {
  position: relative;
  z-index: 5;
  margin: 18px 0 0;
  max-width: 660px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  line-height: 1.25;
}

.field-wrap {
  position: relative;
  width: min(100%, 1500px);
  margin: -7.2vw auto -3.2vw;
}

#field {
  display: block;
  width: 100%;
  max-height: 69svh;
  min-height: 420px;
  overflow: visible;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}

.field-notes path {
  fill: none;
  stroke: rgba(23, 23, 23, .18);
  stroke-width: 1.6;
  stroke-dasharray: 3 9;
}

.field-notes text {
  fill: rgba(23, 23, 23, .4);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
}

.drawn-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: url(#roughShadow);
}

.erased-line {
  fill: none;
  stroke: var(--paper);
  stroke-width: 19;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.reverse-wake {
  fill: none;
  stroke: var(--teal);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 12;
  opacity: .95;
  vector-effect: non-scaling-stroke;
}

.ghost-path {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 7 10;
  opacity: 0;
  vector-effect: non-scaling-stroke;
  transition: opacity .2s ease;
}

.is-reading .ghost-path { opacity: .82; }

.obstacle circle.outer {
  fill: url(#hatch);
  stroke: var(--ink);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.obstacle circle.inner {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.obstacle text {
  fill: var(--ink);
  font-size: 9px;
  font-weight: 900;
  text-anchor: middle;
  letter-spacing: .12em;
}

.door .door-slot {
  fill: var(--white);
  stroke-width: 5;
  opacity: .86;
  vector-effect: non-scaling-stroke;
}

.door .door-mark { opacity: .42; }

.door text {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.door .accepted { opacity: 0; font-size: 8px; }

.door.arrived .door-slot {
  opacity: 1;
  animation: door-ping .55s cubic-bezier(.2,.8,.2,1) both;
}

.door.arrived .door-mark, .door.arrived .accepted { opacity: 1; }

.field-resolution { opacity: 0; transform: translateY(14px); transition: opacity .25s ease, transform .35s cubic-bezier(.2,.8,.2,1); }
.field-resolution rect { fill: var(--ink); }
.field-resolution text { fill: var(--paper); font-size: 15px; font-weight: 1000; letter-spacing: .055em; }
.threshold-met .field-resolution { opacity: 1; transform: translateY(0); }

.marker circle {
  stroke: var(--ink);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.marker-start circle { fill: var(--ink); }
.marker-end circle:first-child { fill: var(--white); }
.marker-end circle:nth-child(2) { fill: var(--paper); stroke-width: 2; }

.marker text {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
}

.marker.is-hot circle { animation: marker-pulse .75s ease-in-out infinite alternate; }

.traveler { transition: opacity .2s ease; }
.traveler .body { stroke: var(--ink); stroke-width: 3; vector-effect: non-scaling-stroke; }
.traveler .eye { fill: var(--ink); }
.traveler.bump .body { animation: bump .28s linear 2; }
.traveler-tag {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .05em;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.readers {
  position: relative;
  z-index: 6;
  max-width: 1080px;
  margin: 0 auto;
  border-top: 3px solid var(--ink);
  padding-top: 8px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
}

.readers ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.readers li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 14px;
}

.reader-name {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .08em;
}

.reader-name::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border: 2px solid var(--ink);
  background: var(--reader-color);
  transform: rotate(45deg);
}

.actions {
  position: relative;
  z-index: 8;
  min-height: 57px;
  max-width: 1080px;
  margin: 14px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

button {
  min-height: 46px;
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 10px 15px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.primary { background: var(--ink); color: var(--paper); }
button[hidden] { display: none; }

.result {
  position: absolute;
  z-index: 7;
  right: 30px;
  bottom: 96px;
  max-width: 420px;
  margin: 0;
  text-align: right;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.1rem, 2vw, 1.7rem);
  font-style: italic;
  line-height: 1.05;
  pointer-events: none;
}

.finale-copy {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  pointer-events: none;
  opacity: 0;
  transform: rotate(-4deg) scale(.9);
}

.finale-copy span {
  display: block;
  font-size: clamp(4rem, 12vw, 12rem);
  font-weight: 1000;
  letter-spacing: -.09em;
  line-height: .72;
  color: rgba(255, 79, 135, .2);
  -webkit-text-stroke: 2px var(--pink);
}

.finale .finale-copy {
  opacity: 1;
  transform: rotate(-4deg) scale(1);
  transition: opacity .7s ease, transform .9s cubic-bezier(.16,1,.3,1);
}

footer {
  position: relative;
  z-index: 6;
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

footer a {
  color: inherit;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -16px;
}

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

@keyframes marker-pulse {
  to { transform: scale(1.18); }
}

@keyframes bump {
  25% { transform: rotate(-18deg) scale(.85); }
  75% { transform: rotate(18deg) scale(1.12); }
}

@keyframes door-ping {
  50% { stroke-width: 15; opacity: 1; }
}

@media (max-width: 760px) {
  #experience { padding: 16px 14px calc(14px + var(--safe-bottom)); }
  .masthead { width: 78%; }
  h1 { font-size: clamp(2.55rem, 12.15vw, 5rem); line-height: .8; }
  .chapter { top: 18px; right: 14px; width: 27%; border-top-width: 4px; }
  .chapter strong { font-size: .72rem; }
  .instruction { margin-top: 14px; max-width: 90%; font-size: .98rem; }
  .field-wrap { width: 100%; margin: -14px 0 -16px; }
  #field { min-height: 360px; max-height: 55svh; }
  #field { min-height: 390px; max-height: 60svh; }
  .readers { grid-template-columns: 1fr; gap: 6px; padding-top: 6px; }
  .readers ul { gap: 5px 12px; }
  .readers li { font-size: 12px; }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 50px; }
  .actions button { min-width: 0; padding-inline: 8px; font-size: 11px; line-height: 1.05; }
  .result { position: relative; right: auto; bottom: auto; margin: 5px 0 0; max-width: none; text-align: left; min-height: 1.2em; }
  footer { flex-wrap: wrap; justify-content: flex-start; font-size: 9px; }
  footer span:last-child { width: 100%; }
  .field-notes text { display: none; }
}

@media (max-height: 720px) and (min-width: 761px) {
  #experience { padding-top: 14px; }
  h1 { font-size: clamp(3.2rem, 6.6vw, 6rem); }
  .instruction { margin-top: 10px; }
  .field-wrap { margin-top: -9vw; margin-bottom: -5vw; }
  #field { min-height: 330px; max-height: 62svh; }
}

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