:root {
  color-scheme: dark;
  --ink: #211a14;
  --paper: #ddd0b5;
  --paper-deep: #c5b38f;
  --paper-light: #eee5d1;
  --night: #17120e;
  --night-soft: #211a14;
  --red: #9d3028;
  --red-bright: #c34a39;
  --gold: #bd9b57;
  --muted: #9b8e78;
  --line: rgba(197, 179, 143, 0.22);
  --font-body: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --font-display: "STKaiti", "Kaiti SC", "KaiTi", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--night);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper-light);
  background:
    radial-gradient(circle at 48% 18%, rgba(112, 74, 38, 0.18), transparent 33rem),
    linear-gradient(145deg, #110e0b 0%, #1b1510 45%, #100d0b 100%);
  font-family: var(--font-body);
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.grain {
  position: fixed;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

[hidden] {
  display: none !important;
}

.title-screen {
  position: relative;
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 48px 24px;
  isolation: isolate;
  text-align: center;
}

.title-screen::before {
  position: absolute;
  z-index: -2;
  width: min(75vw, 840px);
  aspect-ratio: 1;
  border: 1px solid rgba(189, 155, 87, 0.08);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 36px, rgba(189, 155, 87, 0.025) 37px 38px),
    radial-gradient(circle, rgba(116, 76, 36, 0.13), transparent 62%);
  content: "";
}

.title-screen::after {
  position: absolute;
  z-index: -1;
  bottom: 0;
  width: 100%;
  height: 38%;
  background:
    linear-gradient(to top, rgba(12, 10, 8, 0.9), transparent),
    repeating-linear-gradient(165deg, transparent 0 72px, rgba(201, 176, 125, 0.025) 74px 75px);
  clip-path: polygon(0 68%, 9% 44%, 18% 69%, 29% 28%, 38% 62%, 49% 36%, 58% 72%, 70% 29%, 79% 55%, 89% 25%, 100% 61%, 100% 100%, 0 100%);
  content: "";
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.title-mark {
  position: absolute;
  top: calc(50% - 225px);
  margin-left: 300px;
  transform: rotate(8deg);
  border: 2px solid rgba(157, 48, 40, 0.7);
  color: rgba(157, 48, 40, 0.76);
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
  padding: 8px;
}

.title-screen h1 {
  margin: 18px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 12vw, 8.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.08em;
  text-shadow: 0 12px 38px rgba(0, 0, 0, 0.52);
}

.title-subtitle {
  margin: 0 0 44px;
  color: #bcae98;
  font-size: 1rem;
  line-height: 2;
  letter-spacing: 0.18em;
}

.primary-button {
  display: inline-flex;
  min-width: 190px;
  border: 1px solid #b34a3d;
  background: linear-gradient(135deg, #8d2b26, #ad3e32);
  box-shadow: 0 12px 28px rgba(79, 17, 13, 0.3), inset 0 1px rgba(255, 255, 255, 0.08);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 13px 27px;
  transition: transform 180ms ease, background 180ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #a0342d, #c04a3b);
}

.primary-button small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
}

.primary-button.compact {
  min-width: 0;
  padding: 10px 18px;
}

.text-button {
  margin-top: 16px;
  border: 0;
  border-bottom: 1px solid rgba(189, 155, 87, 0.45);
  color: #c7b99f;
  background: transparent;
  cursor: pointer;
  padding: 6px 4px;
}

.title-note {
  position: absolute;
  bottom: 28px;
  margin: 0;
  color: #6e6254;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
}

.game-screen {
  min-height: 100vh;
}

.game-header {
  display: grid;
  height: 76px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 13, 10, 0.82);
  backdrop-filter: blur(14px);
  align-items: center;
  grid-template-columns: 1fr auto 1fr;
  padding: 0 34px;
}

.brand {
  display: flex;
  width: max-content;
  border: 0;
  color: #b9ad98;
  background: transparent;
  cursor: pointer;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.12em;
}

.brand-seal {
  display: grid;
  width: 31px;
  height: 31px;
  border: 1px solid var(--red-bright);
  color: var(--red-bright);
  place-items: center;
}

.chapter-heading {
  text-align: center;
}

.chapter-heading span,
.chapter-heading strong {
  display: block;
}

.chapter-heading span {
  margin-bottom: 4px;
  color: #756958;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
}

.chapter-heading strong {
  color: #cbbda4;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.icon-button {
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #7f725e;
  background: transparent;
  cursor: pointer;
}

.icon-button.active {
  border-color: var(--gold);
  color: var(--gold);
}

.game-layout {
  display: grid;
  min-height: calc(100vh - 76px);
  grid-template-columns: minmax(210px, 260px) minmax(420px, 780px) minmax(200px, 260px);
  justify-content: center;
}

.status-panel,
.chronicle-panel {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  align-self: start;
  overflow: auto;
  padding: 42px 28px;
}

.status-panel {
  border-right: 1px solid var(--line);
}

.chronicle-panel {
  border-left: 1px solid var(--line);
}

.identity-card {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.identity-card h2 {
  margin: 10px 0 8px;
  font-family: var(--font-body);
  font-size: 2.15rem;
  font-weight: 400;
}

.identity-card p:last-child {
  margin: 0;
  color: #9a8d77;
  font-size: 0.74rem;
  line-height: 1.8;
}

.meters {
  display: grid;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}

.meter-heading {
  display: flex;
  color: #8f806b;
  font-size: 0.72rem;
  justify-content: space-between;
  letter-spacing: 0.12em;
}

.meter-heading b {
  color: #c9b997;
  font-weight: 500;
}

.meter-track {
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  background: #30271e;
}

.meter-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 500ms ease;
}

.danger .meter-track i {
  background: var(--red-bright);
}

.conscience .meter-track i {
  background: #7c9271;
}

.action-counter {
  display: flex;
  padding: 26px 0;
  color: var(--muted);
  font-size: 0.72rem;
  align-items: center;
  justify-content: space-between;
}

.action-pips {
  display: flex;
  gap: 6px;
}

.action-pips i {
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  border: 1px solid #614e34;
}

.action-pips i.full {
  border-color: var(--gold);
  background: var(--gold);
}

.evidence-button {
  display: flex;
  width: 100%;
  border: 1px solid var(--line);
  color: #8f806b;
  background: rgba(255, 255, 255, 0.018);
  cursor: pointer;
  padding: 12px 13px;
  justify-content: space-between;
  transition: border-color 180ms ease, color 180ms ease;
}

.evidence-button:hover {
  border-color: rgba(189, 155, 87, 0.5);
  color: #c7b99f;
}

.evidence-button b {
  color: var(--red-bright);
  font-weight: 500;
}

.story-panel {
  position: relative;
  padding: 44px clamp(34px, 6vw, 84px) 80px;
  background:
    linear-gradient(rgba(23, 18, 14, 0.93), rgba(23, 18, 14, 0.96)),
    repeating-linear-gradient(90deg, transparent 0 32px, rgba(189, 155, 87, 0.025) 33px 34px);
}

.scene-meta {
  display: flex;
  margin-bottom: 44px;
  color: #9a8d77;
  font-size: 0.67rem;
  justify-content: space-between;
  letter-spacing: 0.14em;
}

.scene-meta span:first-child::before {
  color: var(--red-bright);
  content: "◆";
  margin-right: 9px;
  font-size: 0.54rem;
}

.story-content {
  animation: reveal 420ms ease both;
}

.story-content h2 {
  margin: 0 0 24px;
  color: #e3d6bd;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.06em;
}

.story-content p {
  margin: 0 0 19px;
  color: #b2a58f;
  font-size: 0.94rem;
  line-height: 2.05;
  text-align: justify;
}

.story-content p:first-of-type::first-letter {
  float: left;
  margin: 0.1em 0.15em 0 0;
  color: var(--red-bright);
  font-family: var(--font-display);
  font-size: 3.4em;
  line-height: 0.8;
}

.story-content blockquote {
  position: relative;
  margin: 28px 0;
  border-left: 2px solid var(--red);
  color: #d1c2a8;
  background: rgba(157, 48, 40, 0.06);
  font-size: 0.9rem;
  line-height: 1.9;
  padding: 14px 20px;
}

.story-content .speaker {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
}

.story-content .ending-title {
  margin-top: 60px;
  color: var(--red-bright);
  text-align: center;
}

.story-content .ending-copy {
  color: #d3c5ac;
  font-size: 1rem;
  text-align: center;
}

.choices {
  display: grid;
  margin-top: 42px;
  animation: reveal 500ms 120ms ease both;
  gap: 12px;
}

.choice-button {
  display: grid;
  width: 100%;
  border: 1px solid rgba(197, 179, 143, 0.2);
  color: #c9bca5;
  background: rgba(255, 255, 255, 0.018);
  cursor: pointer;
  grid-template-columns: 34px 1fr auto;
  padding: 15px 16px;
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.choice-button:hover {
  transform: translateX(4px);
  border-color: rgba(189, 155, 87, 0.55);
  background: rgba(189, 155, 87, 0.045);
}

.choice-number {
  color: var(--red-bright);
}

.choice-cost {
  color: #9a8d77;
  font-size: 0.66rem;
}

.choice-button[disabled] {
  cursor: not-allowed;
  opacity: 0.38;
}

.choice-button[disabled]:hover {
  transform: none;
  border-color: rgba(197, 179, 143, 0.2);
}

.event-log {
  display: grid;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  gap: 24px;
}

.event-log li {
  position: relative;
  color: #968a75;
  font-size: 0.7rem;
  line-height: 1.7;
  padding-left: 17px;
}

.event-log li::before {
  position: absolute;
  top: 0.65em;
  left: 0;
  width: 5px;
  height: 5px;
  border: 1px solid #73503b;
  transform: rotate(45deg);
  content: "";
}

.event-log time {
  display: block;
  margin-bottom: 3px;
  color: #9b8c75;
  font-size: 0.62rem;
}

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid rgba(189, 155, 87, 0.35);
  color: #cfc0a7;
  background: #1d1712;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65);
  padding: 0;
}

dialog::backdrop {
  background: rgba(10, 8, 6, 0.78);
  backdrop-filter: blur(5px);
}

.dialog-heading {
  display: flex;
  border-bottom: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
}

.dialog-heading h2,
.confirm-dialog h2 {
  margin: 5px 0 0;
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 400;
}

.close-button {
  border: 0;
  color: #776a59;
  background: transparent;
  cursor: pointer;
  font-size: 1.8rem;
}

.evidence-list {
  display: grid;
  max-height: 60vh;
  overflow: auto;
  padding: 24px 28px 32px;
  gap: 12px;
}

.dossier-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
}

