/* =========================================================================
   密斯卡托尼克：第七封印 — 视觉系统
   1920s archive / cosmic horror / letterpress gold on black-green
   ========================================================================= */
:root {
  --bg: #070a09;
  --bg-deep: #040605;
  --bg-green: #0b1210;
  --panel: rgba(12, 18, 16, 0.84);
  --panel-solid: #0d1412;
  --panel-soft: rgba(22, 29, 26, 0.62);
  --ink: #d9d3c4;
  --ink-dim: #b9b3a5;
  --muted: #8b958c;
  --muted-2: #6b756e;
  --gold: #c8a86b;
  --gold-bright: #e8cd93;
  --gold-soft: rgba(200, 168, 107, 0.16);
  --gold-line: rgba(200, 168, 107, 0.26);
  --line: rgba(217, 211, 196, 0.11);
  --teal: #69a79b;
  --teal-dim: #37655f;
  --violet: #a586c7;
  --violet-dim: #5d4a79;
  --red: #c0695f;
  --red-dim: #6b3632;
  --paper: #ded5c2;
  --paper-ink: #26251f;
  --paper-line: rgba(66, 57, 42, 0.25);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC", Georgia, serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "Courier New", monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg-deep); }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(1100px 780px at 50% -10%, rgba(38, 56, 49, 0.52), transparent 62%),
    radial-gradient(900px 600px at 110% 12%, rgba(49, 37, 65, 0.28), transparent 65%),
    radial-gradient(700px 700px at -10% 90%, rgba(44, 66, 58, 0.22), transparent 65%),
    linear-gradient(180deg, #080c0a 0%, #060807 60%, #040605 100%);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.16;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(255, 255, 255, 0.035) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(0, 0, 0, 0.08) 3px 4px);
  mix-blend-mode: overlay;
}
::selection { background: rgba(200, 168, 107, 0.32); color: #fff; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
html { -webkit-text-size-adjust: 100%; }
a { color: var(--gold); }
p { line-height: 1.78; margin: 0 0 0.7em; }
h1, h2, h3, h4, h5 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.02em; margin: 0; }
em { font-style: normal; }
[hidden] { display: none !important; }
#app { position: relative; z-index: 2; min-height: 100vh; }
#boot-error {
  position: fixed; z-index: 999; left: 1rem; right: 1rem; bottom: 1rem;
  background: #2a1210; border: 1px solid #a45148; color: #f0c9b8;
  padding: 0.8rem 1rem; font-family: var(--mono); font-size: 0.7rem;
  white-space: pre-wrap; line-height: 1.6;
}
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.8; }
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.62) 100%);
}

/* ------------------------------------------------------------------ common */
.screen { display: none; min-height: 100vh; animation: screenIn 0.5s ease both; }
.screen.is-active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.eyebrow {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.55rem;
}
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.tiny { font-size: 0.68rem; line-height: 1.6; color: var(--muted-2); }
.warning { color: #a88a72; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  min-height: 42px; padding: 0.62rem 1.15rem;
  border: 1px solid var(--gold-line);
  background: rgba(200, 168, 107, 0.045);
  color: var(--ink);
  font-family: var(--serif); font-size: 0.88rem; letter-spacing: 0.05em;
  border-radius: 2px;
  transition: all 0.22s ease;
  position: relative;
}
.btn:hover:not(:disabled) {
  border-color: rgba(200, 168, 107, 0.68);
  background: rgba(200, 168, 107, 0.12);
  color: var(--gold-bright);
  box-shadow: 0 0 24px rgba(200, 168, 107, 0.08);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.38; }
.btn-primary {
  border-color: rgba(200, 168, 107, 0.62);
  background: linear-gradient(180deg, rgba(200, 168, 107, 0.2), rgba(200, 168, 107, 0.08));
  color: #f1e4c8;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, rgba(200, 168, 107, 0.32), rgba(200, 168, 107, 0.13)); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-dim); }
.btn-danger { border-color: rgba(192, 105, 95, 0.55); background: rgba(192, 105, 95, 0.1); color: #e4a79d; }
.btn-danger:hover:not(:disabled) { background: rgba(192, 105, 95, 0.2); border-color: var(--red); }
.btn-lg { min-height: 54px; padding: 0.85rem 1.8rem; font-size: 1rem; }
.btn-block { width: 100%; margin-top: 0.6rem; }
.link-btn {
  border: 0; background: transparent; color: var(--muted); padding: 0.5rem 0;
  font-size: 0.78rem; letter-spacing: 0.06em; transition: color 0.2s;
}
.link-btn:hover { color: var(--gold); }
.link-btn span { margin-left: 0.4rem; }
.parchment {
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(255, 248, 228, 0.05), transparent 35%),
    linear-gradient(145deg, rgba(24, 31, 28, 0.94), rgba(12, 17, 15, 0.97));
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), var(--shadow);
  position: relative;
}
.parchment::before {
  content: ""; position: absolute; inset: 5px; border: 1px solid rgba(200, 168, 107, 0.08);
  pointer-events: none; border-radius: 1px;
}
.empty-state, .empty-note {
  padding: 1.2rem; border: 1px dashed rgba(217, 211, 196, 0.12);
  color: var(--muted); font-size: 0.84rem; text-align: center;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 0.38rem; }
