:root {
  --paper: #f3eadb;
  --paper-soft: #faf3e7;
  --oat: #e3d2b8;
  --kraft: #c9a77c;
  --cocoa: #6b4a3a;
  --cocoa-deep: #4b3128;
  --ink: #2b211d;
  --gold: #d9ae62;
  --gold-bright: #f2c477;
  --gold-deep: #a8752f;
  --sage: #9fae9a;
  --silver: #d9d5ce;
  --night: #050505;
  --warm-white: #fff4dc;
  --line: rgba(107, 74, 58, 0.16);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "Kaiti TC", serif;
  --shadow: 0 28px 80px rgba(61, 44, 33, 0.2);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  display: grid;
  place-items: center;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 10%, #fbf5eb 0, #eadcc8 52%, #d6c1a4 100%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.7s ease, color 0.7s ease;
}

body.theme-dark {
  background: #050505;
  color: var(--warm-white);
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(rgba(90, 64, 46, 0.18) 0.55px, transparent 0.8px),
    radial-gradient(rgba(255, 255, 255, 0.5) 0.6px, transparent 0.9px),
    repeating-linear-gradient(112deg, transparent 0 11px, rgba(107, 74, 58, 0.032) 11px 12px);
  background-size: 5px 5px, 7px 7px, 100% 100%;
  background-position: 0 0, 3px 4px, 0 0;
}

body.theme-dark .page-noise {
  opacity: 0.16;
  mix-blend-mode: soft-light;
}

.ambient-stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient-stars span {
  position: absolute;
  color: var(--gold-deep);
  font-size: 12px;
  opacity: 0.45;
  animation: twinkle 4s ease-in-out infinite;
}

.ambient-stars span:nth-child(1) { top: 8%; left: 5%; font-size: 18px; animation-delay: 0.4s; }
.ambient-stars span:nth-child(2) { top: 18%; left: 92%; font-size: 11px; animation-delay: 1.6s; }
.ambient-stars span:nth-child(3) { top: 72%; left: 4%; font-size: 9px; animation-delay: 2.4s; }
.ambient-stars span:nth-child(4) { top: 86%; left: 88%; font-size: 16px; animation-delay: 0.9s; }
.ambient-stars span:nth-child(5) { top: 38%; left: 96%; font-size: 8px; animation-delay: 3s; }
.ambient-stars span:nth-child(6) { top: 54%; left: 2%; font-size: 13px; animation-delay: 1.1s; }
.ambient-stars span:nth-child(7) { top: 4%; left: 70%; font-size: 9px; animation-delay: 2.1s; }
.ambient-stars span:nth-child(8) { top: 92%; left: 58%; font-size: 10px; animation-delay: 0.2s; }
.ambient-stars span:nth-child(9) { top: 26%; left: 76%; font-size: 7px; animation-delay: 2.8s; }
.ambient-stars span:nth-child(10) { top: 64%; left: 94%; font-size: 12px; animation-delay: 1.9s; }

/* stage */

.stage-shell {
  position: relative;
  z-index: 2;
  width: min(96vw, 1440px);
  height: min(90vh, 810px);
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(107, 74, 58, 0.14);
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.9), transparent 32%),
    radial-gradient(circle at 82% 76%, rgba(201, 167, 124, 0.14), transparent 40%),
    var(--paper);
  box-shadow: 0 36px 100px rgba(61, 44, 33, 0.26);
  transition: background 0.7s ease;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.32), transparent 28%, transparent 72%, rgba(201, 167, 124, 0.08)),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(107, 74, 58, 0.012) 3px 4px);
}

body.theme-dark .stage {
  background: #050505;
}

.topbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid rgba(107, 74, 58, 0.1);
  background: rgba(255, 250, 242, 0.48);
  color: var(--cocoa);
  backdrop-filter: blur(16px);
  transition: background 0.6s ease, color 0.6s ease, border-color 0.6s ease;
}

body.theme-dark .topbar {
  border-color: rgba(255, 244, 220, 0.1);
  background: rgba(5, 5, 5, 0.26);
  color: rgba(255, 244, 220, 0.82);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  color: var(--gold-deep);
  font-size: 16px;
}

body.theme-dark .brand-mark {
  color: var(--gold-bright);
}

