/* ============================================================
   app.css — 全站基础样式
   ------------------------------------------------------------
   昼夜模式通过 <html data-theme="day|dusk|night"> 切换，
   所有颜色都用 CSS 变量，所以一改全改。
   ============================================================ */

:root {
  /* 像素风格：所有圆角都用小数值，营造"方块感" */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  --pixel-font: "Zpix", "Fusion Pixel", "Silkscreen", monospace;
  --body-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Hiragino Sans GB", "Noto Sans SC", sans-serif;

  /* 动效时长 */
  --t-fast: 0.16s;
  --t-mid: 0.32s;
  --t-slow: 0.6s;
}

/* ---------- 白天 ---------- */
html[data-theme="day"] {
  --bg: #f6e7d3;
  --bg-deep: #ecd7bd;
  --wall: #f2ddc4;
  --floor: #c98f5c;
  --floor-dark: #b57c4c;
  --card: #fffaf2;
  --card-alt: #f6e9d8;
  --ink: #5a4030;
  --ink-soft: #8d7059;
  --ink-faint: #b9a08a;
  --accent: #e88b8b;
  --accent-deep: #cf6a6a;
  --gold: #e8b866;
  --sky: #bfe3f0;
  --sky-deep: #9ed0e6;
  --shadow: rgba(122, 84, 52, 0.18);
  --lamp: #ffd98a;
  --lamp-glow: rgba(255, 217, 138, 0.55);
  --window-light: #fff3d6;
}

/* ---------- 黄昏 ---------- */
html[data-theme="dusk"] {
  --bg: #f0cdb4;
  --bg-deep: #e0b295;
  --wall: #e8c3a6;
  --floor: #b87c50;
  --floor-dark: #9e6741;
  --card: #fff3e8;
  --card-alt: #f2ded0;
  --ink: #5c3a2c;
  --ink-soft: #94695290;
  --ink-faint: #b08d78;
  --accent: #e67f7f;
  --accent-deep: #c85f5f;
  --gold: #f0b45c;
  --sky: #f5b98a;
  --sky-deep: #e79a6c;
  --shadow: rgba(120, 70, 44, 0.22);
  --lamp: #ffc96b;
  --lamp-glow: rgba(255, 201, 107, 0.6);
  --window-light: #ffd9a3;
}

/* ---------- 夜晚 ---------- */
html[data-theme="night"] {
  --bg: #3a3352;
  --bg-deep: #2c2740;
  --wall: #453c60;
  --floor: #5a4560;
  --floor-dark: #4a3850;
  --card: #4a4166;
  --card-alt: #3f3659;
  --ink: #f0e6f5;
  --ink-soft: #c0b2d4;
  --ink-faint: #8d80a6;
  --accent: #ef9bb0;
  --accent-deep: #d97b93;
  --gold: #ffcf7a;
  --sky: #2f2a4a;
  --sky-deep: #241f3a;
  --shadow: rgba(0, 0, 0, 0.35);
  --lamp: #ffd98a;
  --lamp-glow: rgba(255, 217, 138, 0.7);
  --window-light: #6b6390;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--ink);
  transition: background var(--t-slow) ease, color var(--t-slow) ease;
  overflow-x: hidden;
  /* 手机竖屏优先，桌面端也限制在手机宽度内居中 */
  display: flex;
  justify-content: center;
}

/* 手机画布：所有页面都活在这个容器里 */
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  transition: background var(--t-slow) ease;
  overflow: hidden;
  box-shadow: 0 0 60px var(--shadow);
}

/* ---------- 像素颗粒质感（叠一层很淡的噪点） ---------- */
.pixel-grain::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.045;
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.5) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
html[data-theme="night"] .pixel-grain::after {
  mix-blend-mode: screen;
  opacity: 0.03;
}

/* ---------- 通用像素图标 ---------- */
.pixel-icon {
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 var(--shadow));
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-md);
  border: 2px solid var(--bg-deep);
  box-shadow: 0 4px 0 var(--shadow);
  transition: background var(--t-slow) ease, border-color var(--t-slow) ease;
}

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--r-md);
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--accent-deep);
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--accent-deep);
  filter: brightness(0.96);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 2px solid var(--bg-deep);
  box-shadow: none;
}
.btn-ghost:active { transform: translateY(2px); }

/* ---------- 页面转场 ---------- */
.page {
  animation: pageIn var(--t-mid) ease both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.fade-out { animation: pageOut var(--t-fast) ease both; }
@keyframes pageOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ---------- 顶部返回栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--bg-deep);
}
.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.topbar .back {
  font-size: 20px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb {
  background: var(--ink-faint);
  border-radius: 3px;
}

/* ---------- 通用文字工具类 ---------- */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.center { text-align: center; }

/* ---------- 隐藏元素 ---------- */
.hidden { display: none !important; }

/* ---------- 减少动画偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}