/* ============================================================
   夏末未寄 · Galgame Engine Stylesheet
   ============================================================ */

:root {
  --accent:        #9fd3e8;
  --accent-warm:   #ffcf9e;
  --ink:           #eef2f7;
  --ink-dim:       #a9b4c2;
  --panel-bg:      rgba(14, 18, 26, 0.86);
  --panel-border:  rgba(255, 255, 255, 0.10);
  --radius:        14px;
  --dialogue-h:    clamp(150px, 24vh, 210px);
  --font: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC",
          "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC",
                "SimSun", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #05070a;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100vw; height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- 舞台 ---------- */

#stage {
  position: absolute; inset: 0;
  overflow: hidden;
  background: #05070a;
}

.bg-layer {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center 40%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 600ms ease;
  will-change: opacity, transform;
  transform: scale(1.02);
}
.bg-layer.visible { opacity: 1; }
.bg-layer.kb { animation: kenburns 26s ease-in-out infinite alternate; }

@keyframes kenburns {
  from { transform: scale(1.02) translateY(0); }
  to   { transform: scale(1.075) translateY(-1.2%); }
}

#vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 42%, rgba(4,6,10,0.42) 100%),
    linear-gradient(to bottom, rgba(4,6,10,0.30) 0%, transparent 22%,
                    transparent 62%, rgba(4,6,10,0.55) 100%);
  z-index: 6;
}

#flash-layer {
  position: absolute; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity 260ms ease;
}

/* ---------- 立绘 ---------- */

#chara-layer {
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
}

.chara {
  position: absolute;
  bottom: 0;
  height: 92%;
  transform: translateX(-50%) translateY(3%) scale(0.985);
  opacity: 0;
  transition: opacity 380ms ease, transform 380ms cubic-bezier(.22,.9,.24,1),
              filter 320ms ease, left 380ms cubic-bezier(.22,.9,.24,1);
  will-change: opacity, transform, left;
}
.chara.in {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.chara.dim { filter: brightness(0.62) saturate(0.86); }

.chara img {
  height: 100%;
  width: auto;
  display: block;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.42));
}

.chara.breathing { animation: breathe 5.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50%      { transform: translateX(-50%) translateY(-0.7%) scale(1.004); }
}

/* 立绘占位（素材缺失时） */
.chara-ph {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 5vh;
}
.chara-ph .ph-card {
  width: clamp(120px, 17vw, 210px);
  height: 68%;
  border-radius: 14px;
  border: 1.5px dashed rgba(255,255,255,0.55);
  background:
    repeating-linear-gradient(135deg,
      rgba(255,255,255,0.06) 0 10px,
      transparent 10px 20px),
    linear-gradient(180deg, rgba(14,18,26,0.46) 0%, rgba(14,18,26,0.30) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    0 10px 34px rgba(6,10,18,0.28),
    inset 0 0 40px rgba(255,255,255,0.05);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.chara-ph .ph-name {
  writing-mode: vertical-rl;
  font-size: clamp(20px, 2.6vw, 32px);
  font-weight: 300;
  letter-spacing: 0.34em;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 6px rgba(0,0,0,0.55);
}
.chara-ph .ph-hint {
  margin-top: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.82);
  background: rgba(10,14,20,0.42);
  text-align: center;
  line-height: 1.7;
  white-space: pre-line;
}

/* ---------- CG ---------- */

#cg-layer {
  position: absolute; inset: 0;
  z-index: 5;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #05070a;
  opacity: 0;
  transition: opacity 420ms ease;
}
#cg-layer.visible { opacity: 1; }

/* ---------- 对话框 ---------- */

#dialogue {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 2.6vh, 30px);
  transform: translateX(-50%);
  width: min(1180px, 94vw);
  min-height: var(--dialogue-h);
  padding: clamp(22px, 3.2vh, 34px) clamp(24px, 3.4vw, 46px) clamp(20px, 3vh, 30px);
  border-radius: var(--radius);
  background: linear-gradient(180deg,
      rgba(13,17,24,0.68) 0%,
      rgba(11,14,20,0.90) 55%,
      rgba(9,12,17,0.94) 100%);
  border: 1px solid var(--panel-border);
  box-shadow: 0 18px 48px rgba(0,0,0,0.48),
              inset 0 1px 0 rgba(255,255,255,0.07);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  z-index: 20;
  transition: opacity 260ms ease, transform 260ms ease;
}
#dialogue.hide-ui {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

