/* ============================================
   丝路商栈 (Silk Road Post) - 主样式表
   ============================================ */

/* --- CSS 变量（色彩系统 - 丝路暖金+翡翠绿）--- */
:root {
  --primary: #D4A373;
  --primary-light: #E8CCAA;
  --primary-dark: #B8844A;
  --secondary: #2A9D8F;
  --secondary-light: #45BFAF;
  --secondary-dark: #1E7A6E;
  --bg-main: #FEFAE0;
  --bg-panel: #FFF3E0;
  --bg-card: rgba(255, 255, 255, 0.65);
  --bg-gradient: linear-gradient(180deg, #FFF3E0 0%, #FFE8D6 100%);
  --text: #5E503F;
  --text-title: #3E2723;
  --text-disabled: #B0A08A;
  --error: #E76F51;
  --error-light: #F5A590;
  --success: #2A9D8F;
  --border: rgba(212, 163, 115, 0.4);
  --shadow-sm: 0 2px 8px rgba(62, 39, 35, 0.08);
  --shadow-md: 0 4px 16px rgba(62, 39, 35, 0.12);
  --shadow-lg: 0 8px 32px rgba(62, 39, 35, 0.16);
  --shadow-card: 0 2px 12px rgba(62, 39, 35, 0.06), 0 0 0 1px rgba(212, 163, 115, 0.08);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.4s ease-in-out;
  --font-body: 'Noto Serif SC', 'SimSun', 'Songti SC', serif;
  /* 安全区域适配 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* --- 高对比度模式 --- */
.high-contrast {
  --bg-main: #2C2416;
  --bg-panel: #3E2E1F;
  --bg-gradient: linear-gradient(180deg, #3E2E1F 0%, #2C2416 100%);
  --text: #F0E6D3;
  --text-title: #F5EEDC;
  --text-disabled: #8A7E6B;
  --primary: #F0C878;
  --primary-dark: #D4A353;
  --secondary: #5ED5C0;
  --border: rgba(240, 200, 120, 0.5);
}

/* --- 全局重置 --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-main);
  height: 100dvh;
  overflow: hidden;
  line-height: 1.6;
  transition: background var(--transition-slow);
}

/* --- Canvas 背景 --- */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

#app.scene-mode ~ #bg-canvas,
#app.scene-mode #bg-canvas {
  display: none;
}

/* --- 主布局 --- */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 像素场景模式 - 全屏沉浸 */
#app.scene-mode {
  /* 天空45% + 地平线4% + 沙地51%，模拟画面向左右延伸 */
  background: linear-gradient(to bottom,
    #0d0d1a 0%,       /* 天空顶：深黑蓝 */
    #1a0840 20%,      /* 天空上：深蓝 */
    #2e1060 38%,      /* 天空下：暗紫 */
    #4a1a70 44%,      /* 天空底：紫色 */
    #6B2460 45%,      /* 地平线1：紫红 */
    #9B3A40 47%,      /* 地平线2 */
    #C4613B 48%,      /* 地平线3：过渡 */
    #c4a360 49%,      /* 沙地上沿：沙黄 */
    #B89850 75%,      /* 沙地中 */
    #A8863A 100%      /* 沙地底：深沙褐 */
  );
  padding: 0 !important;
}
#app.scene-mode #top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  border-radius: 0;
  background: rgba(13, 8, 4, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  border-bottom: 1px solid rgba(212, 163, 115, 0.3);
  padding: 6px 12px;
}
#app.scene-mode #top-bar #game-title {
  font-size: 1rem;
}
#app.scene-mode #top-bar .stats {
  gap: 10px;
}
#app.scene-mode #top-bar .stat-item {
  font-size: 0.75rem;
  color: #FFFFFF;
}
#app.scene-mode #top-bar .stat-item svg {
  width: 16px;
  height: 16px;
}
#app.scene-mode #main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
}
#app.scene-mode #scene-canvas {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  border: none;
  box-shadow: none;
  margin: 0;
}
#app.scene-mode #main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: transparent;
}
#app.scene-mode #scene-hud {
  flex: 0 0 auto;
  padding: 4px 6px;
  min-height: 36px;
}

/* --- 顶部状态栏 --- */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 243, 224, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

#top-bar .stats {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-title);
  font-weight: 500;
}

.stat-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* --- 标题 --- */
#game-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* --- 主内容区 --- */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 1;
  visibility: visible;
}

