/* ==========================================================================
   HAPPY 1ST ANNIVERSARY - MOBILE OPTIMIZED STYLESHEET
   Themes: Romantic Pastel Pink, Champagne Cream, Deep Ruby Red
   ========================================================================== */

:root {
  --theme-pink-bg: linear-gradient(135deg, #ffd1dc 0%, #ffb6c1 50%, #fecfef 100%);
  --theme-pink-deep: #ff4b72;
  --theme-pink-soft: #ffe4e9;
  --theme-gold: #d4af37;
  --theme-red: #d32f2f;
  --theme-red-glow: rgba(229, 57, 53, 0.4);
  --paper-cream: #ffffff;
  --paper-yellow-soft: #ffffff;
  --envelope-body: #ffffff;
  --envelope-pocket: #fcfcfc;
  --envelope-dark: #f8f8f8;
  --text-dark: #2c2523;
  --text-muted: #665b57;
  --font-serif: 'Cormorant Upright', 'Playfair Display', serif;
  --font-cursive: 'Dancing Script', 'Great Vibes', cursive;
  --font-body: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-subtle: 0 10px 30px rgba(255, 75, 114, 0.15);
  --shadow-heavy: 0 20px 50px rgba(0, 0, 0, 0.25);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #111115; /* Nền tối sang trọng phía sau khung điện thoại desktop */
  font-family: var(--font-body);
  color: var(--text-dark);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 9:16 Mobile Aspect Ratio Framework */
#app-viewport {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  height: 100dvh;
  max-height: 880px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 10px #1e1e26;
  border-radius: 36px;
  background: var(--theme-pink-bg);
}

@media (max-width: 480px) {
  #app-viewport {
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Background Animated Canvas */
#bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Floating Audio Control */
.floating-controls {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 1000;
}

.control-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--theme-pink-deep);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(255, 75, 114, 0.25);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.control-btn:active {
  transform: scale(0.9);
}

.control-btn.active i {
  animation: discRotate 3s linear infinite;
}

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

/* Scene Framework */
.scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.8s ease, visibility 0.8s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 10;
}

/* ==========================================================================
   SCENE 1: ENVELOPE & LETTER UNFOLD
   ========================================================================== */
#scene-envelope {
  background: radial-gradient(circle at center, #fff0f3 0%, #ffccd5 60%, #ffb3c1 100%);
}

.envelope-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 20px;
}

.envelope-hint {
  position: absolute;
  top: 8%;
  background: rgba(255, 255, 255, 0.85);
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(255, 75, 114, 0.2);
  color: var(--theme-pink-deep);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
  animation: floatBounce 2s ease-in-out infinite;
  transition: opacity 0.5s ease;
}

.envelope-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes floatBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Envelope Container */
.envelope {
  position: relative;
  width: 320px;
  height: 220px;
  background: var(--envelope-body);
  border-radius: 6px;
  box-shadow: 0 25px 45px rgba(186, 73, 98, 0.25), 0 10px 15px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  perspective: 1200px;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.envelope-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-pocket);
  border-radius: 6px;
  z-index: 10;
}

/* 3D Top Flap */
.envelope-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 125px solid #ffffff;
  transform-origin: top center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.2s 0.3s;
  z-index: 30;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.08));
}

.envelope.open .envelope-top-flap {
  transform: rotateX(180deg);
  z-index: 15;
  border-top-color: #f7f7f7;
}

/* Pocket Flaps (Left, Right, Bottom) */
.envelope-pocket {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 25;
  pointer-events: none;
}

.envelope-pocket::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid #fcfcfc;
  border-right: 160px solid transparent;
  border-top: 110px solid transparent;
  border-bottom: 110px solid #fcfcfc;
  border-radius: 0 0 0 6px;
  filter: drop-shadow(2px 0 4px rgba(0, 0, 0, 0.04));
}

.envelope-pocket::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-right: 160px solid #ffffff;
  border-left: 160px solid transparent;
  border-top: 110px solid transparent;
  border-bottom: 110px solid #ffffff;
  border-radius: 0 0 6px 0;
  filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.05));
}

