/* ==========================================================================
   CSS Variables & Base Theme
   ========================================================================== */
:root {
  --bg: #281018;
  --wine: #581C32;
  --wine-dark: #3a1522;
  --iv: #F5EEE3;
  --iv-light: #fbf6ee;
  --iv-dark: #eadfcd;
  --gold: #B69A62;
  --gold-light: #d6bc86;
  --bl: #D8A4AA;
  --sg: #78846B;
  color-scheme: dark;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  background: var(--bg);
  color: var(--iv);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

h1, h2, h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  margin: 0;
  line-height: 1.15;
}

[tabindex="-1"] {
  outline: none;
}

/* ==========================================================================
   Ambient Canvas: z-index 35 để các cánh hoa bay TRÊN các cảnh
   ========================================================================== */
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 35;
}

/* ==========================================================================
   General Scenes & Transitions
   ========================================================================== */
.sc {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  visibility: hidden;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 1s ease, transform 1.2s cubic-bezier(0.22, 0.8, 0.2, 1), visibility 0s 1s;
  z-index: 10;
}

.sc.on {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 1s ease, transform 1.2s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.eb {
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0;
  font-weight: 500;
}

.envb {
  background: none;
  border: 0;
  padding: 0;
  margin: 4px 0 6px;
  cursor: pointer;
  transition: transform 0.8s cubic-bezier(0.22, 0.8, 0.2, 1);
  touch-action: manipulation;
}

@media (hover: hover) {
  .envb:hover { transform: translateY(-5px); }
}

.envb:focus-visible, .x:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
}

.orn {
  position: absolute;
  width: 56px;
  height: 56px;
  color: var(--gold);
  opacity: 0.65;
  pointer-events: none;
}
.o0 { left: 16px; top: 16px; }
.o1 { right: 16px; top: 16px; transform: scaleX(-1); }
.o2 { left: 16px; bottom: 16px; transform: scaleY(-1); }
.o3 { right: 16px; bottom: 16px; transform: scale(-1); }

/* ==========================================================================
   Scene 1: Invitation & Opening Envelope (Two-phase realistic fold)
   ========================================================================== */
