/* ==========================================================================
   尋章摘句 — 故宮宮廷古典美學 × 綾絹裝裱密室主題樣式庫
   (Palace Museum Imperial Classical Aesthetics & Silk Brocade Mounting)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=LXGW+WenKai+TC:wght@400;700&family=Noto+Serif+TC:wght@400;600;700;900&display=swap');

:root {
  /* ── 1. 故宮宮廷經典配色體系 (Palace Imperial Color System) ── */
  --palace-vermilion: #b82823;          /* 故宮硃牆紅 / 朱砂紅 */
  --palace-vermilion-deep: #8e1e19;     /* 硃紅重彩 / 醇厚印泥色 */
  --palace-vermilion-light: #d8453d;    /* 丹砂霞光 */
  --palace-vermilion-glow: rgba(184, 40, 35, 0.42);

  --palace-indigo: #2c4a6f;             /* 霽藍景泰藍 / 霽青釉色 */
  --palace-indigo-deep: #192e46;        /* 幽藍霽青 / 沉香墨藍 */
  --palace-indigo-light: #3e6594;       /* 淺霽青天色 */
  --palace-indigo-glow: rgba(44, 74, 111, 0.38);

  --palace-gold: #c59a3f;               /* 泥金描金 / 蒔金 */
  --palace-gold-bright: #e8c15a;        /* 庫金明耀 / 泥金提亮 */
  --palace-gold-dark: #8a6721;          /* 古銅泥金 / 烏金 */
  --palace-gold-glow: rgba(197, 154, 63, 0.45);

  --palace-jade: #2e5d4b;               /* 宮廷翡翠玉色 / 碧玉翡翠 */
  --palace-jade-light: #46836b;         /* 青碧靈玉 */
  --palace-jade-glow: rgba(46, 93, 75, 0.36);

  --palace-ink: #1a1714;                /* 玄墨 / 徽墨 */
  --palace-ink-deep: #0e0c0a;           /* 松煙重墨 */
  --palace-ink-soft: #554b41;           /* 淡墨松煙 */
  --palace-ink-faint: rgba(26, 23, 20, 0.08);

  --palace-paper: #f7f1e5;              /* 宋代澄心堂仿古宣紙底 */
  --palace-paper-deep: #ede3d1;         /* 煮硾熟宣底色 / 隔水宣紙 */
  --palace-paper-card: #faf6ed;         /* 宋畫精裱玉版宣紙心 */
  --palace-paper-dark: #dfd2bc;         /* 古色熟宣邊綾 */

  --palace-rosewood: #3d261d;           /* 故宮紫檀紅木 */
  --palace-rosewood-dark: #271812;      /* 老紅木榫卯深色 */
  --palace-duan-stone: #32252b;         /* 紫袍玉帶紫端硯 */
  --palace-bronze: #4a6b63;             /* 宣德青銅器古銹色 */
  --palace-bronze-copper: #9a6945;      /* 赤銅金屬光澤 */

  /* 基礎相容映射 (Backward Compatibility) */
  --paper: var(--palace-paper);
  --paper-deep: var(--palace-paper-deep);
  --paper-trans: rgba(247, 241, 229, 0.88);
  --paper-card: var(--palace-paper-card);
  
  --ink: var(--palace-ink);
  --ink-deep: var(--palace-ink-deep);
  --ink-soft: var(--palace-ink-soft);
  --ink-faint: var(--palace-ink-faint);
  
  --vermilion: var(--palace-vermilion);
  --vermilion-dark: var(--palace-vermilion-deep);
  --vermilion-glow: var(--palace-vermilion-glow);
  
  --gold: var(--palace-gold);
  --gold-bright: var(--palace-gold-bright);
  --gold-dark: var(--palace-gold-dark);
  --gold-glow: var(--palace-gold-glow);
  
  --indigo: var(--palace-indigo);
  --indigo-dark: var(--palace-indigo-deep);
  --indigo-light: var(--palace-indigo-light);
  
  --jade: var(--palace-jade);
  --jade-light: var(--palace-jade-light);
  
  --cell-bg: #fdfbf7;                   /* 漢白玉溫潤石質 */
  --cell-border: #d4c5ab;               /* 泥金描線邊 */
  --radius: 12px;
  --radius-sm: 6px;
  --radius-lg: 18px;

  /* 五行琉璃破陣色調 (Five-Element Imperial Gemstones) */
  --found-0: #ebd3c8; /* 火靈赤霞・珊瑚紅 */
  --found-1: #c9dbe7; /* 水靈幽瀾・霽青釉 */
  --found-2: #cee0cb; /* 木靈青嵐・翡翠碧 */
  --found-3: #e1d3e8; /* 坤土玄紫・紫袍玉 */
  --found-4: #eee4c2; /* 乾金耀魄・蒔金黃 */
  
  /* 故宮宮廷陰影與光暈 */
  --shadow-ink: 0 4px 20px rgba(26, 23, 20, 0.12), 0 1px 4px rgba(26, 23, 20, 0.08);
  --shadow-talisman: 0 8px 26px rgba(184, 40, 35, 0.22), 0 2px 8px rgba(26, 23, 20, 0.14);
  --shadow-gold: 0 0 18px rgba(197, 154, 63, 0.38);
  --shadow-curio: 0 6px 22px rgba(39, 24, 18, 0.18), inset 0 0 0 1px rgba(197, 154, 63, 0.35);

  /* 宮廷國風開源字型體系 (楷書・行書・宋體) */
  --font-serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --font-title: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "Noto Serif TC", serif;
  --font-kai: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "Noto Serif TC", serif;
  --font-calligraphy: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "Noto Serif TC", serif;
}

/* ── 全域背景：宋代澄心堂宣紙底 × 綾絹暗紋 ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--palace-paper);
  color: var(--palace-ink);
  font-family: var(--font-serif);
  min-height: 100%;
  position: relative;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* 宋代澄心堂宣紙微紋理與四方金石水墨微光 */
body {
  background-image: 
    radial-gradient(circle at 12% 12%, rgba(197, 154, 63, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 88% 88%, rgba(44, 74, 111, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(247, 241, 229, 0.95) 0%, rgba(237, 227, 209, 0.72) 100%),
    /* 綾絹經緯織錦幾何暗紋 (Silk Brocade Woven Pattern) */
    url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23c59a3f' fill-opacity='0.035' fill-rule='evenodd'%3E%3Cpath d='M0 20L20 0l20 20-20 20L0 20zm4 0l16-16 16 16-16 16L4 20z'/%3E%3Ccircle cx='20' cy='20' r='3'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
}

/* 宮廷雲氣與松煙暗香浮動 */
body::before {
  content: "";
  position: fixed;
  top: -80px;
  right: -80px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(26, 23, 20, 0.07) 0%, rgba(44, 74, 111, 0.04) 50%, transparent 70%);
  border-radius: 46% 54% 62% 38% / 45% 42% 58% 55%;
  filter: blur(32px);
  pointer-events: none;
  z-index: 0;
  animation: palace-ink-drift 24s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  bottom: -90px;
  left: -90px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(184, 40, 35, 0.06) 0%, rgba(197, 154, 63, 0.05) 45%, transparent 70%);
  border-radius: 56% 44% 39% 61% / 42% 64% 36% 58%;
  filter: blur(38px);
  pointer-events: none;
  z-index: 0;
  animation: palace-ink-drift 30s ease-in-out infinite alternate-reverse;
}

@keyframes palace-ink-drift {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  50% { transform: translate(30px, 24px) scale(1.09) rotate(10deg); }
  100% { transform: translate(-20px, 38px) scale(0.94) rotate(-8deg); }
}

.hidden { display: none !important; }
.muted { color: var(--palace-ink-soft); }

/* ── 頂部導航 (App Header - 故宮金絲宣和裝) ── */
.app-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.95rem 1.5rem;
  background: linear-gradient(180deg, rgba(250, 246, 237, 0.97) 0%, rgba(247, 241, 229, 0.9) 100%);
  border-bottom: 2px solid var(--palace-gold);
  box-shadow: 
    0 4px 18px rgba(26, 23, 20, 0.08),
    inset 0 -1px 0 rgba(184, 40, 35, 0.35);
  backdrop-filter: blur(8px);
}

.app-brand {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  outline: none;
  position: relative;
}

.brand-mascot-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mascot-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffdf8 0%, #f7ecd7 100%);
  border: 2px solid var(--palace-gold);
  box-shadow: 0 2px 8px rgba(197, 154, 63, 0.35), inset 0 1px 3px #fff;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  flex-shrink: 0;
}

.app-brand:hover .brand-mascot-icon {
  transform: scale(1.12) rotate(6deg);
  box-shadow: 0 6px 16px rgba(197, 154, 63, 0.5), 0 0 12px var(--palace-gold-glow);
}

.mascot-sparkle-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--palace-gold-bright);
  box-shadow: 0 0 8px #fef08a;
  animation: sparkle-pulse 1.8s infinite alternate;
}

@keyframes sparkle-pulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

.brand-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* 故宮御用璽印 (Imperial Chop Seal) */
.app-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #ffffff;
  background: linear-gradient(135deg, var(--palace-vermilion) 0%, var(--palace-vermilion-deep) 100%);
  border: 1.5px solid var(--palace-gold-bright);
  border-radius: 4px;
  padding: 0.18rem 0.48rem;
  line-height: 1.2;
  box-shadow: 
    0 2px 6px rgba(184, 40, 35, 0.4),
    inset 0 0 0 1px rgba(142, 30, 25, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  position: relative;
}

.app-title {
  font-family: var(--font-calligraphy);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--palace-ink-deep);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8), 2px 2px 5px rgba(26, 23, 20, 0.15);
}

.demo-badge {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  color: #fff;
  background: linear-gradient(135deg, var(--palace-vermilion), var(--palace-vermilion-deep));
  border: 1px solid var(--palace-gold-bright);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  box-shadow: 0 2px 6px var(--palace-vermilion-glow);
}

.app-nav {
  margin-left: auto;
  display: flex;
  gap: 0.55rem;
}

/* 景泰藍與泥金導航按鈕 (Cloisonné & Gold Nav Buttons) */
.nav-btn {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  background: rgba(250, 246, 237, 0.9);
  color: var(--palace-indigo-deep);
  border: 1.5px solid rgba(197, 154, 63, 0.6);
  border-radius: 999px;
  padding: 0.38rem 1.15rem;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(26, 23, 20, 0.05);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.nav-btn:hover {
  background: #ffffff;
  border-color: var(--palace-gold-bright);
  color: var(--palace-vermilion);
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(197, 154, 63, 0.28);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--palace-indigo) 0%, var(--palace-indigo-deep) 100%);
  color: #fdfaf2;
  border-color: var(--palace-gold-bright);
  box-shadow: 
    0 3px 10px rgba(25, 46, 70, 0.38),
    inset 0 1px 0 rgba(232, 193, 90, 0.45);
}

/* 仙童即時對話氣泡 (Mascot Speech Bubble) */
.mascot-speech-bubble {
  position: absolute;
  top: 110%;
  left: 0;
  z-index: 30;
  background: linear-gradient(135deg, #ffffff 0%, #faf4e6 100%);
  border: 1.5px solid var(--palace-gold);
  border-radius: 12px;
  padding: 0.55rem 0.85rem;
  box-shadow: 0 6px 20px rgba(26, 23, 20, 0.15);
  white-space: nowrap;
  animation: bubble-float-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.mascot-speech-bubble p {
  font-family: var(--font-calligraphy);
  font-size: 0.88rem;
  color: var(--palace-ink-deep);
  font-weight: 700;
}

.mascot-speech-triangle {
  position: absolute;
  top: -7px;
  left: 24px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-left: 1.5px solid var(--palace-gold);
  border-top: 1.5px solid var(--palace-gold);
  transform: rotate(45deg);
}

@keyframes bubble-float-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

main {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

.view-title {
  font-family: var(--font-calligraphy);
  font-size: 1.45rem;
  letter-spacing: 0.25em;
  margin-bottom: 1.2rem;
  color: var(--palace-indigo-deep);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
}

.view-title::before {
  content: "❖";
  font-size: 0.95rem;
  color: var(--palace-gold);
}

.view-title::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--palace-gold) 0%, rgba(197, 154, 63, 0.1) 100%);
  margin-left: 0.6rem;
}

/* ── 寬螢幕桌面排版 ────────────────────────── */
@media (min-width: 992px) {
  main:has(#view-game:not(.hidden)) {
    max-width: 1200px;
    padding: 1.5rem 1.8rem 3.5rem;
  }
  
  #view-game .game-layout {
    display: grid;
    grid-template-columns: minmax(480px, 1fr) 410px;
    gap: 2.2rem;
    align-items: start;
  }
  
  #view-game .game-board {
    min-width: 0;
    position: relative;
  }
  
  #view-game .game-panel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
  }
  
  #view-game .game-panel .character-stage { order: -3; margin-bottom: 1rem; }
  #view-game .game-panel .hint-bar { order: -2; margin-bottom: 0.9rem; }
  #view-game .game-panel .hint-msg { order: -1; }
  
  #view-game .grid {
    width: min(48vw, 560px);
  }
  
  #view-game .cell {
    font-size: clamp(0.95rem, calc(min(48vw, 560px) * 0.58 / var(--grid-n, 5)), 2.4rem);
  }
}

/* ── 密室大廳／陣法選擇視圖 (Chamber Hero & Curio Shelf) ── */
.chamber-hero {
  text-align: center;
  padding: 1.5rem 1.2rem 1.8rem;
  margin-bottom: 1.6rem;
  background: linear-gradient(180deg, rgba(252, 248, 240, 0.96) 0%, rgba(244, 235, 217, 0.85) 100%);
  border: 2px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  box-shadow: 
    0 8px 24px rgba(26, 23, 20, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    inset 0 0 0 4px var(--palace-paper-deep);
  position: relative;
  overflow: hidden;
}

.chamber-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--palace-vermilion), var(--palace-gold), var(--palace-indigo));
}

.chamber-hero-tag {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--palace-vermilion);
  background: rgba(184, 40, 35, 0.08);
  border: 1px solid rgba(184, 40, 35, 0.3);
  padding: 0.22rem 0.9rem;
  border-radius: 999px;
  letter-spacing: 0.18em;
  margin-bottom: 0.6rem;
}

.chamber-hero-title {
  font-family: var(--font-calligraphy);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--palace-ink-deep);
  letter-spacing: 0.28em;
  margin-bottom: 0.6rem;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
}

.chamber-hero-desc {
  font-size: 0.95rem;
  color: var(--palace-ink-soft);
  line-height: 1.75;
  max-width: 540px;
  margin: 0 auto;
}

.chamber-grid {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

/* 故宮紅木博古架陣法卡片 (Palace Curio Shelf Chamber Cards) */
.chamber-card {
  background: var(--palace-paper-card);
  border: 2px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-curio);
  position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease;
  overflow: hidden;
}

.chamber-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: var(--chamber-color, var(--palace-indigo));
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.15);
}

.chamber-card:hover {
  transform: translateY(-4px);
  border-color: var(--palace-gold-bright);
  box-shadow: 0 12px 32px rgba(26, 23, 20, 0.16), 0 0 16px var(--palace-gold-glow);
}

.chamber-card.locked {
  opacity: 0.72;
  background: #eae0cf;
  border-color: #baa98f;
}

.chamber-card.done {
  border-color: var(--palace-gold-bright);
  box-shadow: 0 4px 18px rgba(197, 154, 63, 0.25);
}