/* Wax Seal with Heart */
.wax-seal {
  position: absolute;
  top: 105px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 35% 35%, #ff5252, var(--theme-red), #8b0000);
  border-radius: 50%;
  box-shadow: 0 6px 15px rgba(183, 28, 28, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffebee;
  cursor: pointer;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wax-seal::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  border-radius: 50%;
}

.wax-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.wax-inner i {
  font-size: 16px;
  margin-bottom: 2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.wax-text {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.envelope.open .wax-seal {
  opacity: 0;
  transform: translate(-50%, -80px) scale(0.5);
  pointer-events: none;
}

/* ==========================================================================
   REALISTIC 3D TRI-FOLD WHITE LETTER (LÁ THƯ TRẮNG MỞ TỪNG NẾP GẤP 3D)
   ========================================================================== */

/* Letter Wrapper inside/outside Envelope */
.letter-trifold-wrapper {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 290px;
  height: 185px;
  z-index: 20;
  perspective: 1500px;
  pointer-events: none;
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ẨN HOÀN TOÀN KHI CHƯA MỞ (ĐỂ KHÔNG BỊ TRỒI RA KHỎI PHONG BÌ) */
.envelope:not(.open):not(.floating):not(.unfolded) .letter-trifold-wrapper {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.1); /* Thu nhỏ cực độ để không bao giờ lòi ra ngoài */
}

/* Khi phong bì mở, thư hiện lên dần từ bên trong trước khi nổi ra */
.envelope.open .letter-trifold-wrapper {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Khi phong bì mở hoàn toàn: Thư trồi lên giữa màn hình ở trạng thái gấp 3 */
.envelope.floating .letter-trifold-wrapper,
.envelope.unfolded .letter-trifold-wrapper,
.envelope.folding .letter-trifold-wrapper {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100vw - 32px);
  max-width: 380px;
  height: auto;
  max-height: 88dvh;
  z-index: 200;
  pointer-events: auto;
  overflow-y: visible;
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Khung giấy thư màu trắng tinh khôi - Khung thân giữa là gốc */
.letter-trifold-paper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  transform-style: preserve-3d;
  transition: box-shadow 0.5s ease;
}

/* Các nếp gấp (Panels container) */
.trifold-panel {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.6s ease;
}

/* Mặt trước và sau của nếp gấp (Chống lỗi bóng xuyên thấu 3D) */
.panel-front, .panel-back {
  width: 100%;
  background: #ffffff;
  background-image: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-left: 1px solid rgba(235, 230, 235, 0.9);
  border-right: 1px solid rgba(235, 230, 235, 0.9);
  border-radius: inherit;
}

.panel-back {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  transform: rotateX(180deg);
  background: #ffffff; /* Trắng trơn cho mặt sau */
  background-image: none;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.03); /* Đổ bóng nhẹ tạo chất giấy */
}

/* Nếp gấp giữa (Middle Fold - Thân thư gốc) */
.panel-middle {
  z-index: 2;
  border-top: 1px dashed rgba(220, 200, 210, 0.3);
  border-bottom: 1px dashed rgba(220, 200, 210, 0.3);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(255, 75, 114, 0.15);
}

.envelope.unfolded .panel-middle {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 182, 193, 0.5);
}

/* Nếp gấp trên (Top Fold) */
.panel-top {
  position: absolute;
  bottom: 100%;
  left: 0;
  border-top: 1px solid rgba(235, 230, 235, 0.9);
  border-radius: 12px 12px 0 0;
  transform-origin: bottom center;
  transform: rotateX(-179.5deg);
  z-index: 3;
  box-shadow: none; /* Bỏ hẳn bóng râm khi gập để chống lỗi đen chữ */
}

/* Mở nếp gấp trên */
.envelope.unfold-top .panel-top,
.envelope.unfolded .panel-top {
  transform: rotateX(0deg);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

/* Nếp gấp dưới (Bottom Fold) */
.panel-bottom {
  position: absolute;
  top: 100%;
  left: 0;
  border-bottom: 1px solid rgba(235, 230, 235, 0.9);
  border-radius: 0 0 12px 12px;
  transform-origin: top center;
  transform: rotateX(179.5deg);
  z-index: 4;
  box-shadow: none; /* Bỏ bóng râm khi gập */
}

/* Mở nếp gấp dưới */
.envelope.unfold-bottom .panel-bottom,
.envelope.unfolded .panel-bottom {
  transform: rotateX(0deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Nội dung bên trong mặt trước từng nếp gấp */
.panel-front {
  padding: 16px 20px;
  color: #1a1a1a;
}

.panel-top .panel-front {
  padding-bottom: 8px;
}

.panel-middle .panel-front {
  padding-top: 12px;
  padding-bottom: 12px;
}

.panel-bottom .panel-front {
  padding-top: 10px;
  padding-bottom: 20px;
}

/* Chi tiết đường gân nếp gấp ngoài đời */
.crease-fold-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.05) 50%, transparent 100%);
  pointer-events: none;
}

.line-bottom {
  bottom: 0;
}

/* Typography Lá Thư Màu Trắng */
.letter-header {
  text-align: center;
  margin-bottom: 8px;
}

.heart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #fff0f3;
  color: var(--theme-pink-deep);
  border-radius: 50%;
  font-size: 16px;
  margin-bottom: 4px;
  box-shadow: 0 3px 8px rgba(255, 75, 114, 0.18);
}