.sound-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  opacity: 0.72;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0 0 8px;
  border: 1px solid rgba(107, 74, 58, 0.18);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
}

body.theme-dark .menu-toggle {
  border-color: rgba(255, 244, 220, 0.16);
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.34);
}

.sound-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
}

.sound-btn.is-muted {
  opacity: 0.4;
}

.scenes {
  position: absolute;
  inset: 0;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 82px 56px 56px;
  overflow-y: auto;
  scrollbar-width: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s ease;
}

.scene::-webkit-scrollbar {
  display: none;
}

.scene.is-active {
  z-index: 3;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

body.instant .scene,
body.instant .fireworks-title,
body.instant .fireworks-point,
body.instant .fireworks-credit,
body.instant .letter-line {
  transition: none !important;
}

.scene-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: center;
  gap: 5%;
  flex: 1;
  width: 100%;
  min-height: 0;
}

.copy-col {
  max-width: 470px;
  padding-left: 8px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold-deep);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.86;
}

.copy-col h1,
.copy-col h2 {
  margin: 0;
  color: var(--cocoa-deep);
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.28;
}

.copy-col h1 {
  font-size: clamp(38px, 4.5vw, 66px);
}

.copy-col h2 {
  font-size: clamp(31px, 3.5vw, 52px);
}

.copy-col h1 em {
  color: var(--gold-deep);
  font-style: italic;
  font-weight: 400;
}

.from {
  margin: 16px 0 28px;
  color: rgba(107, 74, 58, 0.73);
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.08em;
}

.sub {
  margin: 14px 0 28px;
  color: rgba(107, 74, 58, 0.66);
  font-family: var(--hand);
  font-size: 15px;
  letter-spacing: 0.03em;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid rgba(107, 74, 58, 0.24);
  border-radius: 999px;
  background: linear-gradient(135deg, #6e4e3b, #4d3228);
  color: #fff4dc;
  box-shadow: 0 14px 32px rgba(61, 44, 33, 0.2);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(61, 44, 33, 0.27);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.primary-btn.small {
  min-height: 40px;
  padding: 9px 17px;
  font-size: 11px;
}

.arrow {
  color: var(--gold-bright);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1;
}

.text-btn {
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--cocoa);
  font-size: 11px;
  text-decoration: underline;
  text-decoration-color: rgba(107, 74, 58, 0.24);
  text-underline-offset: 4px;
  cursor: pointer;
  opacity: 0.72;
}

/* gate */

.gate-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.hero-collage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.envelope-art {
  position: absolute;
  top: 13%;
  left: 18%;
  width: 46%;
  max-width: 340px;
  aspect-ratio: 0.82;
  overflow: hidden;
  border: 1px solid rgba(107, 74, 58, 0.16);
  border-radius: 5px 10px 7px 4px;
  background: #f8f0e3;
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
  animation: floatEnvelope 7s ease-in-out infinite;
}

.envelope-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: multiply;
  filter: sepia(0.06) contrast(1.03);
}

.envelope-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(145deg, rgba(242, 196, 119, 0.12), transparent 44%, rgba(107, 74, 58, 0.06));
}

.envelope-art.is-open {
  animation: none;
  opacity: 0;
  transform: translateY(-18px) rotate(1deg) scale(1.03);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.envelope-script {
  position: absolute;
  top: 31%;
  left: 50%;
  color: #8a5f3a;
  font-family: var(--serif);
  font-size: clamp(20px, 2.2vw, 31px);
  font-style: italic;
  line-height: 1.08;
  text-align: center;
  transform: translateX(-50%) rotate(-5deg);
  pointer-events: none;
}

.wax-seal {
  position: absolute;
  top: 61%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(79, 31, 21, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #b06b4f, #7d3f31 56%, #5b2a23);
  box-shadow: 0 8px 18px rgba(74, 31, 24, 0.28), inset 0 0 0 4px rgba(122, 56, 43, 0.32);
  color: #f9e7c5;
  font-family: var(--serif);
  font-size: 22px;
  transform: translate(-50%, -50%) rotate(-8deg);
}

.polaroid {
  position: absolute;
  top: 10%;
  right: 5%;
  width: 30%;
  max-width: 210px;
  margin: 0;
  padding: 8px 8px 23px;
  border: 1px solid rgba(107, 74, 58, 0.13);
  background: #fffaf0;
  box-shadow: 0 18px 40px rgba(61, 44, 33, 0.2);
  transform: rotate(7deg);
}

.polaroid::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 38%;
  width: 52px;
  height: 18px;
  background: rgba(217, 174, 98, 0.35);
  transform: rotate(-4deg);
}

.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  filter: saturate(0.9) sepia(0.05);
}

