/* ===================================================================
   SEL RPG - HÀNH TRÌNH THẤU CẢM
   Style sheet: Hỗ trợ Cánh Cửa 01 (Tức Giận), 02 (Thất Vọng) & 03 (Lo Âu)
   Responsive cho Mobile, Desktop & Máy chiếu lớp học
   Vẽ đồ họa CSS / SVG & Hiệu ứng chuyển động cảm xúc đa màn
   =================================================================== */

:root {
  --font-sans: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  /* Bảng màu chủ đạo - Cửa 01: Ngọn Lửa Tức Giận */
  --color-anger-main: #ef4444;
  --color-anger-deep: #b91c1c;
  --color-anger-glow: rgba(239, 68, 68, 0.45);

  /* Bảng màu chủ đạo - Cửa 02: Vực Sâu Thất Vọng */
  --color-abyss-main: #6366f1;
  --color-abyss-deep: #4338ca;
  --color-abyss-glow: rgba(99, 102, 241, 0.45);

  /* Bảng màu chủ đạo - Cửa 03: Cơn Bão Lo Âu */
  --color-anxiety-main: #0ea5e9;
  --color-anxiety-deep: #0284c7;
  --color-anxiety-glow: rgba(14, 165, 233, 0.45);

  /* Bảng màu giải tỏa & bình an */
  --color-calm-main: #0284c7;
  --color-calm-light: #38bdf8;
  --color-calm-glow: rgba(56, 189, 248, 0.35);

  --color-connection-main: #10b981;
  --color-connection-light: #34d399;
  --color-connection-glow: rgba(16, 185, 129, 0.35);

  --color-gold: #f59e0b;
  --color-gold-light: #fef08a;

  --bg-dark: #0f172a;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-border: rgba(226, 232, 240, 0.8);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
  --shadow-glow-anger: 0 0 35px rgba(239, 68, 68, 0.6);
  --shadow-glow-abyss: 0 0 35px rgba(99, 102, 241, 0.6);
  --shadow-glow-anxiety: 0 0 35px rgba(14, 165, 233, 0.6);
  --shadow-glow-calm: 0 0 35px rgba(245, 158, 11, 0.5);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==================== RESET & CƠ BẢN ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: #0b0f19;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ==================== THEMES ==================== */
/* Theme Cửa 01: Đỏ rực tức giận */
body.theme-anger {
  background: radial-gradient(circle at 50% 20%, #450a0a 0%, #1e1111 60%, #0a0606 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 02: Tím lạnh thất vọng */
body.theme-abyss {
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 60%, #030712 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 03: Xanh bão cuộn trào lo âu */
body.theme-anxiety {
  background: radial-gradient(circle at 50% 20%, #0c4a6e 0%, #075985 35%, #0f172a 75%, #030712 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 04: Cam rực nắng sân bóng */
body.theme-blaze {
  background: radial-gradient(circle at 50% 20%, #7c2d12 0%, #431407 45%, #1c1917 80%, #09090b 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 05: Tím vòng tròn khép kín */
body.theme-circle {
  background: radial-gradient(circle at 50% 20%, #581c87 0%, #3b0764 45%, #0f172a 80%, #030712 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 06: Ngọc lam bản lĩnh tử tế */
body.theme-kindness {
  background: radial-gradient(circle at 50% 20%, #115e59 0%, #134e4a 45%, #0f172a 80%, #030712 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 07: Xám bạc khoảng lặng bên trong */
body.theme-solitude {
  background: radial-gradient(circle at 50% 20%, #334155 0%, #1e293b 45%, #0f172a 80%, #020617 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 08: Hổ phách áp lực kỳ vọng */
body.theme-burden {
  background: radial-gradient(circle at 50% 20%, #78350f 0%, #451a03 45%, #1c1917 80%, #09090b 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 09: Ngọc lục bảo bản lĩnh mở lời */
body.theme-voice {
  background: radial-gradient(circle at 50% 20%, #065f46 0%, #064e3b 45%, #0f172a 80%, #030712 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 10: Chàm đêm khuya trước màn hình */
body.theme-midnight {
  background: radial-gradient(circle at 50% 20%, #312e81 0%, #1e1b4b 45%, #0f172a 80%, #020617 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 11: Hồng thẫm gian bếp gia đình */
body.theme-hearth {
  background: radial-gradient(circle at 50% 20%, #881337 0%, #4c0519 45%, #1c1917 80%, #09090b 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme Cửa 12: Xanh da trời kết nối ngôi nhà */
body.theme-home {
  background: radial-gradient(circle at 50% 20%, #075985 0%, #0c4a6e 45%, #0f172a 80%, #020617 100%);
  transition: background 1.2s ease-in-out;
}

/* Theme khi mở khóa thành công: Vàng dịu & xanh ngọc hy vọng */
body.theme-calm {
  background: radial-gradient(circle at 50% 20%, #1c3127 0%, #0f1c24 60%, #060b11 100%);
  transition: background 1.2s ease-in-out;
}

/* ==================== HEADER / HUD ==================== */
.hud-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.hud-top-row {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.hud-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.hud-chapter-tag {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  letter-spacing: 0.3px;
  opacity: 0.9;
}

.hud-door-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #ffffff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  transition: var(--transition-smooth);
}

.theme-abyss .hud-badge {
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.theme-anxiety .hud-badge {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

.theme-blaze .hud-badge {
  background: linear-gradient(135deg, #f97316, #c2410c);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
}

.theme-circle .hud-badge {
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.4);
}

.theme-kindness .hud-badge {
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.4);
}

.theme-solitude .hud-badge {
  background: linear-gradient(135deg, #64748b, #475569);
  box-shadow: 0 2px 8px rgba(100, 116, 139, 0.4);
}

.theme-burden .hud-badge {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.theme-voice .hud-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.theme-midnight .hud-badge {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.theme-hearth .hud-badge {
  background: linear-gradient(135deg, #e11d48, #be123c);
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.4);
}

.theme-home .hud-badge {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.theme-calm .hud-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.hud-main-title {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.2px;
}

/* THANH ĐIỀU HƯỚNG 2 TẦNG: MỤC LỤC CHƯƠNG & CÁNH CỬA */
.hud-toc-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.chapter-nav-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  padding: 3px;
  max-width: 100%;
}

.chapter-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.chapter-nav-pill:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.chapter-nav-pill.active {
  background: rgba(251, 191, 36, 0.2);
  border-color: rgba(251, 191, 36, 0.55);
  color: #fef08a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.door-nav-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  padding: 3px;
  max-width: 100%;
}

.door-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.door-nav-pill:hover:not(.active) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  transition: var(--transition-smooth);
}

.door-nav-pill.active {
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.door-nav-pill[data-door-num="1"].active {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.door-nav-pill[data-door-num="1"].active .nav-dot {
  background: #fef2f2;
}

.door-nav-pill[data-door-num="2"].active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.door-nav-pill[data-door-num="2"].active .nav-dot {
  background: #e0e7ff;
}

.door-nav-pill[data-door-num="3"].active {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.door-nav-pill[data-door-num="3"].active .nav-dot {
  background: #e0f2fe;
}

.door-nav-pill[data-door-num="4"].active {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.door-nav-pill[data-door-num="4"].active .nav-dot {
  background: #ffedd5;
}

.door-nav-pill[data-door-num="5"].active {
  background: linear-gradient(135deg, #a855f7, #9333ea);
}

.door-nav-pill[data-door-num="5"].active .nav-dot {
  background: #f3e8ff;
}

.door-nav-pill[data-door-num="6"].active {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.door-nav-pill[data-door-num="6"].active .nav-dot {
  background: #ccfbf1;
}

.door-nav-pill[data-door-num="7"].active {
  background: linear-gradient(135deg, #64748b, #475569);
}

.door-nav-pill[data-door-num="7"].active .nav-dot {
  background: #f1f5f9;
}

.door-nav-pill[data-door-num="8"].active {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.door-nav-pill[data-door-num="8"].active .nav-dot {
  background: #fef3c7;
}

.door-nav-pill[data-door-num="9"].active {
  background: linear-gradient(135deg, #10b981, #059669);
}

.door-nav-pill[data-door-num="9"].active .nav-dot {
  background: #d1fae5;
}

.door-nav-pill[data-door-num="10"].active {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
}

.door-nav-pill[data-door-num="10"].active .nav-dot {
  background: #e0e7ff;
}

.door-nav-pill[data-door-num="11"].active {
  background: linear-gradient(135deg, #e11d48, #be123c);
}

.door-nav-pill[data-door-num="11"].active .nav-dot {
  background: #ffe4e6;
}

.door-nav-pill[data-door-num="12"].active {
  background: linear-gradient(135deg, #0284c7, #0369a1);
}

.door-nav-pill[data-door-num="12"].active .nav-dot {
  background: #e0f2fe;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: scale(0.96);
}

.hud-btn .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hud-btn-music.is-active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(125, 211, 252, 0.55);
  color: #e0f2fe;
}

.hud-btn-music.is-muted {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(241, 245, 249, 0.65);
}

/* THANH TRẠNG THÁI: BÌNH TĨNH & KẾT NỐI */
.hud-stats-row {
  max-width: 1300px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-card {
  position: relative;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 6px 12px;
}

.stat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
}

.stat-icon-wrap {
  font-size: 15px;
}

.stat-name {
  color: #cbd5e1;
}

.stat-numeric {
  margin-left: auto;
  font-family: monospace, var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
}

.stat-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.6s ease, box-shadow 0.6s ease;
  position: relative;
}

.stat-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmerLight 2.2s infinite;
}

@keyframes shimmerLight {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.fill-calm {
  background: linear-gradient(90deg, #0284c7, #38bdf8, #06b6d4);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.fill-connection {
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
}

/* 5 CẤP ĐỘ NHIỆT KẾ CẢM XÚC (0-20%, 21-40%, 41-60%, 61-80%, 81-100%) */
.stat-bar-fill.level-1 {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.stat-bar-fill.level-2 {
  background: linear-gradient(90deg, #ea580c, #f97316);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.55);
}

.stat-bar-fill.level-3 {
  background: linear-gradient(90deg, #ca8a04, #eab308);
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.55);
}

.fill-calm.level-4 {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.58);
}

.fill-connection.level-4 {
  background: linear-gradient(90deg, #65a30d, #84cc16);
  box-shadow: 0 0 10px rgba(132, 204, 22, 0.55);
}

.fill-calm.level-5 {
  background: linear-gradient(90deg, #0369a1, #06b6d4);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.68);
}

.fill-connection.level-5 {
  background: linear-gradient(90deg, #059669, #10b981);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.68);
}

/* SỐ NHẢY DELTA (+10, -30) */
.stat-delta-container {
  position: absolute;
  top: -8px;
  right: 12px;
  pointer-events: none;
}

.stat-delta-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  animation: deltaFloatUp 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.stat-delta-badge.positive {
  background: #10b981;
  color: #ffffff;
}

.stat-delta-badge.negative {
  background: #ef4444;
  color: #ffffff;
}

@keyframes deltaFloatUp {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.85);
  }
  20% {
    opacity: 1;
    transform: translateY(-4px) scale(1.15);
  }
  60% {
    opacity: 1;
    transform: translateY(-16px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) scale(0.9);
  }
}

/* ==================== BỐ CỤC CHÍNH (GAME LAYOUT) ==================== */
.game-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
  min-height: calc(100vh - 100px);
}

/* ==================== CỘT 1: SCENE VIEWPORT ==================== */
.scene-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 380px;
  max-height: 600px;
  background: #111422;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 1.2s ease;
}

.scene-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.scene-stage.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

.scene-svg-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* CÁC LỚP PHỦ HÀO QUANG CẢM XÚC */
.anger-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(239, 68, 68, 0.42) 0%, rgba(185, 28, 28, 0.25) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: heatPulsate 2.8s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 1;
}

.abyss-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(99, 102, 241, 0.46) 0%, rgba(67, 56, 202, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: abyssPulsate 3.4s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.anxiety-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(14, 165, 233, 0.48) 0%, rgba(2, 132, 199, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: stormPulsate 2.4s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.blaze-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(249, 115, 22, 0.46) 0%, rgba(194, 65, 12, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: heatPulsate 2.8s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.circle-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(168, 85, 247, 0.46) 0%, rgba(126, 34, 206, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: abyssPulsate 3.4s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.kindness-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(20, 184, 166, 0.46) 0%, rgba(15, 118, 110, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: stormPulsate 2.8s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.solitude-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(148, 163, 184, 0.42) 0%, rgba(71, 85, 105, 0.26) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: abyssPulsate 3.6s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.burden-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(245, 158, 11, 0.44) 0%, rgba(180, 83, 9, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: heatPulsate 2.9s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.voice-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(16, 185, 129, 0.45) 0%, rgba(5, 150, 105, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: stormPulsate 2.8s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.midnight-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(79, 70, 229, 0.46) 0%, rgba(55, 48, 163, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: abyssPulsate 3.2s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.hearth-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(225, 29, 72, 0.45) 0%, rgba(190, 18, 60, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: heatPulsate 2.8s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.home-glow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(2, 132, 199, 0.46) 0%, rgba(3, 105, 161, 0.28) 50%, transparent 80%);
  pointer-events: none;
  z-index: 5;
  animation: stormPulsate 2.9s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  transition: opacity 1.2s ease;
  opacity: 0;
}

.anger-glow-overlay,
.abyss-glow-overlay,
.anxiety-glow-overlay,
.blaze-glow-overlay,
.circle-glow-overlay,
.kindness-glow-overlay,
.solitude-glow-overlay,
.burden-glow-overlay,
.voice-glow-overlay,
.midnight-glow-overlay,
.hearth-glow-overlay,
.home-glow-overlay {
  opacity: 0;
}

.theme-anger .anger-glow-overlay { opacity: 1; }
.theme-abyss .abyss-glow-overlay { opacity: 1; }
.theme-anxiety .anxiety-glow-overlay { opacity: 1; }
.theme-blaze .blaze-glow-overlay { opacity: 1; }
.theme-circle .circle-glow-overlay { opacity: 1; }
.theme-kindness .kindness-glow-overlay { opacity: 1; }
.theme-solitude .solitude-glow-overlay { opacity: 1; }
.theme-burden .burden-glow-overlay { opacity: 1; }
.theme-voice .voice-glow-overlay { opacity: 1; }
.theme-midnight .midnight-glow-overlay { opacity: 1; }
.theme-hearth .hearth-glow-overlay { opacity: 1; }
.theme-home .home-glow-overlay { opacity: 1; }

@keyframes heatPulsate {
  0% { opacity: 0.65; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.02); }
}

@keyframes abyssPulsate {
  0% { opacity: 0.55; transform: scale(0.97); }
  100% { opacity: 0.95; transform: scale(1.03); }
}

@keyframes stormPulsate {
  0% { opacity: 0.5; transform: scale(0.97); filter: hue-rotate(0deg); }
  100% { opacity: 0.95; transform: scale(1.03); filter: hue-rotate(15deg); }
}

.warm-sunlight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 40%, rgba(254, 240, 138, 0.4) 0%, rgba(245, 158, 11, 0.2) 60%, transparent 90%);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.theme-calm .anger-glow-overlay,
.theme-calm .abyss-glow-overlay,
.theme-calm .anxiety-glow-overlay,
.theme-calm .blaze-glow-overlay,
.theme-calm .circle-glow-overlay,
.theme-calm .kindness-glow-overlay,
.theme-calm .solitude-glow-overlay,
.theme-calm .burden-glow-overlay,
.theme-calm .voice-glow-overlay,
.theme-calm .midnight-glow-overlay,
.theme-calm .hearth-glow-overlay,
.theme-calm .home-glow-overlay {
  opacity: 0 !important;
}

.theme-calm .warm-sunlight-overlay {
  opacity: 1;
}

/* LÀN SƯƠNG MÙ (MIST DRIFT) */
.mist-layer {
  position: absolute;
  width: 200%;
  height: 120px;
  bottom: 0;
  left: -50%;
  pointer-events: none;
  z-index: 8;
  opacity: 0.75;
  background: radial-gradient(ellipse at 50% 80%, rgba(248, 250, 252, 0.65) 0%, rgba(226, 232, 240, 0.3) 50%, transparent 80%);
  filter: blur(14px);
  animation: mistDrift 14s ease-in-out infinite alternate;
  transition: opacity 1s ease, transform 1s ease;
}

.theme-abyss .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(199, 210, 254, 0.65) 0%, rgba(129, 140, 248, 0.3) 50%, transparent 80%);
}

.theme-anxiety .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(186, 230, 253, 0.7) 0%, rgba(56, 189, 248, 0.3) 50%, transparent 80%);
}

.theme-blaze .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(254, 215, 170, 0.7) 0%, rgba(249, 115, 22, 0.3) 50%, transparent 80%);
}

.theme-circle .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(233, 213, 255, 0.68) 0%, rgba(168, 85, 247, 0.3) 50%, transparent 80%);
}

.theme-kindness .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(153, 246, 228, 0.68) 0%, rgba(20, 184, 166, 0.3) 50%, transparent 80%);
}

.theme-solitude .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(226, 232, 240, 0.68) 0%, rgba(100, 116, 139, 0.3) 50%, transparent 80%);
}

.theme-burden .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(253, 230, 138, 0.68) 0%, rgba(217, 119, 6, 0.3) 50%, transparent 80%);
}

.theme-voice .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(167, 243, 208, 0.68) 0%, rgba(16, 185, 129, 0.3) 50%, transparent 80%);
}

.theme-midnight .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(199, 210, 254, 0.65) 0%, rgba(79, 70, 229, 0.3) 50%, transparent 80%);
}

.theme-hearth .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(254, 205, 211, 0.65) 0%, rgba(225, 29, 72, 0.3) 50%, transparent 80%);
}

.theme-home .mist-layer {
  background: radial-gradient(ellipse at 50% 80%, rgba(186, 230, 253, 0.68) 0%, rgba(2, 132, 199, 0.3) 50%, transparent 80%);
}

.mist-top {
  bottom: 120px;
  height: 100px;
  opacity: 0.45;
  animation: mistDrift 18s ease-in-out infinite alternate-reverse;
}

.mist-dissolved {
  opacity: 0 !important;
  transform: translateY(40px) scale(0.8);
}

@keyframes mistDrift {
  0% { transform: translateX(-6%); }
  100% { transform: translateX(6%); }
}

/* HẠT TÀN LỬA / BỤI CẢM XÚC */
.ember-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.ember-spark {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #fca5a5;
  box-shadow: 0 0 6px #ef4444;
  border-radius: 50%;
  animation: emberRise 3.5s linear infinite;
}

.theme-abyss .ember-spark {
  background: #c7d2fe;
  box-shadow: 0 0 6px #818cf8;
}

.theme-anxiety .ember-spark {
  background: #bae6fd;
  box-shadow: 0 0 7px #38bdf8;
}

.theme-blaze .ember-spark {
  background: #fed7aa;
  box-shadow: 0 0 7px #f97316;
}

.theme-circle .ember-spark {
  background: #e9d5ff;
  box-shadow: 0 0 7px #a855f7;
}

.theme-kindness .ember-spark {
  background: #99f6e4;
  box-shadow: 0 0 7px #14b8a6;
}

.theme-solitude .ember-spark {
  background: #e2e8f0;
  box-shadow: 0 0 7px #64748b;
}

.theme-burden .ember-spark {
  background: #fde68a;
  box-shadow: 0 0 7px #d97706;
}

.theme-voice .ember-spark {
  background: #a7f3d0;
  box-shadow: 0 0 7px #10b981;
}

.theme-midnight .ember-spark {
  background: #c7d2fe;
  box-shadow: 0 0 7px #4f46e5;
}

.theme-hearth .ember-spark {
  background: #fecdd3;
  box-shadow: 0 0 7px #e11d48;
}

.theme-home .ember-spark {
  background: #bae6fd;
  box-shadow: 0 0 7px #0284c7;
}

@keyframes emberRise {
  0% {
    transform: translateY(100%) scale(0.6);
    opacity: 0;
  }
  30% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.7;
  }
  100% {
    transform: translateY(-80px) scale(0);
    opacity: 0;
  }
}

/* VẦNG HÀO QUANG SVG CHUYỂN ĐỘNG */
.pulse-halo {
  animation: haloPulse 3s ease-in-out infinite alternate;
  transform-origin: 400px 270px;
}

@keyframes haloPulse {
  0% { transform: scale(0.92); opacity: 0.65; }
  100% { transform: scale(1.08); opacity: 0.95; }
}

/* CÁNH CỬA GỖ 3D XOAY */
.door-perspective-wrap {
  position: absolute;
  top: 10.5%;
  left: 36.2%;
  width: 27.5%;
  height: 65.5%;
  perspective: 1100px;
  z-index: 10;
}

.door-leaf {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transition: transform 1.6s cubic-bezier(0.25, 1, 0.5, 1);
  transform-style: preserve-3d;
}

.door-open {
  transform: rotateY(-82deg) !important;
}

.door-ajar {
  transform: rotateY(-24deg) !important;
}

.door-inner-panel {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #78350f 0%, #9a3412 50%, #451a03 100%);
  border: 4px solid #3f1a04;
  border-radius: 6px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.7), 2px 0 10px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  position: relative;
}

.door-window {
  width: 75%;
  height: 25%;
  background: #1e293b;
  border: 3px solid #451a03;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
}

.door-window-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #ef4444 0%, transparent 70%);
  opacity: 0.8;
  animation: heatPulsate 2s infinite alternate;
  transition: background 0.8s ease;
}

.theme-abyss .door-window-glow {
  background: radial-gradient(circle, #8b5cf6 0%, #4338ca 70%);
  opacity: 0.85;
}

.theme-anxiety .door-window-glow {
  background: radial-gradient(circle, #38bdf8 0%, #0ea5e9 70%);
  opacity: 0.88;
}

.theme-blaze .door-window-glow {
  background: radial-gradient(circle, #fb923c 0%, #f97316 70%);
  opacity: 0.86;
}

.theme-circle .door-window-glow {
  background: radial-gradient(circle, #c084fc 0%, #a855f7 70%);
  opacity: 0.86;
}

.theme-kindness .door-window-glow {
  background: radial-gradient(circle, #2dd4bf 0%, #14b8a6 70%);
  opacity: 0.86;
}

.theme-solitude .door-window-glow {
  background: radial-gradient(circle, #94a3b8 0%, #64748b 70%);
  opacity: 0.84;
}

.theme-burden .door-window-glow {
  background: radial-gradient(circle, #fbbf24 0%, #d97706 70%);
  opacity: 0.86;
}

.theme-voice .door-window-glow {
  background: radial-gradient(circle, #34d399 0%, #10b981 70%);
  opacity: 0.86;
}

.theme-midnight .door-window-glow {
  background: radial-gradient(circle, #818cf8 0%, #4f46e5 70%);
  opacity: 0.86;
}

.theme-hearth .door-window-glow {
  background: radial-gradient(circle, #fb7185 0%, #e11d48 70%);
  opacity: 0.86;
}

.theme-home .door-window-glow {
  background: radial-gradient(circle, #38bdf8 0%, #0284c7 70%);
  opacity: 0.86;
}

.theme-calm .door-window-glow {
  background: radial-gradient(circle, #fde047 0%, #38bdf8 70%);
  opacity: 0.9;
}

.door-window-reflection {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 40%;
  background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);
  transform: rotate(-25deg);
}

.door-plate {
  margin-top: 10px;
  background: #0f172a;
  border: 1px solid #fbbf24;
  padding: 3px 8px;
  border-radius: 4px;
  text-align: center;
}

.door-plate-num {
  display: block;
  font-size: 8px;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 1px;
}

.door-plate-title {
  display: block;
  font-size: 7px;
  font-weight: 600;
  color: #ffffff;
}

.door-wood-grooves {
  width: 85%;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.groove-panel {
  width: 100%;
  height: 45px;
  border: 2px solid #3f1a04;
  background: rgba(0, 0, 0, 0.15);
  box-shadow: inset 1px 1px 4px rgba(0,0,0,0.6);
  border-radius: 3px;
}

.door-knob {
  position: absolute;
  right: 10px;
  top: 55%;
  width: 14px;
  height: 24px;
}

.knob-plate {
  width: 10px;
  height: 24px;
  background: #ca8a04;
  border-radius: 2px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.6);
}

.knob-handle {
  position: absolute;
  top: 4px;
  left: -5px;
  width: 14px;
  height: 6px;
  background: #eab308;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* 2 Ổ KHÓA SƯƠNG MÙ TREO TRÊN CỬA */
.locks-overlay {
  position: absolute;
  top: 36%;
  left: 31%;
  width: 38%;
  display: flex;
  justify-content: space-around;
  z-index: 20;
  pointer-events: none;
}

.lock-token {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.lock-chains {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: -3px;
}

.chain-link {
  width: 6px;
  height: 10px;
  border: 2px solid #cbd5e1;
  border-radius: 3px;
  margin-top: -3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.lock-body-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lock-shackle {
  width: 22px;
  height: 16px;
  border: 4px solid #94a3b8;
  border-bottom: none;
  border-top-left-radius: 11px;
  border-top-right-radius: 11px;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: left bottom;
}

.lock-body {
  width: 64px;
  padding: 6px 4px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid #ef4444;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(239, 68, 68, 0.4);
  text-align: center;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.theme-abyss .lock-body {
  border-color: #8b5cf6;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(139, 92, 246, 0.4);
}

.theme-anxiety .lock-body {
  border-color: #0ea5e9;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(14, 165, 233, 0.4);
}

.theme-blaze .lock-body {
  border-color: #f97316;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(249, 115, 22, 0.4);
}

.theme-circle .lock-body {
  border-color: #a855f7;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(168, 85, 247, 0.4);
}

.theme-kindness .lock-body {
  border-color: #14b8a6;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(20, 184, 166, 0.4);
}

.theme-solitude .lock-body {
  border-color: #64748b;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(100, 116, 139, 0.4);
}

.theme-burden .lock-body {
  border-color: #d97706;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(217, 119, 6, 0.4);
}

.theme-voice .lock-body {
  border-color: #10b981;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(16, 185, 129, 0.4);
}

.theme-midnight .lock-body {
  border-color: #4f46e5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(79, 70, 229, 0.4);
}

.theme-hearth .lock-body {
  border-color: #e11d48;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(225, 29, 72, 0.4);
}

.theme-home .lock-body {
  border-color: #0284c7;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(2, 132, 199, 0.4);
}

.lock-svg {
  width: 18px;
  height: 18px;
  color: #ef4444;
  margin-bottom: 2px;
}

.theme-abyss .lock-svg { color: #a78bfa; }
.theme-anxiety .lock-svg { color: #38bdf8; }
.theme-blaze .lock-svg { color: #fb923c; }
.theme-circle .lock-svg { color: #c084fc; }
.theme-kindness .lock-svg { color: #2dd4bf; }
.theme-solitude .lock-svg { color: #94a3b8; }
.theme-burden .lock-svg { color: #fbbf24; }
.theme-voice .lock-svg { color: #34d399; }
.theme-midnight .lock-svg { color: #818cf8; }
.theme-hearth .lock-svg { color: #fb7185; }
.theme-home .lock-svg { color: #38bdf8; }

.lock-label {
  font-size: 8.5px;
  font-weight: 700;
  color: #f1f5f9;
}

.lock-sub {
  font-size: 7.5px;
  color: #94a3b8;
  white-space: nowrap;
}

/* TRẠNG THÁI KHÓA ĐƯỢC MỞ */
.lock-token.unlocked .lock-shackle {
  transform: translateY(-5px) rotate(-35deg);
  border-color: #34d399;
}

.lock-token.unlocked .lock-body {
  border-color: #10b981 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.6) !important;
}

.lock-token.unlocked .lock-svg {
  color: #34d399 !important;
}

.lock-token.unlocked {
  animation: unlockFloating 2s ease-in-out infinite alternate;
}

@keyframes unlockFloating {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.lock-sparkle-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, #34d399 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.sparkle-animate {
  animation: sparklePop 0.8s ease-out forwards;
}

@keyframes sparklePop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.6); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

.pulse-usb {
  animation: usbBlink 1.4s infinite;
}

@keyframes usbBlink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; filter: drop-shadow(0 0 5px #38bdf8); }
}

/* ==================== CỘT 2: DIALOGUE & INTERACTION PANEL ==================== */
.dialogue-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialogue-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--bg-card-border);
  transition: var(--transition-smooth);
  animation: cardFadeIn 0.5s ease;
}

.dialogue-card.hidden {
  display: none !important;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialogue-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.step-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: #fee2e2;
  color: #b91c1c;
}

.theme-abyss .step-tag { background: #ede9fe; color: #5b21b6; }
.theme-anxiety .step-tag { background: #e0f2fe; color: #0284c7; }
.theme-blaze .step-tag { background: #ffedd5; color: #c2410c; }
.theme-circle .step-tag { background: #f3e8ff; color: #7e22ce; }
.theme-kindness .step-tag { background: #ccfbf1; color: #0f766e; }
.theme-solitude .step-tag { background: #f1f5f9; color: #475569; }
.theme-burden .step-tag { background: #fef3c7; color: #b45309; }
.theme-voice .step-tag { background: #d1fae5; color: #047857; }
.theme-midnight .step-tag { background: #e0e7ff; color: #3730a3; }
.theme-hearth .step-tag { background: #ffe4e6; color: #be123c; }
.theme-home .step-tag { background: #e0f2fe; color: #0369a1; }

.step-tag.lock-tag {
  background: #e0f2fe;
  color: #0369a1;
}

.step-tag.success-tag {
  background: #dcfce7;
  color: #15803d;
}

.step-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.q-progress-indicator {
  font-size: 12px;
  font-weight: 600;
  color: #0284c7;
}

/* DÒNG SUY NGHĨ (THOUGHT BUBBLE) */
.thought-bubble {
  display: flex;
  gap: 14px;
  background: linear-gradient(135deg, #fff1f2 0%, #fff7ed 100%);
  border-left: 4px solid #ef4444;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.theme-abyss .thought-bubble {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-left-color: #8b5cf6;
}

.theme-anxiety .thought-bubble {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left-color: #0ea5e9;
}

.theme-blaze .thought-bubble {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-left-color: #f97316;
}

.theme-circle .thought-bubble {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-left-color: #a855f7;
}

.theme-kindness .thought-bubble {
  background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
  border-left-color: #14b8a6;
}

.theme-solitude .thought-bubble {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-left-color: #64748b;
}

.theme-burden .thought-bubble {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-left-color: #d97706;
}

.theme-voice .thought-bubble {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-left-color: #10b981;
}

.theme-midnight .thought-bubble {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-left-color: #4f46e5;
}

.theme-hearth .thought-bubble {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-left-color: #e11d48;
}

.theme-home .thought-bubble {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left-color: #0284c7;
}

.thought-icon {
  font-size: 24px;
  line-height: 1;
}

.thought-heading {
  font-size: 13px;
  font-weight: 700;
  color: #b91c1c;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.theme-abyss .thought-heading { color: #5b21b6; }
.theme-anxiety .thought-heading { color: #0284c7; }
.theme-blaze .thought-heading { color: #c2410c; }
.theme-circle .thought-heading { color: #7e22ce; }
.theme-kindness .thought-heading { color: #0f766e; }
.theme-solitude .thought-heading { color: #475569; }
.theme-burden .thought-heading { color: #b45309; }
.theme-voice .thought-heading { color: #047857; }
.theme-midnight .thought-heading { color: #3730a3; }
.theme-hearth .thought-heading { color: #be123c; }
.theme-home .thought-heading { color: #0369a1; }

.thought-text {
  font-size: 15px;
  color: #334155;
  font-style: italic;
  line-height: 1.6;
}

/* BỐI CẢNH & NHIỆM VỤ */
.context-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.context-desc strong {
  color: #b91c1c;
}

.theme-abyss .context-desc strong { color: #5b21b6; }
.theme-anxiety .context-desc strong { color: #0284c7; }
.theme-blaze .context-desc strong { color: #c2410c; }
.theme-circle .context-desc strong { color: #7e22ce; }
.theme-kindness .context-desc strong { color: #0f766e; }
.theme-solitude .context-desc strong { color: #475569; }
.theme-burden .context-desc strong { color: #b45309; }
.theme-voice .context-desc strong { color: #047857; }
.theme-midnight .context-desc strong { color: #3730a3; }
.theme-hearth .context-desc strong { color: #be123c; }
.theme-home .context-desc strong { color: #0369a1; }

.mission-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 14px;
  color: #166534;
}

.mission-icon {
  font-size: 20px;
}

/* CÂU HỎI LÀM RÕ */
.question-header {
  margin-bottom: 20px;
}

.question-theme {
  font-size: 14px;
  font-weight: 700;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.question-prompt {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.5;
}

/* DANH SÁCH LỰA CHỌN (OPTIONS) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
  width: 100%;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.option-item:focus {
  outline: none;
}

.option-item:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .option-item:hover:not(:disabled) {
    border-color: #38bdf8;
    background: #f0f9ff;
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
  }
}

.option-item:active:not(:disabled) {
  transform: scale(0.99);
}

.option-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  color: #475569;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

@media (hover: hover) and (pointer: fine) {
  .option-item:hover:not(:disabled) .option-badge {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
  }
}

.option-text {
  font-size: 15px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.55;
  flex-grow: 1;
}

/* TRẠNG THÁI OPTION SAU KHI CHỌN */
.option-item.selected-correct {
  border-color: #10b981;
  background: #f0fdf4;
}

.option-item.selected-correct .option-badge {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

.option-item.selected-wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.option-item.selected-wrong .option-badge {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.option-item:disabled {
  cursor: default;
  opacity: 0.75;
}

/* HỘP PHẢN HỒI (FEEDBACK CARD) */
.feedback-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-md);
  margin-top: 14px;
  animation: cardFadeIn 0.4s ease;
}

.feedback-card.correct {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
}

.feedback-card.wrong {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
}

.feedback-content {
  flex-grow: 1;
}

.feedback-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.feedback-card.correct .feedback-title {
  color: #15803d;
}

.feedback-card.wrong .feedback-title {
  color: #b45309;
}

.feedback-message {
  font-size: 14.5px;
  line-height: 1.6;
  color: #334155;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* GIAI ĐOẠN 3: HÀNH ĐỘNG TRONG LỚP */
.stage3-story-box {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 4px solid #0284c7;
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.stage3-story-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.stage3-description {
  font-size: 15.5px;
  color: #0f172a;
  line-height: 1.6;
}

.action-choice-prompt {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 14px;
}

.stage3-choices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-item-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.choice-item-btn:hover {
  border-color: #0284c7;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.choice-item-btn:active {
  transform: scale(0.99);
}

.choice-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.choice-text {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.5;
}

/* ==================== MÀN HÌNH KẾT CỤC (ENDING) ==================== */
.ending-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
}

.ending-badge-wrap {
  margin-bottom: 8px;
}

.ending-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: var(--radius-full);
}

.ending-card.danger .ending-badge {
  background: #fee2e2;
  color: #dc2626;
}

.ending-card.warning .ending-badge {
  background: #fef3c7;
  color: #d97706;
}

.ending-card.success .ending-badge {
  background: #dcfce7;
  color: #16a34a;
}

.ending-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 14px;
}

.ending-card.danger .ending-title {
  color: #b91c1c;
}

.ending-card.warning .ending-title {
  color: #b45309;
}

.ending-card.success .ending-title {
  color: #15803d;
}

.ending-stats-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.end-stat-pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.ending-narrative {
  font-size: 15.5px;
  color: #1e293b;
  line-height: 1.65;
  margin-bottom: 16px;
}

.ending-suggestion-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.suggestion-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.suggestion-text {
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

/* HÀNH TRÌNH LỰA CHỌN CỦA CON (CHOICE HISTORY) */
.choice-history-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.choice-history-heading {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.choice-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: #ffffff;
  border-left: 3px solid #0284c7;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.history-stage-badge {
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
}

.history-choice-text {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.45;
}

/* XEM TRƯỚC VÀ NÚT CHUYỂN CÁNH CỬA */
.next-door-teaser {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border: 1.5px solid #a5b4fc;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.teaser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.teaser-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: #4338ca;
  text-transform: uppercase;
}

.teaser-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #4338ca;
  color: #ffffff;
}

.next-door-teaser h4 {
  font-size: 16px;
  color: #1e1b4b;
  font-weight: 700;
}

.next-door-teaser p {
  font-size: 13.5px;
  color: #4338ca;
  line-height: 1.5;
  margin-bottom: 6px;
}

.btn-next-door {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
}

.btn-next-door:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.55);
}

/* KHUNG CHÚC MỪNG HOÀN THÀNH TOÀN BỘ 3 CÁNH CỬA (GRAND FINISH) */
.grand-finish-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 40%, #e0f2fe 100%);
  border: 2px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.25);
  animation: cardFadeIn 0.6s ease;
}

.grand-finish-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

.grand-finish-title {
  font-size: 18px;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 6px;
  line-height: 1.4;
}

.grand-finish-desc {
  font-size: 14px;
  color: #451a03;
  margin-bottom: 16px;
}

.grand-badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.grand-badge-item {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 10px;
  border: 1.5px solid #e2e8f0;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.grand-badge-item .badge-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}

.grand-badge-item strong {
  display: block;
  font-size: 12px;
  color: #0f172a;
  margin-bottom: 4px;
}

.grand-badge-item p {
  font-size: 10.5px;
  color: #64748b;
  line-height: 1.35;
}

.grand-badge-item.badge-anger { border-color: #fca5a5; }
.grand-badge-item.badge-abyss { border-color: #c7d2fe; }
.grand-badge-item.badge-anxiety { border-color: #bae6fd; }
.grand-badge-item.badge-blaze { border-color: #fdba74; }
.grand-badge-item.badge-circle { border-color: #d8b4fe; }
.grand-badge-item.badge-kindness { border-color: #5eead4; }
.grand-badge-item.badge-solitude { border-color: #cbd5e1; }
.grand-badge-item.badge-burden { border-color: #fcd34d; }
.grand-badge-item.badge-voice { border-color: #6ee7b7; }
.grand-badge-item.badge-midnight { border-color: #a5b4fc; }
.grand-badge-item.badge-hearth { border-color: #fda4af; }
.grand-badge-item.badge-home { border-color: #7dd3fc; }

.btn-replay-all {
  width: 100%;
  font-size: 15px;
}

.ending-actions {
  display: flex;
  gap: 12px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-pulse {
  animation: btnPulseGlow 2.5s infinite;
}

@keyframes btnPulseGlow {
  0%, 100% { box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4); }
  50% { box-shadow: 0 4px 22px rgba(56, 189, 248, 0.7); }
}

.btn-outline {
  background: transparent;
  border: 1.5px solid #cbd5e1;
  color: #475569;
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
}

.btn-arrow {
  width: 18px;
  height: 18px;
}

.btn-restart {
  width: 100%;
}

.btn-restart .icon {
  width: 18px;
  height: 18px;
}

/* ==================== TIỆN ÍCH ==================== */
.hidden {
  display: none !important;
}

/* ===================================================================
   RESPONSIVE DESIGN CHO MÁY CHIẾU LỚP HỌC VÀ ĐIỆN THOẠI DI ĐỘNG
   =================================================================== */

@media (min-width: 1200px) {
  .hud-main-title {
    font-size: 19px;
  }
  .stat-card {
    padding: 8px 16px;
  }
  .stat-numeric {
    font-size: 15px;
  }
  .question-prompt {
    font-size: 20px;
  }
  .thought-text {
    font-size: 16px;
  }
}

@media (max-width: 1199px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .scene-viewport {
    max-height: 440px;
  }
  .grand-badges-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .hud-header {
    padding: 8px 12px;
  }
  
  .hud-top-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .hud-title-wrap {
    flex-grow: 1;
  }

  .hud-main-title {
    font-size: 14.5px;
  }

  .hud-toc-nav {
    order: 3;
    width: 100%;
    margin-top: 2px;
  }

  .chapter-nav-pill {
    padding: 4px 10px;
    font-size: 11px;
  }

  .door-nav-pill {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .hud-btn .btn-label {
    display: none;
  }

  .hud-btn {
    padding: 6px 8px;
  }

  .hud-stats-row {
    gap: 8px;
  }

  .stat-card {
    padding: 5px 8px;
  }

  .stat-meta {
    font-size: 11.5px;
  }

  .stat-numeric {
    font-size: 12.5px;
  }

  .game-layout {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 14px;
  }

  .scene-viewport {
    aspect-ratio: 16 / 11;
    min-height: 250px;
    border-radius: var(--radius-md);
  }

  .dialogue-card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .question-prompt {
    font-size: 16px;
  }

  .option-item {
    padding: 12px;
    gap: 10px;
  }

  .option-text {
    font-size: 14px;
  }

  .grand-badges-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .btn {
    padding: 10px 18px;
    font-size: 14px;
  }
}

/* ==================== TRANG MỞ ĐẦU (SPLASH / TITLE SCREEN) ==================== */
body.is-splash-active {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.is-splash-active .hud-header,
body.is-splash-active .game-layout {
  display: none;
}

.splash-screen {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3.5vw, 40px) 20px;
  background: radial-gradient(circle at 50% 34%, #fffbeb 0%, #fef3c7 38%, #e0f2fe 78%, #dbeafe 100%);
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.splash-screen.is-leaving {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.splash-screen.hidden {
  display: none;
}

.splash-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.splash-sun-glow {
  position: absolute;
  top: 42%;
  left: 50%;
  width: min(760px, 110vw);
  height: min(760px, 110vw);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(251, 191, 36, 0.32) 0%, rgba(253, 224, 71, 0.14) 38%, rgba(255, 255, 255, 0) 72%);
  animation: splashSunPulse 5.5s ease-in-out infinite;
}

@keyframes splashSunPulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(0.97);
    opacity: 0.85;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
}

.splash-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 3vh, 28px);
}

.splash-door-stage {
  display: flex;
  justify-content: center;
  align-items: center;
}

.splash-door-trigger {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  outline: none;
  user-select: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.splash-door-trigger:hover,
.splash-door-trigger:focus-visible {
  transform: translateY(-4px);
}

.splash-door-trigger:focus-visible .splash-door-frame {
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.45), 0 24px 48px rgba(120, 53, 15, 0.28);
}

/* Biển lớp SEL07 trên khung cửa mở đầu */
.splash-door-plaque {
  background: #0f172a;
  color: #fef08a;
  border: 2px solid #fbbf24;
  border-radius: 6px;
  padding: 4px 16px;
  font-size: clamp(11px, 1.5vw, 13px);
  font-weight: 800;
  letter-spacing: 1.4px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
  margin-bottom: 8px;
  z-index: 3;
}

/* Khung cửa lớp học ấm áp */
.splash-door-frame {
  position: relative;
  width: clamp(156px, 28vw, 210px);
  height: clamp(232px, 40vh, 305px);
  padding: 10px 10px 0 10px;
  border-radius: 14px 14px 4px 4px;
  background: linear-gradient(180deg, #451a03 0%, #291102 100%);
  border: 3px solid #78350f;
  box-shadow: 0 22px 44px rgba(120, 53, 15, 0.24), 0 0 36px rgba(251, 191, 36, 0.28);
  perspective: 1000px;
  overflow: hidden;
}

/* Ánh sáng ấm bên trong lớp học khi cửa hé mở */
.splash-door-interior-light {
  position: absolute;
  inset: 10px 10px 0 10px;
  border-radius: 6px 6px 0 0;
  background: radial-gradient(circle at 35% 40%, #fffbeb 0%, #fde68a 45%, #f59e0b 100%);
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.85);
}

/* Cánh cửa gỗ 3D */
.splash-door-leaf {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(160deg, #b45309 0%, #92400e 45%, #78350f 100%);
  border: 2px solid #d97706;
  box-shadow: inset 0 2px 10px rgba(254, 243, 199, 0.25);
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 14px 14px;
  gap: 14px;
}

.splash-door-trigger:hover .splash-door-leaf,
.splash-door-trigger:focus-visible .splash-door-leaf {
  transform: rotateY(-16deg);
  box-shadow: 8px 0 20px rgba(120, 53, 15, 0.25);
}

.splash-door-trigger.is-opening .splash-door-leaf {
  transform: rotateY(-58deg);
}

/* Ô kính sáng trên cánh cửa */
.splash-door-window {
  position: relative;
  width: 68%;
  height: 36%;
  border-radius: 6px;
  background: linear-gradient(145deg, #fef9c3 0%, #fde68a 55%, #fcd34d 100%);
  border: 3px solid #451a03;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.8), 0 0 16px rgba(254, 240, 138, 0.55);
  overflow: hidden;
}

.splash-door-window-sun {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 65% 30%, rgba(255, 255, 255, 0.9) 0%, rgba(254, 240, 138, 0.2) 65%);
}

.splash-door-window-shine {
  position: absolute;
  top: -20%;
  left: -30%;
  width: 48%;
  height: 150%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.45) 50%, rgba(255, 255, 255, 0) 100%);
  transform: rotate(22deg);
}

.splash-door-panel-lower {
  width: 72%;
  flex: 1;
  border-radius: 4px;
  border: 2px solid rgba(251, 191, 36, 0.28);
  background: linear-gradient(180deg, rgba(120, 53, 15, 0.35) 0%, rgba(69, 26, 3, 0.4) 100%);
}

/* Tay nắm cửa đồng */
.splash-door-knob {
  position: absolute;
  right: 12px;
  top: 52%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fef08a 0%, #f59e0b 65%, #b45309 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Tiêu đề & dòng phụ */
.splash-text-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.splash-title {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.18;
  color: #1e293b;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.8);
}

.splash-subtitle {
  font-family: var(--font-sans);
  font-size: clamp(0.72rem, 3.1vw, 1.05rem);
  font-weight: 500;
  color: #475569;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .splash-subtitle {
    font-size: clamp(0.68rem, 3.1vw, 0.88rem);
    letter-spacing: 0;
  }
}

/* Nút bắt đầu */
.splash-actions {
  margin-top: 2px;
}

.btn-splash-enter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: clamp(13px, 2vw, 16px) clamp(26px, 4vw, 36px);
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: clamp(15px, 2vw, 17px);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(217, 119, 6, 0.32), 0 2px 6px rgba(15, 23, 42, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.btn-splash-enter:hover,
.btn-splash-enter:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(217, 119, 6, 0.42), 0 4px 10px rgba(15, 23, 42, 0.15);
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  outline: none;
}

.btn-splash-enter:active {
  transform: translateY(0);
}

.splash-enter-arrow {
  display: inline-block;
  font-size: 1.15em;
  transition: transform 0.25s ease;
}

.btn-splash-enter:hover .splash-enter-arrow {
  transform: translateX(4px);
}

@media (max-height: 680px) {
  .splash-content {
    gap: 14px;
  }

  .splash-door-frame {
    height: clamp(185px, 34vh, 240px);
    width: clamp(130px, 24vw, 172px);
  }
}

/* ==================== TIẾN ĐỘ 12 CÁNH CỬA & NÚT LỜI TRI ÂN ==================== */
.toc-chapter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.toc-progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.toc-progress-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.btn-gratitude-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.btn-gratitude-nav.is-locked {
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(203, 213, 225, 0.4);
  color: #cbd5e1;
}

.btn-gratitude-nav.is-locked:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.btn-gratitude-nav.is-unlocked {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: 1px solid #fde68a;
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.45);
  animation: btnPulseGlow 2.4s infinite;
}

.btn-gratitude-nav.is-unlocked:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
}

.door-nav-pill.is-completed .nav-dot {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.75);
}

.nav-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #6ee7b7;
  margin-left: 1px;
}

.door-nav-pill.active .nav-check {
  color: #ffffff;
}

/* ==================== THÔNG BÁO TIẾN ĐỘ & CTA LỜI TRI ÂN TRONG MÀN KẾT CỤC ==================== */
.ending-progress-notice {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.ending-gratitude-cta {
  margin: 14px 0;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #fbbf24;
  text-align: center;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.18);
}

.gratitude-cta-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.gratitude-cta-desc {
  font-size: 13.5px;
  color: #78350f;
  margin-bottom: 12px;
  line-height: 1.5;
}

.btn-open-gratitude {
  width: 100%;
}

/* ==================== TOAST THÔNG BÁO NHẸ ==================== */
.toc-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  max-width: min(92vw, 480px);
  padding: 11px 18px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fef3c7;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

/* ==================== TRANG KẾT HÀNH TRÌNH: LỜI CHÚC MỪNG & TRI ÂN ==================== */
body.is-gratitude-active {
  overflow-x: hidden;
  background: #fffbeb;
}

body.is-gratitude-active .hud-header,
body.is-gratitude-active .game-layout,
body.is-gratitude-active .splash-screen {
  display: none;
}

.gratitude-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px) 16px;
  background: radial-gradient(circle at 50% 18%, #fffdf5 0%, #fef6e4 38%, #fdecc8 72%, #e0f2fe 100%);
  overflow-x: hidden;
}

/* Hạt sáng thời gian trôi chậm rãi (CSS thuần) */
.gratitude-light-motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.light-mote {
  position: absolute;
  bottom: -24px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(251, 191, 36, 0.55) 55%, rgba(245, 158, 11, 0) 100%);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
  opacity: 0;
  animation: floatLightMote 11s ease-in-out infinite;
}

.light-mote:nth-child(1)  { left: 8%;  width: 8px;  height: 8px;  animation-duration: 10s; animation-delay: 0s; }
.light-mote:nth-child(2)  { left: 18%; width: 12px; height: 12px; animation-duration: 13s; animation-delay: 1.5s; }
.light-mote:nth-child(3)  { left: 28%; width: 6px;  height: 6px;  animation-duration: 9s;  animation-delay: 3s; }
.light-mote:nth-child(4)  { left: 39%; width: 10px; height: 10px; animation-duration: 12s; animation-delay: 0.8s; }
.light-mote:nth-child(5)  { left: 50%; width: 14px; height: 14px; animation-duration: 15s; animation-delay: 2.2s; }
.light-mote:nth-child(6)  { left: 61%; width: 7px;  height: 7px;  animation-duration: 10.5s; animation-delay: 4s; }
.light-mote:nth-child(7)  { left: 72%; width: 11px; height: 11px; animation-duration: 13.5s; animation-delay: 1.2s; }
.light-mote:nth-child(8)  { left: 82%; width: 6px;  height: 6px;  animation-duration: 9.5s; animation-delay: 2.8s; }
.light-mote:nth-child(9)  { left: 91%; width: 10px; height: 10px; animation-duration: 12.5s; animation-delay: 0.5s; }
.light-mote:nth-child(10) { left: 45%; width: 8px;  height: 8px;  animation-duration: 14s; animation-delay: 5s; }

@keyframes floatLightMote {
  0% {
    transform: translateY(0) translateX(0) scale(0.7);
    opacity: 0;
  }
  18% {
    opacity: 0.75;
  }
  55% {
    transform: translateY(-48vh) translateX(18px) scale(1);
    opacity: 0.65;
  }
  100% {
    transform: translateY(-102vh) translateX(-14px) scale(0.6);
    opacity: 0;
  }
}

.gratitude-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 960px;
  background: rgba(255, 253, 248, 0.9);
  border: 1.5px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 44px);
  box-shadow: 0 24px 60px rgba(120, 53, 15, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
}

/* Hiệu ứng giở từng trang nhật ký */
@keyframes journalReveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gratitude-screen.is-revealed .gratitude-tier-1,
.gratitude-screen.is-revealed .gratitude-tier-2 .gratitude-card,
.gratitude-screen.is-revealed .gratitude-tier-3,
.gratitude-screen.is-revealed .gratitude-tier-4 {
  opacity: 0;
  animation: journalReveal 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.gratitude-screen.is-revealed .gratitude-tier-1 { animation-delay: 0.08s; }
.gratitude-screen.is-revealed .gratitude-tier-2 .gratitude-card:nth-child(1) { animation-delay: 0.25s; }
.gratitude-screen.is-revealed .gratitude-tier-2 .gratitude-card:nth-child(2) { animation-delay: 0.42s; }
.gratitude-screen.is-revealed .gratitude-tier-2 .gratitude-card:nth-child(3) { animation-delay: 0.58s; }
.gratitude-screen.is-revealed .gratitude-tier-3 { animation-delay: 0.76s; }
.gratitude-screen.is-revealed .gratitude-tier-4 { animation-delay: 0.94s; }

.gratitude-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.gratitude-illustration-wrap {
  width: 100%;
  max-width: 360px;
  margin-bottom: 6px;
  border-radius: 18px;
  padding: 5px;
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.95), rgba(251, 191, 36, 0.45));
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.22), 0 4px 12px rgba(15, 23, 42, 0.08);
}

.gratitude-illustration {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  object-fit: cover;
}

.gratitude-kicker {
  display: inline-block;
  padding: 5px 15px;
  border-radius: var(--radius-full);
  background: #0f172a;
  color: #fef08a;
  border: 1.5px solid #fbbf24;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.1px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

.gratitude-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 4vw, 37px);
  font-weight: 700;
  line-height: 1.25;
  color: #1e293b;
}

.gratitude-lead {
  max-width: 720px;
  font-size: clamp(14.5px, 2vw, 16.5px);
  font-weight: 500;
  color: #1e293b;
  line-height: 1.72;
}

.gratitude-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: left;
  align-items: stretch;
}

.gratitude-card {
  height: 100%;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 22px 20px;
  border: 1.5px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.gratitude-card:not(.is-opened) {
  animation: cardBreathGlow 3.2s ease-in-out infinite;
}

@keyframes cardBreathGlow {
  0%, 100% { box-shadow: 0 6px 18px rgba(245, 158, 11, 0.08); }
  50% { box-shadow: 0 10px 26px rgba(245, 158, 11, 0.24), 0 0 0 2px rgba(251, 191, 36, 0.32); }
}

.gratitude-card:hover,
.gratitude-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(217, 119, 6, 0.16), 0 0 0 2px rgba(251, 191, 36, 0.45);
}

.gratitude-card.is-opened {
  cursor: default;
  animation: none;
}

.gratitude-card-hint {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: rgba(254, 243, 199, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.gratitude-card.is-opened .gratitude-card-hint {
  display: none;
}

.gratitude-friends { border-color: #bae6fd; background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%); }
.gratitude-teachers { border-color: #bbf7d0; background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%); }
.gratitude-parents { border-color: #fde68a; background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%); }

.gratitude-card-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.gratitude-card-icon {
  font-size: 22px;
  line-height: 1;
}

.gratitude-card h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
}

.gratitude-card-sub {
  display: inline-block;
  margin-top: 3px;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  line-height: 1.35;
}

.gratitude-card p {
  font-size: 13.8px;
  font-weight: 500;
  color: #292524;
  line-height: 1.68;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(6px);
  transition: max-height 0.5s ease, opacity 0.45s ease, transform 0.45s ease;
}

.gratitude-card.is-opened p {
  max-height: 320px;
  opacity: 1;
  transform: translateY(0);
}

/* Tầng 3: Khung tự vấn trung tâm với viền ánh vàng mềm mại */
.gratitude-reflection-box {
  position: relative;
  margin: 2px auto 0;
  max-width: 760px;
  padding: 16px 22px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.72) 0%, rgba(254, 243, 199, 0.55) 100%);
  border: 1.5px dashed rgba(217, 119, 6, 0.45);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.08);
  transition: padding 0.45s ease, box-shadow 0.55s ease, border-color 0.55s ease, background 0.55s ease;
}

.gratitude-reflection-box:not(.is-unlocked) .reflection-spark,
.gratitude-reflection-box:not(.is-unlocked) .gratitude-closing-quote {
  display: none;
}

.gratitude-reflection-box.is-unlocked {
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.98) 0%, rgba(254, 243, 199, 0.85) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.82);
  box-shadow: 0 12px 34px rgba(245, 158, 11, 0.24), inset 0 0 28px rgba(255, 255, 255, 0.78);
}

.gratitude-reflection-box.is-unlocked .reflection-spark,
.gratitude-reflection-box.is-unlocked .gratitude-closing-quote {
  display: block;
  animation: journalReveal 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reflection-lock-hint {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin: 0;
}

.gratitude-reflection-box.is-unlocked .reflection-lock-hint {
  display: none;
}

.reflection-spark {
  display: inline-block;
  font-size: 16px;
  color: #d97706;
  margin-bottom: 6px;
}

.gratitude-closing-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(15.5px, 2vw, 18.5px);
  font-weight: 600;
  color: #451a03;
  line-height: 1.62;
}

.gratitude-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.gratitude-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.gratitude-reset-row {
  margin-top: 2px;
}

.btn-reset-progress {
  background: transparent;
  border: none;
  color: #64748b;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s ease;
}

.btn-reset-progress:hover {
  color: #dc2626;
}

@media (max-width: 768px) {
  .gratitude-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .gratitude-actions {
    flex-direction: column;
  }

  .gratitude-actions .btn {
    width: 100%;
  }
}

/* ==================== THÔNG ĐIỆP KHÉP CHƯƠNG & HIỆU ỨNG GÕ MÁY ==================== */
.ending-chapter-closing-cta {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.96) 0%, rgba(254, 243, 199, 0.92) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.55);
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chapter-closing-cta-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: #0f172a;
  color: #fef08a;
  border: 1px solid #fbbf24;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.chapter-closing-cta-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #451a03;
}

.btn-open-chapter-closing {
  width: 100%;
  max-width: 360px;
  justify-content: center;
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  border-color: #b45309;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.28);
}

.btn-open-chapter-closing:hover {
  background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
}

body.is-chapter-closing-active {
  overflow-x: hidden;
  background: #fffbeb;
}

body.is-chapter-closing-active .hud-header,
body.is-chapter-closing-active .game-layout,
body.is-chapter-closing-active .splash-screen,
body.is-chapter-closing-active .gratitude-screen {
  display: none;
}

.chapter-closing-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px) 16px;
  background: radial-gradient(circle at 50% 20%, #fffdf7 0%, #fef6e4 42%, #fde68a 100%);
  overflow-x: hidden;
}

.chapter-closing-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 760px;
  background: rgba(255, 253, 248, 0.94);
  border: 1.5px solid rgba(245, 158, 11, 0.48);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4.5vw, 46px);
  box-shadow:
    0 24px 60px rgba(146, 64, 14, 0.16),
    0 0 36px rgba(251, 191, 36, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.85) inset;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  animation: journalReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.chapter-closing-topbar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.chapter-closing-kicker {
  display: inline-block;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  background: #0f172a;
  color: #fef08a;
  border: 1.5px solid #fbbf24;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.chapter-closing-audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.closing-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(217, 119, 6, 0.35);
  background: rgba(255, 251, 235, 0.9);
  color: #78350f;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.closing-audio-btn:hover {
  background: #fef3c7;
  border-color: rgba(217, 119, 6, 0.65);
}

.closing-audio-btn.is-muted {
  opacity: 0.65;
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(148, 163, 184, 0.45);
  color: #475569;
}

.chapter-closing-chapter-name {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #b45309;
  letter-spacing: 0.3px;
}

.chapter-closing-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(24px, 4.2vw, 36px);
  font-weight: 700;
  line-height: 1.25;
  color: #1e293b;
}

.chapter-closing-message-box {
  width: 100%;
  margin: 6px 0;
  padding: clamp(20px, 3.5vw, 30px) clamp(18px, 3.5vw, 32px);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 251, 235, 0.95) 100%);
  border: 1px solid rgba(245, 158, 11, 0.38);
  box-shadow: 0 10px 26px rgba(180, 83, 9, 0.08) inset, 0 6px 20px rgba(245, 158, 11, 0.08);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.chapter-closing-message-box:hover,
.chapter-closing-message-box:focus-visible {
  outline: none;
  border-color: rgba(245, 158, 11, 0.72);
  box-shadow: 0 10px 26px rgba(180, 83, 9, 0.1) inset, 0 8px 24px rgba(245, 158, 11, 0.14);
}

.chapter-closing-message {
  margin: 0;
  min-height: 4.8em;
  font-family: var(--font-serif);
  font-size: clamp(17px, 2.3vw, 21px);
  line-height: 1.75;
  color: #1e293b;
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.12em;
  margin-left: 3px;
  vertical-align: -0.16em;
  background-color: #d97706;
  animation: typewriterBlink 0.78s steps(2, start) infinite;
}

.typewriter-cursor.hidden {
  display: none;
}

@keyframes typewriterBlink {
  0%, 45% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

.chapter-closing-skip-hint {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  font-style: italic;
  color: #92400e;
  opacity: 0.75;
  text-align: right;
  transition: opacity 0.3s ease;
}

.chapter-closing-skip-hint.is-done {
  opacity: 0;
  pointer-events: none;
}

.chapter-closing-actions {
  width: 100%;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0.35;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.55s ease, transform 0.55s ease, filter 0.55s ease;
  filter: saturate(0.65);
}

.chapter-closing-actions.is-ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  filter: saturate(1);
}

.chapter-closing-next-btn {
  width: 100%;
  max-width: 380px;
  justify-content: center;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  border-color: #b45309;
  color: #ffffff;
  box-shadow: 0 10px 26px rgba(217, 119, 6, 0.28);
}

.chapter-closing-next-btn:hover {
  background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
}

.btn-chapter-closing-back {
  background: transparent;
  border: none;
  color: #78350f;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.btn-chapter-closing-back:hover {
  opacity: 1;
}

@media (max-width: 640px) {
  .chapter-closing-topbar {
    justify-content: center;
  }

  .chapter-closing-skip-hint {
    text-align: center;
  }
}

/* ==================== NÚT & MODAL HƯỚNG DẪN CÁCH CHƠI ==================== */
.splash-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn-splash-howto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-splash-howto:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(245, 158, 11, 0.65);
  transform: translateY(-1px);
}

.hud-btn-howto {
  background: rgba(255, 251, 235, 0.9);
  border-color: rgba(245, 158, 11, 0.45);
  color: #92400e;
}

.hud-btn-howto:hover {
  background: #fef3c7;
  border-color: rgba(217, 119, 6, 0.7);
}

.how-to-play-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.how-to-play-modal.hidden {
  display: none;
}

.how-to-play-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(6px);
  animation: fadeInBackdrop 0.22s ease forwards;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.how-to-play-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  max-height: 90dvh;
  overflow-y: auto;
  background: rgba(255, 253, 249, 0.98);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3.5vw, 30px);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.85) inset;
  animation: journalReveal 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.how-to-play-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.how-to-play-kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: #0f172a;
  color: #fef08a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.9px;
  margin-bottom: 6px;
}

.how-to-play-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(20px, 3.2vw, 26px);
  color: #1e293b;
  line-height: 1.25;
}

.how-to-play-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #f8fafc;
  color: #334155;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.how-to-play-close:hover {
  background: #fee2e2;
  color: #b91c1c;
  transform: rotate(90deg);
}

.how-to-play-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.howto-card {
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid transparent;
  text-align: left;
}

.howto-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.howto-card-icon {
  font-size: 18px;
  line-height: 1;
}

.howto-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
}

.howto-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #334155;
}

.howto-card-goal {
  background: #fffbeb;
  border-color: #fde68a;
}

.howto-card-stats {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.howto-card-branch {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.howto-card-gratitude {
  background: #fdf2f8;
  border-color: #fbcfe8;
}

.how-to-play-footer {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.btn-howto-confirm {
  min-width: 240px;
  justify-content: center;
  font-weight: 700;
}

@media (max-width: 640px) {
  .how-to-play-grid {
    grid-template-columns: 1fr;
  }

  .btn-howto-confirm {
    width: 100%;
  }
}