.letter-title {
  font-family: var(--font-cursive);
  font-size: 32px;
  color: #111111;
  font-weight: 700;
  line-height: 1.1;
}

.letter-subtitle {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #887777;
  font-weight: 600;
  margin-top: 2px;
}

.letter-divider {
  color: #ff758c;
  font-size: 16px;
  margin: 4px 0;
}

.letter-text-lead, .letter-text {
  font-size: 15px;
  line-height: 1.65;
  color: #222222;
  text-align: justify;
  margin-bottom: 10px;
}

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

.letter-text strong, .letter-text-lead strong {
  color: var(--theme-red);
  font-weight: 700;
}

.letter-sign {
  text-align: right;
  margin-top: 6px;
  margin-bottom: 15px;
}

.letter-sign p {
  font-size: 13px;
  color: #666666;
  margin-bottom: 2px;
}

.sign-name {
  font-family: var(--font-cursive);
  font-size: 26px;
  color: var(--theme-red);
  font-weight: 700;
}

/* NÚT ĐỎ CHỮ TRẮNG Ở ĐÁY LÁ THƯ */
.letter-action {
  margin-top: 10px;
  text-align: center;
}

.btn-love-red {
  position: relative;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #e53935 0%, #d32f2f 50%, #b71c1c 100%);
  color: #ffffff !important;
  border: none;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 25px var(--theme-red-glow), 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.btn-love-red .btn-icon {
  font-size: 17px;
  transition: transform 0.3s ease;
}

.btn-love-red:hover .btn-icon,
.btn-love-red:active .btn-icon {
  transform: translateX(4px) scale(1.15);
}

.btn-love-red:active {
  transform: scale(0.96);
  box-shadow: 0 4px 15px var(--theme-red-glow);
}

.btn-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: rotate(25deg);
  animation: buttonShine 3.5s infinite;
}

@keyframes buttonShine {
  0% { transform: translateX(-100%) rotate(25deg); }
  40%, 100% { transform: translateX(100%) rotate(25deg); }
}

/* Folding animation for scene transition */
.envelope.folding .letter-trifold-wrapper {
  transform: translate(-50%, -50%) scale(0.2) rotate(-6deg) !important;
  opacity: 0 !important;
  transition: all 0.6s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}


/* ==========================================================================
   SCENE 2: CINEMA BLACKOUT & VIDEO PLAYBACK
   ========================================================================== */
#scene-video {
  background: #000000;
  z-index: 80;
}

.cinema-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(30, 10, 20, 0.4) 0%, #050305 85%);
  pointer-events: none;
}

.video-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 16px 30px;
  z-index: 10;
}

.video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
}

.video-badge {
  color: #ffccd5;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 0 10px rgba(255, 117, 140, 0.6);
}

.btn-skip {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-skip:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

.video-container {
  position: relative;
  width: 100%;
  flex: 1;
  max-height: 72vh;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 20px 60px rgba(255, 75, 114, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#anniversary-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
}

.video-controls-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.video-controls-overlay.show {
  opacity: 1;
}

.btn-big-play {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 75, 114, 0.85);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-big-play:active {
  transform: scale(0.9);
}

.video-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
}

.video-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff758c, #ff4b72);
  transition: width 0.1s linear;
}

.video-footer {
  text-align: center;
  padding-top: 10px;
}

.video-note {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}


/* ==========================================================================
   SCENE 3: 3D INTERACTIVE EBOOK ON PINK THEME
   ========================================================================== */
#scene-book {
  background: radial-gradient(circle at top center, #ffe5ec 0%, #ffb6c1 60%, #ffa4b6 100%);
  overflow: hidden;
}

.book-scene-container {
  width: 100%;
  max-width: 440px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 15px 12px 25px;
}