.tag {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0.18rem 0.45rem;
  border: 1px solid rgba(200, 168, 107, 0.25);
  background: rgba(200, 168, 107, 0.06);
  color: var(--gold);
  font-size: 0.68rem; font-family: var(--mono); letter-spacing: 0.04em;
  border-radius: 2px;
}
.tag-交, .tag-他 { border-color: rgba(105, 167, 155, 0.3); color: var(--teal); background: rgba(105, 167, 155, 0.07); }
.tag-害, .tag-战, .tag-支 { border-color: rgba(192, 105, 95, 0.32); color: #cf8e84; background: rgba(192, 105, 95, 0.07); }
.tag-梦, .tag-时 { border-color: rgba(165, 134, 199, 0.32); color: var(--violet); background: rgba(165, 134, 199, 0.07); }
.tag-保, .tag-续 { border-color: rgba(110, 150, 120, 0.35); color: #9dbd9e; background: rgba(110, 150, 120, 0.07); }
.tag-召, .tag-造 { border-color: rgba(196, 155, 95, 0.4); color: #d0af7b; }

/* ===================================================================== title */
#screen-title { display: none; }
#screen-title.is-active { display: grid; place-items: center; padding: 3rem 1.5rem; }
.title-wrap { width: min(720px, 100%); text-align: center; position: relative; }
.title-sigil { width: 190px; height: 190px; margin: 0 auto 1rem; color: var(--gold); opacity: 0.85; filter: drop-shadow(0 0 35px rgba(200, 168, 107, 0.15)); }
.title-sigil svg { width: 100%; height: 100%; }
.sigil-ring { animation: slowSpin 120s linear infinite; transform-origin: 120px 120px; }
.sigil-tri { opacity: 0.75; }
@keyframes slowSpin { to { transform: rotate(360deg); } }
.game-title {
  font-size: clamp(2.5rem, 7.6vw, 4.6rem);
  line-height: 1.16; font-weight: 600; letter-spacing: 0.06em;
  color: #e7ddc9; text-shadow: 0 2px 22px rgba(0, 0, 0, 0.85), 0 0 55px rgba(200, 168, 107, 0.09);
  margin: 0.7rem 0 0.9rem;
}
.game-title em { color: var(--gold-bright); font-style: normal; letter-spacing: 0.16em; }
.title-colon { color: var(--gold); }
.game-subtitle { color: var(--ink-dim); font-size: clamp(0.9rem, 1.7vw, 1.12rem); margin: 0 auto 2rem; max-width: 34em; line-height: 1.9; }
.title-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin: 1.7rem 0 2.4rem; }
.title-actions .btn { min-width: 190px; }
.title-foot { color: var(--muted-2); }
.source-line { font-size: 0.72rem; letter-spacing: 0.04em; margin-bottom: 0.5rem; }
.source-line span { color: var(--ink-dim); }
.warning { opacity: 0.85; }
.sound-toggle {
  position: fixed; left: 1.3rem; bottom: 1.2rem; z-index: 10;
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(8, 12, 10, 0.65); border: 1px solid var(--line);
  color: var(--muted); font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em;
  padding: 0.5rem 0.7rem; border-radius: 2px; transition: all 0.25s;
}
.sound-toggle:hover { border-color: var(--gold-line); color: var(--gold); }
.sound-toggle.is-on { color: var(--gold); border-color: rgba(200, 168, 107, 0.5); }
.sound-icon { font-size: 0.8rem; }
.sound-toggle.is-on .sound-icon { animation: soundPulse 3.4s ease-in-out infinite; }
@keyframes soundPulse { 50% { opacity: 0.35; } }

/* ==================================================================== create */
#screen-create { padding: 2.4rem clamp(1rem, 4vw, 4rem) 4rem; }
.create-shell { max-width: 1380px; margin: 0 auto; }
.create-head { display: flex; align-items: flex-start; gap: 1.5rem; margin-bottom: 1.15rem; }
.create-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); margin-bottom: 0.35rem; }
.btn-back { margin-top: 0.2rem; white-space: nowrap; }
.create-grid { display: grid; grid-template-columns: minmax(340px, 1.1fr) minmax(320px, 0.9fr); gap: 1.3rem; align-items: start; }
.create-roles { display: flex; flex-direction: column; gap: 0.4rem; }
.role-card {
  display: flex; align-items: center; gap: 0.9rem;
  text-align: left; width: 100%;
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--line);
  background: rgba(14, 20, 17, 0.66);
  border-radius: 2px;
  transition: all 0.22s ease;
}
.role-card:hover { border-color: var(--gold-line); background: rgba(25, 33, 28, 0.8); transform: translateX(3px); }
.role-card.is-selected { border-color: rgba(200, 168, 107, 0.62); background: linear-gradient(90deg, rgba(200, 168, 107, 0.1), rgba(14, 20, 17, 0.75)); }
.role-glyph {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  border: 1px solid var(--gold-line); color: var(--gold);
  font-family: var(--serif); font-size: 0.68rem; letter-spacing: 0.02em;
  border-radius: 50%;
}
.role-main { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; flex: 1; }
.role-name { font-size: 1.05rem; color: #e2dacb; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.role-name em { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.12em; color: var(--muted-2); font-style: normal; text-transform: uppercase; }
.role-tagline { font-size: 0.8rem; color: var(--muted); }
.role-skills { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.15rem; }
.mini-skill { font-size: 0.62rem; color: var(--gold); background: rgba(200, 168, 107, 0.06); padding: 0.1rem 0.35rem; border: 1px solid rgba(200, 168, 107, 0.15); }
.role-check { color: var(--gold-bright); width: 1rem; text-align: center; }
.create-preview { padding: 1.15rem 1.25rem; min-height: 360px; }
.preview-head h3 { font-size: 1.65rem; color: var(--gold-bright); }
.preview-en { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.2em; color: var(--muted-2); text-transform: uppercase; margin: 0.15rem 0 0.7rem; }
.preview-tagline { color: var(--ink-dim); font-style: italic; line-height: 1.6; }
.preview-desc { color: var(--ink-dim); font-size: 0.86rem; line-height: 1.78; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 1rem 0; }
.stat-cell { background: rgba(9, 13, 11, 0.7); padding: 0.55rem 0.4rem; display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
.stat-cell span { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-2); letter-spacing: 0.08em; }
.stat-cell b { font-family: var(--mono); font-size: 0.78rem; color: var(--ink); font-weight: 500; }
.derived-row { display: flex; gap: 1.2rem; flex-wrap: wrap; color: var(--muted); font-size: 0.72rem; padding: 0.2rem 0 0.8rem; }
.derived-row b { color: var(--gold-bright); font-family: var(--mono); margin-right: 0.2rem; }
.skill-preview { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.7rem 0; margin-bottom: 0.8rem; }
.skill-preview div { display: flex; justify-content: space-between; font-size: 0.76rem; padding: 0.2rem 0; color: var(--ink-dim); }
.skill-preview b { font-family: var(--mono); color: var(--teal); font-weight: 500; }
.preview-passive, .preview-items { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.preview-passive b { color: var(--gold-bright); display: block; margin: 0.15rem 0 0.25rem; }
.preview-passive p, .preview-items p { font-size: 0.78rem; color: var(--muted); margin: 0; line-height: 1.65; }
.preview-empty { display: grid; place-items: center; min-height: 340px; color: var(--muted); text-align: center; }
.create-launch { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.name-field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 260px; flex: 1; max-width: 360px; }
.name-field input {
  background: rgba(6, 9, 8, 0.7); border: 1px solid var(--line); color: var(--ink);
  padding: 0.75rem 0.8rem; border-radius: 2px; font-size: 1rem;
  outline: none; transition: border 0.2s;
}
.name-field input:focus { border-color: rgba(200, 168, 107, 0.6); }
.launch-actions { display: flex; align-items: center; gap: 1.3rem; flex-wrap: wrap; justify-content: flex-end; }

/* ====================================================================== game */
#screen-game { padding: 0 1rem 1rem; }
.topbar {
  display: grid; grid-template-columns: minmax(260px, 1.2fr) minmax(240px, auto) minmax(280px, auto) auto;
  align-items: center; gap: 1rem;
  max-width: 1680px; margin: 0 auto;
  padding: max(0.8rem, env(safe-area-inset-top)) max(0.35rem, env(safe-area-inset-right)) 0.75rem max(0.35rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(7, 10, 9, 0.97), rgba(7, 10, 9, 0.86));
  backdrop-filter: blur(12px);
}
.topbar-brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark { color: var(--gold); font-size: 1.15rem; text-shadow: 0 0 16px rgba(200, 168, 107, 0.4); }
.brand-title { font-size: 0.93rem; letter-spacing: 0.08em; margin: 0; color: #e3dbcb; white-space: nowrap; }
.brand-sub { font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.2em; color: var(--muted-2); margin: 0.18rem 0 0; }
.topbar-night { display: flex; align-items: center; gap: 0.8rem; }
.night-label { font-size: 0.8rem; color: var(--gold); letter-spacing: 0.08em; white-space: nowrap; }
.night-label b { font-family: var(--mono); font-size: 1rem; color: var(--gold-bright); }
.night-date { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.doom { width: 88px; height: 5px; background: rgba(217, 211, 196, 0.08); position: relative; border: 1px solid rgba(217, 211, 196, 0.1); }
.doom-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-dim), var(--gold), var(--red)); transition: width 0.8s ease; }
.doom-marks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(14.28% - 1px), rgba(0, 0, 0, 0.55) calc(14.28% - 1px) 14.28%); }
.topbar-resources { display: flex; gap: 0.5rem; justify-content: flex-end; }
.res-chip { display: flex; align-items: center; gap: 0.36rem; position: relative; padding: 0.25rem 0.45rem; border: 1px solid var(--line); background: rgba(10, 14, 12, 0.6); min-width: 68px; }
.res-icon { font-size: 0.7rem; opacity: 0.8; }
.res-hp .res-icon { color: var(--red); }
.res-san .res-icon { color: var(--violet); }
.res-mp .res-icon { color: var(--teal); }
.res-luck .res-icon { color: var(--gold); }
.res-text { display: flex; align-items: baseline; gap: 0.22rem; font-family: var(--mono); }
.res-text b { font-size: 0.76rem; font-weight: 500; color: var(--ink); }
.res-text small { font-size: 0.5rem; color: var(--muted-2); letter-spacing: 0.08em; }
.res-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: rgba(255, 255, 255, 0.04); }
.res-bar i { display: block; height: 100%; transition: width 0.5s ease; }
.res-hp .res-bar i { background: var(--red); }
.res-san .res-bar i { background: var(--violet); }
.res-mp .res-bar i { background: var(--teal); }
.res-luck .res-bar i { background: var(--gold); }
.topbar-nav { display: flex; gap: 0.1rem; }
.icon-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.12rem;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 0.9rem; padding: 0.3rem 0.5rem; min-width: 44px;
  transition: all 0.2s;
}
.icon-btn span { font-family: var(--sans); font-size: 0.52rem; letter-spacing: 0.04em; }
.icon-btn:hover { color: var(--gold); border-color: var(--gold-line); background: rgba(200, 168, 107, 0.05); }

