:root {
  color-scheme: dark;
  --ink: #fff8dc;
  --muted: rgba(255, 248, 220, .68);
  --coral: #ff6e62;
  --cyan: #85f0ff;
  --violet: #7a47ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #120c38;
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

#experience, #stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100svh;
}

#stage {
  outline: none;
  isolation: isolate;
  touch-action: none;
  user-select: none;
}

#city {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.intro, .scene-copy, .finale {
  position: absolute;
  z-index: 3;
}

.intro {
  left: max(28px, env(safe-area-inset-left));
  bottom: max(38px, calc(env(safe-area-inset-bottom) + 24px));
  width: min(640px, calc(100vw - 56px));
  transition: opacity .7s ease, transform .8s cubic-bezier(.2,.8,.2,1);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .19em;
  text-transform: uppercase;
}

h1, .finale h2 {
  margin: 0;
  max-width: 10ch;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 8.4vw, 112px);
  font-weight: 400;
  letter-spacing: -.065em;
  line-height: .78;
  text-wrap: balance;
  text-shadow: 0 3px 40px rgba(13, 7, 48, .22);
}

.lede {
  margin: 24px 0 22px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.35;
}

#begin, #restart {
  min-height: 48px;
  padding: 0 19px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 999px;
  color: #160e42;
  background: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(9, 5, 33, .18);
  transition: transform .2s ease, background .2s ease;
}

#begin:hover, #restart:hover { transform: translateY(-2px); background: #fff; }
#begin:focus-visible, #restart:focus-visible, .about-button:focus-visible, .step-zone:focus-visible, #about-close:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.scene-copy {
  top: max(24px, env(safe-area-inset-top));
  left: max(26px, env(safe-area-inset-left));
  width: min(420px, calc(100vw - 110px));
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .45s ease, transform .55s ease;
  pointer-events: none;
}

.scene-copy p { margin: 0; }
.scene-copy #district-number {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.scene-copy h2 {
  margin: 5px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 400;
  letter-spacing: -.04em;
  line-height: 1;
}

.scene-copy #district-line {
  max-width: 36ch;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.step-zones {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  opacity: 0;
  pointer-events: none;
}

.step-zone {
  width: 50%;
  height: 100%;
  padding: 0;
  border: 0;
  color: transparent;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.step-zone span {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  color: rgba(255,255,255,.48);
  font-size: 9px;
  font-weight: 800;
}

.step-left span { left: max(18px, env(safe-area-inset-left)); }
.step-right span { right: max(18px, env(safe-area-inset-right)); }

.instruction {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.7);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .4s ease, transform .4s ease;
  pointer-events: none;
  white-space: nowrap;
}

.keys { display: flex; gap: 3px; }
.keys i {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  font-style: normal;
}

.finale {
  top: 50%;
  left: 50%;
  width: min(780px, calc(100vw - 48px));
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -42%);
  pointer-events: none;
  transition: opacity 1s ease, transform 1.1s cubic-bezier(.2,.8,.2,1);
}

.finale .eyebrow { color: #fff0a5; }
.finale h2 {
  max-width: none;
  font-size: clamp(48px, 9vw, 126px);
  line-height: .79;
  text-shadow: 0 6px 42px rgba(10, 4, 40, .72);
}

.finale #final-line {
  margin: 24px auto 20px;
  color: rgba(255,255,255,.84);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(16px, 2vw, 21px);
  text-shadow: 0 3px 20px #10092f;
}

.about-button {
  position: absolute;
  z-index: 5;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 48px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: rgba(255,255,255,.72);
  background: rgba(16, 9, 48, .14);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

#experience[data-state="walking"] .intro,
#experience[data-state="transition"] .intro,
#experience[data-state="finale"] .intro,
#experience[data-state="complete"] .intro {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

#experience[data-state="walking"] .scene-copy,
#experience[data-state="transition"] .scene-copy {
  opacity: 1;
  transform: translateY(0);
}

#experience[data-state="walking"] .step-zones { opacity: 1; pointer-events: auto; }
#experience[data-state="walking"] .instruction { opacity: 1; transform: translate(-50%, 0); }

#experience[data-state="complete"] .finale {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

dialog {
  width: min(520px, calc(100vw - 34px));
  padding: 30px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 22px;
  color: var(--ink);
  background: rgba(22, 13, 63, .96);
  box-shadow: 0 30px 100px rgba(0,0,0,.54);
}

dialog::backdrop { background: rgba(5, 3, 20, .76); backdrop-filter: blur(8px); }
dialog h2 { margin: 0 40px 14px 0; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 400; letter-spacing: -.04em; }
dialog p:not(.eyebrow) { color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.6; }
#about-close { position: absolute; top: 15px; right: 15px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: white; background: rgba(255,255,255,.1); font-size: 24px; cursor: pointer; }

.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: 620px) {
  .intro { bottom: max(72px, calc(env(safe-area-inset-bottom) + 54px)); width: calc(100vw - 44px); left: 22px; }
  h1 { font-size: clamp(48px, 16vw, 74px); }
  .lede { margin-top: 20px; }
  .scene-copy { top: max(20px, env(safe-area-inset-top)); left: 20px; }
  .scene-copy h2 { font-size: 31px; }
  .instruction { bottom: max(18px, env(safe-area-inset-bottom)); }
  #instruction-copy { display: none; }
  .keys i { width: 30px; height: 30px; }
  .finale { width: calc(100vw - 34px); }
  .finale h2 { font-size: clamp(50px, 17vw, 82px); }
}

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