:root {
  --ink: #211d18;
  --ink-soft: #4e4336;
  --paper: #efe4ca;
  --paper-deep: #ddcba5;
  --gold: #c8993e;
  --gold-light: #e4c57d;
  --red: #8e3029;
  --red-dark: #5f201c;
  --night: #15120f;
  --line: rgba(158, 112, 35, 0.6);
  --shadow: 0 18px 56px rgba(22, 15, 9, 0.3);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  color: var(--ink);
  background: var(--night);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-width: 320px;
  background: #0d0b09;
}

button, input { font: inherit; }

button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #16120e;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  padding: 10px clamp(18px, 4vw, 64px);
  display: grid;
  grid-template-columns: 1fr minmax(220px, 420px) 1fr;
  align-items: center;
  gap: 24px;
  color: #f7efd9;
  background: rgba(18, 15, 12, 0.96);
  border-bottom: 1px solid rgba(210, 168, 82, 0.45);
  backdrop-filter: blur(12px);
}

.is-hidden { display: none !important; }

.brand-button {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #1f1a14;
  background: var(--gold-light);
  border-radius: 50%;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 26px;
}

.brand-button strong, .brand-button small { display: block; }
.brand-button strong { letter-spacing: 0.12em; }
.brand-button small { margin-top: 2px; color: #cdbd9c; font-size: 11px; letter-spacing: 0.08em; }

.header-progress { display: flex; align-items: center; gap: 14px; color: #d9cbae; font-size: 13px; }
.progress-track { flex: 1; height: 5px; overflow: hidden; background: #4c4032; border-radius: 99px; }
.progress-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #b88835, #edd397); transition: width 300ms ease; }

.header-actions { justify-self: end; display: flex; gap: 10px; }
.text-button, .footer-link {
  color: #efe3c7;
  background: transparent;
  border: 1px solid rgba(218, 181, 103, 0.6);
  border-radius: 6px;
  padding: 9px 14px;
}
.text-button:hover, .text-button:focus-visible { background: rgba(216, 177, 96, 0.12); }

.screen { min-height: calc(100vh - 112px); }

.app-footer {
  min-height: 40px;
  padding: 8px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #b9aa90;
  background: #12100d;
  border-top: 1px solid rgba(210, 168, 82, 0.25);
  font-size: 12px;
}
.footer-link { padding: 3px 0; border: 0; border-bottom: 1px solid currentColor; border-radius: 0; }

.landing, .briefing, .success-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #f8f0dc;
  background-position: center;
  background-size: cover;
}

.landing { background-image: linear-gradient(90deg, rgba(18, 14, 11, 0.82) 0%, rgba(18, 14, 11, 0.46) 54%, rgba(18, 14, 11, 0.28)), url("assets/hero.webp"); }
.briefing { background-image: linear-gradient(90deg, rgba(11, 9, 8, 0.9), rgba(11, 9, 8, 0.35)), url("assets/archive.webp"); }
.success-screen { background-image: linear-gradient(90deg, rgba(12, 10, 8, 0.82), rgba(12, 10, 8, 0.36)), url("assets/hero.webp"); }

.frame {
  position: absolute;
  inset: 22px;
  pointer-events: none;
  border: 1px solid rgba(219, 177, 91, 0.8);
}
.frame::after { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(219, 177, 91, 0.45); }

.landing-content, .briefing-content, .success-content {
  position: relative;
  z-index: 2;
  width: min(1120px, calc(100% - 80px));
}

.landing-content { display: grid; grid-template-columns: minmax(0, 720px) minmax(240px, 320px); gap: 56px; align-items: end; }

.kicker, .eyebrow {
  margin: 0 0 14px;
  color: var(--gold-light);
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.display-title {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(64px, 8vw, 116px);
  font-weight: 500;
  letter-spacing: 0.13em;
  text-shadow: 0 7px 22px rgba(0,0,0,0.35);
}

.landing-subtitle { margin: 22px 0 8px; font-size: clamp(22px, 2.4vw, 34px); letter-spacing: 0.04em; }
.landing-description { max-width: 680px; margin: 0; color: #ded2bc; font-size: 16px; line-height: 1.9; }

.landing-actions { display: flex; gap: 14px; margin-top: 34px; flex-wrap: wrap; }
.primary-button, .secondary-button, .option-button {
  min-height: 52px;
  padding: 13px 24px;
  border-radius: 7px;
  border: 1px solid var(--gold);
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}
.primary-button { color: #201b15; background: #ead9ae; }
.primary-button:hover, .primary-button:focus-visible { transform: translateY(-2px); background: #f5e8c6; }
.primary-button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }
.secondary-button { color: #f3e8ce; background: rgba(16, 13, 10, 0.72); }
.secondary-button:hover, .secondary-button:focus-visible { background: rgba(153, 103, 36, 0.28); }

.investigator-card {
  padding: 26px;
  color: #30281f;
  background: rgba(239, 228, 202, 0.94);
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.investigator-card label { display: block; font-weight: 700; margin-bottom: 10px; }
.investigator-card input { width: 100%; padding: 12px; border: 1px solid #9f8151; border-radius: 5px; background: rgba(255,255,255,0.72); color: var(--ink); }
.investigator-card small { display: block; margin-top: 9px; color: #6a5945; line-height: 1.5; }
.resume-note { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid rgba(111, 76, 27, 0.25); color: #6f4b20; font-size: 13px; }

.briefing-content { max-width: none; justify-self: center; }
.briefing-content > .kicker,
.briefing-content > h1,
.briefing-card { width: min(860px, 100%); }
.briefing-content h1, .success-content h1 { margin: 0 0 18px; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(46px, 6vw, 78px); font-weight: 500; }
.briefing-card { padding: 30px 34px; background: rgba(20, 16, 12, 0.7); border: 1px solid rgba(214, 173, 90, 0.72); border-radius: 10px; box-shadow: var(--shadow); }
.briefing-card p { margin: 0 0 16px; color: #eee2ca; font-size: 18px; line-height: 1.9; }
.briefing-note { color: #d5b66f !important; font-size: 14px !important; }

.paper-screen {
  min-height: calc(100vh - 112px);
  padding: clamp(30px, 5vw, 70px) clamp(20px, 6vw, 92px);
  background:
    linear-gradient(rgba(245, 237, 217, 0.93), rgba(232, 216, 183, 0.95)),
    url("assets/archive.webp") center/cover fixed;
}

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.section-heading h1 { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(42px, 5vw, 68px); font-weight: 500; }
.section-heading p { max-width: 620px; margin: 10px 0 0; color: #6b5636; font-size: 17px; line-height: 1.7; }
.chapter-tag { display: inline-block; margin-bottom: 9px; padding: 7px 15px; color: #f3e5c5; background: #2d2822; border-radius: 5px; font-family: "Microsoft YaHei", sans-serif; font-weight: 700; }

.mission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.mission-card {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: end;
  padding: 24px;
  color: #fff7e6;
  background-position: center;
  background-size: cover;
  border: 1px solid #a4742c;
  border-radius: 9px;
  box-shadow: 0 12px 28px rgba(79, 50, 18, 0.18);
  isolation: isolate;
  text-align: left;
}
.mission-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(20,15,11,0.92), rgba(20,15,11,0.18)); }
.mission-card:hover, .mission-card:focus-visible { transform: translateY(-2px); box-shadow: 0 17px 36px rgba(79, 50, 18, 0.27); }
.mission-card.complete { border-color: #762c27; }
.mission-number { color: var(--gold-light); font-family: "Microsoft YaHei", sans-serif; font-size: 13px; font-weight: 800; letter-spacing: 0.12em; }
.mission-card h2 { margin: 8px 0 5px; font-size: 27px; }
.mission-card p { margin: 0; color: #e1d5be; line-height: 1.55; }
.status-chip { position: absolute; top: 16px; right: 16px; padding: 6px 10px; color: #2d2116; background: #ead6a5; border-radius: 99px; font-size: 12px; font-weight: 700; }

.final-entry { margin-top: 28px; padding: 24px 26px; display: flex; align-items: center; justify-content: space-between; gap: 30px; background: rgba(249,241,221,0.78); border: 1px solid #aa7c35; border-radius: 9px; }
.final-entry h2 { margin: 0 0 6px; font-size: 24px; }
.final-entry p { margin: 0; color: #67533a; }

.task-screen {
  position: relative;
  min-height: calc(100vh - 112px);
  display: grid;
  align-items: end;
  padding: clamp(30px, 5vw, 72px) clamp(20px, 6vw, 94px);
  color: #fff8e8;
  background-position: center;
  background-size: cover;
  isolation: isolate;
}
.task-screen::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10,8,6,0.3), rgba(10,8,6,0.82)); }
.task-panel { width: min(1180px, 100%); margin: 0 auto; }
.task-meta { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 14px; }
.task-meta .chapter-tag { margin: 0; }
.source-badge { color: #e6d2a8; font-size: 12px; background: rgba(18,14,10,0.62); padding: 8px 12px; border: 1px solid rgba(215,170,80,0.55); border-radius: 5px; }
.task-title { margin: 0; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(42px, 5vw, 66px); font-weight: 500; }
.task-intro { margin: 9px 0 23px; color: #e9ddc7; font-size: 18px; }
.question-panel { padding: 24px; background: rgba(25, 19, 14, 0.84); border: 1px solid rgba(211, 164, 73, 0.82); border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.question-panel h2 { margin: 0 0 18px; font-size: clamp(23px, 2.5vw, 32px); font-weight: 600; }
.options-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.option-button { min-height: 76px; color: #fbf2df; background: rgba(41,32,24,0.86); text-align: left; font-size: 16px; line-height: 1.5; }
.option-button:hover, .option-button:focus-visible { background: rgba(146,91,39,0.6); transform: translateY(-2px); }
.task-tools { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 16px; }
.task-tools-left { display: flex; gap: 10px; }
.hint-box, .feedback-box { margin-top: 14px; padding: 13px 16px; border-radius: 6px; line-height: 1.65; }
.hint-box { color: #32281c; background: #ead9ae; }
.feedback-box { color: #ffe7df; background: rgba(125,39,31,0.9); border: 1px solid #d28b78; }

.evidence-reveal { padding: 26px; color: #31281f; background: rgba(244,233,209,0.96); border: 1px solid #ae7f36; border-radius: 10px; box-shadow: var(--shadow); }
.evidence-reveal .evidence-code { color: var(--red); font-family: "Microsoft YaHei", sans-serif; font-weight: 800; letter-spacing: 0.08em; }
.evidence-reveal h2 { margin: 8px 0 12px; font-family: "STKaiti", "KaiTi", serif; font-size: 40px; }
.evidence-reveal p { max-width: 850px; line-height: 1.8; }
.evidence-strength { display: inline-block; margin: 8px 0 20px; padding: 7px 12px; color: #fff5e5; background: var(--red); border-radius: 4px; font-size: 13px; font-weight: 700; }

.final-screen { min-height: calc(100vh - 112px); padding: clamp(34px, 5vw, 70px) clamp(20px, 6vw, 92px); background: linear-gradient(rgba(239,228,202,0.94),rgba(233,218,187,0.95)), url("assets/mural.webp") center/cover; }
.evidence-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 22px 0 30px; }
.evidence-mini { padding: 17px; background: rgba(255,250,235,0.72); border: 1px solid #b28a4e; border-radius: 7px; }
.evidence-mini b { display: block; color: var(--red); margin-bottom: 7px; }
.final-options { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 15px; }
.final-options .option-button { color: #fff8ea; background: #2e2923; text-align: center; font-size: 18px; }

.success-content { max-width: 1120px; }
.success-content > p { max-width: 700px; color: #eadfc9; font-size: 18px; line-height: 1.8; }
.report-paper { margin-top: 26px; padding: clamp(22px, 3vw, 36px); color: var(--ink); background: rgba(245,235,212,0.96); border: 1px solid var(--gold); border-radius: 9px; box-shadow: var(--shadow); }
.report-header { display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px solid #aa8750; padding-bottom: 18px; }
.report-header h2 { margin: 0; font-size: 30px; }
.report-id { text-align: right; color: #705b3b; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin: 22px 0; }
.metric { padding: 16px; background: rgba(225,207,168,0.56); border-radius: 6px; }
.metric span { display: block; color: #705b3b; font-size: 12px; margin-bottom: 8px; }
.metric strong { font-family: "Microsoft YaHei", sans-serif; font-size: 24px; }
.report-evidence { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.report-evidence p { margin: 0; padding: 12px 14px; border-left: 3px solid var(--red); background: rgba(255,255,255,0.42); }
.report-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

.dialog-panel {
  width: min(760px, calc(100% - 30px));
  max-height: min(82vh, 820px);
  padding: 0;
  color: var(--ink);
  background: #eee2c7;
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 24px 90px rgba(0,0,0,0.55);
}
.dialog-panel::backdrop { background: rgba(8,6,5,0.76); backdrop-filter: blur(3px); }
.dialog-wide { width: min(980px, calc(100% - 30px)); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 22px 26px; background: #2b251e; color: #fff2d6; border-bottom: 1px solid var(--gold); }
.dialog-header h2 { margin: 0; font-size: 28px; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.icon-button { width: 38px; height: 38px; color: #fff2d6; background: transparent; border: 1px solid rgba(223,186,110,0.62); border-radius: 50%; font-size: 24px; }
.evidence-list, .sources-content { padding: 24px 26px 30px; overflow: auto; }
.evidence-item { display: grid; grid-template-columns: 72px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid rgba(125,91,41,0.3); }
.evidence-item:last-child { border-bottom: 0; }
.evidence-icon { width: 62px; height: 62px; display: grid; place-items: center; color: #fff1d6; background: var(--red-dark); border-radius: 50%; font-weight: 800; }
.evidence-item h3 { margin: 0 0 6px; }
.evidence-item p { margin: 0; color: #67543b; line-height: 1.65; }
.evidence-item.locked { opacity: 0.5; }
.sources-content section { margin-bottom: 24px; }
.sources-content h3 { margin-bottom: 8px; color: var(--red-dark); }
.sources-content p, .sources-content li { line-height: 1.8; }
.help-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; background: rgba(139,98,36,0.3); }
.help-grid article { padding: 26px; background: #efe4ca; }
.help-grid b { color: var(--red); font-size: 30px; }
.help-grid h3 { margin: 8px 0; }
.help-grid p { margin: 0; color: #68563e; line-height: 1.65; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 380px; padding: 13px 18px; color: #fff4dd; background: rgba(33,27,21,0.96); border: 1px solid var(--gold); border-radius: 7px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr auto; height: auto; }
  .header-progress { order: 3; grid-column: 1 / -1; }
  .landing-content { grid-template-columns: 1fr; align-items: center; padding: 80px 0; }
  .investigator-card { max-width: 430px; }
  .mission-grid, .report-evidence { grid-template-columns: 1fr; }
  .options-grid, .final-options { grid-template-columns: 1fr; }
  .evidence-strip, .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .final-entry { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .frame { inset: 10px; }
  .landing-content, .briefing-content, .success-content { width: calc(100% - 36px); }
  .display-title { font-size: 56px; }
  .header-actions { gap: 5px; }
  .text-button { padding: 8px 9px; font-size: 12px; }
  .brand-button small { display: none; }
  .paper-screen, .task-screen, .final-screen { padding: 28px 16px; }
  .evidence-strip, .metrics-grid, .help-grid { grid-template-columns: 1fr; }
  .task-meta, .section-heading, .report-header { align-items: flex-start; flex-direction: column; }
  .task-tools { align-items: stretch; flex-direction: column; }
}

@media print {
  body { background: #fff; }
  .app-header, .app-footer, .frame, .report-actions, .success-content > .eyebrow, .success-content > h1, .success-content > p { display: none !important; }
  .success-screen { display: block; min-height: auto; padding: 0; color: #000; background: #fff; }
  .success-content { width: 100%; max-width: none; }
  .report-paper { margin: 0; box-shadow: none; border: 1px solid #777; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
