/* ── 标题界面 + 事件/结局一览(v0.7.9+)── */

#title-root {
  /* 容器,实际样式挂在内部 .title-screen / .title-gallery 上 */
}

/* ============ 主标题屏 ============ */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a0808;     /* fallback,bg image 加载前 */
  overflow: hidden;
}

/* 背景图三档:dark(默认)/ medium(>50% 结局)/ bright(>50% + 好结局)。
   cover 放大铺满裁中间 —— contain 会因图/屏比例不同(尤其 mobile 竖屏)
   上下留大片褐色空白。 */
.title-screen-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.title-screen-bg.tier-dark   { background-image: url("../assets/title-bg-dark.webp"); }
.title-screen-bg.tier-medium { background-image: url("../assets/title-bg.webp"); }
.title-screen-bg.tier-bright { background-image: url("../assets/title-bg-bright.webp"); }

/* tier-dark fallback:已经够暗,几乎全黑 */
.title-screen.tier-dark   { background: #0a0303; }
.title-screen.tier-medium { background: #1a0808; }
.title-screen.tier-bright { background: #3a1a10; }   /* 偏暖,跟 bright 图边缘融合 */

/* per-tier 暗罩:dark 已暗→只 vignette;medium 维持原版;bright 几乎不压 */
.title-screen-bg.tier-dark::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 95% 80% at 50% 50%, transparent 55%, rgba(0,0,0,0.25) 100%);
  pointer-events: none;
}
.title-screen-bg.tier-medium::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.30) 0%, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.10) 70%, rgba(0,0,0,0.40) 100%),
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 45%, rgba(0,0,0,0.30) 100%);
  pointer-events: none;
}
.title-screen-bg.tier-bright::after {
  content: '';
  position: absolute;
  inset: 0;
  /* bright 图本身明亮,几乎不压,只加边缘暖色 vignette 让金光更聚焦 */
  background:
    radial-gradient(ellipse 100% 85% at 50% 50%, transparent 65%, rgba(80,40,20,0.18) 100%);
  pointer-events: none;
}

.title-screen-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.title-name {
  /* 字体跟主游戏一致(思源宋体本地嵌入,见 styles/fonts.css);
     v0.7.9+:600→700,本地仅嵌 400/600,浏览器合成 bold 比 600 更具分量 */
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 68px;
  letter-spacing: 0.35em;
  font-weight: 700;
  margin-bottom: 18px;
  padding-left: 0.35em;
  /* color + text-shadow 由 tier 决定,见下 */
}

.title-subname {
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 15px;
  letter-spacing: 0.5em;
  font-weight: 700;
  margin-bottom: 64px;
  padding-left: 0.5em;
  /* color 由 tier 决定 */
}

