:root {
  color-scheme: dark;
  --ink: #eef3df;
  --muted: #aeb8aa;
  --water: #b9fff0;
  --water-deep: #6dd7d0;
  --lichen: #dceb79;
  --night: #10191a;
  --world-scale: 1;
  --world-x: 0px;
  --world-y: 0px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 320px;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  position: fixed;
  inset: 0;
}

button,
dialog { font: inherit; }

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

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

#app {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 560px;
  isolation: isolate;
  overflow: hidden;
  background: var(--night);
}

#world {
  position: absolute;
  inset: -1px;
  z-index: 0;
  overflow: hidden;
  transform: translate3d(var(--world-x), var(--world-y), 0) scale(var(--world-scale));
  transform-origin: 50% 50%;
  transition: transform 1.8s cubic-bezier(.16,.72,.18,1), filter 1.2s ease;
  will-change: transform;
}

#geology {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  filter: saturate(.82) brightness(.78) contrast(1.08);
  transform: scale(1.025);
}

#storm-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 13, 18, .08) 0%, rgba(6, 13, 12, .04) 32%, rgba(4, 9, 9, .44) 100%),
    radial-gradient(circle at 50% 30%, transparent 0 12%, rgba(1, 8, 8, .18) 62%, rgba(0, 5, 5, .68) 100%);
  mix-blend-mode: multiply;
  pointer-events: none;
}

#routes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#stone-marks path {
  fill: none;
  stroke: rgba(236, 219, 177, .15);
  stroke-width: 2;
  stroke-dasharray: 1 10;
}

#history path,
#candidates path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

#history path {
  stroke: rgba(190, 255, 239, .32);
  stroke-width: 1.6;
  filter: url(#water-glow);
}

#history path.taking {
  stroke: var(--water);
  stroke-width: 3.2;
}

#candidates path {
  stroke: rgba(191, 255, 238, .68);
  stroke-width: 1.5;
  stroke-dasharray: 3 10;
  animation: fissure-breathe 2.8s ease-in-out infinite;
}

#signature-water {
  opacity: 0;
  transition: opacity 1.6s ease;
}

#signature-water.revealed { opacity: 1; }

#confluence {
  fill: none;
  stroke: var(--water);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

#signature-water.joined #confluence {
  opacity: .9;
  animation: confluence-ring 1.8s ease-out infinite;
}

#signature-water.joined #old-drop { opacity: .25; }

#old-thread {
  fill: none;
  stroke: url(#old-water);
  stroke-width: 4;
  stroke-dasharray: 8 12;
  filter: url(#water-glow);
  animation: old-current 2.2s linear infinite;
}

#old-drop {
  fill: #dcfff5;
  filter: url(#water-glow);
}

#drop {
  position: absolute;
  left: 50%;
  top: 27%;
  width: 30px;
  height: 30px;
  z-index: 5;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(169, 255, 239, .95));
  transition: opacity .5s ease;
}

#drop::before,
#drop::after,
#drop span {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 52% 48% 62% 38% / 35% 45% 55% 65%;
  background: radial-gradient(circle at 32% 25%, #fff 0 8%, #c9fff5 24%, #79d9d2 72%, #336a6e 100%);
  transform: rotate(45deg);
}

#drop::before {
  inset: 1px;
  opacity: .2;
  animation: drop-ring 2.3s ease-out infinite;
}

#drop::after {
  inset: 10px;
  opacity: .7;
}

#choice-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.route-choice {
  position: absolute;
  width: clamp(136px, 18vw, 220px);
  min-height: 54px;
  padding: 10px 14px 11px;
  border: 1px solid rgba(199, 255, 241, .46);
  border-radius: 18px 34px 20px 30px;
  background: rgba(10, 24, 23, .74);
  color: var(--ink);
  box-shadow: 0 12px 35px rgba(0, 0, 0, .28), inset 0 0 0 1px rgba(255,255,255,.025);
  backdrop-filter: blur(12px) saturate(.8);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  text-align: left;
  transition: border-color .25s ease, background .25s ease, transform .25s ease, opacity .3s ease;
}

