/* ==========================================================================
   CINEMATIC LOVE — style.css
   Bảng màu: xanh đêm · tím than · hồng pastel · vàng hoàng hôn
   ========================================================================== */

:root {
  --night: #0b0e2a;
  --night-2: #141a46;
  --indigo: #2a1b4a;
  --plum: #3d2160;
  --pink: #f7b6c8;
  --pink-2: #e98fb0;
  --gold: #ffcf8a;
  --gold-2: #f6a86b;
  --cream: #fff6ec;
  --text: #fdf4ff;
  --muted: rgba(253, 244, 255, 0.68);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-line: rgba(255, 255, 255, 0.16);

  --f-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-title: "Playfair Display", Georgia, "Times New Roman", serif;
  --f-hand: "Dancing Script", "Segoe Script", "Brush Script MT", cursive;

  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --scene-dur: 1100ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

.is-hidden { display: none !important; }
[tabindex="-1"]:focus { outline: none; }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.muted { color: var(--muted); }

/* --------------------------------------------------------------------------
   NỀN TRỜI
   -------------------------------------------------------------------------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.sky__layer { position: absolute; inset: 0; transition: opacity 1.8s ease; }

.sky__layer--night {
  background:
    radial-gradient(120% 70% at 50% 110%, rgba(246, 168, 107, 0.28), transparent 60%),
    radial-gradient(90% 60% at 80% 0%, rgba(61, 33, 96, 0.9), transparent 70%),
    linear-gradient(180deg, #070923 0%, #10164a 45%, #2a1b4a 80%, #4a2a5e 100%);
}
.sky__layer--dusk {
  opacity: 0;
  background:
    radial-gradient(110% 60% at 50% 105%, rgba(255, 207, 138, 0.45), transparent 60%),
    radial-gradient(80% 55% at 20% 10%, rgba(233, 143, 176, 0.25), transparent 70%),
    linear-gradient(180deg, #0c0f33 0%, #2a1b4a 45%, #6b3270 75%, #c2627a 100%);
}
.sky__layer--warm {
  opacity: 0;
  background:
    radial-gradient(90% 60% at 50% 100%, rgba(255, 207, 138, 0.55), transparent 65%),
    radial-gradient(60% 40% at 50% 30%, rgba(255, 180, 120, 0.18), transparent 70%),
    linear-gradient(180deg, #160f2e 0%, #3a1f3f 45%, #6d3a3f 78%, #b06a45 100%);
}
body[data-mood="dusk"] .sky__layer--dusk { opacity: 1; }
body[data-mood="warm"] .sky__layer--warm { opacity: 1; }

/* Thành phố về đêm (SVG nhẹ, không cần ảnh) */
.sky__city {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26vh; min-height: 140px;
  opacity: 0.55;
  background: bottom center / auto 100% repeat-x url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 160'%3E%3Cg fill='%23070a1f'%3E%3Crect x='0' y='90' width='46' height='70'/%3E%3Crect x='40' y='60' width='38' height='100'/%3E%3Crect x='74' y='100' width='52' height='60'/%3E%3Crect x='120' y='40' width='30' height='120'/%3E%3Crect x='146' y='80' width='60' height='80'/%3E%3Crect x='200' y='55' width='40' height='105'/%3E%3Crect x='236' y='105' width='56' height='55'/%3E%3Crect x='288' y='30' width='34' height='130'/%3E%3Crect x='318' y='85' width='50' height='75'/%3E%3Crect x='364' y='65' width='42' height='95'/%3E%3Crect x='402' y='110' width='60' height='50'/%3E%3Crect x='456' y='50' width='36' height='110'/%3E%3Crect x='488' y='92' width='58' height='68'/%3E%3Crect x='540' y='70' width='60' height='90'/%3E%3C/g%3E%3Cg fill='%23ffcf8a' opacity='.75'%3E%3Crect x='50' y='72' width='4' height='5'/%3E%3Crect x='62' y='90' width='4' height='5'/%3E%3Crect x='128' y='54' width='4' height='5'/%3E%3Crect x='136' y='80' width='4' height='5'/%3E%3Crect x='160' y='96' width='4' height='5'/%3E%3Crect x='212' y='70' width='4' height='5'/%3E%3Crect x='224' y='100' width='4' height='5'/%3E%3Crect x='298' y='46' width='4' height='5'/%3E%3Crect x='306' y='76' width='4' height='5'/%3E%3Crect x='300' y='110' width='4' height='5'/%3E%3Crect x='330' y='100' width='4' height='5'/%3E%3Crect x='376' y='80' width='4' height='5'/%3E%3Crect x='388' y='112' width='4' height='5'/%3E%3Crect x='466' y='66' width='4' height='5'/%3E%3Crect x='474' y='96' width='4' height='5'/%3E%3Crect x='500' y='108' width='4' height='5'/%3E%3Crect x='556' y='86' width='4' height='5'/%3E%3Crect x='572' y='116' width='4' height='5'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: linear-gradient(to top, #000 55%, transparent);
          mask-image: linear-gradient(to top, #000 55%, transparent);
  transition: opacity 1.6s ease;
}
body[data-mood="warm"] .sky__city { opacity: 0.25; }

#stars { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Bokeh */
.bokeh span {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, var(--c, rgba(247, 182, 200, 0.55)) 0%, transparent 70%);
  filter: blur(1px);
  opacity: 0;
  animation: bokeh-drift var(--d, 18s) ease-in-out var(--delay, 0s) infinite;
  will-change: transform, opacity;
}
@keyframes bokeh-drift {
  0%   { transform: translate3d(0, 0, 0) scale(0.9); opacity: 0; }
  20%  { opacity: var(--o, 0.5); }
  50%  { transform: translate3d(var(--dx, 20px), var(--dy, -30px), 0) scale(1.08); }
  80%  { opacity: var(--o, 0.5); }
  100% { transform: translate3d(0, 0, 0) scale(0.9); opacity: 0; }
}

/* Trái tim bay */
.hearts .float-heart {
  position: absolute; bottom: -40px;
  font-size: var(--s, 18px);
  color: var(--c, var(--pink));
  text-shadow: 0 0 12px currentColor;
  opacity: 0;
  animation: heart-rise var(--d, 9s) linear forwards;
  will-change: transform, opacity;
}
@keyframes heart-rise {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: var(--o, 0.8); }
  50%  { transform: translate3d(var(--sway, 30px), -55vh, 0) rotate(12deg); }
  90%  { opacity: var(--o, 0.8); }
  100% { transform: translate3d(calc(var(--sway, 30px) * -0.5), -112vh, 0) rotate(-8deg); opacity: 0; }
}