.book-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.book-main-title {
  font-family: var(--font-cursive);
  font-size: 32px;
  color: #721c38;
  font-weight: 700;
  text-shadow: 0 2px 5px rgba(255, 255, 255, 0.6);
}

.sparkle-icon {
  font-size: 18px;
  animation: twinkle 1.5s infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.4; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

.book-guide {
  font-size: 12px;
  color: #8c3b56;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.6);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 5px;
  backdrop-filter: blur(4px);
}

/* 3D Book Viewport */
.book-viewport {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1600px;
  overflow: visible;
}

/* 3D Book Viewport Alignment & Open Spread */
.book-3d {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 290px;
  height: 430px;
  transform-style: preserve-3d;
  box-shadow: 0 25px 50px rgba(114, 28, 56, 0.3);
  border-radius: 0 16px 16px 0;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: left center; /* Gáy sách là gốc tọa độ biến hình 3D */
  /* Trạng thái đóng bìa: Căn giữa bìa sách to rạng rỡ vào đúng giữa màn hình */
  transform: translate(-145px, -50%) scale(0.95);
}

/* Trạng thái mở sách: Tăng kích thước to rõ hơn (scale 0.60), gáy sách cố định ở ĐÚNG CHÍNH GIỮA 50% (translate(0, -50%)), 2 trang xòe đều 2 bên cân đối tuyệt đối 100% ở MIDDLE */
.book-3d.book-open {
  transform-origin: left center;
  transform: translate(0, -50%) scale(0.60);
}

@media (max-width: 400px) {
  .book-3d.book-open {
    transform: translate(0, -50%) scale(0.54);
  }
}

/* Individual Book Pages */
.book-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 0 16px 16px 0;
  cursor: pointer;
}

.book-page.flipped {
  transform: rotateY(-180deg);
}

/* Front and Back of Each Page */
.page-front, .page-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 16px 16px 0;
  overflow: hidden;
  box-shadow: inset 5px 0 20px rgba(0, 0, 0, 0.08);
}

.page-front {
  z-index: 2;
}

.page-back {
  transform: rotateY(180deg);
  border-radius: 16px 0 0 16px;
  z-index: 1;
  box-shadow: inset -5px 0 20px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   EDITORIAL BOOK TEMPLATE (BÌA VÀ TRANG THEO MẪU ẢNH NGƯỜI DÙNG)
   ========================================================================== */

/* 1. EDITORIAL COVER DESIGN (Image 1 Template) */
.cover-template {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fff0f3 0%, #ffe5ec 50%, #ffd6e0 100%);
  border-radius: 0 16px 16px 0;
  overflow: hidden;
}

/* White Spine Strip on Left Edge */
.cover-spine {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 100%;
  background: #ffffff;
  z-index: 10;
  box-shadow: inset -3px 0 6px rgba(0, 0, 0, 0.15), 1px 0 3px rgba(0, 0, 0, 0.1);
}

/* Cover Photo Container */
.cover-photo-box {
  position: absolute;
  top: 0;
  left: 22px;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.cover-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* Căn góc trên để luôn hiển thị đầy đủ khuôn mặt */
  filter: none; /* Màu tươi nguyên gốc của ảnh */
  transition: transform 0.5s ease;
}

.cover-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(114, 28, 56, 0.75) 0%, rgba(114, 28, 56, 0.15) 50%, transparent 100%);
}

/* Cover Typography: "one year with you" */
.cover-typography {
  position: absolute;
  bottom: 35px;
  left: 38px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  line-height: 0.92;
}

.cover-text-line {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 46px;
  font-weight: 900;
  color: #ffffff;
  text-transform: lowercase;
  letter-spacing: -1.5px;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
}

/* Cover Tap Badge */
.cover-tap-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 12;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: pulseHint 1.8s infinite;
}

@keyframes pulseHint {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}


/* 2. EDITORIAL INNER SPREAD (Image 2 Template) */

/* Left Page: Who's that girl? Essay */
.editorial-page-left {
  background: #ffffff;
  padding: 22px 18px 18px 22px;
}

.editorial-paper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.editorial-header {
  margin-top: 4px;
  line-height: 0.92;
}

.head-serif {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  color: #111111;
  display: block;
}

.head-sub {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  font-style: italic;
  color: #333333;
  margin-left: 8px;
}

.head-cursive {
  font-family: var(--font-cursive);
  font-size: 54px;
  font-weight: 700;
  color: #000000;
  margin-top: -12px;
  margin-left: 18px;
}

.editorial-body {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.5;
  color: #2b2b2b;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Georgia, serif;
  text-align: justify;
}