/* ── tier-dark:米白字(像古籍烫金)+ 紧黑描边 ── */
.tier-dark .title-name {
  color: #f0e2c4;
  text-shadow:
    0 0 2px rgba(0,0,0,0.95),
    0 0 5px rgba(0,0,0,0.85),
    0 2px 20px rgba(0,0,0,0.90),
    0 0 36px rgba(184,134,11,0.18);
}
.tier-dark .title-subname { color: #d4c4a4; text-shadow: 0 0 2px rgba(0,0,0,0.9), 0 1px 6px rgba(0,0,0,0.75); }

/* ── tier-medium:暖米白 + 深朱红描边(暮色橙红天空) ── */
.tier-medium .title-name {
  color: #f5e2b8;
  text-shadow:
    0 0 2px rgba(60,15,10,0.95),
    0 0 6px rgba(60,15,10,0.85),
    0 2px 20px rgba(0,0,0,0.80),
    0 0 36px rgba(184,134,11,0.15);
}
.tier-medium .title-subname { color: #d8c090; text-shadow: 0 0 2px rgba(60,15,10,0.9), 0 1px 6px rgba(0,0,0,0.60); }

/* ── tier-bright:深朱红字 + 米白光晕(创乳金沐光天空) ── */
.tier-bright .title-name {
  color: #5a0808;
  text-shadow:
    0 0 3px rgba(255,247,232,0.90),
    0 0 8px rgba(255,247,232,0.60),
    0 2px 12px rgba(120,40,20,0.55);
}
.tier-bright .title-subname { color: #7a1818; text-shadow: 0 0 3px rgba(255,247,232,0.85), 0 1px 4px rgba(255,247,232,0.55); }

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.title-menu-btn {
  /* 按钮也走楷体,跟标题一致 */
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.35em;
  background: transparent;
  border-radius: 1px;
  padding: 11px 56px;
  padding-right: calc(56px + 0.35em);  /* 字符间距末字补偿 */
  cursor: pointer;
  transition: all 0.18s ease;
  /* color / border / hover 由 tier 决定 */
}

/* ── 按钮 tier 风格 ── */
.tier-dark .title-menu-btn {
  color: #e8d8b8;
  border: 1px solid rgba(232, 216, 184, 0.30);
  text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 0 4px rgba(0,0,0,0.7);
}
.tier-dark .title-menu-btn:hover {
  background: rgba(232, 216, 184, 0.10);
  border-color: rgba(240, 226, 196, 0.6);
  color: #f5e8c8;
  letter-spacing: 0.4em;
}

.tier-medium .title-menu-btn {
  color: #f0e0c0;
  background: rgba(20,8,4,0.32);                  /* 半透深底 — 暮色橙红天空里立字 */
  border: 1px solid rgba(240, 224, 192, 0.35);
  text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 0 4px rgba(60,15,10,0.7);
}
.tier-medium .title-menu-btn:hover {
  background: rgba(20,8,4,0.55);
  border-color: rgba(245, 230, 200, 0.65);
  color: #fbeed0;
  letter-spacing: 0.4em;
}

.tier-bright .title-menu-btn {
  color: #5a0808;
  background: rgba(255,247,232,0.58);             /* 半透宣纸底 — 亮天空里立起深字 */
  border: 1px solid rgba(106, 13, 13, 0.40);
  text-shadow: 0 1px 2px rgba(255,247,232,0.6);
}
.tier-bright .title-menu-btn:hover {
  background: rgba(255,247,232,0.88);
  border-color: #8b1a1a;
  color: #4a0808;
  letter-spacing: 0.4em;
}

.title-version {
  position: absolute;
  bottom: 18px;
  right: 22px;
  font-size: 11px;
  color: rgba(200, 180, 140, 0.4);
  letter-spacing: 0.1em;
  font-family: "Cinzel", serif;
}

/* 告辞页 */
.title-screen-inner.farewell { gap: 48px; }
.title-farewell-text {
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 46px;
  letter-spacing: 0.4em;
  padding-left: 0.4em;
  font-weight: 600;
  /* color / shadow 走 tier */
}
.title-farewell-text .title-farewell-sub { font-size: 22px; }
.title-farewell-hint {
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: 13px;
  letter-spacing: 0.3em;
  margin-top: -16px;
  /* color 走 tier */
}
.farewell-back {
  margin-top: 16px;
  font-size: 14px;
  letter-spacing: 0.2em;
  padding: 8px 24px;
}

.tier-dark   .title-farewell-text { color: #f0e2c4; text-shadow: 0 0 2px rgba(0,0,0,0.95), 0 0 5px rgba(0,0,0,0.85), 0 2px 18px rgba(0,0,0,0.90); }
.tier-dark   .title-farewell-sub  { color: #d4c4a4; }
.tier-dark   .title-farewell-hint { color: rgba(216, 200, 168, 0.60); }

.tier-medium .title-farewell-text { color: #f5e2b8; text-shadow: 0 0 2px rgba(60,15,10,0.95), 0 0 6px rgba(60,15,10,0.85), 0 2px 18px rgba(0,0,0,0.80); }
.tier-medium .title-farewell-sub  { color: #d8c090; }
.tier-medium .title-farewell-hint { color: rgba(228, 212, 180, 0.65); }

.tier-bright .title-farewell-text { color: #5a0808; text-shadow: 0 0 3px rgba(255,247,232,0.90), 0 0 8px rgba(255,247,232,0.55), 0 2px 12px rgba(120,40,20,0.50); }
.tier-bright .title-farewell-sub  { color: #7a1818; }
.tier-bright .title-farewell-hint { color: rgba(80, 30, 20, 0.65); }

/* ============ 一览页(事件/结局共用)============ */
.title-gallery {
  position: fixed;
  inset: 0;
  z-index: 200;
  background-color: var(--bg-paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'><g fill='none' stroke='%238b1a1a' stroke-opacity='0.055' stroke-width='0.8' stroke-linejoin='miter'><path d='M6 6 H66 V66 H6 Z'/><path d='M14 14 H58 V58 H14 V36'/><path d='M22 22 H50 V50 H22 V40'/></g><circle cx='36' cy='36' r='1.4' fill='%238b1a1a' fill-opacity='0.09'/></svg>");
  background-repeat: repeat;
  background-size: 72px 72px;
  font-family: "Cinzel", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 2px solid var(--red-imp);
  background: rgba(239, 229, 203, 0.85);
  flex-shrink: 0;
}
.gallery-title {
  font-size: 24px;
  letter-spacing: 0.4em;
  color: var(--red-imp);
  padding-left: 0.4em;
}
.gallery-stats {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}
.gallery-stats strong {
  color: var(--red-imp);
  font-size: 16px;
}
.gallery-back {
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--red-imp);
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.gallery-back:hover {
  background: rgba(139, 26, 26, 0.08);
  border-color: var(--red-imp);
}

.gallery-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 36px 48px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.gallery-cat {
  margin-bottom: 28px;
}
.gallery-cat-title {
  font-size: 17px;
  letter-spacing: 0.25em;
  color: var(--red-imp);
  border-left: 4px solid var(--red-imp);
  padding-left: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.gallery-cat-stat {
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  font-weight: normal;
}

/* 单事件条目 */
.gallery-item {
  background: rgba(251, 246, 231, 0.88);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.gallery-item.locked {
  background: rgba(220, 215, 200, 0.45);
  color: var(--ink-mute);
}
.gallery-item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.gallery-item-icon {
  font-size: 16px;
  flex-shrink: 0;
  color: var(--red-imp);
}
.gallery-item.locked .gallery-item-icon { color: var(--ink-mute); }
.gallery-item-name {
  flex: 1;
  font-size: 15px;
  letter-spacing: 0.15em;
  color: var(--ink);
  font-weight: 500;
}
.gallery-item.locked .gallery-item-name { color: var(--ink-mute); }
.gallery-item-turn {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.gallery-item-narrative {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink-soft);
  white-space: pre-line;
  letter-spacing: 0.02em;
}

/* ── v0.7.11+:结局一览 tile 平铺 ── */
/* 结局/事件一览都铺满更大区域(v0.7.13+:事件也改 tile 后通用此宽度) */
.title-gallery--endings .gallery-body,
.title-gallery--events .gallery-body {
  max-width: 1800px;
  padding: 32px 56px 64px;
}

/* ── v0.7.13+:事件一览改 tile 平铺(与结局一览同款 tile,加 category 分组容器)── */
.event-cat-block {
  margin-bottom: 36px;
}
.event-cat-block:last-child { margin-bottom: 0; }
.event-cat-title {
  font-size: 16px;
  letter-spacing: 0.32em;
  color: var(--red-imp);
  padding: 6px 0 12px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 18px;
  padding-left: 0.32em;
}
.event-cat-stat {
  font-size: 12px;
  color: var(--ink-mute);
  margin-left: 14px;
  letter-spacing: 0.15em;
  font-weight: normal;
}
/* .event-tile-grid 已与 .ending-tile-grid 合并到上方共享规则,此处保留空块作历史标注 */
/* event-tile 复用 .ending-tile 大部分样式;此处只覆盖差异:title 字号略小,因事件名比结局名长 */
.ending-tile.event-tile .ending-tile-title {
  font-size: 16px;
  letter-spacing: 0.22em;
}
.ending-tile.event-tile.locked .ending-tile-title {
  font-size: 18px;
  letter-spacing: 0.42em;
}
/* 无图事件 tile:深色渐变填底,overlay 居中显示 icon + 标题 */
.ending-tile.event-tile.no-img {
  background: linear-gradient(135deg, #2a1a15, #1a0a08);
}
.ending-tile.event-tile.no-img .ending-tile-overlay {
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* v0.7.13+:事件 / 结局 tile-grid 共用规则。固定 4 列占满,最后一行未填满处右侧留空(非撑大);
   tile 等宽等高(aspect-ratio:3/2 自动算高)。窄屏 media query 降级到 3/2 列防过小。 */
.ending-tile-grid,
.event-tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 1200px) {
  .ending-tile-grid,
  .event-tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .ending-tile-grid,
  .event-tile-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 单 tile:已解锁版(button)+ 未解锁版(div.locked)共享布局 */
.ending-tile {
  position: relative;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(40, 30, 25, 0.85);
  padding: 0;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: block;
}
.ending-tile:not(.locked):hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.ending-tile.locked {
  cursor: default;
  background: linear-gradient(135deg, rgba(50, 35, 30, 0.85), rgba(25, 18, 15, 0.92));
}

.ending-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.ending-tile.no-img { background: linear-gradient(135deg, #2a1a15, #1a0a08); }

/* group pill — 右上角小色标 */
.ending-tile-group {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 2px 8px;
  background: rgba(139, 26, 26, 0.85);
  color: #f5e8c4;
  border-radius: 1px;
}
.ending-tile.locked .ending-tile-group {
  background: rgba(80, 70, 60, 0.7);
  color: var(--ink-mute);
}

/* overlay:已解锁=底部 gradient,未解锁=全屏居中 */
.ending-tile-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 18px 16px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.55) 65%, rgba(0,0,0,0) 100%);
  text-align: center;
  pointer-events: none;
}
.ending-tile.locked .ending-tile-overlay {
  inset: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
}

.ending-tile-title {
  font-size: 19px;
  letter-spacing: 0.32em;
  color: #f5e8c4;
  font-weight: 600;
  padding-left: 0.32em;
}
.ending-tile.locked .ending-tile-title {
  color: var(--ink-mute);
  letter-spacing: 0.5em;
  font-size: 22px;
}

.ending-tile-turn {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(245, 232, 196, 0.75);
  margin-top: 5px;
}
.ending-tile.locked .ending-tile-turn {
  color: var(--ink-mute);
  margin-top: 8px;
  letter-spacing: 0.2em;
}

/* ── 结局详情 modal ── */
.ending-detail-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  overflow-y: auto;
}
.ending-detail-box {
  position: relative;
  background: rgba(251, 246, 231, 0.98);
  border: 1px solid var(--gold);
  border-radius: 4px;
  max-width: 760px;
  width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 0 0 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.ending-detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #f5e8c4;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ending-detail-close:hover { background: rgba(0, 0, 0, 0.85); }

.ending-detail-banner {
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #2a1a15, #1a0a08);
}
.ending-detail-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.ending-detail-banner.no-img { aspect-ratio: 8 / 1; }

.ending-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 30px 4px;
}
.ending-detail-title {
  font-size: 22px;
  letter-spacing: 0.3em;
  color: var(--red-imp);
  padding-left: 0.3em;
}
.ending-detail-turn {
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.ending-detail-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 0.15em;
  font-style: italic;
  padding: 6px 30px 0;
}
.ending-detail-body {
  font-size: 14px;
  line-height: 1.95;
  color: var(--ink);
  letter-spacing: 0.02em;
  padding: 16px 30px 0;
  margin-top: 14px;
  border-top: 1px dashed var(--border);
}
.ending-detail-body em {
  color: var(--red-imp);
  font-style: italic;
}

/* 终幕 modal 多按钮间距(原 modal-footer text-align:center 默认间距太紧)*/
.modal-footer .modal-btn + .modal-btn {
  margin-left: 12px;
}

/* 响应式:窄屏 */
@media (max-width: 720px) {
  /* 竖屏 cover 裁切定位 — 封面妃子背影在图横向 ~30%,center 会被裁掉只剩中间宫殿。
     百分比越大,裁切区越靠图右侧,妃子背影相对落到画面越靠左。 */
  .title-screen-bg {
    background-position: 35% center;
  }
  /* "雍正爱情故事"6 字保留一行(letter-spacing 收 + 字号略减,iPhone SE 375 也单行) */
  .title-name {
    font-size: 36px;
    letter-spacing: 0.18em;
    padding-left: 0.18em;
    white-space: nowrap;
  }
  .title-subname { font-size: 12px; margin-bottom: 40px; }
  .title-menu-btn { font-size: 16px; padding: 9px 36px; }
  .gallery-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .gallery-title { font-size: 18px; }
  .gallery-body { padding: 16px; }
  .title-gallery--endings .gallery-body { padding: 16px; }
  .ending-tile-grid,
  .event-tile-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
  .ending-tile-title { font-size: 14px; letter-spacing: 0.2em; }
  .ending-detail-mask { padding: 12px; }
  .ending-detail-head { padding: 16px 20px 4px; flex-direction: column; gap: 4px; align-items: flex-start; }
  .ending-detail-title { font-size: 18px; }
  .ending-detail-subtitle { padding: 6px 20px 0; }
  .ending-detail-body { padding: 16px 20px 0; }
}
@media (max-width: 480px) {
  .ending-tile-grid,
  .event-tile-grid { grid-template-columns: 1fr; }
}