.polaroid figcaption {
  margin-top: 8px;
  color: rgba(107, 74, 58, 0.7);
  font-family: var(--hand);
  font-size: 11px;
  text-align: right;
}

.flower-card {
  position: absolute;
  bottom: 7%;
  left: 2%;
  width: 27%;
  max-width: 170px;
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(107, 74, 58, 0.13);
  background: #fffaf0;
  box-shadow: 0 14px 34px rgba(61, 44, 33, 0.16);
  transform: rotate(-8deg);
}

.flower-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.72) sepia(0.1);
}

.spark {
  position: absolute;
  color: var(--gold-deep);
  opacity: 0.55;
  animation: twinkle 3.8s ease-in-out infinite;
}

.spark.s1 { top: 7%; left: 10%; font-size: 20px; animation-delay: 0.3s; }
.spark.s2 { top: 18%; right: 8%; font-size: 13px; animation-delay: 1.5s; }
.spark.s3 { bottom: 13%; right: 18%; font-size: 18px; animation-delay: 2.3s; }
.spark.s4 { bottom: 28%; left: 8%; font-size: 11px; animation-delay: 0.8s; }

/* letter */

.scene-letter {
  align-items: center;
  justify-content: center;
  padding-top: 78px;
  padding-bottom: 50px;
  text-align: center;
}

.letter-heading h2 {
  margin: 0;
  color: var(--cocoa-deep);
  font-family: var(--serif);
  font-size: clamp(30px, 3.2vw, 46px);
  font-weight: 500;
  letter-spacing: 0.07em;
}

.letter-heading p:last-child {
  margin: 9px 0 0;
  color: rgba(107, 74, 58, 0.55);
  font-family: var(--hand);
  font-size: 12px;
}

.letter-paper {
  position: relative;
  flex: 0 0 auto;
  width: min(80%, 900px);
  height: 72%;
  min-height: 300px;
  margin-top: 16px;
  padding: 22px 44px 26px;
  overflow-y: auto;
  border: 1px solid rgba(107, 74, 58, 0.13);
  border-radius: 5px 10px 7px 4px;
  background:
    radial-gradient(circle at 15% 16%, rgba(255, 255, 255, 0.68), transparent 34%),
    radial-gradient(circle at 88% 84%, rgba(201, 167, 124, 0.1), transparent 40%),
    #fbf4e8;
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: rgba(107, 74, 58, 0.18) transparent;
  transform: rotate(-0.25deg);
  text-align: left;
}

.letter-paper::-webkit-scrollbar {
  width: 4px;
}

.letter-paper::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(107, 74, 58, 0.18);
}

.letter-ornament {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(107, 74, 58, 0.12);
  color: var(--gold-deep);
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  letter-spacing: 0.04em;
}

.ornament-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(201, 167, 124, 0.5), transparent);
}

.letter-content {
  padding: 15px 2px 0;
  color: #4a352b;
  font-family: var(--hand);
  font-size: clamp(13px, 0.95vw, 14.5px);
  line-height: 1.76;
  letter-spacing: 0.015em;
}

