/* ==========================================================================
   《黑森林童话书（内测版）v2.0》 — 场景油画融合黑框终端 + 厚涂收藏卡样式
   ========================================================================== */

:root {
  --bg: #0f0f12;
  --box: #17171c;
  --box-hi: #212129;
  --edge: rgba(235, 229, 216, 0.13);
  --edge-soft: rgba(235, 229, 216, 0.07);
  --ink: #ece6d9;
  --ink-soft: #cfcabf;
  --ink-mute: rgba(235, 229, 216, 0.50);
  --cyan: #7bc7b8;
  --cyan-bg: rgba(123, 199, 184, 0.11);
  --gold: #dbb46c;
  --gold-bg: rgba(219, 180, 108, 0.11);
  --red: #df6b5e;
  --red-bg: rgba(223, 107, 94, 0.12);
  --purple: #b594e2;
  --purple-bg: rgba(181, 148, 226, 0.12);
  --font: "LXGW WenKai Screen", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif SC", sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.74;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ==================== 渐进式单行顶栏 ==================== */
.top-hud {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: 610px;
  margin: 0 auto;
  padding: 9px 12px 7px;
  background: linear-gradient(180deg, var(--bg) 84%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  min-height: 42px;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-pill {
  appearance: none;
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--box);
  border: 1px solid var(--edge-soft);
  color: var(--ink-soft);
  white-space: nowrap;
}
button.hud-pill {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
button.hud-pill:hover {
  border-color: var(--edge);
  background: var(--box-hi);
}
.life-pill strong { color: var(--red); font-weight: 600; }
.ap-pill strong { color: var(--cyan); font-weight: 600; }
.ap-pill.ap-low strong { color: var(--red); }
.day-pill { color: var(--gold); }
.day-pill.phase-night { color: var(--cyan); border-color: rgba(123, 199, 184, 0.28); }
.day-pill.phase-dusk { color: #e29d65; }

.hud-btn {
  appearance: none;
  border: 1px solid var(--edge);
  background: var(--box);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hud-btn:hover {
  background: var(--box-hi);
  border-color: var(--gold);
}
.hud-btn-ghost {
  color: var(--ink-soft);
  border-color: var(--edge-soft);
  padding: 4px 7px;
}
.hud-btn.bgm-muted {
  color: var(--ink-mute);
  opacity: 0.65;
}

/* ==================== 核心黑框终端 + 顶部场景油画窗 ==================== */
.game-shell {
  max-width: 610px;
  margin: 0 auto;
  padding: 4px 12px 44px;
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.terminal-box {
  background: var(--box);
  border: 1px solid var(--edge);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}

.scene-banner {
  position: relative;
  width: 100%;
  height: 168px;
  background: #101014;
  overflow: hidden;
}

.scene-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  display: block;
  filter: saturate(0.92) contrast(1.04) brightness(0.86);
  transition: opacity 0.36s ease;
}

.scene-banner-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(16, 16, 20, 0.18) 0%,
    rgba(23, 23, 28, 0.36) 58%,
    var(--box) 100%
  );
  pointer-events: none;
}

.scene-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 6px;
  font-size: 0.76rem;
  color: rgba(236, 230, 217, 0.78);
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.terminal-body {
  padding: 12px 18px 17px;
}

.log-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 82px;
}

.log-line {
  font-size: 1.0rem;
  line-height: 1.76;
  color: var(--ink);
  opacity: 0;
  transform: translateY(3px);
  animation: linePop 0.18s ease forwards;
}

.log-line.line-death {
  color: var(--red);
  background: var(--red-bg);
  border-left: 2.5px solid var(--red);
  padding: 7px 11px;
  border-radius: 0 4px 4px 0;
  font-weight: 600;
}

.log-line.line-gain {
  color: var(--gold);
  background: var(--gold-bg);
  border-left: 2.5px solid var(--gold);
  padding: 7px 11px;
  border-radius: 0 4px 4px 0;
}

.log-line.line-rewind,
.log-line.line-exploit {
  color: var(--cyan);
  background: var(--cyan-bg);
  border-left: 2.5px solid var(--cyan);
  padding: 7px 11px;
  border-radius: 0 4px 4px 0;
}

.log-line.line-whisper {
  color: var(--purple);
  background: var(--purple-bg);
  border-left: 2.5px solid var(--purple);
  padding: 7px 11px;
  border-radius: 0 4px 4px 0;
}

.log-line.line-mute {
  color: var(--ink-mute);
  font-size: 0.91rem;
}

/* 正文内可点击交互词条（0行动力消耗） */
.term-link {
  color: var(--gold);
  border-bottom: 1px dashed rgba(219, 180, 108, 0.6);
  cursor: pointer;
  padding: 0 1px;
  transition: color 0.15s ease, background 0.15s ease;
}
.term-link:hover {
  background: var(--gold-bg);
  color: #f5d693;
}

/* 商店/酒馆话题标签 */
.memory-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.memory-chip {
  appearance: none;
  background: var(--box-hi);
  border: 1px solid var(--edge);
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 0.79rem;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
}
.memory-chip:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* 按需弹出的场景输入框 */
.context-input-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--edge);
}