#fireworks {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 30; pointer-events: none;
}

/* --------------------------------------------------------------------------
   CẢNH (SCENE) & CHUYỂN CẢNH
   -------------------------------------------------------------------------- */
main { position: relative; z-index: 10; height: 100%; }

.scene {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: calc(72px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0; visibility: hidden;
  transform: scale(1.04);
  filter: blur(8px);
  transition:
    opacity var(--scene-dur) var(--ease),
    transform var(--scene-dur) var(--ease),
    filter var(--scene-dur) var(--ease),
    visibility 0s linear var(--scene-dur);
}
.scene.is-active {
  opacity: 1; visibility: visible; transform: none; filter: none;
  transition:
    opacity var(--scene-dur) var(--ease) 250ms,
    transform var(--scene-dur) var(--ease) 250ms,
    filter var(--scene-dur) var(--ease) 250ms,
    visibility 0s;
}
.scene.is-leaving { transform: scale(0.96); }

.scene__inner { width: 100%; max-width: 560px; margin: auto; }
.scene__head { text-align: center; margin-bottom: 18px; }
.scene__head h2 { margin: 0 0 4px; }

h1, h2 { font-family: var(--f-title); font-weight: 700; letter-spacing: 0.01em; }
h2 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: 0 0 18px; }

/* Hiện dần (dùng cho màn 1) */
.reveal { opacity: 0; transform: translateY(16px); }
.is-active .reveal { animation: rise 1.1s var(--ease) forwards; }
.is-active .reveal:nth-of-type(1) { animation-delay: 0.6s; }
.is-active .intro__line2 { animation-delay: 1.9s; }
.is-active #btnOpen { animation-delay: 3s; }
.is-active .intro__sound { animation-delay: 3.6s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   NÚT BẤM
   -------------------------------------------------------------------------- */
.btn {
  --bg: var(--glass);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 14px 30px;
  border: 1px solid var(--glass-line); border-radius: 999px;
  background: var(--bg);
  font-weight: 500; font-size: 1.02rem; letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease), box-shadow 0.3s ease, background 0.3s ease, opacity 0.4s ease;
  touch-action: manipulation;
  user-select: none;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.95); }
.btn:focus-visible, .icon-btn:focus-visible, .play-btn:focus-visible, .music-fab:focus-visible, .album__nav:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px;
}