.letter-line {
  margin: 0 0 0.8em;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.letter-line.is-in {
  opacity: 1;
  transform: translateY(0);
}

.letter-line:last-child {
  margin-bottom: 0;
}

.highlight {
  color: #80532f;
  background: linear-gradient(transparent 64%, rgba(217, 174, 98, 0.3) 64%);
}

.letter-signature {
  position: relative;
  z-index: 2;
  margin-top: 14px;
  color: rgba(107, 74, 58, 0.9);
  font-family: var(--hand);
  font-size: 14px;
  text-align: right;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.letter-signature.is-in {
  opacity: 1;
  transform: translateY(0);
}

.letter-flower {
  position: absolute;
  right: 12px;
  bottom: 8px;
  width: 74px;
  height: 74px;
  overflow: hidden;
  border-radius: 50%;
  opacity: 0.12;
  transform: rotate(9deg);
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, #000 48%, transparent 72%);
  mask-image: radial-gradient(circle, #000 48%, transparent 72%);
}

.letter-flower img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: multiply;
}

.letter-next {
  position: relative;
  z-index: 3;
  margin-top: 15px;
}

/* cake and blow */

.scene-cake,
.scene-blow {
  background:
    radial-gradient(circle at 74% 42%, rgba(122, 74, 44, 0.44), transparent 34%),
    radial-gradient(circle at 50% 10%, #2d1b13 0, #150e0b 55%, #080606 100%);
  color: var(--warm-white);
}

.scene-cake .copy-col h2,
.scene-blow .copy-col h2 {
  color: var(--warm-white);
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.scene-cake .sub,
.scene-blow .sub {
  color: rgba(255, 244, 220, 0.62);
}

.scene-cake .eyebrow,
.scene-blow .eyebrow {
  color: var(--gold-bright);
}

.scene-cake .primary-btn,
.scene-blow .primary-btn {
  border-color: rgba(255, 244, 220, 0.16);
  background: linear-gradient(135deg, #dcb16a, #b9803c);
  color: #2b1b12;
}

.scene-cake .arrow,
.scene-blow .arrow {
  color: #4b2b16;
}

.cake-frame {
  position: relative;
  width: min(72%, 380px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255, 244, 220, 0.16);
  border-radius: 24px 18px 26px 16px;
  background: #180f0b;
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.58), 0 0 60px rgba(217, 174, 98, 0.1);
  transform: rotate(-0.7deg);
  animation: cakeFloat 6.4s ease-in-out infinite;
}

.cake-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.04) sepia(0.05);
  transform: scale(1.02);
}

.cake-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 52% 52%, transparent 40%, rgba(10, 7, 6, 0.42) 100%);
}

.cake-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.38);
}

.cake-glow {
  position: absolute;
  right: 8%;
  bottom: -7%;
  left: 8%;
  z-index: 2;
  height: 20%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(242, 196, 119, 0.34), transparent 70%);
  filter: blur(14px);
  pointer-events: none;
}

.cake-tag {
  position: absolute;
  right: 10%;
  bottom: 9%;
  z-index: 4;
  padding: 4px 10px;
  border: 1px solid rgba(255, 244, 220, 0.26);
  border-radius: 2px;
  background: rgba(42, 28, 23, 0.62);
  color: var(--warm-white);
  font-family: var(--hand);
  font-size: 10px;
  letter-spacing: 0.08em;
  transform: rotate(-4deg);
  backdrop-filter: blur(6px);
}

.candle-row {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.candle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 7px;
  height: var(--h);
  padding: 0;
  border: 0;
  border-radius: 4px 4px 3px 3px;
  background: linear-gradient(90deg, #e2c49b, #fff0cf 50%, #caa477);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}

.candle::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 1px;
  height: 6px;
  background: #4b3526;
  transform: translateX(-50%);
}

.flame {
  position: absolute;
  top: -21px;
  left: 50%;
  width: 13px;
  height: 21px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(ellipse at 50% 70%, #fff9d9 0 24%, #ffd47a 44%, #f39a3d 70%, transparent 74%);
  box-shadow: 0 0 16px rgba(242, 196, 119, 0.9), 0 0 34px rgba(242, 150, 64, 0.38);
  transform: translateX(-50%) scale(1);
  transform-origin: 50% 100%;
  animation: flameFlicker 1.45s ease-in-out infinite;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.flame::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 2px;
  left: 3px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 247, 210, 0.85);
  filter: blur(1px);
}

.candle.is-out .flame {
  opacity: 0;
  transform: translateX(-50%) scale(0.15);
}

.candle.is-out::after {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(214, 202, 190, 0.5);
  filter: blur(3px);
  animation: smokeRise 1.9s ease-out forwards;
}

.scene-blow.tap-mode .candle {
  cursor: pointer;
  pointer-events: auto;
}

.scene-blow.tap-mode .candle:hover .flame {
  transform: translateX(-50%) scale(1.18) rotate(5deg);
}

.blow-cake {
  width: min(64%, 340px);
}

.mic-card {
  width: min(100%, 430px);
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 244, 220, 0.15);
  border-radius: 15px;
  background: rgba(255, 244, 220, 0.07);
  color: var(--warm-white);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.mic-card strong {
  display: block;
  margin-bottom: 4px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.mic-card > p {
  margin: 0;
  color: rgba(255, 244, 220, 0.55);
  font-family: var(--hand);
  font-size: 10px;
}

.mic-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.mic-actions .text-btn {
  color: rgba(255, 244, 220, 0.72);
  text-decoration-color: rgba(255, 244, 220, 0.24);
}

.mic-meter {
  height: 3px;
  margin: 10px 0 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 244, 220, 0.12);
}

.mic-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright), #fff6d7);
  transition: width 0.08s linear;
}