.editorial-body p {
  margin-bottom: 6px;
}

.editorial-page-num {
  font-size: 11px;
  font-family: monospace;
  color: #aaaaaa;
  text-align: left;
}

/* Right Page: Full-bleed photo of girlfriend + Side Bookmarks */
.editorial-page-right {
  background: #ffffff;
  position: relative;
  overflow: visible !important; /* Cho phép các thẻ kẹp nhô ra bên ngoài sách */
}

.editorial-photo-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0 16px 16px 0;
  background: #ffffff;
}

.editorial-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* Căn góc trên để luôn hiển thị đầy đủ nụ cười & khuôn mặt ảnh dọc */
  filter: none;
}

/* Side Bookmark: Pink Star Tab ⭐ bên hông góc trên phải */
.bookmark-star-tab {
  position: absolute;
  top: 35px;
  right: -16px;
  width: 28px;
  height: 28px;
  background: #ff4b72;
  color: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 2px 4px 10px rgba(255, 75, 114, 0.4);
  z-index: 30;
  transform: rotate(6deg);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Side Bookmark: Photostrip kẹp bên hông góc dưới phải */
.bookmark-photostrip {
  position: absolute;
  bottom: 25px;
  right: -24px;
  width: 48px;
  background: #111111;
  padding: 5px 3px;
  border-radius: 4px;
  box-shadow: 4px 8px 18px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
  transform: rotate(2deg);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Ẩn các thẻ kẹp bookmark bên hông khi sách chưa mở bìa (chống lòi ra ngoài) */
.book-3d:not(.book-open) .bookmark-star-tab,
.book-3d:not(.book-open) .bookmark-photostrip {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.photostrip-item {
  width: 100%;
  height: 50px;
  border-radius: 2px;
  overflow: hidden;
}

.photostrip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.back-cover-design {
  background: linear-gradient(135deg, #222222 0%, #0d0d0d 100%);
}

.back-cover-text {
  text-align: center;
  color: #fff;
}

.back-cover-text i {
  font-size: 38px;
  color: #ffd700;
  margin-bottom: 10px;
}

.back-cover-text h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin-bottom: 5px;
}

/* Inner Page Styling */
.vintage-bg {
  width: 100%;
  height: 100%;
  background: #fff9f6;
  background-image: radial-gradient(#f7e1e7 15%, transparent 16%);
  background-size: 16px 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Polaroid Photo Card */
.photo-polaroid {
  width: 100%;
  max-height: 200px;
  background: #ffffff;
  padding: 8px 8px 24px;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.05);
  transform: rotate(-1.5deg);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.photo-polaroid img {
  width: 100%;
  height: 165px;
  object-fit: cover;
  border-radius: 4px;
}

.polaroid-caption {
  font-family: var(--font-cursive);
  font-size: 15px;
  color: #5c3843;
  margin-top: 6px;
  text-align: center;
  font-weight: 700;
}

.page-heading {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--theme-pink-deep);
  font-weight: 700;
  margin-top: 8px;
  text-align: center;
}

.page-text {
  font-size: 13px;
  line-height: 1.5;
  color: #4a3e42;
  text-align: center;
  padding: 0 4px;
}

.page-number {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: #a8949a;
  font-weight: 600;
}

/* Love Counter Display */
.love-counter-box {
  display: flex;
  gap: 6px;
  justify-content: center;
  width: 100%;
  margin: 6px 0;
}

.counter-item {
  flex: 1;
  background: #ffebee;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 6px rgba(255, 75, 114, 0.1);
}

.counter-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--theme-red);
  font-family: var(--font-serif);
}

.counter-label {
  font-size: 10px;
  color: #7d6b70;
  text-transform: uppercase;
  font-weight: 600;
}

/* End Page Actions */
.end-page-content {
  justify-content: center;
  gap: 15px;
  text-align: center;
}

.end-heart-badge {
  font-size: 42px;
  color: var(--theme-pink-deep);
  animation: heartbeat 1.2s infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.15); }
  50% { transform: scale(0.95); }
  75% { transform: scale(1.1); }
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 220px;
}

