:root {
  --wine: #3D1419;
  --rose: #9A3F4A;
  --sage: #2F4731;
  --blush: #F3D9DE;
  --cream: #FAF3EA;
  --card-cream: #F6ECDD;
  --flap-tan: #E3CFA3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--cream);
}

body {
  font-family: 'Cormorant Garamond', serif;
  color: var(--wine);
}

.std-app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  overflow: hidden;
}

/* Screens */

.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  padding: 70px 24px 60px;
}

.screen.is-active { display: flex; }

.screen--center {
  justify-content: center;
  text-align: center;
}

.screen--top {
  justify-content: flex-start;
}

/* Shared text styles */

.eyebrow {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 4px;
  font-weight: 600;
  text-align: center;
}

.eyebrow--rose { color: var(--rose); margin-bottom: 10px; }
.eyebrow--wine { color: var(--wine); margin-bottom: 26px; }

.script-names {
  font-family: 'Parisienne', cursive;
  font-size: 56px;
  line-height: 1;
  color: var(--wine);
  text-align: center;
}

.script-names--revealed {
  font-size: 52px;
  line-height: 1.05;
  margin-bottom: 44px;
}

.script-header {
  font-family: 'Parisienne', cursive;
  font-size: 44px;
  color: var(--wine);
  margin-bottom: 8px;
}

.caption {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 3px;
  color: rgba(61, 20, 25, 0.67);
  font-weight: 600;
}

.link-button, .back-link {
  border: none;
  background: none;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(61, 20, 25, 0.67);
}

.back-link { align-self: flex-start; margin-bottom: 40px; }
.link-button { margin-top: 20px; text-decoration: underline; }

/* Loading / error */

.loading-text {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: rgba(61, 20, 25, 0.67);
}

.error-title {
  font-family: 'Parisienne', cursive;
  font-size: 36px;
  color: var(--wine);
  margin-bottom: 14px;
}

.error-body {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: rgba(61, 20, 25, 0.75);
  max-width: 320px;
  line-height: 1.6;
}

/* Envelope (closed) screen */

.envelope-heading {
  text-align: center;
  margin-bottom: 44px;
}

.envelope-button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.envelope-wrap {
  perspective: 1400px;
  width: min(84vw, 460px);
}

.envelope-body {
  position: relative;
  width: 100%;
  aspect-ratio: 460 / 300;
  background: var(--card-cream);
  border-radius: 5px;
  box-shadow: 0 18px 40px rgba(61, 20, 25, 0.13), 0 2px 6px rgba(61, 20, 25, 0.1);
}

.envelope-letter {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 19%;
  aspect-ratio: 1;
  background: var(--wine);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 3px;
  z-index: 1;
}

.envelope-postage {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 40px;
  height: 52px;
  border: 1.5px dashed rgba(61, 20, 25, 0.33);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, monospace;
  font-size: 8px;
  color: rgba(61, 20, 25, 0.53);
  text-align: center;
  line-height: 1.3;
  z-index: 3;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  transform-origin: top center;
  transform-style: preserve-3d;
  z-index: 2;
}

.envelope-flap-inner {
  position: absolute;
  inset: 0;
  background: var(--flap-tan);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 5px 5px 0 0;
}

.envelope-seal {
  position: absolute;
  left: 50%;
  top: 60%;
  width: 52px;
  height: 52px;
  background: var(--wine);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Parisienne', cursive;
  color: var(--card-cream);
  font-size: 18px;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(61, 20, 25, 0.33);
}

.is-opening .envelope-flap { animation: flapOpen 0.9s ease-in forwards; }
.is-opening .envelope-seal { animation: sealBreak 0.5s ease-in 0.15s forwards; }
.is-opening .envelope-letter { animation: letterPeek 0.6s ease-out 0.35s forwards; }

@keyframes flapOpen { from { transform: rotateX(0deg); } to { transform: rotateX(-162deg); } }
@keyframes sealBreak { to { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(20deg); } }
@keyframes letterPeek { to { transform: translateY(-46px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

.fade-up { opacity: 0; animation: fadeUp 0.7s ease both; }
.pop-in { opacity: 0; animation: popIn 0.6s ease both; }

/* Revealed screen */

.greeting {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--rose);
  margin-bottom: 18px;
  max-width: 320px;
  text-align: center;
  line-height: 1.5;
}

.mini-envelope {
  width: 280px;
  position: relative;
  margin-bottom: 20px;
}

.mini-envelope-flap {
  position: relative;
  width: 100%;
  height: 80px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: var(--flap-tan);
  box-shadow: 0 -2px 6px rgba(61, 20, 25, 0.06) inset;
}

.mini-envelope-body {
  position: relative;
  width: 100%;
  height: 172px;
  background: var(--card-cream);
  margin-top: -1px;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 14px 30px rgba(61, 20, 25, 0.15);
}

.mini-envelope-diamond {
  position: absolute;
  left: 50%;
  top: -46px;
  width: 118px;
  height: 118px;
  background: var(--wine);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(61, 20, 25, 0.19);
}

.mini-envelope-diamond span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-45deg);
  font-family: 'Parisienne', cursive;
  color: var(--blush);
  font-size: 22px;
}

.mini-envelope-seal {
  position: absolute;
  left: 50%;
  top: 58px;
  width: 50px;
  height: 50px;
  background: var(--card-cream);
  border: 2px solid var(--wine);
  border-radius: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Parisienne', cursive;
  color: var(--wine);
  font-size: 15px;
  box-shadow: 0 3px 8px rgba(61, 20, 25, 0.19);
}