.mic-status {
  min-height: 14px;
  margin: 0;
  color: rgba(255, 244, 220, 0.56) !important;
  font-family: var(--sans) !important;
  font-size: 9px !important;
  letter-spacing: 0.05em;
}

.tap-hint {
  margin-top: 12px;
  color: rgba(255, 244, 220, 0.64);
  font-size: 11px;
}

.tap-hint button {
  padding: 2px 3px;
  border: 0;
  background: none;
  color: var(--gold-bright);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* wish */

.scene-wish {
  background:
    radial-gradient(circle at 26% 22%, rgba(255, 255, 255, 0.66), transparent 34%),
    radial-gradient(circle at 82% 72%, rgba(201, 167, 124, 0.13), transparent 42%),
    var(--paper);
}

.wish-paper {
  position: relative;
  width: min(76%, 460px);
  padding: 24px 28px 22px;
  border: 1px solid rgba(107, 74, 58, 0.14);
  border-radius: 6px 11px 7px 5px;
  background: #fffaf0;
  box-shadow: var(--shadow);
  transform: rotate(0.4deg);
}

.wish-paper::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 42%;
  width: 56px;
  height: 17px;
  background: rgba(217, 174, 98, 0.36);
  transform: rotate(-4deg);
}

.wish-kicker {
  margin: 0;
  color: rgba(107, 74, 58, 0.46);
  font-family: var(--serif);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.wish-paper h3 {
  margin: 10px 0 12px;
  color: #5c3d33;
  font-family: var(--serif);
  font-size: 27px;
  font-style: italic;
  font-weight: 400;
}

.wish-paper textarea {
  width: 100%;
  min-height: 106px;
  padding: 6px 2px;
  resize: none;
  border: 0;
  outline: none;
  background:
    repeating-linear-gradient(transparent 0 27px, rgba(107, 74, 58, 0.13) 27px 28px);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 15px;
  line-height: 28px;
}

.wish-paper textarea::placeholder {
  color: rgba(107, 74, 58, 0.3);
}

.wish-meta {
  color: rgba(107, 74, 58, 0.4);
  font-size: 9px;
  text-align: right;
}

.wish-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 9px 0 13px;
}

.wish-chip {
  padding: 5px 9px;
  border: 1px solid rgba(107, 74, 58, 0.18);
  border-radius: 999px;
  background: transparent;
  color: rgba(107, 74, 58, 0.72);
  font-size: 10px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.wish-chip.is-active {
  border-color: var(--cocoa);
  background: var(--cocoa);
  color: var(--paper);
}

.wish-paper .primary-btn {
  width: 100%;
  margin-top: 2px;
}

.wish-paper .text-btn {
  display: block;
  margin: 3px auto 0;
}

.privacy-note {
  margin: 2px 0 0;
  color: rgba(107, 74, 58, 0.35);
  font-size: 8px;
  text-align: center;
}

.wish-star {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  color: var(--gold);
  font-size: 28px;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 20px rgba(217, 174, 98, 0.9);
}

.wish-star.is-flying {
  animation: starFly 1.35s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

/* fireworks */

.scene-fireworks {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: block;
  padding: 0;
  overflow: hidden;
  background: #050505;
}

.scene-fireworks.is-active {
  z-index: 20;
}

#fireworksCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.fireworks-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 38%, transparent 0 34%, rgba(0, 0, 0, 0.18) 68%, rgba(0, 0, 0, 0.56) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 20%, transparent 78%, rgba(0, 0, 0, 0.42));
}

.fireworks-water {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  height: 24%;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent, rgba(217, 174, 98, 0.04) 42%, rgba(0, 0, 0, 0.72)),
    repeating-linear-gradient(176deg, transparent 0 18px, rgba(255, 244, 220, 0.03) 18px 19px, transparent 19px 38px);
  filter: blur(0.4px);
  opacity: 0.8;
}