.btn-firework {
  background: linear-gradient(135deg, #ff4b72, #e91e63);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease;
}

.btn-restart {
  background: #f0e6eb;
  color: #634752;
  border: 1px solid #d9cad1;
  padding: 10px 16px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-firework:active, .btn-restart:active {
  transform: scale(0.95);
}

/* Book Bottom Navigation */
.book-nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 10px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 117, 140, 0.3);
  color: var(--theme-pink-deep);
  padding: 10px 16px;
  border-radius: 25px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(255, 75, 114, 0.15);
  transition: all 0.2s ease;
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.nav-btn:not(:disabled):active {
  transform: scale(0.93);
  background: #fff;
}

.page-indicator {
  font-size: 13px;
  font-weight: 600;
  color: #721c38;
}

/* Media Query Fine-Tuning for Small Phones */
@media (max-width: 360px) {
  .envelope {
    width: 280px;
    height: 190px;
  }
  .envelope-top-flap {
    border-left-width: 140px;
    border-right-width: 140px;
    border-top-width: 110px;
  }
  .envelope-pocket::before {
    border-left-width: 140px;
  }
  .envelope-pocket::after {
    border-right-width: 140px;
  }
  .book-3d {
    width: 270px;
    height: 390px;
  }
  .letter-title {
    font-size: 26px;
  }
  .letter-body {
    font-size: 14px;
  }
}

/* ==========================================================================
   NEW CUSTOMIZED PAGES: FESTIVAL & BIRTHDAY SPLIT STYLES
   ========================================================================== */

.photo-contain-fit {
  object-fit: cover !important;
  object-position: center bottom !important;
}

/* Căn góc dưới cho ảnh 2 ly nước hẹn hò (hendaho.jpg) để hiển thị đầy đủ 2 ly nước, ống hút và đĩa hướng dương */
img[src*="hendaho.jpg"] {
  object-fit: cover !important;
  object-position: center bottom !important;
}

/* Căn giữa mặt cho ảnh selfie cặp đôi (henho_couple.jpg) */
img[src*="henho_couple.jpg"] {
  object-fit: cover !important;
  object-position: center 25% !important;
}

/* FESTIVAL PAGE STYLES - Tông màu hồng đồng nhất */
.fest-bg {
  background: linear-gradient(135deg, #fff0f3 0%, #ffe5ec 100%);
  color: #2b2b2b;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.fest-heading {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: #721c38;
  text-align: center;
  margin-bottom: 2px;
}

.fest-sub {
  font-size: 11px;
  color: #8c3b56;
  text-align: center;
  font-style: italic;
  margin-bottom: 10px;
}

.fest-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.fest-photo-main {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.fest-photo-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.fest-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: #ffb6c1;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 182, 193, 0.3);
}

.fest-photo-row {
  display: flex;
  gap: 8px;
  height: 110px;
}

.fest-photo-thumb {
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.fest-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

/* BIRTHDAY PAGE STYLES (SPLIT 2 HALVES) */
.birthday-page-bg {
  background: #fff0f3;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.birthday-heading {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #721c38;
  text-align: center;
  margin-bottom: 8px;
}

.birthday-split-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.birthday-half-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(114, 28, 56, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.birthday-photo-frame {
  width: 100%;
  height: 122px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 182, 193, 0.4);
}

.birthday-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* HIỂN THỊ TRỌN VẸN 100% BỨC ẢNH QUÀ SINH NHẬT KHÔNG BỊ XÉN DÙ CHỈ 1 PIXEL */
  object-position: center center;
  filter: drop-shadow(0 3px 8px rgba(114, 28, 56, 0.15));
}

.birthday-label {
  font-size: 11px;
  font-weight: 700;
  color: #8c3b56;
}

.birthday-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #ffb6c1, transparent);
  margin: 2px 0;
}

/* NEW YEAR PAGE STYLES - Tông màu hồng đồng nhất */
.newyear-page-bg {
  background: linear-gradient(135deg, #fff0f3 0%, #ffe0e9 100%);
  color: #2b2b2b;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.newyear-heading {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #721c38;
  text-align: center;
  margin-bottom: 2px;
}

.newyear-sub {
  font-size: 11px;
  color: #8c3b56;
  text-align: center;
  font-weight: 600;
  margin-bottom: 8px;
}

.newyear-photos-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.newyear-photo-card {
  position: relative;
  width: 100%;
  height: 132px;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(114, 28, 56, 0.12);
  border: 1px solid rgba(255, 182, 193, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.newyear-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 3px 8px rgba(114, 28, 56, 0.15));
}

.newyear-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  color: #721c38;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 182, 193, 0.5);
}

.newyear-badge.badge-heart {
  color: #e6005c;
  border-color: rgba(230, 0, 92, 0.3);
}
