:root {
  --bg: #f5f0e8;
  --bg2: #ece5d8;
  --bg3: #e0d7c8;
  --bg4: #d5ccbc;
  --border: #c4b8a4;
  --text: #2c251d;  /* 从#3a3228加深，提升对比度 */
  --text2: #8a7a6a;
  --text-muted: #b0a898; /* 新增：更浅的文字色，用于辅助信息 */
  --red: #c41e3a;
  --red2: #8b1528;
  --green: #4a7a4a;
  --blue: #4a5a7a;
  --gold: #c9a96e;
  --purple: #7a4a8a;
  --cyan: #4a7a8a;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.15);
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 60px;
  --header-height: 50px;
  --transition-fast: 0.15s;
  --transition-normal: 0.2s;
  --transition-slow: 0.3s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Serif SC', 'STKaiti', 'KaiTi', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }

/* ===== Login ===== */
/* P7：登录页背景用「入仙门图」，卡片半透明浮于其上 */
.login-bg {
  position: fixed;
  inset: 0;
  background: url('../assets/bg/login.jpg') center/cover no-repeat;
  z-index: 0;
  filter: saturate(0.9) brightness(1.02);
  animation: bgDrift 40s ease-in-out infinite alternate;
}

/* 极慢的呼吸位移：让静态背景有生气，同时不干扰阅读（reduced-motion 下自动关闭） */
@keyframes bgDrift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.09) translate3d(-1.2%, -1%, 0); }
}

.login-card {
  position: relative;
  z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 0 Q45 15 30 30 Q15 15 30 0Z' fill='%23f5f0e8' opacity='0.15'/%3E%3C/svg%3E") repeat, rgba(245,240,232,0.94);
  backdrop-filter: blur(3px);
  border: 1px solid var(--border);
  padding: 32px 32px 28px;
  max-width: 380px;
  margin: 0 auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  align-self: center;
  margin-top: 8vh;
  overflow: hidden;
}

.game-title-img {
  display: block;
  width: 240px;
  max-width: 80%;
  height: auto;
  margin: 0 auto 2px;
  filter: drop-shadow(0 2px 6px rgba(58,50,40,0.25));
}

.login-view { display: none; }
.login-view.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); position: relative; }

.game-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 40px;
  letter-spacing: 12px;
  color: var(--text);
  margin-bottom: 6px;
}

.game-subtitle {
  font-size: 12px;
  color: var(--text2);
  letter-spacing: 6px;
  margin-bottom: 32px;
}

.input-field {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  background: #faf6f0;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
  border-radius: var(--radius);
}

.input-field:focus { outline: none; border-color: var(--red); }

select.input-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a7a6a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.btn {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  border-radius: var(--radius);
}

