@font-face {
  font-family: "ZCOOL KuaiLe";
  src: url("fonts/ZCOOLKuaiLe-Regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

@font-face {
  font-family: "Wedding CJK Fallback";
  src: url("fonts/LXGWMarkerGothic-Regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

:root {
  --paper: #f6f5f0;
  --green: #718653;
  --green-dark: #4f6439;
  --green-soft: #b9c98f;
  --yellow: #e6cd61;
  --orange: #d98c4a;
  --ink: #584e3d;
  --muted: #7e7463;
  --font-cn-hand: "ZCOOL KuaiLe", "Wedding CJK Fallback", "STKaiti", "KaiTi", "Kaiti SC", "PingFang SC", sans-serif;
  --font-en-hand: "ZCOOL KuaiLe", "Segoe Print", "Comic Sans MS", cursive;
}

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

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: url("paper_texture_invitation.jpg");
  background-repeat: repeat;
  background-size: min(100vw, 766px) auto;
  font-family: var(--font-cn-hand);
}

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

button {
  cursor: pointer;
}

.page {
  width: min(100%, 766px);
  margin: 0 auto;
  background-color: var(--paper);
  background-image: url("paper_texture_invitation.jpg");
  background-repeat: repeat;
  background-size: 100% auto;
  box-shadow: 0 0 35px rgba(56, 48, 35, .08);
}

.invitation-wrap {
  width: 100%;
  background: var(--paper);
}

.invitation {
  display: block;
  width: 100%;
  height: auto;
}

.rsvp-page {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100svh;
  margin-top: -2px;
  overflow: hidden;
  background-color: var(--paper);
  background-image: url("paper_texture_invitation.jpg");
  background-repeat: repeat;
  background-size: 100% auto;
}

.floral-frame {
  position: absolute;
  z-index: 0;
  top: 20px;
  left: 18px;
  width: calc(100% - 36px);
  height: auto;
  opacity: .92;
  pointer-events: none;
  user-select: none;
}

.rsvp-section {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100svh;
  margin: 0 auto;
  padding: 44px 16px 80px;
}

.paper-card {
  width: min(100%, 380px);
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  padding: 0 0 28px;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

h1 {
  margin: 0 0 16px;
  color: var(--green-dark);
  font-family: var(--font-en-hand);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: .9;
  transform: rotate(-1deg);
}

h1 span {
  display: block;
  margin-top: 13px;
  color: var(--green);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .12em;
  line-height: 1.1;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  letter-spacing: .08em;
}

.choices {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  display: grid;
  gap: 9px;
}

.choice {
  width: 100%;
  border: 1px solid rgba(103, 128, 72, .19);
  border-radius: 14px;
  min-height: 56px;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, .55);
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.choice:active {
  transform: scale(.985);
}

.choice.active {
  border-color: var(--green);
  background: rgba(205, 218, 166, .34);
}

.choice .dot {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--green-soft);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 5px var(--paper);
}

.choice.active .dot {
  background: var(--green);
}

.choice strong,
.choice small {
  display: block;
}

.choice strong {
  color: var(--ink);
  font-size: 15px;
  letter-spacing: .05em;
}

.choice small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.form {
  width: 100%;
  max-width: 340px;
  margin-right: auto;
  margin-left: auto;
  margin-top: 26px;
  display: grid;
  gap: 17px;
  text-align: left;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  color: var(--ink);
  font-size: 14px;
}

.field em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(100, 123, 70, .20);
  border-radius: 14px;
  outline: none;
  padding: 13px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, .60);
  font-family: var(--font-cn-hand);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(82, 107, 58, .54);
  box-shadow: 0 0 0 3px rgba(114, 139, 79, .08);
}

textarea {
  resize: vertical;
}

.submit {
  margin-top: 2px;
  border: 0;
  border-radius: 999px;
  padding: 15px 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  box-shadow: 0 8px 20px rgba(82, 107, 58, .16);
  letter-spacing: .12em;
}

.submit:disabled {
  opacity: .62;
  cursor: wait;
}

.success {
  padding: 24px 6px 8px;
}

.success-flower {
  width: 62px;
  height: 62px;
  margin: 0 auto 15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--orange);
  background: rgba(230, 205, 97, .22);
  font-size: 30px;
}

