/* ==========================================================================
   青春记事 · Galgame 样式表
   ========================================================================== */
:root {
  --bg-deep: #0d1117;
  --bg-panel: rgba(18, 22, 30, 0.92);
  --ink: #eceff4;
  --ink-dim: #aeb6c4;
  --accent: #6fb7ff;
  --accent-2: #9a7bff;
  --danger: #ff6b81;
  --box-text: #1d2430;
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", "Noto Sans SC", sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-deep);
  overflow: hidden;
}

/* ---------- 通用屏幕容器 ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 1;
}
.screen.active { opacity: 1; pointer-events: auto; z-index: 2; }

/* ---------- 启动画面 ---------- */
#boot-screen {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(111,183,255,.25), transparent 60%),
    radial-gradient(900px 500px at 80% 110%, rgba(154,123,255,.18), transparent 60%),
    linear-gradient(160deg,#0d1117,#121820 55%,#0a0e13);
}
.boot-title-wrap { position: relative; text-align: center; padding: 0 24px; }
.boot-title-glow {
  position: absolute; inset: -40px -80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(111,183,255,.35), transparent 70%);
  filter: blur(30px); z-index: 0; animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:1} }
#boot-title {
  position: relative; z-index: 1;
  font-size: clamp(44px, 9vw, 92px); font-weight: 800; letter-spacing: 0.12em;
  background: linear-gradient(120deg,#eaf3ff,#9ac8ff 55%,#c9a8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 8px 40px rgba(111,183,255,.25);
}
.boot-subtitle { margin-top: 14px; font-size: clamp(14px,2.4vw,20px); color: var(--ink-dim); letter-spacing: .3em; }
.boot-meta { margin-top: 10px; font-size: 13px; color: #6b7686; letter-spacing: .1em; }

.boot-actions {
  margin-top: 46px; display: flex; flex-direction: column; gap: 12px; width: min(300px, 78vw);
}
.boot-footer { position: absolute; bottom: 20px; font-size: 12px; color: #5a6472; letter-spacing: .08em; }

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit; font-size: 15px; letter-spacing: .18em;
  color: var(--ink); cursor: pointer; user-select: none;
  padding: 13px 22px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; transition: all .2s ease;
}
.btn-primary {
  background: linear-gradient(120deg,var(--accent),var(--accent-2));
  color: #0b1020; font-weight: 700; border: none;
  box-shadow: 0 10px 30px rgba(111,183,255,.30);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(111,183,255,.45); }
.btn-ghost { border-color: rgba(255,255,255,.14); color: var(--ink-dim); }
.btn-ghost:hover { border-color: rgba(255,255,255,.35); color: var(--ink); background: rgba(255,255,255,.04); }
.btn-danger { border-color: rgba(255,107,129,.4); color: var(--danger); }
.btn-danger:hover { background: rgba(255,107,129,.1); }

/* ---------- 章节选择 ---------- */
#chapter-screen, #save-screen { background: var(--bg-deep); align-items: stretch; justify-content: flex-start; }
.chapter-head {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 26px; border-bottom: 1px solid rgba(255,255,255,.08); width: 100%;
}
.chapter-head h2 { font-size: 20px; font-weight: 700; letter-spacing: .1em; }
.chapter-list, .save-list {
  flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 22px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
  align-content: start; overflow-y: auto;
}
.chapter-card {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; padding: 16px 18px; cursor: pointer; transition: all .2s ease;
}
.chapter-card:hover { transform: translateY(-3px); border-color: rgba(111,183,255,.5); background: rgba(111,183,255,.06); }
.chapter-card .num { font-size: 12px; color: var(--accent); letter-spacing: .2em; }
.chapter-card .title { margin-top: 8px; font-size: 17px; font-weight: 700; }
.chapter-card .desc { margin-top: 6px; font-size: 13px; color: var(--ink-dim); line-height: 1.5; }

.save-slot {
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: all .2s; min-height: 92px;
}
.save-slot:hover { border-color: rgba(154,123,255,.5); background: rgba(154,123,255,.06); }
.save-slot.empty { border-style: dashed; opacity: .55; display:flex; align-items:center; justify-content:center; color: var(--ink-dim); }
.save-slot .slot-no { font-size: 12px; color: var(--accent-2); letter-spacing: .15em; }
.save-slot .slot-info { margin-top: 8px; font-size: 13px; line-height: 1.5; }
.save-slot .slot-chap { color: var(--ink); font-weight: 600; }
.save-slot .slot-time { color: #6b7686; font-size: 12px; margin-top: 4px; }

/* ---------- 游戏主画面 ---------- */
#game-screen { background: #000; }
.stage { position: absolute; inset: 0; overflow: hidden; }
.bg-layer, .sprite-layer, .fx-layer { position: absolute; inset: 0; }
.bg-layer img, .bg-layer .bg-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sprite-layer { }
.sprite {
  position: absolute; bottom: 0; height: 88vh;
  transition: transform .5s ease, opacity .35s ease;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.45));
}
.sprite[data-pos="left"] { left: 7%; transform-origin: bottom center; }
.sprite[data-pos="center"] { left: 50%; transform: translateX(-50%); }
.sprite[data-pos="right"] { right: 7%; }
.sprite[data-pos="left"]{ transform: scale(1); }
.sprite.hidden { opacity: 0; }

