:root {
  color-scheme: light;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-synthesis: none;
  background: #fff1f6;
  color: #70425d;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 0% 2%, #ffd8e8 0, transparent 34%),
    radial-gradient(circle at 95% 88%, #ffe0ea 0, transparent 38%),
    linear-gradient(160deg, #fff6fa, #ffedf5 55%, #fff8fb);
}

button { font: inherit; }

.intro-screen {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(30px, 7vh, 52px);
  padding: 30px 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, #fffafd 0, transparent 55%),
    linear-gradient(155deg, #ffe8f1, #ffdce9 56%, #fff2f7);
}

.intro-screen[hidden] { display: none; }
.intro-screen.is-opening { animation: intro-leave .6s ease 2s both; }

.intro-caption {
  margin: 0;
  color: #a94c79;
  font-size: clamp(18px, 5vw, 23px);
  font-weight: 700;
  text-align: center;
}

.intro-caption span { color: #d15d91; }

.envelope {
  position: relative;
  width: min(74vw, 290px);
  height: 190px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 700px;
  filter: drop-shadow(0 20px 18px rgba(160, 66, 107, .17));
}

.envelope:focus-visible { outline: 3px solid #9f346c; outline-offset: 12px; border-radius: 12px; }
.envelope:disabled { cursor: default; opacity: 1; }

.envelope-back,
.envelope-front,
.envelope-flap { position: absolute; left: 0; right: 0; }

.envelope-back {
  top: 15px;
  bottom: 0;
  border: 1px solid #e99abc;
  border-radius: 8px 8px 13px 13px;
  background: #f7bdd5;
}

.intro-letter {
  position: absolute;
  z-index: 2;
  top: 38px;
  left: 10%;
  width: 80%;
  height: 142px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #f6d9e5;
  border-radius: 8px;
  color: #a9507b;
  background: #fffdfd;
  box-shadow: 0 5px 12px rgba(135, 51, 89, .12);
  font-size: 14px;
  font-weight: 700;
}

.intro-screen.is-opening .intro-letter { animation: letter-rise .8s ease .95s both; }

.letter-icon { color: #d45f94; font-family: Georgia, serif; font-size: 32px; line-height: 1; }

.envelope-front {
  z-index: 4;
  top: 15px;
  bottom: 0;
  border-radius: 0 0 13px 13px;
  background: linear-gradient(145deg, #f9c9dc, #eea9c8);
  clip-path: polygon(0 12%, 50% 62%, 100% 12%, 100% 100%, 0 100%);
}

.envelope-flap {
  z-index: 5;
  top: 15px;
  height: 112px;
  background: #f5b7d1;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  backface-visibility: hidden;
}

.intro-screen.is-opening .envelope-flap { animation: flap-open .65s ease .4s forwards; }

.envelope-seal {
  position: absolute;
  z-index: 6;
  top: 73px;
  left: 50%;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  transform: translateX(-50%);
  border-radius: 50%;
  color: #fff;
  background: #ce5b91;
  box-shadow: 0 3px 8px rgba(137, 37, 87, .18);
  font-family: Georgia, serif;
  font-size: 24px;
}

.intro-screen.is-opening .envelope-seal { animation: seal-fade .2s ease .4s forwards; }

.intro-hint {
  margin: 0;
  color: #995370;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

@keyframes flap-open {
  from { transform: rotateX(0); }
  to { transform: rotateX(180deg); }
}

@keyframes letter-rise {
  from { transform: translateY(24px); }
  to { transform: translateY(-76px); }
}

@keyframes seal-fade {
  to { opacity: 0; visibility: hidden; }
}

@keyframes intro-leave {
  from { opacity: 1; visibility: visible; }
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  filter: blur(75px);
  pointer-events: none;
  opacity: .4;
}

.ambient-one { top: -10rem; left: -8rem; background: #f6a4cb; }
.ambient-two { right: -10rem; bottom: -11rem; background: #f4a8c9; }

.heart-rain {
  position: fixed;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.rain-heart {
  position: absolute;
  top: -10vh;
  left: var(--left);
  color: var(--color);
  font-family: Georgia, serif;
  font-size: var(--size);
  line-height: 1;
  opacity: 0;
  animation: heart-fall var(--duration) linear var(--delay) infinite;
}

@keyframes heart-fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(-15deg); opacity: 0; }
  10%, 85% { opacity: .42; }
  100% { transform: translate3d(var(--drift), 115vh, 0) rotate(35deg); opacity: 0; }
}

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100svh;
  padding: 22px 16px 20px;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: center;
}

.tiny-stars {
  color: #dc7ca8;
  font-size: 21px;
  letter-spacing: 13px;
  line-height: 1;
  transform: translateX(6px);
  user-select: none;
}

.tiny-stars span { color: #c45489; }

.love-note {
  position: relative;
  width: min(100%, 610px);
  margin: 18px 0;
  padding: clamp(25px, 5vw, 45px);
  border: 1px solid #f6c9dc;
  border-radius: 30px;
  background: radial-gradient(circle at 50% -12%, #fff1f7, transparent 43%), #fffdfd;
  box-shadow: 0 20px 55px rgba(167, 77, 116, .13), 0 3px 12px rgba(167, 77, 116, .07);
}

.love-note::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid #fbe6ee;
  border-radius: 23px;
  pointer-events: none;
}

.note-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.eyebrow {
  color: #b96a92;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .13em;
}

.heart-mark {
  color: #db6f9f;
  font-family: Georgia, serif;
  font-size: 34px;
  line-height: 1;
}

.note-body { padding: clamp(26px, 5vw, 40px) 0 2px; text-align: center; }

.intro {
  margin: 0 0 16px;
  color: #a56b87;
  font-size: clamp(14px, 2.8vw, 16px);
  line-height: 1.7;
}

h1 {
  margin: 0;
  color: #723650;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.18;
}

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

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(100%, 250px);
  margin: 24px auto 20px;
  color: #d977a5;
  font-family: Georgia, serif;
  font-size: 16px;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #eab3cc);
}

.divider::after { transform: rotate(180deg); }

.message {
  margin: 0 auto;
  color: #76586a;
  font-size: clamp(15px, 3vw, 16px);
  line-height: 1.95;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: min(100%, 330px);
  margin: 30px auto 0;
}

.button {
  width: 100%;
  min-height: 56px;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 11px 23px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 3px solid #9f346c; outline-offset: 4px; }

.button-yes {
  color: #fff;
  background: linear-gradient(135deg, #ce5a91, #ad386f);
  box-shadow: 0 8px 20px rgba(175, 56, 111, .23);
}

.button-yes:hover { box-shadow: 0 11px 24px rgba(175, 56, 111, .33); }

.button-later {
  border-color: #e9bfd2;
  color: #8b4e6e;
  background: #fff8fb;
}

.button-later:hover { background: #fff0f6; }
.button-later:disabled,
.button-later:disabled:hover {
  cursor: not-allowed;
  transform: none;
  color: #b79cab;
  border-color: #eddbe3;
  background: #f9f4f6;
  box-shadow: none;
}

.footer-note {
  margin: 0;
  color: #ae7c99;
  font-size: 12px;
  letter-spacing: .01em;
  text-align: center;
}

.footer-note span { color: #cc5f92; margin: 0 5px; }

.answer-dialog {
  width: min(calc(100% - 32px), 480px);
  max-height: calc(100% - 32px);
  border: 1px solid #f0bfd4;
  border-radius: 28px;
  padding: 40px 28px 32px;
  color: #70425d;
  background: linear-gradient(150deg, #fffafd, #fff0f7);
  box-shadow: 0 30px 90px #71395545;
  text-align: center;
}

.answer-dialog::backdrop { background: rgba(69, 27, 52, .48); backdrop-filter: blur(5px); }
.dialog-sparkle { color: #d96599; font-family: Georgia, serif; font-size: 30px; letter-spacing: .2em; }
.answer-dialog h2 { margin: 14px 0; color: #b4437b; font-size: clamp(28px, 6vw, 38px); }
.answer-dialog p { margin: 0 0 28px; color: #74546a; font-size: 15px; line-height: 2; }
.answer-dialog .notification-status {
  min-height: 24px;
  margin: -12px 0 25px;
  color: #9b5277;
  font-size: 13px;
  line-height: 1.7;
}
.button-close {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: #b4437b;
}

.button-close small { font-size: 12px; font-weight: 500; opacity: .88; }

.celebration { position: fixed; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; }
.celebration[hidden] { display: none; }
.confetti {
  position: absolute;
  top: -30px;
  left: var(--left);
  color: var(--color);
  font-family: Georgia, serif;
  font-size: var(--size);
  animation: fall var(--duration) linear var(--delay) forwards;
}

@keyframes fall {
  from { transform: translate3d(0, -20px, 0) rotate(0); opacity: 0; }
  10% { opacity: 1; }
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(480deg); opacity: 0; }
}

@media (max-width: 500px) {
  .page-shell { padding: 20px 14px 18px; }
  .love-note { margin: 15px 0; border-radius: 26px; }
  .love-note::before { inset: 7px; border-radius: 20px; }
  .note-body { padding-top: 27px; }
  .actions { margin-top: 26px; }
  .footer-note { font-size: 11px; }
}

@media (max-width: 360px) {
  .love-note { padding: 22px; }
  h1 { font-size: 45px; }
  .message { font-size: 14px; }
}

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