.success p {
  margin: 12px 0 20px;
  color: var(--muted);
}

.edit {
  border: 1px solid rgba(82, 107, 58, .25);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, .52);
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  padding: 9px 14px;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  color: #fff;
  background: rgba(54, 54, 48, .88);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  white-space: normal;
  transition: .22s ease;
}

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

.music-toggle {
  position: fixed;
  z-index: 30;
  top: calc(16px + env(safe-area-inset-top));
  right: max(16px, calc((100vw - 766px) / 2 + 16px));
  width: 40px;
  height: 40px;
  border: 1px solid rgba(79, 100, 57, .24);
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--green-dark);
  background-color: rgba(246, 245, 240, .88);
  background-image: url("paper_texture_invitation.jpg");
  background-size: 380px auto;
  box-shadow: 0 4px 15px rgba(56, 48, 35, .12);
  font-family: Georgia, serif;
  font-size: 20px;
  line-height: 1;
  backdrop-filter: blur(3px);
}

.music-toggle::after {
  content: "";
  position: absolute;
  width: 1px;
  height: 27px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(42deg);
  opacity: .72;
  transition: opacity .18s ease;
}

.music-toggle.playing::after {
  opacity: 0;
}

.music-toggle.playing span {
  animation: musicPulse 1.8s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  50% { transform: scale(1.12) rotate(5deg); }
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .music-toggle {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .music-toggle::after {
    height: 23px;
  }
}

@media (max-width: 420px) {
  .floral-frame {
    top: 18px;
    left: 8px;
    width: calc(100% - 16px);
    height: auto;
    opacity: .88;
  }

}


/* =========================================================
   Mobile floral-safe layout
   花框向两侧溢出，表单收进中间留白，避免覆盖水彩花草
   ========================================================= */
@media (max-width: 520px) {
  .rsvp-page {
    min-height: 100svh;
    overflow: hidden;
  }

  /* 花框故意做得比屏幕更宽，把两侧花草推到边缘 */
  .floral-frame {
    top: 76px;
    left: -16%;
    width: 132%;
    max-width: none;
    height: auto;
    opacity: .94;
  }

  .rsvp-section {
    min-height: 100svh;
    padding: 30px 12px 78px;
  }

  .paper-card {
    width: 100%;
    max-width: none;
    padding-bottom: 22px;
  }

  /* 标题单独留在花框上方，不压住顶部花枝 */
  h1 {
    margin-bottom: 22px;
    font-size: 27px;
  }

  h1 span {
    margin-top: 11px;
    font-size: 13px;
  }

  /* 核心：把交互控件限制在花框中央留白 */
  .choices,
  .form {
    width: min(268px, calc(100% - 76px));
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  .choices {
    gap: 7px;
  }

  .choice {
    min-height: 46px;
    padding: 7px 10px;
    gap: 8px;
    border-radius: 12px;
  }

  .choice .dot {
    width: 16px;
    height: 16px;
    border-width: 1.5px;
    box-shadow: inset 0 0 0 4px var(--paper);
  }

  .choice strong {
    font-size: 13px;
    letter-spacing: .04em;
  }

  .choice small {
    margin-top: 0;
    font-size: 9.8px;
    line-height: 1.25;
  }

  .form {
    margin-top: 18px;
    gap: 12px;
  }

  .field {
    gap: 6px;
  }

  .field > span {
    font-size: 12.5px;
  }

  .field em {
    font-size: 11px;
  }

  /* 仍保留 16px，避免 iPhone 聚焦输入框时自动页面缩放 */
  input,
  select,
  textarea {
    min-width: 0;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 16px;
  }

  textarea {
    min-height: 74px;
  }

  .submit {
    margin-top: 0;
    padding: 11px 18px;
    font-size: 14px;
  }

  .success {
    width: min(268px, calc(100% - 76px));
    margin-right: auto;
    margin-left: auto;
    padding-top: 18px;
  }

  .success-flower {
    width: 52px;
    height: 52px;
    margin-bottom: 11px;
    font-size: 25px;
  }

  .success h2 {
    font-size: 21px;
  }
}

/* 非常窄的手机（320~350px）再收一点 */
@media (max-width: 350px) {
  .floral-frame {
    left: -19%;
    width: 138%;
  }

  .choices,
  .form,
  .success {
    width: min(248px, calc(100% - 68px));
  }

  h1 {
    font-size: 25px;
  }
}


/* =========================================================
   Desktop floral-safe layout
   与手机端同一原则：花框贴边，表单收进中央留白
   ========================================================= */
@media (min-width: 700px) {
  .rsvp-page {
    min-height: 1040px;
    overflow: hidden;
  }

  /* 花框在 766px 页面内向两侧略微溢出 */
  .floral-frame {
    top: 46px;
    left: -7%;
    width: 114%;
    max-width: none;
    height: auto;
    opacity: .94;
  }

  .rsvp-section {
    min-height: 1040px;
    padding: 36px 24px 90px;
  }

  .paper-card {
    width: 100%;
    max-width: none;
    padding-bottom: 24px;
  }

  h1 {
    margin-bottom: 24px;
    font-size: 30px;
  }

  h1 span {
    margin-top: 12px;
    font-size: 14px;
  }

  /* 核心交互区控制在中央，不进入两侧花草 */
  .choices,
  .form {
    width: 318px;
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  .choices {
    gap: 8px;
  }

  .choice {
    min-height: 50px;
    padding: 8px 12px;
    gap: 9px;
    border-radius: 13px;
  }

  .choice .dot {
    width: 17px;
    height: 17px;
    border-width: 1.5px;
    box-shadow: inset 0 0 0 4px var(--paper);
  }

  .choice strong {
    font-size: 14px;
  }

  .choice small {
    font-size: 10.5px;
    line-height: 1.25;
  }

  .form {
    margin-top: 20px;
    gap: 13px;
  }

  .field {
    gap: 6px;
  }

  .field > span {
    font-size: 13px;
  }

  input,
  select,
  textarea {
    padding: 9px 11px;
    border-radius: 11px;
    font-size: 16px;
  }

  textarea {
    min-height: 78px;
  }

  .submit {
    padding: 12px 20px;
    font-size: 14px;
  }

  .success {
    width: 318px;
    margin-right: auto;
    margin-left: auto;
    padding-top: 20px;
  }
}

/* 中等宽度平板/窄桌面，留白再多一点 */
@media (min-width: 521px) and (max-width: 699px) {
  .floral-frame {
    top: 58px;
    left: -10%;
    width: 120%;
    max-width: none;
  }

  .choices,
  .form,
  .success {
    width: 292px;
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }
}


/* =========================================================
   FINAL MOBILE RSVP COMPOSITION
   1) 花框完整显示，不缩放裁切
   2) 未选择：标题 + 选项整体垂直居中
   3) 选择后：表单从中心上下同时展开
   4) 控件进一步缩小，完全让出两侧水彩花草
   ========================================================= */
@media (max-width: 520px) {
  .rsvp-page {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    min-height: 0;
    overflow: hidden;
  }

  /* 花框按原比例完整铺在页面内 */
  .floral-frame {
    top: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: contain;
    opacity: .94;
  }

  /*
   * RSVP 区和花框占据同一块 2:3 画布。
   * flex 居中是关键：表单出现后，总高度增加，
   * 内容会同时向上和向下扩展。
   */
  .rsvp-section {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    min-height: 0;
    padding: 7% 8px 5%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .paper-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  h1 {
    margin: 0 0 15px;
    font-size: 21px;
    line-height: .92;
  }

  h1 span {
    margin-top: 7px;
    font-size: 10px;
    letter-spacing: .10em;
  }

  /* 控件只占中央约一半屏宽 */
  .choices,
  .form,
  .success {
    width: min(194px, 50vw);
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  .choices {
    gap: 5px;
  }

  .choice {
    min-height: 36px;
    padding: 4px 7px;
    gap: 6px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .50);
  }

  .choice .dot {
    width: 13px;
    height: 13px;
    border-width: 1.25px;
    box-shadow: inset 0 0 0 3px var(--paper);
  }

  .choice strong {
    font-size: 11px;
    letter-spacing: .02em;
  }

  .choice small {
    margin-top: 0;
    font-size: 7.7px;
    line-height: 1.12;
  }

  /* 表单出现时做轻微展开动画，不再滚动页面 */
  .form:not(.hidden) {
    animation: rsvpReveal .26s ease-out both;
  }

  @keyframes rsvpReveal {
    from {
      opacity: 0;
      transform: scale(.97);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  .form {
    margin-top: 10px;
    gap: 7px;
  }

  .field {
    gap: 3px;
  }

  .field > span {
    font-size: 10.5px;
  }

  .field em {
    font-size: 9px;
  }

  /*
   * iOS 输入字体继续保持 16px，防止聚焦自动放大。
   * 视觉尺寸主要靠宽度和 padding 缩小。
   */
  input,
  select,
  textarea {
    min-width: 0;
    padding: 4px 7px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.15;
    background: rgba(255, 255, 255, .53);
  }

  input,
  select {
    min-height: 31px;
  }

  textarea {
    min-height: 46px;
    max-height: 58px;
  }

  .submit {
    width: 100%;
    margin-top: 0;
    padding: 7px 10px;
    font-size: 11.5px;
    box-shadow: 0 5px 14px rgba(82, 107, 58, .13);
  }

  .success {
    padding: 11px 0 0;
  }

  .success-flower {
    width: 38px;
    height: 38px;
    margin-bottom: 6px;
    font-size: 19px;
  }

  .success h2 {
    font-size: 17px;
  }

  .success p {
    margin: 6px 0 10px;
    font-size: 10.5px;
  }

  .edit {
    padding: 6px 11px;
    font-size: 10.5px;
  }
}

/* 320~350px 的小屏再轻微收窄，但花框仍保持 100% 完整显示 */
@media (max-width: 350px) {
  .choices,
  .form,
  .success {
    width: 48vw;
  }

  h1 {
    font-size: 19px;
    margin-bottom: 12px;
  }

  .choice {
    min-height: 34px;
  }

  .choice strong {
    font-size: 10.5px;
  }

  .choice small {
    font-size: 7.2px;
  }
}


/* =========================================================
   FINAL DESKTOP RSVP COMPOSITION
   电脑端：控件保持原尺寸；未选择居中，选择后上下同时展开
   ========================================================= */
@media (min-width: 700px) {
  .rsvp-page {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    min-height: 0;
    overflow: hidden;
  }

  /* 桌面端花框完整显示，不再依赖内容高度撑开 */
  .floral-frame {
    top: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: contain;
    opacity: .94;
  }

  /*
   * RSVP 与花框共用同一个画布。
   * flex 垂直居中后，表单出现时整体高度增加，
   * 内容会自动向上、向下同时展开。
   */
  .rsvp-section {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    min-height: 0;
    padding: 5.5% 24px 4%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .paper-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 0 18px;
  }

  /* 保持电脑端现有尺寸，不再缩小 */
  h1 {
    margin: 0 0 24px;
    font-size: 30px;
  }

  h1 span {
    margin-top: 12px;
    font-size: 14px;
  }

  .choices,
  .form,
  .success {
    width: 318px;
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  .choices {
    gap: 8px;
  }

  .choice {
    min-height: 50px;
    padding: 8px 12px;
    gap: 9px;
    border-radius: 13px;
  }

  .choice .dot {
    width: 17px;
    height: 17px;
    border-width: 1.5px;
    box-shadow: inset 0 0 0 4px var(--paper);
  }

  .choice strong {
    font-size: 14px;
  }

  .choice small {
    font-size: 10.5px;
    line-height: 1.25;
  }

  .form {
    margin-top: 20px;
    gap: 13px;
  }

  .field {
    gap: 6px;
  }

  .field > span {
    font-size: 13px;
  }

  input,
  select,
  textarea {
    padding: 9px 11px;
    border-radius: 11px;
    font-size: 16px;
  }

  textarea {
    min-height: 78px;
  }

  .submit {
    padding: 12px 20px;
    font-size: 14px;
  }

  .success {
    padding-top: 20px;
  }

  /* 选择后只做淡入，不触发滚动 */
  .form:not(.hidden) {
    animation: desktopRsvpReveal .24s ease-out both;
  }

  @keyframes desktopRsvpReveal {
    from {
      opacity: 0;
      transform: scale(.985);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
}
