/* ===================================================
   RESET & VARIABLES
   =================================================== */
:root {
  --bg-gradient: linear-gradient(135deg, #ffd3e2 0%, #ffb6c1 50%, #ffa5ba 100%);
  --card-pink: #f27297;
  --card-pink-dark: #e05b82;
  --card-pink-light: #ff8fae;
  --white: #ffffff;
  --paper-bg: #fffefb;
  --line-color: rgba(220, 195, 195, 0.45);
  --text-dark: #4a3b40;
  --text-cursive: #3d2b33;
  --shadow-soft: 0 16px 36px rgba(224, 91, 130, 0.22);
  --shadow-paper: 0 12px 32px rgba(100, 60, 75, 0.15), 0 2px 6px rgba(0, 0, 0, 0.05);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 10px;
}

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

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================================================
   FLOATING LAYERS:
   - Ảnh Polaroid rơi ĐẰNG SAU thư (z-index: 5)
   - Icon/Sticker rơi ĐẰNG TRƯỚC thư (z-index: 25)
   =================================================== */
#floating-layer-back,
#floating-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

#floating-layer-front {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.floater-item {
  position: absolute;
  top: -160px;
  will-change: transform, opacity;
  animation: fallDownwards var(--duration, 11s) linear forwards;
  pointer-events: none;
}