.chamber-badge-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.chamber-element-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--chamber-color, var(--palace-indigo));
  padding: 0.16rem 0.6rem;
  border-radius: 4px;
  letter-spacing: 0.12em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.chamber-status-badge {
  font-size: 0.76rem;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.chamber-status-badge.open {
  color: var(--palace-indigo-deep);
  background: #e1edf5;
  border: 1px solid #b7d6ea;
}

.chamber-status-badge.win {
  color: var(--palace-gold-dark);
  background: #fdf5df;
  border: 1px solid var(--palace-gold);
}

.chamber-status-badge.lock {
  color: #7f8c8d;
  background: #e5e7e9;
  border: 1px solid #bdc3c7;
}

.chamber-title {
  font-family: var(--font-calligraphy);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.12em;
  color: var(--palace-ink-deep);
  margin-bottom: 0.15rem;
}

.chamber-alias {
  font-size: 0.85rem;
  color: var(--palace-ink-soft);
  letter-spacing: 0.08em;
}

.chamber-guardian-section {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid rgba(197, 154, 63, 0.35);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.9rem 0;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.8);
}

.chamber-guardian-standee-box {
  flex: 0 0 110px;
  height: 125px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chamber-guardian-name {
  font-family: var(--font-calligraphy);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--palace-indigo-deep);
  margin-right: 0.45rem;
}

.chamber-guardian-title {
  font-size: 0.78rem;
  color: var(--palace-gold-dark);
  background: #fef8eb;
  padding: 0.08rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(197, 154, 63, 0.3);
}

.chamber-lore {
  font-size: 0.9rem;
  color: var(--palace-ink-deep);
  line-height: 1.7;
  margin-bottom: 0.9rem;
}

.chamber-progress-box { margin-bottom: 0.9rem; }
.chamber-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--palace-ink-soft);
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.chamber-progress-bar {
  height: 9px;
  background: var(--palace-paper-deep);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(197, 154, 63, 0.25);
}
.chamber-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--chamber-color, var(--palace-indigo)), var(--chamber-accent, var(--palace-gold-bright)));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.chamber-treasure-preview {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #fdfaf2;
  border: 1.5px dashed var(--palace-gold);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  margin-bottom: 1.1rem;
}
.chamber-treasure-preview .treasure-icon { font-size: 1.4rem; }
.chamber-treasure-preview .treasure-text small {
  display: block;
  font-size: 0.74rem;
  color: var(--palace-gold-dark);
}
.chamber-treasure-preview .treasure-text strong {
  font-size: 0.9rem;
  color: var(--palace-ink-deep);
}

.chamber-card-actions { display: flex; gap: 0.65rem; }
.chamber-enter-btn { flex: 1; }

/* ── 遊戲盤面頂部 HUD (宣德青銅獸首古香爐 × 御用松煙紫端硯) ── */
.game-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
  background: linear-gradient(135deg, rgba(252, 248, 240, 0.97) 0%, rgba(244, 235, 217, 0.94) 100%);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  box-shadow: var(--shadow-ink);
  flex-wrap: wrap;
}

.game-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-array-badge {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--palace-indigo) 0%, var(--palace-indigo-deep) 100%);
  border: 1px solid var(--palace-gold-bright);
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.1em;
  box-shadow: 0 2px 6px rgba(25, 46, 70, 0.3);
}

.game-level-title {
  font-family: var(--font-calligraphy);
  font-size: 1.35rem;
  letter-spacing: 0.18em;
  color: var(--palace-ink-deep);
  font-weight: 700;
}

/* 宣德青銅獸首古香爐 (Xuande Bronze Censer Incense Timer) */
.timer-display {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--palace-ink-deep);
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #e8dfcf 0%, #dbcbaf 100%);
  border: 1.5px solid var(--palace-bronze);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.6), 0 2px 6px rgba(26, 23, 20, 0.12);
  position: relative;
}

.incense-burner-mini {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
  margin-right: 2px;
}

.incense-stick-wrap {
  width: 6px;
  height: 26px;
  background: rgba(46, 38, 29, 0.2);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: visible;
  border: 1px solid rgba(138, 103, 33, 0.3);
}

.incense-stick-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #d33c2a 0%, #8c2a1e 70%, #4a2018 100%);
  border-radius: 2px;
  transition: height 0.25s linear;
}

