:root {
  color-scheme: dark;
  --ink: #f2f8f5;
  --muted: #a8bcc4;
  --night: #061827;
  --warm: #ff735f;
  --cool: #63e5ff;
  --bridge: #e9ffd2;
  --bridge-progress: 0;
  --settled: 0;
  --safe-top: max(1rem, env(safe-area-inset-top));
  --safe-bottom: max(1rem, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

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

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  contain: strict;
  color: var(--ink);
  font-family: "Helvetica Neue", "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  isolation: isolate;
}

button,
a { font: inherit; }

button { color: inherit; }

#weather,
.bridge-art,
.grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#weather {
  z-index: -4;
  display: block;
}

.bridge-art {
  z-index: -3;
  object-fit: cover;
  opacity: calc(var(--bridge-progress) * .76 - var(--settled) * .28);
  filter: saturate(calc(.9 - var(--settled) * .62)) contrast(1.06) brightness(calc(.72 - var(--settled) * .08));
  mix-blend-mode: screen;
  transform: scale(calc(1.06 - var(--bridge-progress) * .06));
  transition: opacity 900ms ease, transform 1800ms cubic-bezier(.2,.7,.2,1);
  pointer-events: none;
}

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

.masthead {
  position: fixed;
  z-index: 20;
  top: var(--safe-top);
  left: clamp(1rem, 3vw, 2.5rem);
  right: clamp(1rem, 3vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(242,248,245,.7);
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .15em;
  text-transform: uppercase;
  pointer-events: none;
}

.archive-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: .65rem;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}

.archive-mark {
  width: 1.4rem;
  height: .45rem;
  border-top: 1px solid var(--warm);
  border-bottom: 1px solid var(--cool);
  transform: skewX(-25deg);
}

#experience { position: absolute; inset: 0; }

.intro-panel {
  position: absolute;
  left: clamp(1.25rem, 8vw, 8rem);
  right: clamp(1.25rem, 50vw, 54rem);
  bottom: clamp(2rem, 9vh, 6.5rem);
  z-index: 10;
  max-width: 48rem;
  animation: arrive 1000ms both cubic-bezier(.2,.7,.2,1);
}

.eyebrow {
  margin: 0 0 1.1rem;
  color: #bcd0d6;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 7.2vw, 6.8rem);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .9;
  text-wrap: balance;
}

.dek {
  max-width: 35rem;
  margin: clamp(1.4rem, 3vw, 2.4rem) 0 1.65rem;
  color: #c4d2d5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.55vw, 1.3rem);
  line-height: 1.45;
}

.start-button,
.again-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-width: min(22rem, 100%);
  min-height: 52px;
  padding: .85rem 1rem .85rem 1.2rem;
  border: 1px solid rgba(233,255,210,.4);
  border-radius: 999px;
  background: rgba(8,29,42,.56);
  box-shadow: 0 1rem 4rem rgba(0,0,0,.2);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.start-button:hover,
.again-button:hover { background: rgba(233,255,210,.1); }

.start-button:focus-visible,
.again-button:focus-visible,
.archive-link:focus-visible,
.weather-control:focus-visible {
  outline: 2px solid var(--bridge);
  outline-offset: 4px;
}

