/* ==========================================================================
   📖 勇者鬥惡龍 RPG 驚喜禮物網頁 - 樣式表 (Visual Novel Font Gift CSS)
   風格：勇者鬥惡龍地下城堡 (Dragon Quest Dungeon Castle) / 奇幻魔王城 / 企鵝金黃與火炬光芒
   ========================================================================== */

/* 1. 字型設定 */
@font-face {
  font-family: 'TearsFont-Standard';
  src: url('assets/fonts/tearsfont-1.1.otf') format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'TearsFont-VF';
  src: url('assets/fonts/tearsfont-vf-1.1.otf') format('opentype');
  font-display: swap;
}

/* 2. 設計系統權杖 (Design Tokens) */
:root {
  /* 勇者鬥惡龍地下城色調 */
  --bg-dungeon-dark: #0b0f19;
  --bg-card-dungeon: rgba(18, 26, 44, 0.88);
  --glass-border: rgba(245, 158, 11, 0.35);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  
  /* 深海藍與魔王城堡紫 */
  --navy-dark: #0f172a;
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #64748b;

  /* 城堡火炬與溫暖黃金點綴 */
  --accent-yellow: #fbbf24;
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.4);
  --torch-orange: #f97316;

  /* 魔法紫與淡藍光暈 */
  --magic-purple: #8b5cf6;
  --magic-cyan: #38bdf8;
  --pastel-pink: #f472b6;

  --font-ui: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'TearsFont-VF', 'TearsFont-Standard', 'Outfit', sans-serif;

  --rond-val: 50;
}

/* 3. 重置與基礎樣式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dungeon-dark);
  color: var(--text-main);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

/* 4. 勇者鬥惡龍動態地下城堡大氣背景 (Dynamic Dungeon Castle Atmosphere) */
.ambient-background.dungeon-theme {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  /* 高解析度奇幻城堡背景圖與 Ken Burns 鏡頭慢推動畫 */
  background: url('assets/images/rpg_castle_bg.jpg') no-repeat center center / cover;
  animation: castleKenBurns 28s ease-in-out infinite alternate;
}

/* 城堡中央陰影與氛圍遮罩 */
.dungeon-castle-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 40%, rgba(15, 23, 42, 0.45) 0%, rgba(7, 10, 18, 0.85) 100%);
}

/* 城堡火炬火焰晃動暈光 (Torch Light Flares) */
.torch-glow {
  position: absolute;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  animation: torchFlicker 3.5s ease-in-out infinite alternate;
}

.torch-left {
  top: 20%;
  left: -5%;
  background: radial-gradient(circle, var(--torch-orange), var(--accent-gold), transparent 70%);
}

.torch-right {
  top: 20%;
  right: -5%;
  background: radial-gradient(circle, var(--accent-gold), var(--magic-purple), transparent 70%);
  animation-delay: -1.7s;
}

.dungeon-sparks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 40px 60px, rgba(251, 191, 36, 0.85), rgba(0,0,0,0)),
    radial-gradient(3px 3px at 120px 180px, rgba(249, 115, 22, 0.75), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 280px 90px, rgba(56, 189, 248, 0.85), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 360px 240px, rgba(251, 191, 36, 0.7), rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 350px 350px;
  opacity: 0.75;
  animation: sparkFloat 20s linear infinite;
}

@keyframes castleKenBurns {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.05) translate(-12px, -6px); }
  100% { transform: scale(1.02) translate(10px, -12px); }
}

@keyframes torchFlicker {
  0% { transform: scale(1) translate(0, 0); opacity: 0.5; }
  50% { transform: scale(1.1) translate(15px, 10px); opacity: 0.72; }
  100% { transform: scale(0.95) translate(-10px, 15px); opacity: 0.55; }
}

@keyframes sparkFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-350px); }
}

/* Canvas Confetti 頂層 */
#canvas-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  pointer-events: none;
}