/* ── 像素场景 Canvas（全屏无黑边）── */
#scene-canvas {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  border: none;
  box-shadow: none;
  background: #0D0804;
  touch-action: manipulation;
}
/* 场景下方 HUD 按钮条 */
#scene-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: #0D0804;
  border-top: 1px solid rgba(212, 163, 115, 0.25);
  justify-content: center;
}
#scene-hud .btn {
  font-size: 11px;
  padding: 4px 10px;
  min-height: 28px;
  min-width: auto;
  border-radius: 4px;
}
/* 移动端 HUD 优化 */
@media (max-width: 768px) {
  #scene-hud {
    gap: 3px;
    padding: 4px 4px;
    padding-bottom: calc(4px + var(--safe-bottom));
  }
  #scene-hud .btn {
    font-size: 10px;
    padding: 5px 8px;
    min-height: 32px;
  }
}

/* --- 面板 --- */
.panel {
  background: rgba(255, 248, 240, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.panel-inner {
  background: var(--bg-gradient);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

/* --- 对话框 --- */
.dialog {
  position: relative;
}

.dialog-text {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  min-height: 3em;
}

.dialog-speaker {
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

/* --- 角色立绘区 --- */
.character-portrait {
  text-align: center;
  margin-bottom: 12px;
}

.character-portrait img {
  max-width: 200px;
  max-height: 260px;
  border-radius: var(--radius-md);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-md);
  object-fit: cover;
  background: var(--bg-panel);
}

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  font-weight: 500;
  color: #fff;
  background: linear-gradient(135deg, #C99A5D, #D4A373);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
  min-width: 110px;
  min-height: 42px;
  text-align: center;
  outline: none;
  box-shadow: 0 2px 8px rgba(180, 130, 70, 0.2), 0 1px 2px rgba(62, 39, 35, 0.06);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 50%);
  border-radius: inherit;
  pointer-events: none;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(180, 130, 70, 0.3), 0 2px 4px rgba(62, 39, 35, 0.08);
}

.btn:active {
  filter: brightness(0.92);
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(180, 130, 70, 0.15);
}

.btn:focus-visible {
  outline: 2px solid var(--primary-dark);
  outline-offset: 2px;
}

.btn:disabled {
  background: #C0B39A;
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.btn-secondary {
  background: linear-gradient(135deg, #1E8A7A, #2A9D8F);
  box-shadow: 0 2px 8px rgba(30, 120, 100, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.btn-outline::after { display: none; }

.btn-outline:hover {
  background: rgba(212, 163, 115, 0.1);
  box-shadow: 0 2px 8px rgba(180, 130, 70, 0.1);
}

.btn-danger {
  background: linear-gradient(135deg, #D15A42, #E76F51);
  box-shadow: 0 2px 8px rgba(210, 80, 60, 0.2);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  min-width: auto;
  min-height: 34px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1.1rem;
  min-height: 48px;
}

/* --- 选项组 --- */
.options-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.options-group .btn {
  justify-content: flex-start;
  text-align: left;
  width: 100%;
}

.option-hint {
  font-size: 0.8rem;
  color: var(--text-disabled);
  margin-left: auto;
  padding-left: 12px;
  white-space: nowrap;
}

/* --- 进度条 --- */
.progress-bar {
  height: 8px;
  background: #EDE0D4;
  border-radius: 4px;
  overflow: hidden;
  flex: 1;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  background: var(--secondary);
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-fill.gold {
  background: var(--primary);
}

.progress-fill.danger {
  background: var(--error);
}

/* --- 建筑/设施网格 --- */
.facility-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 500px) {
  .facility-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.facility-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  box-shadow: 0 1px 4px rgba(62, 39, 35, 0.04);
}

.facility-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  background: rgba(255, 248, 240, 0.9);
}

.facility-card:active {
  transform: scale(0.97);
}

.facility-card.owned {
  border-color: var(--secondary);
  background: rgba(42, 157, 143, 0.08);
  box-shadow: 0 0 0 1px rgba(42, 157, 143, 0.1);
}

.facility-card svg {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
}

.facility-card .name {
  font-weight: 600;
  color: var(--text-title);
  font-size: 0.8rem;
}

.facility-card .level {
  font-size: 0.7rem;
  color: var(--secondary);
  margin-top: 2px;
}

.facility-card .cost {
  font-size: 0.7rem;
  color: var(--text-disabled);
  margin-top: 2px;
}

/* --- 融合工坊 --- */
.fusion-workshop {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.fusion-slot {
  background: rgba(255, 255, 255, 0.5);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  gap: 8px;
}

.fusion-slot:hover {
  border-color: var(--primary);
  background: rgba(212, 163, 115, 0.08);
}

.fusion-slot.selected {
  border-color: var(--secondary);
  border-style: solid;
  background: rgba(42, 157, 143, 0.08);
}

.fusion-slot .slot-label {
  color: var(--text-disabled);
  font-size: 0.85rem;
}

.fusion-slot .item-name {
  font-weight: 600;
  color: var(--text-title);
}

.fusion-plus {
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 700;
}

.fusion-result {
  text-align: center;
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.fusion-result .result-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--secondary);
}

.fusion-result .result-desc {
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 4px;
}

/* --- 融合特效 Canvas --- */
#fusion-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* --- 物品列表 --- */
.item-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}

.item-card {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.item-card:hover {
  border-color: var(--primary);
  background: rgba(212, 163, 115, 0.1);
}

.item-card.selected {
  border-color: var(--secondary);
  background: rgba(42, 157, 143, 0.1);
}

.item-card.recommended {
  position: relative;
  border-color: rgba(212, 163, 115, 0.5);
  background: rgba(212, 163, 115, 0.06);
}
.item-card.recommended::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: var(--radius-sm);
  border: 1.5px dashed rgba(212, 163, 115, 0.4);
  pointer-events: none;
}
.item-card.recommended:hover {
  border-color: var(--primary);
  background: rgba(212, 163, 115, 0.12);
}

/* 配方小格子（融合工坊内，类似物品栏） */
.recipe-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.recipe-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  min-height: 72px;
  position: relative;
}
.recipe-tile:hover {
  border-color: var(--secondary);
  background: rgba(42, 157, 143, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.recipe-tile .recipe-tile-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}
.recipe-tile .recipe-tile-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.3;
  margin-bottom: 2px;
}
.recipe-tile .recipe-tile-formula {
  font-size: 0.65rem;
  color: var(--text-disabled);
  line-height: 1.2;
}
.recipe-tile .recipe-tile-lore {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: var(--secondary);
  opacity: 0.7;
}

.item-faction {
  font-size: 0.7rem;
  color: var(--text-disabled);
  margin-top: 2px;
}

/* --- 声望面板 --- */
.reputation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.rep-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
}

.rep-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.rep-name {
  width: 70px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-title);
  flex-shrink: 0;
}

.rep-value {
  font-size: 0.8rem;
  color: var(--text-disabled);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* --- 成就徽章 --- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  text-align: center;
  opacity: 0.4;
  transition: all var(--transition-fast);
}

.badge.earned {
  opacity: 1;
  background: rgba(42, 157, 143, 0.08);
  border: 1px solid var(--secondary);
}

.badge svg {
  width: 40px;
  height: 40px;
}

.badge .name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-title);
}