.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--red); border-color: var(--red2); color: #fff; }
.btn.primary:hover { background: var(--red2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { width: auto; padding: 6px 14px; font-size: 12px; }
.btn.danger { background: var(--red2); border-color: var(--red2); color: #fff; }
.btn.success { background: var(--green); border-color: #3a5a3a; color: #fff; }

/* ===== Game Layout ===== */
#game-view { display: none; }
#game-view.active { display: flex; flex-direction: column; min-height: 100vh; }

.game-header {
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.char-name { font-family: 'Ma Shan Zheng', cursive; font-size: 20px; letter-spacing: 2px; }
.realm-badge {
  background: linear-gradient(135deg, var(--red), var(--red2));
  border: none;
  color: #fff;
  padding: 3px 12px;
  font-size: 11px;
  letter-spacing: 1px;
  border-radius: 20px;
}

.header-right { display: flex; align-items: center; gap: 16px; }
.resource { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.resource span { color: var(--gold); font-weight: 600; }

/* ===== Sidebar Navigation ===== */
.game-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar-nav {
  width: var(--sidebar-width);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width var(--transition-slow);
  position: relative;
}

.sidebar-nav.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-nav.collapsed .nav-group-title span:last-child,
.sidebar-nav.collapsed .nav-items {
  display: none;
}

.sidebar-nav.collapsed .nav-icon {
  margin: 0 auto;
}

.sidebar-collapse-btn {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background var(--transition-fast);
  font-size: 12px;
  color: var(--text2);
}

.sidebar-collapse-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

.sidebar-nav.collapsed .sidebar-collapse-btn {
  right: -12px;
}

.nav-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.nav-section:last-child { border-bottom: none; }

.nav-section-title {
  padding: 0 16px 8px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text2);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--text2);
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(0,0,0,0.03); color: var(--text); }
.nav-item.active {
  color: var(--red);
  background: rgba(196,30,58,0.05);
  border-left-color: var(--red);
  font-weight: 600;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: var(--bg3);
  border-radius: var(--radius);
  flex-shrink: 0;
  overflow: hidden;
}

/* P7：美术图标（挂载成功时替换文字图标） */
.nav-icon-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
  filter: saturate(0.95);
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.nav-item:hover .nav-icon-img { transform: scale(1.08); filter: saturate(1.1); }

.nav-item.active .nav-icon {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(196,30,58,0.25);
}

.nav-item.active .nav-icon-img { filter: brightness(1.12) saturate(1.15); }

.nav-item.active .nav-icon {
  background: var(--red);
  color: #fff;
}

/* ===== Main Content ===== */
/* P7：内容区铺在场景背景之上，面板保持可读（半透明纸感） */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* 场景背景层：全局 fixed 贴右，透明度低——只做氛围，绝不抢文字 */
.scene-bg {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  left: var(--sidebar-width);
  background-image: var(--scene-bg, none);
  background-size: cover;
  background-position: center right;
  opacity: 0.16;
  z-index: 0;
  pointer-events: none;
  transition: background-image 0.5s ease, opacity 0.5s ease;
  mix-blend-mode: luminosity;   /* 与纸质底色相融，避免彩色背景让文字发飘 */
}

.scene-bg.visible { opacity: 0.22; }

/* 左侧导航折叠时背景跟着让位 */
.sidebar-nav.collapsed ~ .scene-bg { left: var(--sidebar-collapsed-width); }

@media (max-width: 768px) {
  .scene-bg { left: 0; opacity: 0.10; }
}

.content-area > .char-panel:first-child { margin-top: 0; }

/* 面板在场景背景上保持不透明（可读性优先于氛围） */
.content-area .char-panel { background: #faf6f0; }

/* ===== Character Panel ===== */
.char-panel {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.char-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.char-panel-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 18px;
  letter-spacing: 2px;
}

.combat-power { font-size: 11px; color: var(--text2); }

/* ===== Equipment Grid (8 Slots) ===== */
.equip-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.equip-slot {
  aspect-ratio: 1;
  background: #faf6f0;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border-radius: var(--radius);
  min-height: 60px;
}

.equip-slot:hover { border-color: var(--red); background: #f5ede0; }
.equip-slot .icon { font-size: 22px; margin-bottom: 2px; }
.equip-slot .name { font-size: 9px; color: var(--text2); text-align: center; line-height: 1.1; }
.equip-slot.empty { opacity: 0.5; }
.equip-slot.empty .icon { font-size: 18px; color: var(--border); }
.equip-slot.equipped { border-color: var(--green); background: #f0f8f0; }
.equip-slot .enhance { position: absolute; top: 2px; right: 2px; font-size: 8px; color: var(--gold); font-weight: 600; }
.equip-slot .quality { position: absolute; bottom: 2px; left: 2px; right: 2px; font-size: 7px; text-align: center; color: var(--text2); }

/* ===== Stats Panel ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}

.stat-item:last-child { border-bottom: none; }
.stat-label { color: var(--text2); }
.stat-value { font-weight: 600; }

/* ===== Bar Styles ===== */
.bar-group { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; color: var(--text2); }
.bar-track { height: 8px; background: var(--bg3); overflow: hidden; border-radius: 4px; }
.bar-fill { height: 100%; transition: width 0.5s; border-radius: 4px; }
.hp-fill { background: linear-gradient(90deg, var(--red2), var(--red)); }
.mp-fill { background: linear-gradient(90deg, var(--blue), #6a8aaa); }
.exp-fill { background: linear-gradient(90deg, var(--gold), #d4b87a); }
.sp-fill { background: linear-gradient(90deg, var(--green), #6a9a6a); }

/* ===== Quick Actions ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.quick-action {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: var(--radius);
}

.quick-action:hover { border-color: var(--red); background: #f5ede0; transform: translateY(-1px); }
.quick-action .icon { font-size: 20px; margin-bottom: 4px; }
.quick-action .name { font-size: 11px; letter-spacing: 1px; }

/* ===== Shop Items ===== */
.shop-item {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.shop-item:hover { border-color: var(--red); }
.shop-item-info { flex: 1; }
.shop-item-name { font-weight: 600; margin-bottom: 2px; font-size: 13px; }
.shop-item-desc { font-size: 11px; color: var(--text2); }
.shop-item-price { color: var(--gold); font-weight: 600; margin-top: 2px; font-size: 12px; }

/* 洞府条目图标（轮137 接线）。
   素材是透明底圆形/建筑精灵，所以只给尺寸与轻微投影 —— 不画背景块，
   否则又会变成"白方块贴在暖纸上"那种接缝（见 待抠图清单.md 的教训）。 */
.cave-item-icon {
  width: 44px; height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(60, 45, 25, 0.18));
}
.shop-item .cave-item-icon { margin-right: 6px; }
/* 小屏时收一点，避免条目过高 */
@media (max-width: 720px) { .cave-item-icon { width: 34px; height: 34px; } }

/* 称谓牌（轮172）：与称号（履历）互补 —— 称谓是身份名片 */
.honorific-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 6px;
}
.honorific-cell {
  text-align: center;
  padding: 5px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  cursor: pointer;
}
.honorific-cell.locked { opacity: 0.45; cursor: default; }
.honorific-cell.equipped { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.honorific-plaque { width: 100%; max-height: 30px; object-fit: contain; }
.honorific-name { font-size: 10px; font-weight: 600; margin-top: 2px; }
.honorific-cond { font-size: 9px; color: var(--text2); }

/* 头像与头像框（轮171）：框是**中心透明**的图，所以头像垫下面、框盖上面 */
.char-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  margin-right: 8px;
  cursor: pointer;
  flex: 0 0 auto;
}
.char-avatar-img {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  object-fit: cover;
}
.char-avatar-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}
.avatar-cell {
  text-align: center;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  cursor: pointer;
}
.avatar-cell.locked { opacity: 0.45; cursor: default; }
.avatar-cell.equipped { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.avatar-pic { width: 100%; aspect-ratio: 1/1; object-fit: contain; }
.avatar-name { font-size: 10px; font-weight: 600; }
.avatar-cond { font-size: 9px; color: var(--text2); }

/* 称号牌匾（轮170）：12 个槽位全部接上（titles.js 的 slot 与素材一一对应） */
.title-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 6px;
}
.title-cell {
  text-align: center;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  cursor: pointer;
}
.title-cell.locked { opacity: 0.45; cursor: default; }
.title-cell.equipped { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.title-plaque { width: 100%; max-height: 34px; object-fit: contain; }
.title-name { font-size: 11px; font-weight: 600; margin-top: 2px; }
.title-cond { font-size: 9px; color: var(--text2); }

/* 货币图标（轮169）：`CURRENCY_ICON` 映射表早就有，界面以前从没调过它 */
.currency-icon { width: 13px; height: 13px; object-fit: contain; margin-right: 3px; vertical-align: -2px; }
/* 功法标志（轮169）：按 element 取，功法数据里唯一可用的分类轴 */
.gongfa-emblem { width: 18px; height: 18px; object-fit: contain; }

/* 增益栏（轮168）
 * db.character_buffs 是战斗加成的唯一真源，而前端以前完全没有展示它的地方 ——
 * 玩家吃了丹、挂了阵，界面上看不出变化。 */
.buff-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  flex-wrap: wrap;
  max-width: 46vw;
}
.buff-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  white-space: nowrap;
}
.buff-icon { width: 14px; height: 14px; object-fit: contain; }
.buff-pct { color: var(--gold); }
.buff-left { color: var(--text2); font-size: 10px; }

/* 物品格 + 品质框（轮167）
 * 品质框用 background-image 铺在格子上、图标叠上层 ——
 * 框的**中心本来就是透明的**（这正是轮167 重生成它的原因：旧图 12 格里 10 格是黑块）。 */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.item-cell { text-align: center; cursor: pointer; }
.item-cell-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);   /* 框素材缺失时的兜底 */
  border-radius: 4px;
}
.item-cell-label { font-size: 13px; font-weight: 600; color: var(--text); }
.item-cell-qty {
  position: absolute;
  right: 4px;
  bottom: 18px;
  font-size: 10px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  padding: 0 3px;
}
.item-cell-name {
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 创收图标（轮152）：金券/仙玉/福利等 16 个图标接在标题或角标里 */
.money-icon {
  width: 18px; height: 18px;
  object-fit: contain;
  vertical-align: -4px;
  margin-right: 3px;
}
/* 套餐角标：图标 + 文字横排。素材缺失时只剩文字，排版不塌 */
.pkg-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 4px;
}
.badge-icon { width: 14px; height: 14px; object-fit: contain; }

/* 按钮徽章图标（轮138）：接在按钮文字左侧。
   按钮本身已有底色，所以图标只需小尺寸 + 垂直居中，不加投影（避免糊成一团）。 */
.btn-icon {
  width: 18px; height: 18px;
  object-fit: contain;
  vertical-align: -4px;
  margin-right: 4px;
}

/* 仙盟旗帜（轮137）：挂在盟名左侧，尺寸贴着标题行高 */
.guild-flag {
  width: 26px; height: 34px;
  object-fit: contain;
  vertical-align: -8px;
  margin-right: 6px;
  filter: drop-shadow(0 1px 2px rgba(60, 45, 25, 0.22));
}

/**
 * 面板底纹（轮137 引入，轮144 修正）
 *
 * ## 第一版为什么看不见
 *
 * 原实现把底纹画在 `#tab-content::before`（`position:absolute; inset:0`）。
 * 但页面内容全是不透明的 `.char-panel` 面板，**把这一层整个盖住了** ——
 * 只有面板之间的窄缝能露出来。审计里"底纹生效"是真的（`backgroundImage` 确实设上了），
 * 而截图里**完全看不出来**：素材应用了却不可见，还白占体积。
 *
 * ## 现在
 *
 * 底纹画在**面板自己**身上（`.char-panel` 的 `background-image`），
 * 面板原本的 `background-color` 仍在，两者叠加。
 * 图案 PNG 自带 alpha（用户抠的透明底），所以不需要再叠 opacity ——
 * 线条本身就是半透明的墨色/金色。
 */
.panel-backdrop .char-panel {
  background-image: var(--panel-bg-url);
  background-repeat: repeat;
  background-size: 256px 256px;
  background-position: center top;
}

/* ===== Dungeon Grid ===== */
.dungeon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.dungeon-card {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: var(--radius);
}

.dungeon-card:hover { border-color: var(--red); transform: translateY(-2px); box-shadow: var(--shadow); }
.dungeon-card h4 { margin-bottom: 6px; font-size: 13px; }
.dungeon-card p { font-size: 11px; color: var(--text2); margin: 2px 0; }

/* ===== Arena Opponent ===== */
.arena-opponent {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.arena-opponent:hover { border-color: var(--red); }

/* ===== Pet Card ===== */
.pet-card {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
}

.pet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.pet-name { font-weight: 600; font-size: 13px; }
.pet-quality { font-size: 11px; color: var(--text2); }

.pet-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 11px;
}

.pet-stat {
  display: flex;
  justify-content: space-between;
}

.pet-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ===== Gongfa Card ===== */
.gongfa-card {
  background: #faf6f0;
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
}

.gongfa-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.gongfa-name { font-weight: 600; font-size: 13px; }
.gongfa-quality { font-size: 11px; color: var(--text2); }

.gongfa-stats {
  font-size: 11px;
  line-height: 1.6;
}

.gongfa-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ===== Battle Result ===== */
.battle-result {
  text-align: center;
  padding: 16px;
}

.battle-result h3 {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 28px;
  margin-bottom: 16px;
}

.battle-result .reward {
  margin: 8px 0;
  color: var(--gold);
  font-size: 14px;
}

.battle-log {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 10px;
  margin: 12px 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
  border-radius: var(--radius);
}

.battle-log .log-entry {
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}

.battle-log .log-entry:last-child { border-bottom: none; }
.battle-log .damage { color: var(--red); font-weight: 600; }
.battle-log .heal { color: var(--green); font-weight: 600; }
.battle-log .critical { color: var(--gold); font-weight: 600; }

/* ===== Rankings Table ===== */
.rankings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.rankings-table th, .rankings-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.rankings-table th {
  background: var(--bg2);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(58,50,40,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 18px;
  letter-spacing: 2px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text2);
  transition: color 0.2s;
}

.modal-close:hover { color: var(--red); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 24px;
  font-size: 13px;
  z-index: 2000;
  animation: fadeIn 0.3s;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Misc ===== */
.quality-凡器 { color: var(--text2); }
.quality-灵器 { color: var(--blue); }
.quality-法宝 { color: var(--purple); }
.quality-古宝 { color: var(--cyan); }
.quality-灵宝 { color: var(--green); }
.quality-道器 { color: var(--gold); }
.quality-仙器 { color: var(--red); }
.quality-混沌至宝 { color: var(--red2); }

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text2);
}

/* P7：空状态插画（Q版立绘角标 + 汉字符 + 呼吸动画） */
.empty-illus {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg2);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: emptyBreathe 4s ease-in-out infinite;
}

.empty-illus .empty-chibi {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
  filter: saturate(0.7) brightness(1.06);
}

.empty-illus .empty-glyph {
  position: relative;
  z-index: 1;
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 34px;
  color: var(--text);
  opacity: 0.72;
  text-shadow: 0 1px 3px rgba(245,240,232,0.9);
}

.empty-illus.no-img .empty-glyph { opacity: 0.5; }

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

.empty-state .title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state .desc {
  font-size: 13px;
  color: var(--text2);
  max-width: 300px;
  margin: 0 auto;
  line-height: 1.6;
}

.loading {
  text-align: center;
  padding: 20px;
  color: var(--text2);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

::selection { background: rgba(196,30,58,0.15); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .sidebar-nav { display: none; }

  .game-body { flex-direction: column; }

  .content-area { padding: 12px; }

  .tab-nav {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 50px;
    z-index: 99;
  }

  .tab-nav::-webkit-scrollbar { display: none; }

  .tab-btn {
    padding: 10px 14px;
    color: var(--text2);
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tab-btn:hover { color: var(--text); background: rgba(0,0,0,0.02); }
  .tab-btn.active { color: var(--red); border-bottom-color: var(--red); background: rgba(196,30,58,0.05); }

  .equip-section { grid-template-columns: 1fr; }
  .equip-slots { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .equip-slot { min-height: 50px; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .dungeon-grid { grid-template-columns: 1fr; }

  .char-panel { padding: 12px; margin-bottom: 10px; }
  .char-panel-title { font-size: 15px; }
  .action-btn { padding: 8px; font-size: 11px; }
  .btn.small { padding: 5px 10px; font-size: 11px; }
  .modal-content { width: 95%; max-height: 85vh; }
  .modal-header { padding: 10px 14px; }
  .modal-title { font-size: 15px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; }
  .battle-result h3 { font-size: 22px; }
  .battle-log { max-height: 140px; font-size: 10px; }
}

/* ===== Tablet ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar-nav { width: 180px; }
  .content-area { padding: 16px; }
}

/* ===== Large Screen ===== */
@media (min-width: 1200px) {
  .sidebar-nav { width: 220px; }
  .content-area { padding: 24px; }
  .char-panel { padding: 20px; }
}

/* VIP Effects */
@keyframes vipGlow {
  0%, 100% { box-shadow: 0 0 5px var(--gold), 0 0 10px var(--gold); }
  50% { box-shadow: 0 0 15px var(--gold), 0 0 25px var(--gold); }
}

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

@keyframes vipShine {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.vip-effect { animation: vipGlow 2s ease-in-out infinite; }
.vip-float { animation: vipFloat 3s ease-in-out infinite; }
.vip-shine {
  background: linear-gradient(90deg, var(--gold) 0%, #fff 50%, var(--gold) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: vipShine 3s linear infinite;
}

/* VIP动画节流：尊重用户减少动画的偏好 */
@media (prefers-reduced-motion: reduce) {
  .vip-effect, .vip-float, .vip-shine,
  .vip-login-glow, .vip-border-rainbow, .vip-battle-victory,
  .vip-rainbow-name, .vip-badge-pulse,
  .vip-level-5 .char-panel, .vip-level-7 .char-panel, .vip-level-10 .char-panel {
    animation: none !important;
  }
  
  .bar-fill {
    transition: none !important;
  }
  
  .btn, .nav-item, .shop-item, .dungeon-card, .equip-slot, .quick-action {
    transition: none !important;
  }
}

/* VIP Login Glow Effect */
@keyframes loginGlow {
  0% { box-shadow: 0 0 5px rgba(201,169,110,0.3); }
  50% { box-shadow: 0 0 30px rgba(201,169,110,0.6), 0 0 60px rgba(201,169,110,0.3); }
  100% { box-shadow: 0 0 5px rgba(201,169,110,0.3); }
}

@keyframes vipBorder {
  0%, 100% { border-color: var(--gold); }
  33% { border-color: #ff6b6b; }
  66% { border-color: #4fc3f7; }
}

@keyframes particleFloat {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
}

@keyframes battleVictory {
  0% { transform: scale(1); text-shadow: 0 0 5px var(--gold); }
  50% { transform: scale(1.2); text-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold); }
  100% { transform: scale(1); text-shadow: 0 0 5px var(--gold); }
}

@keyframes rainbowText {
  0% { color: #ff6b6b; }
  16% { color: #ffa726; }
  33% { color: #ffee58; }
  50% { color: #66bb6a; }
  66% { color: #4fc3f7; }
  83% { color: #ab47bc; }
  100% { color: #ff6b6b; }
}

@keyframes vipBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.vip-login-glow { animation: loginGlow 2s ease-in-out infinite; }
.vip-border-rainbow { animation: vipBorder 3s linear infinite; }
.vip-battle-victory { animation: battleVictory 1s ease-in-out 3; }
.vip-rainbow-name { animation: rainbowText 3s linear infinite; }
.vip-badge-pulse { animation: vipBadgePulse 2s ease-in-out infinite; }

/* VIP Level-specific Effects */
.vip-level-5 .char-panel { border: 2px solid var(--gold); }
.vip-level-7 .char-panel { border: 2px solid var(--gold); box-shadow: 0 0 15px rgba(201,169,110,0.3); }
.vip-level-10 .char-panel { border: 2px solid var(--gold); box-shadow: 0 0 20px rgba(201,169,110,0.4); background: linear-gradient(135deg, rgba(201,169,110,0.05), transparent); }

/* Particle Container */
.vip-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.vip-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  animation: particleFloat 2s ease-out forwards;
}

/* Login Card VIP Enhancements */
.login-card.vip-active {
  border: 2px solid var(--gold);
  box-shadow: 0 0 30px rgba(201,169,110,0.3);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --bg4: #0a0a20;
  --border: #333355;
  --text: #e0e0e0;
  --text2: #a0a0a0;
  --text-muted: #7777aa;
  --red: #e53e3e;
  --red2: #c53030;
  --green: #66bb6a;
  --blue: #6a8aaa;
  --gold: #d4a55e;
  --purple: #b07ad8;
  --cyan: #5ab8c8;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.5);
}

[data-theme="dark"] .login-card {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 0 Q45 15 30 30 Q15 15 30 0Z' fill='%231a1a2e' opacity='0.3'/%3E%3C/svg%3E") repeat, rgba(22,33,62,0.98);
  border-color: #333355;
}

[data-theme="dark"] .char-panel,
[data-theme="dark"] .shop-item,
[data-theme="dark"] .dungeon-card,
[data-theme="dark"] .equip-slot,
[data-theme="dark"] .quick-action,
[data-theme="dark"] .pet-card,
[data-theme="dark"] .gongfa-card,
[data-theme="dark"] .arena-opponent {
  background: #16213e;
  border-color: #333355;
}

[data-theme="dark"] .char-panel:hover,
[data-theme="dark"] .shop-item:hover,
[data-theme="dark"] .dungeon-card:hover {
  border-color: var(--red);
  background: #1a1a3e;
}

[data-theme="dark"] .sidebar-nav {
  background: #16213e;
  border-right-color: #333355;
}

[data-theme="dark"] .game-header {
  background: linear-gradient(180deg, #16213e, #1a1a2e);
  border-bottom-color: #333355;
}

[data-theme="dark"] .input-field,
[data-theme="dark"] .search-input {
  background: #1a1a2e;
  border-color: #333355;
  color: #e0e0e0;
}

[data-theme="dark"] .input-field:focus,
[data-theme="dark"] .search-input:focus {
  border-color: var(--red);
}

[data-theme="dark"] .btn {
  background: #16213e;
  border-color: #333355;
  color: #e0e0e0;
}

[data-theme="dark"] .btn:hover {
  background: #1a1a3e;
}

[data-theme="dark"] .btn.primary {
  background: var(--red);
  border-color: var(--red2);
  color: #fff;
}

[data-theme="dark"] .modal-overlay {
  background: rgba(10,10,32,0.8);
}

[data-theme="dark"] .modal-content {
  background: #1a1a2e;
  border-color: #333355;
}

[data-theme="dark"] .modal-header {
  background: #16213e;
  border-bottom-color: #333355;
}

[data-theme="dark"] .toast {
  background: #16213e;
  border: 1px solid #333355;
}

[data-theme="dark"] .battle-log {
  background: #1a1a2e;
  border-color: #333355;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #16213e 25%, #333355 50%, #16213e 75%);
}

[data-theme="dark"] .global-loading {
  background: rgba(10,10,32,0.9);
}

[data-theme="dark"] .filter-btn {
  background: #16213e;
  border-color: #333355;
  color: #a0a0a0;
}

[data-theme="dark"] .filter-btn:hover {
  background: #1a1a3e;
  color: #e0e0e0;
}

[data-theme="dark"] .filter-btn.active {
  background: var(--red);
  border-color: var(--red2);
  color: #fff;
}

[data-theme="dark"] .pagination-btn {
  background: #16213e;
  border-color: #333355;
  color: #e0e0e0;
}

[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
  background: #1a1a3e;
}

[data-theme="dark"] .pagination-btn.active {
  background: var(--red);
  border-color: var(--red2);
  color: #fff;
}

/* Chat panel scrollbar */
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Settings toggle */
.setting-toggle {
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}
.setting-toggle.active { background: var(--green); }
.setting-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}
.setting-toggle.active::after { transform: translateX(18px); }

/* Skeleton loading */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--border) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* ===== Global Loading Overlay ===== */
.global-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(245,240,232,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.global-loading.active {
  opacity: 1;
  visibility: visible;
}

.global-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.global-loading-text {
  margin-left: 16px;
  font-size: 14px;
  color: var(--text);
}

/* ===== Search & Filter Component ===== */
.search-filter {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: #faf6f0;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius);
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--red);
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

.filter-btn.active {
  background: var(--red);
  border-color: var(--red2);
  color: #fff;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 0;
}

.pagination-btn {
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--bg3);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--red);
  border-color: var(--red2);
  color: #fff;
}

.pagination-info {
  font-size: 12px;
  color: var(--text2);
  margin: 0 8px;
}

/* ===== CountUp Animation ===== */
.resource-value {
  display: inline-block;
  transition: transform 0.3s ease-out;
}

.resource-value.updating {
  animation: countUp 0.5s ease-out;
}

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

/* Page Transitions */
.tab-content {
  animation: tabFadeIn 0.3s ease-out;
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

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

.char-panel {
  animation: slideInUp 0.3s ease-out;
}

/* Hover Effects */
.nav-item {
  transition: all 0.2s ease;
}

.nav-item:hover {
  transform: translateX(4px);
  background: var(--bg2);
}

.btn {
  transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Toast Animation */
.toast {
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.2s forwards;
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* Resource Counter Animation */
.resource-value {
  transition: all 0.3s ease;
}

.resource-value.updated {
  animation: resourcePulse 0.5s ease;
}

@keyframes resourcePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); color: var(--gold); }
  100% { transform: scale(1); }
}

/* Equipment Slot Hover */
.equip-slot {
  transition: all 0.2s ease;
  cursor: pointer;
}

.equip-slot:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* Smooth Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text2);
}

/* Admin Panel Styles */
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--red);
  font-family: 'Ma Shan Zheng', cursive;
}
.stat-label {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

/* Quest Tracker */
#quest-tracker {
  transition: all 0.3s ease;
}
#quest-tracker:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Announcement Popup Animation */
#announcement-popup .modal-content {
  animation: popIn 0.3s ease-out;
}
#ad-popup .modal-content {
  animation: popIn 0.3s ease-out;
}
#quest-complete-popup .modal-content {
  animation: popIn 0.3s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Admin Table */
#admin-users-list table {
  border-radius: var(--radius);
  overflow: hidden;
}
#admin-users-list tr:hover {
  background: var(--bg2);
}

/* Badge Styles */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}
.badge-red { background: var(--red); color: #fff; }
.badge-gold { background: var(--gold); color: #fff; }
.badge-green { background: var(--green); color: #fff; }

/* Admin Nav Highlight */
.nav-item[data-tab="admin"] .nav-icon {
  background: var(--red);
  color: #fff;
}

/* 阶段10：12 主导航分组折叠 */
.nav-group { margin-bottom: 2px; }
.nav-group-title {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; user-select: none; color: var(--text);
  border-radius: var(--radius);
}
.nav-group-title:hover { background: var(--bg2); }
.nav-group .nav-items { display: none; }
.nav-group.open .nav-items { display: block; }
.nav-group .nav-item { padding-left: 26px; }

/* ===== Utility Classes ===== */
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 14px; }
.text-xl { font-size: 16px; }
.text-2xl { font-size: 18px; }
.text-muted { color: var(--text2); }
.text-accent { color: var(--accent, var(--gold)); }
.text-success { color: var(--success, var(--green)); }
.text-danger { color: var(--danger, var(--red)); }

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-dashed { border-style: dashed; }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }

.bg-panel { background: #faf6f0; }
.bg-secondary { background: var(--bg2); }
.bg-tertiary { background: var(--bg3); }

.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-hover { box-shadow: var(--shadow-hover); }

/* Item Row (common pattern for list items) */
.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  background: #faf6f0;
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast);
}

.item-row:hover {
  border-color: var(--red);
}

.item-row-info {
  flex: 1;
  min-width: 0;
}

.item-row-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}

.item-row-desc {
  font-size: 11px;
  color: var(--text2);
}

.item-row-quantity {
  font-size: 11px;
  color: var(--text2);
  margin-left: 8px;
}

/* Stat Row (common pattern for stats display) */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--text2);
}

.stat-value {
  font-weight: 600;
}

/* Button Group */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group .btn {
  flex: 1;
  min-width: 120px;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 18px;
  letter-spacing: 2px;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* Info Text (small muted) */
.info-text {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.6;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* Badge Accent */
.badge-accent {
  background: var(--accent, var(--gold));
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

/* ===== P7 剧情记年（世界锚点展示）===== */
.lore-panel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
}

.lore-anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.lore-chip {
  display: inline-block;
  padding: 2px 9px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--red2);
  background: rgba(196,30,58,0.07);
  border: 1px solid rgba(196,30,58,0.22);
  border-radius: 11px;
  cursor: default;
}

.lore-para {
  font-size: 12px;
  line-height: 1.9;
  color: var(--text);
  margin: 0 0 8px;
  text-indent: 2em;   /* 中文段落首行缩进，读起来像书 */
}

.lore-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 6px;
}

.lore-note {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.7;
  padding: 6px 10px;
  margin-bottom: 10px;
  background: rgba(201,169,110,0.08);
  border-left: 2px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.lore-timeline {
  border-left: 2px solid var(--border);
  padding-left: 14px;
  position: relative;
}

.lore-event {
  margin-bottom: 14px;
  position: relative;
}

/* 时间轴节点：小圆点压在竖线上 */
.lore-event::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

.lore-event-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 2px;
}

.lore-age { font-weight: 600; color: var(--text); }
.lore-era {
  padding: 0 6px;
  border-radius: 8px;
  background: rgba(201,169,110,0.16);
  color: #8a6a2a;
  font-size: 10px;
}
.lore-type { color: var(--text2); }

.lore-event-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.lore-event-body {
  font-size: 12px;
  line-height: 1.8;
  color: var(--text);
}

[data-theme="dark"] .lore-panel { background: #16213e; border-color: #333355; }
[data-theme="dark"] .lore-note { background: rgba(201,169,110,0.12); }
[data-theme="dark"] .lore-chip { color: #e8a0a8; background: rgba(196,30,58,0.18); border-color: rgba(196,30,58,0.4); }
