:root {
  --void: #07090c;
  --iron: #11151a;
  --iron-raised: #192029;
  --iron-line: #45515f;
  --gold: #c5a369;
  --gold-light: #f0d397;
  --paper: #e4d7bf;
  --muted: #9aa3ad;
  --blood: #b4403d;
  --blood-light: #e06b5c;
  --green: #74aa75;
  --blue: #7f9fc8;
  --serif: Georgia, 'STZhongsong', '华文中宋', 'SimSun', serif;
  --ui: 'Segoe UI', 'Microsoft YaHei', system-ui, sans-serif;
  --reading: 'SimSun', '宋体', 'Noto Serif SC', serif;
  --shadow: 0 18px 48px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--paper);
  background: radial-gradient(circle at 75% 0, #1b2632 0, transparent 30rem), var(--void);
  font-family: var(--ui);
  line-height: 1.7;
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: '';
  pointer-events: none;
  opacity: .24;
  background-image: linear-gradient(120deg, transparent 48%, rgb(255 255 255 / .035) 49%, transparent 50%);
  background-size: 8px 8px;
}
a { color: var(--gold-light); text-decoration: none; }
a:hover { color: #fff2c8; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
::selection { color: #111; background: var(--gold-light); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; z-index: 100; top: -4rem; left: 1rem; padding: .45rem .8rem; color: #111; background: var(--gold-light); }
.skip-link:focus { top: 1rem; }

/* Global combat HUD */
.combat-hud {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto minmax(180px, .9fr);
  gap: .8rem;
  align-items: center;
  min-height: 4.7rem;
  padding: .55rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid #586879;
  background: linear-gradient(180deg, rgb(23 30 38 / .98), rgb(9 12 16 / .98));
  box-shadow: 0 7px 20px rgb(0 0 0 / .35);
}
.hud-brand { display: inline-flex; gap: .7rem; align-items: center; color: var(--gold-light); font-family: var(--serif); font-size: 1.05rem; letter-spacing: .13em; }
.hud-brand:hover { text-decoration: none; }
.hud-brand small { display: block; margin-top: -.1rem; color: var(--muted); font-family: var(--ui); font-size: .62rem; letter-spacing: .2em; }
.hud-brand-mark { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--gold); color: var(--gold); transform: rotate(45deg); }
.party-status { display: flex; gap: .35rem; align-items: center; }
.party-member { display: grid; min-width: 3.2rem; padding: .15rem .42rem .35rem; border: 1px solid #586879; color: #c5ced6; font-size: .62rem; letter-spacing: .09em; text-align: center; background: #121a22; }
.party-member::after { display: block; height: .2rem; margin-top: .22rem; content: ''; background: linear-gradient(90deg, var(--blood) 72%, #2b3948 72%); }
.member-two::after { background: linear-gradient(90deg, var(--blood) 92%, #2b3948 92%); }
.member-three::after { background: linear-gradient(90deg, var(--blood) 64%, #2b3948 64%); }
.member-four::after { background: linear-gradient(90deg, var(--blood) 83%, #2b3948 83%); }
.hud-progress { display: flex; gap: .55rem; align-items: center; color: var(--muted); font-size: .72rem; letter-spacing: .08em; white-space: nowrap; }
.hud-progress strong { color: var(--gold-light); font-family: var(--serif); font-size: .95rem; }
.hud-search { display: flex; justify-content: flex-end; }
.hud-search input { width: min(100%, 18rem); padding: .45rem .7rem; border: 1px solid #4a5968; color: var(--paper); background: #0a0e12; }
.hud-search input::placeholder { color: #6d7b87; }
.hud-search input:focus { border-color: var(--gold); outline: none; }

/* Shell and chapter navigation */
.site-shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: clamp(1rem, 2.6vw, 2.3rem); width: min(1500px, calc(100% - 2rem)); margin: 1.2rem auto 4rem; }
.waypoint-rail { position: sticky; top: 6rem; align-self: start; max-height: calc(100vh - 7.5rem); overflow: auto; padding: .8rem; border: 1px solid #3d4c5a; background: linear-gradient(145deg, #151d25, #0b0f14); box-shadow: var(--shadow); }
.waypoint-region { margin: 0 0 .8rem; padding: 0 0 .8rem; border-bottom: 1px solid rgb(115 134 151 / .22); }
.waypoint-region:last-child { margin-bottom: 0; border-bottom: 0; }
.waypoint-region > p { margin: 0 0 .25rem; color: var(--gold); font-family: var(--serif); font-size: .72rem; letter-spacing: .2em; }
.waypoint-link { position: relative; display: flex; gap: .65rem; align-items: baseline; padding: .35rem .45rem; color: #c0c7cc; font-size: .79rem; }
.waypoint-link:hover { color: var(--gold-light); background: rgb(197 163 105 / .1); }
.waypoint-link.active { color: #fff1c5; background: linear-gradient(90deg, rgb(180 64 61 / .45), transparent); }
.waypoint-stone { width: .42rem; height: .42rem; flex: 0 0 auto; border: 1px solid var(--gold); transform: rotate(45deg); }
.waypoint-link.active .waypoint-stone { background: var(--gold-light); box-shadow: 0 0 8px var(--gold); }
.waypoint-region[hidden], .waypoint-link[hidden] { display: none; }

/* Page command layer */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 17.5rem; gap: 1rem 1.2rem; align-items: start; }
.page-commandbar, .site-footer { grid-column: 1 / -1; }
.page-commandbar { display: flex; justify-content: space-between; padding: .38rem .8rem; border: 1px solid #394958; color: #8e9ba7; font-size: .72rem; letter-spacing: .11em; background: #0d131a; }
.page-commandbar span:last-child { color: var(--green); }
.quest-console { grid-column: 2; grid-row: 2; position: sticky; top: 6rem; padding: .85rem; border: 1px solid #566473; background: linear-gradient(160deg, #18212b, #0a0f14); box-shadow: var(--shadow); }
.console-heading { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: .5rem; border-bottom: 1px solid rgb(197 163 105 / .45); color: var(--gold-light); font-family: var(--serif); font-size: .9rem; letter-spacing: .08em; }
.console-heading strong { color: var(--green); font-family: var(--ui); font-size: .75rem; }
.quest-filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem; margin: .75rem 0; }
.filter-button, .btn { padding: .38rem .45rem; border: 1px solid #516172; color: #cdd4d9; background: #10171e; font-size: .7rem; }
.filter-button:hover, .filter-button.active, .btn:hover { border-color: var(--gold); color: #15110a; background: var(--gold-light); }
.quest-list { display: grid; gap: .28rem; max-height: 55vh; overflow: auto; }
.quest-item { display: grid; grid-template-columns: 1.45rem 1fr; border: 1px solid transparent; background: rgb(255 255 255 / .025); }
.quest-item:hover { border-color: #617182; }
.quest-item.complete { opacity: .6; }
.quest-item.complete a { text-decoration: line-through; }
.quest-item a { display: block; padding: .36rem .3rem .4rem 0; color: #d6d9d6; font-size: .72rem; line-height: 1.35; }
.quest-item small { display: block; color: var(--gold); font-size: .59rem; letter-spacing: .12em; }
.quest-toggle { width: 1.1rem; height: 1.1rem; margin: .45rem .18rem 0 .25rem; border: 1px solid #718091; color: #0c1319; background: transparent; line-height: .8rem; }
.quest-item.complete .quest-toggle { border-color: var(--green); background: var(--green); }
.quest-empty { color: var(--muted); font-size: .75rem; }

/* Reading log */
.journal-page { grid-column: 1; position: relative; min-width: 0; padding: clamp(1.2rem, 3vw, 2.7rem); border: 1px solid #3f4d59; background: linear-gradient(145deg, rgb(25 31 37 / .98), rgb(12 16 20 / .98)); box-shadow: var(--shadow); }
.journal-page::before, .journal-page::after { position: absolute; width: .55rem; height: .55rem; content: ''; border: 1px solid var(--gold); transform: rotate(45deg); }
.journal-page::before { top: .55rem; left: .55rem; }
.journal-page::after { right: .55rem; bottom: .55rem; }
.journal-eyebrow, .section-kicker { margin: 0 0 .35rem; color: var(--gold); font-size: .7rem; letter-spacing: .25em; }
.journal-page h1, .home-section h2 { margin: 0 0 1rem; color: #f1dcaa; font-family: var(--serif); font-size: clamp(1.65rem, 3.4vw, 2.5rem); letter-spacing: .08em; line-height: 1.25; }
.journal-page h1 { padding-bottom: 1rem; border-bottom: 2px solid var(--blood); }
.journal-page h2 { margin: 2.6rem 0 1rem; padding-bottom: .45rem; border-bottom: 1px solid rgb(197 163 105 / .38); color: var(--gold-light); font-family: var(--serif); font-size: clamp(1.3rem, 2.4vw, 1.85rem); }
.journal-page h3 { margin: 2rem 0 .7rem; color: #f0d9a6; font-family: var(--serif); font-size: 1.15rem; }
.journal-page h3::before { margin-right: .4rem; content: '◆'; color: var(--blood-light); font-size: .65rem; }
.journal-page p, .journal-page li { font-family: var(--reading); font-size: 1rem; }
.journal-page p { margin: .8rem 0; }
.journal-page li { margin: .36rem 0; }
.journal-page strong { color: #ffe0a0; }
.journal-page blockquote { margin: 1.2rem 0; padding: .8rem 1rem; border-left: 3px solid var(--blood); color: #c2c8cd; background: rgb(180 64 61 / .08); }
.journal-page code { padding: .05rem .35rem; color: #ffe0a0; background: #080c10; }
.table-wrap { overflow: auto; margin: 1rem 0; border: 1px solid #485765; }
.md-table { width: 100%; min-width: 35rem; border-collapse: collapse; }
.md-table th { padding: .65rem .75rem; color: #f0d397; font-family: var(--serif); font-weight: 400; text-align: left; background: #202a33; }
.md-table td { padding: .65rem .75rem; border-top: 1px solid rgb(116 137 155 / .22); color: #d4d9dc; }
.md-table tbody tr:hover { background: rgb(197 163 105 / .08); }
.rarity, .badge { display: inline-block; padding: .08rem .38rem; border: 1px solid currentColor; font-family: var(--ui); font-size: .72rem; }
.rarity-safe, .badge-null { color: var(--green); }
.rarity-rare, .badge-light { color: var(--blue); }
.rarity-danger, .badge-detail { color: var(--blood-light); }
.md-img { max-width: 100%; margin: 1.3rem 0; padding: .55rem; border: 1px solid #4c5c6c; background: #090d11; }
.md-img img { display: block; width: 100%; height: auto; filter: saturate(.88) contrast(1.05); }
.md-img figcaption { margin-top: .5rem; color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-align: center; }
.spoiler { margin: 1rem 0; border: 1px solid #70433e; background: #15191e; }
.spoiler summary { display: flex; align-items: center; gap: .5rem; padding: .72rem .85rem; color: #f1c1ad; cursor: pointer; background: rgb(180 64 61 / .14); }
.spoiler summary::before { content: '◆'; color: var(--blood-light); font-size: .7rem; }
.spoiler-body { padding: .1rem 1rem .8rem; }

/* Home dashboard */
.home .content { grid-template-columns: 1fr; }
.home .journal-page { grid-column: 1 / -1; padding: 0; border: 0; background: none; box-shadow: none; }
.home .journal-page::before, .home .journal-page::after { display: none; }
.hero { position: relative; min-height: min(42rem, 68vh); display: grid; align-items: end; overflow: hidden; border: 1px solid #516172; background: linear-gradient(90deg, rgb(6 9 12 / .94) 0%, rgb(6 9 12 / .68) 44%, rgb(6 9 12 / .12) 100%), url('../images/ui/hud-hero.png') center / cover; box-shadow: var(--shadow); }
.hero-copy { max-width: 42rem; padding: clamp(1.4rem, 6vw, 5rem); }
.hero-copy > p:first-child { color: var(--gold); font-size: .74rem; letter-spacing: .22em; }
.hero h1 { margin: .35rem 0 1.2rem; color: #fff0c2; font-family: var(--serif); font-size: clamp(2.5rem, 6vw, 5rem); letter-spacing: .06em; line-height: 1.08; text-shadow: 0 4px 20px #000; }
.hero-copy > p:not(:first-child) { max-width: 30rem; color: #d6d9dc; font-family: var(--reading); }
.hero-action { display: inline-block; margin-top: .8rem; padding: .65rem 1rem; border: 1px solid var(--gold-light); color: #181107; background: var(--gold-light); font-size: .82rem; letter-spacing: .12em; }
.hero-action:hover { color: #fff; border-color: var(--blood-light); background: var(--blood); }
.home-section { margin-top: 2rem; padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid #3f4d59; background: linear-gradient(145deg, #161d24, #0e1318); }
.home-section h2 { margin-bottom: 1.2rem; }
.act-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.act-progress, .chapter-card { position: relative; display: flex; flex-direction: column; justify-content: end; min-height: 11rem; overflow: hidden; padding: 1rem; border: 1px solid #4d5c69; color: #fff; background-color: #111820; background-position: center; background-size: cover; isolation: isolate; }
.act-progress::before, .chapter-card::before { position: absolute; z-index: -1; inset: 0; content: ''; background: linear-gradient(0deg, rgb(5 7 9 / .92), rgb(5 7 9 / .15)); transition: background .2s ease; }
.act-progress:hover::before, .chapter-card:hover::before { background: linear-gradient(0deg, rgb(75 19 22 / .88), rgb(5 7 9 / .05)); }
.act-one { background-image: url('../images/ui/act-one.png'); }
.act-two { background-image: url('../images/ui/act-two.png'); }
.act-three { background-image: url('../images/ui/act-three.png'); }
.act-progress span, .chapter-card span { color: var(--gold-light); font-size: .72rem; letter-spacing: .18em; }
.act-progress strong { font-family: var(--serif); font-size: 1.35rem; }
.act-progress i { display: block; width: 100%; height: .32rem; margin-top: .5rem; background: linear-gradient(90deg, var(--green) var(--progress), #34414d var(--progress)); }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .8rem; }
.chapter-card { min-height: 9.5rem; background-image: none; background-color: #17202a; }
.chapter-card.act-one { background-image: url('../images/ui/act-one.png'); }
.chapter-card.act-two { background-image: url('../images/ui/act-two.png'); }
.chapter-card.act-three { background-image: url('../images/ui/act-three.png'); }
.chapter-card strong { margin: .35rem 0; color: #fff0c2; font-family: var(--serif); font-size: 1.05rem; }
.chapter-card i { color: #bcc5cd; font-size: .7rem; font-style: normal; }
.rules-panel { border-color: #60413c; background: linear-gradient(110deg, #211719, #10161b); }
.rules-panel p:last-child { max-width: 46rem; margin-bottom: 0; color: #d3c8b9; font-family: var(--reading); }

.site-footer { display: flex; flex-wrap: wrap; gap: .65rem 1.1rem; align-items: center; padding: 1rem; color: var(--muted); border: 1px solid #3f4d59; background: #0d1217; font-size: .72rem; }
.site-footer p { margin: 0; }
.site-footer .btn:first-of-type { margin-left: auto; }

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

@media (max-width: 1050px) {
  .combat-hud { grid-template-columns: 1fr auto auto; }
  .hud-search { grid-column: 1 / -1; justify-content: stretch; }
  .hud-search input { width: 100%; }
  .site-shell { grid-template-columns: 1fr; }
  .waypoint-rail { position: relative; top: auto; display: flex; gap: .8rem; max-height: none; overflow-x: auto; }
  .waypoint-region { min-width: max-content; margin: 0; padding: 0 .8rem 0 0; border: 0; border-right: 1px solid rgb(115 134 151 / .22); }
  .content { grid-template-columns: minmax(0, 1fr) 15rem; }
}

@media (max-width: 760px) {
  .combat-hud { grid-template-columns: 1fr auto; gap: .45rem; padding: .5rem .8rem; }
  .party-status { display: none; }
  .hud-progress { font-size: .62rem; }
  .site-shell { width: min(100% - 1rem, 1500px); margin-top: .6rem; }
  .content { grid-template-columns: 1fr; }
  .page-commandbar { font-size: .61rem; }
  .quest-console { grid-column: 1; grid-row: auto; position: relative; top: auto; order: 1; }
  .journal-page { grid-column: 1; grid-row: auto; order: 2; padding: 1.1rem; }
  .site-footer { order: 3; }
  .act-overview { grid-template-columns: 1fr; }
  .hero { min-height: 31rem; background-position: 63% center; }
  .hero-copy { padding: 1.5rem; }
  .hero h1 { font-size: clamp(2.2rem, 12vw, 3.5rem); }
  .site-footer .btn:first-of-type { margin-left: 0; }
}