/* --- 弹窗/模态 --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
  -webkit-overflow-scrolling: touch;
}

.modal {
  background: var(--bg-panel);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 标题栏：标题左 + 关闭按钮右 */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-title);
  margin: 0;
  flex: 1;
}

.modal-close {
  background: rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: #fff;
  background: var(--error);
  border-color: var(--error);
}

/* 可滚动内容区 */
.modal-scroll {
  padding: 14px 18px 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* --- 标签页 --- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-disabled);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

/* --- 回合/季度信息 --- */
.season-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-title);
}

.season-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.season-dot.spring { background: #8BC34A; }
.season-dot.summer { background: #FF7043; }
.season-dot.autumn { background: #FFA726; }
.season-dot.winter { background: #90CAF9; }

/* --- 通知 --- */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 12px 24px;
  font-size: 0.9rem;
  color: var(--text-title);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: notificationIn 0.3s ease-out;
  pointer-events: none;
}

.notification.error {
  border-color: var(--error);
  color: var(--error);
}

.notification.success {
  border-color: var(--secondary);
  color: var(--secondary);
}

/* --- 飘字效果 --- */
.float-text {
  position: fixed;
  pointer-events: none;
  z-index: 250;
  font-weight: 700;
  font-size: 1.2rem;
  animation: floatUp 1.2s ease-out forwards;
}

.float-text.positive { color: var(--secondary); }
.float-text.negative { color: var(--error); }

/* --- 食谱/配方书 --- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.recipe-card {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.recipe-card .recipe-name {
  font-weight: 600;
  color: var(--text-title);
  margin-bottom: 4px;
}

.recipe-card .recipe-ingredients {
  font-size: 0.8rem;
  color: var(--text-disabled);
}

.recipe-card .recipe-rarity {
  font-size: 0.75rem;
  margin-top: 4px;
}

.rarity-common { color: #9E9E9E; }
.rarity-uncommon { color: var(--secondary); }
.rarity-rare { color: #7E57C2; }
.rarity-epic { color: #FF6F00; }
.rarity-legendary { color: #D4A373; }

/* --- 工具栏 --- */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .btn {
  min-width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* --- 加载画面 --- */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-main);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

#loading-screen .logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 0.1em;
}

#loading-screen .loader {
  width: 60px;
  height: 60px;
}

/* --- 屏幕阅读器 --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- 动画关键帧 --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes notificationIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.2); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* --- 滚动条 --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-disabled);
  border-radius: 3px;
}

/* --- 小游戏覆盖层 --- */
.minigame-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.minigame-modal {
  background: var(--bg-panel);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.minigame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--text-title);
  font-size: 1.1rem;
}