.card-cluster {
  position: relative;
  width: 320px;
  max-width: 100%;
  height: 560px;
  margin-bottom: 8px;
}

.card {
  position: absolute;
  border-radius: 2px;
  padding: 26px 20px;
  text-align: center;
}

.card--save-the-date {
  top: 0;
  left: 0;
  width: 210px;
  height: 270px;
  background: var(--blush);
  color: var(--wine);
  box-shadow: 0 12px 26px rgba(61, 20, 25, 0.15);
  transform: rotate(-4deg);
  z-index: 1;
}

.script-card {
  font-family: 'Parisienne', cursive;
  font-size: 34px;
  line-height: 1.15;
}

.card--date {
  top: 60px;
  left: 140px;
  width: 180px;
  height: 250px;
  background: var(--wine);
  color: var(--card-cream);
  box-shadow: 0 14px 30px rgba(61, 20, 25, 0.21);
  transform: rotate(4deg);
  z-index: 2;
}

.card-date-month {
  font-size: 12px;
  letter-spacing: 1.5px;
  font-family: system-ui, sans-serif;
  opacity: 0.7;
  margin-bottom: 4px;
}

.card-date-day {
  font-family: 'Parisienne', cursive;
  font-size: 32px;
  line-height: 1;
  margin-bottom: 12px;
}

.card-venue-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.card-venue-location {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 14px;
}

.card-maps-link {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--blush);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(243, 217, 222, 0.53);
}

.rsvp-cta {
  position: absolute;
  top: 270px;
  left: 190px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: var(--sage);
  color: var(--cream);
  font-family: 'Parisienne', cursive;
  font-size: 20px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(47, 71, 49, 0.25);
  z-index: 3;
}

.rsvp-cta:disabled {
  cursor: not-allowed;
  background: rgba(61, 20, 25, 0.35);
  box-shadow: none;
}

.polaroid {
  position: absolute;
  width: 150px;
  z-index: 1;
}

.polaroid--one { top: 330px; left: 6px; transform: rotate(-7deg); }
.polaroid--two { top: 400px; left: 100px; transform: rotate(5deg); z-index: 2; }

.polaroid-photo {
  background: #fff;
  padding: 8px 8px 20px;
  box-shadow: 0 8px 20px rgba(61, 20, 25, 0.19);
  border-radius: 2px;
  width: 134px;
  height: 134px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(61, 20, 25, 0.4);
  background-image: repeating-linear-gradient(45deg, rgba(61,20,25,0.05) 0 10px, transparent 10px 20px);
}

.countdown {
  display: flex;
  gap: 22px;
  margin-top: 20px;
}

.countdown-cell { text-align: center; }

.countdown-value {
  font-size: 26px;
  font-weight: 500;
  color: var(--wine);
}

.countdown-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(61, 20, 25, 0.67);
  font-family: system-ui, sans-serif;
}

.footer-note {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: rgba(61, 20, 25, 0.67);
  margin-top: 40px;
  text-align: center;
  max-width: 280px;
}

/* RSVP screen */

.subhead {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: rgba(61, 20, 25, 0.67);
  text-align: center;
  max-width: 320px;
  margin-bottom: 44px;
}

.rsvp-form {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guest-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 40px;
}

.guest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid rgba(61, 20, 25, 0.09);
  border-radius: 3px;
  padding: 16px 20px;
}

.guest-name { font-size: 17px; }

.guest-toggles { display: flex; gap: 6px; }

.pill {
  border-radius: 16px;
  padding: 6px 14px;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  background: transparent;
}

.pill--yes {
  border: 1px solid var(--sage);
  color: var(--sage);
}

.pill--yes.is-active {
  background: var(--sage);
  color: var(--cream);
}

.pill--no {
  border: 1px solid var(--rose);
  color: var(--rose);
}

.pill--no.is-active {
  background: var(--rose);
  color: var(--cream);
}

.field {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 36px;
}

.field label {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: rgba(61, 20, 25, 0.67);
}

.field input {
  border: 1px solid rgba(61, 20, 25, 0.19);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px;
  background: #fff;
  color: var(--wine);
}

.form-error {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: var(--rose);
  max-width: 400px;
  text-align: center;
  margin-bottom: 16px;
}

.submit-button {
  border: none;
  background: var(--wine);
  color: var(--cream);
  border-radius: 24px;
  padding: 16px 48px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(61, 20, 25, 0.21);
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.rsvp-deadline-note {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: rgba(61, 20, 25, 0.67);
  max-width: 320px;
  text-align: center;
  margin-top: 16px;
}

/* Thanks screen */

.thanks-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  animation: popIn 0.5s ease both;
}

.thanks-icon-inner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cream);
}

.thanks-body {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: rgba(61, 20, 25, 0.8);
  max-width: 340px;
  line-height: 1.7;
  margin-bottom: 30px;
}

.thanks-summary {
  background: var(--blush);
  border-radius: 3px;
  padding: 20px 28px;
  margin-bottom: 36px;
  min-width: 260px;
}

.thanks-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(61, 20, 25, 0.08);
  gap: 20px;
}

.thanks-row:last-child { border-bottom: none; }

.thanks-row-status { font-weight: 600; }
.thanks-row-status.is-yes { color: var(--sage); }
.thanks-row-status.is-no { color: var(--rose); }

@media (max-width: 360px) {
  .card-cluster { width: 280px; }
  .card--date { left: 110px; width: 170px; }
  .rsvp-cta { left: 160px; }
}
