:root {
  color-scheme: light;
  --ink: #2d2727;
  --ink-soft: #716463;
  --paper: #fffaf0;
  --paper-deep: #efe0c6;
  --cinnabar: #7d2632;
  --cinnabar-bright: #a5464e;
  --pine: #355b4d;
  --lake: #4f7180;
  --gold: #b8954f;
  --gold-pale: #e5d1a0;
  --night: #202a35;
  --line: rgba(91, 58, 58, .19);
  --shadow: 0 18px 44px rgba(54, 35, 35, .13);
  font-family: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  background: #dfe5df;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #dfe5df; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(116, 44, 52, .035) 1px, transparent 1px) 0 0 / 92px 100%,
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(74, 58, 53, .027) 35px),
    #e2e6df;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(184, 149, 79, .7); outline-offset: 3px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); padding: 9px 14px; background: #fff; color: var(--cinnabar); }
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px clamp(14px, 3vw, 40px);
  border-bottom: 1px solid rgba(107, 65, 65, .15);
  background: rgba(249, 245, 236, .94);
  backdrop-filter: blur(16px);
}
.brand-button { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.brand-button strong, .brand-button small { display: block; }
.brand-button strong { color: var(--cinnabar); font-size: 18px; letter-spacing: .08em; }
.brand-button small { margin-top: 2px; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 10px; }
.brand-seal, .loading-seal, .seal-small {
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  background: var(--cinnabar);
  color: #fff2d4;
  box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 4px rgba(255, 244, 218, .55);
}
.brand-seal, .loading-seal { width: 42px; height: 42px; font-size: 22px; font-weight: 700; }
.seal-small { width: 44px; height: 44px; font-size: 22px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.ghost-button, .primary-button, .secondary-button, .tab-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: "Microsoft YaHei", sans-serif;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.ghost-button { padding: 8px 13px; border-color: var(--line); background: rgba(255,255,255,.5); color: var(--ink-soft); font-size: 13px; }
.primary-button, .secondary-button { min-height: 46px; padding: 11px 22px; font-weight: 700; }
.primary-button { border-color: #65202a; background: var(--cinnabar); color: #fff9eb; box-shadow: 0 9px 21px rgba(89, 31, 40, .2); }
.secondary-button { border-color: var(--line); background: var(--paper); color: var(--cinnabar); }
.primary-button:hover, .choice-button:hover { transform: translateY(-1px); box-shadow: 0 12px 25px rgba(89, 31, 40, .25); }
.ghost-button:hover, .secondary-button:hover { border-color: rgba(125, 38, 50, .45); background: #fff; }
button:disabled { cursor: not-allowed; opacity: .58; transform: none !important; }

.save-indicator { color: var(--pine); font-family: "Microsoft YaHei", sans-serif; font-size: 12px; white-space: nowrap; }
.save-indicator.is-saving { color: #936f2c; }
.save-indicator.is-error { color: #9b3737; }
#main-content { min-height: calc(100vh - 64px); }
.app-loading { display: grid; min-height: calc(100vh - 64px); place-content: center; justify-items: center; color: var(--ink-soft); }
.app-loading[hidden] { display: none; }
.app-loading p { margin: 14px 0 0; }
.screen { width: min(1500px, 100%); min-height: calc(100vh - 64px); margin: 0 auto; }
.eyebrow { margin: 0 0 8px; color: var(--cinnabar); font-family: "Microsoft YaHei", sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .11em; }
.lead { font-size: clamp(18px, 2.1vw, 24px); line-height: 1.75; }

/* 登录：第一屏就是宫门与人物，不做营销式拆页。 */
.auth-screen { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .7fr); background: #f4eee2; }
.auth-atmosphere { position: relative; min-height: calc(100vh - 64px); overflow: hidden; background: #2f3032; color: #fff7e8; }
.auth-arch { position: absolute; inset: 0; }
.auth-arch svg { width: 100%; height: 100%; object-fit: cover; opacity: .76; }
.auth-arch::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(24,22,23,.82) 0%, rgba(33,28,29,.56) 48%, rgba(37,26,27,.18) 100%), linear-gradient(0deg, rgba(20,18,19,.6), transparent 50%); }
.auth-copy { position: relative; z-index: 2; display: flex; min-height: calc(100vh - 64px); width: min(850px, 92%); flex-direction: column; justify-content: center; padding: 48px clamp(26px, 5vw, 82px) 30px; }
.auth-copy .eyebrow { color: #e0c177; }
.auth-copy h1 { margin: 0; font-size: clamp(50px, 7vw, 92px); font-weight: 500; line-height: 1.04; letter-spacing: 0; text-shadow: 0 8px 25px rgba(0,0,0,.28); }
.hero-lead { max-width: 720px; margin: 22px 0 0; color: #f6ead6; font-size: clamp(17px, 2vw, 22px); line-height: 1.9; }
.hero-ribbon { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 24px; color: #e8d8bb; font-family: "Microsoft YaHei", sans-serif; font-size: 12px; }
.hero-ribbon span::before { content: "◆"; margin-right: 8px; color: #d3aa55; font-size: 9px; }
.ensemble-strip { display: flex; width: min(720px, 100%); align-items: flex-end; gap: clamp(2px, 1vw, 12px); margin-top: 24px; }
.ensemble-strip > div { position: relative; flex: 1 1 0; min-width: 0; text-align: center; }
.ensemble-strip svg { display: block; width: 100%; max-height: 185px; }
.ensemble-strip span { display: block; margin-top: -8px; color: #eadcc4; font-family: "Microsoft YaHei", sans-serif; font-size: 11px; }
.auth-card { align-self: center; margin: 28px clamp(18px, 3vw, 46px); padding: clamp(24px, 3vw, 38px); border-top: 4px solid var(--cinnabar); background: rgba(255, 251, 243, .96); box-shadow: var(--shadow); }
.auth-card-head { display: flex; align-items: center; gap: 14px; }
.auth-card h2 { margin: 0; color: #4b3033; font-size: clamp(26px, 3vw, 36px); font-weight: 500; }
.auth-intro { color: var(--ink-soft); line-height: 1.75; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 24px 0 20px; padding: 4px; background: #eee4d3; }
.tab-button { border: 0; background: transparent; color: var(--ink-soft); }
.tab-button.is-active { background: #fffaf0; color: var(--cinnabar); box-shadow: 0 3px 9px rgba(63,44,40,.08); }
.auth-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field span { color: #5e4d4d; font-family: "Microsoft YaHei", sans-serif; font-size: 13px; font-weight: 700; }
.field input { width: 100%; min-height: 46px; border: 1px solid #cdbdad; border-radius: 4px; background: #fffdfa; padding: 10px 12px; color: var(--ink); }
.field input::placeholder { color: #ad9d96; }
.form-error { padding: 10px 12px; border-left: 3px solid #9f3d42; background: #f9e7e4; color: #823136; font-family: "Microsoft YaHei", sans-serif; font-size: 13px; }
.form-note { margin: 0; color: #887a75; font-family: "Microsoft YaHei", sans-serif; font-size: 11px; line-height: 1.6; }

/* 命途簿 */
.lobby-screen { padding: clamp(22px, 4vw, 54px); }
.lobby-hero { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.lobby-hero h1 { margin: 0; color: #4f2a2e; font-size: clamp(36px, 5vw, 64px); font-weight: 500; }
.lobby-hero p:not(.eyebrow) { max-width: 800px; color: var(--ink-soft); font-size: 17px; line-height: 1.9; }
.lobby-seal { display: grid; width: 94px; height: 112px; flex: 0 0 auto; place-items: center; border: 2px solid var(--gold); background: var(--cinnabar); color: #fff0cf; font-size: 30px; line-height: 1.1; box-shadow: inset 0 0 0 5px var(--cinnabar), inset 0 0 0 6px rgba(255,244,215,.55); }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.lobby-progress { margin: 26px 0 0; }
.progress-line { height: 4px; overflow: hidden; background: rgba(112, 85, 76, .13); }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, var(--cinnabar), var(--gold)); transition: width .35s ease; }
.lobby-progress > div:last-child { display: flex; justify-content: space-between; gap: 14px; margin-top: 8px; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 12px; }
.lobby-columns { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(0, 1.45fr); gap: clamp(24px, 4vw, 58px); margin-top: 46px; }
.lobby-panel { min-width: 0; }
.lobby-panel h2 { margin: 0 0 20px; color: #513438; font-size: 26px; font-weight: 500; line-height: 1.4; }
.thread-list { display: grid; gap: 13px; }
.thread-row { display: grid; grid-template-columns: 12px 1fr; gap: 10px; align-items: start; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.thread-row i { width: 8px; height: 8px; margin-top: 6px; transform: rotate(45deg); background: var(--gold); }
.thread-row strong, .thread-row small { display: block; }
.thread-row strong { color: #4d3637; font-size: 15px; }
.thread-row small { margin-top: 4px; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 12px; line-height: 1.6; }
.empty-thread { color: var(--ink-soft); line-height: 1.8; }
.ending-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ending-tile { display: grid; min-height: 92px; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; padding: 13px; border: 1px solid var(--line); background: rgba(255,250,240,.7); }
.ending-tile.is-locked { filter: grayscale(.3); opacity: .66; }
.ending-mark { display: grid; width: 40px; height: 48px; place-items: center; border: 1px solid var(--gold); color: var(--cinnabar); font-size: 14px; }
.ending-tile strong { color: #513438; }
.ending-tile p { margin: 5px 0 0; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 11px; line-height: 1.5; }

/* 角色揭示 */
.reveal-screen { display: grid; place-items: center; padding: 28px; }
.reveal-card { display: grid; width: min(900px, 100%); grid-template-columns: 260px 1fr; gap: 34px; align-items: center; padding: 34px; border-top: 5px solid var(--cinnabar); background: var(--paper); box-shadow: var(--shadow); }
.reveal-art svg { width: 100%; }
.reveal-card h1 { margin: 0; color: #4f2a2e; font-size: 54px; font-weight: 500; }
.reveal-card p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.85; }
.role-notes { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 24px; }
.role-notes span { padding: 6px 9px; border-left: 2px solid var(--gold); background: #f1e6d3; color: #645553; font-family: "Microsoft YaHei", sans-serif; font-size: 11px; }

/* 游戏正文 */
.game-screen { padding: 18px clamp(12px, 2.5vw, 36px) 54px; }
.game-topbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 13px; }
.game-topbar h1 { margin: 0; color: #4c3032; font-size: clamp(25px, 3vw, 38px); font-weight: 500; }
.game-top-actions { display: flex; align-items: center; gap: 10px; }
.chapter-count { color: var(--cinnabar); font-family: "Microsoft YaHei", sans-serif; font-size: 12px; }
.game-layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.sync-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; padding: 11px 13px; border-left: 4px solid #a34742; background: #f8e8e2; color: #7c3635; font-family: "Microsoft YaHei", sans-serif; font-size: 12px; }
.sync-banner .secondary-button { min-height: 36px; padding: 7px 12px; white-space: nowrap; }
.world-panel { position: sticky; top: 86px; min-width: 0; padding: 18px; border: 1px solid var(--line); background: rgba(249,244,233,.84); }
.portrait-wrap { height: 180px; overflow: hidden; border-bottom: 1px solid var(--line); text-align: center; }
.portrait-wrap svg { height: 205px; max-width: 100%; }
.player-name { margin: 15px 0 2px; text-align: center; color: #4b2e32; font-size: 23px; }
.player-title { margin: 0 0 18px; text-align: center; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 11px; }
.world-note { margin-top: 18px; }
.world-note > span { display: block; margin-bottom: 10px; color: var(--cinnabar); font-family: "Microsoft YaHei", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.world-note > p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.8; }
.world-panel .thread-row { grid-template-columns: 8px 1fr; gap: 7px; padding-bottom: 10px; }
.world-panel .thread-row i { width: 6px; height: 6px; }
.world-panel .thread-row strong { font-size: 13px; }
.world-panel .thread-row small { font-size: 10px; }
.story-column { min-width: 0; }
.scene-frame { position: relative; height: clamp(310px, 43vw, 570px); min-height: 310px; overflow: hidden; border: 1px solid rgba(63,42,42,.22); background: #59605e; }
.scene-frame > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(17,17,20,.12), transparent 38%, rgba(27,19,21,.42)); pointer-events: none; }
.scene-topline { position: absolute; inset: 14px 14px auto; display: flex; justify-content: space-between; gap: 10px; color: #fff5df; font-family: "Microsoft YaHei", sans-serif; font-size: 11px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.scene-topline span { padding: 6px 9px; border: 1px solid rgba(255,245,224,.35); background: rgba(35,25,27,.35); backdrop-filter: blur(4px); }
.scene-cast { position: absolute; inset: auto 1.5% -9px; display: flex; align-items: flex-end; justify-content: center; gap: clamp(0px, 1.5vw, 16px); }
.scene-cast > div { width: min(22%, 205px); min-width: 108px; filter: drop-shadow(0 10px 9px rgba(28,18,21,.34)); transform-origin: bottom center; }
.scene-cast > div:nth-child(even) { transform: translateY(10px) scale(.94); }
.scene-cast svg { display: block; width: 100%; }
.story-paper { position: relative; width: min(930px, 94%); margin: -12px auto 0; padding: clamp(26px, 4.5vw, 58px) clamp(22px, 6vw, 72px) 44px; border-top: 4px solid var(--cinnabar); background:
  linear-gradient(90deg, rgba(126,49,58,.035) 1px, transparent 1px) 0 0 / 38px 100%,
  var(--paper); box-shadow: var(--shadow); }
.story-paper::before, .story-paper::after { content: ""; position: absolute; top: 0; bottom: 0; width: 6px; background: repeating-linear-gradient(0deg, var(--gold) 0 6px, transparent 6px 12px); opacity: .34; }
.story-paper::before { left: 12px; }
.story-paper::after { right: 12px; }
.paper-kicker { display: flex; justify-content: space-between; gap: 12px; color: var(--cinnabar); font-family: "Microsoft YaHei", sans-serif; font-size: 11px; }
.story-paper h2 { margin: 12px 0 24px; color: #492b2e; font-size: clamp(30px, 4vw, 46px); font-weight: 500; }
.story-text { color: #3f3534; font-size: clamp(16px, 1.55vw, 19px); line-height: 2.05; }
.story-text p { margin: 0 0 1.35em; text-indent: 2em; }
.narrative-echo { margin: 24px 0; padding: 15px 18px; border-left: 3px solid var(--gold); background: #f2e7d4; color: #655451; font-size: 14px; line-height: 1.8; }
.narrative-echo span { margin-right: 10px; color: var(--cinnabar); font-family: "Microsoft YaHei", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.choice-prompt { margin: 28px 0 14px; color: #4e3034; font-size: 18px; font-weight: 700; line-height: 1.7; }
.story-actions { margin-top: 24px; }
.continue-button { min-width: 150px; }
.choice-stack { display: grid; gap: 10px; }
.choice-button { display: grid; min-height: 62px; grid-template-columns: 38px 1fr; gap: 12px; align-items: center; width: 100%; padding: 12px 16px; border: 1px solid #d2bda9; border-radius: 4px; background: #fffdf8; cursor: pointer; text-align: left; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease; }
.choice-button:hover { border-color: rgba(125,38,50,.62); background: #fff9ef; }
.choice-index { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--gold); color: var(--cinnabar); font-family: Georgia, serif; font-size: 14px; }
.choice-button strong { color: #443537; font-size: 15px; font-weight: 600; line-height: 1.6; }

/* 结局 */
.ending-screen { display: grid; place-items: center; padding: 32px; }
.ending-card { display: grid; width: min(980px, 100%); grid-template-columns: minmax(210px, 300px) 1fr; gap: 42px; align-items: center; padding: clamp(28px, 5vw, 60px); border-top: 6px solid var(--cinnabar); background: var(--paper); box-shadow: var(--shadow); }
.ending-art svg { width: 100%; }
.ending-card h1 { margin: 0; color: #4d2a2e; font-size: clamp(42px, 6vw, 72px); font-weight: 500; }
.ending-text { color: #4c4140; font-size: 17px; line-height: 2; }
.ending-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 20px; color: var(--ink-soft); font-family: "Microsoft YaHei", sans-serif; font-size: 11px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 340px; padding: 12px 15px; border-left: 4px solid var(--gold); background: #2d2828; color: #fff8e8; box-shadow: 0 12px 30px rgba(0,0,0,.22); font-family: "Microsoft YaHei", sans-serif; font-size: 13px; }

@media (max-width: 1050px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-atmosphere { min-height: 610px; }
  .auth-copy { min-height: 610px; }
  .auth-card { width: min(650px, calc(100% - 36px)); margin: -40px auto 34px; position: relative; z-index: 3; }
  .game-layout { grid-template-columns: 205px minmax(0, 1fr); }
  .scene-cast > div { min-width: 92px; }
}

@media (max-width: 760px) {
  .site-header { min-height: 58px; padding: 7px 10px; }
  .brand-seal { width: 37px; height: 37px; font-size: 19px; }
  .brand-button strong { font-size: 16px; }
  .brand-button small { display: none; }
  .save-indicator { display: none; }
  .ghost-button { padding: 7px 9px; font-size: 11px; }
  .audio-button span:first-child { display: none; }
  #main-content, .screen { min-height: calc(100vh - 58px); }
  .auth-atmosphere, .auth-copy { min-height: 570px; }
  .auth-copy { width: 100%; padding: 42px 20px 24px; justify-content: flex-start; }
  .auth-copy h1 { font-size: 52px; }
  .hero-lead { font-size: 16px; line-height: 1.75; }
  .ensemble-strip { margin-top: auto; }
  .ensemble-strip svg { max-height: 130px; }
  .ensemble-strip span { font-size: 9px; }
  .auth-card { padding: 24px 20px; }
  .lobby-screen { padding: 22px 16px 42px; }
  .lobby-hero { align-items: flex-start; }
  .lobby-hero h1 { font-size: 37px; }
  .lobby-hero p:not(.eyebrow) { font-size: 15px; }
  .lobby-seal { width: 62px; height: 77px; font-size: 21px; }
  .lobby-columns { grid-template-columns: 1fr; margin-top: 34px; }
  .ending-grid { grid-template-columns: 1fr; }
  .reveal-card, .ending-card { grid-template-columns: 1fr; gap: 18px; padding: 24px 20px; }
  .reveal-art, .ending-art { max-width: 210px; margin: auto; }
  .reveal-card h1 { font-size: 44px; }
  .game-screen { padding: 12px 0 38px; }
  .game-topbar, .game-screen > .progress-line { margin-left: 12px; margin-right: 12px; }
  .game-topbar { align-items: center; }
  .game-topbar h1 { font-size: 25px; }
  .game-layout { display: block; margin-top: 12px; }
  .world-panel { position: static; display: grid; grid-template-columns: 64px 1fr; gap: 0 13px; margin: 0 12px 12px; padding: 10px; }
  .portrait-wrap { grid-row: 1 / span 3; width: 64px; height: 76px; border: 0; }
  .portrait-wrap svg { width: 80px; height: auto; transform: translate(-8px, -2px); }
  .player-name, .player-title { text-align: left; }
  .player-name { margin: 8px 0 1px; font-size: 18px; }
  .player-title { margin-bottom: 0; }
  .world-note { display: none; }
  .scene-frame { height: 330px; min-height: 330px; border-left: 0; border-right: 0; }
  .scene-cast { left: -4%; right: -4%; gap: 0; }
  .scene-cast > div { min-width: 78px; width: 25%; }
  .story-paper { width: calc(100% - 20px); margin-top: -8px; padding: 27px 26px 34px; }
  .story-paper::before, .story-paper::after { width: 3px; }
  .story-paper::before { left: 7px; }
  .story-paper::after { right: 7px; }
  .paper-kicker { font-size: 9px; }
  .story-paper h2 { font-size: 32px; }
  .story-text { font-size: 16px; line-height: 1.95; }
  .choice-button { grid-template-columns: 32px 1fr; padding: 11px 12px; }
  .choice-index { width: 27px; height: 27px; }
}

@media (max-width: 420px) {
  .auth-copy h1 { font-size: 44px; }
  .hero-ribbon { gap: 7px 13px; }
  .ensemble-strip > div:nth-child(4) { display: none; }
  .scene-frame { height: 300px; min-height: 300px; }
  .scene-cast > div { min-width: 70px; }
  .story-paper { padding-left: 22px; padding-right: 22px; }
  .lobby-progress > div:last-child { flex-direction: column; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