.polaroid-frame {
  background: #ffffff;
  padding: 6px 6px 20px 6px;
  border-radius: 4px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.polaroid-frame img {
  width: 96px;
  height: 128px;
  object-fit: cover;
  object-position: center top;
  border-radius: 2px;
  display: block;
}

.floater-sticker {
  font-size: 2rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* ===================================================
   FLOATING AUDIO BUTTON
   =================================================== */
.music-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 16px rgba(224, 91, 130, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  font-size: 1.25rem;
  transition: transform 0.2s, background 0.2s;
}

.music-btn:hover {
  transform: scale(1.08);
  background: #ffffff;
}

/* ===================================================
   SCREEN 1: PASSCODE SCREEN
   =================================================== */
.screen-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.screen-hidden {
  display: none !important;
}

.passcode-card {
  background: var(--card-pink);
  background: linear-gradient(145deg, #f77d9f, #ec6088);
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 28px;
  max-width: 580px;
  width: 100%;
}

.avatar-wrapper {
  flex-shrink: 0;
  width: 200px;
  height: 270px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

.keypad-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.keypad-title {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dots-container {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-dot.active {
  background: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 240px;
}

.key-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 auto;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.key-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.5);
}

.key-btn.action-btn {
  font-size: 1.1rem;
}

.key-btn.submit-btn {
  background: rgba(255, 255, 255, 0.88);
  color: var(--card-pink-dark);
}

.key-btn.submit-btn:active {
  background: #ffffff;
}

.passcode-note {
  margin-top: 14px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}

/* ===================================================
   SCREEN 2: ENVELOPE SCREEN
   =================================================== */
.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  perspective: 1000px;
}

.envelope-box {
  position: relative;
  width: 320px;
  height: 220px;
  background: #f77a9c;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Các cánh gập của phong bì */
.envelope-flap-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 120px solid #fa8aa7;
  transform-origin: top center;
  z-index: 5;
  transition: transform 0.6s ease;
}

.envelope-flap-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 110px solid transparent;
  border-bottom: 110px solid transparent;
  border-left: 170px solid #f26f93;
  z-index: 4;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.envelope-flap-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-top: 110px solid transparent;
  border-bottom: 110px solid transparent;
  border-right: 170px solid #f0648a;
  z-index: 4;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.envelope-flap-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-bottom: 130px solid #ea5c83;
  z-index: 4;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.envelope-seal {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 6;
  transition: transform 0.3s;
}

.envelope-preview-letter {
  position: absolute;
  width: 86%;
  height: 80%;
  background: var(--paper-bg);
  border-radius: 8px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Dancing Script', cursive;
  font-size: 1.8rem;
  color: var(--card-pink-dark);
  font-weight: 700;
  transform: translateY(0);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.envelope-wrapper.opened .envelope-flap-top {
  animation: openTopFlap 0.7s forwards;
}

.envelope-wrapper.opened .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
}

.envelope-wrapper.opened .envelope-preview-letter {
  animation: slideLetterUp 0.8s 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.envelope-prompt {
  margin-top: 24px;
  font-size: 1rem;
  color: #a44865;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ===================================================
   SCREEN 3: LETTER DECK (INTERACTIVE CARDS)
   =================================================== */
.letter-deck-container {
  width: 100%;
  max-width: 520px;
  height: 390px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#letter-deck {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.letter-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--paper-bg);
  background-image: repeating-linear-gradient(transparent,
      transparent 31px,
      var(--line-color) 31px,
      var(--line-color) 32px);
  background-position: 0 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
  padding: 24px 28px 40px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(220, 210, 200, 0.4);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s;
  cursor: grab;
}

.letter-card:active {
  cursor: grabbing;
}

.card-chibi-wrap {
  width: 90px;
  height: 95px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.08));
}

.letter-text {
  font-family: 'Dancing Script', 'Caveat', cursive;
  font-size: 1.85rem;
  line-height: 1.5;
  color: var(--text-cursive);
  font-weight: 700;
  word-break: break-word;
  white-space: pre-line;
}

.letter-subtext {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.95rem;
  color: #8c737c;
  margin-top: 10px;
}

.card-footer {
  position: absolute;
  bottom: 12px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #ad9a9f;
}

.page-indicator {
  font-family: monospace;
  font-size: 0.85rem;
}

.nav-hint {
  font-size: 0.78rem;
  color: #ba8c9b;
}

/* Nút chuyển trang điều hướng trên PC/Mobile */
.deck-controls {
  position: absolute;
  bottom: -65px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  width: 100%;
  z-index: 20;
}

.control-btn {
  padding: 10px 22px;
  border-radius: 20px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: var(--card-pink-dark);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(224, 91, 130, 0.15);
  cursor: pointer;
  transition: all 0.2s;
}

.control-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
}

/* ===================================================
   SCREEN 4: CONFESSION FINALE MODAL
   =================================================== */
.card-final .letter-text {
  font-size: 1.45rem;
  line-height: 1.35;
  margin-bottom: 2px;
}

.card-final .letter-subtext {
  font-size: 0.88rem;
  margin-top: 2px;
  margin-bottom: 6px;
}

.decision-box {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  position: relative;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.decision-btn {
  width: 86%;
  max-width: 250px;
  padding: 9px 18px;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.yes-btn {
  background: linear-gradient(135deg, #f77a9c, #e0537a);
  color: #ffffff;
}

.yes-btn:hover,
.yes-btn:active {
  background: linear-gradient(135deg, #e0537a, #c73860);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 20px rgba(224, 83, 122, 0.35);
}

.no-btn {
  background: linear-gradient(135deg, #fff2f5, #ffdce5);
  color: #c73860;
  border: 1.5px solid #ffb8ca;
  position: relative;
}

.no-btn:hover,
.no-btn:active {
  background: linear-gradient(135deg, #ffdce5, #ffb8ca);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 20px rgba(255, 184, 202, 0.4);
}

/* Modal chúc mừng khi đồng ý */
.celebration-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.celebration-card {
  background: #ffffff;
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.celebration-card h2 {
  font-family: 'Dancing Script', cursive;
  font-size: 2.4rem;
  color: var(--card-pink-dark);
  margin-bottom: 16px;
}

.celebration-card p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: #554148;
}

/* ===================================================
   SCREEN 1.5: CHAPTER SELECTION SCREEN
   =================================================== */
.chapter-container {
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.chapter-header {
  text-align: center;
  margin-bottom: 22px;
}

.chapter-title {
  font-family: 'Dancing Script', cursive;
  font-size: 2.5rem;
  color: var(--card-pink-dark);
  text-shadow: 0 2px 8px rgba(255, 255, 255, 0.8);
  margin-bottom: 6px;
}

.chapter-subtitle {
  font-size: 0.95rem;
  color: #7d5e67;
  font-weight: 500;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.chapter-card {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(224, 91, 130, 0.15);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s, background 0.25s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.chapter-card.unlocked:hover {
  transform: translateY(-4px) scale(1.02);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 14px 32px rgba(224, 91, 130, 0.25);
  border-color: var(--card-pink-light);
}

.chapter-card.unlocked:active {
  transform: scale(0.98);
}

.chapter-card.locked {
  background: rgba(255, 255, 255, 0.55);
  opacity: 0.82;
  cursor: pointer;
}

.chapter-card.locked:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.7);
}

.chapter-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd3e2, #ffb6c1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(224, 91, 130, 0.2);
}

.chapter-card.locked .chapter-icon-wrap {
  background: linear-gradient(135deg, #eee3e7, #e2d5da);
  box-shadow: none;
}

.chapter-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chapter-card-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: #4a343c;
  margin-bottom: 4px;
}

.chapter-card-desc {
  font-size: 0.85rem;
  color: #8c6e78;
  line-height: 1.4;
}

.chapter-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.chapter-badge.badge-unlocked {
  background: #ffecf2;
  color: var(--card-pink-dark);
  border: 1px solid rgba(242, 114, 151, 0.3);
}

.chapter-badge.badge-locked {
  background: #f0eaed;
  color: #927e85;
}

/* Toast thông báo */
.chapter-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(74, 52, 60, 0.92);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 25px;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 999;
  text-align: center;
  max-width: 90%;
  white-space: normal;
  pointer-events: none;
}

/* Nút quay lại menu chương */
.back-menu-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(242, 114, 151, 0.3);
  font-size: 0.85rem;
}

/* ===================================================
   CHIBI CHARACTER LIVE 2.5D ANIMATION COMPONENT
   =================================================== */
.chibi-character-container {
  position: relative;
  display: inline-block;
  user-select: none;
  filter: drop-shadow(0 6px 14px rgba(224, 91, 130, 0.22));
}

/* Lắc lư nhịp thở Live2D tự nhiên */
.chibi-body-motion {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center bottom;
  animation: chibiLiveIdle 3.8s ease-in-out infinite;
}

@keyframes chibiLiveIdle {

  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1, 1);
  }

  25% {
    transform: translateY(-4px) rotate(-1.8deg) scale(1.015, 1.02);
  }

  50% {
    transform: translateY(-1px) rotate(0.8deg) scale(0.995, 0.99);
  }

  75% {
    transform: translateY(-5px) rotate(1.8deg) scale(1.02, 1.025);
  }
}

/* Khi nói chuyện: gật gù cử động nhẹ nhàng */
.chibi-character-container.talking .chibi-body-motion {
  animation: chibiLiveTalk 0.35s ease-in-out infinite alternate;
}

@keyframes chibiLiveTalk {
  0% {
    transform: translateY(0) rotate(-1deg) scale(1.02);
  }

  100% {
    transform: translateY(-4px) rotate(1.5deg) scale(1.045);
  }
}

/* Ảnh nhân vật chính & các lớp biểu cảm */
.chibi-main-art {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 1;
}

.chibi-blink-art,
.chibi-wink-art {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease;
}

/* Tự động chớp mắt anime mượt mà: Double-blink tự nhiên mỗi 4.2 giây */
.chibi-character-container:not(.pose-smile):not(.pose-celebrate) .chibi-blink-art {
  animation: chibiAutoBlink 4.2s ease-in-out infinite;
}

@keyframes chibiAutoBlink {

  0%,
  91%,
  95.5%,
  100% {
    opacity: 0;
  }

  92.5%,
  94.5% {
    opacity: 1;
    /* Chớp mắt lần 1 (84ms) */
  }

  97%,
  98.5% {
    opacity: 1;
    /* Chớp nhẹ lần 2 (63ms) */
  }
}

/* Nụ cười nhắm mắt tít mắt hạnh phúc (Thẻ 5 & Modal Chúc Mừng) */
.chibi-character-container.pose-smile .chibi-blink-art,
.chibi-character-container.pose-celebrate .chibi-blink-art {
  opacity: 1 !important;
  animation: none !important;
}

/* Tương tác khi click/chạm vào Mascot: Nháy mắt tinh nghịch (Wink) + Nhảy cẫng */
.chibi-mascot-container.tapped .chibi-wink-art {
  opacity: 1 !important;
  animation: none !important;
}

.chibi-mascot-container.tapped .chibi-blink-art {
  opacity: 0 !important;
  animation: none !important;
}

/* Tương tác khi hover/touch trên thẻ thư */
.card-chibi-wrap:hover .chibi-wink-art,
.card-chibi-wrap:active .chibi-wink-art {
  opacity: 1 !important;
}

.card-chibi-wrap:hover .chibi-blink-art,
.card-chibi-wrap:active .chibi-blink-art {
  opacity: 0 !important;
}

/* Lóa sáng gọng kính */
.glasses-glint-bar {
  position: absolute;
  top: 41%;
  left: 8%;
  width: 84%;
  height: 20%;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
  border-radius: 8px;
}

.glint-beam {
  position: absolute;
  top: -20%;
  left: -60%;
  width: 30%;
  height: 140%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-25deg);
  animation: glintSweep 4.5s ease-in-out infinite;
}

@keyframes glintSweep {

  0%,
  75%,
  100% {
    left: -60%;
    opacity: 0;
  }

  80% {
    opacity: 0.95;
  }

  88% {
    left: 140%;
    opacity: 0;
  }
}

/* Má hồng thở nhẹ */
.blush-dot {
  position: absolute;
  width: 20px;
  height: 11px;
  background: radial-gradient(circle, rgba(255, 95, 120, 0.75) 0%, rgba(255, 95, 120, 0) 75%);
  border-radius: 50%;
  top: 61%;
  z-index: 2;
  pointer-events: none;
  animation: blushBreathe 2.8s ease-in-out infinite;
}

.blush-dot.left {
  left: 16%;
}

.blush-dot.right {
  right: 16%;
}

@keyframes blushBreathe {

  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }

  50% {
    opacity: 0.95;
    transform: scale(1.2);
  }
}

/* Phản ứng bật nảy khi người dùng chạm vào Mascot */
.chibi-mascot-container.tapped .chibi-character-container {
  animation: chibiTapReaction 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.35) !important;
}

@keyframes chibiTapReaction {
  0% {
    transform: scale(0.92);
  }

  35% {
    transform: translateY(-16px) scale(1.12) rotate(-3deg);
  }

  65% {
    transform: translateY(-4px) scale(1.04) rotate(2deg);
  }

  100% {
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.chibi-pop-heart {
  position: absolute;
  pointer-events: none;
  font-size: 1.4rem;
  animation: popHeartFly 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  z-index: 90;
}

@keyframes popHeartFly {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }

  50% {
    opacity: 1;
    transform: translateY(-35px) scale(1.2) rotate(15deg);
  }

  100% {
    opacity: 0;
    transform: translateY(-65px) scale(0.9) rotate(-15deg);
  }
}

.chibi-prop {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  line-height: 1;
}

/* Pose Props */
.prop-wave {
  bottom: 8%;
  right: -6%;
  font-size: 1.55rem;
  animation: waveHand 1.1s ease-in-out infinite alternate;
  transform-origin: bottom center;
}

@keyframes waveHand {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(-24deg);
  }
}

.prop-key {
  bottom: 12%;
  right: -8%;
  font-size: 1.6rem;
  animation: bounceKey 2.2s ease-in-out infinite;
}

@keyframes bounceKey {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-6px) rotate(14deg);
  }
}