/* 5. 頁面框架佈局 */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 6. Header 導覽列 */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card-dungeon);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--glass-border);
  border-radius: 20px;
  margin-bottom: 24px;
  box-shadow: var(--glass-shadow);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title .icon {
  font-size: 2rem;
  animation: swordGlow 2s infinite alternate;
}

.title-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-yellow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.title-text .subtitle {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.header-controls {
  display: flex;
  gap: 10px;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.control-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-yellow);
  transform: translateY(-2px);
}

/* 7. 主遊戲卡片 (Dungeon Castle RPG Section) */
.game-card.dungeon-card {
  background: var(--bg-card-dungeon);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid var(--glass-border);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--glass-shadow), inset 0 0 30px rgba(0, 0, 0, 0.5);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 進度條列 */
.chapter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.chapter-badge {
  padding: 5px 14px;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  color: #fff;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.chapter-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-yellow);
  flex: 1;
}

.progress-container {
  width: 140px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--magic-purple), var(--accent-yellow));
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* 8. 視覺小說佈局 (Visual Novel Layout) */
.vn-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: start;
}

/* 人物欄 */
.avatar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar-card {
  position: relative;
  width: 100%;
  max-width: 260px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6), 0 0 20px var(--accent-gold-glow);
  animation: avatarFloat 6s ease-in-out infinite alternate;
}

.avatar-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid var(--accent-gold);
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-yellow);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-yellow);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-yellow);
  animation: pulseDot 1.5s infinite alternate;
}

/* 專利影片與立繪融合模式 (去除 MP4 黑色底背景) */
.media-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  /* 魔王祭壇光芒背景 */
  background: radial-gradient(circle at center, #2e1065 0%, #0f172a 80%);
  border: 1.5px solid rgba(251, 191, 36, 0.4);
}

.media-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* 關鍵！將影片黑色背景轉為透明，無縫融合成城堡背景 */
  mix-blend-mode: screen;
}

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

.hidden {
  display: none !important;
}

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

@keyframes pulseDot {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.3); }
}

/* 對話欄 (魔王城高質感捲軸 style) */
.dialogue-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.speech-bubble-wrapper {
  position: relative;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid var(--accent-gold);
  border-radius: 22px;
  padding: 24px 28px 20px;
  box-shadow: inset 0 0 25px rgba(0,0,0,0.8), 0 8px 24px rgba(0,0,0,0.4);
}

.speaker-tag {
  position: absolute;
  top: -14px;
  left: 24px;
  padding: 4px 16px;
  background: linear-gradient(135deg, var(--accent-gold), #d97706);
  color: #0f172a;
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  letter-spacing: 0.02em;
}

.dialogue-box {
  min-height: 85px;
  margin-top: 6px;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--text-main);
  font-weight: 500;
  /* 移除 pre-wrap，改用 normal 避免首行縮排 */
  white-space: normal;
  word-break: break-word;
  text-indent: 0;
}

.typewriter-text {
  display: inline;
  text-indent: 0;
}

.cursor {
  display: inline-block;
  color: var(--accent-yellow);
  font-weight: bold;
  animation: blink 0.8s infinite;
  margin-left: 2px;
}

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

/* 13. 3D 城堡開門過場動畫 (3D Castle Gate Opening Transition) */
.castle-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  overflow: hidden;
  perspective: 1400px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.castle-gate-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 雙扇古典城堡大門 */
.gate-door {
  width: 50vw;
  height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 60%, #070a12 100%);
  background-image: 
    repeating-linear-gradient(0deg, rgba(0,0,0,0.4), rgba(0,0,0,0.4) 40px, rgba(245, 158, 11, 0.2) 41px, rgba(0,0,0,0.4) 43px),
    radial-gradient(circle at center, rgba(30, 41, 59, 0.9), rgba(7, 10, 18, 0.98));
  border: 4px solid var(--accent-gold);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.95);
  position: relative;
  transition: transform 1.5s cubic-bezier(0.77, 0, 0.175, 1);
  transform-style: preserve-3d;
  will-change: transform;
}