.route-choice::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  border: 1px solid rgba(185, 255, 240, .12);
  border-radius: inherit;
  transform: translate(-50%, -50%);
  animation: choice-ring 2.8s ease-out infinite;
}

.route-choice:hover {
  border-color: var(--water);
  background: rgba(18, 43, 40, .9);
  transform: translate(-50%, -50%) scale(1.025);
}

.route-choice strong,
.route-choice small { display: block; }

.route-choice strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(15px, 1.4vw, 19px);
  font-weight: 500;
  letter-spacing: -.015em;
}

.route-choice small {
  margin-top: 2px;
  color: #aebdb6;
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.route-choice.is-leaving {
  opacity: 0;
  pointer-events: none;
}

#rain {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  opacity: .62;
  transition: opacity 1.4s ease;
}

.rain-line {
  position: absolute;
  top: -16vh;
  width: 1px;
  height: var(--length);
  background: linear-gradient(180deg, transparent, rgba(206, 239, 236, .7));
  transform: rotate(12deg);
  animation: rain-fall var(--duration) linear var(--delay) infinite;
}

.site-mark {
  position: absolute;
  z-index: 12;
  left: max(20px, env(safe-area-inset-left));
  top: max(18px, env(safe-area-inset-top));
  display: flex;
  gap: 12px;
  align-items: center;
  color: rgba(233, 242, 226, .72);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.site-mark time {
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.24);
  color: rgba(233, 242, 226, .44);
}

.quiet-button {
  position: absolute;
  z-index: 12;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  min-width: 58px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(6, 16, 16, .28);
  color: rgba(238, 243, 223, .8);
  cursor: pointer;
}

.panel {
  position: absolute;
  z-index: 10;
}

.opening-panel {
  left: max(5vw, 26px);
  bottom: max(6vh, 34px);
  max-width: min(550px, 88vw);
  text-shadow: 0 3px 30px rgba(0,0,0,.65);
  transition: opacity .7s ease, transform .9s ease;
}

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

h1,
h2,
p { text-wrap: balance; }

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(55px, 9.2vw, 126px);
  font-weight: 400;
  line-height: .82;
  letter-spacing: -.075em;
}

.opening-copy {
  margin: 22px 0 24px;
  color: rgba(238, 243, 223, .78);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 25px);
  line-height: 1.3;
}

.primary-button {
  min-height: 50px;
  padding: 12px 19px;
  border: 0;
  border-radius: 999px;
  background: var(--water);
  color: #10201e;
  box-shadow: 0 12px 34px rgba(4, 13, 12, .3);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .015em;
  cursor: pointer;
  transition: transform .25s ease, background .25s ease;
}

.primary-button:hover { transform: translateY(-2px); background: #dcfff7; }

.primary-button span { display: inline-block; margin-left: 8px; }

.story-panel {
  left: max(4vw, 22px);
  bottom: max(4vh, 22px);
  max-width: min(520px, 78vw);
  padding: 18px 20px 16px;
  border-left: 1px solid rgba(185, 255, 240, .48);
  background: linear-gradient(90deg, rgba(7, 15, 14, .68), rgba(7, 15, 14, 0));
  pointer-events: none;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity .6s ease, transform .7s ease;
}

.story-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 3vw, 39px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -.035em;
}

#time-line {
  margin: 9px 0 0;
  color: var(--water);
  font-size: 12px;
  letter-spacing: .02em;
}

#choice-help {
  margin: 5px 0 0;
  color: rgba(234, 240, 223, .55);
  font-size: 10px;
}

#progress {
  position: absolute;
  z-index: 11;
  left: max(20px, env(safe-area-inset-left));
  top: 50%;
  display: grid;
  gap: 9px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity .6s ease;
}