.minigame-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-disabled);
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.minigame-close:hover {
  color: var(--error-light);
  background: rgba(231, 111, 81, 0.1);
}

.minigame-info {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.minigame-info strong {
  color: var(--secondary);
}

.minigame-canvas-wrap {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.minigame-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.minigame-next {
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
}

.minigame-controls-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-disabled);
  padding: 8px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-sm);
}

/* ── 俄罗斯方块触摸按钮 ── */
.tetris-touch-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.tetris-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.tetris-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(212, 163, 115, 0.12);
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.tetris-btn:active {
  background: var(--primary);
  color: #fff;
  transform: scale(0.93);
}
.tetris-btn-wide {
  width: 80px;
  font-size: 0.8rem;
}

/* ── 贪吃蛇布局：画布左 + 方向键右 ── */
.snake-layout {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.snake-canvas-side {
  flex: 1;
  min-width: 0;
}

/* ── 贪吃蛇方向按钮（十字键）── */
.snake-touch-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.snake-row {
  display: flex;
  gap: 2px;
  justify-content: center;
}
.snake-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(212, 163, 115, 0.12);
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.snake-btn:active {
  background: var(--primary);
  color: #fff;
  transform: scale(0.9);
}
.snake-btn-pause {
  background: rgba(231, 111, 81, 0.12);
  border-color: rgba(231, 111, 81, 0.3);
  color: var(--error);
  font-size: 0.9rem;
  width: 50px;
}

/* ── 俄罗斯方块弹窗 mobile 缩小 ── */
.tetris-modal {
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tetris-modal .minigame-canvas-wrap {
  align-items: center;
}
.tetris-modal #tetris-canvas {
  max-width: 140px;
  max-height: 280px;
  width: auto;
  height: auto;
}
@media (max-width: 600px) {
  .tetris-modal {
    padding: 10px;
  }
  .tetris-modal .minigame-header { font-size: 0.95rem; margin-bottom: 6px; }
  .tetris-modal .minigame-info { gap: 6px; font-size: 0.7rem; padding: 4px 8px; }
  .tetris-modal #tetris-canvas {
    max-width: 120px;
    max-height: 240px;
  }
  .tetris-modal #tetris-next { width: 60px; height: 48px; }
  .tetris-modal .minigame-side { gap: 3px; }
  .tetris-btn { width: 30px; height: 30px; font-size: 0.8rem; border-radius: 6px; }
  .tetris-btn-wide { width: 64px; font-size: 0.7rem; }
}

@media (max-width: 600px) {
  .minigame-canvas-wrap {
    flex-direction: column;
    align-items: center;
  }
  .minigame-side {
    width: 100%;
  }
  .minigame-modal {
    padding: 12px;
  }
}