.gate-door.left-door {
  transform-origin: left center;
  border-right: 3px solid rgba(255, 215, 0, 0.8);
}

.gate-door.right-door {
  transform-origin: right center;
  border-left: 3px solid rgba(255, 215, 0, 0.8);
}

.door-iron-studs {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle at 10px 10px, rgba(255,215,0,0.5) 2px, transparent 3px);
  background-size: 60px 80px;
  opacity: 0.6;
}

/* 門鎖/皇家魔法印記 (Gate Seal) */
.gate-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-yellow) 0%, #d97706 100%);
  border: 4px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 50px var(--accent-gold-glow), 0 0 80px rgba(245, 158, 11, 0.6);
  z-index: 10001;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
}

.gate-seal .seal-icon {
  font-size: 3.8rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

/* 開門瞬間光芒噴發 (Light Burst) */
.gate-light-burst {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.9) 0%, rgba(245, 158, 11, 0.6) 40%, transparent 80%);
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity 0.6s ease;
}

/* 3D 雙扇門掀開狀態 */
.castle-gate-overlay.opening .left-door {
  transform: perspective(1400px) rotateY(-110deg);
}

.castle-gate-overlay.opening .right-door {
  transform: perspective(1400px) rotateY(110deg);
}

.castle-gate-overlay.opening .gate-seal {
  transform: translate(-50%, -50%) scale(1.8);
  opacity: 0;
}

.castle-gate-overlay.opening .gate-light-burst {
  opacity: 1;
}

/* 3D 雙扇門強行撞擊關上狀態 (Slam Shut Rejection Animation) */
.castle-gate-overlay.slamming .left-door {
  animation: doorSlamLeft 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

.castle-gate-overlay.slamming .right-door {
  animation: doorSlamRight 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

.castle-gate-overlay.slamming .gate-seal {
  background: radial-gradient(circle, #f472b6 0%, #be123c 100%);
  box-shadow: 0 0 50px rgba(244, 114, 182, 0.8), 0 0 80px rgba(225, 29, 72, 0.6);
  animation: sealSlamLock 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

body.earthquake {
  animation: earthquakeShake 0.45s ease-in-out;
}

@keyframes doorSlamLeft {
  0% { transform: perspective(1400px) rotateY(-110deg); }
  82% { transform: perspective(1400px) rotateY(5deg); }
  100% { transform: perspective(1400px) rotateY(0deg); }
}

@keyframes doorSlamRight {
  0% { transform: perspective(1400px) rotateY(110deg); }
  82% { transform: perspective(1400px) rotateY(-5deg); }
  100% { transform: perspective(1400px) rotateY(0deg); }
}

@keyframes sealSlamLock {
  0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes earthquakeShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-12px, 8px) rotate(-1deg); }
  35% { transform: translate(12px, -8px) rotate(1deg); }
  55% { transform: translate(-8px, 6px); }
  75% { transform: translate(6px, -4px); }
}

/* 反應彈泡 Bubble */
.reaction-bubble {
  margin-top: 14px;
  padding: 12px 18px;
  background: rgba(30, 41, 59, 0.9);
  border: 1.5px solid var(--magic-purple);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--accent-yellow);
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  0% { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* 選項區 */
.options-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.options-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.03em;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 下一頁箭頭按鈕 — 固定在畫面底部中央 FAB 浮動按鈕 */
.next-step-wrapper {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8888;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: fabSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.next-step-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-yellow);
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  white-space: nowrap;
}

@keyframes fabSlideUp {
  0% { opacity: 0; transform: translateX(-50%) translateY(30px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.next-arrow-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-yellow) 0%, #d97706 100%);
  border: 3px solid #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.65), 0 0 0 6px rgba(245,158,11,0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: arrowPulse 1.5s ease-in-out infinite alternate;
}

.next-arrow-btn .arrow-icon {
  font-size: 1.8rem;
  font-weight: 900;
  transition: transform 0.25s ease;
}

.next-arrow-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.7);
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
}

.next-arrow-btn:hover .arrow-icon {
  transform: translateX(4px) scale(1.1);
}

.next-arrow-btn:active {
  transform: scale(0.95);
}

@keyframes arrowPulse {
  0% { transform: scale(1); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3); }
  100% { transform: scale(1.08); box-shadow: 0 10px 28px rgba(245, 158, 11, 0.6); }
}

