:root {
  --bg: #120f12;
  --panel: rgba(33, 23, 31, 0.82);
  --panel-strong: rgba(49, 31, 43, 0.92);
  --line: rgba(255, 220, 186, 0.14);
  --text: #f8ecd7;
  --muted: #cdbca7;
  --accent: #f5b54a;
  --accent-2: #7fd3c6;
  --danger: #f07f6f;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background:
    url("assets/backgrounds/main-bg.jpg") center/cover no-repeat fixed,
    radial-gradient(circle at top left, rgba(255, 148, 76, 0.18), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(127, 211, 198, 0.14), transparent 30%),
    linear-gradient(135deg, #0d0a0d 0%, #171117 52%, #1a1218 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; opacity: 0.25;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
}

/* ═══════ SHELL — 竖屏默认：单列 ═══════ */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ═══════ 顶部导航栏（竖屏 sidebar 收成 topbar） ═══════ */
.global-mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(17, 34, 64, 0.6);
  border: 1px solid #bda27b;
  color: #e8dcc4;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}
.global-mute-btn:active {
  transform: scale(0.9);
}

.sidebar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(19,14,18,0.98), rgba(27,18,24,0.94));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
}

.brand { flex: 0 0 auto; margin-top: 8px; }
.brand h1 { font-size: 28px; margin: 0; white-space: nowrap; }
.brand-eyebrow, .brand-copy { display: none; }

.status-card {
  flex: 0 0 auto;
  display: flex; gap: 14px;
  padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none;
}
.status-row { border: 0; padding: 0; gap: 6px; font-size: 12px; }
.status-row span { opacity: 0.6; }

.timeline {
  flex: 1 1 100%;
  display: flex; gap: 0; list-style: none; padding: 0; margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.timeline-item {
  flex: 0 0 auto; white-space: nowrap;
  padding: 6px 12px; border-radius: 12px; font-size: 12px;
  border: 1px solid transparent; background: rgba(255,255,255,0.02);
  transition: all 200ms ease;
}
.timeline-item.is-active {
  color: var(--text); font-weight: 600;
  border-color: rgba(245,181,74,0.45); background: rgba(245,181,74,0.14);
}

.sidebar-foot { flex: 0 0 auto; margin-left: auto; }
.sidebar-foot .ghost-btn { padding: 8px 14px; font-size: 12px; }

/* ═══════ 主舞台 ═══════ */
.stage { padding: 0; max-width: 100%; width: 100%; }
.scene { display: none; margin: 0 auto; animation: fade-in 360ms ease; max-width: 480px; }
.scene.is-visible { display: block; }
.scroll-scene.is-visible { display: flex; max-width: none; }

body.is-opening-scene {
  overflow: hidden;
}

body.is-opening-scene .sidebar {
  display: none;
}

body.is-opening-scene .app-shell {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

body.is-opening-scene .stage {
  padding: 0;
}

.opening-scene {
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.opening-cover-bg {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  /* 改为 center bottom 确保底部的按钮距离屏幕底部的相对位置最稳定 */
  background: url("assets/backgrounds/opening-new.jpg") center bottom / cover no-repeat;
  display: block;
}

.invisible-enter-btn {
  position: absolute;
  /* 进一步上移并加大高度，完全覆盖整个深色画框及其边缘 */
  bottom: 17.5%; 
  left: 50%;
  transform: translateX(-50%);
  width: 82%; /* 稍微加宽一点覆盖到两边的圆环装饰 */
  max-width: 360px;
  height: 11%; /* 高度加大 */
  min-height: 75px;
  
  /* 透明热区 */
  opacity: 1; 
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  z-index: 10;
  border-radius: 20px; /* 调整圆角配合增大的区域 */
  -webkit-tap-highlight-color: transparent;
  
  /* 点击特效过渡 */
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
  .invisible-enter-btn:hover {
    background-color: rgba(255, 255, 255, 0.08); /* 微微提亮 */
  }
}

/* 确保手机端点击特效生效，并且更加明显 */
.invisible-enter-btn:active, 
.invisible-enter-btn:focus {
  background-color: rgba(255, 255, 255, 0.25) !important; /* 按下时泛白光，加!important确保覆盖 */
  transform: translateX(-50%) scale(0.96) !important; /* 按下时稍微缩小，带来物理按压感 */
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.4) !important; /* 内发光增强 */
}

.opening-art {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-items: stretch;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(6, 5, 7, 0.88) 0%, rgba(6, 5, 7, 0.45) 28%, rgba(6, 5, 7, 0.06) 52%, rgba(6, 5, 7, 0.02) 78%, rgba(6, 5, 7, 0.0) 100%),
    url("assets/backgrounds/opening-bg.jpg") calc(100% + 80px) center/cover no-repeat;
}

.opening-art::before,
.opening-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.opening-art::before {
  background:
    radial-gradient(circle at 72% 22%, rgba(255, 255, 255, 0.08), transparent 20%),
    radial-gradient(circle at 60% 70%, rgba(151, 18, 27, 0.16), transparent 26%);
}

.opening-art::after {
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 100%);
}