.dossier-tab {
  min-height: 46px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  letter-spacing: 0.14em;
}

.dossier-tab:hover,
.dossier-tab.active {
  border-bottom-color: var(--red-bright);
  color: var(--paper-light);
}

.dossier-pane {
  max-height: 60vh;
  overflow: auto;
}

.evidence-card {
  border: 1px solid var(--line);
  padding: 16px;
}

.evidence-card header {
  display: flex;
  margin-bottom: 8px;
  align-items: center;
  justify-content: space-between;
}

.evidence-card h3 {
  margin: 0;
  color: #d3c5aa;
  font-size: 0.9rem;
}

.evidence-tag {
  color: var(--red-bright);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.evidence-card p,
.empty-evidence,
.confirm-dialog p {
  margin: 0;
  color: #9b8e79;
  font-size: 0.75rem;
  line-height: 1.8;
}

.relations-list {
  display: grid;
  padding: 24px 28px 32px;
  gap: 12px;
}

.relation-card {
  display: grid;
  border-bottom: 1px solid var(--line);
  align-items: center;
  grid-template-columns: 40px 1fr auto;
  padding: 14px 0;
  gap: 14px;
}

.relation-seal {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(189, 155, 87, 0.4);
  color: var(--gold);
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.relation-card h3,
.relation-card p {
  margin: 0;
}

.relation-card h3 {
  color: #d3c5aa;
  font-size: 0.9rem;
}

.relation-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
}

.relation-state {
  font-size: 0.68rem;
  font-weight: 500;
}

.relation-state.trusted { color: #9eb08d; }
.relation-state.hostile { color: #d36a58; }
.relation-state.neutral { color: var(--muted); }

.chronicle-list {
  display: grid;
  margin: 0;
  padding: 24px 28px 32px;
  list-style: none;
  gap: 18px;
}

.chronicle-list li {
  border-left: 1px solid rgba(189, 155, 87, 0.35);
  padding-left: 16px;
}

.chronicle-list time {
  color: var(--gold);
  font-size: 0.66rem;
}

.chronicle-list p {
  margin: 5px 0 0;
  color: #aa9c84;
  font-size: 0.76rem;
  line-height: 1.75;
}

.confirm-dialog {
  padding: 30px;
  text-align: center;
}

.dialog-actions {
  display: flex;
  margin-top: 24px;
  justify-content: center;
  gap: 16px;
}

.dialog-actions .text-button {
  margin-top: 0;
}

.toast {
  position: fixed;
  z-index: 20;
  bottom: 28px;
  left: 50%;
  border: 1px solid rgba(189, 155, 87, 0.32);
  transform: translate(-50%, 12px);
  color: #cdbfa7;
  background: rgba(27, 21, 16, 0.96);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  padding: 11px 18px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes reveal {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .chronicle-panel {
    display: none;
  }
}

@media (max-width: 680px) {
  .game-header {
    height: 66px;
    grid-template-columns: 1fr auto;
    padding: 0 18px;
  }

  .brand > span:last-child,
  .icon-button {
    display: none;
  }

  .chapter-heading {
    text-align: right;
  }

  .game-layout {
    display: block;
    min-height: calc(100vh - 66px);
  }

  .status-panel {
    position: static;
    height: auto;
    overflow: visible;
    display: grid;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: 1fr 1fr;
    padding: 16px 18px;
    gap: 12px;
  }

  .identity-card {
    display: none;
  }

  .meters {
    padding: 0;
    border: 0;
    gap: 7px;
  }

  .meter-heading {
    font-size: 0.62rem;
  }

  .action-counter {
    padding: 0;
  }

  .evidence-button {
    min-height: 44px;
    grid-column: 1 / -1;
  }

  .story-panel {
    min-height: calc(100vh - 164px);
    padding: 28px 22px 60px;
  }

  .scene-meta {
    margin-bottom: 30px;
  }

  .story-content p {
    font-size: 0.9rem;
    line-height: 1.95;
  }

  .choice-button {
    min-height: 52px;
    grid-template-columns: 28px 1fr;
  }

  .choice-cost {
    display: block;
    grid-column: 2;
    margin-top: 5px;
  }

  .title-mark {
    top: calc(50% - 190px);
    margin-left: 235px;
  }
}

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