/* 氛围流光 */
.fx-layer { pointer-events: none; }
.fx-snow, .fx-sakura { position: absolute; top: -10px; border-radius: 50%; opacity:.85; animation: fall linear infinite; }
@keyframes fall {
  0% { transform: translateY(-20px); }
  100% { transform: translateY(105vh); }
}

/* ---------- 顶部工具栏 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.5), transparent);
}
.chapter-label { font-size: 13px; color: rgba(255,255,255,.85); letter-spacing: .12em; }
.topbar-right { display: flex; gap: 10px; }
.tool-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.15);
  background: rgba(16,20,28,.6); color: var(--ink); font-size: 17px; cursor: pointer;
  backdrop-filter: blur(8px); transition: all .18s; display:flex; align-items:center; justify-content:center;
}
.tool-btn:hover { background: rgba(111,183,255,.25); border-color: rgba(111,183,255,.5); }
.tool-btn.active { background: rgba(111,183,255,.35); margin-left:0; }
.tool-btn.toggled { color: var(--accent); border-color: var(--accent); }

/* ---------- 对话框 ---------- */
.dialogue {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  width: min(980px, 92vw); z-index: 9; cursor: pointer;
  background: linear-gradient(180deg, rgba(240,244,250,.96), rgba(222,229,238,.96));
  color: var(--box-text); border-radius: 16px; padding: 22px 30px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.7);
}
.speaker-name {
  position: absolute; top: -26px; left: 88px;
  background: linear-gradient(120deg,var(--accent),var(--accent-2));
  color: #0b1020; font-weight: 700; font-size: 15px; letter-spacing: .08em;
  padding: 6px 18px; border-radius: 20px; box-shadow: 0 6px 18px rgba(111,183,255,.3);
}
/* 说话人头像：随说话人切换，与场景CG并存（对象存储偏上以露出脸部）——与名字并排，不重叠 */
.speaker-portrait {
  position: absolute; top: -40px; left: 18px;
  width: 54px; height: 54px; border-radius: 50%;
  object-fit: cover; object-position: center 20%;
  border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  background: #1a2230; display: none; z-index: 4;
}
.dialogue.narration .speaker-portrait { display: none !important; }
.dialogue-text {
  font-size: clamp(16px, 2.3vw, 21px); line-height: 1.75; min-height: 3.6em;
  text-align: justify; word-break: break-word;
}
.advance-hint {
  position: absolute; right: 24px; bottom: 8px; color: var(--accent); font-size: 16px;
  animation: bob 1.3s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(6px)} }