.opening-scroll {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  width: min(260px, 78vw);
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  padding: 44px 26px;
  color: #ddd1ba;
  background:
    linear-gradient(180deg, rgba(16, 13, 14, 0.82), rgba(24, 18, 18, 0.72)),
    linear-gradient(90deg, rgba(150, 116, 58, 0.08), transparent 24%, transparent 76%, rgba(150, 116, 58, 0.08));
  border-left: 3px solid rgba(121, 92, 46, 0.55);
  border-right: 3px solid rgba(121, 92, 46, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 48px rgba(0, 0, 0, 0.32);
}

.opening-scroll::before,
.opening-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  background: linear-gradient(180deg, #564022, #2d2113 40%, #695032);
  box-shadow: inset 0 0 0 1px rgba(255, 233, 188, 0.1);
}

.opening-scroll::before {
  left: -18px;
}

.opening-scroll::after {
  right: -18px;
}

.opening-mark {
  margin: 0;
  color: rgba(245, 181, 74, 0.74);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.opening-scroll h2 {
  margin: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.12em;
  line-height: 1;
  font-size: clamp(56px, 8vw, 88px);
  color: rgba(235, 223, 204, 0.92);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

.opening-copy {
  margin: 0;
  max-width: 11em;
  color: #d0c1a6;
  font-size: 16px;
  line-height: 1.9;
}

.opening-copy-secondary {
  color: rgba(205, 188, 167, 0.88);
  font-size: 14px;
}

.opening-enter-btn {
  align-self: flex-start;
  margin-top: 12px;
}


/* ═══════ 通用面板 ═══════ */

/* ═══════ 字体 ═══════ */
.brand h1 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #f5b54a, #f8d88e);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.brand-eyebrow {
  margin: 0 0 8px; font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--accent);
}
.reason-copy, .story-copy, .timeline-item {
  color: var(--muted); line-height: 1.6;
}



/* ═══════ 按钮 ═══════ */

.primary-btn, .ghost-btn {
  appearance: none; border-radius: 999px; padding: 13px 20px; font-size: 14px;
  text-decoration: none; cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.primary-btn {
  background-color: #0c1b33;
  color: #e8dcc4;
  border: 2px solid #bda27b;
  font-weight: 600;
  box-shadow: inset 0 0 10px rgba(189, 162, 123, 0.2), 0 4px 15px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
  font-family: "KaiTi", "STKaiti", serif;
}
.primary-btn:hover { box-shadow: inset 0 0 15px rgba(189, 162, 123, 0.4), 0 6px 20px rgba(0, 0, 0, 0.4); transform: translateY(-1px); }
.primary-btn:active { transform: scale(0.98); background-color: #1a2c4e; }
.ghost-btn {
  border: 1px solid rgba(255,255,255,0.16); color: var(--text); background: rgba(255,255,255,0.04);
}
.ghost-btn:hover { border-color: rgba(255,255,255,0.28); background: rgba(255,255,255,0.08); }
.primary-btn:disabled, .ghost-btn:disabled { cursor: not-allowed; opacity: 0.4; transform: none; box-shadow: none; }

/* ═══════ 加载动画 ═══════ */

/* ═══════ 纹样/灵兽选择 ═══════ */

/* ═══════ 角色预览 ═══════ */


/* ═══════ 海报 ═══════ */


/* ═══════ 视频预览弹窗 ═══════ */
.video-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.video-modal[hidden] {
  display: none !important;
}

.video-modal-content {
  position: relative;
  width: 90%;
  max-width: 500px;
  background-color: #112240;
  border-radius: 12px;
  border: 2px solid #bda27b;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.close-video-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
  color: #e6d5b8;
  border: 1px solid #bda27b;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
}

.close-video-btn:hover {
  background-color: #c43939;
  border-color: #c43939;
}

#previewVideo {
  width: 100%;
  max-height: 80vh;
  display: block;
  background-color: #000;
}

/* ═══════ 动画 ═══════ */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════ 手机端（<768px） ═══════ */
@media (max-width: 767px) {
  html, body {
    background-attachment: scroll;
  }

  body::before {
    opacity: 0.16;
    background-size: 22px 22px;
  }

  body.is-opening-scene {
    overflow: auto;
  }

  .sidebar {
    display: none;
  }

  .stage {
    padding: 0;
  }

  .scene {
    max-width: none;
  }

  body:not(.is-opening-scene) .scene {
    width: 100%;
  }

  .opening-scene {
    min-height: auto;
  }

  .opening-art {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    align-items: stretch;
    background:
      linear-gradient(90deg, rgba(6, 5, 7, 0.94) 0%, rgba(6, 5, 7, 0.66) 34%, rgba(6, 5, 7, 0.20) 58%, rgba(6, 5, 7, 0.08) 100%),
      url("assets/backgrounds/opening-bg.jpg") 76% center/cover no-repeat;
  }

  .opening-scroll {
    width: min(214px, 56vw);
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(28px + env(safe-area-inset-top, 0px)) 14px calc(28px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
    justify-content: center;
  }

  .opening-scroll::before,
  .opening-scroll::after {
    width: 8px;
  }

  .opening-scroll::before {
    left: -14px;
  }

  .opening-scroll::after {
    right: -14px;
  }

  .opening-mark {
    font-size: 10px;
    letter-spacing: 0.28em;
  }

  .opening-scroll h2 {
    font-size: clamp(40px, 13vw, 68px);
  }

  .opening-copy {
    max-width: none;
    font-size: 15px;
    line-height: 1.8;
  }

  .opening-copy-secondary {
    font-size: 13px;
    line-height: 1.75;
  }

  .opening-enter-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .scene-head {
    margin-bottom: 12px;
    padding: 10px 4px 0;
  }

  .scene-head h2 {
    font-size: clamp(22px, 8vw, 30px);
    line-height: 1.15;
  }

  .scene-head p {
    font-size: 14px;
    line-height: 1.7;
  }

  .panel {
    padding: 12px;
    border-radius: 16px;
  }

  .field input,
  .field select {
    min-height: 46px;
    font-size: 16px;
  }

  .photo-preview {
    min-height: 148px;
    border-radius: 18px;
  }

  .tips-grid,
  .history-list {
    grid-template-columns: 1fr;
  }

  .pattern-head,
  .history-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions > * {
    width: 100%;
  }

  .option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-card {
    padding: 12px 10px;
    border-radius: 14px;
  }

  .option-card h4 {
    font-size: 16px;
  }

  .option-card-img {
    width: 42px;
    height: 42px;
  }

  .reveal-emblem,
  .spirit-icon {
    width: 96px;
    height: 96px;
    border-radius: 22px;
  }

  .reveal-copy h3 {
    font-size: clamp(26px, 9vw, 38px);
  }

  .character-preview-panel {
    min-height: 244px;
  }
}

/* ═══════ 小屏手机（≤480px） ═══════ */
@media (max-width: 480px) {
  .sidebar {
    gap: 8px 10px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .timeline-item {
    padding: 6px 8px;
    font-size: 10px;
  }

  .opening-art {
    background:
      linear-gradient(90deg, rgba(6, 5, 7, 0.96) 0%, rgba(6, 5, 7, 0.76) 36%, rgba(6, 5, 7, 0.30) 58%, rgba(6, 5, 7, 0.12) 100%),
      url("assets/backgrounds/opening-bg.jpg") 80% center/cover no-repeat;
  }

  .opening-scroll {
    width: min(198px, 54vw);
    padding: calc(24px + env(safe-area-inset-top, 0px)) 12px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .opening-scroll h2 {
    font-size: clamp(34px, 12vw, 58px);
  }

  .opening-copy {
    font-size: 14px;
    line-height: 1.72;
  }

  .opening-copy-secondary {
    font-size: 12px;
  }

  .stage {
    padding: 0;
  }

  .panel {
    padding: 10px;
  }
  .pattern-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .pattern-card {
    flex-direction: row;
    padding: 10px 12px;
    gap: 12px;
  }
  .pattern-card-img {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 12px;
  }
  .pattern-card-info {
    text-align: left;
  }
  .showcase-emblem {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
  }

  .scene-head {
    padding: 8px 2px 0;
  }

  .scene-head h2 {
    font-size: clamp(20px, 8.8vw, 28px);
  }

  .scene-head p {
    font-size: 13px;
  }

  .tips-grid {
    gap: 8px;
  }

  .tip-card {
    padding: 12px;
  }

  .scroll-container {
    margin: 8px auto;
    border-radius: 8px;
  }

  .sidebar-foot .ghost-btn {
    padding: 7px 10px;
    font-size: 11px;
  }
}

/* ═══════ 横屏 / 平板（≥768px） ═══════ */
@media (min-width: 768px) {
  .app-shell { grid-template-columns: 240px 1fr; grid-template-rows: 1fr; }

  .sidebar {
    flex-direction: column; flex-wrap: nowrap;
    padding: 24px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-right: 1px solid var(--line); border-bottom: 0;
  }
  .brand h1 { font-size: 34px; }
  .brand-eyebrow { display: block; }
  .brand-copy { display: block; }

  .status-card {
    display: block; padding: 14px; border: 1px solid var(--line); border-radius: 18px;
    background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(16px);
  }
  .status-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
  .status-row:last-child { border-bottom: 0; }

  .timeline { flex: unset; display: grid; gap: 5px; overflow-x: visible; }
  .timeline-item { white-space: normal; padding: 10px 13px; font-size: 13px; }

  .sidebar-foot { margin-left: 0; margin-top: auto; }
  .sidebar-foot .ghost-btn { padding: 12px 18px; font-size: 14px; }

  .stage { padding: 0; }
  .scene { max-width: 900px; }

  body.is-opening-scene .stage {
    padding: 0;
  }

  .opening-art {
    padding: 0;
  }

  .opening-scroll {
    width: 300px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 54px 34px;
  }

}

.history-toggle {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
}

.share-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 180ms ease;
}

.share-btn:hover {
  background: rgba(245, 181, 74, 0.2);
  border-color: var(--accent);
}

.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: fade-in 200ms ease;
}

.share-content {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
}

.share-content h3 {
  margin-top: 0;
  font-size: 24px;
}

.share-options {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 180ms ease;
}

.share-option:hover {
  border-color: var(--accent);
  background: rgba(245, 181, 74, 0.1);
}

.share-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.share-option-text {
  flex: 1;
}

.share-option-text h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.share-option-text p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.share-link-input {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
}

.share-close-btn {
  margin-top: 16px;
  width: 100%;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: fade-in 200ms ease;
}

.preview-modal {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  transition: background 180ms ease;
}

.preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.preview-image {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  margin-top: 16px;
}

.preview-share-btn {
  top: 16px;
  right: 56px;
}

.preview-image-container {
  position: relative;
}

.preview-image-container canvas {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
}

.preview-controls {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.preview-controls button {
  flex: 1;
}

.preview-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.preview-info p {
  margin: 6px 0;
}

.preview-download {
  display: block;
  text-align: center;
  margin-top: 20px;
  width: 100%;
}

.history-page .scene-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.scene-head-left {
  flex: 1;
}

.scene-head-right {
  display: flex;
  gap: 12px;
}

.history-page .scene-head h2 {
  font-size: 28px;
}

.ghost-btn.danger {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.3);
}
.ghost-btn.danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.history-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(245, 181, 74, 0.15);
}

.history-item.selected {
  border-color: var(--accent);
  background: rgba(245, 181, 74, 0.08);
}

.history-item-select {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transition: opacity 200ms ease;
}

.history-item:hover .history-item-select,
.history-item.selected .history-item-select {
  opacity: 1;
}

.history-item-select + label {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  z-index: 9;
  transition: all 200ms ease;
}

.history-item:hover .history-item-select + label,
.history-item.selected .history-item-select + label {
  border-color: var(--accent);
}

.history-item-select:checked + label::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent);
  font-size: 14px;
  font-weight: bold;
}