/* 宣德香爐香頭赤紅炭火與微光微震 (Glowing Ember) */
.incense-ember-dot {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: radial-gradient(circle, #fff7c2 0%, #ff5722 60%, #b71c1c 100%);
  border-radius: 50%;
  box-shadow: 0 0 8px #ff5722, 0 0 14px #ff9800;
  animation: ember-incense-glow 1.2s infinite alternate;
}

@keyframes ember-incense-glow {
  0% { transform: translateX(-50%) scale(0.85); opacity: 0.8; box-shadow: 0 0 6px #ff5722; }
  100% { transform: translateX(-50%) scale(1.35); opacity: 1; box-shadow: 0 0 12px #ff9800, 0 0 18px #ffeb3b; }
}

.incense-censer-icon {
  font-size: 1.25rem;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(74, 107, 99, 0.4));
}

.timer-display.warn {
  color: var(--palace-vermilion);
  background: linear-gradient(135deg, #fae0db 0%, #f4cac3 100%);
  border-color: var(--palace-vermilion);
  animation: timer-alarm-shake 0.8s ease-in-out infinite;
}

.timer-display.warn .incense-ember-dot {
  background: radial-gradient(circle, #ffffff 0%, #ff1744 60%, #b71c1c 100%);
  box-shadow: 0 0 14px #ff1744, 0 0 22px #d50000;
}

/* 故宮御用松煙紫端硯 (Imperial Duan Inkstone Pool) */
.ink-display {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--palace-indigo-deep);
  background: linear-gradient(135deg, #ede4d1 0%, #e0d0af 100%);
  border: 1.5px solid var(--palace-gold);
  border-radius: 999px;
  padding: 0.3rem 0.95rem;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.7), 0 2px 6px rgba(26, 23, 20, 0.12);
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ink-display:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(197, 154, 63, 0.35);
}

.ink-dish-icon {
  font-size: 1.25rem;
  margin-right: 0.15rem;
  filter: drop-shadow(0 2px 3px rgba(50, 37, 43, 0.35));
}

.timer-text-wrap, .ink-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.timer-tag, .ink-tag {
  font-size: 0.68rem;
  color: var(--palace-ink-soft);
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* ── 密室破陣封印條 (Seal Runes Bar - 掐絲琺瑯紫金符印) ── */
.seal-progress-bar {
  background: linear-gradient(135deg, #fdfaf2 0%, #f6edd9 100%);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  margin-bottom: 1rem;
  box-shadow: 0 3px 10px rgba(26, 23, 20, 0.08);
}

.seal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--palace-indigo-deep);
  margin-bottom: 0.5rem;
}

.seal-title { letter-spacing: 0.12em; font-family: var(--font-calligraphy); }

.seal-count {
  font-size: 0.8rem;
  color: var(--palace-gold-dark);
  background: #fff8e8;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(197, 154, 63, 0.4);
  font-weight: 700;
}

.seal-runes {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.seal-rune-node {
  flex: 1 1 auto;
  min-width: 48px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.seal-rune-node.locked {
  background: #ede3ce;
  color: #8c7d67;
  border: 1.5px dashed #baa98f;
}

.seal-rune-node.unsealed {
  background: linear-gradient(135deg, #fff3cf 0%, #fed966 100%);
  color: #783f04;
  border: 1.5px solid var(--palace-gold-bright);
  box-shadow: 0 0 12px rgba(232, 193, 90, 0.55);
  transform: scale(1.05);
}

.rune-symbol {
  font-family: var(--font-calligraphy);
  font-size: 1.05rem;
}

/* ── 密室字陣 (Game Board & Matrix - 故宮太極殿漢白玉盤面) ── */
.game-board {
  position: relative;
  background: linear-gradient(145deg, rgba(250, 246, 237, 0.94) 0%, rgba(244, 233, 212, 0.94) 100%);
  border: 2px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  padding: 1.25rem 0.9rem;
  box-shadow: 
    var(--shadow-ink),
    0 0 30px rgba(197, 154, 63, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

/* 盤面太極與八卦雲氣金線底紋 */
.game-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='200' cy='200' r='180' stroke='%23c59a3f' stroke-width='1.5' stroke-opacity='0.16' stroke-dasharray='4 6'/%3E%3Ccircle cx='200' cy='200' r='140' stroke='%23c59a3f' stroke-width='1' stroke-opacity='0.12'/%3E%3Ccircle cx='200' cy='200' r='80' stroke='%232c4a6f' stroke-width='1.5' stroke-opacity='0.09'/%3E%3Cpath d='M200 20 L200 380 M20 200 L380 200 M72 72 L328 328 M72 328 L328 72' stroke='%23c59a3f' stroke-width='0.8' stroke-opacity='0.12'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: min(90%, 400px);
  pointer-events: none;
  opacity: 0.9;
}

/* 故宮雙層錦綾描金滾邊護角 */
.game-board::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(197, 154, 63, 0.3);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  /* 盤面寬度隨 --grid-n 成長，確保大盤面每格仍有可觸控尺寸；超出視窗時由 .game-board 水平捲動 */
  width: min(96vw, max(450px, calc(var(--grid-n, 5) * 30px)));
  margin: 0 auto 1.2rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  z-index: 2;
  padding: 10px;
  background: linear-gradient(145deg, #eee4d1, #dfd2bc);
  border: 2px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  box-shadow: 
    0 8px 24px rgba(26, 23, 20, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6),
    inset 0 3px 8px rgba(26, 23, 20, 0.12);
}

/* 漢白玉石字格微浮雕 (Han White Jade Stone Cell Relief) */
.cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(0.88rem, calc(min(96vw, max(450px, var(--grid-n, 5) * 30px)) * 0.58 / var(--grid-n, 5)), 2.1rem);
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f8f2e7 75%, #ece1cf 100%);
  color: var(--palace-ink-deep);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius-sm);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(197, 154, 63, 0.4),
    0 2px 6px rgba(26, 23, 20, 0.1);
  position: relative;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
}

.cell:hover {
  transform: translateY(-2px) scale(1.05);
  border-color: var(--palace-gold-bright);
  z-index: 5;
  box-shadow: 0 5px 15px rgba(197, 154, 63, 0.35), inset 0 0 0 1px #fff;
}

/* 拖曳預覽：霽青玉色半透靈光 */
.cell.preview {
  background: linear-gradient(135deg, #e3eef7 0%, #bfd8ec 100%) !important;
  color: var(--palace-indigo-deep);
  border-color: var(--palace-indigo);
  transform: scale(1.08) !important;
  z-index: 10;
  box-shadow: 0 4px 14px rgba(44, 74, 111, 0.38), 0 0 12px var(--palace-indigo-glow);
  animation: preview-breath 0.6s ease-in-out infinite alternate;
}

@keyframes preview-breath {
  0% { box-shadow: 0 2px 8px rgba(44, 74, 111, 0.28); }
  100% { box-shadow: 0 5px 16px rgba(44, 74, 111, 0.48), 0 0 14px var(--palace-gold-glow); }
}

/* 破陣成功：五行琉璃靈光 */
.cell.found {
  animation: palace-breakthrough 0.65s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  animation-delay: var(--found-delay, 0ms);
  animation-fill-mode: both;
  border-color: var(--palace-gold-bright);
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(26, 23, 20, 0.15), inset 0 0 8px rgba(255, 255, 255, 0.7);
}

@keyframes palace-breakthrough {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.22) rotate(2deg); filter: brightness(1.35) drop-shadow(0 0 14px var(--palace-gold-bright)); }
  70% { transform: scale(0.96) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); filter: brightness(1); }
}

/* 加深已破字格顏色：與未破的漢白玉底明顯區隔，孩子找剩餘成語時一眼可辨 */
.cell.found-0 { background: linear-gradient(135deg, #f5c4b4 0%, #e08b6f 100%); color: #5d190f; border-color: #c06a4c; }
.cell.found-1 { background: linear-gradient(135deg, #bcd9ec 0%, #7fa9c4 100%); color: #122d3f; border-color: #5d89a6; }
.cell.found-2 { background: linear-gradient(135deg, #c4e2bd 0%, #8bb97f 100%); color: #193a16; border-color: #6d9c60; }
.cell.found-3 { background: linear-gradient(135deg, #ddc8e8 0%, #ad8ac0 100%); color: #3a1a4a; border-color: #8f6ba3; }
.cell.found-4 { background: linear-gradient(135deg, #f0e3b4 0%, #cfb567 100%); color: #4d3a0b; border-color: #ab923f; }

/* 錯誤震顫 (Cinnabar Shake) */
.cell.invalid {
  animation: shake-cinnabar 0.4s ease;
  background: linear-gradient(135deg, #fae0db 0%, #f0bdb4 100%);
  border-color: var(--palace-vermilion);
  color: var(--palace-vermilion-deep);
}

@keyframes shake-cinnabar {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-1.5deg); }
  40% { transform: translateX(5px) rotate(1.5deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* 閃現金光 */
.cell.flash {
  background: linear-gradient(135deg, #fff7dc 0%, #fce196 100%) !important;
  border-color: var(--palace-gold-bright) !important;
  color: var(--palace-gold-dark) !important;
  box-shadow: 0 0 18px var(--palace-gold-bright);
  animation: flash-gold-pulse 0.7s infinite alternate;
}

@keyframes flash-gold-pulse {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.08); filter: brightness(1.28); }
}

/* 乾隆御覽硃砂圈印 (Circle Seal) */
.cell.hint-circle::after {
  content: "";
  position: absolute;
  inset: 5%;
  border: 3px solid var(--palace-vermilion);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 10px var(--palace-vermilion-glow), inset 0 0 6px var(--palace-vermilion-glow);
  animation: circle-seal-stamp 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes circle-seal-stamp {
  0% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── 密室線索古卷清單 (Target List - 故宮紅木博古架卡片) ── */
.target-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.target-list li.target-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  line-height: 1.68;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, rgba(255, 253, 249, 0.97) 0%, rgba(248, 241, 227, 0.95) 100%);
  border: 1.5px solid var(--palace-gold);
  border-left: 5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-ink);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.target-list li.target-card:hover {
  transform: translateX(5px);
  border-color: var(--palace-gold-bright);
  box-shadow: 0 5px 15px rgba(197, 154, 63, 0.25);
}

.target-list li.target-card.selected {
  border-color: var(--palace-indigo);
  border-left-color: var(--palace-vermilion);
  background: linear-gradient(135deg, #ffffff 0%, #f2ebdf 100%);
  box-shadow: 0 0 0 2px rgba(44, 74, 111, 0.35), 0 5px 16px rgba(26, 23, 20, 0.12);
  transform: translateX(7px);
}

.target-list li.target-card.done {
  text-decoration: line-through;
  text-decoration-color: var(--palace-vermilion);
  text-decoration-thickness: 2.5px;
  color: var(--palace-ink-soft);
  cursor: default;
  letter-spacing: 0.18em;
  font-size: 1.05rem;
  border-left-color: var(--palace-vermilion);
  background: rgba(239, 230, 214, 0.65);
  opacity: 0.85;
}

.target-list li.target-card.done::after {
  content: "破";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) rotate(12deg);
  font-family: var(--font-calligraphy);
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--palace-vermilion);
  border: 1.5px solid var(--palace-vermilion);
  border-radius: 4px;
  padding: 0 0.3rem;
  opacity: 0.8;
  box-shadow: 0 2px 4px var(--palace-vermilion-glow);
}

.clue-text { flex: 1; min-width: 0; }

.clue-tag {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  border-radius: 4px;
  padding: 0.14rem 0.55rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.clue-tag[data-style="釋義"]   { background: #dceaf2; color: #1c455c; border: 1px solid #acc8d8; }
.clue-tag[data-style="急轉彎"] { background: #faecc3; color: #7f5203; border: 1px solid #e0c67e; }
.clue-tag[data-style="典故"]   { background: #ebd5e4; color: #6b335c; border: 1px solid #ccaec4; }
.clue-tag[data-style="換句話說"]   { background: #dfebd4; color: #3b5d23; border: 1px solid #b6d1a5; }
.clue-tag[data-style="情境"]   { background: #f7ded3; color: #873d1f; border: 1px solid #dfb09e; }

/* ── 提示工具列 (Hint Bar) ── */
.hint-bar {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hint-btn {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: linear-gradient(145deg, #fffdf8 0%, #f4e9d7 100%);
  color: var(--palace-ink-deep);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(26, 23, 20, 0.08);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hint-btn:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: var(--palace-gold-bright);
  box-shadow: 0 5px 14px rgba(197, 154, 63, 0.3);
}

.hint-btn small { color: var(--palace-ink-soft); font-size: 0.74rem; font-weight: 400; }
.hint-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }

.hint-btn.earn {
  background: linear-gradient(135deg, var(--palace-indigo) 0%, var(--palace-indigo-deep) 100%);
  color: #fff9ed;
  border-color: var(--palace-gold-bright);
  box-shadow: 0 3px 10px rgba(44, 74, 111, 0.35);
}
.hint-btn.earn small { color: #dce7ee; }
.hint-btn.earn:not(:disabled):hover {
  box-shadow: 0 5px 16px rgba(44, 74, 111, 0.48), 0 0 12px var(--palace-gold-glow);
}

.hint-quota {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--palace-ink-soft);
  font-weight: 600;
}
.hint-quota.exhausted { color: var(--palace-vermilion); text-shadow: 0 0 8px var(--palace-vermilion-glow); font-weight: 700; }
.hint-msg {
  text-align: center;
  margin-top: 0.7rem;
  min-height: 1.4em;
  color: var(--palace-vermilion);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

/* ── 國風按鈕全域 (Buttons) ── */
.primary-btn, .ghost-btn, .danger-btn {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  border-radius: 999px;
  padding: 0.48rem 1.3rem;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.primary-btn {
  background: linear-gradient(135deg, var(--palace-indigo) 0%, var(--palace-indigo-deep) 100%);
  color: #fff9ee;
  border: 1.5px solid var(--palace-gold-bright);
  box-shadow: 0 3px 10px rgba(44, 74, 111, 0.35);
}
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(44, 74, 111, 0.45), 0 0 12px var(--palace-gold-glow);
}

.ghost-btn {
  background: rgba(250, 246, 237, 0.9);
  color: var(--palace-indigo-deep);
  border: 1.5px solid var(--palace-gold);
  box-shadow: 0 2px 6px rgba(26, 23, 20, 0.05);
}
.ghost-btn:hover {
  background: #ffffff;
  border-color: var(--palace-gold-bright);
  color: var(--palace-vermilion);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(197, 154, 63, 0.22);
}

.danger-btn {
  background: linear-gradient(135deg, var(--palace-vermilion) 0%, var(--palace-vermilion-deep) 100%);
  color: #fff9ee;
  border: 1.5px solid var(--palace-gold-bright);
  box-shadow: 0 3px 10px rgba(184, 40, 35, 0.35);
}
.danger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(184, 40, 35, 0.45);
}

/* ── 彈窗系統 (Modals - 故宮綾絹裝裱錦匣) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 12, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.modal {
  position: relative;
  width: min(92vw, 460px);
  background: var(--palace-paper-card);
  border: 2.5px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.4rem 1.4rem;
  box-shadow: 
    0 18px 50px rgba(14, 12, 10, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    inset 0 0 0 4px var(--palace-paper-deep);
  animation: palace-modal-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes palace-modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.95rem;
  font: inherit;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--palace-ink-soft);
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  transform: rotate(90deg);
  color: var(--palace-vermilion);
}

.card-badge {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--palace-vermilion) 0%, var(--palace-vermilion-deep) 100%);
  border: 1px solid var(--palace-gold-bright);
  border-radius: 4px;
  padding: 0.18rem 0.65rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.22em;
  box-shadow: 0 2px 6px var(--palace-vermilion-glow);
}

.card-text {
  font-family: var(--font-calligraphy);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  margin-bottom: 0.85rem;
  color: var(--palace-ink-deep);
}

.card-meaning { margin-bottom: 0.65rem; line-height: 1.8; font-size: 1.02rem; }
.card-insight { color: var(--palace-indigo-deep); line-height: 1.8; margin-bottom: 0.65rem; font-weight: 600; }
.card-source { color: var(--palace-ink-soft); font-size: 0.9rem; }

/* 研墨答題 (Quiz Modal) */
.quiz-examiner-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  margin-bottom: 1.1rem;
}

.quiz-examiner-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--palace-gold);
  box-shadow: 0 2px 6px rgba(197, 154, 63, 0.25);
  flex-shrink: 0;
  overflow: hidden;
}

.examiner-name {
  display: block;
  font-family: var(--font-calligraphy);
  font-size: 1rem;
  color: var(--palace-indigo-deep);
  margin-bottom: 0.15rem;
}

.examiner-quote {
  font-size: 0.85rem;
  color: var(--palace-ink-soft);
  line-height: 1.45;
}

.quiz-prompt {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1.85;
  margin-bottom: 1.1rem;
  letter-spacing: 0.08em;
  color: var(--palace-ink-deep);
}

.quiz-options { display: grid; gap: 0.65rem; }
.quiz-options button {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  background: var(--palace-paper-card);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2px 5px rgba(26, 23, 20, 0.06);
  transition: all 0.2s ease;
}

.quiz-options button:hover:not(:disabled) {
  border-color: var(--palace-gold-bright);
  transform: translateY(-1px);
}

.quiz-options button.correct {
  background: #e2f0d9;
  border-color: var(--palace-jade);
  color: var(--palace-jade);
  font-weight: 700;
}

.quiz-options button.wrong {
  background: #fde4e2;
  border-color: var(--palace-vermilion);
  color: var(--palace-vermilion-deep);
}

/* ── 角色展演台與漫畫對話 (Character Stage & Comic Bubbles) ── */
.fengshen-companion.character-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98) 0%, rgba(246, 238, 222, 0.95) 100%);
  border: 2px solid var(--palace-gold);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 8px 24px rgba(26, 23, 20, 0.12), 0 2px 6px rgba(197, 154, 63, 0.2);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.stage-aura-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.stage-magic-circle {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1.5px dashed rgba(197, 154, 63, 0.38);
  box-shadow: inset 0 0 20px rgba(197, 154, 63, 0.15), 0 0 15px rgba(197, 154, 63, 0.2);
  animation: magic-circle-spin 24s linear infinite;
}

@keyframes magic-circle-spin {
  0% { transform: translateX(-50%) rotate(0deg); }
  100% { transform: translateX(-50%) rotate(360deg); }
}

.companion-standee-container {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 68px;
  margin-top: 0.15rem;
}

.standee-img-container.stage-large .fengshen-standee-img {
  max-height: 60px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(26, 23, 20, 0.18));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: standee-float 4s ease-in-out infinite;
}

@keyframes standee-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}

.character-stage:hover {
  transform: translateY(-3px);
  border-color: var(--palace-gold-bright);
  box-shadow: 0 12px 32px rgba(197, 154, 63, 0.28);
}

.character-stage:hover .fengshen-standee-img {
  transform: translateY(-4px) scale(1.05);
}

/* 漫畫音效標籤 (SFX Tag) */
.comic-sfx-tag {
  position: absolute;
  top: 10px;
  right: 18px;
  z-index: 5;
  font-family: var(--font-calligraphy);
  font-size: 1.45rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--palace-vermilion) 0%, var(--palace-vermilion-deep) 100%);
  border: 2px solid #fff;
  border-radius: 8px;
  padding: 0.12rem 0.6rem;
  transform: rotate(12deg) scale(1);
  box-shadow: 0 4px 12px var(--palace-vermilion-glow), 2px 2px 0 rgba(0,0,0,0.15);
  pointer-events: none;
  letter-spacing: 0.1em;
}

.comic-bubble {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: #ffffff;
  border: 2px solid var(--palace-gold);
  box-shadow: 0 4px 14px rgba(26, 23, 20, 0.08);
}

.companion-name {
  font-family: var(--font-calligraphy);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--palace-indigo-deep);
}

.companion-hint-badge {
  font-size: 0.74rem;
  color: var(--palace-gold-dark);
  background: #fef8eb;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(197, 154, 63, 0.3);
}

.companion-text {
  font-size: 0.95rem;
  color: var(--palace-ink-deep);
  line-height: 1.65;
  margin-top: 0.3rem;
}

/* ── 破陣漫畫特寫 Cut-In 特效 (.manga-cutin-overlay) ── */
.manga-cutin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(14, 12, 10, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  cursor: pointer;
  opacity: 0;
  transition: opacity 220ms ease;
}

.manga-cutin-overlay.active { opacity: 1; }

.cutin-speedlines-bg {
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(197, 154, 63, 0.2) 0deg 3deg,
    transparent 3deg 8deg,
    rgba(255, 255, 255, 0.12) 8deg 11deg,
    transparent 11deg 16deg
  );
  animation: cutin-spin 18s linear infinite;
}

@keyframes cutin-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.cutin-slash-bar {
  position: absolute;
  width: 140%;
  height: 130px;
  background: linear-gradient(90deg, transparent 0%, rgba(184, 40, 35, 0.95) 20%, rgba(197, 154, 63, 0.95) 80%, transparent 100%);
  transform: rotate(-12deg);
  box-shadow: 0 0 40px var(--palace-gold-glow);
  filter: blur(1px);
}

.cutin-content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, 0.75fr);
  grid-template-areas:
    "character kanji"
    "character bubble";
  align-items: center;
  gap: 1rem clamp(1rem, 2.5vw, 2rem);
  max-width: 1120px;
  width: 100%;
  max-height: 100%;
  min-width: 0;
}

.cutin-character-stage {
  grid-area: character;
  min-width: 0;
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(239, 205, 126, 0.9);
  border-radius: 6px 20px 8px 17px;
  background: #efe1c1;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.46), 0 0 0 5px rgba(114, 34, 24, 0.42);
}

.cutin-character-stage .fengshen-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 70vh;
  object-fit: cover;
}

.cutin-kanji-wrap {
  grid-area: kanji;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cutin-kanji-stamp {
  display: block;
  max-width: 100%;
  font-family: var(--font-calligraphy);
  font-size: clamp(2.5rem, 4.5vw, 4.5rem);
  font-weight: 900;
  line-height: 1.12;
  white-space: nowrap;
  color: #fff6d6;
  text-shadow: 
    0 0 20px #f59e0b,
    0 0 40px #b45309,
    4px 4px 0 #78350f,
    8px 8px 20px rgba(0,0,0,0.6);
}

.cutin-kanji-stamp[data-length-tier="long"] { font-size: clamp(1.65rem, 3vw, 3rem); }
.cutin-kanji-stamp[data-length-tier="extra-long"] { font-size: clamp(1.2rem, 2.1vw, 2.15rem); }

.cutin-kanji-sub {
  display: block;
  max-width: 100%;
  font-family: var(--font-serif);
  font-size: clamp(0.78rem, 1.3vw, 1rem);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.16em;
  color: #fef08a;
  background: rgba(18, 14, 11, 0.88);
  border: 1.5px solid #eab308;
  border-radius: 999px;
  padding: 0.25rem 1.1rem;
  margin-top: 0.75rem;
  white-space: normal;
}

.cutin-bubble-wrap {
  grid-area: bubble;
  min-width: 0;
  align-self: start;
}

.cutin-comic-bubble {
  position: relative;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 2px solid #d9b365;
  border-radius: 5px 18px 6px 15px;
  background: rgba(255, 250, 232, 0.96);
  color: #173a38;
  box-shadow: 7px 8px 0 rgba(95, 31, 23, 0.72), 0 14px 26px rgba(0, 0, 0, 0.32);
}

.cutin-comic-bubble strong {
  display: block;
  font-size: 1.05rem;
  color: #842a20;
}

.cutin-comic-bubble p {
  margin: 0.35rem 0 0;
  line-height: 1.55;
}

.cutin-dismiss-hint {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 0.42rem 0.9rem;
  border: 1px solid rgba(245, 214, 142, 0.72);
  border-radius: 999px;
  background: rgba(13, 19, 18, 0.78);
  color: #fff6d6;
  font-size: 0.82rem;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .manga-cutin-overlay {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(44px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .cutin-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "character"
      "kanji"
      "bubble";
    gap: 0.65rem;
    width: min(100%, 620px);
  }

  .cutin-character-stage {
    width: min(100%, 560px);
    max-height: 42dvh;
    justify-self: center;
  }

  .cutin-kanji-stamp { font-size: clamp(2rem, 10vw, 3.5rem); }
  .cutin-kanji-stamp[data-length-tier="long"] { font-size: clamp(1.4rem, 6.5vw, 2.4rem); }
  .cutin-kanji-stamp[data-length-tier="extra-long"] { font-size: clamp(1rem, 4.6vw, 1.65rem); }
  .cutin-comic-bubble { padding: 0.65rem 0.8rem; }
  .cutin-comic-bubble p { font-size: 0.88rem; }
}

/* ── 結算視窗增強：故宮題名榜與法寶 ── */
.complete-modal { text-align: center; }
.complete-array-name {
  font-family: var(--font-calligraphy);
  font-size: 1.05rem;
  color: var(--palace-indigo-deep);
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: 0.1em;
}

.complete-group-photo-wrap {
  margin: 0.8rem 0 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--palace-gold);
  box-shadow: 0 4px 16px rgba(26, 23, 20, 0.15);
}

.complete-group-photo-img {
  width: 100%;
  height: auto;
  display: block;
}

.complete-guardian-feedback, .timeout-rescue-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #ffffff;
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  margin-bottom: 1.1rem;
  text-align: left;
}

.settle-avatar {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(170, 125, 49, 0.58);
  border-radius: 10px;
  background: #fffdf6;
}

.settle-avatar .fengshen-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
}

.complete-treasure-box {
  background: linear-gradient(135deg, #fdf9ee 0%, #faecd0 100%);
  border: 1.5px solid var(--palace-gold);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.3rem;
  text-align: left;
  box-shadow: 0 4px 16px rgba(197, 154, 63, 0.22);
}

.treasure-header {
  font-size: 0.85rem;
  color: var(--palace-vermilion);
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 0.45rem;
}

.treasure-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.treasure-icon { font-size: 2.2rem; line-height: 1; }
.treasure-name {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--palace-ink-deep);
  margin-bottom: 0.15rem;
}
.treasure-desc {
  font-size: 0.94rem;
  color: var(--palace-ink-soft);
  line-height: 1.55;
}

/* ── 底部趣味仙童彩蛋 (.easter-egg-mascot) ── */
.easter-egg-mascot {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

.mascot-avatar-box {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffdf8 0%, #fef3c7 100%);
  border: 2.5px solid var(--palace-gold);
  box-shadow: 0 6px 20px rgba(197, 154, 63, 0.38), inset 0 2px 4px #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: mascot-idle 4s ease-in-out infinite alternate;
}

@keyframes mascot-idle {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(4deg); }
  100% { transform: translateY(0) rotate(-2deg); }
}

.easter-egg-mascot:hover .mascot-avatar-box {
  transform: scale(1.14) translateY(-6px);
  box-shadow: 0 10px 26px rgba(197, 154, 63, 0.48);
}

.mascot-tooltip {
  margin-top: 0.4rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--palace-ink-deep);
  background: #ffffff;
  border: 1px solid var(--palace-gold);
  border-radius: 999px;
  padding: 0.16rem 0.6rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  white-space: nowrap;
}

/* ── 響應式優化 (Mobile RWD) ───────────────── */
@media (max-width: 480px) {
  .app-title { font-size: 1.4rem; letter-spacing: 0.18em; }
  main { padding: 0.8rem 0.6rem 2.5rem; }
  .grid { gap: 4px; }
  .hint-btn { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  .chapter-levels { grid-template-columns: repeat(2, 1fr); }
  .game-top { gap: 0.5rem; flex-wrap: wrap; }
  .card-text { font-size: 1.5rem; }
  .modal { padding: 1.3rem 1rem 1.1rem; }
  .chamber-hero-title { font-size: 1.5rem; }
  .seal-runes { gap: 0.3rem; }
  .seal-rune-node { min-width: 36px; height: 30px; font-size: 0.75rem; }
  .easter-egg-mascot { bottom: 0.8rem; right: 0.8rem; }
  .mascot-avatar-box { width: 52px; height: 52px; }
}

/* ==========================================================================
   故宮博物院宮廷古風 UI 與 16:10 滿版 Q 版角色圖整合樣式
   ========================================================================== */

/* ── 1. 密室大廳 (Chamber View) 故宮宮廷 Hero 大圖與名陣水印 ── */
.palace-hero-card {
  padding: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, #fffcf5 0%, #f7eee0 100%);
  border: 2px solid rgba(198, 146, 36, 0.45);
  box-shadow: 0 10px 30px rgba(24, 20, 17, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  margin-bottom: 1.6rem;
}

.palace-hero-banner-wrap {
  position: relative;
  width: 100%;
  max-height: 240px;
  overflow: hidden;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  border-bottom: 3px solid var(--gold);
}

.palace-hero-banner-img {
  width: 100%;
  height: 100%;
  max-height: 240px;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
  transition: transform 0.4s ease;
}

.palace-hero-banner-wrap:hover .palace-hero-banner-img {
  transform: scale(1.03);
}

.palace-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(24,20,17,0.4) 100%);
  pointer-events: none;
}

.palace-hero-body {
  padding: 1.2rem 1.4rem 1.4rem;
  text-align: center;
}

.palace-seal-tag {
  display: inline-block;
  font-family: var(--font-calligraphy);
  background: var(--vermilion);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--gold-bright);
  margin-right: 0.4rem;
  box-shadow: 0 2px 4px rgba(185, 43, 39, 0.3);
}

/* 陣法卡片故宮名陣水印暗紋與法寶預覽 */
.chamber-card {
  position: relative;
}

.chamber-card-watermark {
  position: absolute;
  right: 12px;
  top: 8px;
  font-family: var(--font-calligraphy);
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--chamber-color, var(--indigo));
  opacity: 0.07;
  pointer-events: none;
  line-height: 1;
  user-select: none;
  letter-spacing: 0.1em;
}

.treasure-preview-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #faecd0 100%);
  border: 1.5px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(198, 146, 36, 0.25);
  flex-shrink: 0;
  padding: 4px;
}

.treasure-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── 2. 遊戲盤面 (Game View) 故宮金絲玉石質感與博古架展演台 ── */
.palace-jade-board {
  position: relative;
  background: linear-gradient(135deg, #fbf7ee 0%, #f3e8d2 100%);
  border: 3px solid #c69224;
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: 
    0 8px 24px rgba(24, 20, 17, 0.15),
    inset 0 0 0 2px rgba(255, 255, 255, 0.7),
    inset 0 0 16px rgba(198, 146, 36, 0.12);
}

.board-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  z-index: 3;
}
.board-corner.corner-tl {
  top: 4px;
  left: 4px;
  border-top: 3px solid #c69224;
  border-left: 3px solid #c69224;
  border-top-left-radius: 4px;
}
.board-corner.corner-tr {
  top: 4px;
  right: 4px;
  border-top: 3px solid #c69224;
  border-right: 3px solid #c69224;
  border-top-right-radius: 4px;
}
.board-corner.corner-bl {
  bottom: 4px;
  left: 4px;
  border-bottom: 3px solid #c69224;
  border-left: 3px solid #c69224;
  border-bottom-left-radius: 4px;
}
.board-corner.corner-br {
  bottom: 4px;
  right: 4px;
  border-bottom: 3px solid #c69224;
  border-right: 3px solid #c69224;
  border-bottom-right-radius: 4px;
}

/* 故宮玉石字格 (Palace Jade Cells) */
.palace-jade-board .cell {
  background: linear-gradient(145deg, #ffffff 0%, #fcf8ee 60%, #f4ebd9 100%);
  border: 1.5px solid #d4af37;
  border-radius: 8px;
  box-shadow: 
    inset 0 1px 2px rgba(255, 255, 255, 0.95),
    inset 0 -1px 2px rgba(198, 146, 36, 0.15),
    0 3px 6px rgba(24, 20, 17, 0.08);
  font-family: var(--font-serif);
  font-weight: 700;
  color: #1a1613;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palace-jade-board .cell:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: #b45309;
  box-shadow: 
    0 6px 14px rgba(198, 146, 36, 0.35),
    0 0 10px rgba(250, 204, 21, 0.4);
}

/* 故宮博古架立繪展演台 (Palace Bogu Shelf Stage) */
.palace-bogu-stage {
  position: relative;
  width: 100%;
  height: 220px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 45%, rgba(255, 253, 248, 0.95) 0%, rgba(244, 235, 217, 0.6) 80%);
  border: 2px solid rgba(198, 146, 36, 0.35);
  box-shadow: inset 0 0 20px rgba(198, 146, 36, 0.08), 0 4px 14px rgba(24, 20, 17, 0.06);
  overflow: hidden;
}

.bogu-shelf-lattice {
  position: absolute;
  inset: 6px;
  border: 1.5px solid rgba(140, 99, 16, 0.2);
  border-radius: 8px;
  background-image: 
    linear-gradient(rgba(140, 99, 16, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 99, 16, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.bogu-cloud-halo {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 2px dashed rgba(212, 175, 55, 0.4);
  box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.15), 0 0 15px rgba(212, 175, 55, 0.2);
  animation: magic-circle-spin 28s linear infinite;
  pointer-events: none;
}

.bogu-jade-pedestal {
  position: absolute;
  bottom: 0;
  left: 15%;
  right: 15%;
  height: 14px;
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 50%, #86efac 100%);
  border: 1.5px solid #2b5442;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 2px 8px rgba(43, 84, 66, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.companion-avatar-wrap {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  border-radius: inherit;
}

.companion-avatar-wrap .fengshen-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.88) contrast(1.03);
  animation: companion-idle 4s ease-in-out infinite;
  transition: transform 0.25s ease;
}

.fengshen-companion:hover .companion-avatar-wrap .fengshen-avatar-img {
  transform: scale(1.04);
}

/* ── 3. 破陣結算彈窗 (宮廷聖旨 / 金榜題名) ── */
.palace-edict-modal {
  position: relative;
  background: linear-gradient(180deg, #fffbf0 0%, #fdf5e2 40%, #f8ecc8 100%) !important;
  border: 3px solid #b45309 !important;
  border-radius: var(--radius-lg);
  box-shadow: 
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(250, 204, 21, 0.35),
    inset 0 0 0 3px rgba(254, 240, 138, 0.8);
  padding: 1.6rem 1.4rem 1.4rem;
  max-width: 520px;
}

.edict-header-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(90deg, #991b1b 0%, #b91c1c 50%, #991b1b 100%);
  color: #fef08a;
  border: 2px solid var(--gold-bright);
  border-radius: 999px;
  padding: 0.35rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(153, 27, 27, 0.4);
}

.edict-plaque-title {
  font-family: var(--font-calligraphy);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.edict-dragon-mark {
  font-size: 1.2rem;
}

.edict-body-wrap {
  position: relative;
}

/* 研墨題未達標時，金印收斂為半透明——避免玩家把「找完字」誤讀成「全部完成」 */
#modal-complete.quiz-pending .palace-vermilion-seal-stamp { opacity: 0.35; filter: grayscale(0.6); }
#modal-complete.quiz-pending .edict-plaque-title::after { content: '（研墨未成）'; font-size: 0.7em; opacity: 0.8; }

.palace-vermilion-seal-stamp {
  position: absolute;
  top: -10px;
  right: -5px;
  width: 58px;
  height: 58px;
  border: 2.5px solid var(--vermilion);
  background: rgba(185, 43, 39, 0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(12deg);
  box-shadow: 0 3px 10px rgba(185, 43, 39, 0.25);
  animation: seal-stamp-in 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  z-index: 10;
  pointer-events: none;
}

@keyframes seal-stamp-in {
  0% { transform: scale(2.2) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(12deg); opacity: 1; }
}

.seal-inner-text {
  font-family: var(--font-calligraphy);
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--vermilion);
  line-height: 1.15;
  text-align: center;
  writing-mode: vertical-rl;
  letter-spacing: 0.15em;
}

.group-photo-silk-ribbon {
  font-family: var(--font-calligraphy);
  font-size: 0.88rem;
  font-weight: 700;
  color: #78350f;
  background: linear-gradient(90deg, #fef08a 0%, #fde047 50%, #fef08a 100%);
  border: 1px solid #ca8a04;
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  margin-top: 0.4rem;
  box-shadow: 0 2px 6px rgba(202, 138, 4, 0.25);
  display: inline-block;
}

.treasure-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: radial-gradient(circle, #ffffff 40%, #fef08a 100%);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(198, 146, 36, 0.35);
  flex-shrink: 0;
  padding: 6px;
}

.treasure-shard-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* ── 響應式優化 (Mobile & Tablet RWD) ── */
@media (max-width: 959px) {
  .fengshen-companion.character-stage {
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 0.95rem;
    gap: 0.95rem;
  }

  .companion-standee-container {
    flex: 0 0 105px;
    height: 115px;
    margin-top: 0;
  }

  .standee-img-container.stage-large .fengshen-standee-img {
    max-height: 110px;
  }

  .stage-magic-circle {
    width: 130px;
    height: 130px;
    top: 5%;
  }

  .comic-bubble {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0.8rem;
  }

}

@media (max-width: 480px) {
  .app-title { font-size: 1.45rem; letter-spacing: 0.2em; }
  main { padding: 0.8rem 0.6rem 2.8rem; }
  .grid { gap: 5px; padding: 6px; }
  .hint-btn { padding: 0.45rem 0.65rem; font-size: 0.86rem; }
  .chapter-levels { grid-template-columns: repeat(2, 1fr); }
  .game-top { gap: 0.5rem; flex-wrap: wrap; }
  .card-text { font-size: 1.55rem; }
  .modal { padding: 1.35rem 1.1rem 1.2rem; }
  .chamber-hero-title { font-size: 1.6rem; }
  .seal-runes { gap: 0.35rem; }
  .seal-rune-node { min-width: 38px; height: 32px; font-size: 0.78rem; }
  .easter-egg-mascot { bottom: 0.9rem; right: 0.9rem; }
  .mascot-avatar-box { width: 54px; height: 54px; }
}

/* ==========================================================================
   2026 國風潑墨視覺重製
   宣紙留白 × 青墨山水 × 朱砂鈐印 × 泥金神光
   此區為最終主題層，保留既有 HTML class 與遊戲狀態契約。
   ========================================================================== */

:root {
  --palace-vermilion: #a62f25;
  --palace-vermilion-deep: #762018;
  --palace-vermilion-light: #c94c3e;
  --palace-vermilion-glow: rgba(166, 47, 37, 0.32);
  --palace-indigo: #315854;
  --palace-indigo-deep: #173a38;
  --palace-indigo-light: #5f8179;
  --palace-indigo-glow: rgba(49, 88, 84, 0.28);
  --palace-gold: #aa7d31;
  --palace-gold-bright: #d5ad57;
  --palace-gold-dark: #74531d;
  --palace-gold-glow: rgba(170, 125, 49, 0.32);
  --palace-jade: #315f50;
  --palace-jade-light: #658d77;
  --palace-ink: #252b29;
  --palace-ink-deep: #101b1a;
  --palace-ink-soft: #4c5a55;
  --palace-ink-faint: rgba(16, 27, 26, 0.08);
  --palace-paper: #f4eddd;
  --palace-paper-deep: #e4d7bd;
  --palace-paper-card: #fbf7eb;
  --palace-paper-dark: #d2c2a2;
  --paper-trans: rgba(244, 237, 221, 0.9);
  --cell-bg: #fcf8ed;
  --cell-border: #baa06c;
  --radius: 10px;
  --radius-sm: 5px;
  --radius-lg: 16px;
  --shadow-ink: 0 14px 35px rgba(16, 27, 26, 0.1), 0 2px 7px rgba(16, 27, 26, 0.08);
  --shadow-curio: 0 18px 42px rgba(16, 27, 26, 0.12), inset 0 0 0 1px rgba(170, 125, 49, 0.24);
}

html {
  background: var(--palace-paper-deep);
  scroll-behavior: smooth;
}

body {
  isolation: isolate;
  line-height: 1.65;
  background-color: var(--palace-paper);
  background-image:
    radial-gradient(ellipse at 8% 4%, rgba(19, 54, 52, 0.17) 0 1%, transparent 24%),
    radial-gradient(ellipse at 94% 22%, rgba(19, 54, 52, 0.1) 0 2%, transparent 25%),
    linear-gradient(104deg, transparent 0 17%, rgba(91, 75, 48, 0.025) 17.2%, transparent 17.8% 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  background-blend-mode: multiply, multiply, normal, soft-light;
}

body::before {
  top: 8vh;
  right: -12rem;
  width: min(58vw, 760px);
  height: min(58vw, 760px);
  border-radius: 58% 42% 68% 32% / 42% 59% 41% 58%;
  background:
    radial-gradient(ellipse at 42% 46%, rgba(15, 42, 40, 0.2) 0 10%, rgba(35, 70, 65, 0.1) 24%, transparent 60%),
    radial-gradient(ellipse at 61% 58%, rgba(15, 42, 40, 0.1), transparent 50%);
  filter: blur(8px);
  opacity: 0.65;
}

body::after {
  bottom: -15rem;
  left: -11rem;
  width: min(54vw, 690px);
  height: min(54vw, 690px);
  border-radius: 44% 56% 35% 65% / 61% 38% 62% 39%;
  background: radial-gradient(ellipse, rgba(166, 47, 37, 0.1) 0 9%, rgba(170, 125, 49, 0.07) 25%, transparent 62%);
  filter: blur(10px);
  opacity: 0.58;
}

::selection {
  color: #fffdf6;
  background: var(--palace-vermilion);
}

.app-header {
  position: sticky;
  top: 0;
  padding: 0.78rem clamp(0.8rem, 3vw, 2.2rem);
  background:
    linear-gradient(90deg, rgba(251, 247, 235, 0.97), rgba(241, 233, 215, 0.93)),
    repeating-linear-gradient(90deg, transparent 0 32px, rgba(23, 58, 56, 0.035) 33px 34px);
  border-bottom: 1px solid rgba(116, 83, 29, 0.7);
  box-shadow: 0 8px 28px rgba(16, 27, 26, 0.1), inset 0 -3px 0 rgba(166, 47, 37, 0.08);
  backdrop-filter: blur(14px) saturate(0.92);
}

.app-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -3px;
  left: 0;
  height: 5px;
  background: linear-gradient(90deg, transparent, rgba(170, 125, 49, 0.48) 18% 24%, transparent 48%, rgba(166, 47, 37, 0.35) 78%, transparent);
  filter: blur(1px);
  pointer-events: none;
}

.brand-mascot-icon {
  border-color: var(--palace-vermilion);
  background: var(--palace-paper-card);
  box-shadow: 0 0 0 3px rgba(170, 125, 49, 0.2), 0 5px 13px rgba(16, 27, 26, 0.14);
}

.app-seal {
  border: 2px solid rgba(255, 245, 218, 0.86);
  border-radius: 2px 5px 3px 6px;
  background: var(--palace-vermilion);
  box-shadow: 0 0 0 1px var(--palace-vermilion-deep), 2px 3px 0 rgba(118, 32, 24, 0.18);
}

.app-title {
  color: var(--palace-ink-deep);
  text-shadow: 1px 2px 0 rgba(255, 255, 255, 0.65);
}

.nav-btn,
.primary-btn,
.ghost-btn,
.danger-btn,
.hint-btn,
.col-tab-btn,
.quiz-options button {
  min-height: 44px;
}

.nav-btn {
  border: 1px solid rgba(49, 88, 84, 0.32);
  border-radius: 5px 11px 5px 10px;
  color: var(--palace-indigo-deep);
  background: rgba(251, 247, 235, 0.66);
  box-shadow: none;
}

.nav-btn.active {
  border-color: var(--palace-gold-bright);
  background: linear-gradient(145deg, #254d49, #102d2b);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.18), 0 4px 11px rgba(16, 45, 43, 0.24);
}

main {
  width: 100%;
  padding-top: clamp(1rem, 2.6vw, 2rem);
}

main:has(#view-chamber:not(.hidden)),
main:has(#view-map:not(.hidden)),
main:has(#view-collection:not(.hidden)) {
  max-width: 1120px;
}

.view-title {
  color: var(--palace-ink-deep);
}

.view-title::before {
  content: "印";
  display: inline-grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 2px 5px 3px 4px;
  color: var(--palace-vermilion);
  font-size: 0.72rem;
  transform: rotate(-5deg);
}

.view-title::after {
  height: 7px;
  background: linear-gradient(90deg, var(--palace-gold), rgba(49, 88, 84, 0.28) 42%, transparent 88%);
  clip-path: polygon(0 36%, 92% 20%, 100% 48%, 84% 62%, 3% 74%);
}

.palace-hero-card {
  border: 1px solid rgba(116, 83, 29, 0.72);
  border-radius: 4px 18px 5px 16px;
  background: rgba(251, 247, 235, 0.88);
  box-shadow: var(--shadow-ink), inset 0 0 0 5px rgba(170, 125, 49, 0.08);
}

.palace-hero-banner-wrap {
  max-height: 390px;
  background: #102d2b;
  border-bottom: 2px solid var(--palace-gold);
}

.palace-hero-banner-img {
  max-height: 390px;
  aspect-ratio: 16 / 7;
  object-position: center 32%;
  filter: saturate(0.86) contrast(1.06);
}

.palace-hero-overlay {
  background:
    linear-gradient(180deg, transparent 42%, rgba(13, 31, 29, 0.62) 100%),
    linear-gradient(90deg, rgba(16, 45, 43, 0.18), transparent 32% 68%, rgba(16, 45, 43, 0.2));
}

.palace-hero-body {
  padding: clamp(1.1rem, 3vw, 2rem);
  background:
    radial-gradient(ellipse at 100% 0, rgba(49, 88, 84, 0.1), transparent 43%),
    linear-gradient(150deg, rgba(255, 253, 245, 0.98), rgba(235, 225, 204, 0.9));
}

.chamber-hero-title {
  font-size: clamp(1.65rem, 4vw, 2.65rem);
  color: var(--palace-ink-deep);
  text-wrap: balance;
}

.chamber-hero-desc {
  max-width: 760px;
  color: #3f4e49;
  font-size: clamp(0.95rem, 1.7vw, 1.05rem);
}

.chamber-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.3vw, 1.6rem);
}

.chamber-card,
.level-card,
.settings-block,
.collection-list button {
  background:
    radial-gradient(ellipse at 104% -8%, rgba(49, 88, 84, 0.13), transparent 38%),
    linear-gradient(145deg, rgba(255, 253, 246, 0.97), rgba(239, 230, 210, 0.94));
  border-color: rgba(116, 83, 29, 0.58);
  border-radius: 5px 15px 6px 13px;
  box-shadow: var(--shadow-ink);
}

.settings-block {
  position: relative;
  overflow: hidden;
}

.chamber-card::before {
  width: 5px;
  background: linear-gradient(var(--chamber-color, var(--palace-indigo)), rgba(49, 88, 84, 0.15));
  box-shadow: 3px 0 9px rgba(16, 27, 26, 0.08);
}

.chamber-card::after,
.settings-block::after {
  content: "";
  position: absolute;
  right: -2rem;
  bottom: -2.4rem;
  width: 9rem;
  height: 6rem;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(23, 58, 56, 0.1), transparent 65%);
  transform: rotate(-15deg);
  pointer-events: none;
}

.chamber-card:hover {
  border-color: var(--palace-gold);
  box-shadow: 0 20px 42px rgba(16, 27, 26, 0.16), 0 0 0 1px rgba(170, 125, 49, 0.18);
}

.chamber-guardian-section,
.quiz-examiner-wrap,
.complete-guardian-feedback,
.timeout-rescue-wrap {
  background: rgba(255, 253, 246, 0.68);
  border-color: rgba(170, 125, 49, 0.44);
  border-radius: 4px 12px 5px 11px;
}

.game-top,
.seal-progress-bar,
.game-board,
.fengshen-companion.character-stage,
.modal {
  border-color: rgba(116, 83, 29, 0.7);
  background:
    radial-gradient(ellipse at 98% 3%, rgba(49, 88, 84, 0.14), transparent 36%),
    linear-gradient(145deg, rgba(255, 253, 246, 0.97), rgba(232, 222, 200, 0.95));
  box-shadow: var(--shadow-ink), inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.grid {
  background:
    radial-gradient(ellipse at 12% 5%, rgba(49, 88, 84, 0.22), transparent 36%),
    linear-gradient(145deg, #cfc1a5, #e9dfca);
  border-color: var(--palace-gold-dark);
  box-shadow: 0 15px 34px rgba(16, 27, 26, 0.18), inset 0 2px 12px rgba(16, 27, 26, 0.12);
}

.cell,
.palace-jade-board .cell {
  border-color: rgba(116, 83, 29, 0.68);
  background:
    linear-gradient(150deg, rgba(255, 255, 250, 0.98), rgba(239, 232, 214, 0.96)),
    radial-gradient(circle, rgba(49, 88, 84, 0.1), transparent 70%);
  color: var(--palace-ink-deep);
  box-shadow: inset 0 1px 0 #fff, 0 2px 5px rgba(16, 27, 26, 0.12);
}

.target-list li.target-card {
  border-color: rgba(170, 125, 49, 0.54);
  border-left-color: var(--palace-vermilion);
  border-radius: 3px 12px 4px 10px;
  background: linear-gradient(100deg, rgba(255, 253, 247, 0.98), rgba(237, 228, 208, 0.92));
}

.palace-bogu-stage {
  height: 248px;
  border-color: rgba(170, 125, 49, 0.5);
  background:
    radial-gradient(circle at 50% 42%, rgba(213, 173, 87, 0.26) 0 12%, transparent 44%),
    radial-gradient(ellipse at 90% 15%, rgba(49, 88, 84, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(254, 251, 241, 0.97), rgba(224, 214, 193, 0.9));
}

.bogu-shelf-lattice {
  opacity: 0.52;
  background-size: 42px 42px;
}

.bogu-cloud-halo {
  border-color: rgba(170, 125, 49, 0.5);
  box-shadow: inset 0 0 24px rgba(170, 125, 49, 0.17), 0 0 20px rgba(49, 88, 84, 0.13);
}

.companion-avatar-wrap {
  height: 100%;
  align-items: stretch;
}

.companion-avatar-wrap .fengshen-avatar-img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  -webkit-mask-image: none;
  mask-image: none;
}

/* 新版單張立繪以克制動態區分角色狀態 */
@keyframes companion-idle {
  0%, 100% { transform: scale(1.025); }
  50% { transform: scale(1.04); }
}

.companion-avatar-wrap .fengshen-avatar-img[data-mood="thinking"] {
  animation: companion-thinking 2.8s ease-in-out infinite;
  transform-origin: 50% 82%;
}

.companion-avatar-wrap .fengshen-avatar-img[data-mood="victory"] {
  animation: companion-victory 720ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: 50% 90%;
}

.companion-avatar-wrap .fengshen-avatar-img[data-mood="panic"] {
  animation: companion-panic 460ms ease-in-out infinite;
  transform-origin: 50% 86%;
}

@keyframes companion-thinking {
  0%, 100% { transform: scale(1.025) rotate(-0.25deg); }
  50% { transform: scale(1.04) rotate(0.25deg); }
}

@keyframes companion-victory {
  0% { transform: scale(1.025); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1.025); }
}

@keyframes companion-panic {
  0%, 100% { transform: scale(1.035) translateX(0); }
  35% { transform: scale(1.035) translateX(-3px); }
  70% { transform: scale(1.035) translateX(3px); }
}

.comic-bubble {
  border-color: rgba(170, 125, 49, 0.6);
  border-radius: 4px 13px 5px 12px;
  background: rgba(255, 253, 246, 0.95);
}

.primary-btn,
.hint-btn.earn {
  border-color: var(--palace-gold-bright);
  border-radius: 4px 11px 5px 10px;
  background: linear-gradient(145deg, #315854, #173a38);
  color: #fffaf0;
}

.ghost-btn,
.hint-btn {
  border-color: rgba(116, 83, 29, 0.66);
  border-radius: 4px 11px 5px 10px;
  background: rgba(251, 247, 235, 0.86);
}

.danger-btn {
  border-radius: 4px 11px 5px 10px;
}

.modal-backdrop {
  background: rgba(8, 22, 21, 0.76);
}

.modal {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border-radius: 5px 18px 6px 15px;
}

/* 手機中文鍵盤開啟時，iOS 不一定會更新 fixed 元素的 layout viewport。
   由 game.js 寫入 Visual Viewport，讓研墨填空列保持在鍵盤上方。 */
.modal-backdrop {
  top: var(--xzzj-visible-viewport-top, 0px);
  right: 0;
  bottom: auto;
  left: 0;
  width: 100%;
  height: var(--xzzj-visible-viewport-height, 100dvh);
}

.modal {
  max-height: calc(var(--xzzj-visible-viewport-height, 100dvh) - 2rem);
}

.quiz-fill input {
  scroll-margin-block: 1rem;
}

.modal-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.code-area,
.cross-input-row input,
.quiz-fill input {
  color: var(--palace-ink-deep);
  background: rgba(255, 253, 246, 0.92);
  border-color: rgba(116, 83, 29, 0.65);
}

:where(
  button,
  [role="button"],
  input,
  textarea,
  select,
  a,
  .cell,
  .target-card,
  .fengshen-companion,
  .easter-egg-mascot
):focus-visible {
  outline: 3px solid var(--palace-vermilion);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 249, 232, 0.92);
}

@media (min-width: 992px) {
  #view-game .game-layout {
    grid-template-columns: minmax(500px, 1fr) minmax(360px, 420px);
  }

  .chapter-levels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header {
    position: relative;
    align-items: center;
    padding: 0.7rem;
  }

  .app-brand {
    max-width: calc(100% - 0.5rem);
  }

  .app-nav {
    width: calc(100% + 1.4rem);
    margin: 0 -0.7rem -0.7rem;
    padding: 0.55rem 0.7rem 0.65rem;
    gap: 0.45rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
    background: rgba(23, 58, 56, 0.06);
  }

  .nav-btn {
    flex: 0 0 auto;
    padding-inline: 0.85rem;
    scroll-snap-align: start;
  }

  .chamber-grid {
    grid-template-columns: 1fr;
  }

  .palace-hero-banner-img {
    aspect-ratio: 4 / 3;
  }

  .chamber-card {
    padding: 1.1rem;
  }

  .chamber-guardian-section {
    align-items: flex-start;
  }

  .game-top > * {
    flex: 1 1 auto;
  }

  .ink-display {
    margin-left: 0;
  }

  .hint-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hint-quota {
    grid-column: 1 / -1;
  }

  .hint-btn {
    width: 100%;
  }

  .fengshen-companion.character-stage {
    flex-direction: column;
  }

  .palace-bogu-stage {
    flex: none;
    width: 100%;
    height: 228px;
  }

  .settings-actions > * {
    flex: 1 1 10rem;
  }
}

@media (max-width: 480px) {
  .brand-mascot-icon {
    width: 40px;
    height: 40px;
  }

  .app-seal {
    display: none;
  }

  .app-title {
    font-size: 1.35rem;
    letter-spacing: 0.14em;
  }

  main {
    padding-inline: 0.65rem;
  }

  .palace-hero-body {
    padding-inline: 0.9rem;
  }

  .chamber-hero-title {
    letter-spacing: 0.16em;
  }

  .chamber-guardian-section {
    flex-direction: column;
  }

  .chamber-guardian-standee-box {
    width: 100%;
    flex-basis: 132px;
  }

  .grid {
    width: min(94vw, 450px);
    border-width: 1px;
  }

  .palace-jade-board {
    padding: 0.55rem;
  }

  .target-list li.target-card {
    gap: 0.5rem;
    padding: 0.65rem 0.7rem;
  }

  .fengshen-companion.character-stage {
    flex-direction: column;
  }

  .palace-bogu-stage {
    flex: none;
    width: 100%;
    height: 228px;
  }

  .companion-avatar-wrap {
    height: 100%;
  }

  .companion-avatar-wrap .fengshen-avatar-img {
    max-height: none;
  }

  .modal-backdrop {
    padding: 0.6rem;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: calc(var(--xzzj-visible-viewport-height, 100dvh) - 1.2rem);
  }
}

@media (hover: none) {
  .nav-btn:hover,
  .chamber-card:hover,
  .cell:hover,
  .target-list li.target-card:hover,
  .primary-btn:hover,
  .ghost-btn:hover,
  .danger-btn:hover,
  .hint-btn:not(:disabled):hover {
    transform: none;
  }
}

/* ── 封神山河闖關圖：關卡直接疊在同一張大地圖上 ──
   桌機：沉浸式全螢幕疊層。
   手機（≤760px）：真 iOS 對「fixed 全螢幕＋巨型捲動畫布」會整段拒繪（實機踩雷），
   一律改走一般頁面流，只有地圖框本身可平移。 */
@media (min-width: 761px) {
  .map-immersive-active {
    overflow: hidden;
  }

  .map-immersive-active > .app-header,
  .map-immersive-active > #mobile-tabbar {
    visibility: hidden;
    pointer-events: none;
  }

  #view-map:not(.hidden) {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 1200;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: max(0.8rem, env(safe-area-inset-top)) max(0.85rem, env(safe-area-inset-right)) max(0.8rem, env(safe-area-inset-bottom)) max(0.85rem, env(safe-area-inset-left));
    overflow: hidden;
    background:
      radial-gradient(circle at 12% 10%, rgba(231, 196, 111, 0.2), transparent 27%),
      linear-gradient(145deg, #102d2b 0%, #173c38 45%, #0c2423 100%);
  }

  #view-map:fullscreen {
    width: 100vw;
    height: 100vh;
  }
}


.map-immersive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.1rem 0.2rem 0.65rem;
  color: #fff7dc;
}

.map-immersive-toolbar .view-title {
  margin: 0;
  color: #fff7dc;
}

.map-immersive-kicker {
  display: block;
  margin-bottom: 0.12rem;
  color: #e8c36a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.map-immersive-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.map-immersive-actions .ghost-btn {
  border-color: rgba(255, 247, 220, 0.58);
  color: #fff7dc;
  background: rgba(7, 27, 25, 0.62);
}

#view-map .map-instruction {
  color: rgba(255, 247, 220, 0.86);
}

