/* ============================================================
   校园失踪案 · 全局样式与设计规范
   视觉方向：写实暗调悬疑 / 深夜档案室氛围
   ============================================================ */

/* ---------- 设计 Tokens ---------- */
:root {
  /* 色彩：暗调悬疑 */
  --c-ink:        #0e1116;   /* 页面底色：深夜墨蓝 */
  --c-panel:      #161b24;   /* 面板 */
  --c-panel-2:    #1d2431;   /* 浮层 */
  --c-line:       #2a3242;   /* 描边 */
  --c-text:       #e8e4d9;   /* 正文：纸白 */
  --c-muted:      #9aa3b2;   /* 次要文字 */
  --c-accent:     #e8b34b;   /* 强调：档案灯琥珀 */
  --c-clue:       #5fb3a1;   /* 线索：青绿 */
  --c-danger:     #d96c5f;   /* 危险/反转 */
  --c-focus:      #7fb4e8;   /* 焦点环 */
  --c-shadow:     rgba(0,0,0,.55);

  /* 字体：衬线叙事 + 无衬线界面 */
  --font-display: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-ui:      "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "JetBrains Mono", "Consolas", monospace;

  /* 字号阶梯 */
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px;
  --fs-lg: 20px; --fs-xl: 28px; --fs-2xl: 40px;

  /* 间距阶梯 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* 圆角与阴影 */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow-card: 0 10px 30px var(--c-shadow);
  --shadow-fab:  0 4px 14px rgba(0,0,0,.45);

  /* 动效 */
  --ease: cubic-bezier(.22,.61,.36,1);
  --t-fast: .18s; --t-mid: .35s; --t-slow: .6s;
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  color: var(--c-text);
  background: var(--c-ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
/* hidden 属性兜底：避免组件样式中的 display 覆盖浏览器默认的 display:none */
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}
::selection { background: rgba(232,179,75,.35); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--c-line);
  background: var(--c-panel-2);
  color: var(--c-text);
  padding: 10px 22px;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { background: #263042; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #e8b34b, #c98a2e);
  border-color: #b07a24;
  color: #241a05;
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(135deg, #f2c46a, #d6993a); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 14px; font-size: var(--fs-sm); }
.icon-btn {
  background: transparent; border: none; color: var(--c-muted);
  font-size: var(--fs-lg); line-height: 1; padding: 4px 8px; border-radius: var(--r-sm);
}
.icon-btn:hover { color: var(--c-text); background: rgba(255,255,255,.06); }

/* ---------- 加载屏 ---------- */
.loading-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(232,179,75,.1), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(95,179,161,.08), transparent 50%),
    var(--c-ink);
  transition: opacity var(--t-slow) var(--ease);
}
.loading-screen.done { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; max-width: 480px; padding: var(--sp-6); }
.loading-sub {
  letter-spacing: .5em; color: var(--c-accent); font-size: var(--fs-sm);
  text-transform: uppercase; margin-bottom: var(--sp-5);
  animation: pulseText 2.4s ease-in-out infinite;
}
.loading-title {
  font-family: var(--font-display); font-size: clamp(30px, 6vw, 52px);
  font-weight: 900; letter-spacing: .06em; color: var(--c-text);
  text-shadow: 0 2px 24px rgba(232,179,75,.25);
}
.loading-echo {
  display: block; font-size: .55em; color: var(--c-accent);
  letter-spacing: .35em; margin-top: var(--sp-2);
}
.loading-bar {
  width: 280px; height: 3px; margin: var(--sp-6) auto var(--sp-3);
  background: var(--c-panel-2); border-radius: 99px; overflow: hidden;
}
.loading-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--c-clue), var(--c-accent));
  border-radius: 99px;
  box-shadow: 0 0 12px rgba(232,179,75,.6);
  transition: width .35s var(--ease);
}
.loading-text {
  color: var(--c-muted); font-size: var(--fs-xs);
  letter-spacing: .25em; min-height: 1.6em;
}
@keyframes pulseText {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

/* ---------- 音乐开关按钮 ---------- */
.music-btn {
  background: rgba(22,27,36,.85);
  border: 1px solid var(--c-line); border-radius: 999px;
  color: var(--c-muted); font-size: var(--fs-md);
  width: 42px; height: 42px; display: grid; place-items: center;
  cursor: pointer; transition: border-color var(--t-fast), color var(--t-fast);
  box-shadow: var(--shadow-fab);
}
.music-btn:hover { border-color: var(--c-accent); color: var(--c-accent); }
.music-btn-corner { position: fixed; top: var(--sp-4); right: var(--sp-5); z-index: 110; }
.music-btn-fab {
  position: fixed; right: calc(var(--sp-5) + 110px); bottom: 76px; z-index: 40;
}

/* ---------- 标题画面 ---------- */
.title-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(232,179,75,.08), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(95,179,161,.06), transparent 50%),
    var(--c-ink);
  animation: fadeIn var(--t-slow) var(--ease);
}
.title-inner { max-width: 680px; text-align: center; padding: var(--sp-6); }
.title-sub {
  letter-spacing: .5em; color: var(--c-accent); font-size: var(--fs-sm);
  text-transform: uppercase; margin-bottom: var(--sp-4);
}
.title-main {
  font-family: var(--font-display);
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900; line-height: 1.15; letter-spacing: .06em;
  text-shadow: 0 2px 24px rgba(232,179,75,.25);
}
.title-echo {
  display: block; font-size: .55em; color: var(--c-accent);
  letter-spacing: .35em; margin-top: var(--sp-2);
}
.title-desc {
  margin: var(--sp-6) auto; color: var(--c-muted); line-height: 1.9; font-size: var(--fs-md);
}
.title-desc em { color: var(--c-text); font-style: normal; font-family: var(--font-display); }
.title-actions { display: flex; gap: var(--sp-4); justify-content: center; margin: var(--sp-5) 0; }
.title-tip { color: var(--c-muted); font-size: var(--fs-xs); opacity: .8; }