.btn--primary {
  --bg: linear-gradient(135deg, #f7b6c8 0%, #e98fb0 45%, #f6a86b 100%);
  border-color: rgba(255, 255, 255, 0.35);
  color: #2a0f2a; font-weight: 600;
  box-shadow: 0 8px 30px rgba(233, 143, 176, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn--primary::after {
  content: ""; position: absolute; inset: -6px; border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(247, 182, 200, 0.55);
  animation: pulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(247, 182, 200, 0.5); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(247, 182, 200, 0); }
}
.btn--primary:hover { box-shadow: 0 12px 38px rgba(233, 143, 176, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5); }

.btn--ghost { --bg: rgba(255, 255, 255, 0.07); }
.btn--ghost:hover { --bg: rgba(255, 255, 255, 0.14); }

.btn--lg { min-height: 58px; padding: 16px 34px; font-size: 1.08rem; }

.btn--link {
  border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  color: var(--pink); text-decoration: underline; text-underline-offset: 4px;
  min-height: 44px; padding: 8px 12px; font-size: 0.98rem;
}

.btn--warm {
  --bg: linear-gradient(135deg, #ffe2b4, #ffcf8a 50%, #f6a86b);
  color: #3a1f12; font-weight: 600; border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 30px rgba(255, 190, 120, 0.4);
}

.btn.is-entering { animation: rise 0.9s var(--ease) both; }

/* Hiệu ứng gợn sóng khi chạm */
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, 0.5);
  transform: scale(0); animation: ripple 0.6s ease-out forwards;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
.btn { overflow: hidden; }
.btn--primary { overflow: visible; }
.btn--primary .ripple-wrap { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }

/* --------------------------------------------------------------------------
   NÚT NHẠC NỔI
   -------------------------------------------------------------------------- */
.music-fab {
  position: fixed; z-index: 40;
  top: calc(16px + var(--safe-top)); right: 16px;
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--glass-line);
  background: rgba(20, 16, 50, 0.55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease), background 0.3s;
}
.music-fab:active { transform: scale(0.92); }
.music-fab__bars { display: none; gap: 3px; align-items: flex-end; height: 18px; }
.music-fab__bars i { width: 3px; background: var(--pink); border-radius: 2px; animation: bar 0.9s ease-in-out infinite; }
.music-fab__bars i:nth-child(2) { animation-delay: 0.2s; }
.music-fab__bars i:nth-child(3) { animation-delay: 0.4s; }
@keyframes bar { 0%, 100% { height: 5px; } 50% { height: 18px; } }
.music-fab.is-playing { background: rgba(233, 143, 176, 0.25); }
.music-fab.is-playing .music-fab__icon { display: none; }
.music-fab.is-playing .music-fab__bars { display: flex; }
/* Trình duyệt chặn tự phát: nút nhấp nháy + dòng nhắc "Chạm để bật nhạc" */
.music-fab.is-waiting::before {
  content: ""; position: absolute; inset: -1px; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(247, 182, 200, 0.6);
  animation: pulse 1.8s ease-out infinite;
  pointer-events: none;
}
.music-fab.is-waiting::after {
  content: attr(data-hint);
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; padding: 6px 12px; border-radius: 999px;
  font-size: 0.85rem; color: var(--text);
  background: rgba(20, 16, 50, 0.75); border: 1px solid var(--glass-line);
  pointer-events: none;
  animation: hint-in 0.6s ease both;
}
@keyframes hint-in { from { opacity: 0; } }
.music-fab__icon { position: relative; }
.music-fab:not(.is-playing) .music-fab__icon::after {
  content: ""; position: absolute; left: -3px; top: 50%; width: 28px; height: 2px;
  background: currentColor; transform: rotate(-45deg); opacity: 0.8;
}

/* --------------------------------------------------------------------------
   MÀN 1 — LỜI MỜI
   -------------------------------------------------------------------------- */
.glow-heart {
  font-size: 64px; line-height: 1; color: var(--pink);
  text-shadow: 0 0 20px rgba(247, 182, 200, 0.9), 0 0 60px rgba(233, 143, 176, 0.7);
  animation: beat 1.6s ease-in-out infinite;
  margin-bottom: 28px;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.14); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
}
.intro__line1 {
  font-family: var(--f-title); font-style: italic;
  font-size: clamp(1.45rem, 6.2vw, 2.3rem); line-height: 1.35;
  margin: 0 0 14px; text-wrap: balance;
}
.intro__line2 { font-size: clamp(1.05rem, 4.4vw, 1.25rem); color: var(--muted); margin: 0 0 36px; text-wrap: balance; }
.intro__sound { color: var(--muted); font-size: 0.9rem; margin: 18px 0 0; }
.intro__sound:empty { display: none; }

/* --------------------------------------------------------------------------
   MÀN 2 — BỨC THƯ
   -------------------------------------------------------------------------- */
