:root {
  color-scheme: dark;
  --ink: #071017;
  --ink-soft: #101b23;
  --paper: #eee4cf;
  --paper-dim: #b9ad96;
  --cinnabar: #a9342e;
  --cinnabar-bright: #d45a47;
  --gold: #caa86a;
  --gold-light: #ead39d;
  --line: rgba(216, 188, 133, .25);
  --glass: rgba(7, 14, 20, .78);
  --shadow: 0 24px 80px rgba(0, 0, 0, .52);
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  color: var(--paper);
  background: var(--ink) url("assets/grand-view-garden.png") center / cover fixed no-repeat;
  font-size: 16px;
  line-height: 1.65;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(90deg, rgba(2, 8, 12, .92) 0%, rgba(3, 9, 14, .68) 48%, rgba(3, 8, 12, .38) 100%), linear-gradient(0deg, rgba(2, 7, 10, .78), transparent 60%);
  z-index: -2;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 78% 16%, rgba(215, 225, 231, .12), transparent 24%), radial-gradient(circle at 13% 26%, rgba(183, 50, 38, .12), transparent 14%);
  z-index: -1;
}

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

.app-shell { min-height: 100vh; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

.start-screen {
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: min(760px, 92vw);
  padding: 64px clamp(24px, 7vw, 96px);
}

.title-seal, .result-seal {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(234, 211, 157, .55);
  background: var(--cinnabar);
  box-shadow: inset 0 0 0 4px rgba(86, 20, 18, .45), 0 10px 30px rgba(0, 0, 0, .35);
  font-size: 1.65rem;
  transform: rotate(-2deg);
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(3.4rem, 8vw, 6.8rem); font-weight: 500; letter-spacing: .08em; line-height: 1.05; text-shadow: 0 10px 36px rgba(0,0,0,.8); }
.subtitle { margin: 8px 0 36px; color: var(--gold-light); font-size: clamp(1.2rem, 2vw, 1.65rem); letter-spacing: .48em; }

.start-card {
  width: min(620px, 100%);
  padding: 22px 24px;
  border-left: 2px solid var(--cinnabar-bright);
  background: linear-gradient(90deg, rgba(8, 17, 23, .86), rgba(8, 17, 23, .52));
  backdrop-filter: blur(8px);
  color: #ded4c0;
}
.start-card p:last-child { margin-bottom: 0; }
.fiction-note { color: var(--paper-dim); font-size: .88rem; }

.primary-btn, .secondary-btn, .solve-btn {
  border: 0;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, opacity .2s ease;
}
.primary-btn {
  margin-top: 28px;
  padding: 13px 24px;
  background: var(--cinnabar);
  box-shadow: 0 10px 30px rgba(0,0,0,.32);
  font-weight: 700;
  letter-spacing: .08em;
}
.primary-btn:hover, .solve-btn:not(:disabled):hover { transform: translateY(-2px); background: #bd4035; }

.game-screen { flex-direction: column; padding: clamp(20px, 4vw, 48px); }
.game-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; width: min(1240px, 100%); margin: 0 auto 22px; }
.game-header h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.5rem); font-weight: 500; letter-spacing: .12em; }
.status-row { display: flex; align-items: stretch; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); }
.status-item { min-width: 88px; padding: 8px 16px; border-right: 1px solid var(--line); text-align: center; }
.status-item span { display: block; color: var(--paper-dim); font-family: system-ui, sans-serif; font-size: .75rem; }
.status-item strong { color: var(--gold-light); font-size: 1.25rem; }
.icon-btn { border: 0; background: transparent; padding: 10px 16px; cursor: pointer; }
.icon-btn span { display: inline-grid; min-width: 24px; height: 24px; place-items: center; margin-left: 7px; border-radius: 50%; background: var(--cinnabar); font-size: .8rem; }

.game-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(330px, .8fr); gap: 20px; width: min(1240px, 100%); margin: 0 auto; }
.map-panel, .scene-panel { min-height: 590px; border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.map-panel { padding: clamp(20px, 3vw, 34px); background: linear-gradient(140deg, rgba(7, 15, 21, .9), rgba(10, 21, 28, .72)); }
.scene-panel { position: relative; overflow: hidden; padding: clamp(24px, 3vw, 38px); background: rgba(10, 18, 23, .88); }
.scene-panel::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(202, 168, 106, .13); pointer-events: none; }

