:root {
  color-scheme: dark;
  --ink: #f4ead4;
  --muted: #c6baa2;
  --soil: #1d1714;
  --green: #8aa58e;
  --water: #77e4dc;
  --gold: #dfbc75;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body, #experience { width: 100%; height: 100%; margin: 0; }

html { background: var(--soil); }

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--soil);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

#experience { position: relative; isolation: isolate; overflow: hidden; }

#world {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

#world:focus-visible { box-shadow: inset 0 0 0 3px rgba(119, 228, 220, .75); }

.grain {
  position: absolute;
  inset: -40%;
  z-index: 1;
  pointer-events: none;
  opacity: .08;
  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='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  transform: rotate(3deg);
  mix-blend-mode: soft-light;
}

.mast {
  position: absolute;
  z-index: 3;
  left: max(22px, env(safe-area-inset-left));
  top: max(20px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 13px;
  transition: opacity .7s ease, transform .7s ease;
}

.mark { width: 20px; height: 32px; position: relative; }
.mark span { position: absolute; left: 9px; width: 1px; height: 26px; background: currentColor; transform-origin: bottom; }
.mark span:nth-child(1) { transform: rotate(-22deg); }
.mark span:nth-child(2) { transform: rotate(0); }
.mark span:nth-child(3) { transform: rotate(22deg); }
.date, .quiet-title { margin: 0; text-transform: uppercase; letter-spacing: .15em; }
.date { font-size: 9px; opacity: .58; }
.quiet-title { margin-top: 4px; font-size: 11px; font-weight: 650; }

.memory {
  position: absolute;
  z-index: 4;
  top: max(28px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .8s ease;
}

body:not([data-phase="intro"]) .memory { opacity: 1; }
.memory-dot { width: 8px; height: 8px; border: 1px solid rgba(244, 234, 212, .48); border-radius: 50%; transition: .65s ease; }
.memory-dot.found { background: var(--water); border-color: var(--water); box-shadow: 0 0 15px rgba(119, 228, 220, .8); }

.sound {
  position: absolute;
  z-index: 5;
  right: max(18px, env(safe-area-inset-right));
  top: max(17px, env(safe-area-inset-top));
  min-width: 48px;
  min-height: 48px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: .78;
}

.sound:hover { opacity: 1; }
.sound-label { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.sound-rings { position: relative; width: 14px; height: 14px; border: 1px solid currentColor; border-radius: 50%; }
.sound-rings::before, .sound-rings::after { content: ""; position: absolute; inset: -4px; border: 1px solid currentColor; border-left-color: transparent; border-bottom-color: transparent; border-radius: 50%; transform: rotate(45deg); }
.sound-rings::after { inset: 3px; background: currentColor; border: 0; }
.sound[aria-pressed="false"] .sound-rings::before { display: none; }
.sound[aria-pressed="false"] .sound-rings { opacity: .45; }

.intro {
  position: absolute;
  z-index: 4;
  left: clamp(24px, 7vw, 112px);
  bottom: clamp(34px, 9vh, 100px);
  width: min(520px, calc(100vw - 48px));
  transition: opacity .85s ease, transform .85s cubic-bezier(.22,.72,.2,1);
}

.intro.dismissed { opacity: 0; transform: translateY(24px); pointer-events: none; }
.kicker, .privacy, .ending-kicker { margin: 0; text-transform: uppercase; letter-spacing: .16em; font-size: 10px; }
.kicker { color: var(--gold); }

h1 {
  margin: 14px 0 18px;
  font: 400 clamp(52px, 7.6vw, 112px)/.84 var(--serif);
  letter-spacing: -.055em;
  text-wrap: balance;
  text-shadow: 0 3px 30px rgba(0,0,0,.22);
}

.lede { max-width: 440px; margin: 0; color: rgba(244,234,212,.82); font: 400 clamp(15px, 1.5vw, 18px)/1.55 var(--serif); }

.begin, .again {
  margin-top: 27px;
  min-height: 52px;
  border: 1px solid rgba(244,234,212,.55);
  border-radius: 99px;
  background: rgba(15, 20, 17, .32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}

.begin { min-width: 220px; padding: 0 9px 0 22px; display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; }
.begin i { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--ink); color: #25332d; font-style: normal; }
.begin:hover, .again:hover { background: var(--ink); color: #25332d; transform: translateY(-2px); }
.privacy { margin-top: 15px; opacity: .48; font-size: 8px; }

.chapter {
  position: absolute;
  z-index: 4;
  left: max(24px, env(safe-area-inset-left));
  top: 50%;
  width: 176px;
  opacity: 0;
  transform: translateY(-45%);
  transition: opacity .7s ease, transform .7s ease;
  pointer-events: none;
}

body[data-phase="growing"] .chapter, body[data-phase="interlude"] .chapter { opacity: .78; transform: translateY(-50%); }
.chapter-number { margin: 0 0 8px; font-size: 9px; letter-spacing: .18em; color: var(--water); }
.chapter-line { margin: 0; font: italic 16px/1.25 var(--serif); }

.guide {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  min-height: 42px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(244,234,212,.16);
  border-radius: 99px;
  background: rgba(15, 12, 10, .38);
  color: rgba(244,234,212,.66);
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .7s ease, transform .7s ease;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

body[data-phase="growing"] .guide { opacity: 1; transform: translate(-50%, 0); }
.guide b { color: var(--ink); font-weight: 650; }
.touch-guide { display: none; }

.ending {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 47%;
  width: min(720px, calc(100vw - 48px));
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -42%);
  pointer-events: none;
  transition: opacity 1.4s ease, transform 1.4s cubic-bezier(.2,.7,.2,1);
  text-shadow: 0 2px 28px rgba(16,28,24,.35);
}

body[data-phase="ending"] .ending { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.ending-kicker { color: #405a4c; font-weight: 700; }
.ending h2 { margin: 11px 0 15px; color: #26372f; font: 400 clamp(45px, 6.6vw, 92px)/.9 var(--serif); letter-spacing: -.05em; }
.ending p:not(.ending-kicker) { margin: 0; color: #3a5147; font: italic 17px/1.4 var(--serif); }
.again { margin-top: 25px; padding: 0 22px; border-color: rgba(39,56,48,.45); background: rgba(239,231,208,.45); color: #26372f; }

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

.share-mode .intro,
.share-mode .sound,
.share-mode .memory,
.share-mode .chapter,
.share-mode .guide,
.share-mode .ending { display: none; }

@media (pointer: coarse), (max-width: 700px) {
  .desktop-guide { display: none; }
  .touch-guide { display: inline; }
  .quiet-title { display: none; }
  .intro { left: 24px; bottom: max(30px, calc(env(safe-area-inset-bottom) + 18px)); }
  h1 { font-size: clamp(49px, 16vw, 76px); }
  .lede { max-width: 90%; font-size: 16px; }
  .chapter { top: 112px; left: 24px; width: 145px; transform: none; }
  body[data-phase="growing"] .chapter, body[data-phase="interlude"] .chapter { transform: none; }
  .guide { bottom: max(14px, env(safe-area-inset-bottom)); }
  .sound-label { display: none; }
  .sound { right: 10px; top: max(10px, env(safe-area-inset-top)); justify-content: center; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .intro { bottom: 22px; }
  h1 { margin: 9px 0 11px; font-size: 54px; }
  .lede { max-width: 390px; line-height: 1.35; }
  .privacy { display: none; }
  .begin { margin-top: 15px; }
  .chapter { left: auto; right: 28px; top: 50%; text-align: right; }
}

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