/* --- 确认弹窗 --- */
.confirm-dialog {
  max-width: 420px;
  text-align: center;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.confirm-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-title);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.confirm-body {
  padding: 6px 0 16px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

.confirm-body p {
  margin: 0 0 10px;
}

.confirm-cost {
  font-size: 1rem;
  color: var(--secondary);
  background: rgba(42, 157, 143, 0.08);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.confirm-cost strong {
  font-weight: 700;
}

.confirm-rules {
  text-align: left;
  margin: 12px 0;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.confirm-rule {
  padding: 5px 0;
  font-size: 0.82rem;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.rule-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 1px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.confirm-actions .btn {
  min-width: 110px;
}

/* --- 小游戏结果弹窗 --- */
.minigame-result-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
  animation: fadeIn 0.35s ease;
}

.result-card {
  background: #fffef9;
  border-radius: 16px;
  padding: 28px 32px 24px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-card.result-win {
  border-top: 4px solid #4CAF50;
}

.result-card.result-lose {
  border-top: 4px solid #E76F51;
}

.result-icon {
  font-size: 2.5rem;
  margin-bottom: 6px;
}

.result-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 8px;
}

.result-message {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 4px;
}

.result-detail {
  font-size: 0.82rem;
  color: var(--secondary);
  margin-top: 6px;
  padding: 6px 12px;
  background: rgba(42, 157, 143, 0.07);
  border-radius: 8px;
  display: inline-block;
}

.result-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 20px;
}

.result-actions .btn {
  min-width: 120px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.result-actions .btn-retry {
  background: var(--primary);
  color: #fff;
  border: none;
}

.result-actions .btn-retry:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.result-actions .btn-quit {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

.result-actions .btn-quit:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
}

@keyframes scaleIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- 诗词对句 --- */
.poetry-question-area {
  text-align: center;
  padding: 16px 0 10px;
}

.poetry-upper {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.poetry-author {
  font-size: 0.82rem;
  color: var(--text-disabled);
  margin-bottom: 2px;
}

.poetry-hint {
  font-size: 0.85rem;
  color: var(--secondary);
  margin-top: 4px;
}

.poetry-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px 12px;
}

.poetry-option {
  padding: 12px 8px;
  font-size: 0.95rem;
  font-weight: 600;
  background: #fefefe;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
}

.poetry-option:hover {
  border-color: var(--primary);
  background: rgba(42,157,143,0.06);
  transform: translateY(-1px);
}

.poetry-option.poetry-correct {
  border-color: #4CAF50;
  background: rgba(76,175,80,0.12);
  color: #2E7D32;
}

.poetry-option.poetry-wrong {
  border-color: #E76F51;
  background: rgba(231,111,81,0.12);
  color: #C62828;
}

/* --- 圣火守护 --- */
.fire-gauge-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
  gap: 16px;
}

.fire-gauge {
  position: relative;
  width: 48px;
  height: 200px;
  background: #1a1a2e;
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.fire-safe-zone {
  position: absolute;
  left: 0; right: 0;
  background: rgba(76,175,80,0.15);
  border-left: 2px dashed rgba(76,175,80,0.4);
  border-right: 2px dashed rgba(76,175,80,0.4);
}

.fire-level {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  transition: height 0.3s, background 0.5s;
  border-radius: 0 0 7px 7px;
}

.fire-flame-icon {
  font-size: 2rem;
  transition: transform 0.2s;
  animation: firePulse 1.2s ease-in-out infinite;
}

@keyframes firePulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.btn-fire-add {
  background: linear-gradient(135deg, #E65100, #FF6F00);
  color: #fff;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 36px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(230,81,0,0.3);
}

.btn-fire-add:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(230,81,0,0.45);
}

.btn-fire-add:active {
  transform: scale(0.96);
}

/* --- 文物拼合 --- */
#artifact-slider {
  cursor: pointer;
}

/* --- 曼陀罗描画 --- */
#mandala-canvas {
  background: #0d0d1a;
}

/* --- 梨园乐谱 --- */
.melody-keys {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 6px;
}

.melody-key {
  width: 56px;
  text-align: center;
  padding: 5px 0;
  border-radius: 6px;
  transition: all 0.15s;
}

.melody-key kbd {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 0;
  margin-bottom: 2px;
  color: #ddd;
}

.melody-key span {
  font-size: 0.7rem;
  color: var(--text-disabled);
}

.melody-key.hit-perfect kbd {
  background: rgba(76,175,80,0.35);
  border-color: #4CAF50;
  color: #4CAF50;
  transform: scale(1.08);
}

.melody-key.hit-good kbd {
  background: rgba(255,179,0,0.25);
  border-color: #FFB300;
  color: #FFB300;
  transform: scale(1.04);
}

.game-countdown {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 4rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 30px rgba(42,157,143,0.6), 0 0 60px rgba(42,157,143,0.3);
  animation: cdPop 0.6s ease-out;
  pointer-events: none;
  z-index: 10;
}

@keyframes cdPop {
  0% { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  60% { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
}

/* ========== 集市货柜拼图 ========== */
.market-shelf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #3d2b1a 0%, #2a1a0a 100%);
  border-radius: 8px;
  border: 3px solid #5a3a1a;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.market-item-card {
  background: #1a1a2e;
  border: 2px solid #555;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}
.market-item-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  border-color: #aaa;
}

.market-item-img {
  width: 100%;
  height: 120px;
  overflow: hidden;
  background: #0d0d1a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.market-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.market-item-label {
  padding: 6px 4px 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e8d5b0;
}

.market-item-badge {
  display: inline-block;
  padding: 2px 10px;
  margin: 2px 0 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  color: #fff;
  font-weight: 600;
}

.market-item-done {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #4CAF50;
  pointer-events: none;
}

/* 拼图区域 */
.puzzle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

@media (min-width: 540px) {
  .puzzle-container {
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 16px !important;
  }
}

.puzzle-board-wrap {
  position: relative;
  flex-shrink: 0;
}

.puzzle-grid {
  background: #222;
  border: 2px solid #444;
  border-radius: 6px;
}

.puzzle-piece {
  transition: outline 0.15s, opacity 0.15s, transform 0.1s;
}
.puzzle-piece:hover {
  filter: brightness(1.2);
  transform: scale(1.03);
  z-index: 2;
}
.puzzle-piece[draggable="true"]:active {
  cursor: grabbing !important;
}

/* 文物讲解弹窗 */
.artifact-story-modal {
  max-height: 85vh;
  overflow-y: auto;
}

.artifact-story-content {
  text-align: center;
  padding: 8px 0;
  color: var(--text);
}

.artifact-story-img {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.artifact-story-img img {
  image-rendering: pixelated;
}

.artifact-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
  font-size: 0.8rem;
  color: var(--text-disabled);
}

.artifact-story, .artifact-significance {
  text-align: left;
  margin: 10px 0;
  padding: 10px 14px;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}
.artifact-story h4, .artifact-significance h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--primary-dark);
}
.artifact-story p, .artifact-significance p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.7;
}