.prop-thought {
  top: -8%;
  right: -6%;
  font-size: 1.45rem;
  animation: floatThought 2.5s ease-in-out infinite;
}

@keyframes floatThought {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-5px) scale(1.08);
  }
}

.prop-glasses-glint {
  top: 44%;
  right: 27%;
  font-size: 1.25rem;
  animation: glintPulse 1.8s ease-in-out infinite;
}

@keyframes glintPulse {

  0%,
  100% {
    opacity: 0.2;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

.prop-flower {
  bottom: 4%;
  left: -4%;
  font-size: 1.55rem;
  animation: floatFlower 2.4s ease-in-out infinite;
}

@keyframes floatFlower {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px) rotate(-8deg);
  }
}

.prop-ring {
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  animation: ringGlow 1.8s ease-in-out infinite;
}

@keyframes ringGlow {

  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.18);
  }
}

.prop-hat {
  top: -11%;
  left: 48%;
  transform: translateX(-50%) rotate(8deg);
  width: 32%;
  height: 32%;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
}

.prop-confetti-l {
  top: 8%;
  left: -12%;
  font-size: 1.45rem;
  animation: spinConfetti 2.4s ease-in-out infinite;
}

.prop-confetti-r {
  top: 8%;
  right: -12%;
  font-size: 1.45rem;
  animation: spinConfetti 2.4s ease-in-out infinite reverse;
}

