/* 画布 1920×1080，整体等比缩放。字体只用 OFL / 免费商用的（方正汉仪雅黑一律禁用） */
:root {
  --w: 1920px;
  --h: 1080px;
  --ink: #f2ece4;
  --box: rgba(14, 16, 22, .78);
  --accent: #d8b26a;
  --font: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", sans-serif;
  --font-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #05060a;
  overflow: hidden;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 居中不能靠 inset:0 + margin:auto —— 画布 1920 宽比窗口大的时候，CSS 会按
   "过约束"规则把 margin-left/top 强行归零（等分会得到负值），画布左上角被顶到窗口
   左上角，再以画布自己的中心缩放，结果整体偏出去。改成 50% 定位 + translate 自身一半，
   这个写法跟画布比窗口大不大无关。 */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  width: var(--w);
  height: var(--h);
  transform-origin: center;
  overflow: hidden;
  background: #05060a;
}

.layer { position: absolute; inset: 0; }

/* ── 背景 ───────────────────────────────────────────── */

#bg > div {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity .55s ease;
}
#bg > div.on { opacity: 1; }

/* 时段变体全部用滤镜做，不另外出图（省一半背景预算） */
#bg.t-晴    { filter: none; }
#bg.t-黄昏  { filter: sepia(.28) saturate(1.25) hue-rotate(-12deg) brightness(.94); }
#bg.t-夜    { filter: saturate(.62) brightness(.5) hue-rotate(198deg) contrast(1.08); }
#bg.t-雨    { filter: saturate(.72) brightness(.82) contrast(.94); }
#bg { transition: filter .6s ease; }

/* ── 立绘 ───────────────────────────────────────────── */

#sprites .sp {
  position: absolute;
  bottom: 0;
  height: 96%;
  aspect-ratio: 896 / 1216;
  background-size: contain;
  background-position: bottom center;
  background-repeat: no-repeat;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .35s ease, transform .35s ease, filter .3s ease;
}
#sprites .sp.on { opacity: 1; transform: none; }
/* 非说话者压暗，这是最省成本的"谁在说话"提示 */
#sprites .sp.dim { filter: brightness(.62) saturate(.85); }
/* 说话者微微前倾放大。差分不够多的时候，靠这点动静撑住画面 */
#sprites .sp.on.talk { transform: translateY(-10px) scale(1.015); }

/* ── CG ─────────────────────────────────────────────── */

#cg {
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity .7s ease;
  pointer-events: none;
}
#cg.on { opacity: 1; }

#flash {
  position: absolute; inset: 0; background: #000;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
#flash.on { opacity: 1; }

/* ── 对话框 ─────────────────────────────────────────── */

#textbox {
  position: absolute;
  left: 90px; right: 90px; bottom: 54px;
  min-height: 250px;
  padding: 34px 44px 40px;
  background: var(--box);
  backdrop-filter: blur(7px);
  border: 1px solid rgba(216, 178, 106, .22);
  border-radius: 8px;
  box-shadow: 0 10px 44px rgba(0, 0, 0, .5);
}
#textbox.hidden { display: none; }

#namebox {
  position: absolute;
  top: -22px; left: 30px;
  padding: 7px 26px;
  background: linear-gradient(180deg, #2b2f3d, #191c26);
  border: 1px solid rgba(216, 178, 106, .4);
  border-radius: 5px;
  color: var(--accent);
  font-size: 27px;
  letter-spacing: 2px;
}
#namebox:empty { display: none; }

#text {
  font-size: 33px;
  line-height: 1.78;
  color: var(--ink);
  min-height: 120px;
  white-space: pre-wrap;
}
/* 男主心声：衬线 + 偏灰，和说出口的话在视觉上分开 */
#text.inner { font-family: var(--font-serif); color: #b9c2cf; font-style: italic; }
#text.narr  { color: #ddd6cb; }

#next {
  position: absolute; right: 34px; bottom: 14px;
  color: var(--accent); font-size: 24px;
  animation: bob 1.1s ease-in-out infinite;
  opacity: 0;
}
#next.on { opacity: .85; }
@keyframes bob { 50% { transform: translateY(6px); opacity: .35; } }

/* ── 选项 ───────────────────────────────────────────── */

#choices {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  background: rgba(6, 8, 14, .5);
}
#choices.on { display: flex; }
#choices button {
  width: 940px; padding: 26px;
  font-family: var(--font); font-size: 31px; color: var(--ink);
  background: rgba(22, 26, 36, .9);
  border: 1px solid rgba(216, 178, 106, .35);
  border-radius: 6px; cursor: pointer;
  transition: .18s;
}
#choices button:hover {
  background: rgba(48, 42, 30, .95);
  border-color: var(--accent);
  transform: translateX(8px);
}