.history-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.history-item-info {
  padding: 16px;
}

.history-item-info h4 {
  margin: 0 0 8px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 20px;
}

.history-item-info p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--muted);
}

.merge-badge {
  position: absolute;
  bottom: 16px;
  right: 16px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--accent);
  color: #241400;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.merge-badge:hover {
  opacity: 0.9;
}

@media (max-width: 1080px) {
  .sidebar .timeline { display: none; }
}

@media (max-width: 720px) {
  .stage {
    padding: 0;
  }

  .sidebar {
    padding: 14px 16px;
  }

  .option-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .reveal-panel,
  .tips-grid {
    grid-template-columns: 1fr;
  }

  .reveal-emblem,
  .spirit-icon {
    width: 110px;
    height: 110px;
    font-size: 44px;
  }

  .character-layout {
    gap: 14px;
  }

  .poster-layout {
    gap: 14px;
  }

  .history-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   通用卷轴表单风格基础 (用于STEP 01~05)
========================================= */
.scroll-scene {
  background-color: transparent; /* 背景透明，露出底部的图 */
  display: none; /* 默认隐藏，由 is-visible 控制显示 */
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh;
}

/* 所有卷轴页统一全屏背景 */
.scroll-scene.is-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  background-image: url("assets/backgrounds/pages-bg.png");
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}