.key-hint {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.field-ui { position: absolute; inset: 0; z-index: 5; }

.weather-control {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 50%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}

.weather-control--left { left: 0; }
.weather-control--right { right: 0; }

.weather-control::after {
  content: "";
  position: absolute;
  inset: 18% 12%;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 300ms ease;
}

.weather-control--left::after { box-shadow: inset 0 0 5rem rgba(255,115,95,.15); }
.weather-control--right::after { box-shadow: inset 0 0 5rem rgba(99,229,255,.15); }
.weather-control[aria-pressed="true"]::after { opacity: 1; }

.control-key {
  position: absolute;
  bottom: calc(var(--safe-bottom) + .2rem);
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 50%;
  color: rgba(255,255,255,.7);
  font-size: .66rem;
  font-weight: 750;
  letter-spacing: .1em;
  background: rgba(5,20,31,.22);
  backdrop-filter: blur(10px);
}

.weather-control--left .control-key { left: clamp(1rem, 3vw, 2.5rem); }
.weather-control--right .control-key { right: clamp(1rem, 3vw, 2.5rem); }

.side-caption {
  position: absolute;
  z-index: 3;
  top: 18%;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  width: min(20rem, 38vw);
  pointer-events: none;
}

.side-caption--left { left: clamp(1rem, 4vw, 4rem); text-align: left; }
.side-caption--right { right: clamp(1rem, 4vw, 4rem); text-align: right; }

.side-name {
  color: rgba(255,255,255,.55);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.side-caption strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(.95rem, 1.9vw, 1.35rem);
  font-weight: 400;
}

.side-caption--left strong { color: #ffd0c7; }
.side-caption--right strong { color: #c8f7ff; }

.narrator {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 3.85rem);
  width: min(32rem, calc(100% - 2.5rem));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 16px var(--night);
}

.chapter {
  margin: 0 0 .65rem;
  color: rgba(255,255,255,.52);
  font-size: .61rem;
  font-weight: 750;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.instruction {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2.3vw, 1.5rem);
  line-height: 1.25;
}

.phase-dots {
  display: flex;
  justify-content: center;
  gap: .38rem;
  margin-top: 1rem;
}

.phase-dots i {
  width: 1.2rem;
  height: 2px;
  background: rgba(255,255,255,.2);
  transition: background-color 400ms ease, transform 400ms ease;
}

.phase-dots i.is-done { background: rgba(233,255,210,.48); }
.phase-dots i.is-current { background: var(--bridge); transform: scaleX(1.4); }

.pressure {
  position: absolute;
  z-index: 4;
  top: 31%;
  bottom: 31%;
  width: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255,255,255,.12);
  pointer-events: none;
}

.pressure--left { left: clamp(.5rem, 1.5vw, 1.4rem); }
.pressure--right { right: clamp(.5rem, 1.5vw, 1.4rem); }

.pressure i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10%;
  border-radius: inherit;
  transition: height 120ms linear;
}

.pressure--left i { background: var(--warm); }
.pressure--right i { background: var(--cool); }

.ending {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 50%;
  width: min(44rem, calc(100% - 2.5rem));
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.ending.is-visible {
  opacity: 1;
  pointer-events: auto;
  animation: endingIn 1100ms both cubic-bezier(.2,.7,.2,1);
}

.ending h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 6.5vw, 6rem);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: .95;
}

.ending > p:not(.eyebrow) {
  max-width: 34rem;
  margin: 1.6rem auto 2rem;
  color: #d3deda;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  line-height: 1.45;
}

.again-button { min-width: 14rem; }

.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;
}

[hidden] { display: none !important; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(1rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes endingIn {
  from { opacity: 0; transform: translate(-50%, -47%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 680px) {
  .masthead { font-size: .58rem; }
  .date { display: none; }
  .intro-panel { right: 1.25rem; bottom: calc(var(--safe-bottom) + 1.25rem); }
  h1 { font-size: clamp(2.7rem, 13.5vw, 4.8rem); }
  .dek { max-width: 27rem; margin-top: 1.4rem; }
  .side-caption { top: 20%; width: 41vw; }
  .side-caption--left { left: 1rem; }
  .side-caption--right { right: 1rem; }
  .side-caption strong { font-size: .95rem; }
  .narrator { bottom: calc(var(--safe-bottom) + 3.5rem); }
  .instruction { font-size: 1.08rem; }
  .control-key { width: 2.75rem; height: 2.75rem; }
}

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

@media (prefers-contrast: more) {
  .side-name, .chapter, .masthead { color: #fff; }
  .pressure { width: 4px; }
}