.game-grid {
  display: grid; grid-template-columns: 292px minmax(0, 1fr) 320px;
  gap: 1rem; max-width: 1680px; margin: 1rem auto 0; align-items: start;
}
.side-panel { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.stage { min-width: 0; background: rgba(8, 12, 10, 0.45); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stage-scene { position: relative; height: 200px; overflow: hidden; border-bottom: 1px solid var(--gold-line); background: #070b09; }
.scene-art { position: absolute; inset: 0; color: rgba(200, 168, 107, 0.75); }
.scene-art::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(60% 90% at 72% 16%, rgba(200, 168, 107, 0.13), transparent 62%),
    radial-gradient(80% 100% at 18% 100%, rgba(36, 66, 58, 0.6), transparent 70%),
    linear-gradient(180deg, #0a100d, #060a08);
}
.scene-art svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.95; z-index: 1; filter: drop-shadow(0 0 18px rgba(200, 168, 107, 0.18)); fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.scene-art::after { content: ""; position: absolute; inset: 0; z-index: 2; background: linear-gradient(180deg, rgba(5, 8, 7, 0.08), transparent 38%, rgba(7, 10, 9, 0.92) 100%); }
.scene-moon {
  position: absolute; width: 150px; height: 150px; right: 10%; top: 4%; z-index: 1;
  border-radius: 50%; border: 1px solid rgba(200, 168, 107, 0.3);
  background: radial-gradient(circle at 40% 38%, rgba(226, 207, 166, 0.24), rgba(200, 168, 107, 0.04) 45%, transparent 70%);
  box-shadow: 0 0 80px rgba(200, 168, 107, 0.16);
  animation: moonPulse 12s ease-in-out infinite;
}
@keyframes moonPulse { 50% { opacity: 0.7; transform: scale(0.98); } }
.scene-fog {
  position: absolute; inset: auto 0 0 0; height: 48%; z-index: 1;
  background:
    radial-gradient(60% 100% at 30% 100%, rgba(191, 207, 190, 0.1), transparent 70%),
    linear-gradient(180deg, transparent, rgba(9, 14, 12, 0.65));
}
.scene-caption {
  position: absolute; left: 1.15rem; bottom: 0.8rem; z-index: 3; display: flex; flex-direction: column; gap: 0.1rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
.scene-caption span { font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.2em; color: var(--gold); text-transform: uppercase; }
.scene-library svg { color: rgba(200, 168, 107, 0.82); }
.scene-museum svg { color: rgba(199, 187, 158, 0.82); }
.scene-hospital svg { color: rgba(168, 197, 190, 0.8); }
.scene-grave svg { color: rgba(188, 168, 195, 0.76); }
.scene-harbor svg { color: rgba(134, 190, 192, 0.82); }
.scene-woods svg { color: rgba(148, 182, 143, 0.76); }
.scene-dream svg { color: rgba(201, 174, 226, 0.86); }
.scene-harbor .scene-moon { background: radial-gradient(circle at 40% 38%, rgba(162, 211, 210, 0.24), transparent 68%); }
.scene-grave .scene-moon { background: radial-gradient(circle at 40% 38%, rgba(198, 176, 218, 0.2), transparent 68%); }
.scene-woods .scene-moon { background: radial-gradient(circle at 40% 38%, rgba(188, 207, 168, 0.15), transparent 68%); }
.scene-dream .scene-moon { background: radial-gradient(circle at 40% 38%, rgba(216, 190, 242, 0.24), transparent 68%); }
.hub-head { border-bottom-color: rgba(200, 168, 107, 0.12); }
.hub-head .muted { font-size: 0.76rem; }
.stage-body { padding: 1.2rem 1.25rem 1rem; }
.location-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.location-head h2 { font-size: clamp(1.3rem, 2.4vw, 1.75rem); color: #e6ddcb; letter-spacing: 0.05em; }
.location-desc { color: var(--muted); font-size: 0.82rem; line-height: 1.7; margin: 0.4rem 0 0; max-width: 55em; }
.location-status { font-family: var(--mono); font-size: 0.58rem; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 0.35rem; padding-top: 0.2rem; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); display: inline-block; }
.event-card, .location-card { padding: 1.25rem; }
.event-head { border-bottom: 1px solid var(--line); padding-bottom: 0.8rem; margin-bottom: 1rem; }
.event-head h3 { font-size: 1.3rem; color: var(--gold-bright); margin: 0.15rem 0 0.3rem; }
.event-head blockquote { margin: 0.5rem 0 0; padding-left: 0.85rem; border-left: 2px solid var(--gold-line); color: var(--muted); font-size: 0.8rem; font-style: italic; line-height: 1.7; }
.event-body { color: var(--ink-dim); font-size: 0.9rem; line-height: 1.85; }
.event-body p { margin-bottom: 0.85rem; }
.event-choices { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.2rem; }
.choice-btn {
  display: flex; align-items: flex-start; gap: 0.85rem; text-align: left;
  width: 100%; padding: 0.8rem 0.85rem;
  border: 1px solid var(--line); background: rgba(13, 19, 16, 0.6);
  transition: all 0.2s ease; border-radius: 2px;
}
.choice-btn:hover:not(:disabled) { border-color: rgba(200, 168, 107, 0.5); background: rgba(200, 168, 107, 0.06); transform: translateX(3px); }
.choice-btn.is-locked { opacity: 0.45; }
.choice-index { width: 1.4rem; height: 1.4rem; flex: 0 0 1.4rem; display: grid; place-items: center; border: 1px solid var(--gold-line); font-family: var(--mono); font-size: 0.62rem; color: var(--gold); border-radius: 50%; margin-top: 0.1rem; }
.choice-main { display: flex; flex-direction: column; gap: 0.22rem; min-width: 0; flex: 1; }
.choice-label { font-size: 0.92rem; color: #e2d9c8; line-height: 1.5; }
.choice-meta { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-2); line-height: 1.5; }
.choice-meta b { color: var(--teal); font-weight: 500; }
.choice-hint { font-size: 0.72rem; color: var(--muted); font-style: italic; }
.choice-arrow { color: var(--gold); opacity: 0.5; transition: transform 0.2s; }
.choice-btn:hover .choice-arrow { transform: translateX(4px); opacity: 1; }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.hub-event {
  text-align: left; border: 1px solid var(--line); background: rgba(13, 19, 16, 0.55);
  padding: 0.85rem; display: flex; flex-direction: column; gap: 0.34rem;
  transition: all 0.2s;
}
.hub-event:hover { border-color: rgba(200, 168, 107, 0.45); background: rgba(200, 168, 107, 0.05); transform: translateY(-2px); }
.hub-kicker { font-family: var(--mono); font-size: 0.54rem; letter-spacing: 0.12em; color: var(--gold); text-transform: uppercase; }
.hub-title { font-size: 0.94rem; color: #e2d9c8; }
.hub-desc { font-size: 0.74rem; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hub-go { margin-top: 0.2rem; font-size: 0.64rem; color: var(--gold); font-family: var(--mono); }
.hub-foot { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.7rem; font-family: var(--mono); font-size: 0.6rem; color: var(--muted-2); }
.log-area { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.log-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 0.7rem; margin-bottom: 0.4rem; }
.log-lines { max-height: 230px; overflow-y: auto; padding-right: 0.3rem; scrollbar-width: thin; scrollbar-color: var(--gold-line) transparent; }
.log-line { font-size: 0.78rem; line-height: 1.72; color: var(--muted); margin: 0 0 0.5rem; padding-left: 0.6rem; border-left: 1px solid rgba(217, 211, 196, 0.08); }
.log-line.tone-story { color: var(--ink-dim); }
.log-line.tone-danger { color: #d49a8f; border-left-color: var(--red-dim); }
.log-line.tone-heal { color: #9dbd9e; }
.log-line.tone-night { color: var(--gold-bright); font-family: var(--mono); letter-spacing: 0.14em; border-left-color: var(--gold); }
.log-line.tone-omen { color: var(--violet); border-left-color: var(--violet-dim); }
.log-line.tone-clue { color: var(--gold); border-left-color: var(--gold-line); }
.log-line.tone-spell { color: var(--teal); border-left-color: var(--teal-dim); }
.log-line.tone-grimoire, .log-line.tone-quote { color: #c9b28c; font-style: italic; }
.log-line.tone-loot { color: #c8b37d; }
.log-line.tone-travel { color: var(--muted-2); }
.log-line.tone-muted { color: var(--muted-2); font-size: 0.72rem; }
.log-line.tone-combat-win { color: #9dbd9e; }
.log-line.tone-trust { color: var(--teal); }
.log-line.tone-warn { color: #c9957d; }
.log-line.tone-ending { color: var(--gold-bright); }

/* --------------------------------------------------------------- left panel */
.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; }
.dossier { padding: 1rem; }
.dossier-head { display: flex; gap: 0.8rem; align-items: center; }
.portrait-sigil {
  width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center;
  border: 1px solid rgba(200, 168, 107, 0.4); border-radius: 50%; color: var(--gold);
  font-family: var(--serif); font-size: 0.68rem; letter-spacing: 0.02em;
  background: radial-gradient(circle, rgba(200, 168, 107, 0.12), transparent 70%);
  box-shadow: 0 0 24px rgba(200, 168, 107, 0.06);
}
.dossier-head h3 { font-size: 1.02rem; color: #e4dccb; margin: 0.05rem 0; }
.dossier-head .muted { margin: 0; }
.dossier-vitals { display: flex; flex-direction: column; gap: 0.38rem; margin: 0.8rem 0 0.7rem; }
.vital-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.68rem; color: var(--muted); }
.vital-top b { font-family: var(--mono); font-size: 0.78rem; color: var(--ink); font-weight: 500; }
.vital-top small { font-size: 0.56rem; color: var(--muted-2); }
.vital-bar { height: 4px; background: rgba(255, 255, 255, 0.05); margin-top: 0.2rem; }
.vital-bar i { display: block; height: 100%; transition: width 0.5s; }
.vital-red .vital-bar i { background: linear-gradient(90deg, var(--red-dim), var(--red)); }
.vital-violet .vital-bar i { background: linear-gradient(90deg, var(--violet-dim), var(--violet)); }
.vital-teal .vital-bar i { background: linear-gradient(90deg, var(--teal-dim), var(--teal)); }
.char-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.char-stats span { background: rgba(8, 12, 10, 0.7); padding: 0.35rem 0.2rem; text-align: center; font-family: var(--mono); font-size: 0.68rem; color: var(--ink); }
.char-stats b { display: block; font-size: 0.5rem; color: var(--muted-2); font-weight: 400; letter-spacing: 0.08em; margin-bottom: 0.1rem; }
.meter-note { font-size: 0.6rem; color: var(--muted-2); font-family: var(--mono); margin-top: 0.4rem; }
.boost-chip { margin-top: 0.55rem; font-size: 0.66rem; color: var(--teal); border: 1px solid rgba(105, 167, 155, 0.35); background: rgba(105, 167, 155, 0.08); padding: 0.28rem 0.45rem; text-align: center; font-family: var(--mono); }
.fold summary { list-style: none; display: flex; justify-content: space-between; align-items: baseline; cursor: pointer; color: var(--muted); font-size: 0.74rem; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary b { color: var(--gold); font-family: var(--mono); font-size: 0.68rem; }
.fold[open] summary { margin-bottom: 0.6rem; border-bottom: 1px solid var(--line); padding-bottom: 0.45rem; }
.skills-list { display: flex; flex-direction: column; gap: 0.28rem; }
.skill-row { display: grid; grid-template-columns: 5.2rem 1fr 2rem; align-items: center; gap: 0.35rem; font-size: 0.7rem; color: var(--ink-dim); }
.skill-row b { font-family: var(--mono); font-size: 0.66rem; color: var(--gold); text-align: right; font-weight: 400; }
.skill-row.is-low b { color: var(--muted-2); }
.skill-meter { height: 3px; background: rgba(255, 255, 255, 0.05); }
.skill-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-dim), var(--teal)); opacity: 0.7; }
.clues .clue-tag { cursor: pointer; font-size: 0.66rem; padding: 0.22rem 0.42rem; }
.clue-tag:hover { background: rgba(200, 168, 107, 0.15); }
.item-list { display: flex; flex-direction: column; gap: 0.1rem; }
.item-row { display: flex; align-items: center; gap: 0.45rem; width: 100%; text-align: left; border: 0; background: transparent; padding: 0.34rem 0.15rem; border-bottom: 1px solid rgba(217, 211, 196, 0.055); font-size: 0.72rem; color: var(--ink-dim); }
.item-row:hover { color: var(--gold); background: rgba(200, 168, 107, 0.04); }
.item-glyph { color: var(--gold); width: 0.9rem; text-align: center; font-size: 0.68rem; }
.item-name { flex: 1; }
.item-qty { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-2); }
.contacts { display: flex; flex-direction: column; gap: 0.35rem; }
.contact-row { display: flex; justify-content: space-between; gap: 0.4rem; font-size: 0.72rem; color: var(--ink-dim); }
.trust-pips, .pips { display: inline-flex; gap: 2px; }
.trust-pips i, .pips i { width: 5px; height: 5px; background: rgba(217, 211, 196, 0.12); display: inline-block; }
.trust-pips i.on { background: var(--teal); }
.pips i.on { background: var(--gold); box-shadow: 0 0 5px rgba(200, 168, 107, 0.4); }

/* -------------------------------------------------------------- right panel */
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.6rem; }
.map-card { padding-bottom: 0.7rem; }
.map-wrap { position: relative; height: 210px; background: #060a08; border: 1px solid var(--line); overflow: hidden; }
.map-grid {
  position: absolute; inset: 0; opacity: 0.5;
  background-image: linear-gradient(rgba(200, 168, 107, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(200, 168, 107, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
}
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-lines line { stroke: rgba(200, 168, 107, 0.18); stroke-width: 0.5; stroke-dasharray: 1.5 2; }
.map { position: absolute; inset: 0; }
.map-node {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  border: 0; background: transparent; padding: 0; color: var(--muted);
  width: 70px;
}
.map-dot { width: 9px; height: 9px; border: 1px solid var(--gold); border-radius: 50%; background: rgba(200, 168, 107, 0.16); transition: all 0.2s; }
.map-label { font-size: 0.5rem; text-align: center; line-height: 1.2; color: var(--ink-dim); text-shadow: 0 1px 4px #000; white-space: nowrap; max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
.map-node:hover .map-dot { background: var(--gold); box-shadow: 0 0 14px rgba(200, 168, 107, 0.45); }
.map-node.is-current .map-dot { background: var(--gold-bright); box-shadow: 0 0 16px rgba(232, 205, 147, 0.65); }
.map-node.is-current .map-label { color: var(--gold-bright); }
.map-node.is-locked { opacity: 0.28; }
.map-hint { font-size: 0.6rem; color: var(--muted-2); font-family: var(--mono); margin: 0.55rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.night-card { padding: 0.95rem; }
.night-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.night-omen { color: var(--violet); font-size: 0.72rem; font-style: italic; line-height: 1.6; border-left: 2px solid var(--violet-dim); padding-left: 0.55rem; margin: 0.7rem 0; }
.doom-large { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0.2rem; }
.doom-large .eyebrow { margin: 0; white-space: nowrap; }
.doom-track { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.06); }
.doom-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold), var(--red)); transition: width 0.6s; }
.doom-large b { font-family: var(--mono); font-size: 0.66rem; color: var(--gold); }
.save-note { font-size: 0.56rem; color: var(--muted-2); font-family: var(--mono); text-align: center; margin: 0.6rem 0 0; }
.pulse { animation: dangerPulse 2.8s ease-in-out infinite; }
@keyframes dangerPulse { 50% { box-shadow: 0 0 26px rgba(192, 105, 95, 0.25); border-color: rgba(192, 105, 95, 0.8); } }
.objectives { display: flex; flex-direction: column; gap: 0.35rem; }
.objective { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.72rem; color: var(--muted); }
.objective.is-done { color: var(--ink-dim); }
.objective.is-done span:last-child { text-decoration: line-through; text-decoration-color: rgba(200, 168, 107, 0.4); }
.obj-check { font-family: var(--mono); font-size: 0.68rem; color: var(--gold); width: 0.8rem; flex: 0 0 0.8rem; }
.objective.is-done .obj-check { color: var(--teal); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.quick-btn { text-align: left; border: 1px solid var(--line); background: rgba(11, 16, 14, 0.55); padding: 0.5rem 0.55rem; display: flex; flex-direction: column; gap: 0.15rem; transition: all 0.2s; }
.quick-btn:hover { border-color: var(--gold-line); background: rgba(200, 168, 107, 0.05); }
.quick-btn b { font-size: 0.78rem; color: var(--ink); font-weight: 500; }
.quick-btn span { font-size: 0.55rem; color: var(--muted-2); font-family: var(--mono); }

/* ------------------------------------------------------------------- dock */
.action-dock {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1680px; margin: 1rem auto 0;
  padding: 0.65rem 0.9rem max(0.65rem, env(safe-area-inset-bottom));
  border: 1px solid var(--line); background: rgba(8, 12, 10, 0.9);
  position: sticky; bottom: 0; z-index: 25; backdrop-filter: blur(10px);
}
.dock-location { display: flex; flex-direction: column; gap: 0.1rem; min-width: 145px; }
.dock-location b { font-size: 0.82rem; color: var(--ink); font-weight: 500; }
.dock-center { display: flex; align-items: center; gap: 0.8rem; flex: 1; justify-content: center; color: var(--muted); font-size: 0.72rem; flex-wrap: wrap; }
.dock-night { color: var(--gold); font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; }
.dock-hint { color: var(--muted-2); font-size: 0.65rem; }
.dock-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.dock-actions .btn { min-height: 32px; padding: 0.32rem 0.6rem; font-size: 0.7rem; }

/* ==================================================================== codex */
#screen-codex { padding: 0 1.4rem 1.5rem; }
.codex-head {
  display: flex; align-items: center; gap: 1.4rem;
  max-width: 1560px; margin: 0 auto; padding: 1.25rem 0 0.9rem;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(7, 10, 9, 0.98), rgba(7, 10, 9, 0.92));
  backdrop-filter: blur(12px);
}
.codex-title { display: flex; align-items: center; gap: 0.8rem; min-width: 280px; }
.codex-title h2 { font-size: 1.35rem; color: #e6ddcb; letter-spacing: 0.06em; }
.codex-search { position: relative; flex: 1; max-width: 520px; }
.codex-search input {
  width: 100%; background: rgba(8, 12, 10, 0.8); border: 1px solid var(--line);
  color: var(--ink); padding: 0.65rem 2.3rem 0.65rem 0.8rem; font-size: 0.85rem; outline: none;
}
.codex-search input:focus { border-color: rgba(200, 168, 107, 0.55); }
.search-glyph { position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--gold); pointer-events: none; }
.codex-tabs {
  display: flex; gap: 0.2rem; max-width: 1560px; margin: 0 auto; padding: 0.7rem 0 0;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.codex-tab {
  border: 0; background: transparent; color: var(--muted); padding: 0.6rem 0.9rem;
  font-size: 0.8rem; letter-spacing: 0.06em; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all 0.2s;
}
.codex-tab:hover { color: var(--gold); }
.codex-tab.is-active { color: var(--gold-bright); border-bottom-color: var(--gold); }
.tab-count { font-family: var(--mono); font-size: 0.56rem; color: var(--muted-2); margin-left: 0.3rem; }
.codex-filters { display: flex; flex-wrap: wrap; gap: 0.3rem; max-width: 1560px; margin: 0 auto; padding: 0.6rem 0; }
.filter-chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 0.64rem; padding: 0.22rem 0.55rem; transition: all 0.2s; border-radius: 2px;
}
.filter-chip:hover { color: var(--gold); border-color: var(--gold-line); }
.filter-chip.is-active { color: var(--gold-bright); border-color: rgba(200, 168, 107, 0.5); background: rgba(200, 168, 107, 0.08); }
.codex-body { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr); gap: 1.1rem; max-width: 1560px; margin: 0 auto; align-items: start; }
.codex-list-wrap { min-width: 0; }
.codex-count { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-2); padding: 0.1rem 0 0.55rem; }
.codex-list { display: flex; flex-direction: column; gap: 0.4rem; }
.codex-card {
  text-align: left; width: 100%; padding: 0.75rem 0.85rem;
  border: 1px solid var(--line); background: rgba(12, 18, 16, 0.66);
  transition: all 0.18s; display: flex; flex-direction: column; gap: 0.35rem;
  border-radius: 2px;
}
.codex-card:hover { border-color: rgba(200, 168, 107, 0.4); background: rgba(200, 168, 107, 0.04); }
.codex-card.is-selected { border-color: rgba(200, 168, 107, 0.58); background: rgba(200, 168, 107, 0.07); }
.codex-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.7rem; }
.codex-name { color: #e2d9c8; font-size: 0.92rem; }
.codex-en { font-family: var(--mono); font-size: 0.52rem; color: var(--muted-2); letter-spacing: 0.05em; text-align: right; }
.codex-card-tags { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.cost-inline { font-family: var(--mono); font-size: 0.56rem; color: var(--muted-2); margin-left: auto; }
.codex-snippet { font-size: 0.72rem; color: var(--muted); line-height: 1.6; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.codex-card-meta { display: flex; gap: 1rem; font-family: var(--mono); font-size: 0.54rem; color: var(--muted-2); }
.threat-inline { color: var(--gold); font-size: 0.7rem; letter-spacing: 0.12em; }
.codex-detail { padding: 1.2rem; min-height: 360px; position: sticky; top: 148px; max-height: calc(100vh - 170px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--gold-line) transparent; }
.detail-title { font-size: 1.45rem; color: var(--gold-bright); margin: 0.1rem 0 0.2rem; letter-spacing: 0.04em; }
.detail-en { font-family: var(--mono); font-size: 0.62rem; color: var(--muted-2); letter-spacing: 0.08em; margin: 0 0 0.8rem; line-height: 1.5; }
.detail-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 0.8rem 0; }
.detail-meta-grid div { background: rgba(9, 13, 11, 0.72); padding: 0.45rem 0.55rem; display: flex; flex-direction: column; gap: 0.1rem; }
.detail-meta-grid span { font-family: var(--mono); font-size: 0.52rem; color: var(--muted-2); letter-spacing: 0.08em; text-transform: uppercase; }
.detail-meta-grid b { font-size: 0.72rem; color: var(--ink-dim); font-weight: 400; line-height: 1.5; }
.detail-source { font-family: var(--mono); font-size: 0.52rem; color: var(--muted-2); letter-spacing: 0.06em; margin: 0.2rem 0 0.9rem; }
.detail-body { color: var(--ink-dim); font-size: 0.82rem; line-height: 1.8; }
.detail-body p { margin-bottom: 0.75rem; }
.article-body p { color: var(--ink-dim); }
.detail-quote { border-left: 2px solid var(--gold-line); margin: 0.9rem 0; padding: 0.3rem 0 0.3rem 0.8rem; color: var(--muted); font-style: italic; font-size: 0.8rem; line-height: 1.7; }
.known-badge { display: inline-block; margin: 0.6rem 0; padding: 0.25rem 0.55rem; font-family: var(--mono); font-size: 0.58rem; color: var(--teal); border: 1px solid rgba(105, 167, 155, 0.3); background: rgba(105, 167, 155, 0.07); }
.related-block { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.link-item { display: block; border: 0; background: transparent; color: var(--gold); font-size: 0.76rem; text-align: left; padding: 0.25rem 0; border-bottom: 1px dotted rgba(200, 168, 107, 0.16); }
.link-item:hover { color: var(--gold-bright); }
.link-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.detail-section { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.versions-table { width: 100%; border-collapse: collapse; font-size: 0.68rem; }
.versions-table th { font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.08em; color: var(--muted-2); text-align: left; font-weight: 400; padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--line); }
.versions-table td { padding: 0.38rem 0.25rem; border-bottom: 1px solid rgba(217, 211, 196, 0.06); color: var(--ink-dim); vertical-align: top; }
.versions-table td:first-child { color: var(--ink); }
.legacy-tag { font-size: 0.62rem; opacity: 0.8; }
.detail-stat-grid { grid-template-columns: repeat(3, 1fr); margin: 0.7rem 0 0.9rem; }
.raw-stats { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.raw-stats summary { font-family: var(--mono); font-size: 0.58rem; color: var(--muted-2); cursor: pointer; }
.raw-stats p { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); line-height: 1.7; margin-top: 0.4rem; }
.detail-empty { display: grid; place-items: center; min-height: 300px; text-align: center; color: var(--muted); }
.load-more { width: 100%; margin-top: 0.7rem; }

/* =================================================================== modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(2, 4, 3, 0.78); backdrop-filter: blur(7px);
  opacity: 0; transition: opacity 0.18s;
  padding: 1rem;
}
.modal-backdrop.is-open { opacity: 1; }
.modal {
  width: min(640px, 100%); max-height: 88vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: linear-gradient(155deg, #111814, #090d0b 70%);
  border: 1px solid rgba(200, 168, 107, 0.38);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform: translateY(10px) scale(0.99); transition: transform 0.2s;
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-wide { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.05rem 1.15rem 0.7rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.35rem; color: var(--gold-bright); margin: 0; letter-spacing: 0.04em; }
.modal-close { border: 1px solid var(--line); background: transparent; color: var(--muted); width: 30px; height: 30px; font-size: 1.1rem; line-height: 1; }
.modal-close:hover { color: var(--gold); border-color: var(--gold-line); }
.modal-body { padding: 1.1rem 1.15rem; overflow-y: auto; color: var(--ink-dim); font-size: 0.86rem; line-height: 1.8; scrollbar-width: thin; scrollbar-color: var(--gold-line) transparent; }
.modal-body p { margin-bottom: 0.8rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.45rem; padding: 0.8rem 1.15rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-quote { border-left: 2px solid var(--gold-line); margin: 0 0 1rem; padding: 0.4rem 0 0.4rem 0.8rem; color: var(--muted); font-style: italic; line-height: 1.7; }
.modal-quote cite { display: block; margin-top: 0.3rem; font-size: 0.68rem; color: var(--muted-2); }
.check-result { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.6rem 0.7rem; border: 1px solid var(--line); margin-bottom: 0.9rem; font-family: var(--mono); font-size: 0.66rem; }
.check-result.ok { border-color: rgba(105, 167, 155, 0.4); background: rgba(105, 167, 155, 0.06); }
.check-result.bad { border-color: rgba(192, 105, 95, 0.4); background: rgba(192, 105, 95, 0.06); }
.check-skill { color: var(--gold); }
.check-math b { color: var(--ink); }
.check-verdict { color: var(--teal); font-weight: 600; }
.check-result.bad .check-verdict { color: var(--red); }
.outcome-body { color: var(--ink-dim); }
.outcome-resources { display: flex; flex-wrap: wrap; gap: 0.8rem; border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.7rem; font-family: var(--mono); font-size: 0.62rem; color: var(--muted-2); }
.outcome-resources b { color: var(--ink); font-weight: 500; }
.warn-line { color: #d49a8f; border-left: 2px solid var(--red-dim); padding-left: 0.55rem; font-size: 0.78rem; margin-top: 0.8rem; }
.grimoire-list, .spell-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.grimoire-row, .spell-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; border: 1px solid var(--line); padding: 0.7rem 0.75rem; background: rgba(10, 14, 12, 0.55); }
.grimoire-info, .spell-info { min-width: 0; }
.grimoire-info h4, .spell-info h4 { font-size: 1rem; color: var(--ink); margin: 0.1rem 0 0.2rem; }
.grimoire-row .btn, .spell-row .btn { white-space: nowrap; min-height: 34px; padding: 0.35rem 0.65rem; font-size: 0.7rem; }
.spell-desc { font-size: 0.72rem; color: var(--muted); line-height: 1.6; margin: 0.35rem 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.help-grid h4 { color: var(--gold); font-size: 0.86rem; margin: 0 0 0.3rem; }
.help-grid p { font-size: 0.76rem; color: var(--muted); line-height: 1.65; margin: 0; }
.source-note { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.7rem; font-size: 0.68rem; color: var(--muted-2); }
.ending-modal { text-align: center; padding: 0.4rem 0 0.6rem; }
.ending-rank { font-family: var(--mono); font-size: 4.8rem; font-weight: 400; line-height: 1; color: var(--gold-bright); text-shadow: 0 0 50px rgba(200, 168, 107, 0.18); margin-bottom: 0.8rem; }
.ending-rank.rank-s { color: var(--gold-bright); }
.ending-rank.rank-a { color: var(--teal); }
.ending-rank.rank-b { color: var(--violet); }
.ending-rank.rank-f { color: var(--red); }
.ending-text { max-width: 45em; margin: 0 auto; color: var(--ink-dim); font-size: 0.9rem; line-height: 1.9; text-align: left; }
.ending-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: 0.9rem; font-family: var(--mono); font-size: 0.6rem; color: var(--muted-2); }
.ending-stats b { color: var(--gold); font-weight: 500; }
.combat-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr); gap: 1.2rem; }
.combat-monster-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.7rem; }
.combat-monster-head h4 { font-size: 1.3rem; color: var(--gold-bright); }
.combat-hp { margin: 0.6rem 0 0.8rem; }
.combat-hp-track { height: 7px; background: rgba(255, 255, 255, 0.06); margin: 0.25rem 0; border: 1px solid rgba(192, 105, 95, 0.2); }
.combat-hp-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--red-dim), var(--red)); transition: width 0.4s; }
.combat-hp b { font-family: var(--mono); font-size: 0.64rem; color: var(--red); font-weight: 400; }
.combat-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.7; border-left: 2px solid var(--line); padding-left: 0.6rem; }
.combat-stats { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 0.8rem 0; font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.combat-stats b { color: var(--ink); font-weight: 500; }
.combat-log { background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); padding: 0.55rem 0.65rem; max-height: 130px; overflow-y: auto; }
.combat-log p { font-size: 0.7rem; color: var(--muted); margin: 0 0 0.3rem; line-height: 1.55; }
.combat-log p:last-child { color: var(--ink-dim); }
.combat-attacks { font-size: 0.68rem; color: var(--muted-2); margin-top: 0.6rem; line-height: 1.6; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.combat-actions { display: flex; flex-direction: column; gap: 0.35rem; }
.combat-btn { text-align: left; border: 1px solid var(--line); background: rgba(12, 18, 16, 0.7); padding: 0.5rem 0.6rem; display: flex; flex-direction: column; gap: 0.1rem; transition: all 0.18s; color: var(--ink); }
.combat-btn:hover:not(:disabled) { border-color: var(--gold-line); background: rgba(200, 168, 107, 0.06); }
.combat-btn:disabled, .combat-spell-btn:disabled, .choice-btn:disabled { opacity: 0.34; filter: saturate(0.45); }
.combat-btn small { color: var(--muted-2); font-size: 0.58rem; font-family: var(--mono); }
.combat-btn.danger { border-color: rgba(192, 105, 95, 0.3); color: #d49a8f; }
.combat-spells { display: grid; grid-template-columns: 1fr; gap: 0.25rem; max-height: 150px; overflow-y: auto; }
.combat-spell-title { margin-top: 0.4rem; }
.combat-spell-btn { text-align: left; border: 1px solid rgba(105, 167, 155, 0.2); background: rgba(105, 167, 155, 0.05); padding: 0.4rem 0.5rem; display: flex; flex-direction: column; gap: 0.1rem; }
.combat-spell-btn:hover:not(:disabled) { border-color: rgba(105, 167, 155, 0.55); }
.combat-spell-btn b { font-size: 0.74rem; color: var(--teal); font-weight: 500; }
.combat-spell-btn small { font-size: 0.55rem; color: var(--muted-2); font-family: var(--mono); }

/* ==================================================================== dice */
.dice-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(2, 4, 3, 0.72); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.16s;
}
.dice-overlay.is-visible { opacity: 1; }
.dice-card { text-align: center; border: 1px solid var(--gold-line); background: linear-gradient(160deg, #111814, #080c0a); padding: 1.6rem 2.5rem; min-width: min(340px, 86vw); box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8); }
.dice-number { font-family: var(--mono); font-size: 4rem; color: var(--gold-bright); line-height: 1.05; letter-spacing: 0.06em; margin: 0.3rem 0; text-shadow: 0 0 35px rgba(200, 168, 107, 0.2); }
.dice-overlay.is-success .dice-number { color: var(--teal); }
.dice-overlay.is-failure .dice-number { color: var(--red); }
.dice-target { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); margin: 0.2rem 0; }
.dice-verdict { font-size: 1.1rem; letter-spacing: 0.15em; color: var(--muted); margin-top: 0.7rem; }
.dice-verdict.ok { color: var(--teal); }
.dice-verdict.bad { color: var(--red); }

/* ================================================================== toasts */
.toasts { position: fixed; top: 1rem; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: 0.45rem; width: min(360px, 88vw); pointer-events: none; }
.toast { background: rgba(12, 18, 16, 0.96); border: 1px solid var(--gold-line); border-left: 3px solid var(--gold); color: var(--ink-dim); font-size: 0.76rem; padding: 0.65rem 0.8rem; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); animation: toastIn 0.25s ease both; }
.toast.ok { border-left-color: var(--teal); }
.toast.warn { border-left-color: var(--red); }
.toast.error { border-left-color: var(--red); }
.toast.spell { border-left-color: var(--violet); }
.toast.leaving { opacity: 0; transform: translateX(10px); transition: all 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* =============================================================== responsive */
@media (max-width: 1380px) {
  .game-grid { grid-template-columns: 264px minmax(0, 1fr) 292px; }
  .topbar { grid-template-columns: minmax(220px, 1fr) auto auto auto; }
  .brand-sub { display: none; }
}
@media (max-width: 1150px) {
  .game-grid { grid-template-columns: 244px minmax(0, 1fr); }
  .panel-right { grid-column: 1 / -1; display: grid; grid-template-columns: 1.15fr 0.85fr 1fr; align-items: start; }
  .panel-right .quick-card { display: none; }
  .map-wrap { height: 200px; }
  .codex-body { grid-template-columns: 1fr; }
  .codex-detail { position: static; max-height: none; }
  .topbar { grid-template-columns: 1fr auto auto; }
  .topbar-resources { grid-row: 2; grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .topbar-nav { grid-row: 1; grid-column: 3; }
}
@media (max-width: 900px) {
  .create-grid { grid-template-columns: 1fr; }
  .create-preview { min-height: 0; }
  .game-grid { grid-template-columns: 1fr; }
  .panel-left { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .panel-left .dossier { grid-column: 1 / -1; }
  .panel-right { grid-template-columns: 1fr 1fr; }
  .stage { order: -1; }
  .stage-scene { height: 190px; }
  .action-dock { flex-wrap: wrap; }
  .dock-center { order: 3; width: 100%; justify-content: flex-start; }
  .dock-actions { margin-left: auto; }
  .dock-location { min-width: 0; }
  .combat-layout { grid-template-columns: 1fr; }
  .codex-head { flex-wrap: wrap; gap: 0.8rem; }
  .codex-title { min-width: 0; }
  .codex-search { order: 3; flex: 1 0 100%; max-width: none; }
  .codex-detail { min-height: 0; }
}
@media (max-width: 640px) {
  #screen-game { padding: 0 0.5rem 0.5rem; }
  .topbar {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 0.55rem 0.2rem; gap: 0.4rem 0.55rem;
  }
  .topbar-brand { order: 1; flex: 1 1 auto; min-width: 0; }
  .brand-mark { font-size: 0.85rem; }
  .brand-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; }
  .topbar-night { order: 2; flex: 0 0 auto; gap: 0.4rem; }
  .topbar-nav { order: 3; flex: 0 0 auto; margin-left: auto; }
  .topbar-resources { order: 4; flex: 1 1 100%; justify-content: flex-start; gap: 0.35rem; }
  .night-date { display: none; }
  .doom { width: 54px; }
  .res-chip { min-width: 0; flex: 1 1 0; padding: 0.2rem 0.35rem; }
  .res-text b { font-size: 0.68rem; }
  .icon-btn span { display: none; }
  .icon-btn { min-width: 36px; min-height: 36px; padding: 0.25rem 0.28rem; }
  .topbar-nav { gap: 0; }
  .title-actions .btn { min-height: 50px; }
  .action-dock { gap: 0.35rem; padding: 0.45rem 0.55rem max(0.45rem, env(safe-area-inset-bottom)); }
  .dock-location { display: none; }
  .dock-hint { display: none; }
  .dock-center { order: 0; flex: 1 1 100%; justify-content: space-between; }
  .dock-actions { order: 1; flex: 1 1 100%; margin-left: 0; justify-content: space-between; }
  .dock-actions .btn { flex: 1; min-height: 32px; padding: 0.3rem 0.2rem; font-size: 0.66rem; }
  .panel-left, .panel-right { grid-template-columns: 1fr; }
  .stage-body { padding: 0.9rem 0.8rem 0.8rem; }
  .stage-scene { height: 150px; }
  .scene-caption { left: 0.8rem; bottom: 0.6rem; }
  .scene-caption span { font-size: 0.5rem; letter-spacing: 0.16em; }
  .hub-head h3 { font-size: 1.15rem; }
  .location-head { flex-direction: column; gap: 0.4rem; }
  .hub-grid { grid-template-columns: 1fr; }
  .event-card, .location-card { padding: 0.9rem; }
  .choice-btn { padding: 0.7rem; }
  .title-actions { flex-direction: column; align-items: stretch; }
  .title-actions .btn { min-width: 0; }
  .create-head { flex-direction: column; gap: 0.8rem; }
  .create-launch { flex-direction: column; align-items: stretch; }
  .launch-actions { justify-content: space-between; }
  .name-field { max-width: none; }
  .codex-head { padding-top: 0.8rem; }
  .codex-tabs { padding-top: 0.4rem; }
  .codex-tab { padding: 0.5rem 0.55rem; font-size: 0.72rem; }
  .codex-card-top { flex-direction: column; gap: 0.2rem; }
  .codex-en { text-align: left; }
  .detail-meta-grid { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
  .grimoire-row, .spell-row { flex-direction: column; align-items: stretch; }
  .grimoire-row .btn, .spell-row .btn { width: 100%; }
  .modal { max-height: 92vh; }
  .modal-body { padding: 0.9rem; }
  .combat-layout { gap: 0.8rem; }
  .ending-rank { font-size: 3.6rem; }
  .toasts { top: 0.5rem; right: 0.5rem; }
}
@media (max-width: 640px) {
  #screen-title.is-active { padding-top: max(2rem, env(safe-area-inset-top)); padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  .title-sigil { width: 150px; height: 150px; }
  .sound-toggle { bottom: max(0.8rem, env(safe-area-inset-bottom)); }
}
@media (max-height: 1100px) {
  #screen-create { padding-top: 1.3rem; }
  .create-head h2 { font-size: 1.85rem; }
  .role-card { padding: 0.5rem 0.8rem; gap: 0.7rem; }
  .role-glyph { width: 28px; height: 28px; flex-basis: 28px; font-size: 0.56rem; }
  .role-skills { display: none; }
  .role-tagline { font-size: 0.74rem; }
  .stat-grid { margin: 0.65rem 0; }
  .stat-cell { padding: 0.38rem 0.4rem; }
  .create-launch { margin-top: 0.8rem; padding-top: 0.8rem; }
  .create-launch .btn-lg { min-height: 46px; padding: 0.65rem 1.4rem; font-size: 0.9rem; }
}
@media (max-height: 860px) {
  .title-sigil { width: 120px; height: 120px; margin-bottom: 0.4rem; }
  .game-title { margin-top: 0.35rem; margin-bottom: 0.45rem; }
  .title-actions { margin: 1rem 0 1.2rem; }
  .role-tagline { display: none; }
  .create-head .muted { display: none; }
  .create-head { margin-bottom: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
