:root {
  color-scheme: light;
  --paper: #f4eee6;
  --ink: #382d31;
  --muted: #8c7778;
  --rose: #bb756e;
  --rose-dark: #8e504f;
  --deep: #503c43;
  --line: rgba(106, 77, 77, .2);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 17% 19%, rgba(227, 190, 170, .35), transparent 32%),
    radial-gradient(ellipse at 82% 77%, rgba(188, 142, 137, .2), transparent 33%),
    var(--paper);
  overflow-x: hidden;
}

button { font: inherit; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: .15;
  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='.23'/%3E%3C/svg%3E");
}

.scene {
  position: relative;
  display: flex;
  min-height: 100svh;
  padding: 38px 22px 26px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.eyebrow, .footer-note, .cover-kicker, .cover-date, .letter-topline, .letter-footer {
  font-family: "DM Serif Display", Georgia, serif;
  letter-spacing: .19em;
  text-transform: uppercase;
}

.eyebrow {
  position: relative;
  z-index: 1;
  margin: 0 0 24px;
  color: #9a7775;
  font-size: 10px;
}

.envelope {
  position: relative;
  width: min(540px, 90vw);
  height: min(650px, 70vh);
  min-height: 470px;
  perspective: 1400px;
  filter: drop-shadow(0 28px 34px rgba(71, 48, 47, .15));
}

.envelope-back, .envelope-front, .envelope-flap, .cover, .letter {
  position: absolute;
  inset: 0;
  border-radius: 4px;
}

.envelope-back {
  background: linear-gradient(145deg, #9e5d5d, #875252 68%, #73464b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.envelope-front {
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  clip-path: polygon(0 35%, 50% 69%, 100% 35%, 100% 100%, 0 100%);
  background: linear-gradient(155deg, #bd7b73, #a76565 55%, #96595d);
  transition: opacity .65s ease, transform .8s cubic-bezier(.2,.75,.2,1);
}

.envelope-pocket {
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(255,255,255,.27);
  background: linear-gradient(28deg, rgba(255,255,255,.09) 49.8%, transparent 50%), linear-gradient(-28deg, rgba(75,33,43,.12) 49.8%, transparent 50%);
}

.envelope-flap {
  z-index: 4;
  height: 70%;
  transform-origin: top center;
  clip-path: polygon(0 0, 100% 0, 50% 71%);
  background: linear-gradient(155deg, #cb8c80, #ad6b69 78%);
  backface-visibility: visible;
  transition: transform .8s cubic-bezier(.2,.75,.2,1), z-index 0s .4s;
}

.seal {
  position: absolute;
  z-index: 1;
  top: 62%;
  left: 50%;
  display: grid;
  width: 50px;
  height: 50px;
  place-content: center;
  border: 1px solid rgba(255, 239, 218, .68);
  border-radius: 50%;
  color: #fff0dd;
  background: #8f4f50;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 10px rgba(61, 31, 36, .2);
}

.cover {
  z-index: 5;
  display: flex;
  padding: 58px 52px 36px;
  flex-direction: column;
  align-items: center;
  color: #fff5e9;
  text-align: center;
  background: linear-gradient(150deg, rgba(103, 61, 65, .1), rgba(71, 42, 51, .27));
  transition: opacity .55s ease, transform .7s cubic-bezier(.2,.75,.2,1), visibility .55s;
}

.cover::before, .cover::after {
  position: absolute;
  z-index: -1;
  width: 225px;
  height: 225px;
  border: 1px solid rgba(255, 238, 218, .2);
  border-radius: 50%;
  content: "";
}

.cover::before { top: -135px; left: -122px; }
.cover::after { right: -134px; bottom: -134px; width: 280px; height: 280px; }

.cover-kicker { margin: 0 0 24px; font-size: 9px; opacity: .78; }

h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 54px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: .12em;
}

h1 em { color: #f0c7ab; font-style: normal; }

.cover-note {
  margin: 17px 0 0;
  color: rgba(255, 245, 233, .78);
  font-size: 13px;
  line-height: 2.15;
  letter-spacing: .08em;
}

.open-button, .wish-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.open-button {
  gap: 26px;
  margin-top: 38px;
  padding: 13px 18px 13px 23px;
  border: 1px solid rgba(255, 239, 220, .48);
  border-radius: 99px;
  color: #fff3e5;
  background: rgba(255,255,255,.08);
  font-size: 13px;
  letter-spacing: .08em;
  transition: background .25s, transform .25s;
}

.open-button:hover { background: rgba(255,255,255,.17); transform: translateY(-2px); }
.open-button:focus-visible, .wish-button:focus-visible { outline: 3px solid #d8a68e; outline-offset: 4px; }
.button-arrow { font-family: Georgia, serif; font-size: 17px; }
.cover-date { margin-top: auto; font-size: 9px; opacity: .55; }

.letter {
  z-index: 2;
  inset: 10px 10px 12px;
  overflow: auto;
  padding: 28px 38px 23px;
  color: #46383a;
  background:
    radial-gradient(ellipse at 95% 5%, rgba(232, 210, 188, .3), transparent 26%),
    linear-gradient(135deg, #fffaf2, #f7eee2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(.97);
  scrollbar-color: #c59b8d transparent;
  scrollbar-width: thin;
  transition: opacity .5s ease, transform .7s cubic-bezier(.2,.75,.2,1), visibility .5s;
}

.letter-topline, .letter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #a27a72;
  font-size: 8px;
}

.letter-flower { color: #b47471; font-size: 20px; }
.letter-content { max-width: 405px; margin: 16px auto 25px; }
.letter-content p { margin: 0 0 13px; font-size: 14px; line-height: 1.95; letter-spacing: .035em; }
.letter-content .salutation { margin: 0 0 14px; color: #784c4d; font-size: 22px; letter-spacing: .08em; }
.letter-content .closing { padding-top: 3px; color: #754d4d; font-size: 14px; line-height: 2; }
.letter-footer { padding-top: 12px; border-top: 1px solid var(--line); }
.letter-footer span:last-child { font-family: Georgia, serif; font-size: 19px; }

.afterword {
  position: relative;
  z-index: 1;
  display: flex;
  max-height: 0;
  margin-top: 0;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: max-height .65s ease, margin .65s ease, opacity .55s ease, transform .55s ease, visibility 0s .65s;
}

.afterword-line { margin: 0 0 15px; color: #825b5a; font-size: 16px; letter-spacing: .09em; transition: opacity .18s, transform .18s; }
.afterword-line.is-changing { opacity: 0; transform: translateY(5px); }
.afterword-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; }
.wish-button { gap: 9px; padding: 10px 17px; border: 1px solid rgba(142, 80, 79, .36); border-radius: 99px; color: #815654; background: rgba(255,255,255,.36); font-size: 13px; letter-spacing: .07em; transition: background .2s, transform .2s; }
.wish-button:hover { background: #fff9f0; transform: translateY(-2px); }
.secondary-button, .fold-button { padding-inline: 14px; }
.fold-button { color: #997f78; border-color: rgba(142, 80, 79, .2); background: transparent; }
.wish-icon { color: #b8756c; }
.tiny-note { margin: 8px 0 0; color: #a88e87; font-size: 10px; letter-spacing: .08em; }
.footer-note { position: relative; z-index: 1; margin: 22px 0 0; color: #b19a90; font-size: 8px; transition: opacity .3s; }

.journey-dialog {
  position: fixed;
  inset: 0;
  width: min(880px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  color: var(--ink);
  background: transparent;
}
.journey-dialog:not([open]) { display: none; }
.journey-dialog::backdrop { background: rgba(54, 38, 42, .48); backdrop-filter: blur(5px); }
body:has(.journey-dialog[open]) { overflow: hidden; }
.journey-panel {
  width: 100%;
  max-height: calc(100dvh - 32px);
  margin: 0;
  padding: 24px 30px 22px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(145, 105, 97, .22);
  border-radius: 8px;
  background: rgba(255, 250, 242, .98);
  box-shadow: 0 24px 90px rgba(33, 22, 26, .3);
  animation: journey-arrive .55s cubic-bezier(.2,.75,.2,1) both;
}
.journey-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.journey-close { flex: 0 0 44px; display: grid; width: 44px; height: 44px; margin: -6px -8px 0 0; place-items: center; border: 1px solid rgba(142, 80, 79, .2); border-radius: 50%; color: #805b58; background: rgba(255,255,255,.62); cursor: pointer; font: 28px/1 "Noto Serif SC", "Songti SC", serif; transition: background .2s, transform .2s; }
.journey-close:hover { background: #fff; transform: rotate(90deg); }
.journey-close:focus-visible { outline: 2px solid #b8756c; outline-offset: 3px; }
.journey-kicker { margin: 0 0 8px; color: #ad8178; font: 9px "DM Serif Display", Georgia, serif; letter-spacing: .2em; }
.journey-panel h2 { margin: 0; color: #68494a; font-size: 23px; font-weight: 400; letter-spacing: .1em; }
.route-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.route-choice { padding: 8px 13px; border: 1px solid rgba(142, 80, 79, .24); border-radius: 99px; color: #8d716c; background: rgba(255,255,255,.38); cursor: pointer; font: inherit; font-size: 11px; transition: color .2s, background .2s, border-color .2s, transform .2s; }
.route-choice:hover { transform: translateY(-1px); background: #fff9f0; }
.route-choice.is-selected { border-color: rgba(142, 80, 79, .56); color: #714447; background: #f4e4d5; box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); }
.route-choice:focus-visible, .route-replay:focus-visible { outline: 2px solid #b8756c; outline-offset: 3px; }
.route-map-frame { position: relative; width: min(620px, 100%); margin: 0 auto; overflow: hidden; aspect-ratio: 760 / 880; border: 1px solid rgba(145, 105, 97, .22); background: #f5ede2; box-shadow: 0 10px 28px rgba(71, 48, 47, .08); }
.route-map-canvas { position: absolute; inset: 0; transform: translate(0, 0) scale(1); transform-origin: top left; transition: transform 1.05s cubic-bezier(.2,.7,.2,1); }
.route-map-base, .route-map-overlay { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.route-map-base { object-fit: contain; }
.route-map-overlay { overflow: visible; }
.map-route-track, .map-route-segment { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.map-route-track { stroke: rgba(119, 91, 79, .25); stroke-width: 2.2; }
.map-route-segment { pathLength: 1; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .26s ease; }
.map-route-segment.is-drawn { stroke-dashoffset: 0; }
.map-mode-road { stroke: #a65356; }
.map-mode-sea { stroke: #4d8790; stroke-dasharray: .55 .45; }
.map-mode-air { stroke: #bf8951; stroke-dasharray: .18 .13; stroke-width: 3.5; }
.map-mode-rail { stroke: #357b82; stroke-width: 3.3; }
.map-stop { fill: #f9f2e9; stroke: #99635d; stroke-width: 1.5; transition: fill .2s, r .2s, opacity .2s; }
.map-stop.is-passed { fill: #c88270; stroke: #fff8ed; }
.map-stop.is-current { fill: #783e48; stroke: #fff8ed; stroke-width: 2; r: 5; }
.map-city-label { fill: #59494a; font: 500 13px "Noto Serif SC", "Songti SC", serif; paint-order: stroke; stroke: #f8f1e8; stroke-width: 4px; stroke-linejoin: round; }
.map-traveller { fill: #ad5557; stroke: #fff8ed; stroke-width: 2.5; filter: drop-shadow(0 1px 4px rgba(91, 49, 49, .5)); }
.map-aircraft { pointer-events: none; filter: drop-shadow(0 2px 5px rgba(90, 54, 43, .35)); }
.aircraft-halo { fill: #fff5e8; stroke: #bf8951; stroke-width: 1.2; }
.aircraft-icon { fill: #a65356; stroke: #fff8ed; stroke-width: .8; stroke-linejoin: round; }
.route-map-frame.is-zoomed .map-route-track { stroke-width: .8; }
.route-map-frame.is-zoomed .map-route-segment { stroke-width: 1.1; }
.route-map-frame.is-zoomed .map-city-label { font-size: 4.2px; stroke-width: 1.4px; }
.route-map-frame.is-zoomed .map-stop { r: 1.1; stroke-width: .6; }
.route-map-frame.is-zoomed .map-stop.is-current { r: 1.8; stroke-width: .7; }
.route-map-frame.is-zoomed .map-traveller { r: 2.2; stroke-width: .8; }
.route-map-compass { position: absolute; top: 12px; right: 14px; color: #8f786b; font: 10px "DM Serif Display", Georgia, serif; letter-spacing: .08em; line-height: 1.2; text-align: center; pointer-events: none; }
.route-map-compass span { font-size: 16px; }
.route-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; margin: 16px 0 4px; color: #816d68; font-size: 11px; }
.route-legend span { display: inline-flex; align-items: center; gap: 6px; }
.route-legend i { display: inline-block; width: 19px; height: 0; border-top: 2.5px solid #a65356; }
.route-legend .legend-sea { border-color: #4d8790; border-top-style: dashed; }
.route-legend .legend-air { border-color: #bf8951; border-top-style: dotted; }
.route-legend .legend-rail { border-color: #357b82; border-top-style: double; }
.route-status { min-height: 22px; margin: 17px 0 8px; color: #825654; font-size: 12px; letter-spacing: .04em; }
.route-replay { padding: 8px 13px; border: 1px solid rgba(142, 80, 79, .3); border-radius: 99px; color: #815654; background: transparent; cursor: pointer; font: inherit; font-size: 11px; }
.route-replay[hidden] { display: none; }

.scene.is-open .envelope { height: min(760px, 76vh); }
.scene.is-open .envelope-flap { z-index: 1; transform: rotateX(180deg); }
.scene.is-open .envelope-front { opacity: 0; transform: translateY(70px); }
.scene.is-open .cover { visibility: hidden; opacity: 0; transform: translateY(-30px) scale(.95); pointer-events: none; }
.scene.is-open .letter { z-index: 6; opacity: 1; visibility: visible; transform: translateY(0) scale(1); transition-delay: .28s; }
.scene.is-open .afterword { max-height: 160px; margin-top: 25px; opacity: 1; transform: translateY(0); visibility: visible; transition-delay: .4s; }
.scene.is-open .footer-note { margin-top: 15px; }
.scene.is-lit .envelope-back { box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 0 45px rgba(237, 192, 144, .32); }
.scene.is-lit .spark { color: #e4b675; filter: drop-shadow(0 0 8px rgba(241, 199, 140, .85)); }

.orbit { position: absolute; z-index: -1; border: 1px solid rgba(153, 111, 107, .17); border-radius: 50%; pointer-events: none; }
.orbit-one { width: min(840px, 100vw); aspect-ratio: 1; }
.orbit-two { width: min(1040px, 120vw); aspect-ratio: 1; border-style: dashed; opacity: .5; }
.spark { position: absolute; color: #bc8c77; pointer-events: none; }
.spark-one { top: 18%; left: calc(50% - 340px); font-size: 17px; animation: twinkle 3s ease-in-out infinite; }
.spark-two { right: calc(50% - 355px); bottom: 19%; font-size: 24px; animation: twinkle 4s ease-in-out infinite reverse; }

.celebration { position: fixed; z-index: 10; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -20px; width: 8px; height: 13px; border-radius: 2px; opacity: 0; animation: fall var(--duration) cubic-bezier(.15,.7,.35,1) forwards; }
.confetti-star { width: auto; height: auto; background: transparent !important; font-size: 16px; line-height: 1; }
.toast { position: fixed; z-index: 11; bottom: 28px; left: 50%; padding: 12px 19px; border: 1px solid rgba(255,255,255,.25); border-radius: 99px; color: #fff8ed; background: rgba(76, 54, 58, .91); font-size: 12px; letter-spacing: .08em; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .35s, transform .35s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fall { 0% { opacity: 0; transform: translate3d(0, -5vh, 0) rotate(0deg); } 10% { opacity: .95; } 100% { opacity: 0; transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); } }
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.85) rotate(0); } 50% { opacity: 1; transform: scale(1.12) rotate(25deg); } }
@keyframes journey-arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 820px), (pointer: coarse) {
  .scene { justify-content: flex-start; padding: max(26px, 5vh) 14px calc(20px + env(safe-area-inset-bottom)); }
  .eyebrow { margin-bottom: 20px; font-size: 9px; }
  .envelope { width: min(440px, 92vw); height: min(610px, 68vh); min-height: 465px; }
  .cover { padding: 48px 28px 30px; }
  .cover-note { font-size: 12px; }
  .open-button { margin-top: 30px; }
  .letter { inset: 7px; padding: 21px 20px 18px; }
  .letter-content { margin: 12px auto 18px; }
  .letter-content p { margin-bottom: 11px; font-size: 13px; line-height: 1.85; }
  .letter-content .salutation { font-size: 20px; }
  .letter-content .closing { font-size: 13px; }
  .scene.is-open .envelope { height: min(740px, 72vh); }
  .scene.is-open .afterword { margin-top: 18px; }
  .afterword-line { font-size: 14px; }
  .afterword-actions { display: grid; width: min(420px, 100%); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wish-button { min-width: 0; min-height: 46px; padding: 9px 8px; font-size: 11px; line-height: 1.45; }
  .journey-dialog {
    inset: 50% auto auto 50%;
    width: min(620px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    margin: 0;
    transform: translate(-50%, -50%);
  }
  .journey-panel { max-height: calc(100dvh - 16px); padding: 17px 14px calc(16px + env(safe-area-inset-bottom)); border-radius: 12px; }
  .journey-heading { gap: 10px; }
  .journey-close { margin: -5px -5px 0 0; }
  .journey-panel h2 { font-size: 19px; letter-spacing: .07em; }
  .route-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
  .route-choice { min-height: 44px; padding: 7px 8px; font-size: 10px; line-height: 1.4; }
  .route-map-frame { width: min(520px, 100%); }
  .map-city-label { font-size: 15px; }
  .route-legend { gap: 8px 12px; margin-top: 12px; font-size: 10px; }
  .route-status { margin-top: 12px; font-size: 11px; line-height: 1.7; }
  .route-replay { min-height: 44px; padding: 9px 15px; font-size: 12px; }
  .footer-note { margin-top: 17px; }
  .spark-one { left: 5%; top: 20%; }
  .spark-two { right: 5%; bottom: 17%; }
}

@media (max-height: 760px) and (min-width: 601px) {
  .scene { justify-content: flex-start; padding-top: 18px; }
  .eyebrow { margin-bottom: 12px; }
  .envelope { height: min(590px, 75vh); }
  .scene.is-open .envelope { height: min(680px, 80vh); }
  .footer-note { margin-top: 12px; }
}

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