@keyframes spinConfetti {

  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }

  50% {
    transform: scale(1.15) rotate(15deg);
  }
}

.prop-gift {
  bottom: 4%;
  right: -6%;
  font-size: 1.55rem;
  animation: bounceGift 2s ease-in-out infinite;
}

@keyframes bounceGift {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px) rotate(6deg);
  }
}

.prop-heart {
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  animation: pulseHeart 1.5s ease-in-out infinite;
}

@keyframes pulseHeart {

  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.22);
  }
}

.prop-star {
  top: 10%;
  right: -4%;
  font-size: 1.4rem;
  animation: twinkleStar 1.6s ease-in-out infinite;
}

@keyframes twinkleStar {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.85);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ===================================================
   CHIBI FLOATING MASCOT COMPANION
   =================================================== */
.chibi-mascot-container {
  position: fixed;
  bottom: 16px;
  left: 14px;
  z-index: 85;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chibi-mascot-container:hover {
  transform: scale(1.05);
}

.chibi-mascot-graphic {
  width: 78px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(224, 91, 130, 0.25));
}

.chibi-mascot-graphic svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chibi-mascot-bubble {
  position: relative;
  background: #ffffff;
  padding: 9px 15px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  font-size: 0.84rem;
  color: #4a343c;
  font-weight: 600;
  max-width: min(230px, 62vw);
  white-space: normal;
  word-break: break-word;
  border: 1.5px solid rgba(242, 114, 151, 0.35);
  margin-bottom: 22px;
  line-height: 1.45;
  pointer-events: none;
  transform-origin: bottom left;
}