#view-map .level-map {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#view-map .map-progress {
  color: #fff7dc;
  /* 地圖檢視內禁用 backdrop-filter：iOS 對 fixed 全螢幕＋巨型捲動畫布取樣背景會整段拒繪 */
  background: rgba(7, 27, 25, 0.9);
}

#view-map .map-progress .muted {
  color: rgba(255, 247, 220, 0.74);
}

#view-map .map-progress .rank-stats {
  color: #f4dfaa;
}

.map-instruction {
  margin: 0 0 0.75rem;
  color: var(--palace-ink-soft);
  text-align: center;
}

.world-map-shell {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  border: 2px solid rgba(116, 83, 29, 0.72);
  border-radius: 7px 22px 8px 18px;
  background: #173a38;
  box-shadow: 0 18px 42px rgba(16, 27, 26, 0.2), inset 0 0 0 5px rgba(244, 237, 221, 0.15);
  scrollbar-color: var(--palace-gold) rgba(244, 237, 221, 0.72);
  scrollbar-width: thin;
}

#view-map .world-map-shell {
  height: 100%;
  /* 高度保險絲：部分 iOS Safari 會把巢狀 grid 裡的百分比高度算成近 0，
     地圖整條縮成細縫；vh 是全瀏覽器都吃的單位，保底一定看得到地圖。 */
  min-height: 55vh;
  overflow: auto;
  overscroll-behavior: contain;
}