#name-plate {
  position: absolute;
  top: -17px;
  left: clamp(20px, 2.6vw, 38px);
  padding: 7px 22px 8px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7bb8d4);
  box-shadow: 0 6px 18px rgba(159,211,232,0.22);
  font-size: clamp(13px, 1.15vw, 15px);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #0a1620;
  white-space: nowrap;
  transition: opacity 180ms ease;
}
#name-plate.empty { opacity: 0; }

#text-body {
  position: relative;
  min-height: calc(var(--dialogue-h) - 62px);
  display: flex;
  align-items: flex-start;
}

#text {
  font-size: clamp(15px, 1.06vw, 18px);
  line-height: 2.0;
  letter-spacing: 0.025em;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
  white-space: pre-wrap;
  word-break: break-word;
  width: 100%;
}
#text.narration {
  color: #cfd8e3;
  font-style: normal;
}
#text.thought {
  color: #b8c6d6;
  font-style: italic;
  opacity: 0.92;
}

#next-ind {
  position: absolute;
  right: clamp(18px, 2.4vw, 30px);
  bottom: clamp(12px, 1.8vh, 20px);
  font-size: 13px;
  color: var(--accent);
  opacity: 0;
  animation: bob 1.15s ease-in-out infinite;
}
#next-ind.show { opacity: 0.9; }
@keyframes bob {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50%      { transform: translateY(4px); opacity: 1; }
}

/* ---------- 选项 ---------- */

#choice-scrim {
  position: absolute;
  inset: 0;
  z-index: 24;
  background: radial-gradient(ellipse at 50% 46%, rgba(6,9,14,0.30) 0%, rgba(6,9,14,0.62) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
#choice-scrim.visible { opacity: 1; }

/* 选项出现时对话框退场，台词不再和按钮打架 */
#app.choosing #dialogue {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

#choices {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 84vw);
  max-height: calc(100% - 28px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(9px, 1.6vh, 15px);
  z-index: 25;
}

.choice-btn {
  position: relative;
  width: 100%;
  padding: clamp(14px, 2vh, 19px) clamp(20px, 3vw, 30px);
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.26);
  background: rgba(16,21,30,0.66);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  color: #f3f7fa;
  font-family: inherit;
  font-size: clamp(14px, 1.02vw, 16.5px);
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.34),
              inset 0 1px 0 rgba(255,255,255,0.10);
  transition: transform 190ms cubic-bezier(.22,.9,.24,1),
              background 190ms ease, border-color 190ms ease,
              color 190ms ease, box-shadow 190ms ease;
  opacity: 0;
  animation: choiceIn 380ms cubic-bezier(.22,.9,.24,1) forwards;
}
.choice-btn::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--accent);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: height 190ms ease;
}
.choice-btn:hover {
  background: rgba(159,211,232,0.94);
  border-color: var(--accent);
  color: #0a1620;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(159,211,232,0.26);
}
.choice-btn:hover::before { height: 64%; background: #0a1620; }
.choice-btn:active { transform: translateY(0) scale(0.995); }
.choice-btn.flavor { font-size: 0.94em; opacity: 0.9; }
.choice-btn.flavor::after {
  content: "口味选项";
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.42);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 4px;
  padding: 2px 6px;
}
.choice-btn.flavor:hover::after {
  color: rgba(10,22,32,0.6);
  border-color: rgba(10,22,32,0.3);
}

@keyframes choiceIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 快捷条 ---------- */

#quickbar {
  position: absolute;
  right: clamp(14px, 2vw, 26px);
  top: clamp(12px, 2vh, 22px);
  display: flex;
  gap: 6px;
  z-index: 30;
  transition: opacity 240ms ease;
}
#quickbar.hide-ui { opacity: 0; pointer-events: none; }

