:root {
  color-scheme: light;
  --ground: #f7eee8;
  --paper: #fffaf1;
  --paper-edge: #e8d8c9;
  --ink: #4e202b;
  --ink-soft: #73545a;
  --muted: #735f5b;
  --rose: #d7aaa0;
  --rose-deep: #8d454d;
  --rule: #dfd0c2;
  --space: 4px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--ground);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--ground);
}

button, a { font: inherit; }

button { color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--rose-deep);
  outline-offset: 4px;
}

.page-frame {
  isolation: isolate;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(100%, 660px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(30px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.paper-speck {
  position: absolute;
  z-index: -1;
  inset: 14px 12px;
  border: 1px solid rgba(117, 79, 71, 0.075);
  pointer-events: none;
}

.page-note {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 23px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  letter-spacing: 0.025em;
}

.page-note span { padding: 0 4px; color: var(--rose-deep); }

.screen {
  width: 100%;
  animation: arrive 360ms cubic-bezier(.23, 1, .32, 1) both;
}

.screen[hidden] { display: none; }

.screen--envelope,
.screen--ending {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.screen--envelope { padding-top: 8px; }

.envelope-scene {
  position: relative;
  isolation: isolate;
  width: min(100%, 360px);
  aspect-ratio: 360 / 240;
  margin: 22px 0 20px;
}

.envelope-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 9px 8px rgba(79, 44, 42, 0.10));
  transition: transform 650ms cubic-bezier(.23, 1, .32, 1), opacity 600ms ease;
}

.envelope-flap {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 50% 20%;
  transition: transform 580ms cubic-bezier(.23, 1, .32, 1), opacity 460ms ease;
}

.letter-peek {
  position: absolute;
  z-index: 0;
  top: 18%;
  left: 18%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 64%;
  height: 61%;
  padding: 17px 16px 13px;
  border: 1px solid #e3d3c3;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  transition: transform 700ms cubic-bezier(.23, 1, .32, 1), opacity 500ms ease;
}

.letter-peek img { width: 23px; height: 23px; align-self: flex-end; }

.envelope-seal {
  position: absolute;
  z-index: 3;
  top: 52%;
  left: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  transition: transform 400ms ease, opacity 320ms ease;
}

.envelope-scene.is-opening .envelope-art { transform: translateY(9px); opacity: 0.66; }
.envelope-scene.is-opening .envelope-flap { transform: translateY(-23px) rotate(-2deg) scaleY(.9); opacity: .38; }
.envelope-scene.is-opening .envelope-seal { transform: translate(-50%, -50%) rotate(-10deg) scale(.82); opacity: .45; }
.envelope-scene.is-opening .letter-peek { z-index: 4; transform: translateY(-31px); }

.open-button { min-width: 192px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 19px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease, border-color 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

.button:active:not(:disabled) { transform: scale(.97); }

.button--primary {
  background: var(--ink);
  color: #fffaf3;
}

.button--primary:hover:not(:disabled) { background: #66303c; }

.button--text {
  min-width: 124px;
  border-color: #cdb7aa;
  background: transparent;
  color: var(--ink);
}

.button--text:hover { background: rgba(255, 250, 241, .56); }

.button--outline {
  border-color: #cdb7aa;
  background: transparent;
  color: var(--ink);
}

.button--outline:hover { background: rgba(255, 250, 241, .6); }

.button:disabled,
.button[aria-disabled="true"] {
  border-color: #d9cfc4;
  background: #e9e0d7;
  color: #735f5b;
  cursor: not-allowed;
}

.quiet-note {
  margin: 15px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-style: italic;
}

.screen--ticket { max-width: 508px; margin: 0 auto; }

.ticket {
  position: relative;
  padding: 22px 22px 16px;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  box-shadow: 0 4px 12px rgba(87, 51, 45, 0.045);
}

.ticket-topline,
.ticket-bottomline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.ticket-edition { text-align: right; font-size: 9px; }

.invite-dedication {
  margin: 29px 0 7px;
  color: var(--rose-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-style: italic;
}

.ticket-title,
.ending-title,
.reply-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.ticket-title { max-width: 420px; font-size: clamp(30px, 8.4vw, 43px); line-height: 1.08; }

.ticket-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.ticket-aside {
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-style: italic;
}

.monkey-sticker {
  flex: 0 0 auto;
  width: 60px;
  height: auto;
  transform: rotate(-5deg);
}

.ticket-rule {
  position: relative;
  height: 18px;
  margin: 18px 0 17px;
  border-top: 1px dashed var(--rule);
}

.ticket-rule::before,
.ticket-rule::after {
  position: absolute;
  top: -7px;
  width: 13px;
  height: 13px;
  border: 1px solid var(--paper-edge);
  border-radius: 50%;
  background: var(--ground);
  content: "";
}

.ticket-rule::before { left: -29px; }
.ticket-rule::after { right: -29px; }

.ticket-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 12px;
  margin: 0;
}

.ticket-details div { min-width: 0; }
.ticket-details dt,
.receipt > div > span {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.ticket-details dd {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.25;
  text-wrap: pretty;
}

.ticket-question {
  margin: 26px -2px 0;
  padding: 19px 2px 16px;
  border-top: 1px solid #eee4d8;
  text-align: center;
}

.ticket-question h2 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -.025em;
}

.answer-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.answer-options .button { min-height: 45px; padding: 11px 15px; font-size: 14px; }

.decline-link,
.back-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #c6b5aa;
  text-underline-offset: 4px;
  -webkit-tap-highlight-color: transparent;
}

.decline-link { min-width: 44px; min-height: 44px; margin-top: 8px; padding: 8px 14px; font-size: 13px; }
.decline-link:hover, .back-link:hover { color: var(--ink); }

.ticket-bottomline {
  min-height: 32px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
  font-size: 8px;
  letter-spacing: .07em;
}

.ticket-bottomline img { width: 17px; height: 17px; margin: 0 3px; }
.back-link { display: block; min-height: 44px; margin: 9px auto 0; padding: 10px 12px; font-size: 13px; }

.screen--reply { max-width: 470px; margin: 0 auto; text-align: center; }

.reply-paper {
  min-height: 300px;
  padding: 29px 22px 25px;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  box-shadow: 0 4px 12px rgba(87, 51, 45, 0.04);
}

.step-mark {
  margin: 17px 0 14px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.reply-title { min-height: 2.25em; font-size: clamp(29px, 7.5vw, 39px); line-height: 1.13; }
.reply-copy { margin: 13px auto 0; max-width: 340px; color: var(--ink-soft); font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.5; }
.reply-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 26px; }
.reply-actions .button { min-height: 46px; font-size: 14px; }
.reply-actions .button--text { border-color: transparent; text-decoration: underline; text-decoration-color: #c6b5aa; text-underline-offset: 4px; }

.ending-mark {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  margin-bottom: 17px;
  border: 1px solid #bc8888;
  border-radius: 50%;
  color: var(--rose-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-style: italic;
  transform: rotate(-9deg);
}

.ending-title { margin-top: 15px; font-size: clamp(35px, 9vw, 47px); line-height: 1.08; }
.ending-title span { font-size: .62em; }
.ending-copy { margin: 16px 0 22px; color: var(--ink-soft); font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.5; }

.approval-stamp {
  position: relative;
  align-self: flex-end;
  margin: 0 8px 14px auto;
  padding: 5px 8px 4px;
  border: 2px solid var(--rose-deep);
  color: var(--rose-deep);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .11em;
  opacity: 0;
  transform: rotate(1deg) scale(.94);
  transition: opacity 380ms ease, transform 380ms cubic-bezier(.23, 1, .32, 1);
}

.screen--accepted.is-visible .approval-stamp { opacity: 1; transform: rotate(8deg) scale(.96); }

.receipt {
  width: min(100%, 350px);
  margin: 24px 0 20px;
  padding: 15px 15px 12px;
  border-top: 1px dashed #cdb8a8;
  border-bottom: 1px dashed #cdb8a8;
  text-align: left;
}

.receipt > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; }
.receipt > div > span { flex: 0 0 auto; margin: 0; }
.receipt strong { color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 14px; font-weight: 400; text-align: right; }
.receipt-status strong { color: #496b50; }
.whatsapp-button { min-width: min(100%, 250px); }

.page-footer {
  position: absolute;
  right: 24px;
  bottom: max(18px, env(safe-area-inset-bottom));
  opacity: .55;
}

.page-footer img { display: block; width: 24px; height: 24px; }
.screen-reader-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
  .page-frame { padding-right: 17px; padding-left: 17px; }
  .ticket { padding-right: 18px; padding-left: 18px; }
  .ticket-rule::before { left: -24px; }
  .ticket-rule::after { right: -24px; }
  .ticket-details { gap: 13px 8px; }
  .ticket-details dd { font-size: 14px; }
  .ticket-topline { font-size: 9px; }
  .ticket-edition { font-size: 8px; }
  .monkey-sticker { width: 54px; }
}

@media (min-width: 700px) {
  .page-frame { padding-right: 30px; padding-left: 30px; }
  .ticket { padding: 27px 30px 18px; }
  .ticket-title { font-size: 43px; }
  .monkey-sticker { width: 72px; }
}

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