/* ---------- 游戏主布局 ---------- */
.game {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

/* HUD 顶栏 */
.hud-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  background: linear-gradient(180deg, rgba(14,17,22,.95), rgba(14,17,22,.75));
  border-bottom: 1px solid var(--c-line);
  z-index: 5;
}
.hud-day { display: flex; align-items: baseline; gap: var(--sp-3); }
.day-num {
  font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; color: var(--c-accent);
}
.day-date { color: var(--c-muted); font-size: var(--fs-sm); }
.hud-chapter {
  font-family: var(--font-display); font-size: var(--fs-md); letter-spacing: .15em; color: var(--c-text);
}
.hud-scene {
  padding: 4px 14px; border: 1px solid var(--c-line); border-radius: 999px;
  color: var(--c-clue); font-size: var(--fs-sm);
}

/* HUD 底栏 */
.hud-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  background: rgba(14,17,22,.92);
  border-top: 1px solid var(--c-line);
  z-index: 5;
}
.scene-nav { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.scene-nav button {
  background: transparent; border: 1px solid transparent; color: var(--c-muted);
  padding: 6px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.scene-nav button:hover { color: var(--c-text); }
.scene-nav button.active {
  color: var(--c-accent); border-color: rgba(232,179,75,.5);
  background: rgba(232,179,75,.08);
}
.inventory-bar { display: flex; gap: var(--sp-2); align-items: center; min-height: 48px; }
.inv-item {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--c-panel-2); border: 1px solid var(--c-line); border-radius: var(--r-sm);
  font-size: 22px; cursor: help; position: relative;
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.inv-item:hover { transform: translateY(-3px); border-color: var(--c-accent); }
.inv-item .inv-tip {
  position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
  background: var(--c-panel-2); border: 1px solid var(--c-line); border-radius: var(--r-sm);
  padding: 6px 10px; font-size: var(--fs-xs); color: var(--c-text); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 20;
}
.inv-item:hover .inv-tip { opacity: 1; }

/* ---------- 帮助按钮（右下角常驻） ---------- */
.help-fab {
  position: fixed; right: var(--sp-5); bottom: 76px; z-index: 40;
  background: linear-gradient(135deg, #2a3242, #1d2431);
  border: 1px solid var(--c-accent); color: var(--c-accent);
  padding: 10px 18px; border-radius: 999px; font-size: var(--fs-sm);
  box-shadow: var(--shadow-fab);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.help-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(232,179,75,.3); }

/* ---------- 帮助面板 ---------- */
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(440px, 92vw);
  background: var(--c-panel);
  border-left: 1px solid var(--c-line);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
  animation: slideInRight var(--t-mid) var(--ease);
}
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-line);
}
.help-header h2 { font-family: var(--font-display); font-size: var(--fs-lg); letter-spacing: .1em; }
.help-tabs { display: flex; border-bottom: 1px solid var(--c-line); }
.help-tab {
  flex: 1; background: transparent; border: none; color: var(--c-muted);
  padding: var(--sp-3) 0; font-size: var(--fs-sm);
  border-bottom: 2px solid transparent; transition: color var(--t-fast), border-color var(--t-fast);
}
.help-tab.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }
.help-search { display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) 0; }
.help-search input {
  flex: 1; background: var(--c-ink); border: 1px solid var(--c-line); border-radius: var(--r-sm);
  color: var(--c-text); padding: 8px 12px; font-size: var(--fs-sm); font-family: inherit;
}
.help-search-result {
  margin: var(--sp-2) var(--sp-5) 0; padding: var(--sp-3);
  background: rgba(95,179,161,.08); border: 1px solid rgba(95,179,161,.35);
  border-radius: var(--r-sm); font-size: var(--fs-sm); line-height: 1.7; color: var(--c-text);
}
.help-body { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-5); }
.help-body h3 { font-family: var(--font-display); margin-bottom: var(--sp-3); color: var(--c-accent); }
.task-list { list-style: none; }
.task-list li {
  padding: 8px 0 8px 22px; position: relative; color: var(--c-muted);
  border-bottom: 1px dashed var(--c-line); font-size: var(--fs-sm); line-height: 1.6;
}
.task-list li::before { content: "▸"; position: absolute; left: 4px; color: var(--c-accent); }
.task-list li.done { color: #5c6675; text-decoration: line-through; }
.task-list li.done::before { content: "✓"; color: var(--c-clue); }
.hint-tier { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--c-line); }
.hint-tier-label { color: var(--c-muted); font-size: var(--fs-xs); margin-bottom: var(--sp-2); }
.hint-tier .hint-btn { margin-right: var(--sp-2); }
.hint-btn.revealed { border-color: var(--c-clue); color: var(--c-clue); }
.hint-output {
  margin-top: var(--sp-3); font-size: var(--fs-sm); line-height: 1.8;
  color: var(--c-clue); min-height: 1.8em;
}