/* ── 工具栏 ─────────────────────────────────────────── */

#toolbar {
  position: absolute; top: 22px; right: 26px;
  display: flex; gap: 10px;
}
#toolbar button, .title-menu button, #panel button {
  font-family: var(--font); font-size: 21px; color: #cfd6e0;
  padding: 9px 20px;
  background: rgba(14, 17, 24, .72);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 4px; cursor: pointer; transition: .16s;
}
#toolbar button:hover, .title-menu button:hover, #panel button:hover {
  color: #fff; border-color: var(--accent); background: rgba(40, 36, 26, .9);
}
#toolbar button.active { color: #1a1a1a; background: var(--accent); border-color: var(--accent); }

/* ── 成就 ───────────────────────────────────────────── */

#achievement {
  position: absolute; top: 90px; left: 50%;
  transform: translate(-50%, -180%);
  display: flex; align-items: center; gap: 20px;
  padding: 22px 42px 22px 30px;
  background: linear-gradient(135deg, rgba(48, 40, 22, .97), rgba(20, 20, 26, .97));
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 12px 46px rgba(0, 0, 0, .6);
  transition: transform .34s cubic-bezier(.2, 1.5, .4, 1);
  z-index: 40;
}
#achievement.on { transform: translate(-50%, 0); }
.ach-icon { font-size: 46px; }
.ach-label { font-size: 19px; color: var(--accent); letter-spacing: 4px; }
.ach-name { font-size: 32px; color: #fff; margin-top: 4px; }

/* ── 面板 ───────────────────────────────────────────── */

#panel {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 5, 9, .8);
}
#panel.hidden { display: none; }
.panel-inner {
  width: 1280px; max-height: 84%;
  display: flex; flex-direction: column;
  background: rgba(16, 18, 26, .97);
  border: 1px solid rgba(216, 178, 106, .3);
  border-radius: 8px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px; border-bottom: 1px solid rgba(255, 255, 255, .1);
  color: var(--accent); font-size: 28px; letter-spacing: 3px;
}
#panel-close {
  background: none; border: none; color: #8b93a1;
  font-size: 27px; cursor: pointer;
}
#panel-body { padding: 26px 28px; overflow-y: auto; color: var(--ink); font-size: 23px; }

/* 存读档格子 */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.slot {
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 6px;
  overflow: hidden; cursor: pointer; background: rgba(0, 0, 0, .3);
  transition: .16s;
}
.slot:hover { border-color: var(--accent); }
.slot .thumb {
  height: 150px; background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #4c5361; font-size: 20px;
}
.slot .meta { padding: 12px 14px; font-size: 19px; line-height: 1.5; }
.slot .meta .when { color: #7d8695; font-size: 16px; }

/* 回想 */
.log-line { margin-bottom: 20px; line-height: 1.7; }
.log-line b { color: var(--accent); margin-right: 12px; }
.log-line.inner { color: #98a3b3; font-family: var(--font-serif); font-style: italic; }

/* 设置 */
.cfg-row { display: flex; align-items: center; gap: 20px; margin-bottom: 26px; }
.cfg-row label { width: 210px; color: #b3bbc7; }
.cfg-row input[type=range] { flex: 1; accent-color: var(--accent); }
.cfg-row .val { width: 80px; text-align: right; color: var(--accent); }

/* ── 标题画面 ───────────────────────────────────────── */

#title-screen {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 26px;
  background: radial-gradient(ellipse at 50% 40%, #1c2030, #05060a 72%);
  transition: opacity .5s;
}
#title-screen.hidden { opacity: 0; pointer-events: none; }
.title-main {
  font-family: var(--font-serif); font-size: 92px; color: #f4eee5;
  letter-spacing: 16px; text-shadow: 0 6px 40px rgba(216, 178, 106, .3);
}
.title-sub { font-size: 25px; color: #8c95a4; letter-spacing: 5px; }
.title-menu { display: flex; gap: 18px; margin-top: 30px; }
.title-menu button { font-size: 26px; padding: 14px 44px; }
.title-note {
  position: absolute; bottom: 40px;
  font-size: 18px; color: #4e5563; letter-spacing: 1px;
}

/* 缺图占位：不是报错，是能看的色块 + 标签 */
.ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: rgba(255, 255, 255, .5);
  letter-spacing: 4px; text-align: center;
}
.ph.sp-ph {
  border-radius: 12px 12px 0 0;
  border: 2px dashed rgba(255, 255, 255, .2);
  border-bottom: none;
  writing-mode: vertical-rl;
  font-size: 40px;
}