#progress span {
  width: 5px;
  height: 5px;
  border: 1px solid rgba(233, 243, 224, .48);
  border-radius: 50%;
  transition: height .4s ease, background .4s ease, border-color .4s ease;
}

#progress span.current {
  height: 28px;
  border-radius: 8px;
  border-color: var(--water);
  background: var(--water);
}

#surface-clock {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: 0;
  height: 19vh;
  min-height: 118px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-100%);
  border-bottom: 1px solid rgba(198, 255, 240, .28);
  transition: opacity 1s ease, transform 1.4s cubic-bezier(.2,.78,.2,1);
  background: #17211f;
}

#surface-clock.active {
  opacity: 1;
  transform: translateY(0);
}

.season-grid { position: absolute; inset: 0; }

.season-panel {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  background-image:
    linear-gradient(180deg, var(--season-wash), rgba(7, 13, 12, .08)),
    url("geology-field.webp");
  background-size: cover;
  background-position: 50% 7%;
  background-blend-mode: color, normal;
  filter: saturate(var(--season-saturation)) brightness(var(--season-brightness));
  animation: season-panel-cycle 6.4s steps(1, end) infinite;
}

.season-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.09), transparent 60%, rgba(3,9,8,.38));
}

.season-panel span {
  position: absolute;
  z-index: 1;
  left: 18px;
  bottom: 11px;
  color: rgba(246, 247, 226, .9);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.season-spring { --season-wash: rgba(132, 186, 128, .62); --season-saturation: 1.05; --season-brightness: 1; }
.season-summer { --season-wash: rgba(226, 178, 78, .48); --season-saturation: 1.18; --season-brightness: 1.08; animation-delay: -4.8s; }
.season-autumn { --season-wash: rgba(183, 82, 39, .58); --season-saturation: 1.2; --season-brightness: .9; animation-delay: -3.2s; }
.season-winter { --season-wash: rgba(185, 213, 220, .66); --season-saturation: .42; --season-brightness: 1.03; animation-delay: -1.6s; }

.season-label {
  position: absolute;
  right: 18px;
  bottom: 12px;
  color: rgba(246, 247, 226, .76);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.ending-panel {
  left: max(6vw, 26px);
  bottom: max(7vh, 40px);
  width: min(640px, 86vw);
  padding: 26px 28px 24px;
  border: 1px solid rgba(203, 255, 241, .18);
  background: rgba(7, 15, 14, .74);
  box-shadow: 0 30px 80px rgba(0,0,0,.34);
  backdrop-filter: blur(18px) saturate(.8);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity .9s ease, transform 1s ease;
}

.ending-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 6vw, 76px);
  font-weight: 400;
  line-height: .93;
  letter-spacing: -.055em;
}

#ending-copy {
  max-width: 48ch;
  margin: 16px 0 20px;
  color: rgba(235, 242, 224, .76);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.45;
}

.ending-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.text-button {
  min-height: 48px;
  padding: 10px 15px;
  border: 0;
  background: transparent;
  color: rgba(237, 244, 225, .72);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

#path-summary {
  margin: 14px 0 0;
  padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: rgba(232, 240, 220, .68);
  font-size: 12px;
  line-height: 1.5;
}

#app[data-phase="playing"] .opening-panel {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

#app[data-phase="playing"] .story-panel,
#app[data-phase="playing"] #progress {
  opacity: 1;
  transform: translateY(0);
}

#app[data-phase="playing"] #progress { transform: translateY(-50%); }

#app[data-phase="deep"] .story-panel { bottom: max(3vh, 18px); }

#app[data-phase="deep"] .opening-panel {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

#app[data-phase="deep"] .story-panel,
#app[data-phase="deep"] #progress {
  opacity: 1;
}

#app[data-phase="deep"] #progress { transform: translateY(-50%); }

#app[data-phase="ending"] .story-panel,
#app[data-phase="ending"] #progress,
#app[data-phase="ending"] .opening-panel { opacity: 0; pointer-events: none; }