@keyframes slideUpFade {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.option-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: rgba(30, 41, 59, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.option-btn:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--accent-yellow);
  transform: translateX(6px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}

.option-btn:active {
  transform: translateX(3px) scale(0.99);
}

.option-arrow {
  color: var(--accent-yellow);
  font-size: 1.1rem;
  font-weight: bold;
  transition: transform 0.2s ease;
}

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

/* 9. 通關勝利與字型試衣間 (Victory Section) */
.victory-card.dungeon-card {
  background: var(--bg-card-dungeon);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid var(--accent-gold);
  border-radius: 28px;
  padding: 36px;
  box-shadow: var(--glass-shadow), 0 0 35px rgba(245, 158, 11, 0.2);
  display: flex;
  flex-direction: column;
  gap: 36px;
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.victory-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chest-box {
  width: 90px;
  height: 90px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-yellow), #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.5);
  flex-shrink: 0;
}

.chest-emoji {
  font-size: 3.2rem;
  animation: chestBounce 2s ease-in-out infinite;
}

@keyframes chestBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.08); }
}

.victory-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #0f172a;
  background: var(--accent-yellow);
  padding: 3px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.victory-title-group h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.victory-desc {
  font-size: 0.95rem;
  color: var(--text-sub);
  line-height: 1.6;
}

.victory-desc code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--accent-yellow);
  font-weight: 700;
}

/* 10. 字型試衣間 Card (Playground) */
.playground-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-header h3 {
  font-size: 1.3rem;
  color: var(--accent-yellow);
  font-weight: 800;
  margin-bottom: 4px;
}

.card-header p {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.font-stage-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.stage-tag {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
  background: var(--accent-yellow);
  padding: 4px 12px;
  border-radius: 10px;
}

.preset-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover, .pill-btn.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-yellow);
  color: #fff;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  white-space: nowrap;
}

.input-group input {
  flex: 1;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-group input:focus {
  border-color: var(--accent-yellow);
}

/* 主測試畫布 Display Box */
.preview-display-box {
  min-height: 180px;
  padding: 32px 24px;
  background: radial-gradient(circle at center, rgba(30, 27, 75, 0.8) 0%, rgba(10, 15, 30, 0.95) 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
  overflow: hidden;
}

.vf-target {
  font-family: 'TearsFont-VF', 'TearsFont-Standard', sans-serif;
  font-size: 60px;
  line-height: 1.4;
  letter-spacing: 7px;
  color: #ffffff;
  font-variation-settings: 'ROND' var(--rond-val);
  transition: font-size 0.1s ease, letter-spacing 0.1s ease;
  word-break: break-word;
}

/* 滑桿面板 Grid */
.sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.slider-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-info label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.value-display {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent-yellow);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-yellow);
  box-shadow: 0 0 10px var(--accent-yellow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* 動態律動按鈕 */
.toggle-control {
  justify-content: center;
}

.pulse-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--magic-purple), #6d28d9);
  border: 1.5px solid var(--accent-yellow);
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s ease;
}

.pulse-toggle-btn:hover {
  background: linear-gradient(135deg, #8b5cf6, #5b21b6);
  box-shadow: 0 0 16px var(--accent-gold-glow);
}

.pulse-toggle-btn.active {
  background: var(--accent-yellow);
  color: #0f172a;
  border-color: #fff;
}

/* 11. 祝福寄語卡 (Blessing Card) */
.blessing-card {
  position: relative;
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.9), rgba(15, 23, 42, 0.95));
  border: 2px dashed var(--accent-gold);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blessing-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  color: var(--accent-yellow);
  font-weight: 800;
}

