:root {
  --paper: #f5ecdf;
  --paper-deep: #e8dac7;
  --ink: #5c4a37;
  --muted: #8f7a60;
  --gold: #b99a64;
  --gold-soft: rgba(185, 154, 100, 0.42);
  --veil: rgba(97, 73, 47, 0.28);
  --page-width: min(calc(100vw - 24px), calc((100svh - 22px) * 9 / 16), 520px);
  --detail-scale: 1.025;
  --page-radius: 26px;
  --tear-line-top: 83.3%;
  --tear-zone-left: 7%;
  --tear-zone-top: 80.5%;
  --tear-zone-width: 86%;
  --tear-zone-height: 6.2%;

  --map-button-left: 15%;
  --map-button-top: 51.5%;
  --map-button-width: 27%;
  --map-button-height: 5.1%;
  --venue-hotspot-left: 7%;
  --venue-hotspot-top: 44%;
  --venue-hotspot-width: 86%;
  --venue-hotspot-height: 14%;

  --calendar-hotspot-left: 14%;
  --calendar-hotspot-top: 29.8%;
  --calendar-hotspot-width: 18%;
  --calendar-hotspot-height: 12%;

  --rsvp-hotspot-left: 30%;
  --rsvp-hotspot-top: 80.2%;
  --rsvp-hotspot-width: 40%;
  --rsvp-hotspot-height: 5.2%;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  color: var(--ink);
  font-family: "Times New Roman", "Songti SC", "Noto Serif SC", "PingFang SC", serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 250, 241, 0.94), transparent 30%),
    linear-gradient(145deg, #f2e7d7 0%, #eadbc8 47%, #f7efe5 100%);
  touch-action: pan-y;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.36;
  background-image:
    linear-gradient(rgba(114, 86, 54, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(114, 86, 54, 0.035) 1px, transparent 1px);
  background-size: 5px 5px, 7px 7px;
  mix-blend-mode: multiply;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.invite-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.invite-stage {
  position: relative;
  width: var(--page-width);
  aspect-ratio: 9 / 16;
  filter: drop-shadow(0 22px 28px rgba(81, 58, 36, 0.22));
  perspective: 1200px;
}

.music-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 12;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(185, 154, 100, 0.34);
  border-radius: 50%;
  color: rgba(99, 73, 43, 0.72);
  background: rgba(255, 250, 240, 0.44);
  box-shadow: 0 8px 22px rgba(92, 66, 38, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.music-toggle::before,
.music-toggle::after,
.music-toggle span {
  position: absolute;
  bottom: 9px;
  width: 3px;
  content: "";
  border-radius: 999px;
  background: currentColor;
  transform-origin: bottom;
}

.music-toggle::before {
  left: 10px;
  height: 10px;
}

.music-toggle span {
  left: 15px;
  height: 15px;
}

.music-toggle::after {
  left: 20px;
  height: 12px;
}

.music-toggle.is-playing::before,
.music-toggle.is-playing::after,
.music-toggle.is-playing span {
  animation: musicBars 0.92s ease-in-out infinite;
}

.music-toggle.is-playing span {
  animation-delay: 0.16s;
}

.music-toggle.is-playing::after {
  animation-delay: 0.3s;
}

@keyframes musicBars {
  0%,
  100% {
    transform: scaleY(0.72);
    opacity: 0.62;
  }
  50% {
    transform: scaleY(1.08);
    opacity: 1;
  }
}

.ticket-page {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 18px, 0) scale(0.985);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.72, 0.16, 1);
}

.cover-page {
  z-index: 4;
}

.detail-page {
  z-index: 1;
}

.ticket-page.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}

.cover-page.is-torn {
  z-index: 4;
  opacity: 1;
  pointer-events: none;
  transform: translate3d(0, 0, 0) scale(1);
}

.detail-page.is-revealed {
  z-index: 3;
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(var(--detail-scale));
}

.detail-page.is-revealed img {
  filter: drop-shadow(0 18px 26px rgba(81, 58, 36, 0.2));
}