@media (max-width: 600px) {
  .market-shelf {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
  }
  .market-item-img {
    height: 90px;
  }
}
@media (max-width: 600px) {
  #app {
    padding: 10px;
  }

  #top-bar {
    padding: 10px 12px;
    gap: 8px;
  }

  #game-title {
    font-size: 1.1rem;
  }

  .panel {
    padding: 14px;
  }

  .btn {
    min-width: 100px;
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .fusion-workshop {
    grid-template-columns: 1fr;
  }

  .fusion-plus {
    text-align: center;
    transform: rotate(90deg);
  }

  .reputation-grid {
    grid-template-columns: 1fr;
  }

  .facility-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .character-portrait img {
    max-width: 140px;
    max-height: 180px;
  }

  .stat-item {
    font-size: 0.8rem;
  }

  .sound-panel {
    min-width: 150px;
    padding: 10px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== 沙暴预警像素风小游戏 ==================== */
.sandstorm-modal {
  font-family: 'Courier New', monospace;
  image-rendering: pixelated;
}

.sandstorm-modal .btn {
  font-family: 'Courier New', monospace;
  image-rendering: pixelated;
}

/* 像素风警铃按钮动效 */
#storm-alarm:active {
  transform: scale(0.95);
  box-shadow: inset 3px 3px 0 rgba(0,0,0,0.3), inset -3px -3px 0 rgba(255,255,255,0.1) !important;
}

/* ── 粮仓 · 五谷辨粮 像素风 ── */
.granary-modal {
  font-family: 'Courier New', monospace;
  image-rendering: pixelated;
}

.granary-modal .btn {
  font-family: 'Courier New', monospace;
  image-rendering: pixelated;
}

/* 沙暴粒子闪烁动画 */
@keyframes sand-flicker {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* HUD 按钮引导闪烁 */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(218,165,32,0.3); border-color: rgba(212,163,115,0.25); }
  50% { box-shadow: 0 0 16px rgba(218,165,32,0.9), 0 0 32px rgba(255,215,0,0.4); border-color: #FFD700; }
}
.hud-glow {
  animation: pulse-glow 1.2s ease-in-out infinite !important;
}

/* ============================================
   按钮图标（静音等）
   ============================================ */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(212, 163, 115, 0.12);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--primary-dark);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.btn-icon:hover {
  background: rgba(212, 163, 115, 0.2);
  transform: scale(1.05);
}
.btn-icon:active {
  transform: scale(0.95);
}