.blessing-quote {
  font-family: 'TearsFont-VF', 'TearsFont-Standard', sans-serif;
  font-size: 1.35rem;
  line-height: 1.8;
  color: #ffffff;
  font-variation-settings: 'ROND' 60;
  font-style: normal;
  padding-left: 14px;
  border-left: 4px solid var(--accent-gold);
}

.blessing-signature {
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: 700;
}

/* 12. 下載區 (Download Section) */
.download-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.download-header h3 {
  font-size: 1.25rem;
  color: #fff;
  font-weight: 800;
  margin-bottom: 4px;
}

.download-header p {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.download-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-radius: 18px;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-btn.primary {
  background: linear-gradient(135deg, var(--accent-yellow) 0%, #d97706 100%);
  color: #0f172a;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

.download-btn.primary:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.5);
}

.download-btn.accent {
  background: linear-gradient(135deg, var(--magic-purple) 0%, #4c1d95 100%);
  color: #ffffff;
  border: 1.5px solid var(--accent-gold);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.download-btn.accent:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.5);
}

.download-btn .btn-icon {
  font-size: 2.2rem;
}

.download-btn .btn-text {
  display: flex;
  flex-direction: column;
}

.download-btn .main-title {
  font-size: 0.95rem;
  font-weight: 800;
}

.download-btn .sub-info {
  font-size: 0.75rem;
  opacity: 0.85;
}

/* 門禁系統 (Passcode Gatekeeper Styling) */
.passcode-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 16px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.question-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.question-title h3 {
  font-size: 1.15rem;
  color: #ffffff;
  font-weight: 800;
}

.q-icon {
  font-size: 1.4rem;
}

.hint-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-yellow);
  background: rgba(245, 158, 11, 0.15);
  padding: 6px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.passcode-input-wrapper {
  display: flex;
  gap: 14px;
}

.passcode-input-wrapper input {
  flex: 1;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  color: #ffffff;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  outline: none;
  transition: all 0.25s ease;
}

.passcode-input-wrapper input:focus {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 15px var(--accent-gold-glow);
}

.passcode-input-wrapper input.shake {
  animation: shake 0.4s ease-in-out;
  border-color: #f472b6;
}

.passcode-submit-btn {
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent-yellow) 0%, #d97706 100%);
  border: 1.5px solid #ffffff;
  border-radius: 16px;
  color: #0f172a;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.passcode-submit-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.6);
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
}

.passcode-submit-btn:active {
  transform: scale(0.97);
}