/* 线索板 */
.clue-board { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.clue-group-title {
  grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--c-accent);
  letter-spacing: .2em; margin-top: var(--sp-2);
}
.clue-card {
  background: var(--c-panel-2); border: 1px solid var(--c-line); border-radius: var(--r-sm);
  padding: var(--sp-3); font-size: var(--fs-xs); line-height: 1.6;
}
.clue-card b { display: block; color: var(--c-text); font-size: var(--fs-sm); margin-bottom: 4px; }
.clue-card span { color: var(--c-muted); }
.clue-empty { grid-column: 1 / -1; color: var(--c-muted); font-size: var(--fs-sm); padding: var(--sp-5); text-align: center; }

/* 人物关系图 */
.relation-graph { display: flex; flex-direction: column; gap: var(--sp-3); }
.relation-item {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--c-panel-2); border: 1px solid var(--c-line); border-radius: var(--r-sm);
  padding: var(--sp-3);
}
.relation-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--c-line); }
.relation-item .r-name { font-size: var(--fs-sm); font-weight: 700; }
.relation-item .r-role { font-size: var(--fs-xs); color: var(--c-muted); }
.relation-item .r-bar { flex: 1; height: 6px; background: var(--c-ink); border-radius: 99px; overflow: hidden; margin: 0 var(--sp-2); }
.relation-item .r-bar i { display: block; height: 100%; background: linear-gradient(90deg, #5fb3a1, #e8b34b); border-radius: 99px; transition: width var(--t-mid); }
.relation-item .r-num { font-size: var(--fs-xs); color: var(--c-muted); width: 28px; text-align: right; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%);
  background: rgba(22,27,36,.96); border: 1px solid var(--c-clue); color: var(--c-text);
  padding: 12px 24px; border-radius: var(--r-md); font-size: var(--fs-sm);
  box-shadow: var(--shadow-card); z-index: 60; max-width: 80vw;
  animation: toastIn var(--t-mid) var(--ease);
}
.toast.warn { border-color: var(--c-danger); }
.toast.gold { border-color: var(--c-accent); }

/* ---------- 章节过场 / 结局 ---------- */
.chapter-overlay, .ending-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.92); animation: fadeIn var(--t-slow) var(--ease);
}
.chapter-card, .ending-card {
  max-width: 620px; padding: var(--sp-7); text-align: center;
}
.chapter-day { color: var(--c-accent); letter-spacing: .4em; font-size: var(--fs-sm); }
.chapter-title {
  font-family: var(--font-display); font-size: var(--fs-xl); margin: var(--sp-4) 0;
  letter-spacing: .2em;
}
.chapter-summary { color: var(--c-muted); line-height: 2; margin-bottom: var(--sp-6); }
.ending-card h2 { font-family: var(--font-display); letter-spacing: .3em; color: var(--c-accent); margin-bottom: var(--sp-5); }
.ending-text p {
  color: var(--c-text); line-height: 2.2; font-family: var(--font-display);
  font-size: var(--fs-md); margin-bottom: var(--sp-3);
  opacity: 0; animation: fadeUp .8s var(--ease) forwards;
}
.ending-hook { color: var(--c-danger); margin: var(--sp-6) 0 var(--sp-4); font-size: var(--fs-sm); letter-spacing: .15em; }