.world-map-canvas {
  position: relative;
  min-width: 2600px;
  /* iOS 經典地雷：fixed 容器內的捲動區程式跳捲後拒繪；把內容強制升到獨立合成層。
     另外不用 isolation/filter/全幅覆蓋層，修復度黯淡直接併進背景漸層堆疊。 */
  transform: translateZ(0);
  background:
    linear-gradient(180deg, rgba(9, 30, 28, 0.02), rgba(9, 30, 28, 0.13)),
    url('../assets/art/generated/chamber-map-v2.webp') center / 100% 100% no-repeat;
}

.world-map-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 8px solid rgba(244, 237, 221, 0.18);
  background: linear-gradient(90deg, rgba(12, 31, 29, 0.16), transparent 12% 88%, rgba(12, 31, 29, 0.16));
  pointer-events: none;
}

.world-map-canvas .path-svg,
.world-map-canvas .path-node-wrap,
.world-map-canvas .chapter-landmark {
  z-index: 2;
}

.world-map-canvas .path-line {
  stroke: #f3d275;
  stroke-width: 2;
  opacity: 0.16;
  /* 不加 drop-shadow：2600×900 SVG 的濾鏡區在 iOS 上同樣會撞層大小上限 */
}

.world-map-canvas .path-badges {
  display: none;
}

