/* ================================================================
   BuffNook Tower · Site stylesheet
   —— 只放全局 reset、变量、排版、按钮、游戏容器、卡片、正文、FAQ、页脚 ——
   —— 页面专属样式不许写进这个文件 ——
   ================================================================ */

/* ---------- 1. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; }

/* ---------- 2. 变量（全部来自游戏源码抽取，不许写死数值） ---------- */
:root {
  /* 背景 */
  --bg-0: #1B1714;        /* 页面主背景（暖棕黑） */
  --bg-1: #26201B;        /* 面板表面 */
  --bg-2: #2F2721;        /* 次表面 / 卡片 */
  --bg-canvas: #16120F;   /* 游戏容器底，比主背景再深一层 */

  /* 主色 & 强调色（各只 1 个，全站克制使用） */
  --amber: #E8963A;       /* 主色：drop 按钮、primary、eyebrow、p-big */
  --amber-deep: #8A4A12;  /* primary 按钮 3px 投影 */
  --lime: #C6E03A;        /* 强调色：封顶 ready、里程碑成功信号 */

  /* 正文三档 */
  --ink: #EDE6DA;         /* 亮暖白 · 标题/数值/按钮主文字 */
  --ink-dim: #B3A99A;     /* 暖灰 · 副文字/说明/标签 */
  --ink-mute: #7C7265;    /* 更深的灰 · 辅助/时间戳 */

  /* 边框 */
  --line: #3E342C;               /* 粗边框：面板/按钮 */
  --line-soft: rgba(237,230,218,0.10); /* 柔边框/分隔线 */

  /* 字体 */
  --font: "Inter", "Avenir Next", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;

  /* 形状 */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 14px;      /* --radius 原值 */
  --r-xl: 16px;
  --r-panel: 18px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.35);
  --sh-md: 0 3px 0 #100D0B, inset 0 1px 0 rgba(255,255,255,0.07);
  --sh-lg: 0 22px 50px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.04);
  --sh-panel: 0 24px 60px rgba(0,0,0,0.55);

  /* 动效：全站过渡极快，最长 .18s */
  --t-fast: .06s;
  --t-med: .15s;
  --t-slow: .18s;
  --ease: cubic-bezier(.4,0,.2,1);

  /* 布局 */
  --container: 1100px;
  --container-sm: 760px;
  --topbar: 64px;
  --gap: 14px;
}

/* ---------- 3. 排版 ---------- */
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 14px; }
.eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .24em;
  text-transform: uppercase; color: var(--amber);
}
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 4. 导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar);
  display: flex; align-items: center; gap: var(--gap);
  padding: 0 22px;
  background: rgba(24,20,17,0.88);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.nav-brand img { height: 40px; width: auto; max-width: 48vw; display: block; object-fit: contain; }
.nav-brand b { font-weight: 800; }
.nav-links { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.nav-links a {
  padding: 8px 14px; border-radius: var(--r-pill);
  color: var(--ink-dim); font-size: 13px; font-weight: 600;
  transition: color var(--t-med), background var(--t-med);
}
.nav-links a:hover { color: var(--ink); background: rgba(255,255,255,0.03); }
.nav-links a.active { color: var(--bg-0); background: var(--ink); }
.nav-lang {
  padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-dim); font-size: 12px; font-weight: 700;
  font-family: var(--mono); letter-spacing: .03em;
  cursor: pointer; transition: color var(--t-med), background var(--t-med), border-color var(--t-med);
}
.nav-lang:hover { color: var(--ink); border-color: var(--ink-mute); background: rgba(232,150,58,0.08); }
.nav-lang.active { color: var(--amber); border-color: var(--amber); }

/* 汉堡菜单：不依赖 JS 也能跳转 */
.nav-toggle { display: none; }
.nav-burger {
  width: 34px; height: 34px; display: inline-flex;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  border-radius: var(--r-sm);
}
.nav-burger span {
  width: 18px; height: 2px; background: var(--ink);
  border-radius: 2px;
  transition: transform var(--t-med), opacity var(--t-med);
}

/* ---------- 5. 容器 ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 22px; }
.container-sm { width: 100%; max-width: var(--container-sm); margin: 0 auto; padding: 0 22px; }

/* ---------- 6. 游戏容器 ---------- */
.game-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 22px 18px;
}
.game-head { text-align: center; margin-bottom: 22px; }
.game-head h1 { margin-bottom: 6px; }
.game-head p { color: var(--ink-dim); font-size: 13px; max-width: 520px; margin: 0 auto; }