.s1 {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.frame {
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(182, 154, 98, 0.4);
  pointer-events: none;
}

.in1 {
  position: relative;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto;
  z-index: 5;
}

.s1.on .in1 > * {
  animation: rise 1.4s cubic-bezier(0.22, 0.8, 0.2, 1) var(--d, 0.3s) backwards;
}
.in1 > :nth-child(2) { --d: 0.6s; }
.in1 > :nth-child(3) { --d: 0.95s; }
.in1 > :nth-child(4) { --d: 1.25s; }
.s1.on .orn { animation: fade 2s 0.2s backwards; }

.in1 h1 {
  font-size: clamp(2.8rem, 8.5vw, 4.2rem);
  letter-spacing: -0.01em;
}

.in1 p {
  margin: 0;
  color: rgba(245, 238, 227, 0.86);
  font-size: 1.05rem;
}

.env {
  width: 250px;
  overflow: visible;
  display: block;
  filter: drop-shadow(0 15px 35px rgba(0,0,0,0.5));
}

.env .flap-front {
  transform-box: fill-box;
  transform-origin: 120px 24px;
  transform-origin: top;
  transform: scaleY(1);
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.env .flap-back {
  transform-box: fill-box;
  transform-origin: 120px 24px;
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 0.5s 0.35s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.env .pp {
  transition: transform 1.1s 0.45s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.env .seal {
  transition: opacity 0.35s ease;
}

.env .sp {
  fill: none;
  stroke: #B69A62;
  transform-box: fill-box;
  transform-origin: center;
  animation: sp 3.2s ease-out infinite;
}

@media (hover: hover) {
  .envb:hover .env:not(.open) .flap-front {
    transform: scaleY(0.85);
  }
}

.env.open .flap-front {
  transform: scaleY(0);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.05s 0.38s;
}

.env.open .flap-back {
  transform: scaleY(-1);
}

.env.open .pp {
  transform: translateY(-48px);
}

.env.open .seal {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Scene 2: Interactive Bouquet & Highlighted Spica Star
   ========================================================================== */
.s2 {
  justify-content: center;
  align-items: center;
}

.art {
  position: relative;
  width: min(1120px, 100%);
  margin: auto;
  background: radial-gradient(ellipse at 65% 45%, #fbf6ee, #F5EEE3 60%, #eadfcd);
  color: var(--wine);
  display: grid;
  grid-template-columns: 38% 62%;
  grid-template-rows: 1fr;
  grid-template-areas: "head bq";
  min-height: min(700px, 90vh);
  padding: 38px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  transition: all 0.5s ease;
}

.art::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(182, 154, 98, 0.55);
  pointer-events: none;
}

.art .eb {
  color: #7a6030;
}

.head {
  grid-area: head;
  align-self: center;
  padding: 0 20px 0 14px;
  transition: opacity 0.6s ease;
  z-index: 3;
}

.head h2 {
  font-size: clamp(2.3rem, 4vw, 3.4rem);
  margin-top: 14px;
  line-height: 1.15;
  color: var(--wine-dark);
}

/* Ngôi sao Spica nổi bật & Rực rỡ trên bầu trời hoa */
.spica-interactive {
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
}

.spica-halo {
  fill: url(#gw);
  opacity: 0.85;
  animation: spicaHaloPulse 3s ease-in-out infinite;
  transform-origin: center;
}

.spica-pulse-wave {
  fill: none;
  stroke: #f3c98b;
  stroke-width: 1.2;
  opacity: 0.6;
  animation: spicaWave 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
  transform-origin: center;
}

.spica-rays {
  animation: spicaRaySpin 12s linear infinite;
  transform-origin: center;
  filter: drop-shadow(0 0 6px rgba(243, 201, 139, 0.8));
}

.spica-rays-inner {
  animation: spicaRaySpin 8s linear infinite reverse;
  transform-origin: center;
}

.spica-text-group {
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.spica-interactive:hover .spica-text-group {
  transform: translate(0, 24px) scale(1.08);
}

@keyframes spicaHaloPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.35); opacity: 0.95; }
}

@keyframes spicaWave {
  0% { r: 8px; opacity: 0.8; stroke-width: 1.5; }
  100% { r: 28px; opacity: 0; stroke-width: 0.5; }
}

@keyframes spicaRaySpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.constellation-line {
  stroke: var(--gold);
  stroke-width: 0.9;
  stroke-dasharray: 2 3;
  opacity: 0.45;
  animation: constPulse 4s ease-in-out infinite;
}

@keyframes constPulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.6; }
}

.art.noting .head {
  opacity: 0.15;
}

.bq {
  grid-area: bq;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bq svg {
  width: 100%;
  max-height: max(380px, calc(100dvh - 150px));
  overflow: visible;
}

.s2.on .art { animation: artIn 1.4s cubic-bezier(0.22, 0.8, 0.2, 1) backwards; }
.s2.on .head { animation: rise 1.4s 0.5s cubic-bezier(0.22, 0.8, 0.2, 1) backwards; }
.s2.on .fo { animation: fade 1.6s 1.8s backwards; }
.s2.on .lf { animation: unfurl 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0s) backwards; }

.st path { stroke-dasharray: 1; }
.s2.on .st path { animation: draw 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s backwards; }
.s2.on .in { animation: bloom 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0s) backwards; }
.s2.on .rn, .s2.on .tp {
  animation: petal 1.3s cubic-bezier(0.2, 0.8, 0.2, 1) calc(var(--d, 0s) + var(--k, 0) * 0.1s) backwards;
}

.rn, .tp, .pt, .ct, .sm {
  transition: transform 1.1s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s;
}
.rn:nth-of-type(odd) { --o: 9deg; }
.rn:nth-of-type(even) { --o: -9deg; }
.tp { transform-origin: 0 26px; }
.tl { --o: -22deg; --x: -3px; --sc: 1.04; }
.tr { --o: 22deg; --x: 3px; --sc: 1.04; }
.tc { --o: 0deg; --y: -4px; --sc: 1.08; }
.ct { transform-origin: 0 0; }
.sm { transform-origin: 0 -30px; transform: scaleY(0.2); opacity: 0; }

.f.hv .rn, .f.press .rn, .f:focus-visible .rn, .f.sel .rn {
  transform: rotate(var(--o)) scale(var(--s));
  transition-delay: calc(var(--k) * 0.05s);
}
.f.hv .pt, .f.press .pt, .f:focus-visible .pt, .f.sel .pt { transform: translateY(var(--pt)); }
.f.hv .ct, .f.press .ct, .f:focus-visible .ct, .f.sel .ct { transform: scale(1.4); }
.f.hv .sm, .f.press .sm, .f:focus-visible .sm, .f.sel .sm {
  transform: none;
  opacity: 1;
  transition-delay: 0.25s;
}
.f.hv .tp, .f.press .tp, .f:focus-visible .tp, .f.sel .tp {
  transform: translate(var(--x, 0px), var(--y, 0px)) rotate(var(--o)) scale(var(--sc, 1.05));
  transition-delay: calc(var(--k) * 0.06s);
}

.f {
  cursor: pointer;
  outline: none;
  transition: opacity 0.5s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.f .lift {
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), filter 1s ease;
  filter: drop-shadow(0 3px 3px rgba(40, 16, 24, 0.3)) saturate(1) brightness(1);
}
.f.op .lift {
  filter: drop-shadow(0 2px 2px rgba(40, 16, 24, 0.25)) saturate(0.8) brightness(0.97);
}
.f.op.sel .lift {
  filter: drop-shadow(0 4px 6px rgba(40, 16, 24, 0.35)) saturate(1.1) brightness(1.02);
}
.f.hv .lift, .f.press .lift, .f:focus-visible .lift, .f.sel .lift {
  transform: translateY(-4px) scale(1.05);
}

.glow {
  fill: url(#gw);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.8s ease, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.f.hv .glow, .f.press .glow, .f:focus-visible .glow, .f.sel .glow {
  opacity: 1;
  transform: scale(1);
}

.gf { fill: url(#gw); opacity: 0; pointer-events: none; }
.f.glint .gf { animation: flash 1.1s ease-out; }

.fr {
  fill: none;
  stroke: var(--wine);
  stroke-width: 2;
  stroke-dasharray: 3 4;
  opacity: 0;
}
.f:focus-visible .fr { opacity: 1; }

.dot {
  fill: var(--gold);
  stroke: #fff;
  stroke-opacity: 0.6;
  stroke-width: 0.7;
  opacity: 0;
  transition: opacity 0.9s;
}
.f.op .dot { opacity: 1; }

.gbw { transition: opacity 0.9s; pointer-events: none; }
.gb { fill: url(#gw); opacity: 0; }
.s2.on .gb { animation: breathe 4.2s ease-in-out infinite; }
.f.op .gbw, .f.hv .gbw, .f.press .gbw, .f.sel .gbw { opacity: 0; }

@media (hover: hover) {
  .f:hover .rn { transform: rotate(var(--o)) scale(var(--s)); }
  .f:hover .tp { transform: translate(var(--x, 0px), var(--y, 0px)) rotate(var(--o)) scale(var(--sc, 1.05)); }
  .f:hover .lift { transform: translateY(-4px) scale(1.05); }
  .f:hover .glow { opacity: 1; transform: scale(1); }
  .f:hover .gbw { opacity: 0; }
}

.art.noting .f:not(.sel) { opacity: 0.65; }

.rg {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.6;
  opacity: 0;
  transition: opacity 1.2s;
}
.art.done .rg { opacity: 1; }

.final {
  position: absolute;
  right: 6%;
  bottom: 4%;
  width: 90px;
  text-align: center;
  visibility: hidden;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.4s 0.4s ease, transform 1.4s 0.4s cubic-bezier(0.22, 0.8, 0.2, 1), visibility 0s 1.8s;
  z-index: 10;
}
.art.done .final {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 1.4s 0.4s ease, transform 1.4s 0.4s cubic-bezier(0.22, 0.8, 0.2, 1), visibility 0s;
}
.final .env {
  width: 86px;
  margin: 0 auto;
}

/* Botanical Pressed Note Card */
.note {
  position: absolute;
  z-index: 20;
  left: 3%;
  top: 50%;
  width: min(350px, 34%);
  padding: 30px 26px 20px;
  background: var(--iv-light);
  color: #3a1522;
  border: 1px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 20px 48px rgba(40, 16, 24, 0.32);
  opacity: 0;
  visibility: hidden;
  transform: translate(-26px, -50%);
  transition: opacity 0.6s ease, transform 0.9s cubic-bezier(0.22, 0.8, 0.2, 1), visibility 0s 0.6s;
}

.note.open {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
  transition: opacity 0.6s ease, transform 0.9s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.note h3 {
  font-size: 1.8rem;
  color: var(--wine);
  margin: 0 0 10px;
  line-height: 1.2;
}

.note p {
  margin: 0;
  padding-bottom: 6px;
  font-size: 1rem;
  line-height: 1.65;
  color: #49202f;
}

.note.swap h3, .note.swap p {
  animation: rise 0.8s cubic-bezier(0.22, 0.8, 0.2, 1) backwards;
}
.note.swap p { animation-delay: 0.12s; }

.x {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  color: var(--wine);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  touch-action: manipulation;
}
.x:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* ==========================================================================
   Celestial Virgo Constellation Reveal Modal
   ========================================================================== */
.celestial-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.8s ease, visibility 0s 0.8s;
  touch-action: manipulation;
}

.celestial-modal.open {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.8s ease, visibility 0s;
}

.celestial-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(32, 12, 22, 0.94), rgba(18, 6, 12, 0.98));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.celestial-content {
  position: relative;
  max-width: 440px;
  width: 100%;
  background: rgba(45, 18, 28, 0.88);
  border: 1px solid rgba(182, 154, 98, 0.6);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  padding: 34px 24px 26px;
  text-align: center;
  color: var(--iv);
  transform: scale(0.94);
  transition: transform 0.8s cubic-bezier(0.22, 0.8, 0.2, 1);
  overflow: hidden;
}

.celestial-modal.open .celestial-content {
  transform: none;
}

.celestial-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  color: var(--gold-light);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: all 0.2s;
  z-index: 5;
}
.celestial-close:hover {
  opacity: 1;
  transform: scale(1.15);
}

.celestial-badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.celestial-title {
  font-size: clamp(2.2rem, 5.5vw, 3rem);
  color: var(--gold-light);
  margin: 2px 0 4px;
  letter-spacing: 0.02em;
}

.celestial-subtitle {
  font-size: 0.9rem;
  color: rgba(245, 238, 227, 0.75);
  margin: 0 0 14px;
}

.constellation-map-wrap {
  position: relative;
  width: min(260px, 75vw);
  height: min(260px, 75vw);
  margin: 0 auto 16px;
}

.virgo-big-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 12px rgba(243, 201, 139, 0.4));
}

.celestial-desc {
  font-size: 0.92rem;
  line-height: 1.65;
  color: rgba(245, 238, 227, 0.9);
  font-style: italic;
  margin: 0;
}

/* ==========================================================================
   Scene 3: Handwritten Letter, Compact Layout (Fits 100vh) & Pure Red Wax Seal
   ========================================================================== */
.s3 {
  justify-content: center;
  align-items: center;
}

.paper-wrapper {
  width: min(680px, 100%);
  margin: auto;
  padding: 6px 0;
}

.paper {
  position: relative;
  width: 100%;
  background: var(--iv);
  color: #3a1522;
  /* Bố cục cô đọng để vừa vặn trong 100vh / 100dvh */
  padding: clamp(20px, 3vh, 32px) clamp(18px, 4.5vw, 44px) clamp(16px, 2.5vh, 26px);
  border: 1px solid rgba(182, 154, 98, 0.7);
  border-radius: 4px;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  overflow: visible;
}

.s3.on .paper {
  animation: unfold 1.8s 0.3s cubic-bezier(0.22, 0.8, 0.2, 1) backwards;
}

/* Cành hoa ép khô góc thư */
.dried-flower-wrap {
  position: absolute;
  top: -8px;
  right: 20px;
  width: 46px;
  height: 82px;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(1px 2px 3px rgba(40, 16, 24, 0.25));
}

.washi-tape {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) rotate(-12deg);
  width: 38px;
  height: 12px;
  background: rgba(216, 164, 170, 0.55);
  border: 1px dashed rgba(182, 154, 98, 0.4);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  z-index: 6;
}

.paper .eb { color: #7a6030; }

.paper h2 {
  font-size: clamp(2.3rem, 5.8vw, 3.2rem);
  color: var(--wine);
  margin: 4px 0 10px;
}

.paper p:not(.eb) {
  font-size: clamp(1.15rem, 2.8vw, 1.45rem);
  line-height: 1.65;
  margin: 0 0 0.5em;
}

.paper h3 {
  font-size: clamp(1.5rem, 3.8vw, 1.95rem);
  color: var(--wine);
  text-align: center;
  margin: 16px 0 6px;
}

.paper .sign {
  font-size: clamp(1.3rem, 3.2vw, 1.65rem);
  text-align: right;
  color: var(--wine);
  margin-top: 8px;
}

.paper h2, .paper p:not(.eb), .paper h3 {
  font-family: 'Dancing Script', 'Playwrite VN', cursive;
  font-weight: 600;
}

.w {
  display: inline-block;
  -webkit-clip-path: inset(-0.5em 100% -0.5em -0.2em);
  clip-path: inset(-0.5em 100% -0.5em -0.2em);
}
.w.d {
  -webkit-clip-path: none;
  clip-path: none;
}

.pen {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  margin: -31px 0 0 -3px;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(1px 2px 3px rgba(40, 16, 24, 0.35));
  transition: opacity 0.4s ease;
}

/* Polaroid Card Memory (Gọn gàng vừa vặn trong trang) */
.polaroid-slot {
  display: flex;
  justify-content: center;
  margin: 10px auto 6px;
}

.polaroid-card {
  background: #ffffff;
  padding: 8px 8px 10px;
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(40, 16, 24, 0.2);
  transform: rotate(-2deg);
  max-width: 165px;
  width: 100%;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  user-select: none;
}
.polaroid-card:hover {
  transform: rotate(0deg) scale(1.04);
  box-shadow: 0 10px 25px rgba(40, 16, 24, 0.28);
}

.polaroid-img-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  background: #2a121d;
  overflow: hidden;
  border-radius: 1px;
}

.polaroid-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.polaroid-caption {
  font-family: 'Dancing Script', cursive;
  font-size: 0.95rem;
  color: #581C32;
  text-align: center;
  margin-top: 6px;
  font-weight: 600;
}

/* ==========================================================================
   Con Dấu Sáp Đỏ Thủ Công Cổ Điển (Không chữ hướng dẫn thừa)
   ========================================================================== */
.ps-container {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(182, 154, 98, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.ps-seal-btn {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  touch-action: manipulation;
}
.ps-seal-btn:hover {
  transform: scale(1.1);
}

.red-wax-seal {
  position: relative;
  width: 54px;
  height: 54px;
  filter: drop-shadow(0 4px 12px rgba(50, 10, 20, 0.45));
}

.wax-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ab243b, #7a1222 62%, #42060f);
  clip-path: polygon(
    50% 0%, 65% 3%, 78% 9%, 89% 19%, 96% 32%, 100% 48%, 97% 65%, 90% 79%,
    79% 91%, 63% 97%, 48% 100%, 32% 98%, 18% 91%, 8% 79%, 2% 64%, 0% 48%,
    3% 32%, 11% 18%, 23% 8%, 38% 2%
  );
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35), inset 0 -3px 6px rgba(0, 0, 0, 0.55);
}

.wax-inner {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #8e182c, #5e0b19 75%, #38050d);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wax-stamp-svg {
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.25));
}