.world-map-canvas .path-node.locked {
  width: 44px;
  height: 44px;
  opacity: 0.82;
}

.world-map-canvas .path-node.locked.event::after {
  display: none;
}

.world-map-canvas .route-line-lore { stroke: #9fe0d0; stroke-dasharray: 10 7; }
.world-map-canvas .route-line-treasure { stroke: #f4bb4f; stroke-dasharray: 3 7; }
.world-map-canvas .path-node.route-lore { border-color: #55a895; }
.world-map-canvas .path-node.route-treasure { border-color: #c4851c; }
.world-map-canvas .path-node.boss { width: 62px; height: 62px; border-color: #9f241d; box-shadow: 0 0 0 5px rgba(159, 36, 29, 0.22), 0 6px 18px rgba(8, 24, 23, 0.7); }
.world-map-canvas .path-node.event::after { content: "!"; position: absolute; translate: 18px -20px; color: #fff7dd; background: #a9362d; border-radius: 50%; width: 20px; height: 20px; line-height: 20px; }
/* 修復進度的畫面氛圍：不可用 filter／覆蓋層（iOS 大層拒繪），
   直接以不同深淺的漸層疊在背景圖堆疊最上層。 */
.world-map-canvas.world-repaired-0 { background:
  linear-gradient(180deg, rgba(9, 30, 28, 0.3), rgba(9, 30, 28, 0.38)),
  url('../assets/art/generated/chamber-map-v2.webp') center / 100% 100% no-repeat; }
.world-map-canvas.world-repaired-1 { background:
  linear-gradient(180deg, rgba(9, 30, 28, 0.22), rgba(9, 30, 28, 0.3)),
  url('../assets/art/generated/chamber-map-v2.webp') center / 100% 100% no-repeat; }
.world-map-canvas.world-repaired-2 { background:
  linear-gradient(180deg, rgba(9, 30, 28, 0.15), rgba(9, 30, 28, 0.22)),
  url('../assets/art/generated/chamber-map-v2.webp') center / 100% 100% no-repeat; }
.world-map-canvas.world-repaired-3 { background:
  linear-gradient(180deg, rgba(9, 30, 28, 0.08), rgba(9, 30, 28, 0.15)),
  url('../assets/art/generated/chamber-map-v2.webp') center / 100% 100% no-repeat; }

.daily-encounter-card,
.hidden-level-node,
.boss-phase-hud {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(126, 88, 25, 0.45);
  border-radius: 6px 18px;
  background: rgba(255, 250, 232, 0.92);
  box-shadow: 0 8px 22px rgba(30, 42, 36, 0.12);
}
.daily-encounter-card { display: grid; gap: 0.4rem; }
#view-map .daily-encounter-card {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 6;
  width: min(340px, calc(100% - 2rem));
  margin: 0;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 250, 232, 0.97);
}
#view-map .daily-encounter-card p {
  display: none;
}
#view-map .daily-encounter-card button {
  min-height: 38px;
}
.hidden-level-node { width: 100%; color: #fff8df; background: linear-gradient(110deg, #1a3735, #622621); font-weight: 800; }
.boss-phase-hud { margin: 0.5rem 0 0.9rem; border-color: rgba(159, 36, 29, 0.65); }
.boss-phase-hud span,
.boss-phase-hud strong { display: block; }
.boss-phase-hud span { color: #9f241d; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; }
.boss-phase-hud p { margin: 0.25rem 0 0; }
.world-choice-list { display: grid; gap: 0.6rem; margin-top: 1rem; }
.world-event-modal { max-width: 560px; }

.world-map-canvas .path-node {
  width: 52px;
  height: 52px;
  border-width: 2px;
  background: radial-gradient(circle, rgba(255, 253, 244, 0.96) 34%, rgba(226, 204, 147, 0.9) 100%);
  box-shadow: 0 3px 9px rgba(8, 24, 23, 0.42), inset 0 0 0 2px rgba(255, 255, 255, 0.66);
}

.world-map-canvas .path-stars,
.world-map-canvas .path-badges {
  color: #fff8dc;
  font-weight: 800;
  text-shadow: 0 1px 3px #102421, 0 0 6px #102421;
}

.chapter-landmark {
  position: absolute;
  top: 42px;
  display: grid;
  min-width: 146px;
  transform: translateX(-50%);
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(238, 199, 105, 0.78);
  border-radius: 4px 14px 4px 12px;
  background: rgba(17, 50, 46, 0.86);
  color: #fff7dd;
  text-align: center;
  box-shadow: 0 6px 18px rgba(7, 24, 22, 0.32);
}

.chapter-landmark span {
  color: #e8c36a;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

.chapter-landmark strong {
  margin-top: 0.12rem;
  font-family: var(--font-serif);
  letter-spacing: 0.08em;
}

.generated-portrait {
  filter: saturate(0.88) contrast(1.03);
}

@media (max-width: 760px) {
  #view-map:not(.hidden) {
    padding: max(0.55rem, env(safe-area-inset-top)) max(0.55rem, env(safe-area-inset-right)) max(0.55rem, env(safe-area-inset-bottom)) max(0.55rem, env(safe-area-inset-left));
  }

  .map-immersive-toolbar {
    align-items: flex-start;
  }

  .map-immersive-toolbar .view-title::before,
  .map-immersive-toolbar .view-title::after,
  #btn-map-fullscreen {
    display: none;
  }

  .map-immersive-actions {
    flex: 0 0 auto;
  }

  #btn-close-map {
    min-height: 44px;
    padding-inline: 0.72rem;
    font-size: 0.82rem;
  }

  #view-map .map-instruction {
    margin-bottom: 0.45rem;
    font-size: 0.78rem;
  }

  #view-map .map-progress {
    gap: 0.4rem 0.65rem;
    margin-bottom: 0.45rem;
    padding: 0.55rem 0.65rem;
  }

  #view-map .map-progress .rank-badge {
    padding: 0.2rem 0.55rem;
    font-size: 0.82rem;
  }

  #view-map .map-progress .rank-next {
    flex-basis: 100%;
    font-size: 0.74rem;
  }

  .world-map-shell {
    margin-inline: -0.55rem;
  }

  #view-map .world-map-shell {
    margin-inline: 0;
  }

  #view-map .daily-encounter-card {
    right: 0.55rem;
    bottom: 0.55rem;
    width: auto;
    padding: 0.4rem;
  }

  #view-map .daily-encounter-card > span,
  #view-map .daily-encounter-card > strong {
    display: none;
  }

  #view-map .daily-encounter-card button {
    min-height: 44px;
    padding-inline: 0.7rem;
  }
}

@media (prefers-contrast: more) {
  :root {
    --palace-ink-soft: #27332f;
    --palace-gold: #79571d;
  }

  .nav-btn,
  .chamber-card,
  .level-card,
  .target-list li.target-card,
  .hint-btn,
  .modal,
  .settings-block,
  .collection-list button {
    border-width: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  body::before,
  body::after,
  .stage-magic-circle,
  .bogu-cloud-halo,
  .cutin-speedlines-bg {
    animation: none !important;
  }

  .companion-avatar-wrap .fengshen-avatar-img[data-mood] {
    animation: none !important;
    transform: none !important;
  }
}

/* ── 全站封神敘事配圖插槽（由媒體整合層掛載） ── */
.section-story-figure,
.map-story-figure,
.game-story-figure,
.collection-story-figure,
.chamber-scene-figure {
  position: relative;
  isolation: isolate;
  margin: 0 0 clamp(1rem, 2.4vw, 1.6rem);
  overflow: hidden;
  border: 1px solid rgba(116, 83, 29, 0.7);
  border-radius: 4px 17px 5px 14px;
  background: #173a38;
  box-shadow: 0 15px 34px rgba(16, 27, 26, 0.15), inset 0 0 0 4px rgba(213, 173, 87, 0.1);
}

.section-story-figure::after,
.map-story-figure::after,
.game-story-figure::after,
.collection-story-figure::after,
.chamber-scene-figure::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 5px solid rgba(244, 237, 221, 0.24);
  background:
    linear-gradient(180deg, transparent 48%, rgba(9, 30, 28, 0.35)),
    linear-gradient(90deg, rgba(9, 30, 28, 0.2), transparent 25% 75%, rgba(9, 30, 28, 0.18));
  pointer-events: none;
}

.section-story-img,
.map-story-figure img,
.game-story-figure img,
.collection-story-figure img,
.chamber-scene-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 7;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.82) contrast(1.05) sepia(0.04);
  transition: transform 500ms ease, filter 500ms ease;
}

.section-story-figure:hover img,
.map-story-figure:hover img,
.game-story-figure:hover img,
.collection-story-figure:hover img,
.chamber-scene-figure:hover img {
  transform: scale(1.018);
  filter: saturate(0.9) contrast(1.08);
}

.chamber-scene-figure {
  margin: -1.35rem -1.5rem 1rem;
  border-width: 0 0 1px;
  border-radius: 13px 13px 2px 2px;
  box-shadow: 0 8px 22px rgba(16, 27, 26, 0.12);
}

.chamber-scene-img {
  aspect-ratio: 16 / 8.5;
}

.chamber-guardians-container {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  margin: 0.9rem 0;
  padding: 0.75rem;
  border: 1px solid rgba(170, 125, 49, 0.34);
  border-radius: 4px 12px 5px 11px;
  background: rgba(255, 253, 246, 0.68);
}

.guardians-avatar-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.guardian-avatar-item {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  width: 76px;
  cursor: pointer;
}

.avatar-img-box {
  width: 68px;
  height: 68px;
  overflow: hidden;
  border: 2px solid rgba(170, 125, 49, 0.48);
  border-radius: 50%;
  background: radial-gradient(circle, #fffdf6, #e6d9bd);
  box-shadow: 0 4px 12px rgba(16, 27, 26, 0.14);
}

.guardian-avatar-item.active .avatar-img-box {
  border-color: var(--palace-vermilion);
  box-shadow: 0 0 0 3px rgba(168, 55, 45, 0.12), 0 4px 12px rgba(16, 27, 26, 0.16);
}

.avatar-img-box .fengshen-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.guardian-subname {
  color: var(--palace-ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.chamber-guardian-bubble {
  min-width: 0;
}

.bubble-speaker-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: baseline;
}

.chamber-guardian-quote {
  margin: 0.35rem 0 0;
  color: var(--palace-ink-soft);
  line-height: 1.65;
}

@media (max-width: 760px) {
  .section-story-img,
  .map-story-figure img,
  .game-story-figure img,
  .collection-story-figure img {
    aspect-ratio: 4 / 3;
  }

  .chamber-scene-figure {
    margin: -1.1rem -1.1rem 0.9rem;
  }

  .chamber-guardians-container {
    grid-template-columns: 1fr;
  }
}

@media (hover: none) {
  .section-story-figure:hover img,
  .map-story-figure:hover img,
  .game-story-figure:hover img,
  .collection-story-figure:hover img,
  .chamber-scene-figure:hover img {
    transform: none;
  }
}

/* ── 新手、回訪、行動與無障礙體驗層 ───────────────────── */
.resume-quest-card,
.unfinished-quest-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(170, 125, 49, 0.58);
  border-radius: 5px 16px 6px 14px;
  background: linear-gradient(120deg, rgba(255, 253, 246, 0.97), rgba(232, 219, 184, 0.76));
  box-shadow: 0 10px 24px rgba(16, 27, 26, 0.12);
}

.resume-quest-copy,
.unfinished-quest-prompt > div:first-child { min-width: 0; }
.resume-kicker {
  color: var(--palace-vermilion);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.resume-quest-card h2 {
  margin: 0.18rem 0 0.25rem;
  font-family: var(--font-kai);
  font-size: clamp(1.08rem, 3vw, 1.35rem);
}
.resume-quest-card p,
.unfinished-quest-prompt p { margin: 0; color: var(--palace-ink-soft); line-height: 1.55; }
.unfinished-quest-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.class-coop-panel,
.chamber-details,
.game-scene-details {
  border: 1px solid rgba(170, 125, 49, 0.45);
  border-radius: 5px 13px 6px 11px;
  background: rgba(255, 253, 246, 0.76);
}
.class-coop-panel { margin-top: 1.1rem; }
.class-coop-panel > summary,
.chamber-details > summary,
.game-scene-details > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.68rem 0.9rem;
  color: var(--palace-indigo-deep);
  font-weight: 800;
  cursor: pointer;
}
.class-coop-body,
.chamber-details-body { padding: 0 0.95rem 0.95rem; line-height: 1.65; }
.class-coop-fields {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55rem 0.75rem;
  align-items: center;
  margin: 0.8rem 0;
}
.class-coop-fields input {
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(116, 83, 29, 0.62);
  border-radius: 7px;
  background: #fffdf6;
  font: inherit;
}
.class-coop-fields button { grid-column: 2; }
.privacy-note {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border-left: 4px solid var(--palace-jade);
  background: rgba(46, 93, 75, 0.08);
  color: var(--palace-ink-soft);
  font-size: 0.88rem;
}

.mobile-tabbar,
.mobile-game-controls { display: none; }

.game-scene-details { margin-bottom: 1rem; overflow: hidden; }
.game-scene-details > summary { justify-content: space-between; }
.game-scene-details > summary small { color: var(--palace-ink-soft); font-weight: 500; }
.game-scene-details .game-story-figure { margin: 0; border-width: 1px 0 0; border-radius: 0; }

.level-learning-goal,
.ink-earning-note {
  margin: 0 0 0.8rem;
  padding: 0.65rem 0.8rem;
  border-left: 4px solid var(--palace-jade);
  background: rgba(46, 93, 75, 0.08);
  color: var(--palace-ink-soft);
  line-height: 1.55;
  font-size: 0.88rem;
}

.ink-earning-note { margin-top: 0.55rem; font-size: 0.8rem; }

.play-instruction-tip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 2px solid var(--palace-gold);
  border-radius: 8px 14px 8px 14px;
  background: #fff9e8;
  box-shadow: 0 8px 18px rgba(16, 27, 26, 0.12);
}
.play-instruction-tip > span { font-size: 1.65rem; }
.play-instruction-tip p { flex: 1; min-width: 0; margin: 0; }
.play-instruction-tip p span { display: block; color: var(--palace-ink-soft); line-height: 1.5; }
.play-instruction-tip button,
.rest-reminder button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--palace-gold-dark);
  border-radius: 8px;
  background: #fffdf6;
  color: var(--palace-ink-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.play-mode-selector { border: 0; }
.play-mode-selector legend { margin-bottom: 0.6rem; color: var(--palace-ink-soft); }
.play-mode-selector label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 52px;
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(170, 125, 49, 0.4);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.72);
  cursor: pointer;
}
.play-mode-selector input { width: 22px; height: 22px; accent-color: var(--palace-vermilion); }
.play-mode-selector span { display: grid; gap: 0.15rem; }
.play-mode-selector small { color: var(--palace-ink-soft); line-height: 1.4; }