#app[data-phase="ending"] .ending-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#app[data-phase="ending"] #rain { opacity: .12; }

dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(80svh, 680px);
  padding: 30px;
  border: 1px solid rgba(194, 255, 239, .22);
  border-radius: 22px;
  background: rgba(12, 24, 23, .96);
  color: var(--ink);
  box-shadow: 0 40px 120px rgba(0,0,0,.5);
}

dialog::backdrop { background: rgba(2, 8, 8, .72); backdrop-filter: blur(8px); }

dialog h2 {
  margin: 0 34px 16px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.04em;
}

dialog p:not(.eyebrow) { color: #c6d0c1; line-height: 1.55; }

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  color: var(--ink);
  font-size: 27px;
  cursor: pointer;
}

noscript {
  position: absolute;
  z-index: 30;
  left: 20px;
  bottom: 20px;
  padding: 12px;
  background: #10191a;
}

@keyframes rain-fall {
  from { transform: translate3d(0, -10vh, 0) rotate(12deg); }
  to { transform: translate3d(-8vw, 125vh, 0) rotate(12deg); }
}

@keyframes fissure-breathe { 50% { stroke-opacity: .28; } }
@keyframes drop-ring { to { inset: -12px; opacity: 0; } }
@keyframes choice-ring { to { width: calc(100% + 52px); height: calc(100% + 52px); opacity: 0; } }
@keyframes old-current { to { stroke-dashoffset: -40; } }
@keyframes confluence-ring { to { transform: scale(2.8); opacity: 0; } }
@keyframes season-panel-cycle { 0%, 24.9% { opacity: 1; } 25%, 100% { opacity: 0; } }

@media (max-width: 700px) {
  #app { min-height: 500px; }
  #geology { object-position: 54% 50%; }
  .site-mark time { display: none; }
  .opening-panel { bottom: max(5vh, 26px); }
  h1 { font-size: clamp(52px, 18vw, 82px); }
  .opening-copy { margin: 17px 0 19px; font-size: 17px; }
  .story-panel { max-width: calc(100vw - 82px); padding: 13px 15px 12px; bottom: max(2.5vh, 14px); }
  .story-panel h2 { font-size: clamp(20px, 6.3vw, 28px); }
  .story-panel .eyebrow { margin-bottom: 7px; }
  #choice-help { display: none; }
  #progress { left: 15px; }
  .route-choice { width: min(150px, 38vw); min-height: 50px; padding: 8px 11px 9px; }
  .route-choice strong { font-size: 14px; }
  .route-choice small { font-size: 8px; }
  .ending-panel { left: 18px; bottom: max(3vh, 18px); width: calc(100vw - 36px); padding: 21px 20px 19px; }
  .ending-panel h2 { font-size: clamp(34px, 11.5vw, 54px); }
  #ending-copy { margin: 12px 0 17px; font-size: 15px; }
  #surface-clock { height: 16vh; min-height: 100px; }
}

@media (max-height: 630px) and (orientation: landscape) {
  .opening-panel { bottom: 20px; }
  h1 { font-size: clamp(45px, 10vw, 76px); }
  .opening-copy { margin: 12px 0 14px; font-size: 16px; }
  .story-panel { bottom: 14px; }
  .ending-panel { bottom: 18px; padding: 18px; }
}

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

  #rain { opacity: .16; }
  #surface-clock.active .season-sky { background: linear-gradient(#36475c, #c6d6dd 70%, #58625b 71%); }
  #surface-clock { height: 16vh; }
  #surface-clock .season-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
  #surface-clock .season-panel {
    position: relative;
    inset: auto;
    opacity: 1;
    animation: none !important;
    border-right: 1px solid rgba(230, 246, 236, .18);
  }
  #surface-clock .season-panel:last-child { border-right: 0; }
  #surface-clock .season-panel span { left: 7px; bottom: 7px; font-size: 7px; letter-spacing: .08em; }
  #surface-clock .season-label { display: none; }
}