/* ==========================================================================
   Scene 4: Trái Tim Hạt Phát Sáng Huyền Ảo (Pulsating Particle Heart)
   ========================================================================== */
.s4 {
  padding: 0;
  overflow: hidden;
  background: #000;
  align-items: center;
  justify-content: center;
}

#heart-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.heart-caption {
  position: absolute;
  bottom: max(32px, calc(20px + env(safe-area-inset-bottom, 0px)));
  left: 20px;
  right: 20px;
  text-align: center;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.8s 1.2s ease, transform 1.8s 1.2s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.s4.on .heart-caption {
  opacity: 1;
  transform: none;
}

.heart-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  color: #fce4a6;
  margin: 0 0 6px;
  text-shadow: 0 0 16px rgba(255, 100, 150, 0.7);
}

.heart-sub {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  color: rgba(245, 238, 227, 0.85);
  margin: 0;
  letter-spacing: 0.05em;
}

.heart-back-btn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: max(16px, env(safe-area-inset-left, 16px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--iv);
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  touch-action: manipulation;
}
.heart-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* ==========================================================================
   Keyframe Animations
   ========================================================================== */
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
}
@keyframes bloom {
  from { opacity: 0; transform: scale(0.55) rotate(-14deg); }
}
@keyframes petal {
  from { opacity: 0; transform: scale(0.3) rotate(-30deg); }
}
@keyframes fade {
  from { opacity: 0; }
}
@keyframes breathe {
  0%, 100% { opacity: 0; transform: scale(0.85); }
  50% { opacity: 0.75; transform: scale(1.08); }
}
@keyframes artIn {
  from { opacity: 0; transform: translateY(34px) scale(0.97); }
}
@keyframes unfurl {
  from { opacity: 0; transform: scale(0.05); }
}
@keyframes draw {
  from { stroke-dashoffset: 1; }
}
@keyframes flash {
  from { transform: scale(0.8); opacity: 1; }
  to { transform: scale(1.8); opacity: 0; }
}
@keyframes sp {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(2.4); opacity: 0; }
}
@keyframes unfold {
  from {
    opacity: 0;
    transform: translateY(46px) scale(0.96);
    clip-path: inset(-80px -80px 100% -80px);
  }
  to {
    clip-path: inset(-80px);
  }
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  .sc { padding: 10px; }

  .art {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "head" "bq";
    padding: 20px 14px 16px;
    min-height: 0;
    text-align: center;
  }

  .head {
    align-self: auto;
    padding: 0 4px 4px;
  }

  .head h2 {
    font-size: 2rem;
    margin-top: 4px;
  }

  .bq svg {
    max-height: 54vh;
  }

  .final {
    position: relative;
    right: auto;
    bottom: auto;
    width: 100%;
    margin-top: 6px;
  }

  .note {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    text-align: left;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 16px));
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
    z-index: 100;
  }

  .note.open {
    transform: translateY(0);
  }

  .polaroid-card {
    max-width: 145px;
  }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes rise { from { opacity: 0; } }
  @keyframes artIn { from { opacity: 0; } }
  @keyframes unfold { from { opacity: 0; } }
  @keyframes flash { from { opacity: 1; } to { opacity: 0; } }
  .sc, .sc.on { transform: none; }
  .s2.on .gb { animation: none; opacity: 0.35; }
  .env .sp { animation: none; opacity: 0; }
  .final { transform: none; }
  .note, .note.open { transform: translate(0, -50%); }
}

@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
  .note, .note.open { transform: none; }
}