.onboarding-modal { width: min(92vw, 520px); }
.onboarding-modal h2 { margin: 0.2rem 0 0.5rem; font-family: var(--font-kai); }
.onboarding-steps { display: grid; gap: 0.75rem; margin: 1rem 0; list-style: none; }
.onboarding-steps li { display: flex; align-items: center; gap: 0.75rem; }
.onboarding-steps li > span {
  flex: 0 0 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--palace-indigo-deep);
  color: #fffdf6;
  font-weight: 800;
}
.onboarding-steps li div { display: grid; gap: 0.1rem; }
.onboarding-steps small { color: var(--palace-ink-soft); line-height: 1.4; }
.onboarding-modal > .primary-btn { width: 100%; min-height: 48px; }

.session-summary-card {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(170, 125, 49, 0.52);
  border-radius: 5px 13px 6px 11px;
  background: #fffdf6;
  text-align: left;
}
#modal-complete .complete-guardian-feedback {
  background: #fffdf6;
}
.session-summary-card h4 { margin: 0.15rem 0 0.35rem; font-size: 1.05rem; }
.session-summary-card ul { margin: 0.55rem 0 0; padding-left: 1.2rem; }

.rest-reminder {
  position: fixed;
  z-index: 120;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--palace-gold);
  border-radius: 8px 15px 8px 15px;
  background: #fffdf6;
  box-shadow: 0 16px 36px rgba(8, 22, 21, 0.24);
}
.rest-reminder div { flex: 1; min-width: 0; }
.rest-reminder p { margin: 0.2rem 0 0; color: var(--palace-ink-soft); font-size: 0.86rem; line-height: 1.45; }

.online-presence {
  position: fixed;
  z-index: 1300;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.48rem 0.72rem;
  border: 1px solid rgba(222, 191, 111, 0.68);
  border-radius: 999px;
  background: rgba(17, 50, 46, 0.92);
  color: #fff8df;
  box-shadow: 0 8px 22px rgba(8, 22, 21, 0.25);
  backdrop-filter: blur(9px);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.online-presence-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #6ed49b;
  box-shadow: 0 0 0 4px rgba(110, 212, 155, 0.16), 0 0 10px rgba(110, 212, 155, 0.7);
}

.online-presence.is-offline { opacity: 0.76; }
.online-presence.is-offline .online-presence-dot {
  background: #b9b3a2;
  box-shadow: none;
}

body:has(.modal-backdrop:not(.hidden)) .online-presence {
  visibility: hidden;
  pointer-events: none;
}

.map-immersive-active #view-map .daily-encounter-card { bottom: 4.5rem; }