.ticket-page img,
.cover-piece {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.cover-image,
.cover-pieces,
.cover-piece {
  position: absolute;
  inset: 0;
}

.cover-image {
  z-index: 1;
  transition: opacity 0.18s ease;
}

.cover-pieces {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

.cover-piece {
  filter: drop-shadow(0 10px 12px rgba(67, 48, 30, 0.1));
  will-change: transform, opacity;
}

.cover-piece-top {
  clip-path: inset(0 0 calc(100% - var(--tear-line-top)) 0);
  transform-origin: 50% var(--tear-line-top);
}

.cover-piece-bottom {
  clip-path: inset(var(--tear-line-top) 0 0 0);
  transform-origin: 50% var(--tear-line-top);
}

.cover-page.is-torn .cover-image {
  opacity: 0;
}

.cover-page.is-torn .cover-pieces {
  opacity: 1;
}

.cover-page.is-torn .cover-piece-top {
  animation: tearTop 0.82s cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

.cover-page.is-torn .cover-piece-bottom {
  animation: tearStub 0.82s cubic-bezier(0.2, 0.72, 0.16, 1) both;
}

@keyframes tearTop {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  42% {
    opacity: 0.96;
    transform: translate3d(24px, -10px, 0) rotate(0.55deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(74px, -34px, 0) rotate(2.1deg);
  }
}

@keyframes tearStub {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  48% {
    opacity: 0.92;
    transform: translate3d(14px, 7px, 0) rotate(0.35deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(46px, 22px, 0) rotate(0.9deg);
  }
}

.map-button {
  position: absolute;
  border: 1px solid rgba(185, 154, 100, 0.34);
  color: rgba(97, 71, 42, 0.74);
  background: rgba(255, 250, 240, 0.44);
  box-shadow: 0 8px 18px rgba(95, 68, 39, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(9px) saturate(1.08);
  -webkit-backdrop-filter: blur(9px) saturate(1.08);
}

.tear-zone {
  position: absolute;
  left: var(--tear-zone-left);
  top: var(--tear-zone-top);
  z-index: 5;
  width: var(--tear-zone-width);
  height: var(--tear-zone-height);
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  color: rgba(102, 77, 46, 0.72);
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.tear-zone::before {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 50%;
  height: 12px;
  content: "";
  border-top: 1px solid rgba(185, 154, 100, 0.52);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  opacity: 0.72;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 8px rgba(189, 158, 101, 0.32));
  animation: perforationBreath 2.8s ease-in-out infinite;
}

.tear-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 5px 12px;
  border: 1px solid rgba(185, 154, 100, 0.28);
  border-radius: 999px;
  color: rgba(38, 34, 30, 0.68);
  background: rgba(255, 250, 239, 0.42);
  box-shadow: 0 8px 18px rgba(91, 66, 39, 0.08);
  font-size: clamp(11px, 2.8vw, 13px);
  letter-spacing: 0.08em;
  white-space: nowrap;
  transform: translate(-50%, 8px);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.finger-hint {
  position: absolute;
  left: 38%;
  top: 52%;
  width: 18px;
  height: 28px;
  border: 1.5px solid rgba(128, 94, 52, 0.58);
  border-radius: 10px 10px 9px 9px;
  background: rgba(255, 250, 239, 0.45);
  box-shadow: 0 8px 15px rgba(87, 62, 35, 0.12);
  transform: translate(-50%, 24px) rotate(-7deg);
  animation: fingerSwipeRight 2.4s ease-in-out infinite;
}

.finger-hint::after {
  position: absolute;
  left: 18px;
  top: 50%;
  width: 56px;
  height: 1px;
  content: "";
  background: linear-gradient(to right, rgba(128, 94, 52, 0.42), rgba(128, 94, 52, 0));
  transform: translateY(-50%);
}

.cover-page.is-touching .tear-zone::before {
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(189, 158, 101, 0.46));
}

.cover-page.is-touching .cover-image {
  transform: translateX(var(--tear-drag, 0px)) rotate(var(--tear-drag-rotate, 0deg));
}

.cover-page.is-torn .tear-zone {
  opacity: 0;
  pointer-events: none;
}

@keyframes perforationBreath {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.82;
  }
}

@keyframes fingerSwipeRight {
  0%,
  78%,
  100% {
    opacity: 0;
    transform: translate(-50%, 24px) rotate(-7deg);
  }
  18% {
    opacity: 0.8;
    transform: translate(-50%, 24px) rotate(-7deg);
  }
  52% {
    opacity: 0.54;
    transform: translate(64px, 24px) rotate(-7deg);
  }
}

.map-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.map-button:active {
  transform: translate(-50%, calc(-50% + 1px));
}

.map-button {
  left: var(--map-button-left);
  top: var(--map-button-top);
  width: var(--map-button-width);
  height: var(--map-button-height);
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 0;
  transform: translate(-50%, -50%);
  z-index: 3;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.venue-hotspot,
.calendar-hotspot,
.rsvp-hotspot {
  position: absolute;
  z-index: 2;
  display: block;
  border: 0;
  border-radius: 18px;
  background: transparent;
}

.venue-hotspot {
  left: var(--venue-hotspot-left);
  top: var(--venue-hotspot-top);
  width: var(--venue-hotspot-width);
  height: var(--venue-hotspot-height);
}

.calendar-hotspot {
  left: var(--calendar-hotspot-left);
  top: var(--calendar-hotspot-top);
  width: var(--calendar-hotspot-width);
  height: var(--calendar-hotspot-height);
  min-height: 54px;
}

.rsvp-hotspot {
  left: var(--rsvp-hotspot-left);
  top: var(--rsvp-hotspot-top);
  width: var(--rsvp-hotspot-width);
  height: var(--rsvp-hotspot-height);
  min-height: 42px;
}

.easter-egg {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.easter-egg.is-open {
  display: flex;
}

.egg-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(70, 48, 30, 0.24);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.egg-note {
  position: relative;
  width: min(82vw, 340px);
  padding: 26px 24px 24px;
  border: 2px solid rgba(30, 27, 23, 0.78);
  border-radius: 8px;
  color: #241f1a;
  background:
    radial-gradient(circle at 12% 18%, rgba(198, 81, 65, 0.12), transparent 18%),
    linear-gradient(135deg, rgba(255, 250, 239, 0.96), rgba(243, 232, 210, 0.96));
  box-shadow: 0 22px 50px rgba(56, 36, 22, 0.22);
  transform: rotate(-1.2deg);
  animation: eggPop 0.28s ease both;
}

.egg-note::before {
  position: absolute;
  top: -15px;
  left: 38%;
  width: 74px;
  height: 28px;
  content: "";
  border: 1px solid rgba(30, 27, 23, 0.36);
  background: rgba(255, 247, 230, 0.7);
  transform: rotate(4deg);
}

.egg-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #302923;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.egg-kicker {
  margin: 0 0 8px;
  color: #b75245;
  font-family: "Comic Sans MS", "PingFang SC", sans-serif;
  font-size: 14px;
  letter-spacing: 0.16em;
}

.egg-note h2 {
  margin: 0 0 12px;
  font-family: "Comic Sans MS", "PingFang SC", sans-serif;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.egg-note p {
  font-family: "Comic Sans MS", "PingFang SC", sans-serif;
}

#dayEggCopy {
  margin: 0;
  color: rgba(36, 31, 26, 0.78);
  font-size: 15px;
  line-height: 1.8;
}

.egg-sign {
  margin: 18px 0 0;
  color: #b75245;
  font-size: 14px;
  text-align: right;
}

@keyframes eggPop {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(-2.8deg) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(-1.2deg) scale(1);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(93, 67, 39, 0.32);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  width: min(92vw, 430px);
  max-height: min(86svh, 720px);
  overflow-y: auto;
  padding: 26px 22px 22px;
  border: 1px solid rgba(185, 154, 100, 0.48);
  border-radius: 22px;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 252, 245, 0.9), rgba(242, 231, 214, 0.9)),
    var(--paper);
  box-shadow: 0 24px 70px rgba(63, 44, 27, 0.25);
  animation: modalIn 0.34s ease both;
  -webkit-overflow-scrolling: touch;
}

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

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #7d6748;
  background: rgba(255, 255, 255, 0.34);
  font-size: 26px;
  line-height: 1;
}

.modal-kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.modal-subtitle,
.success-copy {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.field {
  display: grid;
  gap: 8px;
  margin: 0 0 15px;
  color: #6f5a3d;
  font-size: 14px;
}

.field em {
  color: #a77a45;
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(185, 154, 100, 0.36);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 252, 246, 0.72);
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 92px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(169, 126, 67, 0.72);
  box-shadow: 0 0 0 3px rgba(185, 154, 100, 0.13);
}

.choice-field {
  border: 0;
  padding: 0;
}

.choice-field legend {
  margin-bottom: 8px;
}

.choice-field label {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-right: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(185, 154, 100, 0.32);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.52);
}

.choice-field input {
  width: 16px;
  min-height: auto;
  margin: 0 6px 0 0;
  accent-color: #a9834d;
}

.is-disabled {
  opacity: 0.48;
}

.is-disabled select {
  pointer-events: none;
}

.form-message {
  min-height: 20px;
  margin: 2px 0 12px;
  color: #9a673f;
  font-size: 13px;
  line-height: 1.5;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 12px;
  align-items: center;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 16px;
  letter-spacing: 0.06em;
}

.primary-button {
  border: 1px solid rgba(143, 104, 52, 0.72);
  color: #fffaf0;
  background: linear-gradient(135deg, #a9844e, #c5a46a);
  box-shadow: 0 12px 26px rgba(111, 80, 38, 0.2);
}

.secondary-button {
  border: 1px solid rgba(185, 154, 100, 0.38);
  color: #756045;
  background: rgba(255, 252, 246, 0.58);
}

.primary-button[disabled] {
  opacity: 0.72;
  cursor: default;
}

.full-button {
  width: 100%;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(82vw, 360px);
  padding: 10px 16px;
  border: 1px solid rgba(185, 154, 100, 0.38);
  border-radius: 999px;
  color: #674f33;
  background: rgba(255, 250, 241, 0.9);
  box-shadow: 0 12px 30px rgba(73, 50, 28, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.24s ease, transform 0.24s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toast.is-showing {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 390px) {
  :root {
    --page-width: min(calc(100vw - 16px), calc((100svh - 16px) * 9 / 16));
  }

  .invite-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  .modal-card {
    padding: 24px 18px 18px;
    border-radius: 18px;
  }

  h2 {
    font-size: 24px;
  }
}

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