#quickbar button {
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.13);
  background: rgba(12,16,23,0.52);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(238,242,247,0.76);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 160ms ease;
}
#quickbar button:hover {
  background: rgba(159,211,232,0.88);
  border-color: var(--accent);
  color: #0a1620;
}
#quickbar button.on {
  background: rgba(159,211,232,0.88);
  border-color: var(--accent);
  color: #0a1620;
}

/* ---------- 标题画面 ---------- */

#title-screen {
  position: absolute; inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 620ms ease, visibility 620ms;
  overflow: hidden;
}
#title-screen.gone { opacity: 0; visibility: hidden; pointer-events: none; }

#title-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  animation: kb 30s ease-in-out infinite alternate;
}
@keyframes kb {
  from { transform: scale(1.0); }
  to   { transform: scale(1.07); }
}

#title-screen::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 45%, rgba(8,12,18,0.30) 0%, rgba(6,9,14,0.70) 62%, rgba(4,6,10,0.90) 100%),
    linear-gradient(105deg, rgba(6,9,14,0.92) 0%, rgba(6,9,14,0.40) 55%, transparent 100%);
}

#title-inner {
  position: relative;
  z-index: 2;
  width: min(1180px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: clamp(0px, 4vw, 60px);
}

#title-logo { margin-bottom: clamp(30px, 6vh, 56px); }

#title-main {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(40px, 6.4vw, 82px);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.1;
  color: #f7fafc;
  text-shadow: 0 4px 40px rgba(0,0,0,0.55);
}
#title-sub {
  margin: 14px 0 0 4px;
  font-size: clamp(10px, 1vw, 13px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(159,211,232,0.72);
}

#title-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: clamp(210px, 20vw, 268px);
}

#title-menu button {
  position: relative;
  text-align: left;
  padding: 13px 4px 13px 26px;
  border: none;
  background: none;
  color: rgba(238,242,247,0.60);
  font-family: inherit;
  font-size: clamp(14px, 1.15vw, 16px);
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: color 220ms ease, padding-left 220ms ease;
}
#title-menu button::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 0; height: 1px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: width 240ms cubic-bezier(.22,.9,.24,1);
}
#title-menu button:hover { color: #ffffff; padding-left: 40px; }
#title-menu button:hover::before { width: 28px; }
#title-menu button:disabled {
  color: rgba(238,242,247,0.20);
  cursor: default;
  padding-left: 26px;
}
#title-menu button:disabled::before { width: 0; }

#title-foot {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(238,242,247,0.26);
  pointer-events: none;
}

/* ---------- 覆盖层面板 ---------- */

#overlay {
  position: absolute; inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4,6,10,0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 220ms ease;
  padding: 20px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(860px, 94vw);
  max-height: min(640px, 88vh);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 30px 80px rgba(0,0,0,0.62), inset 0 1px 0 rgba(255,255,255,0.07);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  overflow: hidden;
  animation: panelIn 300ms cubic-bezier(.22,.9,.24,1);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--accent);
}
#panel-close {
  width: 30px; height: 30px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--ink-dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: all 160ms ease;
}
#panel-close:hover { background: rgba(255,255,255,0.14); color: #fff; }

.panel-body {
  padding: 22px 24px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 4px;
}

/* 存档槽 */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.slot {
  position: relative;
  padding: 14px 16px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.035);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  transition: all 170ms ease;
  min-height: 88px;
}
.slot:hover {
  border-color: rgba(159,211,232,0.55);
  background: rgba(159,211,232,0.10);
  transform: translateY(-2px);
}
.slot .slot-no {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  opacity: 0.8;
}
.slot .slot-chapter {
  margin-top: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: #eef2f7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot .slot-snippet {
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.slot .slot-time {
  position: absolute;
  right: 13px; top: 13px;
  font-size: 10px;
  color: rgba(255,255,255,0.30);
  letter-spacing: 0.04em;
}
.slot.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.22);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  border-style: dashed;
}
.slot.empty:hover { color: rgba(159,211,232,0.7); }