@media (max-width: 760px) {
  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); overflow-x: clip; }
  #view-game:not(.hidden) {
    display: flex;
    flex-direction: column;
  }
  #view-game:not(.hidden) .mobile-game-controls { order: 0; }
  #view-game:not(.hidden) .game-top { order: 1; }
  #view-game:not(.hidden) .play-instruction-tip { order: 2; }
  #view-game:not(.hidden) .game-layout { display: contents; }
  #view-game:not(.hidden) .game-board { order: 3; margin-bottom: 0.8rem; }
  #view-game:not(.hidden) .level-learning-goal { order: 4; }
  #view-game:not(.hidden) .seal-progress-bar { order: 5; }
  #view-game:not(.hidden) .game-panel { order: 6; }
  #view-game:not(.hidden) .game-scene-details { order: 7; }
  main,
  .view,
  .chamber-card,
  .game-layout,
  .game-board,
  .game-panel { max-width: 100%; min-width: 0; }

  .app-header .app-nav { display: none; }
  .mobile-tabbar {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 0.35rem max(0.35rem, env(safe-area-inset-right)) calc(0.35rem + env(safe-area-inset-bottom)) max(0.35rem, env(safe-area-inset-left));
    border-top: 1px solid rgba(170, 125, 49, 0.58);
    background: rgba(255, 253, 246, 0.96);
    box-shadow: 0 -8px 22px rgba(8, 22, 21, 0.12);
    backdrop-filter: blur(12px);
  }
  .mobile-tabbar .nav-btn {
    min-width: 0;
    min-height: 52px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.1rem;
    padding: 0.25rem 0.1rem;
    border-color: transparent;
    border-radius: 8px;
    box-shadow: none;
    font-size: 0.72rem;
  }
  .mobile-tabbar .nav-btn span:first-child { font-size: 1.15rem; line-height: 1; }

  #view-game:not(.hidden) .mobile-game-controls {
    position: sticky;
    z-index: 25;
    top: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    margin: -0.25rem 0 0.75rem;
    padding: 0.45rem;
    border: 1px solid rgba(170, 125, 49, 0.46);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.94);
    backdrop-filter: blur(9px);
  }
  .mobile-game-controls button {
    min-height: 44px;
    border: 1px solid rgba(116, 83, 29, 0.58);
    border-radius: 7px;
    background: #fffdf6;
    color: var(--palace-indigo-deep);
    font: inherit;
    font-weight: 800;
  }
  #view-game:not(.hidden) ~ .mobile-tabbar,
  body:has(#view-game:not(.hidden)) .mobile-tabbar { display: none; }
  body:has(#view-game:not(.hidden)) { padding-bottom: env(safe-area-inset-bottom); }

  .resume-quest-card,
  .unfinished-quest-prompt,
  .play-instruction-tip { align-items: stretch; flex-direction: column; }
  .resume-quest-card > button,
  .unfinished-quest-actions > button { flex: 1; min-height: 48px; }
  .unfinished-quest-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .game-scene-details:not([open]) { margin-bottom: 0.7rem; }
  .game-scene-details > summary small { font-size: 0.72rem; }
  .class-coop-fields { grid-template-columns: 1fr; }
  .class-coop-fields button { grid-column: 1; min-height: 48px; }
  .settings-actions { display: grid; grid-template-columns: 1fr; }
  .settings-actions > button { width: 100%; min-height: 48px; }
  .rest-reminder {
    bottom: calc(88px + env(safe-area-inset-bottom));
    right: max(0.65rem, env(safe-area-inset-right));
    width: min(300px, calc(100vw - 3.4rem));
    z-index: 80;
  }
  .online-presence {
    right: max(0.65rem, env(safe-area-inset-right));
    bottom: calc(76px + env(safe-area-inset-bottom));
    min-height: 34px;
    padding: 0.4rem 0.62rem;
    font-size: 0.76rem;
  }
  /* 學習航站登入雲朵鈕（外部 SDK 以 inline style 固定在左下）：
     手機版會壓住底部分頁列，抬到分頁列上方；沉浸地圖模式分頁列已隱藏，貼回底部。 */
  button[aria-label="學習航站登入狀態"] {
    left: 0.65rem !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
  }
  body:has(#view-game:not(.hidden)) .online-presence { display: none; }
}

@media (max-width: 380px) {
  .unfinished-quest-actions { grid-template-columns: 1fr; }
  .game-scene-details > summary { align-items: flex-start; flex-direction: column; gap: 0.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .resume-quest-card,
  .unfinished-quest-prompt,
  .play-instruction-tip,
  .rest-reminder,
  .mobile-tabbar { scroll-behavior: auto; }
}

/* ── 第二卷「文林淬鍊卷」（第 51–100 關）：獨立呈現，不進封神山河圖 ── */
.volume2-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 2px dashed rgba(116, 83, 29, 0.4);
}
.volume2-section.hidden { display: none; }
.volume2-header { text-align: center; margin-bottom: 1.25rem; }
.volume2-kicker {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--palace-gold, #c59a3f);
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.volume2-title { margin: 0 0 0.5rem; font-size: 1.4rem; }
.volume2-desc {
  max-width: 640px;
  margin: 0 auto;
  color: var(--palace-ink-soft, #6b5c40);
  font-size: 0.92rem;
  line-height: 1.6;
}
.volume2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.volume2-card {
  position: relative;
  border-radius: 12px;
  border: 2px solid var(--chamber-color, #6b4a2f);
  background: rgba(255, 252, 240, 0.85);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.volume2-card.locked { opacity: 0.55; filter: grayscale(0.5); }
.volume2-card.done { border-color: var(--chamber-accent, #c99a5b); }
.volume2-card-title { margin: 0; font-size: 1.05rem; }
.volume2-card-alias { margin: 0; font-size: 0.8rem; color: var(--palace-ink-soft, #6b5c40); }
.volume2-card-progress-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.volume2-card-progress-fill {
  height: 100%;
  background: var(--chamber-accent, #c99a5b);
}
.volume2-card-stats { font-size: 0.82rem; display: flex; justify-content: space-between; }
.volume2-card .primary-btn, .volume2-card .ghost-btn { width: 100%; }

@media (prefers-color-scheme: dark) {
  .volume2-card { background: rgba(20, 24, 22, 0.55); }
}

/* ── 手機版關卡地圖：一般頁面流（真 iOS 對 fixed 疊層＋巨型捲動畫布會拒繪） ── */
@media (max-width: 760px) {
  #view-map:not(.hidden) {
    display: block;
    margin: 0 -0.85rem;
    padding: 0.9rem 0.85rem 1.2rem;
    background:
      radial-gradient(circle at 12% 10%, rgba(231, 196, 111, 0.2), transparent 27%),
      linear-gradient(145deg, #102d2b 0%, #173c38 45%, #0c2423 100%);
  }

  /* 手機沒有元素全螢幕 API，藏掉全螢幕鈕 */
  #btn-map-fullscreen {
    display: none;
  }

  #view-map .level-map {
    display: block;
    overflow: visible;
  }

  #view-map .world-map-shell {
    height: 64vh;
    min-height: 320px;
    margin-top: 0.7rem;
  }

  /* 今日奇遇改為地圖下方的一般卡片，不再絕對定位壓在圖上。
     真正的底部導覽列遮蔽問題出在 js/app.js requestMapFullscreen()：
     手機不該進原生全螢幕（見該處註解），這裡的 margin 只是額外保留一點
     安全間距，避免內容真的很長時卡片底緣貼近 #mobile-tabbar。 */
  #view-map .daily-encounter-card {
    position: static;
    width: 100%;
    margin: 0.8rem 0 1.2rem;
  }
}

/* ── 已破字格五色必須壓過 .palace-jade-board 主題底色（主題規則在後面會蓋掉 found 色，
      導致已破與未破幾乎同色、孩子找剩餘成語不易辨認） ── */
.cell.found,
.palace-jade-board .cell.found {
  border-color: var(--palace-gold-bright);
  box-shadow: 0 4px 10px rgba(26, 23, 20, 0.15), inset 0 0 8px rgba(255, 255, 255, 0.55);
}
.cell.found-0, .palace-jade-board .cell.found-0 { background: linear-gradient(135deg, #f5c4b4 0%, #e08b6f 100%); color: #5d190f; border-color: #c06a4c; }
.cell.found-1, .palace-jade-board .cell.found-1 { background: linear-gradient(135deg, #bcd9ec 0%, #7fa9c4 100%); color: #122d3f; border-color: #5d89a6; }
.cell.found-2, .palace-jade-board .cell.found-2 { background: linear-gradient(135deg, #c4e2bd 0%, #8bb97f 100%); color: #193a16; border-color: #6d9c60; }
.cell.found-3, .palace-jade-board .cell.found-3 { background: linear-gradient(135deg, #ddc8e8 0%, #ad8ac0 100%); color: #3a1a4a; border-color: #8f6ba3; }
.cell.found-4, .palace-jade-board .cell.found-4 { background: linear-gradient(135deg, #f0e3b4 0%, #cfb567 100%); color: #4d3a0b; border-color: #ab923f; }

/* ── 中間句輕量小卡（答對第 2 句起短暫彈出句義，點一下或倒數自動收） ── */
#mini-knowledge-card {
  position: fixed;
  top: max(0.8rem, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -140%);
  z-index: 95;
  width: min(92vw, 460px);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.95rem;
  border: 1.5px solid var(--palace-gold-bright);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255, 253, 246, 0.98), rgba(238, 228, 205, 0.96));
  box-shadow: 0 10px 26px rgba(16, 27, 26, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.24s ease;
  cursor: pointer;
}
#mini-knowledge-card.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
#mini-knowledge-card strong {
  font-family: var(--font-calligraphy);
  font-size: 1.12rem;
  letter-spacing: 0.08em;
  color: var(--palace-vermilion);
}
#mini-knowledge-card span {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--palace-ink-deep);
}

/* ── 關卡內修為進度提示（原僅大廳可見，動機在解謎當下反而消失） ── */
.level-cultivation-hint {
  margin: -0.3rem 0 0.6rem;
  font-size: 0.82rem;
  color: var(--palace-ink-soft);
}

/* ── 摘句圖鑑「隨機複習」按鈕 ── */
.collection-review-btn {
  display: inline-flex;
  margin: 0.3rem 0 0.9rem;
}

/* ── 知識卡複習模式導覽（下一句／完成） ── */
.card-review-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(170, 125, 49, 0.4);
}
.card-review-progress {
  font-size: 0.82rem;
  color: var(--palace-ink-soft);
}

/* ── 新手引導：模式挑選（重用 .play-mode-selector 樣式，這裡只補間距） ── */
.onboarding-mode-picker {
  margin: 0.9rem 0;
}

/* ── 知識卡出處（唐詩宋詞元曲等文學類句子的作者／朝代，資料本就存在，過去沒顯示） ── */
.card-source {
  margin: -0.4rem 0 0.4rem;
  font-size: 0.86rem;
  font-style: italic;
  color: var(--palace-ink-soft);
  text-align: right;
}

/* ── 連續挑戰紀錄（streak 資料早就有算，過去沒任何 UI 顯示過） ── */
.complete-streak {
  margin: -0.6rem 0 1rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--palace-vermilion, #b5432a);
}
.home-streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--palace-vermilion, #b5432a);
  margin: 0.2rem 0 0;
}

/* ── 破關徽章（calculateBadges 早就算好 insight/swift/scholar，過去沒渲染過） ── */
.complete-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.4rem 0 1rem;
}
.complete-badge-chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--palace-gold-dark);
  background: rgba(197, 154, 63, 0.16);
  border: 1px solid var(--palace-gold);
  animation: found-pop 0.5s ease;
}

/* ── 法寶集齊（10/10）是稀有里程碑，跟日常掉落分開視覺 ── */
.complete-treasure-box.treasure-complete {
  border: 2px solid var(--palace-gold-bright);
  box-shadow: 0 0 18px var(--palace-gold-glow);
  animation: sparkle-pulse 1.4s ease-in-out infinite;
}
.complete-treasure-box.treasure-complete .treasure-header {
  color: var(--palace-gold-dark);
  font-weight: 900;
}

/* ── 章節視覺主題：10 章玩法目前相同，先用棋盤配色做辨識度 ── */
.palace-jade-board[data-chapter="1"],
.palace-jade-board[data-chapter="2"] { --board-chapter-accent: var(--palace-jade, #3f6b52); }
.palace-jade-board[data-chapter="3"],
.palace-jade-board[data-chapter="4"] { --board-chapter-accent: var(--palace-vermilion, #b82823); }
.palace-jade-board[data-chapter="5"],
.palace-jade-board[data-chapter="6"] { --board-chapter-accent: var(--palace-gold-dark, #8a6721); }
.palace-jade-board[data-chapter="7"],
.palace-jade-board[data-chapter="8"] { --board-chapter-accent: #4a5a8f; }
.palace-jade-board[data-chapter="9"],
.palace-jade-board[data-chapter="10"] { --board-chapter-accent: #6a3f8f; }
.palace-jade-board[data-chapter] { border-color: var(--board-chapter-accent, var(--palace-gold)); }
.palace-jade-board[data-chapter] .board-corner { border-color: var(--board-chapter-accent, var(--palace-gold)); }

/* ── 解謎優先體感（溫和版）：線索模式進場先矇上薄紗且不可互動，點過線索才淡入 ── */
.palace-jade-board.grid-veiled #grid {
  opacity: 0.32;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.palace-jade-board.grid-veiled::after {
  content: '👆 先點任一則線索，字盤才會亮起';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--palace-ink, #2b2620);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 2px, rgba(255, 255, 255, 0) 2px 5px),
    rgba(251, 247, 238, 0.74);
  pointer-events: none;
  z-index: 2;
}
.palace-jade-board #grid {
  transition: opacity 0.5s ease;
}

/* ── 連擊徽章（本局暫存，不寫入存檔） ── */
.combo-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--palace-vermilion, #b82823), var(--palace-gold, #c59a3f));
  animation: found-pop 0.4s ease;
}

/* ── 遊戲化深化補丁（2026-08-22 四專家審查）─────────────────── */

/* 文林淬鍊卷守護者：尚無立繪，以書法印章版位頂替，避免四處空框 */
.guardian-seal-avatar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  min-height: 96px;
  padding: 0.6rem 0.4rem;
  border-radius: var(--radius-lg, 12px);
  background: linear-gradient(150deg, #4a3628 0%, #2b2118 100%);
  border: 2px solid var(--palace-gold, #c59a3f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.guardian-seal-glyph {
  font-family: var(--font-serif, serif);
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  color: #f6ecd8;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.guardian-seal-mark {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  background: #9b2c2c;
  color: #fff5e8;
  font-size: 0.85rem;
  font-weight: 700;
}
.guardian-seal-name {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: #e8d6a8;
}

/* 三顆星逐顆點亮：原本是一個字串瞬間出現，三星與一星體感無差別 */
.complete-stars .star-slot {
  display: inline-block;
  transform: scale(1);
}
.complete-stars .star-slot.earned {
  opacity: 0;
  transform: scale(0);
}
.complete-stars .star-slot.earned.lit {
  animation: star-pop 0.52s cubic-bezier(0.18, 0.89, 0.32, 1.4) forwards;
}
@keyframes star-pop {
  0% { opacity: 0; transform: scale(0); }
  55% { opacity: 1; transform: scale(1.5); text-shadow: 0 0 18px var(--palace-gold-bright, #e8c06a); }
  100% { opacity: 1; transform: scale(1); text-shadow: 0 0 6px var(--palace-gold-bright, #e8c06a); }
}

/* 金榜唱名：跨過修為門檻的那一秒 */
.complete-promotion {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.6rem auto;
  padding: 0.6rem 0.9rem;
  max-width: 34rem;
  border-radius: var(--radius-lg, 12px);
  background: linear-gradient(120deg, rgba(197, 154, 63, 0.18), rgba(155, 44, 44, 0.14));
  border: 1px solid var(--palace-gold, #c59a3f);
  text-align: left;
}
.promotion-seal {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 6px;
  background: #9b2c2c;
  color: #fff5e8;
  font-family: var(--font-serif, serif);
  font-size: 1.05rem;
  font-weight: 900;
  animation: seal-drop 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.5) both;
}
@keyframes seal-drop {
  0% { opacity: 0; transform: scale(2.2) rotate(-14deg); }
  100% { opacity: 1; transform: scale(1) rotate(-6deg); }
}
.promotion-text { font-size: 0.92rem; line-height: 1.55; }

.complete-best,
.complete-nextgoal {
  font-size: 0.88rem;
  color: var(--muted, #6b6258);
  margin: 0.3rem 0;
}
.record-chip {
  margin-left: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--palace-gold, #c59a3f);
  color: #241d14;
  font-weight: 700;
  font-size: 0.78rem;
}

/* 提示的星等後果直接寫在提示列上，讓「要不要借」成為知情選擇 */
.hint-star-outlook {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  color: var(--muted, #6b6258);
  margin-bottom: 0.25rem;
}
.hint-star-outlook[data-stars="1"] { color: #9b2c2c; }
.ink-daily-note {
  display: block;
  font-size: 0.68rem;
  opacity: 0.75;
  line-height: 1.2;
}

/* 連擊分級 */
.combo-badge[data-tier="3"] { background: #9b2c2c; }
.combo-badge[data-tier="4"] { background: linear-gradient(120deg, #c59a3f, #9b2c2c); }

.daily-encounter-card.claimed { opacity: 0.68; }

/* 本關目標改成可即時打勾的檢核項（原本是一百關同一句樣板話） */
.level-learning-goal { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.level-learning-goal .goal-lead { font-weight: 700; opacity: 0.8; }
.level-learning-goal .goal-item {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(26, 23, 20, 0.06);
  font-size: 0.84rem;
}
.level-learning-goal .goal-item.done {
  background: rgba(197, 154, 63, 0.24);
  font-weight: 700;
}
#quiz-options button.eliminated { opacity: 0.35; text-decoration: line-through; }

/* ── 典藏閣新分頁（錯題本／文房寶物／功名牆）＋提取式複習 ── */
.collection-overview {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid rgba(60,50,40,.18); border-radius: 10px;
  background: rgba(255,253,246,.7);
}
.collection-overview .overview-bar {
  flex: 1 1 140px; height: 8px; border-radius: 99px;
  background: rgba(60,50,40,.12); overflow: hidden;
}
.collection-overview .overview-bar > span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #8a6a3a, #c9a44a);
}

.collection-typebars { display: grid; gap: 6px; margin-bottom: 12px; }
.collection-typebars .typebar {
  display: grid; grid-template-columns: minmax(4em, 6em) 1fr auto;
  gap: 8px; align-items: center; font-size: .82rem;
}
.collection-typebars .typebar-track { height: 6px; border-radius: 99px; background: rgba(60,50,40,.12); overflow: hidden; }
.collection-typebars .typebar-fill { display: block; height: 100%; background: #8a6a3a; }
.collection-typebars .typebar-num { opacity: .75; white-space: nowrap; }

#wrongbook-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
#wrongbook-list .wrongbook-item > button {
  width: 100%; text-align: left; display: flex; justify-content: space-between;
  align-items: baseline; gap: 10px; padding: 9px 11px; cursor: pointer;
  border: 0; border-left: 3px solid rgba(180,90,60,.55); border-radius: 8px;
  background: rgba(200,120,90,.09); font: inherit; color: inherit;
}
#wrongbook-list .wrongbook-item > button:hover { background: rgba(200,120,90,.16); }
#wrongbook-list .wrongbook-item small { opacity: .7; white-space: nowrap; }

#treasure-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
#treasure-gallery .treasure-card {
  display: block; text-align: center; padding: 12px 10px; border-radius: 12px;
  border: 1px solid rgba(60,50,40,.18); background: rgba(255,253,246,.6);
}
#treasure-gallery .treasure-card h4 { margin: 6px 0 4px; font-size: .95rem; }
#treasure-gallery .treasure-card-img { width: 64px; height: 64px; filter: grayscale(1); opacity: .4; }
#treasure-gallery .treasure-card.complete { border-color: rgba(201,164,74,.8); box-shadow: 0 0 0 2px rgba(201,164,74,.18) inset; }
#treasure-gallery .treasure-card.complete .treasure-card-img { filter: none; opacity: 1; }
#treasure-gallery .treasure-card .shard-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
#treasure-gallery .treasure-card .shard-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(60,50,40,.16); }
#treasure-gallery .treasure-card .shard-dot.got { background: #c9a44a; }
#treasure-gallery .treasure-card-desc { font-size: .78rem; opacity: .78; margin: 6px 0 0; }

.badge-wall-count { margin: 0 0 10px; font-weight: 600; }
#badge-wall .badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; }
.badge-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 8px; font-size: .75rem; background: rgba(201,164,74,.16);
}
.badge-cell.locked { background: rgba(60,50,40,.06); opacity: .5; }
.badge-cell-id { font-weight: 700; opacity: .7; }
.badge-dot { opacity: .22; font-size: .8rem; }
.badge-dot.got { opacity: 1; }

.card-review-selfcheck { display: grid; gap: 8px; justify-items: center; }
.card-review-rate { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.card-review-selfcheck.hidden, .card-review-rate.hidden { display: none; }

/* ── 山河復原度環／真結局進度提示／稱號按鈕 ── */
button.rank-badge { border: 0; font: inherit; cursor: pointer; }
button.rank-badge:hover { text-decoration: underline; }
.world-repair-ring {
  display: inline-grid; place-items: center; width: 62px; height: 62px;
  border-radius: 50%; line-height: 1.1; text-align: center;
  background: conic-gradient(#c9a44a calc(var(--repair, 0) * 1%), rgba(60,50,40,.14) 0);
  position: relative;
}
.world-repair-ring::before {
  content: ''; position: absolute; inset: 6px; border-radius: 50%;
  background: var(--paper, #fbf7ee);
}
.world-repair-ring > b, .world-repair-ring > small { position: relative; }
.world-repair-ring > b { font-size: .92rem; }
.world-repair-ring > small { font-size: .58rem; opacity: .7; }

.true-ending-hint {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  border: 1px dashed rgba(138,106,58,.5); background: rgba(201,164,74,.08);
}
.true-ending-hint p { margin: 4px 0 6px; }
.true-ending-hint ul { margin: 0; padding-left: 1.2em; font-size: .88rem; }

/* ── 收筆卡 ── */
.closing-card { display: grid; gap: 10px; }
.closing-card .closing-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; font-weight: 600; }
.closing-card .closing-hook {
  padding: 10px 12px; border-radius: 10px;
  background: rgba(138,106,58,.1); border-left: 3px solid #8a6a3a;
}

/* ── 課堂模式 ── */
.lesson-mode-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px;
  margin: 8px 0 12px; padding: 9px 12px; border-radius: 10px;
  background: rgba(90,130,110,.14); border-left: 3px solid #4f7d68; font-size: .9rem;
}
body[data-lesson="on"] .home-streak-badge,
body[data-lesson="on"] #rest-reminder { display: none !important; }
#treasure-gallery .treasure-ability { font-size: .78rem; margin: 6px 0 0; opacity: .7; }
#treasure-gallery .treasure-ability.active { opacity: 1; color: #8a6a3a; font-weight: 600; }

/* ── 群仙錄剪影 ── */
.character-gallery-card.locked { opacity: .85; }
.locked-silhouette { position: relative; }
.locked-silhouette .char-gallery-img { filter: brightness(0) opacity(.22); }
.locked-silhouette .lock-glyph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 2.4rem; font-weight: 700; color: rgba(60,50,40,.35);
}

/* ── 協力封印進度條 ── */
.team-seal-bar { height: 9px; border-radius: 99px; background: rgba(60,50,40,.12); overflow: hidden; margin: 8px 0 6px; }
.team-seal-bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #4f7d68, #c9a44a); }
.team-seal-marks { display: flex; justify-content: space-between; list-style: none; padding: 0; margin: 0; font-size: .74rem; opacity: .55; }
.team-seal-marks li.lit { opacity: 1; font-weight: 700; color: #8a6a3a; }

/* ── 學習航站登入鈕（外部 SDK 注入）不要蓋住題目與主按鈕 ──
   實測它會擋到：研墨填空題的題幹、遊戲裡的「去研墨」主鈕、一炷香快陣第 3 個選項、寶典進度條。
   SDK 不歸本站管，只能從站內以 aria-label 選中它覆蓋樣式（跨站通用作法）。 */
button[aria-label="學習航站登入狀態"] {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 70px) !important;
  transform: scale(.86);
  transform-origin: left bottom;
  opacity: .9;
  transition: opacity .2s ease;
}
/* 任何對話框開著時直接讓路——它擋住的正好都是要作答的內容 */
body:has(.modal-backdrop:not(.hidden)) button[aria-label="學習航站登入狀態"],
body:has(#view-game:not(.hidden)) button[aria-label="學習航站登入狀態"] {
  display: none !important;
}
@media (min-width: 900px) {
  button[aria-label="學習航站登入狀態"] {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
  }
}

/* ── 四位評估員實測回報的版面修正 ── */
/* 山河復原度環：原本白字白底完全讀不到 */
.world-repair-ring > b { color: #4a3520; font-weight: 800; }
.world-repair-ring > small { color: #6b5740; }
.world-repair-ring::before { background: #fbf7ee; }
@media (prefers-color-scheme: dark) {
  .world-repair-ring::before { background: #241d16; }
  .world-repair-ring > b { color: #f3e6cd; }
  .world-repair-ring > small { color: #c7b295; }
}

/* 結算「紀錄更新！」金標被切成兩行、右緣還被裁掉 */
.record-chip { white-space: nowrap; display: inline-block; }
.complete-best { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }

/* 說明類文字原本 10.9–13.4px，正好是最需要讀懂的規則字 */
.ink-daily-note, .hint-star-outlook, .level-learning-goal .goal-item,
.hint-note, .map-instruction { font-size: max(13.5px, .86rem); line-height: 1.6; }

/* 手機：線索卡與字盤隔了整張立繪，玩一句要來回滑四五次 */
@media (max-width: 720px) {
  .guardian-portrait, .array-guardian-art { max-height: 180px; object-fit: cover; }
  #target-list { scroll-margin-top: 12px; }
}
.clue-extra { margin-top: 6px; font-size: .84rem; }
.clue-extra > summary { cursor: pointer; color: #8a6a3a; font-weight: 600; }
.clue-extra > p { margin: 4px 0 0; opacity: .85; }

/* ── 鍵盤 focus 樣式跟著主題走，別讓瀏覽器預設紅框跳色 ── */
:focus-visible {
  outline: 2px solid var(--palace-gold-bright, #c9a44a);
  outline-offset: 2px;
}