/* ---------- 动画 ---------- */
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes toastIn  { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 平板 / 窄屏适配 (≤720px) ---------- */
@media (max-width: 720px) {
  .hud-chapter { display: none; }
  .hud-top { padding: var(--sp-2) var(--sp-3); }
  .hud-bottom { flex-direction: column; align-items: stretch; padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
  .scene-nav { justify-content: center; }
  .inventory-bar { justify-content: center; min-height: 40px; }
  .help-fab { bottom: 128px; right: var(--sp-3); font-size: var(--fs-xs); padding: 8px 14px; }
  .music-btn-fab { right: calc(var(--sp-3) + 90px); bottom: 128px; }
  .clue-board { grid-template-columns: 1fr; }
  .title-actions { flex-direction: column; align-items: center; }
  .title-desc { font-size: var(--fs-sm); }
  .title-desc br { display: none; }
  .loading-bar { width: min(280px, 70vw); }
  .chapter-card, .ending-card { padding: var(--sp-5); }
  .chapter-title { font-size: var(--fs-lg); }
  .help-panel { width: min(380px, 94vw); }
  .help-search { padding: var(--sp-3) var(--sp-3) 0; }
  .help-body { padding: var(--sp-4) var(--sp-3); }
  .help-header { padding: var(--sp-3) var(--sp-3); }
  .inv-item { width: 38px; height: 38px; font-size: 18px; }
}

/* ---------- 手机窄屏适配 (≤480px) ---------- */
@media (max-width: 480px) {
  /* 顶栏精简：只显示日期+场景名 */
  .hud-top { padding: var(--sp-1) var(--sp-2); }
  .day-num { font-size: var(--fs-md); }
  .day-date { font-size: var(--fs-xs); }
  .hud-scene { font-size: var(--fs-xs); padding: 3px 10px; }

  /* 底栏更紧凑 */
  .hud-bottom { padding: var(--sp-1) var(--sp-2); }
  .scene-nav button { padding: 4px 8px; font-size: var(--fs-xs); }
  .inventory-bar { min-height: 36px; gap: var(--sp-1); }
  .inv-item { width: 34px; height: 34px; font-size: 16px; }

  /* FAB按钮：右下角纵向排列，避免与底栏重叠 */
  .help-fab { bottom: 120px; right: var(--sp-2); padding: 6px 12px; font-size: 11px; }
  .music-btn-fab { right: var(--sp-2); bottom: 160px; width: 36px; height: 36px; font-size: var(--fs-sm); }
  .music-btn-corner { top: var(--sp-2); right: var(--sp-2); width: 36px; height: 36px; }

  /* 标题画面 */
  .title-inner { padding: var(--sp-4); }
  .title-sub { font-size: var(--fs-xs); letter-spacing: .3em; }
  .title-desc { font-size: var(--fs-sm); line-height: 1.7; margin: var(--sp-4) auto; }
  .title-tip { font-size: 11px; }
  .btn { padding: 10px 18px; font-size: var(--fs-sm); }

  /* 帮助面板全屏宽度 */
  .help-panel { width: 100vw; }
  .help-tab { font-size: var(--fs-xs); padding: var(--sp-2) 0; }

  /* 章节过场/结局 */
  .chapter-card, .ending-card { padding: var(--sp-4); }
  .chapter-title { font-size: var(--fs-md); letter-spacing: .1em; }
  .chapter-summary { font-size: var(--fs-sm); line-height: 1.8; }
  .ending-card h2 { font-size: var(--fs-lg); }
  .ending-text p { font-size: var(--fs-sm); }

  /* 线索板 & 人物关系 */
  .relation-item { flex-wrap: wrap; gap: var(--sp-2); }
  .relation-item .r-bar { flex-basis: 100%; margin: 0; }

  /* Toast */
  .toast { font-size: var(--fs-xs); padding: 10px 16px; max-width: 92vw; }
}