/* 设置项 */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.055);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 13.5px; color: #dfe6ee; letter-spacing: 0.03em; }
.setting-label small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.32);
  letter-spacing: 0;
}
.setting-ctrl { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(120px, 20vw, 200px);
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.16);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(159,211,232,0.15);
  cursor: pointer;
  transition: box-shadow 160ms ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 7px rgba(159,211,232,0.22);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.range-val {
  width: 40px;
  text-align: right;
  font-size: 11.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.toggle {
  position: relative;
  width: 46px; height: 25px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 200ms ease;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  transition: all 200ms cubic-bezier(.22,.9,.24,1);
}
.toggle.on { background: rgba(159,211,232,0.90); border-color: var(--accent); }
.toggle.on::after { left: 25px; background: #0a1620; }

/* 回顾 */
.log-item {
  padding: 13px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.log-item .log-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}
.log-item .log-text {
  font-size: 13.5px;
  line-height: 1.85;
  color: #cfd8e3;
  white-space: pre-wrap;
}
.log-item.narr .log-text { color: #a8b4c2; }

/* 鉴赏 */
.gallery-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.gallery-tabs button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.11);
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 160ms ease;
}
.gallery-tabs button.active {
  background: rgba(159,211,232,0.90);
  border-color: var(--accent);
  color: #0a1620;
}

.cg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.cg-item {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: rgba(255,255,255,0.28);
  letter-spacing: 0.1em;
  cursor: default;
  overflow: hidden;
  transition: all 180ms ease;
}
.cg-item.locked {
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,0.025) 0 8px, transparent 8px 16px) !important;
  border-style: dashed;
}
.cg-item.unlocked { cursor: pointer; }
.cg-item.unlocked:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.45);
}

.ending-list { display: flex; flex-direction: column; gap: 10px; }
.ending-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.03);
}
.ending-row .e-badge {
  flex-shrink: 0;
  min-width: 44px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.e-badge.he { background: rgba(255,207,158,0.18); color: var(--accent-warm); border: 1px solid rgba(255,207,158,0.32); }
.e-badge.be { background: rgba(150,175,200,0.12); color: #93a4b8; border: 1px solid rgba(150,175,200,0.24); }
.e-badge.ne { background: rgba(159,211,232,0.14); color: var(--accent); border: 1px solid rgba(159,211,232,0.28); }
.e-badge.locked { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.22); border: 1px solid rgba(255,255,255,0.08); }
.ending-row .e-name { font-size: 13px; color: #dfe6ee; }
.ending-row.locked .e-name { color: rgba(255,255,255,0.24); }

/* ---------- 章节卡 / 结局卡 ---------- */

#flash {
  position: absolute; inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #06080c;
  opacity: 0;
  transition: opacity 520ms ease;
}
#flash.show { opacity: 1; }

#flash-inner {
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 700ms ease 220ms, transform 700ms cubic-bezier(.22,.9,.24,1) 220ms;
}
#flash.show #flash-inner { opacity: 1; transform: translateY(0); }

#flash-inner .f-kicker {
  font-size: 11px;
  letter-spacing: 0.5em;
  color: rgba(159,211,232,0.60);
  margin-bottom: 20px;
  text-transform: uppercase;
}
#flash-inner .f-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.2vw, 38px);
  font-weight: 400;
  letter-spacing: 0.18em;
  color: #f4f8fa;
  margin: 0;
}
#flash-inner .f-line {
  width: 56px; height: 1px;
  margin: 26px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
#flash-inner .f-desc {
  margin: 22px auto 0;
  max-width: 520px;
  font-size: 13px;
  line-height: 2.0;
  letter-spacing: 0.05em;
  color: rgba(238,242,247,0.52);
}

/* ---------- 点击热区 ---------- */

#click-catcher {
  position: absolute; inset: 0;
  z-index: 10;
  cursor: pointer;
}
#click-catcher.disabled { pointer-events: none; }

/* ---------- 移动端 ---------- */