/* input/loading 可单独换背景，目前与兜底共用同一张图 */
.scene[data-scene="input"].is-visible,
.scene[data-scene="loading"].is-visible {
  background-image: url("assets/backgrounds/pages-bg.png");
}

/* 统一控制所有页面的卷轴高度，进一步缩短，露出更多背景。并使用 margin-top 使其整体下移，避免挡住顶部背景文字 */
.scroll-container {
  width: 92%;
  max-width: 440px;
  height: 76vh !important; /* 高度进一步缩短 */
  height: 76dvh !important;
  margin: 10vh auto 0; /* 顶部增加 10vh 的外边距，使整个卷轴下移 */
  background-color: rgba(242, 234, 215, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid #dccbaf;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #dccbaf, inset 0 0 0 4px #f2ead7, inset 0 0 0 5px #c8b79f;
  color: #2b3643;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 恢复隐藏溢出，依靠内部自适应 */
  position: relative;
}

.scroll-content {
  flex: 1;
  padding: 8px 12px; /* 极限压缩内边距 */
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* 让内容在可用空间内自适应分布 */
  position: relative;
  /* 完全禁用滚动条 */
  overflow: hidden; 
}
.scroll-content::-webkit-scrollbar {
  display: none;
}

/* 顶部标题区 */
.scroll-header {
  text-align: center;
  padding: 12px 16px 8px; /* 进一步压缩头部空间 */
  border-bottom: 1px dashed #dccbaf;
  position: relative;
  flex-shrink: 0; /* 防止头部被压缩 */
}

.step-badge {
  display: inline-block;
  background-color: #112240;
  color: #e6d5b8;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.step-badge span { opacity: 0.8; }

.scroll-header h2 {
  font-size: 16px; /* 进一步缩小标题字号 */
  margin: 0 0 2px 0;
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.scroll-header .ornament {
  color: #647687;
  font-size: 14px;
  vertical-align: middle;
}

.scroll-header .subtitle {
  font-size: 10px;
  color: #647687;
  margin: 0;
}

/* 表单内容区 */
.scroll-form {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.form-group {
  margin-bottom: 12px; /* 极限压缩表单间距 */
}

.form-label {
  display: block;
  font-size: 14px; /* 稍微缩小标签字号 */
  font-weight: 600;
  color: #112240;
  margin-bottom: 6px; /* 极限压缩标签和输入框的间距 */
}
.icon-flower { color: #5a6e82; margin-right: 4px; }
.required { font-size: 12px; color: #112240; font-weight: normal; }
.optional { font-size: 12px; color: #647687; font-weight: normal; }

/* 输入框 */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid #c8b79f;
  background-color: #e8dcc4;
  border-radius: 6px;
  padding: 0 12px;
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 0;
  font-size: 16px;
  color: #112240;
  outline: none;
}
.input-wrapper input::placeholder { color: #8a96a3; }
.char-count { font-size: 14px; color: #8a96a3; }
.input-hint { font-size: 12px; color: #8a96a3; margin-top: 6px; }

/* 性别按钮 */
.gender-options {
  display: flex;
  gap: 12px;
}

.gender-btn {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  border: 1px solid #c8b79f;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  color: #2b3643;
  transition: all 0.2s ease;
  background-color: transparent;
}
.gender-btn .g-icon { margin-right: 4px; color: #8a96a3; }

.gender-btn.active {
  background-color: #112240;
  color: #e6d5b8;
  border-color: #112240;
}
.gender-btn.active .g-icon { color: #e6d5b8; }

/* 照片上传 */
.photo-upload-zone {
  border: 1px dashed #c8b79f;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background-color: rgba(232, 220, 196, 0.4);
  transition: background-color 0.2s;
  min-height: 80px; /* 大幅缩小图片上传框的高度 */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.photo-upload-zone:hover { background-color: rgba(232, 220, 196, 0.8); }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.camera-icon { font-size: 24px; color: #5a6e82; }
.upload-title { font-size: 13px; color: #112240; font-weight: 500; }
.upload-desc { font-size: 11px; color: #8a96a3; }

#photoPreviewImage {
  max-width: 100%;
  max-height: 120px;
  border-radius: 4px;
}

/* 小贴士 */
.tips-box {
  border: 1px solid #c8b79f;
  border-radius: 6px;
  padding: 16px 12px 12px;
  position: relative;
  margin-top: 16px;
}

.tips-title {
  position: absolute;
  top: -14px;
  left: 16px;
  background-color: #112240;
  color: #e6d5b8;
  padding: 4px 16px;
  border-radius: 14px;
  font-size: 13px;
  letter-spacing: 1px;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tips-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.tips-list li {
  font-size: 11px;
  color: #2b3643;
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
}
.tips-list li:last-child { margin-bottom: 0; }
.li-icon { color: #5a6e82; margin-right: 6px; font-size: 12px; line-height: 1.4; }

/* 底部按钮 */
.form-actions {
  margin-top: 16px; /* 大幅减小底部按钮与上方内容的间距 */
  text-align: center;
}

.submit-btn {
  width: 100%;
  background-color: #0c1b33;
  color: #e8dcc4;
  border: 2px solid #bda27b;
  border-radius: 30px;
  padding: 12px 0; /* 减小按钮高度 */
  font-size: 18px; /* 稍微减小字号 */
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  margin-bottom: 4px; /* 大幅减小底部间距 */
  box-shadow: inset 0 0 10px rgba(189, 162, 123, 0.2), 0 4px 15px rgba(0, 0, 0, 0.3);
  font-family: "KaiTi", "STKaiti", serif;
}
.submit-btn:active {
  transform: scale(0.98);
  background-color: #1a2c4e;
}

.back-btn {
  background: none;
  border: none;
  color: #5a6e82;
  font-size: 13px; /* 稍微缩小字号 */
  cursor: pointer;
  padding: 4px 16px; /* 缩小内边距 */
}
.back-btn:hover { color: #112240; }

/* ═══════ 第三页：命运计算 ═══════ */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-ring {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: url("assets/backgrounds/compass-placeholder.png") center/contain no-repeat, radial-gradient(circle, #112240 40%, transparent 70%);
  box-shadow: 0 0 30px rgba(17, 34, 64, 0.4);
  border: 4px solid #bda27b;
}

.progress-circle {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px dashed #8a96a3;
  animation: spin 8s linear infinite;
}

.progress-text {
  font-size: 36px;
  font-weight: 600;
  color: #f2ead7;
  font-family: "Georgia", serif;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.status-box {
  width: 100%;
  text-align: center;
  border: 1px solid #dccbaf;
  border-left: none;
  border-right: none;
  padding: 16px 0;
  margin: 16px 0 24px;
  position: relative;
}
.status-box::before, .status-box::after {
  content: "❁";
  position: absolute;
  color: #bda27b;
  font-size: 18px;
  top: 50%;
  transform: translateY(-50%);
}
.status-box::before { left: 10px; }
.status-box::after { right: 10px; }

.status-main {
  font-size: 16px;
  color: #112240;
  font-weight: 600;
  margin-bottom: 6px;
}
.status-sub {
  font-size: 12px;
  color: #647687;
}

.custom-loading-list {
  width: 100%;
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.custom-loading-list::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  border-left: 1px dashed #c8b79f;
}

.custom-loading-list li {
  position: relative;
  padding-left: 44px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #112240;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.custom-loading-list li::before {
  content: "✓";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-color: #517154;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.custom-loading-list li:last-child {
  margin-bottom: 0;
}
.custom-loading-list li:last-child::before {
  content: "";
  background-color: transparent;
  border: 2px solid #5a6e82;
}
.custom-loading-list li::after {
  content: "已完成";
  font-size: 12px;
  color: #517154;
}
.custom-loading-list li:last-child::after {
  content: "进行中...";
  color: #5a6e82;
}

.loading-footer-tip {
  margin-top: 32px;
  background-color: rgba(189, 162, 123, 0.15);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  color: #647687;
  border: 1px solid #dccbaf;
}

/* ═══════ 第四页：纹样选择 ═══════ */
.pattern-content {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

/* 顶部推荐展示区 */
.pattern-showcase {
  position: relative;
  border: 2px solid #bda27b;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(232, 220, 196, 0.7), rgba(255, 245, 230, 0.5));
  box-shadow: 0 4px 16px rgba(139, 111, 71, 0.15);
}

.showcase-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.showcase-emblem {
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: 20px;
  border: 3px solid #bda27b;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.7);
  font-size: 32px;
  color: #8a96a3;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1), inset 0 0 20px rgba(189,162,123,0.15);
}

.showcase-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  padding: 8px;
}

.showcase-info {
  flex: 1;
}

.showcase-info h3 {
  margin: 0 0 6px 0;
  font-size: 20px;
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
}

.showcase-info .reason-copy {
  font-size: 12px;
  color: #5a6e82;
  margin: 0 0 10px 0;
  line-height: 1.5;
}

.status-tag {
  display: inline-block;
  background-color: rgba(189, 162, 123, 0.2);
  color: #5a6e82;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  border: 1px solid #dccbaf;
}

.tassel-decor-side {
  position: absolute;
  right: -8px;
  top: 20px;
  width: 24px;
  height: 80px;
  background: url("assets/backgrounds/tassel-placeholder.png") center/contain no-repeat;
  pointer-events: none;
}

/* 纹样卡片网格 */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  flex: 1;
}

.pattern-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background-color: rgba(255, 255, 255, 0.3);
  border: 2px solid #dccbaf;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  overflow: hidden;
}

.pattern-card:hover {
  background-color: rgba(255, 255, 255, 0.6);
  border-color: #bda27b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 111, 71, 0.2);
}

.pattern-card.is-selected {
  background: linear-gradient(135deg, #0c1b33, #1a2c4e);
  border-color: #bda27b;
  color: #e6d5b8;
  box-shadow: 0 4px 18px rgba(17, 34, 64, 0.3), inset 0 0 0 1px rgba(189, 162, 123, 0.5);
}

.pattern-card-img {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #dccbaf;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.pattern-card.is-selected .pattern-card-img {
  border-color: rgba(189, 162, 123, 0.5);
  background-color: rgba(255, 255, 255, 0.15);
}

.pattern-card-img img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  image-rendering: pixelated;
}

.pattern-card-info {
  width: 100%;
  text-align: center;
}

.pattern-card-info h4 {
  margin: 0 0 3px 0;
  font-size: 15px;
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
}

.pattern-card.is-selected .pattern-card-info h4 {
  color: #f2ead7;
}

.pattern-card-info p {
  margin: 0;
  font-size: 11px;
  color: #647687;
  line-height: 1.3;
}

.pattern-card.is-selected .pattern-card-info p {
  color: #a3b8cc;
}

.ribbon-recommend {
  position: absolute;
  top: 6px;
  left: -20px;
  background-color: #bda27b;
  color: #fff;
  font-size: 9px;
  padding: 2px 20px;
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-hint {
  font-size: 11px;
  color: #5a6e82;
  margin-bottom: 8px; /* 压缩底距 */
}
/* ═══════ 第五页：角色预览 ═══════ */
.back-arrow-btn {
  position: absolute;
  top: 24px;
  left: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #dccbaf;
  background-color: transparent;
  color: #112240;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.back-arrow-btn:hover {
  background-color: rgba(17, 34, 64, 0.1);
}

.character-content {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.character-portrait-box {
  position: relative;
  margin: 0 auto 12px;
  width: 100%;
  max-width: 320px; /* 极大幅度增大最大宽度限制，让圆圈占满宽度 */
  flex: 1; /* 允许自适应缩放 */
  min-height: 240px; /* 极大幅度增大最小高度 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-frame {
  width: 100%;
  height: 100%;
  max-height: 320px; /* 极大幅度增大最大高度 */
  aspect-ratio: 1 / 1; /* 强制正圆比例 */
  border-radius: 50%; /* 改为正圆或者按比例的椭圆 */
  border: 4px solid #bda27b;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2), inset 0 0 20px rgba(0,0,0,0.5);
  overflow: hidden;
  background: radial-gradient(circle at center, #112240, #060b14);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.2); /* 极大幅度放大人物比例 */
  transform-origin: center top; /* 从顶部居中放大，确保脸部可见 */
}

.preview-zoom-btn {
  position: absolute;
  bottom: 0px;
  right: -10px;
  width: 56px; /* 增大按钮以防文字挤压 */
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #1a2c4e, #112240);
  border: 2px solid #bda27b;
  color: #e6d5b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  padding: 0;
  z-index: 10;
}
.zoom-icon { font-size: 16px; line-height: 1; margin-bottom: 2px; }
.zoom-text { font-size: 10px; transform: scale(0.9); }

.character-name-section {
  text-align: center;
  margin-bottom: 8px; /* 极限减小底边距 */
  padding-bottom: 8px; /* 极限减小内边距 */
  border-bottom: 1px solid #dccbaf;
}

.character-name-section h3 {
  font-size: 24px; /* 再次加大标题字号 */
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
  margin: 0 0 16px 0; /* 再次调整间距 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.character-name-section h3::before, .character-name-section h3::after {
  content: "";
  display: block;
  width: 50px; /* 再次加长装饰线 */
  height: 1px;
  background-color: #bda27b;
}

.stamp {
  display: inline-block;
  color: #c43939;
  border: 1px solid #c43939;
  font-size: 14px; /* 放大印章字号 */
  padding: 2px 4px;
  border-radius: 2px;
  transform: rotate(-5deg);
  opacity: 0.8;
  margin-left: 6px;
}

.character-tags {
  display: flex;
  justify-content: space-between; /* 拉开间距，不让字挤在一起 */
  gap: 8px; /* 间距不要过大 */
  padding: 0 12px;
}

.c-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1; /* 让每个 tag 自适应均匀分布 */
  justify-content: center;
}

.c-tag-icon {
  width: 32px; /* 再次放大图标圆圈 */
  height: 32px;
  border-radius: 50%;
  background-color: #112240;
  color: #bda27b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px; /* 再次放大图标 */
}

.c-tag-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  overflow: hidden; /* 防止文字溢出撑开 */
}

.c-tag-label {
  font-size: 12px; /* 再次加大描述文字字号 */
  color: #647687;
  line-height: 1.1;
  white-space: nowrap;
}

.c-tag-value {
  font-size: 15px; /* 再次加大字号 */
  color: #112240;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px; /* 适当放宽最大宽度，容纳更大的字 */
}

.character-desc-box {
  background-color: rgba(232, 220, 196, 0.4);
  border: 1px solid #c8b79f;
  border-radius: 8px;
  padding: 14px 14px 10px; /* 稍微恢复一点内边距让大字不显得挤 */
  position: relative;
  margin-bottom: 8px; 
}

.desc-title {
  position: absolute;
  top: -10px;
  left: 16px;
  background-color: #112240;
  color: #e6d5b8;
  padding: 2px 12px;
  border-radius: 10px;
  font-size: 13px; /* 稍微放大标题字号 */
  font-weight: 600;
}

.story-copy {
  font-size: 14px; /* 再次调大正文字号 */
  color: #2b3643;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tassel-decor-bottom {
  position: absolute;
  right: 12px;
  bottom: -30px;
  width: 30px;
  height: 80px;
  background: url("assets/backgrounds/tassel-placeholder.png") center/contain no-repeat;
  pointer-events: none;
}

.small-tips {
  margin-top: 8px;
  margin-bottom: 8px; /* 进一步压缩小贴士的下边距 */
  padding: 8px 12px; /* 进一步压缩内边距 */
}
.small-tips p {
  margin: 0;
  font-size: 12px; /* 稍微调大提示文字 */
  color: #647687;
  line-height: 1.4;
}

.dual-actions {
  display: flex;
  gap: 12px;
}

.dual-actions button {
  flex: 1;
  padding: 12px 0; /* 稍微恢复一点按钮高度 */
  border-radius: 30px;
  font-size: 15px; /* 增大按钮字号 */
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "KaiTi", "STKaiti", serif;
}

.secondary-btn {
  background-color: transparent;
  color: #112240;
  border: 1px solid #112240;
}
.secondary-btn:active { background-color: rgba(17, 34, 64, 0.05); }

/* ═══════ 第六页：灵兽选择 ═══════ */
.help-btn {
  position: absolute;
  top: 24px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #dccbaf;
  background-color: transparent;
  color: #112240;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: serif;
}

.spirit-content {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.spirit-linkage-card {
  position: relative;
  border: 1px solid #c8b79f;
  border-radius: 8px;
  padding: 6px 10px; /* 极限减小联动卡片内边距 */
  margin-bottom: 6px; /* 极限减小底边距 */
  background-color: rgba(232, 220, 196, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.linkage-emblem {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  border-radius: 16px;
  border: 2px solid #bda27b;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.7);
  font-size: 28px;
  color: #8a96a3;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}
.linkage-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  padding: 6px;
}

.linkage-info {
  flex: 1;
}

.linkage-row {
  font-size: 11px;
  margin-bottom: 4px;
  color: #2b3643;
  display: flex;
  align-items: center;
}
.linkage-row .l-icon { margin-right: 4px; color: #5a6e82; }
.linkage-row .highlight { color: #1a5336; font-weight: 600; } /* 绿色高亮 */

.linkage-hint {
  font-size: 10px;
  color: #647687;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #dccbaf;
}

.tassel-decor-side-right {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 50px;
  background: url("assets/backgrounds/tassel-placeholder.png") center/contain no-repeat;
  pointer-events: none;
}

/* 灵兽列表样式重构 */
.spirit-list-container {
  display: flex;
  flex-direction: column;
  gap: 4px; /* 极限减小间距 */
  margin-bottom: 6px; /* 极限减小底边距 */
  flex: 1;
}

.spirit-list-card {
  position: relative;
  display: flex;
  background-color: rgba(232, 220, 196, 0.6);
  border: 1px solid #c8b79f;
  border-radius: 8px;
  padding: 4px 6px; /* 极限减小内边距 */
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  align-items: center;
}
.spirit-list-card:hover {
  background-color: rgba(255, 255, 255, 0.5);
}

.spirit-list-card.is-selected {
  background: linear-gradient(to right, #0c1b33, #1a2c4e);
  border-color: #bda27b;
  color: #e6d5b8;
  box-shadow: 0 4px 15px rgba(17, 34, 64, 0.3), inset 0 0 0 1px rgba(189, 162, 123, 0.5);
}

.spirit-list-card.is-selected .s-reason,
.spirit-list-card.is-selected .s-story {
  color: #a3b8cc;
}
.spirit-list-card.is-selected h4 {
  color: #f2ead7;
}

.spirit-card-img {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.8);
  border: 2px solid #dccbaf;
  margin-right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.spirit-card-img img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  image-rendering: pixelated;
}

.spirit-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.spirit-card-info h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge-selected {
  font-size: 9px;
  background-color: #2c4c7c;
  color: #fff;
  padding: 2px 4px;
  border-radius: 10px;
  font-family: sans-serif;
  border: 1px solid rgba(255,255,255,0.2);
}

.s-reason, .s-story {
  font-size: 9px; /* 缩小字号 */
  color: #2b3643;
  margin: 0 0 2px 0; /* 缩小间距 */
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-story { color: #647687; }
.s-icon { display: inline-block; width: 12px; text-align: center; margin-right: 2px; }

.check-circle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #c8b79f;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  background-color: transparent;
  transition: all 0.2s;
}
.spirit-list-card.is-selected .check-circle {
  border-color: #f2ead7;
  color: #f2ead7;
  font-size: 14px;
}
.spirit-list-card.is-selected .check-circle::after {
  content: "✓";
}

/* ═══════ 第七页：角色海报 ═══════ */
.poster-scroll-container {
  height: 76vh !important; /* 与前面页面的卷轴保持统一的截断高度 */
  height: 76dvh !important;
  margin: 10vh auto 0 !important; /* 增加顶部边距实现整体下移 */
  border-radius: 12px;
  border: 1px solid #dccbaf;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #dccbaf, inset 0 0 0 4px #f2ead7, inset 0 0 0 5px #c8b79f;
  background-color: rgba(242, 234, 215, 0.9);
  padding-bottom: 0; /* 移除之前预留给 tab bar 的底部空白 */
}

.poster-header {
  padding-bottom: 12px;
}
.header-title-group {
  text-align: center;
}
.header-subtitle {
  font-size: 11px;
  color: #647687;
  margin-top: 4px;
}
.text-btn {
  border-radius: 16px;
  width: auto;
  padding: 0 12px;
  font-size: 13px;
}

.poster-content {
  padding: 16px;
}

.poster-ornate-wrapper {
  position: relative;
  background-color: #0c1b33;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
  border: 1px solid #c8b79f;
}
.poster-ornate-wrapper canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}
.poster-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(43, 91, 62, 0.9);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  border: 1px solid rgba(255,255,255,0.2);
}

.poster-actions-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.poster-dl-btn, .poster-save-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}
.poster-dl-btn {
  background-color: #0c1b33;
  color: #e6d5b8;
  border: 1px solid #c8b79f;
}
.poster-save-btn {
  background-color: rgba(94, 115, 88, 0.15);
  color: #2b5b3e;
  border: 1px solid #8e9e86;
}
.poster-save-btn.is-saved {
  background-color: #5e7358;
  color: #fff;
}
.btn-icon {
  font-size: 20px;
}
.btn-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.btn-text strong {
  font-size: 14px;
  font-weight: normal;
  font-family: "KaiTi", "STKaiti", serif;
}
.btn-text span {
  font-size: 9px;
  opacity: 0.8;
  margin-top: 2px;
}

.poster-history-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
}
.poster-history-header .line {
  flex: 1;
  height: 1px;
  background-color: #c8b79f;
  opacity: 0.5;
}
.poster-history-header .title-pill {
  padding: 0 16px;
  font-size: 14px;
  color: #112240;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.poster-history-header .badge {
  background-color: #4a5c73;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: normal;
}
.poster-history-header .manage-link {
  position: absolute;
  right: 0;
  font-size: 12px;
  color: #647687;
  text-decoration: none;
}

.history-scroll-row {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 8px;
  scrollbar-width: none; /* Firefox */
}
.history-scroll-row::-webkit-scrollbar {
  display: none; /* Chrome */
}
.h-scroll-card {
  flex: 0 0 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.h-scroll-img {
  width: 90px;
  height: 120px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #c8b79f;
}
.h-scroll-date {
  font-size: 10px;
  color: #647687;
}


/* ═══════ 第八页：历史记录页 ═══════ */
.history-scroll-container {
  height: 76vh !important; /* 与前面页面的卷轴保持统一的截断高度 */
  height: 76dvh !important;
  margin: 10vh auto 0 !important; /* 增加顶部边距实现整体下移 */
  border-radius: 12px;
  border: 1px solid #dccbaf;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #dccbaf, inset 0 0 0 4px #f2ead7, inset 0 0 0 5px #c8b79f;
  background-color: rgba(242, 234, 215, 0.9);
  padding-bottom: 0;
}

.history-header {
  position: relative;
  padding-bottom: 12px;
}
.history-header .back-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  background: none;
  border: none;
  color: #5a6e82;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 12px;
}
.history-header .back-btn:hover { color: #112240; }
.history-actions-top {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.history-actions-top .text-btn {
  border: 1px solid #c8b79f;
  background-color: transparent;
  color: #112240;
}
.history-actions-top .text-danger {
  color: #a33;
  border-color: rgba(170, 51, 51, 0.3);
}
.history-actions-top .text-danger:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.history-content {
  padding: 16px;
}

.history-tip {
  font-size: 12px;
  color: #647687;
  margin-bottom: 20px;
  text-align: center;
}

.history-grid-new {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-card-new {
  position: relative;
  display: flex;
  background-color: rgba(232, 220, 196, 0.6);
  border: 1px solid #c8b79f;
  border-radius: 12px;
  padding: 12px;
  gap: 16px;
  transition: all 0.2s;
  overflow: hidden;
}
.history-card-new.selected {
  background-color: rgba(255, 255, 255, 0.6);
  border-color: #2b5b3e;
  box-shadow: 0 4px 12px rgba(43, 91, 62, 0.1);
}

.history-card-img-wrapper {
  position: relative;
  flex: 0 0 80px;
  width: 80px;
  height: 106px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dccbaf;
}
.history-card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-checkbox-wrapper {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.6);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.history-card-new.selected .history-checkbox-wrapper {
  background: #2b5b3e;
  border-color: #2b5b3e;
}
.history-card-new.selected .history-checkbox-wrapper::after {
  content: "✓";
  color: #fff;
  font-size: 14px;
}
/* 隐藏原生 checkbox */
.history-card-new input[type="checkbox"] {
  display: none;
}

.history-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.history-card-info h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: #112240;
  font-family: "KaiTi", "STKaiti", serif;
}
.history-card-info p {
  margin: 0 0 4px 0;
  font-size: 12px;
  color: #647687;
}
.history-card-info .date {
  font-size: 11px;
  color: #8a96a3;
  margin-top: 4px;
}

.history-card-share {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(17, 34, 64, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 14px;
}
.history-card-share:hover {
  background: rgba(17, 34, 64, 0.1);
}

/* 离线角色预览保留原弹窗布局 */
#previewVideo { width: 100%; max-width: 640px; height: auto; display: block; background: #08233a; }