.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.panel-heading > div { display: flex; align-items: center; gap: 14px; }
.panel-heading h3 { margin: 0; font-size: 1.15rem; letter-spacing: .08em; }
.panel-heading p { margin: 0; color: var(--paper-dim); font-size: .84rem; }
.chapter-mark { color: var(--cinnabar-bright); font-size: 1.6rem; }

.location-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.location-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid rgba(202, 168, 106, .22);
  background: rgba(17, 29, 36, .65);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, transform .2s, background .2s;
}
.location-card:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(234, 211, 157, .62); background: rgba(31, 44, 50, .8); }
.location-card:disabled { cursor: default; opacity: .48; }
.location-card.visited { border-color: rgba(91, 129, 109, .55); background: rgba(25, 43, 38, .6); }
.location-card .loc-top { display: flex; justify-content: space-between; gap: 8px; color: var(--gold-light); }
.location-card strong { font-size: 1.08rem; letter-spacing: .08em; }
.location-card small { color: var(--paper-dim); }
.location-card p { margin: 10px 0 0; color: #c9bfaa; font-size: .87rem; line-height: 1.5; }
.visited-mark { color: #8fb09c; font-family: system-ui, sans-serif; font-size: .72rem; }

.solve-btn { width: 100%; margin-top: 18px; padding: 13px; background: var(--cinnabar); font-weight: 700; }
.solve-btn:disabled { cursor: not-allowed; opacity: .35; }
.solve-hint { margin: 8px 0 0; color: var(--paper-dim); text-align: center; font-size: .8rem; }

.empty-scene { position: relative; z-index: 1; display: grid; min-height: 500px; place-content: center; text-align: center; color: var(--paper-dim); }
.empty-scene p { margin: 20px 0 4px; color: var(--paper); font-size: 1.08rem; }
.moon-glyph { color: var(--gold); font-size: 4rem; font-weight: 100; }

.scene-content { position: relative; z-index: 1; animation: reveal .35s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(9px); } }
.scene-kicker { color: var(--cinnabar-bright); font-size: .8rem; letter-spacing: .18em; }
.scene-content h3 { margin: 4px 0 2px; font-size: 1.9rem; font-weight: 500; }
.speaker { color: var(--gold); font-size: .9rem; }
.scene-narrative { margin: 24px 0; color: #d2c8b5; }
.quote { position: relative; margin: 24px 0; padding: 16px 18px; border-left: 2px solid var(--gold); background: rgba(202, 168, 106, .07); font-size: 1.08rem; }
.question { margin-bottom: 12px; font-weight: 700; }
.dialogue-options { display: grid; gap: 10px; }
.dialogue-option { padding: 13px 14px; border: 1px solid var(--line); background: rgba(19, 31, 38, .75); text-align: left; cursor: pointer; }
.dialogue-option:hover { border-color: var(--gold); background: rgba(40, 45, 42, .76); }
.feedback { padding: 18px; border: 1px solid var(--line); background: rgba(12, 22, 27, .85); }
.feedback.good { border-color: rgba(116, 163, 136, .55); }
.feedback.warn { border-color: rgba(190, 116, 72, .55); }
.feedback h4 { margin: 0 0 8px; color: var(--gold-light); font-size: 1.1rem; }
.feedback p { margin-bottom: 12px; }
.feedback .clue-earned { color: #a9c5b2; font-size: .9rem; }

.verdict-screen, .result-screen { justify-content: center; padding: 42px 20px; background: rgba(3, 9, 13, .76); }
.verdict-wrap, .result-card { width: min(900px, 100%); }
.verdict-wrap { padding: clamp(26px, 5vw, 56px); border: 1px solid var(--line); background: rgba(9, 17, 22, .94); box-shadow: var(--shadow); }
.verdict-wrap h2, .result-card h2 { margin-bottom: 12px; font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 500; }
.verdict-intro { color: var(--paper-dim); }
.text-btn { border: 0; background: transparent; color: var(--gold); cursor: pointer; padding: 0 0 24px; }
fieldset { margin: 32px 0; padding: 0; border: 0; }
legend { margin-bottom: 14px; font-size: 1.1rem; font-weight: 700; }
legend span { display: inline-grid; width: 28px; height: 28px; place-items: center; margin-right: 9px; background: rgba(169, 52, 46, .45); color: var(--gold-light); }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.motive-grid, .evidence-grid { display: grid; gap: 10px; }
.radio-choice, .check-choice { position: relative; }
.radio-choice input, .check-choice input { position: absolute; opacity: 0; pointer-events: none; }
.radio-choice label, .check-choice label { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--line); background: rgba(19, 29, 35, .7); cursor: pointer; transition: .2s; }
.radio-choice input:checked + label, .check-choice input:checked + label { border-color: var(--gold); background: rgba(132, 74, 48, .28); box-shadow: inset 3px 0 var(--cinnabar-bright); }
.radio-choice input:focus-visible + label, .check-choice input:focus-visible + label { outline: 2px solid var(--gold-light); outline-offset: 3px; }
.field-note { color: var(--paper-dim); font-size: .85rem; }
.submit-verdict { width: 100%; }
.form-error { min-height: 24px; margin: 10px 0 0; color: #efaa92; text-align: center; }

.result-card { align-self: center; padding: clamp(28px, 5vw, 58px); border: 1px solid var(--line); background: rgba(8, 16, 21, .95); box-shadow: var(--shadow); }
.result-seal { margin-bottom: 20px; }
.result-summary { color: #ddd2bd; font-size: 1.08rem; }
.result-metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0; border: 1px solid var(--line); }
.result-metrics div { padding: 14px; border-right: 1px solid var(--line); text-align: center; }
.result-metrics div:last-child { border-right: 0; }
.result-metrics span { display: block; color: var(--paper-dim); font-size: .78rem; }
.result-metrics strong { color: var(--gold-light); font-size: 1.45rem; }
.truth-box { padding: 22px; border-left: 3px solid var(--cinnabar); background: rgba(169, 52, 46, .1); }
.truth-box h3 { color: var(--gold-light); }
.truth-box p:last-child { margin-bottom: 0; }
.reflection-box { margin-top: 18px; padding: 18px 22px; border: 1px dashed rgba(202,168,106,.34); color: var(--paper-dim); }
.reflection-box strong { color: var(--paper); }
.result-actions { display: flex; gap: 12px; margin-top: 8px; }
.secondary-btn { margin-top: 28px; padding: 12px 20px; border: 1px solid var(--line); background: transparent; }

.notebook { position: fixed; top: 0; right: 0; z-index: 20; width: min(440px, 94vw); height: 100vh; padding: 28px; background: #0d171c; box-shadow: -24px 0 70px rgba(0,0,0,.6); transform: translateX(105%); transition: transform .28s ease; overflow-y: auto; }
.notebook.open { transform: translateX(0); }
.notebook-head { display: flex; justify-content: space-between; align-items: flex-start; }
.notebook-head h2 { margin: 0; font-size: 2rem; }
.close-btn { border: 1px solid var(--line); background: transparent; width: 40px; height: 40px; cursor: pointer; font-size: 1.5rem; }
.tabs { display: flex; gap: 6px; margin: 24px 0 18px; border-bottom: 1px solid var(--line); }
.tab { padding: 9px 11px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--paper-dim); cursor: pointer; }
.tab.active { color: var(--gold-light); border-color: var(--cinnabar-bright); }
.clue-list { display: grid; gap: 10px; }
.clue-card { padding: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.025); }
.clue-card .type { color: var(--cinnabar-bright); font-size: .72rem; letter-spacing: .1em; }
.clue-card h3 { margin: 4px 0; font-size: 1rem; }
.clue-card p { margin: 0; color: var(--paper-dim); font-size: .87rem; }
.empty-clues { padding: 38px 10px; color: var(--paper-dim); text-align: center; }
.scrim { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.58); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; max-width: calc(100vw - 32px); padding: 10px 18px; background: var(--paper); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.4); transform: translate(-50%, 140%); transition: transform .25s ease; }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 850px) {
  body { background-position: 63% center; }
  .game-header { align-items: flex-start; flex-direction: column; }
  .game-grid { grid-template-columns: 1fr; }
  .map-panel, .scene-panel { min-height: auto; }
  .empty-scene { min-height: 330px; }
  .choice-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .start-screen { padding: 38px 20px; }
  h1 { font-size: 3.3rem; }
  .subtitle { letter-spacing: .3em; }
  .game-screen { padding: 16px; }
  .status-row { width: 100%; }
  .status-item, .icon-btn { flex: 1; min-width: 0; padding-inline: 8px; }
  .location-grid { grid-template-columns: 1fr; }
  .location-card { min-height: 105px; }
  .panel-heading { align-items: flex-start; }
  .panel-heading p { display: none; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .result-metrics { grid-template-columns: 1fr; }
  .result-metrics div { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-metrics div:last-child { border-bottom: 0; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; margin-top: 10px; }
}

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