:root, .world-page { background: #251143; }
html:has(> body.world-page) { overscroll-behavior-y: none; }
.origin-plane, .project-coast { position: relative; }
.origin-plane:focus, .project-coast:focus { outline: none; }
.map-origin-track, .map-project-track { display: none; }
.map-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The sticky viewport spans two real scroll distances. Both renderers measure
   those distances in document coordinates, independently of the moving strip. */
.world-opening[data-journey] {
  --leg-distance: max(1100px, 200svh);
  --overlap: 7%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
[data-journey] .world-viewport {
  position: sticky;
  top: 0;
  grid-area: 1 / 1 / 3 / 2;
  height: 100svh;
  z-index: 1;
  overflow: clip;
}
[data-journey] .world-strip {
  position: relative;
  width: 100%;
  height: 100%;
  transform: translate3d(0, 0, 0);
}
.journey-living, .journey-actor-targets, .journey-pet-hud { display: none; }
[data-journey] :is(.journey-living, .journey-actor-targets),
[data-journey] .world-strip::after {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(200% - var(--overlap));
  height: 100%;
  max-width: none;
  pointer-events: none;
}
[data-journey] .journey-living { display: block; z-index: 3; image-rendering: pixelated; }
[data-journey] .journey-actor-targets { display: block; z-index: 4; }
[data-journey] .living-world-canvas[data-journey-output="shared"] { opacity: 0; }
[data-journey]:has(.scroll-stage[data-phase="preparing"]) :is(.journey-living, .journey-actor-targets, .journey-pet-hud) { display: none; }
[data-journey] .journey-pet-hud {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
/* The same twilight covers the terrain on both banks. */
[data-journey] .origin-plane .night-wash { visibility: hidden; }
[data-journey] .world-strip::after {
  content: "";
  z-index: 2;
  background: #080e36;
  opacity: 0;
  transition: opacity 1.8s ease;
}
[data-journey] .world-strip:has(.night-wash.is-night)::after { opacity: .34; }
[data-journey] .origin-plane,
[data-journey] .project-coast {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
[data-journey] .origin-plane { z-index: 1; }
[data-journey] .surface { position: relative; z-index: 1; opacity: 1; }
[data-journey] .surface:not(.is-live) .world { background: transparent; }
[data-journey] .surface:not(.is-live) .landscape-layer,
[data-journey] .surface:not(.is-live) .world::before { visibility: hidden; }
[data-journey] .origin-plane :is(.intro, .top-nav) { opacity: calc(var(--landing-ui, 0) * var(--intro-alpha, 1)); }
[data-journey] .origin-plane :is(.world-dock, .playback, .world-tools) { opacity: var(--intro-alpha, 1); }
[data-journey] .project-coast {
  left: calc(100% - var(--overlap));
  z-index: 2;
  background: transparent;
  visibility: hidden;
}
[data-journey][data-crossing] .project-coast { visibility: visible; }
[data-journey] .project-coast:not([data-painted]):not([data-static-coast]) :is(.island-visual img, .coast-cloud) { visibility: hidden; }
[data-journey] .world-dock { position: absolute; inset: 0 0 auto; }
[data-journey] #root,
[data-journey] #root .scroll-track,
[data-journey] #root .scroll-stage { height: 100%; min-height: 0; }
[data-journey] #root .scroll-stage { position: relative; }
[data-journey] #root .scroll-track::after { display: none; }

[data-journey] .map-origin-track,
[data-journey] .map-project-track {
  display: block;
  position: relative;
  pointer-events: none;
}
[data-journey] .map-origin-track { grid-area: 1 / 1; height: calc(100svh + var(--leg-distance)); }
/* A sideways trip takes at most one screen of vertical input. On a tall
   screen, match the distance the map actually travels horizontally. */
[data-journey] .map-project-track { grid-area: 2 / 1; height: clamp(360px, 93vw, 100svh); }
[data-journey] .map-stop { position: absolute; bottom: 100svh; width: 1px; height: 0; }
[data-journey][data-leaving] .world-tools,
[data-journey][data-leaving] .top-nav { visibility: hidden; }

.project-coast {
  min-height: max(440px, 78svh);
  overflow: clip;
  isolation: isolate;
  color: #ffedc1;
  background: #251143;
  font-family: PixelBody, monospace;
}
.coast-nav {
  position: absolute;
  top: max(9px, 2.5%);
  inset-inline: 4%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
[data-journey] .coast-nav { left: 4%; pointer-events: none; }
[data-journey] .coast-nav:not([inert]) a { pointer-events: auto; }
.coast-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: #ffedcd;
  font: 400 clamp(15px, 1.45vw, 21px)/1.2 PixelBody, monospace;
}
.coast-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }
.project-coast :focus-visible { outline: 2px solid #ffe4a6; outline-offset: 3px; }
.coast-cloud { position: absolute; image-rendering: pixelated; pointer-events: none; }
.coast-cloud img { display: block; width: 100%; height: auto; }
.cloud-motion { display: none; position: absolute; inset: 0; }
.cloud-motion::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: url('/media/cloud.webp') center / 100% 100% no-repeat;
}
.coast-cloud button {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-width: 32px;
  min-height: 32px;
  transform: translate(-50%, -50%);
}
.cloud-near { left: 20%; top: 24%; width: 11%; }
.cloud-far { left: 71%; top: 15%; width: 6.5%; }
.coast-assembly {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
.project-coast[data-painted] .coast-assembly { display: block; }
.project-coast[data-painted] .island-visual img,
.project-coast[data-painted] .coast-cloud { visibility: hidden; }

.coast-board {
  position: absolute;
  top: var(--waterline, 74%);
  left: 3.7%;
  /* Square CSS fallback remains visible without JS. The live measurements
     replace both dimensions, matching the opening art's independent axes. */
  width: var(--island-row-width, 94.5454545%);
  height: var(--island-height, auto);
  aspect-ratio: 3;
  transform: translateY(-86%);
  z-index: 2;
}
.project-islands {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  list-style: none;
  padding: 0;
  margin: 0;
}
.project-islands li { position: relative; min-width: 0; }
.project-island, .island-visual {
  display: block;
  position: relative;
  width: 100%;
}
.island-visual { height: var(--island-height, auto); aspect-ratio: 1; }
.island-visual img, .coast-life {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  /* Eighteen rows of headroom over the original 78. Both planes use
     exactly the same pixel pitch and the same river baseline. */
  height: 123.076923%;
  image-rendering: pixelated;
}
.coast-life { display: none; pointer-events: none; z-index: 1; }
.project-coast[data-coast-live] .coast-life { display: block; }
/* One project-cloud sprite for the entire journey. The terrain snapshot never
   includes it. Existing world-strip coordinates remain its only camera owner. */
.project-coast[data-coast-ambient] .coast-cloud {
  visibility: visible;
  z-index: 3;
  opacity: var(--cloud-alpha, 0);
  clip-path: inset(-35% var(--cloud-cut, 100%) -35% -35%);
}
.project-coast[data-coast-ambient] .coast-cloud img { visibility: hidden; }
.project-coast[data-coast-ambient] .cloud-motion { display: block; }
.project-coast[data-coast-ambient] .cloud-motion::before {
  animation: none;
}
@media (prefers-reduced-motion: no-preference) {
  .project-coast[data-coast-ambient] .cloud-motion::before {
    animation: coast-continuous-drift 15s ease-in-out infinite alternate;
    animation-play-state: var(--coast-motion, paused);
  }
  .project-coast[data-coast-ambient] .cloud-far .cloud-motion::before { animation-duration: 21s; }
}
@keyframes coast-continuous-drift {
  from { transform: translate(-3%, 1%); }
  to { transform: translate(7%, -4%); }
}
.coast-hotspot, .coast-cloud button {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
.coast-hotspot {
  position: absolute;
  min-width: 26px;
  min-height: 26px;
  transform: translate(-50%, -50%);
  z-index: 3;
}
.coast-hotspot[data-coast-action="river"] { min-height: 20px; z-index: 2; }
.coast-hotspot:focus-visible, .coast-cloud button:focus-visible { outline-offset: 1px; }
.coast-cloud:has(button:is(:hover, :focus-visible)) .cloud-motion::before { filter: brightness(1.12); }
.island-caption {
  position: absolute;
  z-index: 4;
  top: 94%;
  inset-inline: 2px;
  text-align: center;
}
.island-caption h3 {
  display: inline-block;
  max-width: 100%;
  padding: 3px clamp(4px, .85vw, 13px) 4px;
  color: #2b1d3d;
  background: #ffedc1;
  border-block: 2px solid #e9b88b;
  box-shadow: 2px 0 #e9b88b, -2px 0 #e9b88b, 0 3px #8e6070;
  font: 700 clamp(16px, 2vw, 29px)/1.08 PixelDisplay, monospace;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.island-caption h3 .icon { width: .55em; height: .55em; vertical-align: .04em; }
.island-caption p {
  margin-top: 6px;
  color: #ffedcd;
  font: 400 clamp(15px, 1.4vw, 19px)/1.2 PixelBody, monospace;
  text-wrap: balance;
}
[data-journey] .island-caption p { opacity: 0; }
[data-journey] .project-island:is(:hover, :focus-visible) .island-caption p { opacity: 1; }
.project-island:is(:hover, :focus-visible) h3 { background: #fff5d7; text-decoration: underline; }
.project-island:focus-visible { outline-offset: -3px; }
[data-journey] .island-caption { opacity: var(--label-alpha, 0); }
@media (max-width: 660px) {
  .coast-nav { inset-inline: 4%; }
  .island-caption h3 { font-size: clamp(14px, 3.85vw, 22px); padding-inline: 3px; }
  .island-caption h3 .icon { display: none; }
  .island-caption p { font-size: 14px; }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  .island-caption { top: 88%; }
  .island-caption p { display: none; }
}
/* Keep the semantic footer in the viewport without adding a final scroll leg.
   Only links intercept input; the surrounding world remains interactive. */
.world-page { --world-footer-height: calc(52px + env(safe-area-inset-bottom, 0px)); }
.world-page .site-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 7;
  margin: 0;
  color: #d6c4d9;
  background: transparent;
  pointer-events: none;
  text-shadow: 0 1px 2px #251143, 0 0 5px #251143;
}
.world-page .footer-inner {
  width: 100%;
  margin: 0;
  min-height: var(--world-footer-height);
  padding: 4px max(12px, env(safe-area-inset-right, 0px))
    calc(4px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  gap: 12px;
  border: 0;
}
.world-page .site-footer a { pointer-events: auto; }
.world-page .site-footer .brand { gap: 6px; }
.world-page .site-footer .brand img { width: 20px; height: 20px; }
.world-page .site-footer .brand span { font-size: 22px; }
.world-page .site-footer nav { gap: clamp(4px, 1.8vw, 14px); }
.world-page .site-footer nav a { min-width: 44px; }
.world-page .site-footer nav a, .world-page .footer-location { font: 400 16px/1.3 PixelBody, monospace; }

/* Lift the whole landscape, not its signs, to reserve the footer band. The
   measured landscape rect also positions terrain hitboxes and the next bank. */
@media (orientation: landscape) {
  .world-page { --map-footer-lift: max(0px, calc(var(--world-footer-height) + 48px - 8.5svh)); }
  .world-page .world-opening .landscape-layer {
    top: calc(0px - var(--map-footer-lift));
    bottom: auto;
    height: 100%;
  }
  .world-page [data-journey] .island-caption { top: 97%; }
}
/* Descriptions stay within their own island and open only from its sign or
   keyboard focus, never while the pointer merely crosses the artwork. */
.world-page [data-journey] .island-caption p {
  display: block;
  position: absolute;
  inset-inline: 0;
  bottom: calc(100% + 10px);
  margin: 0;
  padding: 6px;
  background: #251143f2;
  border: 1px solid #8e6070;
  pointer-events: none;
}
.world-page [data-journey] .project-island:hover .island-caption p { opacity: 0; }
.world-page [data-journey] .project-island:focus-visible .island-caption p,
.world-page [data-journey] .project-island .island-caption h3:hover + p { opacity: 1; }
.world-page [data-journey] .island-caption p { overflow-wrap: anywhere; }