/* 游戏容器：高度自适应视口，首页一屏看全 */
.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 260px);  /* 导航(58) + H1区 + 游戏按钮 留空间 */
  overflow: hidden;
  background: #16120F;
  border: none;
}
.game-stage > iframe,
.game-stage > .game-loader {
  position: absolute; inset: 0; width: 100%; height: 100%;
}

/* 手机：改成竖宽 9:16 */
@media (max-width: 640px) {
  .game-stage { aspect-ratio: 9 / 16; height: 56vh; min-height: 320px; }
}

/* 加载中：默认就是这个状态（HTML 里 game-stage--loading） */
.game-stage--loading > iframe { display: none; }
.game-stage--loading > .game-loader { display: flex; }

/* 加载完成 */
.game-stage--loaded > iframe { display: block; }
.game-stage--loaded > .game-loader { display: none; }

/* 加载状态兜底：没加任何 modifier 时，也先显示 loader 等 iframe */
.game-stage:not(.game-stage--loaded) > iframe { display: none; }
.game-stage:not(.game-stage--loaded) > .game-loader { display: flex; }

/* 加载动画 */
.game-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg-canvas);
}
.game-loader .spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--amber);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.game-loader .loader-text { font-size: 12px; color: var(--ink-dim); letter-spacing: .06em; }

/* iframe 尺寸安全：不出现 CLS */
.game-stage iframe {
  width: 100%; height: 100%;
  border: 0;
}

/* 游戏下方一排按钮 */
.game-bar {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 14px;
}
.game-bar button {
  height: 38px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-dim); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--t-med), border-color var(--t-med), background var(--t-med);
}
.game-bar button:hover { color: var(--ink); border-color: var(--ink-dim); background: rgba(255,255,255,0.03); }
.game-bar button .icon { font-size: 15px; line-height: 1; }

/* ---------- 7. 卡片 ---------- */
.card-grid {
  display: grid; gap: 14px; margin-top: 22px;
  grid-template-columns: repeat(3, 1fr);
}
.card {
  padding: 18px 18px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: rgba(255,255,255,0.022);
  transition: border-color var(--t-med), transform var(--t-med);
}
.card:hover { border-color: var(--line); transform: translateY(-1px); }
.card .card-num, .card .card-icon { font-family: var(--mono); font-size: 11px; color: var(--amber); font-weight: 700; letter-spacing: .06em; }
.card h3 { margin: 10px 0 6px; }
.card p { color: var(--ink-dim); font-size: 13px; margin: 0; }

/* 相关游戏卡片（封面图 + 游戏名 + 一句话） */
.related-grid {
  display: grid; gap: 14px; margin-top: 22px;
  grid-template-columns: repeat(4, 1fr);
}
.related-card {
  border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  overflow: hidden; background: var(--bg-1);
  transition: border-color var(--t-med), transform var(--t-med);
  display: flex; flex-direction: column;
}
.related-card:hover { border-color: var(--amber); transform: translateY(-1px); }
.related-cover {
  aspect-ratio: 16/9;
  background: var(--bg-2);
  object-fit: cover; width: 100%;
}
.related-info { padding: 12px 14px 14px; }
.related-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.related-desc { font-size: 12px; color: var(--ink-dim); margin-top: 3px; line-height: 1.45; }

/* ---------- 8. 正文区 ---------- */
.site { padding: 44px 22px 24px; }

/* 列表页/法律页的独立 H1 */
.page-h1 { padding: 40px 22px 0; text-align: center; }
.page-h1 h1 { font-size: clamp(26px, 3.6vw, 36px); margin: 0; letter-spacing: -.02em; }
.sec-head { max-width: 720px; }
.sec-head h2 { margin: 8px 0 10px; }
.sec-head p { color: var(--ink-dim); }
.sec { margin-bottom: 40px; }
.sec + .sec { margin-top: 56px; }

/* 这是什么 / 怎么玩 / 技巧 — 正文段落 */
.prose { color: var(--ink); }
.prose p { color: var(--ink-dim); font-size: 14px; line-height: 1.75; max-width: 720px; }
.prose ul { margin: 0 0 14px 22px; color: var(--ink-dim); font-size: 14px; line-height: 1.75; }
.prose li + li { margin-top: 4px; }
.prose strong { color: var(--ink); }
.prose code {
  font-family: var(--mono); font-size: 12px; padding: 1px 6px;
  border-radius: 4px; background: var(--bg-2); color: var(--amber);
}