.context-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 8px 11px;
}
.context-input:focus {
  outline: none;
  border-color: var(--cyan);
}

/* 动词选项按钮组 */
.choices-row {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--edge-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-pill {
  appearance: none;
  background: var(--box-hi);
  border: 1px solid var(--edge);
  border-radius: 5px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.94rem;
  line-height: 1.42;
  padding: 8px 13px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
  text-align: left;
}
.choice-pill:hover:not(:disabled) {
  background: #2b2b35;
  border-color: var(--gold);
}
.choice-pill:active:not(:disabled) {
  transform: scale(0.98);
}
.choice-pill:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}
.choice-pill.pill-full {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.choice-pill.pill-danger {
  border-color: rgba(223, 107, 94, 0.45);
}
.choice-pill.pill-exploit {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(123, 199, 184, 0.08);
}
.choice-pill.pill-ad {
  border-color: rgba(181, 148, 226, 0.5);
  color: var(--purple);
  background: var(--purple-bg);
}
.choice-pill.pill-gold {
  border-color: rgba(219, 180, 108, 0.55);
  color: var(--gold);
}
.pill-cost {
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-left: 6px;
}

/* ==================== 裂纹怀表回溯栏 ==================== */
.watch-bar {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.watch-left-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.watch-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(123, 199, 184, 0.11);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease, transform 0.1s ease;
}
.watch-btn:hover:not(:disabled) {
  background: rgba(123, 199, 184, 0.22);
}
.watch-btn:disabled {
  opacity: 0.36;
  border-color: var(--edge);
  color: var(--ink-mute);
  background: transparent;
  cursor: not-allowed;
}

.watch-wind-btn {
  appearance: none;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px dashed rgba(181, 148, 226, 0.55);
  background: var(--purple-bg);
  color: var(--purple);
  font-family: var(--font);
  font-size: 0.76rem;
  cursor: pointer;
}

.watch-ico {
  width: 15px;
  height: 15px;
}

.skin-quick-tag {
  appearance: none;
  background: var(--box);
  border: 1px solid var(--edge-soft);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: var(--font);
  font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.skin-quick-tag:hover {
  border-color: var(--gold);
}
.skin-quick-tag span {
  color: var(--gold);
  font-weight: 600;
}

/* ==================== 轻量弹窗面板 ==================== */
.sheet-backdrop,
.card-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 8, 0.78);
  backdrop-filter: blur(3px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.sheet-box {
  width: 100%;
  max-width: 510px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--box);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 16px 16px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.70);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--edge-soft);
}
.sheet-title {
  font-size: 1.0rem;
  font-weight: 600;
  color: var(--gold);
}