.fireworks-crowd {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  height: 13%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.92) 0 26%, rgba(0, 0, 0, 0.58) 48%, transparent 72%),
    radial-gradient(circle at 14% 86%, rgba(255, 226, 170, 0.65) 0 1px, transparent 2px),
    radial-gradient(circle at 32% 92%, rgba(255, 226, 170, 0.42) 0 1px, transparent 2px),
    radial-gradient(circle at 69% 88%, rgba(255, 226, 170, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 94%, rgba(255, 226, 170, 0.38) 0 1px, transparent 2px);
  background-size: 100% 100%, 120px 90px, 150px 110px, 170px 100px, 130px 120px;
  opacity: 0.66;
}

.fireworks-ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  max-width: 1040px;
  margin: 0 auto;
  pointer-events: none;
}

.fireworks-title {
  position: absolute;
  top: 15%;
  left: 50%;
  margin: 0;
  color: var(--warm-white);
  font-family: var(--serif);
  font-size: clamp(32px, 4.2vw, 58px);
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 0 30px rgba(217, 174, 98, 0.3), 0 2px 12px rgba(0, 0, 0, 0.86);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.85s ease, transform 0.85s ease;
  white-space: nowrap;
}

.fireworks-title.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.fireworks-point {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 58%;
  max-width: 650px;
  min-height: 82px;
  margin: 0;
  padding: 12px 22px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3), transparent 72%);
  color: rgba(255, 244, 220, 0.96);
  font-family: var(--hand);
  font-size: clamp(19px, 2.1vw, 28px);
  line-height: 1.8;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.92);
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.97);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fireworks-point::before {
  content: "·";
  margin-right: 9px;
  color: var(--gold-bright);
  font-size: 1.3em;
  text-shadow: 0 0 12px rgba(217, 174, 98, 0.9);
  vertical-align: 1px;
}

.fireworks-point.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.fireworks-credit {
  position: absolute;
  right: 5%;
  bottom: 13%;
  margin: 0;
  color: rgba(255, 244, 220, 0.68);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.14em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fireworks-credit.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* progress */

.progress-dock {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  padding: 10px 32px 11px;
  background: linear-gradient(180deg, transparent, rgba(243, 234, 219, 0.92));
  color: var(--cocoa);
  pointer-events: none;
  transition: color 0.5s ease, background 0.5s ease;
}

body.theme-dark .progress-dock {
  background: linear-gradient(180deg, transparent, rgba(5, 5, 5, 0.94));
  color: rgba(255, 244, 220, 0.7);
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 8px;
  letter-spacing: 0.16em;
  opacity: 0.62;
}

.progress-track {
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(107, 74, 58, 0.16);
}

body.theme-dark .progress-track {
  background: rgba(255, 244, 220, 0.16);
}

.progress-fill {
  display: block;
  width: 6%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright), #fff3cf);
  transition: width 0.7s ease;
}

/* menu and toast */

.menu-panel {
  position: fixed;
  top: 82px;
  right: max(18px, calc((100vw - 1440px) / 2 + 18px));
  z-index: 80;
  width: 224px;
  padding: 7px;
  border: 1px solid rgba(107, 74, 58, 0.14);
  border-radius: 14px;
  background: rgba(250, 243, 232, 0.96);
  box-shadow: 0 22px 56px rgba(42, 33, 29, 0.2);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.menu-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.menu-panel button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--cocoa);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.menu-link {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--cocoa);
  font-size: 12px;
  text-align: left;
  text-decoration: none;
}

.menu-link:hover {
  background: rgba(107, 74, 58, 0.075);
}

.menu-panel button:hover {
  background: rgba(107, 74, 58, 0.075);
}

.menu-panel .menu-danger {
  color: #8b4f3d;
}

.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  z-index: 90;
  max-width: min(86vw, 360px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(42, 33, 29, 0.9);
  color: var(--warm-white);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

/* animations */

@keyframes twinkle {
  0%, 100% { opacity: 0.24; transform: scale(0.88); }
  50% { opacity: 0.76; transform: scale(1.12); }
}

@keyframes floatEnvelope {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7px) rotate(-1.8deg); }
}

