:root {
  --ink: #123d42;
  --mint: #bcebd6;
  --paper: #f1e7d2;
  --gold: #e6c77b;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  --sans: "Avenir Next", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: white;
  background: #153f43;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

button { font: inherit; }
[hidden] { display: none !important; }

a { color: inherit; }

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

.loader {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #f4faf4;
  transition: opacity 350ms ease, visibility 350ms;
}

.loader__inner { width: min(240px, 64vw); text-align: center; }

.loader__mark {
  display: grid;
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  place-items: center;
  color: #4e9e7f;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  animation: loader-turn 2.2s ease-in-out infinite;
}

.loader p {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .13em;
}

.loader__track {
  height: 1px;
  margin: 22px 0 13px;
  overflow: hidden;
  background: rgba(24, 95, 76, .15);
}

.loader__track i {
  display: block;
  width: 42%;
  height: 100%;
  background: #4d9d7e;
  animation: loader-track 1.3s ease-in-out infinite;
}

.loader small { color: #66807c; font-size: 9px; letter-spacing: .15em; }

.is-ready .loader { opacity: 0; visibility: hidden; pointer-events: none; }

.stage {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 620px;
  overflow: hidden;
  opacity: 0;
  isolation: isolate;
  transition: opacity 450ms ease;
}

.is-assets-ready .stage { opacity: 1; }

.stage__media,
.stage__media img,
.stage__veil,
.stage__grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage__media { z-index: -3; background: #6fc1b1; }

.stage__media img {
  object-fit: cover;
  object-position: 60% center;
  scale: 1.012;
  transition: scale 900ms cubic-bezier(.16,.7,.2,1);
}

.is-ready .stage__media img { scale: 1; }

.stage__veil {
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(7,44,47,.85), rgba(8,58,59,.60) 32%, rgba(10,74,70,.03) 65%),
    linear-gradient(180deg, rgba(5,37,41,.22), transparent 18%, transparent 72%, rgba(5,33,37,.68));
}

.stage__grain {
  z-index: -1;
  opacity: .16;
  pointer-events: none;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='130'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
}

.topbar {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  right: clamp(24px, 4vw, 64px);
  left: clamp(24px, 4vw, 64px);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,.28);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 400ms 80ms ease, transform 400ms 80ms ease;
}

.is-ready .topbar { opacity: 1; transform: none; }

.brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; }
.brand span { display: grid; width: 24px; height: 24px; place-items: center; color: #c3f3dc; border: 1px solid currentColor; border-radius: 50%; font-size: 8px; }
.brand strong { font-family: var(--serif); font-size: 16px; font-weight: 500; letter-spacing: .12em; }
.hero-layout {
  position: absolute;
  z-index: 1;
  top: max(82px, calc(env(safe-area-inset-top) + 70px));
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 62px));
  left: clamp(28px, 5vw, 82px);
  display: flex;
  width: min(720px, 48vw);
  flex-direction: column;
  justify-content: center;
  gap: clamp(12px, 1.8vh, 20px);
}

.hero-copy {
  width: 100%;
}

.hero-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 3.05vw, 49px);
  font-weight: 500;
  letter-spacing: .035em;
  line-height: 1.32;
  text-shadow: 0 3px 30px rgba(0,30,32,.32);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 480ms 160ms ease, transform 480ms 160ms ease;
}