.letter-stage { display: grid; place-items: center; width: 100%; min-height: 300px; }
.letter-stage > * { grid-area: 1 / 1; }

.envelope {
  position: relative; width: min(82vw, 340px); aspect-ratio: 1.55;
  perspective: 900px;
  transition: transform 0.9s var(--ease), opacity 0.7s ease;
  cursor: pointer;
  animation: float-y 3.4s ease-in-out infinite;
}
@keyframes float-y { 50% { transform: translateY(-8px); } }
.envelope__back, .envelope__front, .envelope__flap, .envelope__paper { position: absolute; inset: 0; border-radius: 10px; }
.envelope__back { background: linear-gradient(160deg, #f4d9c4, #e6b9a6); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); }
.envelope__paper {
  inset: 8% 7% 10%; background: var(--cream); border-radius: 6px;
  transition: transform 0.8s var(--ease) 0.35s;
}
.envelope__front {
  background:
    linear-gradient(to top right, #f0cbb5 50%, transparent 50.5%) left bottom / 50.5% 100% no-repeat,
    linear-gradient(to top left, #ecc2ab 50%, transparent 50.5%) right bottom / 50.5% 100% no-repeat,
    linear-gradient(to top, #e8b9a3 0%, #f2cfba 100%) bottom / 100% 55% no-repeat;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}
.envelope__flap {
  height: 58%; background: linear-gradient(180deg, #f7dfcc, #e9bfa9);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s var(--ease);
  z-index: 3;
}
.envelope__seal {
  position: absolute; left: 50%; top: 52%; z-index: 4;
  width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 20px;
  background: radial-gradient(circle at 35% 30%, #f28aa9, #b8466b);
  box-shadow: 0 4px 12px rgba(120, 20, 60, 0.45);
  transition: transform 0.4s var(--ease), opacity 0.4s;
}
.envelope.is-open { animation: none; }
.envelope.is-open .envelope__seal { transform: scale(0); opacity: 0; }
.envelope.is-open .envelope__flap { transform: rotateX(180deg); z-index: 0; }
.envelope.is-open .envelope__paper { transform: translateY(-45%); }
.envelope.is-gone { opacity: 0; transform: translateY(40px) scale(0.85); pointer-events: none; }

.letter {
  width: min(100%, 520px);
  max-height: min(64vh, 620px); overflow-y: auto;
  padding: 30px 26px 26px;
  border-radius: 14px;
  color: #3b2338;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 207, 138, 0.25), transparent 60%),
    repeating-linear-gradient(transparent 0 33px, rgba(233, 143, 176, 0.13) 33px 34px),
    var(--cream);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(233, 143, 176, 0.25);
  opacity: 0; transform: translateY(30px) scale(0.92); visibility: hidden;
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), visibility 0s 0.9s;
  text-align: left;
  scrollbar-width: thin;
}
.letter.is-shown { opacity: 1; transform: none; visibility: visible; transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.letter:focus { outline: none; }
.letter__greeting {
  font-family: var(--f-hand); font-weight: 700;
  font-size: clamp(1.55rem, 6vw, 1.9rem); line-height: 1.3; margin: 0 0 12px; color: #a33a64;
  min-height: 1.3em;
}
.letter__body p {
  font-family: var(--f-hand); font-weight: 500;
  font-size: clamp(1.28rem, 5vw, 1.5rem); line-height: 1.45; margin: 0 0 12px;
}
.letter__sign {
  font-family: var(--f-hand); font-weight: 700; font-size: 1.5rem;
  text-align: right; margin: 8px 0 0; color: #a33a64;
  opacity: 0; transition: opacity 0.8s ease;
}
.letter__sign.is-shown { opacity: 1; }
.caret { display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: #a33a64; animation: blink 0.8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hint { color: var(--muted); font-size: 0.88rem; margin: 16px 0 6px; min-height: 1.4em; transition: opacity 0.4s; }
.scene--letter .btn { margin-top: 10px; }

/* --------------------------------------------------------------------------
   MÀN 3 — CÂU HỎI
   -------------------------------------------------------------------------- */
.scene--question .scene__inner { position: relative; }
.ring {
  position: absolute; left: 50%; top: 42%; width: 340px; height: 340px; margin: -170px 0 0 -170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(247, 182, 200, 0.28), rgba(233, 143, 176, 0.08) 45%, transparent 70%);
  animation: breathe 4s ease-in-out infinite;
  pointer-events: none; z-index: -1;
}
@keyframes breathe { 50% { transform: scale(1.12); opacity: 0.75; } }
.question__title {
  font-size: clamp(1.9rem, 8.4vw, 3.2rem); line-height: 1.22;
  margin: 0 0 36px; text-wrap: balance;
  background: linear-gradient(120deg, #fff 0%, #ffe0ea 35%, #ffcf8a 70%, #fff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 6s linear infinite;
  filter: drop-shadow(0 4px 24px rgba(233, 143, 176, 0.45));
}
@keyframes shine { to { background-position: -200% center; } }
.question__actions { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
.question__actions .btn { width: 100%; }
.toast {
  min-height: 3.2em; margin: 22px 0 4px; padding: 0 10px;
  font-size: 1.02rem; color: var(--cream);
  opacity: 0; transform: translateY(8px); transition: opacity 0.5s, transform 0.5s var(--ease);
}
.toast.is-shown { opacity: 1; transform: none; }
.scene--question.is-answered .question__actions { pointer-events: none; }

/* --------------------------------------------------------------------------
   MÀN 4 — CHÚC MỪNG
   -------------------------------------------------------------------------- */
.celebrate__title {
  font-size: clamp(2.2rem, 10vw, 3.4rem); margin: 0 0 22px;
  color: var(--cream);
  text-shadow: 0 0 24px rgba(247, 182, 200, 0.8), 0 0 60px rgba(255, 207, 138, 0.5);
}
.celebrate__body { margin: 0 0 30px; }
.celebrate__body p {
  font-size: clamp(1.05rem, 4.4vw, 1.2rem); margin: 0 0 12px; color: var(--text);
  opacity: 0; transform: translateY(12px);
}
.is-active .celebrate__body p { animation: rise 1s var(--ease) forwards; }
.scene--celebrate .btn { opacity: 0; }
.scene--celebrate.is-active .btn { animation: rise 1s var(--ease) 2.6s forwards; }
.scene--celebrate.is-active .celebrate__title { animation: pop 1s var(--ease) both; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: none; } }

/* --------------------------------------------------------------------------
   MÀN 5 — ALBUM POLAROID
   -------------------------------------------------------------------------- */
.scene--album .scene__head h2 { font-size: clamp(1.35rem, 5.4vw, 1.9rem); line-height: 1.25; text-wrap: balance; }
.album { position: relative; width: 100%; max-width: 420px; margin: 0 auto; }
.album__stage {
  position: relative; width: 100%;
  aspect-ratio: 0.72; max-height: 64vh;
  margin: 0 auto;
  touch-action: pan-y;
}
.polaroid {
  position: absolute; left: 50%; top: 50%;
  width: min(72vw, 300px, 40vh);
  padding: 12px 12px 0;
  background: #fffdf8;
  border-radius: 4px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(var(--sc, 1));
  transition: transform 0.7s var(--ease), opacity 0.6s ease, filter 0.6s ease;
  opacity: 0;
  pointer-events: none;
}
.polaroid__img {
  display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; /* khung dọc 3:4 như ảnh điện thoại */
  object-position: 50% 30%; /* ảnh khác tỉ lệ: giữ phần mặt thay vì cắt giữa */
  background: linear-gradient(135deg, #2a1b4a, #e98fb0);
}
/* Khung ảnh — hiệu ứng nhẹ khi ảnh hiện ra:
   ::before = lớp giấy trắng ngà mờ dần (như ảnh polaroid đang hiện hình)
   ::after  = một vệt sáng lướt qua */
.polaroid__frame { position: relative; overflow: hidden; border-radius: 2px; }
.polaroid__frame::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(160deg, #fbf6ea, #eadfc8); opacity: 0;
}
.polaroid__frame::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.4) 50%, transparent 65%);
  transform: translateX(-120%);
}
/* thời lượng ngắn cho hợp nhịp 2–3 giây/ảnh: ảnh rõ hẳn sau ~1.1s */
.polaroid.is-current .polaroid__frame::before { animation: develop 1.1s ease-out both; }
.polaroid.is-current .polaroid__frame::after { animation: sweep 0.9s ease-out 0.5s forwards; }
@keyframes develop { 0% { opacity: 1; } 30% { opacity: 0.75; } 100% { opacity: 0; } }
@keyframes sweep { to { transform: translateX(120%); } }
.polaroid figcaption:empty { height: 40px; } /* không chú thích: dải trắng kiểu polaroid */
.polaroid__cap:last-child { padding-bottom: 12px; }
.polaroid__cap {
  font-family: var(--f-hand); font-weight: 700; color: #3b2338;
  font-size: clamp(1.25rem, 5vw, 1.45rem); line-height: 1.25;
  text-align: center; padding: 12px 6px 4px; margin: 0;
}
.polaroid__date { text-align: center; color: #9a7f8f; font-size: 0.78rem; margin: 0; padding: 0 0 12px; letter-spacing: 0.06em; }
.polaroid.is-current { opacity: 1; pointer-events: auto; z-index: 3; }
.polaroid.is-prev, .polaroid.is-next { opacity: 0.55; z-index: 2; filter: brightness(0.7) blur(0.5px); }
.polaroid.is-prev { --sc: 0.86; transform: translate(-82%, -50%) rotate(-9deg) scale(0.86); }
.polaroid.is-next { --sc: 0.86; transform: translate(-18%, -50%) rotate(9deg) scale(0.86); }
/* Ảnh mới hiện ra êm: mờ dần lên tại chỗ, phóng rất nhẹ — không xoay, không bay */
.polaroid.is-current { animation: settle 0.6s ease-out; }
@keyframes settle { 0% { transform: translate(-50%, -50%) rotate(var(--r)) scale(0.97); opacity: 0; } }
/* Chữ khen dưới ảnh tự "viết" từ trái sang phải sau khi ảnh xuất hiện */
.polaroid.is-current .polaroid__cap { animation: write 0.7s ease-in-out 0.4s both; }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.album__nav {
  position: absolute; top: 50%; z-index: 5;
  width: 46px; height: 46px; margin-top: -23px; border-radius: 50%;
  border: 1px solid var(--glass-line); background: rgba(20, 16, 50, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: 30px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding-bottom: 4px;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.album__nav:active { transform: scale(0.9); }
.album__nav:hover { background: rgba(233, 143, 176, 0.3); }
.album__nav--prev { left: -4px; }
.album__nav--next { right: -4px; }
.album__bar { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 16px 0 22px; }
.album__dots { --dot-w: 28px; --pill: 24px; display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.album__dots.is-many { --dot-w: 20px; --pill: 14px; gap: 2px; } /* nhiều ảnh: chấm nhỏ lại để vừa một hàng */
.album__dots button {
  position: relative;
  width: var(--dot-w); height: 28px; border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.album__dots button::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.35); transition: all 0.3s var(--ease);
}
.album__dots button[aria-selected="true"]::before { width: var(--pill); border-radius: 6px; background: var(--pink); }
/* Thanh tiến trình trên chấm đang xem khi tự trình chiếu */
.album__dots.is-running button[aria-selected="true"]::after {
  content: ""; position: absolute; left: calc((var(--dot-w) - var(--pill)) / 2); top: 50%; height: 9px; margin-top: -4.5px; width: 0;
  border-radius: 6px; background: #fff; opacity: 0.85;
  animation: dot-fill var(--interval, 4s) linear forwards;
}
@keyframes dot-fill { to { width: var(--pill); } }
/* Nút tạm dừng / tự trình chiếu */
.album__play {
  flex: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0; color: var(--text);
  border: 1px solid var(--glass-line); background: rgba(20, 16, 50, 0.5);
  transition: transform 0.2s var(--ease), background 0.2s;
}
.album__play:hover { background: rgba(233, 143, 176, 0.3); }
.album__play:active { transform: scale(0.9); }
.album__play:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.album__play .i-play, .album__play.is-paused .i-pause { display: none; }
.album__play.is-paused .i-play { display: block; }

/* --------------------------------------------------------------------------
   MÀN 6 — TRÌNH PHÁT NHẠC
   -------------------------------------------------------------------------- */
.player {
  width: 100%; max-width: 400px; margin: 0 auto 26px;
  padding: 18px 18px 16px; border-radius: 24px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
/* Đầu trình phát gọn: đĩa nhỏ bên trái, tên bài bên phải */
.player__head { display: flex; align-items: center; gap: 14px; text-align: left; margin-bottom: 6px; }
.player__meta { flex: 1; min-width: 0; }
.vinyl {
  flex: none; width: 76px; aspect-ratio: 1; margin: 0; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 30%, rgba(255, 255, 255, 0.06) 30.5% 31%, transparent 31.5% 38%, rgba(255, 255, 255, 0.05) 38.5% 39%, transparent 39.5% 47%, rgba(255, 255, 255, 0.05) 47.5% 48%, transparent 48.5%),
    conic-gradient(from 30deg, #16122e, #2b2050, #16122e, #2b2050, #16122e);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(255, 255, 255, 0.05);
  display: grid; place-items: center;
  animation: spin 6s linear infinite; animation-play-state: paused;
}
.vinyl.is-spinning { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }
.vinyl__label {
  width: 36%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9a0, #e98fb0 60%, #b8466b);
  display: grid; place-items: center; color: #fff; font-size: 0.95rem;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.2);
}
.player__song { font-family: var(--f-title); font-size: 1.15rem; line-height: 1.3; font-weight: 700; margin: 0; }
.player__artist { margin: 2px 0 0; font-size: 0.9rem; }
.player__artist:empty { display: none; }
.player__times { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.player__controls { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 4px 0 8px; }
.play-btn {
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #2a0f2a;
  background: linear-gradient(135deg, #f7b6c8, #e98fb0 50%, #f6a86b);
  box-shadow: 0 10px 30px rgba(233, 143, 176, 0.5);
  transition: transform 0.2s var(--ease);
}
.play-btn:active { transform: scale(0.92); }
.play-btn .i-pause { display: none; }
.play-btn.is-playing .i-play { display: none; }
.play-btn.is-playing .i-pause { display: block; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.06); cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn--sm { width: 40px; height: 40px; flex: none; }
.icon-btn.is-muted { color: var(--pink); }
.icon-btn.is-muted svg { opacity: 0.5; }
.player__volume { display: flex; align-items: center; gap: 12px; }
.player__note { font-family: var(--f-hand); font-size: 1.3rem; color: var(--pink); margin: 14px 0 0; }
.player__note:empty { display: none; }
.player__error { color: #ffb4b4; font-size: 0.9rem; margin: 10px 0 0; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; background: transparent; cursor: pointer;
  --p: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 4px;
  background: linear-gradient(90deg, var(--pink) 0 var(--p), rgba(255, 255, 255, 0.18) var(--p) 100%);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 4px; background: var(--pink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(247, 182, 200, 0.35);
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(247, 182, 200, 0.35); }
input[type="range"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* --------------------------------------------------------------------------
   MÀN 7 — LỜI NHẮN CUỐI
   -------------------------------------------------------------------------- */
.lamps { position: absolute; inset: 0; pointer-events: none; }
.lamps i {
  position: absolute; top: 0; width: 2px; background: linear-gradient(rgba(255, 220, 160, 0.5), rgba(255, 220, 160, 0.15));
}
.lamps i::after {
  content: ""; position: absolute; left: 50%; bottom: -14px; width: 20px; height: 26px; margin-left: -10px;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 50% 40%, #fff3d6, #ffcf8a 50%, #f6a86b);
  box-shadow: 0 0 22px 8px rgba(255, 200, 120, 0.55), 0 0 70px 26px rgba(255, 180, 100, 0.22);
  animation: flicker 3.5s ease-in-out infinite;
}
/* dây đèn ngắn để bóng đèn không đè lên chữ */
.lamps i:nth-child(1) { left: 10%; height: 9vh; }
.lamps i:nth-child(2) { left: 28%; height: 13vh; }
.lamps i:nth-child(3) { left: 50%; height: 6vh; }
.lamps i:nth-child(4) { left: 72%; height: 12vh; }
.lamps i:nth-child(5) { left: 90%; height: 8vh; }
.lamps i:nth-child(2)::after { animation-delay: 0.7s; }
.lamps i:nth-child(4)::after { animation-delay: 1.4s; }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: 0.82; } 55% { opacity: 0.95; } }
.lamps i { transform-origin: top center; animation: swing 6s ease-in-out infinite; }
.lamps i:nth-child(odd) { animation-duration: 7s; animation-direction: reverse; }
@keyframes swing { 0%, 100% { transform: rotate(1.5deg); } 50% { transform: rotate(-1.5deg); } }

.scene--final .scene__inner { position: relative; z-index: 1; } /* nằm trên hoa & đèn */
.final__lines { min-height: 4em; display: flex; flex-direction: column; justify-content: center; margin-bottom: 24px; }
.final__line {
  font-family: var(--f-hand); font-weight: 700;
  font-size: clamp(1.6rem, 7vw, 2.4rem); line-height: 1.3;
  margin: 0 0 10px; color: var(--cream);
  text-shadow: 0 0 18px rgba(255, 207, 138, 0.55);
  opacity: 0; filter: blur(10px); transform: translateY(14px);
  transition: opacity 1.6s ease, filter 1.6s ease, transform 1.6s var(--ease);
  text-wrap: balance;
}
.final__line.is-shown { opacity: 1; filter: none; transform: none; }
.final__line:last-child { color: #ffe0ea; }

/* Danh sách chọn bài — nằm trong trình phát, ngăn cách bằng một đường kẻ mảnh */
.songs { width: 100%; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--glass-line); text-align: left; }
.songs__title { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; color: var(--cream); }
.songs__title:empty { display: none; }
.songs__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.song {
  width: 100%; min-height: 48px; padding: 6px 14px 6px 6px;
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid var(--glass-line); border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer; touch-action: manipulation;
  transition: transform 0.2s var(--ease), background 0.3s, border-color 0.3s;
}
.song:hover { background: rgba(255, 255, 255, 0.1); }
.song:active { transform: scale(0.97); }
.song:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.song.is-current { border-color: rgba(247, 182, 200, 0.6); background: rgba(233, 143, 176, 0.18); }
.song__icon {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: #2a0f2a;
  background: linear-gradient(135deg, #f7b6c8, #e98fb0 50%, #f6a86b);
}
.song__icon .i-play { margin-left: 2px; }
.song__bars { display: none; gap: 3px; align-items: flex-end; height: 18px; }
.song__bars i { width: 3px; background: #2a0f2a; border-radius: 2px; animation: bar 0.9s ease-in-out infinite; }
.song__bars i:nth-child(2) { animation-delay: 0.2s; }
.song__bars i:nth-child(3) { animation-delay: 0.4s; }
.song.is-playing .i-play { display: none; }
.song.is-playing .song__bars { display: flex; }
.song__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.song__name, .song__artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song__name { font-weight: 600; line-height: 1.3; }
.song__artist { font-size: 0.85rem; color: var(--muted); }

.flowers { position: absolute; left: 0; right: 0; bottom: 0; height: 18vh; min-height: 90px; pointer-events: none; opacity: 0; transform: translateY(20px); transition: opacity 1.5s ease 0.6s, transform 1.5s var(--ease) 0.6s; }
.flowers svg { display: block; width: 100%; height: 100%; } /* block: bỏ khoảng trống dưới svg gây cuộn thừa */
.scene--final.is-active .flowers { opacity: 0.9; transform: none; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 99; margin: 0; font-size: 1.2rem; }

/* --------------------------------------------------------------------------
   MÁY TÍNH
   -------------------------------------------------------------------------- */
@media (min-width: 720px) {
  .question__actions { flex-direction: row; max-width: 520px; justify-content: center; }
  .question__actions .btn { width: auto; flex: 1; }
  .album__nav--prev { left: -64px; }
  .album__nav--next { right: -64px; }
  .letter { padding: 40px 44px 34px; }
}
@media (max-height: 640px) {
  .glow-heart { font-size: 48px; margin-bottom: 16px; }
  .scene { padding-top: calc(64px + var(--safe-top)); }
}
/* Màn hình thấp (điện thoại nhỏ, trình duyệt trong Zalo/Messenger): album gọn lại để nút không bị đẩy khỏi màn */
@media (max-height: 760px) {
  .scene--album { padding-top: calc(60px + var(--safe-top)); padding-bottom: calc(16px + var(--safe-bottom)); }
  .scene--album .scene__head { margin-bottom: 8px; }
  .scene--album .scene__head h2 { font-size: 1.25rem; }
  .scene--album .scene__head p { font-size: 0.88rem; text-wrap: balance; }
  .album__stage { max-height: 52vh; }
  .polaroid { width: min(72vw, 300px, 31vh); }
  .album__bar { margin: 8px 0 12px; }
  /* Màn nhạc gọn: danh sách 2 cột, ẩn thanh âm lượng (điện thoại chỉnh bằng phím cứng) */
  .scene--music { padding-top: calc(60px + var(--safe-top)); padding-bottom: calc(16px + var(--safe-bottom)); }
  .scene--music h2 { font-size: 1.35rem; margin-bottom: 10px; }
  .player { margin-bottom: 16px; padding: 14px 14px 12px; }
  .vinyl { width: 56px; }
  .play-btn { width: 52px; height: 52px; }
  .player__volume { display: none; }
  .songs__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* minmax(0): tên dài thu gọn bằng "…" thay vì tràn khung */
  .song { min-height: 44px; padding: 5px 10px 5px 5px; gap: 8px; }
  .song__icon { width: 30px; height: 30px; }
  .song__name { font-size: 0.9rem; line-height: 1.2; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; } /* tên dài xuống tối đa 2 dòng */
}

/* --------------------------------------------------------------------------
   TÔN TRỌNG CÀI ĐẶT GIẢM CHUYỂN ĐỘNG
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
    transition-delay: 0s !important;
  }
  .scene { transform: none !important; filter: none !important; }
  .reveal, .celebrate__body p, .scene--celebrate .btn { opacity: 1 !important; transform: none !important; }
  .bokeh, .hearts { display: none; }
  .vinyl.is-spinning { animation: none; }
  .final__line { filter: none; }
}