@keyframes cakeFloat {
  0%, 100% { transform: translateY(0) rotate(-0.7deg); }
  50% { transform: translateY(-6px) rotate(0.1deg); }
}

@keyframes flameFlicker {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(-1deg); }
  28% { transform: translateX(-50%) scale(0.96, 1.06) rotate(2deg); }
  55% { transform: translateX(-50%) scale(1.04, 0.96) rotate(-2deg); }
  78% { transform: translateX(-50%) scale(0.98, 1.03) rotate(1deg); }
}

@keyframes smokeRise {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  18% { opacity: 0.6; }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1.5); }
}

@keyframes starFly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(0deg); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(18vw, -28vh) scale(1.15) rotate(140deg); }
}

/* portrait / narrow fallback */

@media (max-aspect-ratio: 1 / 1), (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .stage-shell {
    width: 96vw;
    height: 94dvh;
  }

  .stage {
    border-radius: 18px;
  }

  .topbar {
    height: 58px;
    padding: 0 16px;
  }

  .brand {
    font-size: 11px;
  }

  .sound-btn {
    font-size: 10px;
  }

  .scene {
    padding: 72px 20px 48px;
  }

  .scene-grid,
  .gate-grid {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 12px;
  }

  .copy-col {
    max-width: 100%;
    padding-left: 0;
    text-align: center;
  }

  .copy-col h1 {
    font-size: clamp(32px, 9vw, 46px);
  }

  .copy-col h2 {
    font-size: clamp(27px, 7.5vw, 38px);
  }

  .from {
    margin: 10px 0 18px;
  }

  .sub {
    margin: 8px 0 16px;
  }

  .hero-collage {
    min-height: 300px;
    height: 42vh;
  }

  .envelope-art {
    top: 5%;
    left: 25%;
    width: 46%;
    max-width: 240px;
  }

  .polaroid {
    top: 2%;
    right: 2%;
    width: 29%;
  }

  .flower-card {
    bottom: 2%;
    left: 2%;
    width: 26%;
  }

  .letter-heading h2 {
    font-size: clamp(25px, 7vw, 34px);
  }

  .letter-paper {
    width: 100%;
    height: auto;
    max-height: 52vh;
    min-height: 0;
    padding: 20px 20px 24px;
  }

  .letter-ornament {
    font-size: 18px;
  }

  .letter-content {
    font-size: 14px;
    line-height: 1.85;
  }

  .letter-next {
    margin-top: 12px;
  }

  .cake-frame {
    width: min(64vw, 280px);
  }

  .blow-cake {
    width: min(56vw, 240px);
  }

  .mic-card {
    margin-right: auto;
    margin-left: auto;
    text-align: left;
  }

  .mic-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .wish-paper {
    width: 100%;
    padding: 20px 20px 18px;
  }

  .wish-paper h3 {
    font-size: 24px;
  }

  .fireworks-title {
    top: 17%;
    font-size: clamp(28px, 8vw, 42px);
  }

  .fireworks-point {
    top: 46%;
    width: 82%;
    font-size: clamp(17px, 4.6vw, 22px);
  }

  .fireworks-credit {
    right: 7%;
    bottom: 15%;
  }

  .progress-dock {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-height: 700px) and (min-aspect-ratio: 1 / 1) {
  .scene {
    padding-top: 72px;
    padding-bottom: 46px;
  }

  .copy-col h1 {
    font-size: clamp(34px, 3.9vw, 52px);
  }

  .copy-col h2 {
    font-size: clamp(28px, 3.1vw, 42px);
  }

  .hero-collage {
    min-height: 330px;
  }

  .envelope-art {
    max-width: 285px;
  }

  .polaroid {
    max-width: 175px;
  }

  .flower-card {
    max-width: 140px;
  }

  .letter-paper {
    height: 66%;
  }

  .cake-frame {
    width: min(58%, 310px);
  }

  .blow-cake {
    width: min(50%, 280px);
  }

  .mic-card {
    padding: 10px 13px;
  }

  .mic-actions {
    margin-top: 7px;
  }
}

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

  .letter-line,
  .letter-signature {
    opacity: 1;
    transform: none;
  }
}
