:root {
  color-scheme: dark;
  --bg: #11100f;
  --bg-deep: #090909;
  --panel: #171614;
  --panel-raised: #1d1b18;
  --paper: #d9d0bc;
  --paper-bright: #f0e8d6;
  --muted: #918a7c;
  --faint: #625e56;
  --line: #35312b;
  --line-bright: #51493e;
  --ember: #d78342;
  --ember-bright: #f1ad63;
  --ember-dark: #7d4022;
  --blue: #7da9b2;
  --green: #81a37b;
  --danger: #c16659;
  --story-size: 18px;
  --sidebar-width: 286px;
  --topbar-height: 64px;
  --shadow: 0 24px 80px rgb(0 0 0 / 0.38);
  --font-display: Georgia, "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --font-body: "Noto Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  --font-ui: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(circle at 74% 18%, rgb(125 64 34 / 0.09), transparent 30rem),
    linear-gradient(135deg, #12110f, #0d0d0c 70%);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: repeating-linear-gradient(0deg, transparent 0 3px, rgb(255 255 255 / .018) 3px 4px);
  z-index: 50;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: -80px;
  left: 1rem;
  z-index: 200;
  padding: .7rem 1rem;
  color: #111;
  background: var(--paper-bright);
  transition: top .2s;
}
.skip-link:focus { top: 1rem; }

.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient span {
  position: absolute;
  bottom: -4rem;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--ember-bright);
  box-shadow: 0 0 6px var(--ember);
  opacity: 0;
  animation: ash-rise 13s linear infinite;
}
.ambient span:nth-child(1) { left: 12%; animation-delay: -2s; }
.ambient span:nth-child(2) { left: 28%; animation-delay: -8s; animation-duration: 18s; }
.ambient span:nth-child(3) { left: 48%; animation-delay: -5s; animation-duration: 15s; }
.ambient span:nth-child(4) { left: 67%; animation-delay: -11s; animation-duration: 20s; }
.ambient span:nth-child(5) { left: 81%; animation-delay: -1s; animation-duration: 17s; }
.ambient span:nth-child(6) { left: 93%; animation-delay: -9s; animation-duration: 14s; }
@keyframes ash-rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  15% { opacity: .5; }
  80% { opacity: .15; }
  100% { transform: translate3d(35px, -105vh, 0); opacity: 0; }
}