.chibi-mascot-bubble::after {
  content: "";
  position: absolute;
  bottom: 10px;
  left: -6px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-bottom: 1.5px solid rgba(242, 114, 151, 0.35);
  border-left: 1.5px solid rgba(242, 114, 151, 0.35);
  transform: rotate(45deg);
}

.celebration-chibi-wrap {
  width: 100px;
  height: 110px;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 6px 16px rgba(224, 91, 130, 0.2));
}

/* ===================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   =================================================== */
@media (max-width: 600px) {
  .chapter-container {
    max-width: 340px;
  }

  .chapter-title {
    font-size: 2.1rem;
  }

  .chapter-card {
    padding: 14px 16px;
    gap: 12px;
  }

  .chapter-icon-wrap {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  .chapter-card-title {
    font-size: 1.02rem;
  }

  .chapter-card-desc {
    font-size: 0.8rem;
  }

  .passcode-card {
    flex-direction: column;
    padding: 22px 18px;
    gap: 16px;
    max-width: 330px;
  }

  .avatar-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 50%;
  }

  .keypad-grid {
    gap: 10px;
    max-width: 220px;
  }

  .key-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }

  .letter-deck-container {
    max-width: 340px;
    height: 410px;
  }

  .letter-card {
    padding: 18px 16px 36px 16px;
  }

  .card-chibi-wrap {
    width: 78px;
    height: 88px;
    margin-bottom: 4px;
  }

  .letter-text {
    font-size: 1.55rem;
    line-height: 1.4;
  }

  .chibi-mascot-container {
    bottom: 12px;
    left: 12px;
    gap: 8px;
  }

  .chibi-mascot-graphic {
    width: 68px;
    height: 80px;
  }

  .chibi-mascot-bubble {
    font-size: 0.78rem;
    padding: 8px 12px;
    max-width: min(215px, 62vw);
    margin-bottom: 20px;
  }

  .envelope-box {
    width: 270px;
    height: 185px;
  }

  .envelope-flap-top {
    border-left-width: 135px;
    border-right-width: 135px;
    border-top-width: 100px;
  }

  .envelope-flap-left {
    border-left-width: 145px;
    border-top-width: 95px;
    border-bottom-width: 95px;
  }

  .envelope-flap-right {
    border-right-width: 145px;
    border-top-width: 95px;
    border-bottom-width: 95px;
  }

  .envelope-flap-bottom {
    border-left-width: 135px;
    border-right-width: 135px;
    border-bottom-width: 110px;
  }
}