:root {
  --paper: #f4eee3;
  --paper-2: #ebe2d2;
  --ink: #4a3f35;
  --muted: #85786a;
  --gold: #b8975a;
  --gold-2: #dcc390;
  --sage: #6e7b5a;
  --sage-2: #8d9a76;
  --lace: #faf6ee;
  --col: min(100vw, 480px);
  --script: "Great Vibes", "Segoe Script", cursive;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Montserrat", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--serif);
  color: var(--ink);
  background: #2f2a24 radial-gradient(ellipse at center, #5a4d3e 0%, #2b2621 70%) fixed;
  min-height: 100svh;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* paper texture used by the column */
.paper,
.invite,
.envelope-screen {
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .28 0 0 0 .06 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse at 20% 0%, #fbf8f1 0%, transparent 60%),
    radial-gradient(ellipse at 100% 100%, #ece3d3 0%, transparent 55%);
}

/* ---------- fixed controls ---------- */
.music-btn {
  position: fixed; z-index: 50;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(50% - var(--col) / 2 + 14px);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(250, 246, 238, .92);
  box-shadow: 0 4px 14px rgba(60, 45, 25, .18);
  display: grid; place-items: center;
}
.music-btn[hidden] { display: none; }
.music-btn svg { width: 20px; height: 20px; fill: var(--ink); }
.music-btn .i-play { display: none; }
.music-btn.paused .i-play { display: block; }
.music-btn.paused .i-pause { display: none; }
.music-btn:not(.paused)::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid rgba(184, 151, 90, .6);
  animation: ring 2.2s ease-out infinite;
}
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

.lang {
  position: fixed; z-index: 50;
  top: calc(18px + env(safe-area-inset-top));
  right: calc(50% - var(--col) / 2 + 14px);
  display: flex; padding: 3px; gap: 2px; border-radius: 99px;
  background: rgba(74, 63, 53, .55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.lang button {
  font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: #f1e9db; padding: 7px 11px; border-radius: 99px; transition: .25s;
}
.lang button.active { background: var(--lace); color: var(--ink); }

/* ---------- envelope ---------- */
.envelope-screen {
  position: fixed; inset: 0 auto 0 50%; z-index: 20;
  width: var(--col); transform: translateX(-50%);
  overflow: hidden;
  transition: opacity .9s ease, visibility .9s;
}
.envelope-screen.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.stage {
  position: absolute; left: 50%; top: 50%;
  width: max(100%, calc(100svh * 480 / 900));
  aspect-ratio: 480 / 900;
  transform: translate(-50%, -50%);
  container-type: inline-size;
  perspective: 1400px;
  cursor: pointer; outline: none;
}
.env-layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.env-inside { z-index: 1; }
.env-pocket { z-index: 3; }
.env-flap { z-index: 4; transform-origin: 50% 0; transition: transform 1s cubic-bezier(.5, 0, .3, 1); }
.env-seal { z-index: 5; pointer-events: none; }
.seal { transform-box: fill-box; transform-origin: center; transition: transform .6s ease, opacity .6s ease; animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.letter {
  position: absolute; z-index: 2;
  left: 8%; width: 84%; top: 38%; height: 30%;
  transition: transform 1.2s cubic-bezier(.3, .1, .2, 1) .2s;
}
.letter-inner {
  height: 100%; border-radius: 1.5cqw;
  background: var(--lace);
  box-shadow: 0 2cqw 6cqw rgba(80, 60, 30, .25);
  border: 1px solid #e8dcc5;
  outline: 1px solid var(--gold-2); outline-offset: -3cqw;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 1.5cqw; padding: 6cqw;
  color: var(--ink);
}
.letter .sprig { width: 22cqw; color: var(--gold); }
.letter-small { font-size: 3.6cqw; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.letter-names { font-family: var(--script); font-size: 10cqw; line-height: 1.1; }
.letter-names em { font-style: normal; font-size: .55em; margin: 0 .25em; color: var(--gold); }
.letter-date { font-size: 4cqw; letter-spacing: .25em; }

.stage.opening .seal { animation: none; transform: scale(1.25); opacity: 0; }
.stage.opening .env-flap { transform: rotateX(180deg); }
.stage.flap-back .env-flap { z-index: 0; }
.stage.letter-out .letter { transform: translateY(-80%); }

.tap-hint {
  position: absolute; left: 50%; bottom: calc(13% + env(safe-area-inset-bottom)); z-index: 6;
  transform: translateX(-50%);
  font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
  padding: 12px 22px; border-radius: 99px;
  background: rgba(250, 246, 238, .7);
  box-shadow: 0 2px 10px rgba(80, 60, 30, .08);
  animation: float 2.4s ease-in-out infinite;
  pointer-events: none; transition: opacity .4s;
}
.opened .tap-hint { opacity: 0; }
@keyframes float { 50% { transform: translate(-50%, -6px); } }

/* ---------- invitation column ---------- */
.invite {
  width: var(--col); margin: 0 auto; min-height: 100svh;
  opacity: 0; transition: opacity 1s ease;
  box-shadow: 0 0 60px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.invite.show { opacity: 1; }

.sec { padding: 64px 24px; text-align: center; position: relative; }
.script { font-family: var(--script); font-weight: 400; font-size: 54px; line-height: 1.15; color: var(--ink); }
.script.small { font-size: 34px; }
.caps { font-family: var(--sans); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink); font-weight: 500; }
.small-cap { font-size: 17px; color: var(--muted); letter-spacing: .02em; }
.lead { font-size: 19px; color: var(--muted); line-height: 1.5; max-width: 340px; margin: 12px auto 0; }

.divider { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px auto 18px; color: var(--gold); width: 200px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--gold); opacity: .6; }
.divider.light { color: #e6e9d8; }
.divider.light::before, .divider.light::after { background: #e6e9d8; }

/* hero */
.hero {
  position: relative; height: 100svh; min-height: 560px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, #fffaf0 0%, #f6efe2 45%, #ece2cf 100%);
  overflow: hidden;
}
.hero.has-image { background-size: cover; background-position: center; }
.hero.has-image::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(250,244,232,.15), rgba(250,244,232,.55) 50%, rgba(250,244,232,.15)); }
.arch { position: absolute; left: 6%; top: 10%; width: 88%; height: 90%; }
.hero.has-image .arch { display: none; }
.hero-garland {
  position: absolute; bottom: -10px; width: 58%; height: auto; aspect-ratio: 220 / 200;
  filter: drop-shadow(0 4px 8px rgba(90, 70, 40, .18));
}
.hero-garland.left { left: -10%; }
.hero-garland.right { right: -10%; transform: scaleX(-1); }
.hero.has-image .hero-garland { display: none; }
.hero-content { position: relative; z-index: 1; padding: 0 24px; animation: rise 1.6s ease both .3s; }
.hero-sub { font-family: var(--sans); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin-bottom: 18px; }
.names { font-family: var(--script); font-weight: 400; font-size: clamp(64px, 19vw, 92px); line-height: 1; color: var(--ink); text-shadow: 0 2px 12px rgba(255, 250, 240, .8); }
.names span { display: block; }
.names .amp { font-size: .45em; color: var(--gold); margin: 6px 0; }
.hero-date { margin-top: 22px; font-size: 20px; letter-spacing: .35em; }
.scroll-hint {
  position: absolute; bottom: calc(26px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 1;
  font-size: 18px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.scroll-hint i { font-style: normal; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* scratch coins */
.hand { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--lace); box-shadow: 0 3px 12px rgba(80, 60, 30, .12), inset 0 0 0 1px #e6dac4; }
.hand svg { width: 26px; fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.coins { display: flex; justify-content: center; gap: 12px; margin-top: 26px; }
.coin {
  position: relative; width: min(26vw, 120px); aspect-ratio: 1; border-radius: 50%;
  background: var(--lace);
  box-shadow: 0 0 0 5px #efe5d2, 0 0 0 6px #d8c49d, 0 6px 18px rgba(90, 70, 40, .2);
  display: grid; place-items: center;
}
.coin span { font-size: clamp(20px, 6vw, 26px); letter-spacing: .03em; }
.coin canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; cursor: pointer; transition: opacity .6s; }
.coin.done canvas { opacity: 0; pointer-events: none; }
.full-date { max-height: 0; opacity: 0; overflow: hidden; transition: max-height 1s ease, opacity 1s ease .2s; }
.full-date.show { max-height: 200px; opacity: 1; }
.full-date .divider { margin-top: 30px; width: 240px; }
.full-date .divider span { display: none; }
.weekday { font-size: 22px; letter-spacing: .3em; }
.date-long { font-size: 24px; letter-spacing: .18em; text-transform: uppercase; margin-top: 4px; }

/* greeting */
.greet-card {
  background: linear-gradient(160deg, #7c8966, #66734f);
  color: #f4efe2; border-radius: 22px; padding: 36px 26px 26px;
  box-shadow: 0 0 0 4px #efe5d2, 0 0 0 5px #d8c49d, 0 12px 30px rgba(60, 70, 40, .25);
}
.greet-card .script { color: #fbf7ec; font-size: 48px; }
.greet-card p { font-size: 19px; line-height: 1.55; }
.sprig { width: 120px; color: var(--gold); display: block; margin: 0 auto 6px; }
.sprig.light { color: #f4efe2; }
.garland { width: 100%; max-width: 300px; margin-top: 18px; }

/* calendar */
.calendar {
  margin: 22px auto 0; max-width: 360px; padding: 24px 18px 20px;
  background: var(--lace); border-radius: 18px;
  box-shadow: 0 8px 26px rgba(90, 70, 40, .12), inset 0 0 0 1px #eadfca;
}
.cal-month { font-size: 22px; letter-spacing: .3em; text-transform: uppercase; margin-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px 0; }
.cal-grid .wd { font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: .08em; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid #e8dcc6; margin-bottom: 6px; text-transform: uppercase; }
.cal-grid .d { font-size: 18px; height: 40px; display: grid; place-items: center; position: relative; }
.cal-grid .d.wed { color: #fff; font-weight: 600; }
.cal-grid .d.wed::before {
  content: ""; position: absolute; width: 38px; height: 38px; z-index: -1;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23b8975a' d='M12 21s-7.5-4.6-9.6-9.3C.9 8.2 3.1 4.5 6.7 4.5c2.1 0 3.6 1.2 4.3 2.6h2c.7-1.4 2.2-2.6 4.3-2.6 3.6 0 5.8 3.7 4.3 7.2C19.5 16.4 12 21 12 21z'/></svg>") center/contain no-repeat;
  animation: beat 1.6s ease-in-out infinite;
}
.cal-grid .d.wed { isolation: isolate; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.12); } 30% { transform: scale(1); } 45% { transform: scale(1.08); } }

/* timeline */
.timeline { list-style: none; position: relative; max-width: 380px; margin: 10px auto 0; text-align: left; }
.timeline::before { content: ""; position: absolute; left: 50px; top: 10px; bottom: 10px; width: 1px; background: linear-gradient(var(--gold-2), var(--gold), var(--gold-2)); }
.timeline li { display: grid; grid-template-columns: 100px 1fr; align-items: start; padding: 14px 0; }
.t-icon {
  grid-row: span 3; justify-self: center; position: relative; z-index: 1;
  width: 46px; height: 46px; border-radius: 50%; background: var(--lace); display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--gold-2), 0 4px 10px rgba(90, 70, 40, .12);
}
.t-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--sage); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.t-time { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .12em; color: var(--gold); }
.t-title { font-size: 22px; font-weight: 600; line-height: 1.2; }
.t-text { font-size: 17px; color: var(--muted); }

/* venue */
.venue-pic { margin: 18px -24px 4px; }
.venue-pic svg, .venue-pic img { width: 100%; display: block; }
.venue-pic svg { padding: 0 18px; }
.venue-name { font-size: 28px; letter-spacing: .2em; text-transform: uppercase; margin-top: 14px; }
.venue-addr { font-size: 19px; color: var(--muted); }
.venue-time { font-size: 32px; letter-spacing: .15em; margin: 8px 0 18px; }
.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.btn-row > * { flex: 1; max-width: 180px; }
.btn-outline {
  display: block; padding: 11px 10px; border-radius: 99px; border: 1px solid #8f8273;
  color: var(--ink); text-decoration: none; font-size: 17px; transition: .25s; text-align: center;
}
.btn-outline:hover { background: var(--ink); color: var(--lace); }
.btn-solid {
  width: 100%; padding: 15px; border-radius: 99px; background: var(--sage); color: #fff;
  font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  box-shadow: 0 6px 16px rgba(80, 95, 60, .3); transition: .25s; margin-top: 22px;
}
.btn-solid:hover { background: #5f6b4c; }
.btn-solid.ok { background: var(--sage-2); }


/* cards & forms */
.card {
  margin: 24px auto 0; max-width: 380px; text-align: left; padding: 22px;
  background: var(--lace); border-radius: 20px;
  box-shadow: 0 10px 28px rgba(90, 70, 40, .14), inset 0 0 0 1px #ece1cd;
}
.label { display: block; font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.value { font-size: 22px; padding: 6px 0 14px; border-bottom: 1px solid #e3d7c2; margin-bottom: 12px; letter-spacing: .04em; }
.wish-form label { display: block; margin-bottom: 14px; }
.wish-form input, .wish-form textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #e0d3bc; background: #fffdf8; font: inherit; font-size: 18px; color: var(--ink); resize: vertical;
}
.wish-form input:focus, .wish-form textarea:focus { outline: 2px solid var(--gold-2); border-color: transparent; }
.wish-form .btn-solid { margin-top: 4px; }
.wishes { list-style: none; max-width: 380px; margin: 22px auto 0; display: grid; gap: 12px; text-align: left; }
.wishes li {
  padding: 16px 18px; border-radius: 16px; background: rgba(250, 246, 238, .75);
  border-left: 3px solid var(--gold-2); animation: rise .6s ease both;
}
.wishes .w-name { font-family: var(--script); font-size: 28px; line-height: 1.1; }
.wishes .w-text { font-size: 18px; line-height: 1.45; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.wishes .w-date { font-family: var(--sans); font-size: 10px; letter-spacing: .1em; color: var(--muted); margin-top: 6px; }
.wishes .empty { text-align: center; border: 1px dashed #d8c9ae; background: none; color: var(--muted); font-size: 18px; }

/* countdown */
.countdown {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 22px auto 18px; max-width: 380px;
  padding: 20px 6px; border: 1.5px solid var(--gold-2); border-radius: 4px;
  outline: 1px solid var(--gold-2); outline-offset: 4px;
  background: rgba(250, 246, 238, .6);
}
.countdown div { display: flex; flex-direction: column; align-items: center; position: relative; }
.countdown div + div::before { content: "✦"; position: absolute; left: -6px; top: 14px; font-size: 10px; color: var(--gold); }
.countdown div + div { border-left: 1px solid #e3d5bb; }
.countdown b { font-weight: 400; font-size: 38px; line-height: 1.1; }
.countdown small { font-family: var(--sans); font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.footer { text-align: center; padding: 40px 24px calc(56px + env(safe-area-inset-bottom)); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s ease, transform .9s ease; }
.reveal.in { opacity: 1; transform: none; }

/* falling petals */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.petal {
  position: absolute; top: -20px; width: 12px; height: 9px;
  background: radial-gradient(ellipse at 30% 30%, #fffaf2, #ead9c0);
  border-radius: 80% 0 80% 0; opacity: .85;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .2; }
}

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