/* ── 音乐控制（按钮 + 弹出面板）── */
.music-control {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* 声音设置弹出面板 */
.sound-panel {
  position: absolute;
  top: 44px;
  right: 0;
  background: rgba(255, 243, 224, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 170px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sound-label {
  font-size: 0.85rem;
  color: var(--text-title);
  font-weight: 500;
  white-space: nowrap;
}

/* Toggle 开关 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(212, 163, 115, 0.3);
  border-radius: 22px;
  transition: background-color 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* 音量滑块（通用） */
.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(212, 163, 115, 0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid var(--primary-dark);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.vol-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--primary-dark);
}
.vol-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid var(--primary-dark);
  border-radius: 50%;
  cursor: pointer;
}
/* 静音时滑块变灰 */
.vol-slider.muted-slider {
  opacity: 0.35;
  pointer-events: none;
}

/* ============================================
   全屏触发门 / 微信提示
   ============================================ */
#fullscreen-gate {
  display: flex;
  position: fixed;
  inset: 0;
  background: #0A0604;
  z-index: 999999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: #D4A373;
  font-family: var(--font-body);
  text-align: center;
  padding: 40px;
  cursor: pointer;
}
#fullscreen-gate .gate-icon {
  width: 80px;
  height: 80px;
  animation: rotateHint 2s ease-in-out infinite;
}
#fullscreen-gate .gate-icon svg {
  width: 100%;
  height: 100%;
}
#fullscreen-gate p {
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
  max-width: 280px;
}
@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

/* ============================================
   横屏提示（备用）
   ============================================ */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: #0A0604;
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: #D4A373;
  font-family: var(--font-body);
  text-align: center;
  padding: 40px;
}
#rotate-hint .rotate-icon {
  width: 80px;
  height: 80px;
  animation: rotateHint 2s ease-in-out infinite;
}
#rotate-hint .rotate-icon svg {
  width: 100%;
  height: 100%;
}
#rotate-hint p {
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

/* 摇杆已移除，移动端使用点击移动 */

/* 移动端操作提示 */
#mobile-hint {
  text-align: center;
  padding: 6px 12px;
  font-size: 0.7rem;
  color: var(--text-disabled);
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius-sm);
  margin: 4px 8px;
  line-height: 1.4;
}

/* 仅移动端显示 — 由 JS 动态控制，不依赖 CSS 宽度 */

/* ============================================
   移动端触摸优化（全局）
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* 所有可点击元素加大触控区域 */
  .btn { min-height: 44px; padding: 12px 24px; }
  .btn-sm { min-height: 38px; padding: 8px 16px; }
  .btn-lg { min-height: 52px; padding: 16px 36px; }
  
  .facility-card { min-height: 72px; padding: 14px 8px; }
  .item-card { min-height: 50px; padding: 12px 10px; }
  .recipe-tile { min-height: 80px; padding: 12px 8px; }
  
  .tab { padding: 10px 18px; min-height: 40px; }
  .modal-close { padding: 8px 12px; font-size: 1.8rem; }
  .minigame-close { padding: 8px 12px; font-size: 1.8rem; }
  
  /* 去掉 hover 效果（移动端无 hover） */
  .btn:hover { transform: none; filter: none; box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
  .btn:active { transform: scale(0.96); filter: brightness(0.9); }
  
  .facility-card:hover { transform: none; }
  .facility-card:active { transform: scale(0.97); background: rgba(212, 163, 115, 0.08); }
  
  .item-card:hover { border-color: var(--border); }
  .item-card:active { border-color: var(--primary); background: rgba(212, 163, 115, 0.1); }
  
  .recipe-tile:hover { transform: none; }
  .recipe-tile:active { transform: scale(0.97); border-color: var(--secondary); }
  
  .tab:active { color: var(--primary-dark); }
  
  .poetry-option:hover { border-color: var(--border); }
  .poetry-option:active { border-color: var(--primary); background: rgba(42,157,143,0.06); }
}

/* ============================================
   完整响应式布局
   ============================================ */