.hero-copy h1 span { display: block; color: #fff6d7; }

.afterword {
  margin: 12px 0 0;
  color: rgba(255,255,255,.82);
  font-family: var(--serif);
  font-size: clamp(12px, 1.15vw, 18px);
  letter-spacing: .12em;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 400ms 280ms ease, transform 400ms 280ms ease;
}

.is-ready .hero-copy h1,
.is-ready .afterword { opacity: 1; transform: none; }

.footer {
  position: absolute;
  right: clamp(24px, 4vw, 64px);
  bottom: max(22px, env(safe-area-inset-bottom));
  left: clamp(24px, 4vw, 64px);
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 400ms 300ms ease, transform 400ms 300ms ease;
}

.is-ready .footer { opacity: 1; transform: none; }
.footer nav { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); width: min(760px, 70vw); border-top: 1px solid rgba(255,255,255,.28); }
.footer a { position: relative; display: flex; min-height: 48px; flex-direction: column; justify-content: center; padding: 9px 27px 0 0; text-decoration: none; }
.footer a + a { padding-left: 18px; border-left: 1px solid rgba(255,255,255,.18); }
.footer a small { color: #b9ead5; font-size: 7px; letter-spacing: .16em; text-transform: uppercase; }
.footer a span { margin-top: 3px; color: rgba(255,255,255,.88); font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.footer a i { position: absolute; top: 17px; right: 10px; color: rgba(255,255,255,.58); font-size: 10px; font-style: normal; transition: transform 180ms ease; }
.footer a:hover i { transform: translate(2px,-2px); }
.footer a { transition: background-color 180ms ease; }
.footer a:hover, .footer a:focus-visible { background: rgba(188,235,214,.08); }
.footer a:focus-visible i { transform: translate(2px,-2px); }
.credit { margin: 0; color: rgba(255,255,255,.62); font-size: 8px; letter-spacing: .12em; writing-mode: vertical-rl; }

.letter {
  position: relative;
  display: flex;
  width: min(680px, 100%, calc((100svh - 340px) * 1.603));
  min-width: 430px;
  flex-direction: column;
  align-self: flex-start;
  padding: clamp(8px, .8vw, 12px);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,.42);
  background: rgba(249,249,241,.94);
  box-shadow: 0 12px 36px rgba(0,29,31,.18), 0 2px 5px rgba(0,29,31,.08);
  opacity: 0;
  transform: translateY(8px);
  backdrop-filter: blur(10px) saturate(.88);
  transition: opacity 480ms 420ms ease, transform 480ms 420ms ease;
}

.is-ready .letter { opacity: 1; transform: none; }

.letter__paper {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 952 / 594;
  margin: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(70,91,72,.08);
  background: var(--paper);
  box-shadow: 0 9px 28px rgba(42,56,43,.09);
}

.letter__paper::before { content: none; }
.letter__paper canvas,
.letter__paper img { position: relative; z-index: 1; display: block; width: 94%; height: auto; max-height: 92%; object-fit: contain; }
.letter__paper [hidden] { display: none; }
.letter__paper canvas { aspect-ratio: 952 / 594; opacity: 0; transition: opacity 400ms ease; }
.letter__paper.is-simulation-ready canvas { opacity: 1; }
.letter__replay { position: absolute; z-index: 2; top: clamp(17px, 1.6vw, 23px); right: clamp(17px, 1.6vw, 23px); display: grid; width: 25px; height: 25px; padding: 0; place-items: center; color: rgba(18,61,66,.66); border: 0; border-radius: 50%; background: rgba(247,243,230,.16); cursor: pointer; font-size: 12px; line-height: 1; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(2px); backdrop-filter: blur(4px); transition: opacity 700ms ease, visibility 700ms, color 180ms ease, background 180ms ease, transform 180ms ease; }
.letter__replay.is-visible { opacity: .38; visibility: visible; pointer-events: auto; transform: none; }
.letter__replay.is-visible:hover,
.letter__replay.is-visible:focus-visible { color: var(--ink); background: rgba(247,243,230,.46); opacity: .82; transform: rotate(-18deg); }
.letter__replay::before { content: ''; position: absolute; inset: -10px; }
.noscript-note { margin: 0; padding: 16px 24px; font-size: 13px; }

@keyframes loader-turn { 50% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
@keyframes loader-track { from { transform: translateX(-110%); } to { transform: translateX(260%); } }

@media (max-width: 960px) {
  .stage { height: auto; min-height: 100svh; padding: clamp(340px, 49svh, 510px) 14px max(24px, env(safe-area-inset-bottom)); }
  .stage__media { height: clamp(620px, 90svh, 900px); }
  .stage__media img { object-position: 86% 20%; scale: 1; transition: none; }
  .stage__veil { background: linear-gradient(180deg, rgba(5,38,40,.50), transparent 110px, rgba(7,43,46,.08) 280px, rgba(7,43,46,.82) 520px, #153f43 800px); }
  .topbar { top: max(18px, env(safe-area-inset-top)); right: 20px; left: 20px; padding-bottom: 13px; }
  .brand strong { font-size: 14px; }
  .hero-layout { position: relative; inset: auto; width: min(100%, 640px); margin: 0 auto; justify-content: flex-start; gap: 14px; }
  .hero-copy h1 { max-width: 360px; font-size: clamp(21px, 6.6vw, 28px); line-height: 1.3; }
  .afterword { margin-top: 5px; font-size: 10px; }
  .footer { position: relative; inset: auto; width: min(100%, 640px); margin: 28px auto 0; }
  .footer nav { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .footer a { min-height: 48px; padding-top: 6px; }
  .footer a:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.18); }
  .footer a:nth-child(4) { border-top: 1px solid rgba(255,255,255,.18); }
  .footer a small { font-size: 7px; }
  .footer a span { font-size: 10px; }
  .footer a i { top: 12px; }
  .credit { display: none; }
  .letter { width: 100%; min-width: 0; margin-left: 0; padding: 7px; }
  .letter__replay { top: 12px; right: 12px; width: 23px; height: 23px; font-size: 11px; }
}

@media (max-width: 960px) and (max-height: 480px) {
  .stage { padding-top: 210px; }
  .stage__veil { background: linear-gradient(180deg, rgba(5,38,40,.45), rgba(7,43,46,.1) 90px, rgba(7,43,46,.80) 240px, #153f43 620px); }
}

@media (max-height: 690px) and (min-width: 961px) {
  .hero-layout { top: 76px; bottom: 70px; gap: 8px; }
  .hero-copy h1 { font-size: clamp(28px, 2.7vw, 40px); }
  .afterword { margin-top: 5px; }
  .letter { width: min(600px, 100%); padding: 10px; }
}

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