.passcode-error-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(244, 114, 182, 0.15);
  border: 1.5px solid #f472b6;
  border-radius: 16px;
  color: #fecdd3;
  font-size: 0.95rem;
  font-weight: 700;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.passcode-error-box .error-icon {
  font-size: 1.2rem;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* 14. 響應式 RWD 調整 */
@media (max-width: 768px) {
  .app-wrapper {
    padding: 12px 10px 40px;
  }

  /* Header: 維持單行橫排，不要縱向堆疊 */
  .app-header {
    flex-direction: row;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
  }

  .brand-title {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .brand-title .icon {
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .title-text h1 {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-controls {
    flex-shrink: 0;
  }

  /* Game card padding */
  .game-card.dungeon-card,
  .victory-card.dungeon-card {
    padding: 18px 14px;
    border-radius: 20px;
  }

  /* Chapter bar: badge 與 title 各佔一行，progress bar 獨立一行 */
  .chapter-bar {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 8px 12px;
    align-items: center;
  }

  .chapter-badge {
    grid-column: 1;
    grid-row: 1;
    white-space: nowrap;
  }

  .chapter-title {
    grid-column: 2;
    grid-row: 1;
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-word;
  }

  .progress-container {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  /* VN Layout: 單欄堆疊 */
  .vn-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .avatar-column {
    align-items: center;
  }

  .avatar-card {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
  }

  .avatar-column {
    width: 100%;
  }

  /* Victory/Gatekeeper header: 縱向排列但文字對齊 */
  .victory-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .gatekeeper-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .victory-title-group h2 {
    font-size: 1.3rem;
    word-break: break-word;
  }

  /* Passcode input: 縱向排列，按鈕寬度全展 */
  .passcode-input-wrapper {
    flex-direction: column;
    gap: 10px;
  }

  .passcode-input-wrapper input {
    width: 100%;
    box-sizing: border-box;
  }

  .passcode-submit-btn {
    width: 100%;
    padding: 14px 20px;
  }

  /* Question box: 縱向排列 */
  .question-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Blessing / passive skills card: 防止斷字異常 */
  .blessing-quote {
    font-size: 0.95rem;
    line-height: 2;
    word-break: keep-all;
    overflow-wrap: break-word;
    white-space: normal;
  }

  /* Font playground: 字體試衣間 */
  .playground-card {
    padding: 16px 12px;
  }

  /* vf-target: 手機初始顯示合理尺寸，JS slider 可覆蓋 (移除 !important 讓 JS 控制生效) */
  .vf-target {
    min-height: 120px;
    word-break: break-all;
  }

  .preset-pills {
    flex-wrap: wrap;
    gap: 6px;
  }

  .pill-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  /* Input group for custom text */
  .input-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .input-group input {
    width: 100%;
    box-sizing: border-box;
  }

  /* Download buttons: 縱向 */
  .download-buttons-grid {
    grid-template-columns: 1fr;
  }

  /* Options grid: 一欄 */
  .options-grid {
    grid-template-columns: 1fr;
  }

  /* Slider controls */
  .slider-ticks {
    font-size: 0.65rem;
  }
}

@media (max-width: 420px) {
  .app-wrapper {
    padding: 8px 8px 40px;
  }

  .title-text h1 {
    font-size: 0.92rem;
  }

  .game-card.dungeon-card,
  .victory-card.dungeon-card {
    padding: 14px 10px;
  }

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

  .vf-target {
    word-break: break-all;
  }

  .blessing-quote {
    font-size: 0.88rem;
    line-height: 1.9;
  }
}

/* ===== 下載確認 Modal ===== */
.download-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 10, 18, 0.88);
  backdrop-filter: blur(12px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease;
}

.download-modal-box {
  background: linear-gradient(145deg, #1e1b4b 0%, #0f172a 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 28px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 0 60px rgba(245,158,11,0.35), inset 0 0 30px rgba(0,0,0,0.6);
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-seal-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 12px;
  animation: swordGlow 2s infinite alternate;
}

.download-modal-box h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-yellow);
  margin-bottom: 8px;
}

.download-modal-box p {
  font-size: 0.95rem;
  color: var(--text-sub);
  line-height: 1.7;
  margin-bottom: 20px;
}

.modal-chant-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(245,158,11,0.3);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 10px;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.modal-chant-row.done {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--accent-yellow);
}

.chant-count {
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(255,255,255,0.3);
  transition: color 0.3s ease;
  min-width: 32px;
}

.modal-chant-row.done .chant-count {
  color: var(--accent-yellow);
}

.chant-label {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  transition: color 0.3s ease;
}

.modal-chant-row.done .chant-label {
  color: #ffffff;
}

.chant-check {
  margin-left: auto;
  font-size: 1.3rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-chant-row.done .chant-check {
  opacity: 1;
}

.modal-chant-btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
  border: 1.5px solid rgba(245,158,11,0.5);
  border-radius: 16px;
  color: #ffffff;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(124,58,237,0.4);
}

.modal-chant-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(124,58,237,0.6);
}

.modal-confirm-btn {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--accent-yellow), #d97706);
  border: none;
  border-radius: 16px;
  color: #0f172a;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(245,158,11,0.4);
  display: none;
}

.modal-confirm-btn.visible {
  display: block;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-confirm-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 28px rgba(245,158,11,0.6);
}

.modal-cancel-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 12px;
  font-family: var(--font-ui);
  transition: color 0.2s;
}

.modal-cancel-btn:hover {
  color: #fff;
}

@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