.cover-screen {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem 2rem;
  text-align: center;
}
.cover-screen::after {
  content: "XIII";
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -53%);
  color: transparent;
  -webkit-text-stroke: 1px rgb(217 208 188 / .035);
  font-family: var(--font-display);
  font-size: min(56vw, 38rem);
  line-height: 1;
  pointer-events: none;
  z-index: -1;
}
.cover-rule { display: flex; align-items: center; width: min(24rem, 70vw); color: var(--ember); }
.cover-rule::before, .cover-rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--ember-dark)); }
.cover-rule::after { background: linear-gradient(90deg, var(--ember-dark), transparent); }
.cover-rule span { margin: 0 1rem; }
.cover-kicker, .modal-kicker, .status-label, .ending-overline {
  margin: 1.5rem 0 .6rem;
  color: var(--ember-bright);
  font: 600 .72rem/1.3 var(--font-ui);
  letter-spacing: .22em;
  text-transform: uppercase;
}
.cover-screen h1 { margin: 0; font-family: var(--font-display); font-weight: 400; line-height: 1; letter-spacing: .12em; }
.cover-screen h1 > span { display: block; font-size: clamp(3.5rem, 10vw, 8rem); color: var(--paper-bright); text-shadow: 0 10px 40px #000; }
.cover-screen h1 > small { display: block; margin-top: 1.2rem; color: var(--ember-bright); font-size: clamp(1.05rem, 3vw, 1.7rem); letter-spacing: .48em; }
.cover-quote { margin: 2.2rem 0 .5rem; color: var(--paper); font-size: clamp(1rem, 2vw, 1.25rem); letter-spacing: .08em; }
.cover-warning { margin: 0; color: var(--muted); font-family: var(--font-ui); font-size: .78rem; }
.cover-actions { width: min(30rem, 100%); margin-top: 2.5rem; }
.button {
  border: 1px solid var(--line-bright);
  padding: .75rem 1.1rem;
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: .88rem;
  letter-spacing: .04em;
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .38; }
.button-primary { color: #17110c; background: var(--ember-bright); border-color: var(--ember-bright); font-weight: 700; }
.button-primary:hover:not(:disabled) { background: #ffc27d; border-color: #ffc27d; }
.button-secondary { color: var(--paper); background: #1b1916; }
.button-secondary:hover:not(:disabled) { color: var(--paper-bright); border-color: var(--ember); background: #211c18; }
.button-danger { color: #f4dbd6; background: #301b18; border-color: #6d3730; }
.button-danger:hover { border-color: var(--danger); background: #3b201c; }
.button-large { display: flex; align-items: center; width: 100%; min-height: 3.65rem; margin: .65rem 0; padding: .8rem 1.25rem; text-align: left; }
.button-index { width: 2.2rem; margin-right: 1rem; color: currentColor; opacity: .62; font-family: var(--font-display); font-size: .72rem; }
.button-full { width: 100%; margin-top: 1.5rem; }
.cover-minor-actions { display: flex; align-items: center; justify-content: center; gap: .7rem; margin-top: 1.4rem; color: var(--faint); }
.text-button { padding: .15rem; color: var(--muted); background: none; border: 0; border-bottom: 1px solid transparent; cursor: pointer; font-family: var(--font-ui); font-size: .78rem; }
.text-button:hover { color: var(--ember-bright); border-bottom-color: var(--ember-dark); }
.cover-footer { display: flex; gap: 1.8rem; margin-top: 3rem; color: var(--faint); font: .65rem/1.4 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; }

.game-shell { position: relative; z-index: 2; min-height: 100vh; padding-top: var(--topbar-height); padding-left: var(--sidebar-width); }
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr auto;
  align-items: center;
  background: rgb(14 13 12 / .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-brand { display: flex; align-items: baseline; gap: .8rem; padding: 0 1.5rem; font-family: var(--font-display); color: var(--paper-bright); letter-spacing: .12em; }
.topbar-brand small { color: var(--muted); font: .68rem var(--font-ui); letter-spacing: .08em; }
.topbar-progress { height: 1px; margin: 0 2rem; background: var(--line); }
.topbar-progress span { display: block; width: var(--progress); height: 1px; background: var(--ember); box-shadow: 0 0 7px var(--ember); transition: width .6s ease; }
.topbar-actions { display: flex; height: 100%; align-items: stretch; }
.topbar-button { padding: 0 1rem; color: var(--muted); border: 0; border-left: 1px solid var(--line); background: transparent; cursor: pointer; font: .74rem var(--font-ui); }
.topbar-button:hover { color: var(--paper-bright); background: rgb(255 255 255 / .025); }
.icon-button { display: grid; place-items: center; background: transparent; border: 0; cursor: pointer; }
.close-game { width: 3.3rem; border-left: 1px solid var(--line); color: var(--faint); font-size: 1.35rem; }
.sidebar-toggle { display: none; width: var(--topbar-height); height: var(--topbar-height); }
.sidebar-toggle span { display: block; width: 18px; height: 1px; margin: 2px; background: var(--paper); }

.status-panel { position: fixed; inset: var(--topbar-height) auto 0 0; z-index: 25; width: var(--sidebar-width); background: #141311; border-right: 1px solid var(--line); }
.status-scroll { height: calc(100% - 42px); padding: 1.6rem 1.5rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-bright) transparent; }
.identity-block { padding-bottom: 1.3rem; border-bottom: 1px solid var(--line); }
.identity-block .status-label { margin-top: 0; }
.identity-block h2 { margin: 0; color: var(--paper-bright); font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; }
.identity-address { margin: .25rem 0 0; color: var(--muted); font: .72rem/1.5 var(--font-ui); }
.status-section { padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.status-section .status-label { margin: 0 0 .65rem; color: var(--muted); }
.status-heading { display: flex; align-items: center; justify-content: space-between; font: .72rem var(--font-ui); }
.status-heading strong { color: var(--paper); font-weight: 500; }
.chaos-track { position: relative; display: flex; align-items: center; justify-content: space-between; height: 1.7rem; margin-top: .6rem; color: var(--faint); font: .62rem var(--font-ui); }
.chaos-track::before { content: ""; position: absolute; left: 1rem; right: 1rem; top: 50%; height: 2px; background: linear-gradient(90deg, var(--blue), var(--line-bright) 50%, var(--ember)); }
.chaos-needle { position: absolute; left: var(--chaos-position); top: calc(50% - 5px); width: 2px; height: 11px; background: var(--paper-bright); box-shadow: 0 0 6px rgb(240 232 214 / .5); transform: translateX(-1px); transition: left .45s ease; }
.status-note { margin: .25rem 0 0; color: var(--faint); font: .65rem/1.45 var(--font-ui); }
.faction-badge, .pet-card { display: flex; align-items: center; gap: .75rem; }
.faction-sigil, .pet-glyph { flex: 0 0 auto; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; color: var(--muted); border: 1px solid var(--line-bright); border-radius: 50%; font-family: var(--font-display); }
.faction-badge strong, .pet-card strong { display: block; color: var(--paper); font: 500 .82rem/1.4 var(--font-ui); }
.faction-badge small, .pet-card small { display: block; color: var(--faint); font: .62rem/1.45 var(--font-ui); }
.faction-badge.guild .faction-sigil { color: var(--ember-bright); border-color: var(--ember-dark); }
.faction-badge.council .faction-sigil { color: #a5c6cc; border-color: #425c60; }
.pet-glyph { border-radius: 3px; color: var(--ember-bright); font-size: 1.2rem; }
.bond-row { display: flex; justify-content: space-between; margin-top: .65rem; color: var(--faint); font: .62rem var(--font-ui); }
.bond-pips { color: var(--ember); letter-spacing: .12em; }
.tally-section > div { display: flex; align-items: center; justify-content: space-between; margin: .45rem 0; color: var(--muted); font: .68rem var(--font-ui); }
.tally-section strong { color: var(--paper); font-weight: 500; font-variant-numeric: tabular-nums; }
.chapter-list { margin: 0; padding: 0; list-style: none; counter-reset: chapters; }
.chapter-list li { position: relative; padding: .35rem 0 .35rem 1.5rem; color: var(--faint); font: .64rem/1.4 var(--font-ui); }
.chapter-list li::before { counter-increment: chapters; content: counter(chapters, decimal-leading-zero); position: absolute; left: 0; color: #46423c; font-size: .55rem; }
.chapter-list li.current { color: var(--ember-bright); }
.chapter-list li.complete { color: var(--muted); }
.autosave-indicator { height: 42px; margin: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); border-top: 1px solid var(--line); font: .6rem var(--font-ui); letter-spacing: .06em; }
.autosave-indicator span { width: 5px; height: 5px; margin-right: .5rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 5px var(--green); }
.autosave-indicator.saving span { animation: pulse .7s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }
.sidebar-scrim { display: none; }

.story-stage { min-height: calc(100vh - var(--topbar-height)); display: flex; flex-direction: column; }
.scene-article { width: min(820px, calc(100% - 3rem)); margin: 0 auto; padding: clamp(3rem, 7vw, 6rem) 1rem 4rem; flex: 1; }
.scene-header { margin-bottom: 2.7rem; }
.scene-meta { display: flex; gap: .55rem; color: var(--ember); font: 600 .68rem/1.4 var(--font-ui); letter-spacing: .13em; }
.scene-header h2 { margin: .8rem 0 1.2rem; color: var(--paper-bright); font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 400; line-height: 1.25; letter-spacing: .05em; }
.title-rule { display: flex; align-items: center; width: 100%; }
.title-rule::before { content: ""; width: 2.8rem; height: 2px; background: var(--ember); }
.title-rule span { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-bright), transparent); }
.story-text { color: var(--paper); font-size: var(--story-size); line-height: 2; }
.story-text p { margin: 0 0 1.35em; }
.story-text p.reveal { animation: text-reveal .48s ease both; animation-delay: var(--delay); }
@keyframes text-reveal { from { opacity: 0; transform: translateY(7px); } }
.story-text .dialogue { position: relative; padding-left: 1.2rem; color: var(--paper-bright); border-left: 1px solid var(--line-bright); }
.story-text .dialogue .speaker { display: block; margin-bottom: .15rem; color: var(--ember-bright); font: 600 .65rem var(--font-ui); letter-spacing: .1em; }
.story-text .aside { color: #aaa395; font-style: italic; }
.story-text .aside::before { content: "旁白旁註　"; color: var(--faint); font: .6rem var(--font-ui); letter-spacing: .1em; }
.story-text .meta-aside { color: #c9a27a; }
.story-text .meta-aside::before { content: "旁白越界　"; color: var(--ember); }
.story-text .system-line { padding: .65rem 1rem; color: var(--blue); background: rgb(125 169 178 / .06); border: 1px solid rgb(125 169 178 / .18); font: .78rem/1.65 var(--font-ui); letter-spacing: .04em; }
.story-text .fracture { position: relative; color: #e6c9b2; text-shadow: 1px 0 var(--ember-dark), -1px 0 #324c50; }
.story-text .player-question { margin: 2.2rem 0; padding: 1.2rem 1.4rem; color: var(--paper-bright); background: linear-gradient(135deg, rgb(215 131 66 / .09), transparent); border: 1px solid var(--ember-dark); font-size: 1.05em; }
.story-text .player-question::before { content: "這個問題不是問角色。是問你。"; display: block; margin-bottom: .55rem; color: var(--ember); font: 600 .62rem var(--font-ui); letter-spacing: .12em; }
.story-text .memory-quote { margin: 1.8rem .5rem; padding: .8rem 1.3rem; color: #c6d5d7; border-left: 2px solid var(--blue); font-style: italic; }
.choice-section { margin-top: 3.7rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }
.choice-prompt { display: flex; justify-content: space-between; margin: 0 0 1rem; color: var(--muted); font: 600 .68rem var(--font-ui); letter-spacing: .12em; }
.choice-prompt small { color: var(--faint); font-size: .58rem; font-weight: 400; }
.choices { display: grid; gap: .72rem; }
.choice-button {
  position: relative;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: .8rem;
  width: 100%;
  min-height: 3.7rem;
  padding: .8rem 1rem;
  color: var(--paper);
  text-align: left;
  background: #171614;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .93rem;
  line-height: 1.55;
  transition: border-color .2s, background .2s, transform .2s;
}
.choice-button:hover { transform: translateX(3px); color: var(--paper-bright); background: #1d1a17; border-color: var(--ember-dark); }
.choice-number { color: var(--faint); font: .67rem var(--font-display); }
.choice-arrow { color: var(--ember-dark); transition: transform .2s, color .2s; }
.choice-button:hover .choice-arrow { color: var(--ember); transform: translateX(2px); }
.choice-hint { display: block; margin-top: .2rem; color: var(--faint); font: .64rem/1.45 var(--font-ui); }
.choice-button.special { border-color: #5c422d; background: linear-gradient(90deg, rgb(215 131 66 / .07), #171614); }
.choices.locked { pointer-events: none; opacity: .55; }
.story-footer { display: flex; justify-content: space-between; padding: 1rem 2rem; color: var(--faint); border-top: 1px solid var(--line); font: .62rem var(--font-ui); }

dialog {
  max-width: none;
  color: var(--paper);
  background: transparent;
  border: 0;
  padding: 0;
}
dialog::backdrop { background: rgb(4 4 4 / .82); backdrop-filter: blur(5px); }
.modal { width: min(520px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); background: var(--panel-raised); border: 1px solid var(--line-bright); box-shadow: var(--shadow); overflow: auto; }
.modal-content, .setup-modal form { position: relative; padding: clamp(1.5rem, 4vw, 2.5rem); }
.modal-close { position: absolute; top: .7rem; right: .8rem; width: 2.2rem; height: 2.2rem; color: var(--faint); background: transparent; border: 0; cursor: pointer; font-size: 1.4rem; }
.modal-close:hover { color: var(--paper-bright); }
.modal-kicker { margin-top: 0; }
.modal h2 { margin: .25rem 0 .65rem; color: var(--paper-bright); font-family: var(--font-display); font-size: 2rem; font-weight: 400; }
.modal p { color: var(--muted); font-size: .86rem; }
.modal-intro { max-width: 42rem; }
.wide-modal { width: min(850px, calc(100% - 2rem)); }
.field-label { display: block; margin: 1.5rem 0 .45rem; color: var(--muted); font: .68rem var(--font-ui); letter-spacing: .08em; }
.setup-modal input[type="text"] { width: 100%; padding: .8rem 1rem; color: var(--paper-bright); background: #11100f; border: 1px solid var(--line-bright); border-radius: 2px; }
.address-fieldset { display: flex; gap: .5rem; margin: 1rem 0 0; padding: 0; border: 0; }
.address-fieldset legend { margin-bottom: .45rem; color: var(--muted); font: .68rem var(--font-ui); }
.address-fieldset label { flex: 1; cursor: pointer; }
.address-fieldset input { position: absolute; opacity: 0; }
.address-fieldset span { display: block; padding: .55rem; color: var(--muted); text-align: center; border: 1px solid var(--line); font: .75rem var(--font-ui); }
.address-fieldset input:checked + span { color: var(--paper-bright); border-color: var(--ember); background: rgb(215 131 66 / .08); }
.save-slots { display: grid; gap: .7rem; margin: 1.5rem 0; }
.save-slot { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: 1rem; background: #141311; border: 1px solid var(--line); }
.save-slot h3 { margin: 0; color: var(--paper); font: 500 .83rem var(--font-ui); }
.save-slot p { margin: .15rem 0 0; color: var(--faint); font: .64rem var(--font-ui); }
.save-slot-actions { display: flex; gap: .45rem; }
.save-slot-actions button { padding: .45rem .7rem; color: var(--muted); background: transparent; border: 1px solid var(--line); cursor: pointer; font: .65rem var(--font-ui); }
.save-slot-actions button:hover:not(:disabled) { color: var(--paper); border-color: var(--ember-dark); }
.save-slot-actions button:disabled { opacity: .3; cursor: not-allowed; }
.modal-action-row { display: flex; flex-wrap: wrap; gap: .7rem; }

.archive-modal { width: min(1180px, calc(100% - 2rem)); height: min(820px, calc(100vh - 2rem)); overflow: hidden; }
.archive-content { height: 100%; display: flex; flex-direction: column; }
.archive-heading { display: flex; align-items: end; justify-content: space-between; }
.archive-total { color: var(--faint); font: 1rem var(--font-ui); }
.archive-total strong { color: var(--ember-bright); font-family: var(--font-display); font-size: 2rem; font-weight: 400; }
.archive-toolbar { display: flex; align-items: end; gap: .8rem; margin: 1rem 0; padding: .8rem; background: #141311; border: 1px solid var(--line); }
.archive-toolbar label { display: grid; gap: .25rem; color: var(--faint); font: .62rem var(--font-ui); }
.archive-toolbar select { min-width: 8rem; padding: .4rem 1.6rem .4rem .55rem; color: var(--paper); background: #1d1b18; border: 1px solid var(--line-bright); }
.archive-toolbar .archive-check { display: flex; align-items: center; gap: .45rem; margin: 0 0 .45rem auto; color: var(--muted); }
.archive-layout { min-height: 0; display: grid; grid-template-columns: 1fr minmax(300px, .7fr); gap: 1rem; flex: 1; }
.ending-grid { display: grid; grid-template-columns: repeat(6, 1fr); align-content: start; gap: .4rem; padding-right: .6rem; overflow-y: auto; }
.ending-tile { aspect-ratio: 1; display: grid; place-items: center; color: #514b43; background: #141311; border: 1px solid #2c2925; cursor: pointer; font: .55rem var(--font-ui); }
.ending-tile.unlocked { color: var(--ember-bright); border-color: #624328; background: radial-gradient(circle, rgb(215 131 66 / .12), #171512); }
.ending-tile.director.unlocked::after { content: "✦"; position: absolute; margin: -2rem 0 0 2rem; color: var(--paper); }
.ending-tile { position: relative; }
.ending-tile:hover, .ending-tile.selected { border-color: var(--ember); }
.ending-preview { padding: 1.2rem 1.4rem; background: #141311; border: 1px solid var(--line); overflow-y: auto; }
.empty-preview { color: var(--faint) !important; text-align: center; margin-top: 4rem !important; }
.ending-preview .preview-id { margin: 0; color: var(--ember); font: .62rem var(--font-ui); letter-spacing: .12em; }
.ending-preview h3 { margin: .4rem 0 1rem; color: var(--paper-bright); font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; }
.ending-preview .preview-axes { display: flex; flex-wrap: wrap; gap: .35rem; }
.ending-preview .preview-axes span, .ending-axes span { padding: .25rem .45rem; color: var(--muted); background: #1e1c19; border: 1px solid var(--line); font: .58rem var(--font-ui); }
.ending-preview .preview-body { margin-top: 1.1rem; color: var(--paper); font-size: .86rem; line-height: 1.8; }

.tab-list { display: flex; gap: .3rem; margin: 1.5rem 0 1rem; border-bottom: 1px solid var(--line); }
.tab-button { padding: .65rem 1rem; color: var(--faint); background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font: .7rem var(--font-ui); }
.tab-button.active { color: var(--ember-bright); border-bottom-color: var(--ember); }
.tab-panel { display: none; max-height: 52vh; overflow-y: auto; }
.tab-panel.active { display: block; }
.codex-entry { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.codex-entry h3 { margin: 0; color: var(--paper); font: 500 .9rem var(--font-ui); }
.codex-entry p { margin: .3rem 0 0; color: var(--muted); font-size: .78rem; }
.relationship-meter { display: inline-block; margin-left: .5rem; color: var(--ember); letter-spacing: .12em; }
.locked-entry { opacity: .42; }
.transcript-content { max-height: 60vh; overflow-y: auto; }
.transcript-entry { position: relative; padding: .8rem 0 .8rem 1.5rem; border-left: 1px solid var(--line); }
.transcript-entry::before { content: ""; position: absolute; left: -3px; top: 1.2rem; width: 5px; height: 5px; border-radius: 50%; background: var(--ember-dark); }
.transcript-entry small { color: var(--faint); font: .6rem var(--font-ui); }
.transcript-entry p { margin: .15rem 0; color: var(--paper); }
.range-setting { display: grid; grid-template-columns: 1fr auto; gap: .5rem; margin: 1.5rem 0; color: var(--paper); font: .8rem var(--font-ui); }
.range-setting output { color: var(--ember-bright); }
.range-setting input { grid-column: 1 / -1; width: 100%; accent-color: var(--ember); }
.toggle-setting { display: flex; align-items: center; justify-content: space-between; padding: .9rem 0; border-top: 1px solid var(--line); font-family: var(--font-ui); }
.toggle-setting strong { display: block; color: var(--paper); font-size: .78rem; font-weight: 500; }
.toggle-setting small { display: block; color: var(--faint); font-size: .64rem; }
.toggle-setting input { width: 2.4rem; accent-color: var(--ember); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.8rem; padding-top: 1rem; border-top: 1px solid #4b2925; }
.danger-zone p { margin: 0; }

.ending-modal { width: min(780px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); background: #171512; border-color: #6b492e; }
.ending-sheet { padding: clamp(2rem, 7vw, 4.5rem); text-align: center; }
.ending-overline { margin-top: 0; }
.ending-sheet h2 { margin: .3rem 0; font-size: clamp(2rem, 6vw, 3.4rem); }
.ending-id { color: var(--ember) !important; font: .65rem var(--font-ui) !important; letter-spacing: .16em; }
.ending-axes { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin: 1.1rem 0 1.8rem; }
.ending-body { text-align: left; font-size: var(--story-size); line-height: 1.9; }
.ending-body p { color: var(--paper); font-size: 1em; }
.ending-sheet blockquote { margin: 2.2rem 0; color: var(--ember-bright); font-family: var(--font-display); font-size: 1.15rem; }
.epitaph-field { display: block; margin: 0 auto 1.5rem; max-width: 26rem; text-align: left; }
.epitaph-field span { display: block; margin-bottom: .4rem; color: var(--muted); font: .68rem var(--font-ui); letter-spacing: .06em; }
.epitaph-field input { width: 100%; padding: .7rem .9rem; color: var(--paper-bright); background: #11100f; border: 1px solid var(--line-bright); border-radius: 2px; }
.epitaph-field input:focus { border-color: var(--ember); outline: none; }
.ending-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .7rem; }
.share-hint { margin: 1.1rem 0 0; color: var(--faint); font: .64rem/1.6 var(--font-ui); }

.toast { position: fixed; z-index: 300; left: 50%; bottom: 1.5rem; transform: translate(-50%, 2rem); padding: .65rem 1rem; color: #16110d; background: var(--paper-bright); border-radius: 2px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; font: 600 .72rem var(--font-ui); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; z-index: 500; inset: 0; display: grid; place-items: center; padding: 2rem; color: #111; background: var(--paper); text-align: center; }

body.high-contrast {
  --bg: #050505; --panel: #111; --panel-raised: #151515; --paper: #f2ead8;
  --paper-bright: #fffaf0; --muted: #c2b9a7; --faint: #938a7c; --line: #514c44; --line-bright: #777064;
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }

@media (max-width: 900px) {
  :root { --sidebar-width: 280px; }
  .game-shell { padding-left: 0; }
  .topbar { grid-template-columns: var(--topbar-height) auto 1fr auto; }
  .sidebar-toggle { display: grid; }
  .topbar-progress { display: none; }
  .status-panel { transform: translateX(-101%); transition: transform .25s ease; box-shadow: 12px 0 40px rgb(0 0 0 / .5); }
  body.sidebar-open .status-panel { transform: translateX(0); }
  .sidebar-scrim { position: fixed; display: block; inset: var(--topbar-height) 0 0 0; z-index: 20; width: 100%; height: auto; opacity: 0; pointer-events: none; background: rgb(0 0 0 / .6); border: 0; transition: opacity .2s; }
  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .archive-layout { grid-template-columns: minmax(0, 1fr) minmax(270px, .8fr); }
  .ending-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 650px) {
  :root { --topbar-height: 56px; }
  .cover-screen { justify-content: flex-start; padding-top: 12vh; }
  .cover-screen h1 > small { letter-spacing: .3em; }
  .cover-footer { gap: .7rem; flex-wrap: wrap; justify-content: center; }
  .topbar { grid-template-columns: var(--topbar-height) 1fr auto; }
  .topbar-brand { padding: 0 .7rem; }
  .topbar-brand small { display: none; }
  .topbar-actions .topbar-button { display: none; }
  .close-game { width: var(--topbar-height); }
  .scene-article { width: calc(100% - 1.2rem); padding: 2.7rem .6rem 3rem; }
  .scene-header { margin-bottom: 2rem; }
  .scene-header h2 { font-size: 2.15rem; }
  .story-text { line-height: 1.9; }
  .choice-button { grid-template-columns: 1.5rem 1fr auto; padding: .75rem; }
  .story-footer { padding: .8rem 1rem; }
  .modal { width: calc(100% - 1rem); max-height: calc(100vh - 1rem); }
  .archive-modal { height: calc(100vh - 1rem); }
  .archive-layout { display: block; overflow-y: auto; }
  .ending-grid { grid-template-columns: repeat(5, 1fr); max-height: 42vh; padding: 0 0 .8rem; }
  .ending-preview { min-height: 16rem; }
  .archive-toolbar { flex-wrap: wrap; }
  .archive-toolbar label { flex: 1; }
  .archive-toolbar select { min-width: 0; width: 100%; }
  .archive-toolbar .archive-check { flex-basis: 100%; margin: .3rem 0 0; }
  .save-slot { grid-template-columns: 1fr; }
  .save-slot-actions button { flex: 1; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .ending-sheet { padding: 2rem 1.25rem; }
}

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