/* ═════════════════════════════════════════
   Galgame · 文学阅读器风格
   简约、聚焦文字、温暖克制
   ═════════════════════════════════════════ */

:root {
  --bg: #e8e4dd;
  --bg-card: #dedad3;
  --bg-hover: #d5d0c9;
  --text: #000;
  --text-muted: #5c554b;
  --text-dim: #8a8176;
  --accent: #8b6f47;
  --accent-dim: #a0875b;
  --border: #c8c3ba;
  --overlay-bg: rgba(232,228,221,0.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
button, a { outline: none; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* ─── 创建页 ─── */
h2 {
  font-family: "Noto Serif SC", "STSong", serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  margin: 24px 0 16px;
  letter-spacing: 0.04em;
}
label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 14px 0 4px;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.02em;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #f0ede6;
  color: var(--text);
  font-size: 15px;
  font-family: system-ui, -apple-system, sans-serif;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  padding: 4px 0;
}
.attr-row .emoji { width: 28px; text-align: center; font-size: 17px; }
.attr-row .label { width: 32px; font-size: 13px; color: var(--text-muted); font-family: system-ui, -apple-system, sans-serif; }
.attr-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 40px;               /* 触控区撑大到40px（视觉轨道单独渲染4px），避免移动端误触/弹键盘 */
  background: transparent;
  border: none;
  padding: 0;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.attr-row input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.attr-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  margin-top: -10px;           /* 让thumb中心对齐4px轨道中心 */
}
.attr-row input[type=range]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.attr-row input[type=range]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.attr-row .val { width: 24px; text-align: right; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.free-points {
  text-align: right;
  font-size: 13px;
  color: var(--accent);
  margin: 8px 0;
  font-family: system-ui, -apple-system, sans-serif;
}

.btn {
  display: inline-block;
  padding: 10px 28px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-size: 15px;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 500;
  cursor: pointer;
  margin-top: 16px;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── 场景信息栏 ─── */
.scene-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 0 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.03em;
}
.scene-bar span {
  padding: 2px 0;
}
.scene-bar span + span::before {
  content: "·";
  margin: 0 4px;
  color: var(--text-dim);
}
.scene-bar span:first-child + span::before { display: none; }
/* ─── 叙事 ─── */
.narrative {
  font-size: 17px;
  line-height: 1.9;
  white-space: pre-wrap;
  margin-bottom: 32px;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* ─── 面板卡片 ─── */
.panel-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  width: 100%;
}

.card {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 16px 18px;
  border: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.attr-list { display: flex; flex-wrap: wrap; gap: 5px 12px; }
.attr-item {
  font-size: 13px;
  padding: 1px 0;
  color: var(--text-muted);
  font-family: system-ui, -apple-system, sans-serif;
}

.tags {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
}
/* ─── 选项按钮 ─── */
.option-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  font-family: "Noto Serif SC", "STSong", Georgia, serif;
  letter-spacing: 0.02em;
  transition: all 0.2s;
  line-height: 1.6;
}
.option-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent-dim);
}
.option-btn:active {
  background: var(--bg-hover);
}
.option-btn .eff {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
}
/* ─── 自由输入 ─── */
.option-free {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.option-free input {
  flex: 1;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
  font-family: system-ui, -apple-system, sans-serif;
  height: 40px;
  box-sizing: border-box;
}
.option-free .btn {
  height: 40px;
  margin-top: 0;
  padding: 0 18px;
  line-height: 40px;
}

/* ─── 加载动画 ─── */
.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 15px;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.04em;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.loading::after {
  content: "";
  animation: pulse 1.5s ease-in-out infinite;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 100;
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ─── 滚动区域（手机适配）─── */
@media (max-width: 480px) {
  #app { padding: 16px 14px 32px; }
  .narrative { font-size: 16px; line-height: 1.8; }
  .option-btn { padding: 12px 14px; font-size: 15px; }
}

/* ─── 道具抽屉面板 ─── */
.inv-panel {
  position: fixed; top: 0; left: 0;
  width: 320px; max-width: 85vw; height: 100dvh;
  background: var(--bg);
  z-index: 60;
  box-shadow: 2px 0 24px rgba(0,0,0,0.12);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 20px;
}
.inv-panel.open { transform: translateX(0); }
.inv-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 55;
  pointer-events: none; opacity: 0;
  transition: opacity 0.2s;
}
.inv-backdrop.show { pointer-events: auto; opacity: 1; }

.inv-section { margin-bottom: 20px; }
.inv-section h3 {
  font-size: 14px; color: var(--accent);
  margin-bottom: 8px; font-family: system-ui, sans-serif;
  font-weight: 500; letter-spacing: 0.03em;
}
.inv-slot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 4px;
  background: var(--bg-card); border: 1px solid var(--border);
  margin-bottom: 4px; font-size: 13px;
}
.inv-slot .name { color: var(--text); flex: 1; }
.inv-slot .eff { color: var(--accent); font-size: 12px; margin-left: 8px; }
.inv-slot .act {
  font-size: 11px; padding: 3px 8px; border-radius: 3px;
  border: 1px solid var(--accent); color: var(--accent);
  background: transparent; cursor: pointer; margin-left: 8px;
  font-family: system-ui, sans-serif;
}
.inv-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.inv-item .info { flex: 1; }
.inv-item .name { color: var(--text); font-size: 13px; }
.inv-item .meta { color: var(--text-muted); font-size: 11px; }
.inv-item .act {
  font-size: 11px; padding: 2px 8px; border-radius: 3px;
  border: 1px solid var(--accent); color: var(--accent);
  background: transparent; cursor: pointer; font-family: system-ui, sans-serif;
}
.inv-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--bg-card);
  font-size: 18px; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