/* 键盘/鼠标/触屏 三段说明 */
.howto-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); margin-top: 16px; }
.howto {
  padding: 18px; border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: rgba(255,255,255,0.02);
}
.howto h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.howto h3 .kbd { font-family: var(--mono); font-size: 10px; color: var(--amber); letter-spacing: .1em; }
.howto p { font-size: 13px; color: var(--ink-dim); margin: 8px 0 0; }

/* ---------- 9. FAQ 折叠 ---------- */
.faq { margin-top: 24px; border-top: 1px solid var(--line-soft); }
.faq details { border-bottom: 1px solid var(--line-soft); }
.faq summary {
  list-style: none; cursor: pointer;
  padding: 16px 30px 16px 0; position: relative;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+'; position: absolute; right: 4px; top: 50%;
  transform: translateY(-50%);
  color: var(--amber); font-size: 18px; font-weight: 400;
}
.faq details[open] summary::after { content: '−'; }
.faq p { margin: 0 0 18px; max-width: 720px; color: var(--ink-dim); font-size: 13px; line-height: 1.75; }

/* ---------- 10. 评论区占位 ---------- */
.comments { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line-soft); }
.comments h2 { margin-bottom: 14px; }
.comments-form { display: grid; gap: 10px; margin-bottom: 22px; }
.comments-form textarea {
  min-height: 80px; padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg-1); color: var(--ink);
  resize: vertical; font-size: 13px; line-height: 1.6;
}
.comments-form textarea:focus { outline: none; border-color: var(--amber); }
.comments-form button {
  justify-self: start; height: 38px; padding: 0 18px; border-radius: var(--r-pill);
  background: var(--amber); color: var(--bg-0); font-weight: 700; font-size: 12px;
  border: 1px solid #F3A64B; box-shadow: 0 3px 0 var(--amber-deep);
  transition: transform var(--t-fast);
}
.comments-form button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--amber-deep); }
.comments-empty {
  padding: 20px; text-align: center; color: var(--ink-mute);
  font-size: 13px; border: 1px dashed var(--line); border-radius: var(--r-lg);
}
.comments-list { display: grid; gap: 14px; }
.comment { padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: rgba(255,255,255,0.02); }
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.comment-author { font-weight: 700; font-size: 13px; color: var(--ink); }
.comment-time { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.comment-body { font-size: 13px; color: var(--ink-dim); }

/* ---------- 11. 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 28px 22px 40px; margin-top: 40px;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.footer-brand b { font-weight: 800; }
.footer-brand small { color: var(--ink-dim); font-size: 11px; opacity: .7; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { font-size: 12px; color: var(--ink-dim); transition: color var(--t-med); }
.footer-links a:hover { color: var(--ink); }

/* ---------- 12. 响应式 ---------- */
/* 手机 <640 */
@media (max-width: 640px) {
  :root { --topbar: 54px; }
  .nav { padding: 0 14px; gap: 8px; }
  .nav-brand img { height: 32px; }
  .nav-links {
    position: absolute; top: var(--topbar); left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 10px;
    background: rgba(24,20,17,0.98); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line-soft);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform var(--t-med), opacity var(--t-med);
  }
  .nav-links a { padding: 10px 14px; border-radius: var(--r-sm); }
  .nav-lang { padding: 10px 14px; margin-top: 4px; text-align: left; border-radius: var(--r-sm); }
  .nav-burger { display: inline-flex; }
  .nav-toggle:checked + .nav-burger + .nav-links {
    transform: translateY(0); opacity: 1; pointer-events: auto;
  }

  .game-wrap { padding: 20px 12px 14px; }
  .game-stage { height: 56vh; min-height: 320px; border-radius: 14px; }
  .game-cover .cover-mark { font-size: 64px; }
  .game-cover .cover-title { font-size: 18px; }

  .site { padding: 32px 16px 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .howto-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* 平板 640–1024 */
@media (min-width: 640px) and (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 横屏手机（矮屏） */
@media (max-height: 560px) and (min-width: 641px) {
  .game-stage { max-height: calc(100vh - 180px); }
  .game-head { margin-bottom: 10px; }
  .game-wrap { padding: 18px 16px 10px; }
}

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

/* 暗色（游戏硬编码暗底，仅保留监听位；亮方案暂不做） */
@media (prefers-color-scheme: light) {
  /* 亮方案预留，暂不切换——游戏本体硬编码暗底，外框切亮会打架 */
}