.tab-row {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}
.tab-btn {
  flex: 1;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: 0.79rem;
  padding: 6px 6px;
  cursor: pointer;
}
.tab-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-bg);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 8px 0 14px;
}
.stat-cell {
  background: var(--bg);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.stat-cell strong {
  color: var(--ink);
  float: right;
}

.list-section-title {
  font-size: 0.79rem;
  color: var(--ink-mute);
  margin: 12px 0 6px;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mini-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--edge-soft);
  border-radius: 4px;
  font-size: 0.84rem;
}
.mini-item.equipped {
  border-color: var(--gold);
  background: var(--gold-bg);
}
.mini-item-name {
  color: var(--ink);
  font-weight: 600;
}
.mini-item-sub {
  font-size: 0.75rem;
  color: var(--ink-mute);
  margin-top: 2px;
  line-height: 1.45;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.map-cell {
  appearance: none;
  font-family: var(--font);
  padding: 10px 9px;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 5px;
  text-align: left;
  font-size: 0.83rem;
  color: var(--ink);
  cursor: pointer;
}
.map-cell:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--box-hi);
}
.map-cell.current {
  border-color: var(--cyan);
  color: var(--cyan);
}
.map-cell:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.map-cell-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-mute);
  margin-top: 2px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.gallery-card {
  background: var(--bg);
  border: 1px solid var(--edge-soft);
  border-radius: 6px;
  padding: 6px;
  text-align: center;
  cursor: pointer;
}
.gallery-card.locked {
  opacity: 0.4;
  cursor: default;
}
.gallery-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 4px;
}
.gallery-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: #141418;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.gallery-card-name {
  font-size: 0.75rem;
  color: var(--ink);
}

/* ==================== 收藏卡与激励弹窗 ==================== */
.card-popup-backdrop { z-index: 120; }
.card-popup-box {
  width: 290px;
  background: #161519;
  border: 1px solid rgba(219, 180, 108, 0.48);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.85);
  animation: cardReveal 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.collector-img-frame {
  width: 212px;
  height: 212px;
  margin: 4px auto 11px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(219, 180, 108, 0.36);
  background: #0d0d0f;
}
.collector-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.collector-badge {
  display: inline-block;
  font-size: 0.71rem;
  color: var(--gold);
  background: var(--gold-bg);
  padding: 2px 9px;
  border-radius: 99px;
  margin-bottom: 4px;
}
.collector-title { font-size: 1.03rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.collector-desc {
  font-size: 0.81rem;
  color: var(--ink-soft);
  line-height: 1.56;
  text-align: left;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.035);
  border-radius: 4px;
  margin-bottom: 11px;
}

.ad-backdrop { z-index: 140; }
.ad-box {
  width: 100%;
  max-width: 340px;
  background: #15141a;
  border: 1px solid rgba(181, 148, 226, 0.48);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}
.ad-timer-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--purple);
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin: 12px auto;
  background: var(--purple-bg);
}

.rewind-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  background: radial-gradient(circle, rgba(123, 199, 184, 0.30) 0%, transparent 72%);
  animation: flashFade 0.38s ease-out forwards;
}

@keyframes linePop { to { opacity: 1; transform: translateY(0); } }
@keyframes cardReveal {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes flashFade { 0% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 520px) {
  .top-hud { padding: 7px 9px 5px; }
  .hud-pill { font-size: 0.72rem; padding: 3px 6px; }
  .hud-btn { font-size: 0.73rem; padding: 3px 7px; }
  .game-shell { padding: 4px 9px 36px; }
  .scene-banner { height: 132px; }
  .scene-caption { left: 12px; right: 12px; font-size: 0.72rem; }
  .terminal-body { padding: 10px 13px 14px; }
  .log-line { font-size: 0.96rem; line-height: 1.72; }
  .choice-pill { font-size: 0.90rem; padding: 8px 11px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
