:root {
  --bg: #0c1018;
  --bg2: #141a24;
  --panel: #1a2230cc;
  --line: #2a3548;
  --text: #e6e0d4;
  --muted: #9aa3b5;
  --accent: #c9a86a;
  --accent2: #7eb6c9;
  --danger: #c97a6a;
  --ok: #7ac99a;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "Source Han Serif SC", Georgia, serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 12px 40px #0008;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overflow-x: hidden; }
#fog {
  pointer-events: none; position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a3a5522, transparent 60%),
    radial-gradient(800px 400px at 80% 100%, #1a283822, transparent 50%),
    linear-gradient(180deg, #0c1018 0%, #101622 50%, #0b0e14 100%);
}
#fog::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
  opacity: .35;
}
#app { position: relative; z-index: 1; min-height: 100vh; max-width: 820px; margin: 0 auto; padding: 16px; }
.screen { display: none; animation: fade .35s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none;} }

.title-card { margin-top: 12vh; text-align: center; padding: 28px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.eyebrow { letter-spacing: .3em; color: var(--accent); text-transform: uppercase; font-size: 12px; margin: 0 0 8px; }
.title-card h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 6vw, 42px); margin: 0 0 12px; letter-spacing: .08em; }
.tagline { color: var(--muted); line-height: 1.7; margin: 0 auto 24px; max-width: 28em; }
.title-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hint { margin-top: 18px; color: var(--muted); font-size: 12px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: #1e2838; color: var(--text);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; font: inherit; transition: .15s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.btn.primary { background: linear-gradient(135deg, #3a2f1c, #2a3344); border-color: var(--accent); color: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 6px 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
}
.icon-btn:hover { color: var(--accent); border-color: var(--line); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel-head h2 { font-family: var(--serif); margin: 0 0 6px; }
.panel-head p { margin: 0 0 16px; color: var(--muted); }
.char-grid { display: grid; gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .char-grid { grid-template-columns: repeat(3, 1fr); } }
.char-card {
  text-align: left; border: 1px solid var(--line); background: #121826; border-radius: var(--radius);
  padding: 14px; cursor: pointer; color: inherit; font: inherit; transition: .15s;
}
.char-card:hover, .char-card:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.char-card h3 { margin: 0 0 4px; font-family: var(--serif); color: var(--accent); }
.char-card .role { font-size: 12px; color: var(--accent2); margin-bottom: 8px; }
.char-card .blurb { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0 0 8px; }
.char-card .traits { display: flex; flex-wrap: wrap; gap: 4px; }
.char-card .traits span { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1e2838; color: var(--muted); }

.hud {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 10px; margin-bottom: 12px; background: #0f1520cc; border: 1px solid var(--line);
  border-radius: 10px; position: sticky; top: 8px; backdrop-filter: blur(10px); z-index: 5;
}
.hud-name { font-family: var(--serif); color: var(--accent); margin-right: 8px; }
.hud-loc { color: var(--muted); font-size: 13px; }
.hud-mid { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.hud-mid span { padding: 2px 8px; border-radius: 999px; background: #1a2230; border: 1px solid var(--line); }
.hud-mid .warn { color: var(--danger); border-color: #5a3030; }
.hud-mid .ok { color: var(--ok); }

.stage {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 24px; box-shadow: var(--shadow); min-height: 60vh;
}
.node-title { font-family: var(--serif); font-size: 22px; margin: 0 0 14px; letter-spacing: .06em; color: var(--accent); }
.node-text { font-family: var(--serif); font-size: 17px; line-height: 1.85; white-space: pre-wrap; color: var(--text); }
.node-text .tag-旁白 { color: var(--muted); }
.node-text .tag-内心 { color: #b7a0d4; font-style: italic; }
.node-text .tag-对话 { color: #d4c4a0; }
.node-text .speaker { color: var(--accent2); font-weight: 600; font-family: var(--sans); font-size: 14px; }
.check-result {
  margin: 14px 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #121826; font-size: 14px; line-height: 1.6;
}
.check-result.ok { border-color: #2a5a40; }
.check-result.fail { border-color: #5a3030; }

.choices { display: grid; gap: 8px; margin-top: 18px; }
.choice {
  text-align: left; width: 100%; border: 1px solid var(--line); background: #121826;
  color: var(--text); border-radius: 10px; padding: 12px 14px; cursor: pointer; font: inherit;
  line-height: 1.5; transition: .12s;
}
.choice:hover, .choice:focus-visible { border-color: var(--accent); background: #1a2434; outline: none; }
.choice .num { color: var(--accent); margin-right: 8px; font-variant-numeric: tabular-nums; }
.choice .check-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.choice.locked { opacity: .45; cursor: not-allowed; }

.overlay {
  position: fixed; inset: 0; z-index: 20; background: #000a;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay[hidden] { display: none !important; }
.modal {
  width: min(520px, 100%); max-height: 80vh; overflow: auto;
  background: #141a24; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #141a24; }
.modal-head h3 { margin: 0; font-family: var(--serif); }
.modal-body { padding: 14px; line-height: 1.65; font-size: 14px; }
.modal-body ul { padding-left: 1.2em; margin: 8px 0; }
.modal-body .slot {
  display: flex; justify-content: space-between; gap: 8px; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 8px; background: #101622;
}
.modal-body .slot button { flex-shrink: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1e2838; border: 1px solid var(--accent); color: var(--accent);
  padding: 10px 16px; border-radius: 999px; z-index: 30; font-size: 13px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none !important; }

.debug {
  margin-top: 12px; font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace;
  white-space: pre-wrap; border-top: 1px dashed var(--line); padding-top: 8px;
}