.dialogue.narration .speaker-name { display: none; }
.dialogue.narration .dialogue-text { color: #3a4455; font-style: normal; }

/* ---------- 侧边面板（回看/设置） ---------- */
.panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(400px, 92vw); z-index: 20;
  background: var(--bg-panel); backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255,255,255,.1);
  transform: translateX(105%); transition: transform .32s ease;
  display: flex; flex-direction: column;
}
.panel.open { transform: translateX(0); }
.panel-head { display:flex; align-items:center; gap:14px; padding:18px 20px; border-bottom:1px solid rgba(255,255,255,.08); }
.panel-head h3 { font-size: 17px; letter-spacing:.08em; }
.panel-scroll { flex:1; overflow-y:auto; padding:16px 18px; }
.history-item { margin-bottom:14px; padding:10px 12px; border-left:3px solid var(--accent); background:rgba(255,255,255,.03); border-radius:6px; }
.history-item .who { font-size:12px; color:var(--accent); font-weight:700; margin-bottom:4px; }
.history-item.narration .who { display:none; }
.history-item .what { font-size:14px; line-height:1.65; color:var(--ink); }

.settings-body { flex:1; overflow-y:auto; padding: 20px; display:flex; flex-direction:column; gap:20px; }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:16px; font-size:15px; color:var(--ink); }
.setting-row input[type=range]{ flex:1; max-width:180px; accent-color: var(--accent); }
.settings-select {
  flex:1; max-width:200px; font-family:inherit; font-size:14px;
  padding:9px 12px; border-radius:9px; border:1px solid rgba(255,255,255,.16);
  background:#161b26; color:var(--ink); cursor:pointer;
}
.settings-select:disabled { opacity:.4; cursor:default; }

/* ---------- 全屏卡片遮罩（标题/结束） ---------- */
.card-overlay {
  position: absolute; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% 40%, rgba(12,16,26,.3), rgba(8,11,18,.85)),
              linear-gradient(160deg, rgba(10,14,22,.55), rgba(6,9,15,.9));
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
.card-overlay.show { opacity: 1; pointer-events: auto; }
.card { text-align: center; padding: 0 26px; }
.card-kicker {
  font-size: 15px; letter-spacing: .5em; color: var(--accent); margin-bottom: 18px; text-transform: uppercase;
}
.card-title {
  font-size: clamp(30px, 6vw, 60px); font-weight: 800; letter-spacing: .14em;
  background: linear-gradient(120deg,#eaf3ff,#9ac8ff 55%,#c9a8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.card-sub { margin-top: 16px; font-size: clamp(14px,2.2vw,18px); color: var(--ink-dim); letter-spacing: .2em; }
.end-card .card-title { font-size: clamp(26px,5vw,46px); }
.card-actions { margin-top: 34px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.end-card .card-sub { color: #8a96ab; }

/* ---------- 选择（预留） ---------- */
.choice-wrap { display: flex; flex-direction: column; gap: 12px; padding: 6px 2px 2px; }
.choice-btn {
  text-align: left; border: 1px solid rgba(60,80,120,.3); color: #33415a;
  background: rgba(255,255,255,.6); border-radius: 12px; padding: 13px 18px;
}
.choice-btn:hover { background: #fff; border-color: var(--accent); transform: translateX(4px); }

/* ---------- 照片 CG 插入层 ---------- */
.cg-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(760px, 92vw); max-height: 74vh; z-index: 6;
  pointer-events: none; opacity: 0; transition: opacity .5s ease, transform .5s ease;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  border: 2px solid rgba(255,255,255,.18);
  background: #000;
}
.cg-frame.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
/* 照片CG显示时压暗并虚化背景，聚焦照片 */
#game-screen.cg-active .bg-layer,
#game-screen.cg-active .sprite-layer {
  filter: brightness(.42) blur(3px) saturate(.9);
  transition: filter .5s ease;
}
#game-screen.cg-active::before {
  content: ""; position: absolute; inset: 0; z-index: 4;
  background: radial-gradient(1200px 620px at 50% 45%, transparent, rgba(0,0,0,.55));
  pointer-events: none;
}
.cg-frame img { display: block; width: 100%; max-height: 74vh; object-fit: contain; }
.cg-frame .caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px;
  font-size: 13px; color: #e8eef7; letter-spacing: .05em;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
}
.dialogue { z-index: 9; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(111,183,255,.4); }