@media (max-width: 760px) {
  :root { --dialogue-h: clamp(132px, 26vh, 168px); }

  #dialogue {
    width: 94vw;
    bottom: 10px;
    border-radius: 12px;
    padding: 20px 18px 22px;
  }
  #name-plate { left: 14px; padding: 6px 16px; top: -15px; }
  #text { line-height: 1.9; }

  #quickbar { gap: 4px; right: 8px; top: 8px; }
  #quickbar button { padding: 6px 9px; font-size: 11px; }

  #choices { width: 92vw; gap: 11px; }
  .choice-btn { text-align: center; padding: 15px 16px; }
  .choice-btn::before { display: none; }
  .choice-btn.flavor { padding-right: 58px; padding-left: 12px; }
  .choice-btn.flavor::after { right: 9px; font-size: 9px; padding: 1px 5px; letter-spacing: 0.04em; }

  #title-inner { align-items: center; padding-left: 0; text-align: center; }
  #title-logo { margin-bottom: 34px; }
  #title-main { letter-spacing: 0.1em; }
  #title-menu { width: 220px; }
  #title-menu button { text-align: center; padding-left: 0; }
  #title-menu button::before { display: none; }
  #title-menu button:hover { padding-left: 0; }

  .slot-grid { grid-template-columns: 1fr; }
  .panel { max-height: 90vh; }
  .panel-body { padding: 16px 16px 20px; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .setting-ctrl { width: 100%; }
  input[type="range"] { flex: 1; width: auto; }
}

@media (max-height: 520px) {
  :root { --dialogue-h: 118px; }
  #text { line-height: 1.7; }
}

/* ---------- 占位素材提示 ---------- */

#bg-label {
  position: absolute;
  left: 20px;
  top: 16px;
  z-index: 8;
  font-family: var(--font);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.32);
  pointer-events: none;
  max-width: 46vw;
  white-space: pre-line;
}

@media (max-width: 760px) {
  #bg-label {
    left: 10px;
    top: 48px;
    font-size: 9px;
    max-width: 60vw;
    color: rgba(255,255,255,0.28);
  }
}

/* ---------- 竖屏拦截 ---------- */

#rotate-gate { display: none; }

body.need-rotate #rotate-gate {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 34%, rgba(96,138,180,0.22) 0%, transparent 62%),
    linear-gradient(160deg, #0d1219 0%, #131a24 55%, #0a0e14 100%);
  color: #e8eef6;
  font-family: var(--font);
  text-align: center;
  padding: 24px;
  -webkit-tap-highlight-color: transparent;
}

#rotate-gate .rg-inner { max-width: 300px; }

#rotate-gate .rg-icon {
  color: #8fb8dd;
  margin-bottom: 18px;
  animation: rg-wobble 2.6s ease-in-out infinite;
}

@keyframes rg-wobble {
  0%, 62%, 100% { transform: rotate(0deg); }
  74% { transform: rotate(-16deg); }
  86% { transform: rotate(82deg); }
}

#rotate-gate .rg-title {
  font-size: 19px;
  letter-spacing: 0.22em;
  margin: 0 0 14px;
  color: #f2f6fb;
}

#rotate-gate .rg-sub {
  font-size: 12.5px;
  line-height: 1.9;
  letter-spacing: 0.06em;
  color: rgba(214,228,242,0.62);
  margin: 0 0 22px;
}

#rotate-gate .rg-hint {
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: rgba(214,228,242,0.30);
  margin: 0;
}

/* ---------- 场景光调（立绘跟随时间） ---------- */

#chara-layer { transition: filter 520ms ease; }
#chara-layer.mood-evening {
  filter: sepia(0.24) saturate(1.12) brightness(0.92) contrast(1.02);
}
#chara-layer.mood-night {
  filter: brightness(0.58) saturate(0.72) contrast(1.1) hue-rotate(-8deg);
}

/* ---------- 横屏手机：把 UI 收紧 ---------- */

@media (max-height: 480px) {
  #quickbar {
    top: 8px;
    right: 10px;
    gap: 4px;
  }
  #quickbar button {
    padding: 4px 9px;
    font-size: 10.5px;
    border-radius: 6px;
    letter-spacing: 0.02em;
  }
  #dialogue {
    bottom: 8px;
    width: min(1180px, 97vw);
    padding: 14px 18px 14px;
    border-radius: 12px;
  }
  #name-plate {
    font-size: 12px;
    padding: 2px 11px;
  }
  #text-body { font-size: 15px; }
  #choices { width: min(680px, 90vw); }
  .choice-btn {
    padding: 10px 14px;
    font-size: 13.5px;
  }
}