@media (max-width: 768px) {
  :root {
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
  }

  body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
  }

  #app {
    padding: 8px;
    gap: 8px;
  }

  #top-bar {
    padding: 8px 10px;
    gap: 6px;
    border-radius: var(--radius-md);
    margin-bottom: 6px;
  }
  
  #top-bar #game-title {
    font-size: 1rem;
  }
  
  #top-bar .stats {
    gap: 10px;
  }
  
  .stat-item {
    font-size: 0.78rem;
    gap: 4px;
  }
  
  .stat-item svg {
    width: 16px;
    height: 16px;
  }

  #main-content {
    gap: 8px;
    padding-bottom: calc(var(--safe-bottom) + 8px);
  }

  .panel {
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .panel-inner {
    padding: 10px;
    margin-bottom: 8px;
  }

  .btn {
    min-width: 80px;
    padding: 10px 18px;
    font-size: 0.88rem;
    min-height: 40px;
    border-radius: var(--radius-md);
  }

  .fusion-workshop {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .fusion-slot {
    min-height: 100px;
    padding: 14px;
  }
  .fusion-plus {
    text-align: center;
    transform: rotate(90deg);
    font-size: 1.3rem;
  }

  .reputation-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .facility-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .character-portrait img {
    max-width: 120px;
    max-height: 160px;
  }

  .options-group {
    gap: 6px;
  }

  .toolbar {
    gap: 6px;
  }
  .toolbar .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 36px;
  }

  .dialog-text {
    font-size: 0.9rem;
  }
  .dialog-speaker {
    font-size: 1rem;
  }

  .tabs {
    gap: 2px;
    margin-bottom: 8px;
  }
  .tab {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .modal {
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--radius-md);
  }
  .modal-header {
    padding: 10px 14px 8px;
  }
  .modal-title {
    font-size: 1.05rem;
  }
  .modal-close {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }
  .modal-scroll {
    padding: 10px 14px 16px;
  }

  .minigame-modal {
    padding: 12px;
    max-width: 100%;
    border-radius: var(--radius-md);
  }
  
  .recipe-tiles {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
  }
  
  .recipe-tile {
    padding: 8px 4px 6px;
    min-height: 64px;
  }
  
  .recipe-tile .recipe-tile-name {
    font-size: 0.7rem;
  }

  .item-list {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    max-height: 150px;
  }

  .badge-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
  }

  .confirm-dialog {
    max-width: 92% !important;
    padding: 14px 12px !important;
  }
  .confirm-header {
    font-size: 1rem;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  .confirm-body {
    font-size: 0.8rem;
    padding: 2px 0 8px;
  }
  .confirm-body p {
    margin: 0 0 6px;
  }
  .confirm-rules {
    padding: 8px 10px;
    margin: 8px 0;
    font-size: 0.75rem;
  }
  .confirm-rule {
    font-size: 0.75rem;
    padding: 3px 0;
    gap: 6px;
  }
  .confirm-cost {
    font-size: 0.85rem;
    padding: 6px 10px;
  }
  .confirm-actions {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
  }
  .confirm-actions .btn {
    min-width: 80px;
    flex: 1;
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .poetry-options-grid {
    gap: 8px;
    padding: 6px 8px 10px;
  }
  .poetry-option {
    padding: 10px 6px;
    font-size: 0.88rem;
  }
  .poetry-upper {
    font-size: 1.15rem;
  }

  .market-shelf {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
  }
  .market-item-img {
    height: 80px;
  }

  .fire-gauge {
    width: 40px;
    height: 150px;
  }

  .season-info {
    padding: 8px 12px;
    font-size: 0.82rem;
    gap: 8px;
  }
}

@media (max-width: 400px) {
  #app {
    padding: 4px;
  }

  #top-bar {
    padding: 6px 8px;
    gap: 4px;
  }
  #top-bar .stats {
    gap: 6px;
  }
  .stat-item {
    font-size: 0.7rem;
    gap: 2px;
  }
  .stat-item svg {
    width: 14px;
    height: 14px;
  }

  .facility-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .facility-card {
    padding: 8px 4px;
  }
  .facility-card svg {
    width: 22px;
    height: 22px;
  }
  .facility-card .name {
    font-size: 0.7rem;
  }
  .facility-card .level,
  .facility-card .cost {
    font-size: 0.65rem;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.82rem;
    min-height: 36px;
  }

  .panel {
    padding: 10px;
  }
}

/* ============================================
   iPhone 刘海屏 / 全面屏适配
   ============================================ */
@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
  }
}

/* ============================================
   横屏模式优化
   ============================================ */
@media (max-width: 900px) and (orientation: landscape) {
  #app {
    padding: 2px 6px;
  }
  #top-bar {
    padding: 3px 8px;
    margin-bottom: 2px;
  }
  #game-title {
    font-size: 0.9rem;
  }
  #top-bar .stats {
    gap: 8px;
  }
  .stat-item {
    font-size: 0.7rem;
    gap: 3px;
  }
  .stat-item svg {
    width: 14px;
    height: 14px;
  }
  #main-content {
    gap: 3px;
    overflow-y: auto;
  }

  #app.scene-mode #scene-hud {
    padding: 3px 4px;
    gap: 2px;
  }
  #app.scene-mode #scene-hud .btn {
    font-size: 9px;
    padding: 3px 7px;
    min-height: 24px;
  }

  #mobile-hint { display: none !important; }

  .panel { padding: 6px 10px; }
  .facility-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .facility-card { padding: 6px 4px; }
  .facility-card svg { width: 22px; height: 22px; }
  .facility-card .name { font-size: 0.7rem; }
}

/* ============================================
   竖屏提示已由 #fullscreen-gate 统一处理
   ============================================ */


