/* =========================================================
   守则 · THE RULES
   Ink, paper, dust and one bad fluorescent light.
   ========================================================= */

:root {
  --ink: #ece5d5;
  --ink-soft: #c9c1af;
  --ink-dim: #938c7d;
  --ink-faint: #6b665c;
  --paper: #e3dac6;
  --paper-2: #d3c8b0;
  --paper-ink: #241f18;
  --paper-ink-soft: #4a4235;
  --bg: #1a1e19;
  --bg-lift: #242a23;
  --line: rgba(236, 229, 213, 0.12);
  --line-strong: rgba(236, 229, 213, 0.26);
  --accent: #c1503f;
  --accent-soft: #9d4436;
  --sanity: #d8cfb8;
  --corrupt: #96404a;
  --glow: 120, 150, 128;
  --glow-2: 190, 160, 110;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Serif SC", sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(95% 60% at 50% -8%, rgba(var(--glow), .30), transparent 64%),
    radial-gradient(60% 45% at 6% 106%, rgba(var(--glow-2), .18), transparent 72%),
    radial-gradient(70% 60% at 100% 18%, rgba(var(--glow), .14), transparent 70%),
    linear-gradient(175deg, #30372e 0%, #262c24 38%, #1c211b 72%, #171b16 100%);
  transition: background 1.8s var(--ease);
}
body::after {
  /* faint wallpaper grid + stains */
  content: "";
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px),
    radial-gradient(circle at 22% 18%, rgba(120,90,50,.07), transparent 22%),
    radial-gradient(circle at 78% 82%, rgba(90,80,60,.06), transparent 26%);
  background-size: 84px 84px, 84px 84px, 100% 100%, 100% 100%;
  mask-image: radial-gradient(120% 90% at 50% 40%, #000 20%, transparent 85%);
}

/* scene palettes */
.palette-ward      { --glow: 118, 158, 132; --glow-2: 180, 178, 130; --accent: #b8503f; }
.palette-tunnel    { --glow: 96, 128, 170; --glow-2: 120, 150, 175; --accent: #b8553f; }
.palette-classroom { --glow: 176, 150, 96; --glow-2: 190, 160, 100; --accent: #ad4f3a; }
.palette-apartment { --glow: 150, 122, 96; --glow-2: 170, 130, 95; --accent: #a94b3b; }
.palette-neon      { --glow: 96, 156, 148; --glow-2: 150, 110, 120; --accent: #c05a48; }
.palette-temple    { --glow: 172, 126, 78; --glow-2: 190, 140, 80; --accent: #b14a38; }

/* ---------- atmosphere ---------- */
.atmosphere { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.haze {
  position: absolute; inset: 0;
  background:
    radial-gradient(78% 58% at 50% 34%, rgba(var(--glow), .10), transparent 78%),
    linear-gradient(180deg, rgba(12,15,12,.05) 0%, rgba(10,13,10,.12) 46%, rgba(6,8,6,.42) 100%);
}
.grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 900;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(3) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0) }
  33% { transform: translate(-2%, 1.4%) }
  66% { transform: translate(1.6%, -1.8%) }
  100% { transform: translate(0,0) }
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 800;
  background:
    radial-gradient(125% 95% at 50% 42%, transparent 52%, rgba(0,0,0,.34) 100%),
    linear-gradient(180deg, rgba(0,0,0,.14), transparent 18%, transparent 86%, rgba(0,0,0,.26));
}
body[data-screen="title"] .grain { opacity: .035; }
body.danger-high .vignette { animation: pulse 7s var(--ease) infinite; }
@keyframes pulse { 0%,100%{opacity:.88} 50%{opacity:1} }

/* ---------- primitives ---------- */
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.app {
  height: 100dvh;
  max-width: 1280px;
  isolation: isolate;
  background: none;
  margin: 0 auto;
  padding: clamp(16px, 3.2vh, 34px) clamp(18px, 4.2vw, 56px);
  position: relative;
}
.screen { display: none; height: 100%; position: relative; }
.screen.is-active { display: flex; flex-direction: column; animation: screen-in .9s var(--ease); }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.kicker {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.micro { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); letter-spacing: .05em; line-height: 1.7; }

.btn {
  padding: 14px 32px;
  border-radius: 1px;
  font-size: 14.5px;
  letter-spacing: .18em;
  transition: all .4s var(--ease);
  position: relative;
}
.btn-primary {
  background: linear-gradient(180deg, #f2ecdc, #ded5c0);
  color: #1a1812;
  border: 1px solid #f4efe2;
  min-width: 200px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.3), inset 0 1px 0 #fff;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(0,0,0,.6), 0 0 26px rgba(var(--glow-2), .18); }
.btn-primary:disabled { opacity: .4; cursor: wait; transform: none; }
.btn-ghost {
  border: 1px solid var(--line-strong); color: var(--ink-soft); min-width: 200px;
  background: rgba(255,255,255,.015);
}
.btn-ghost:hover { border-color: rgba(236,229,213,.55); color: var(--ink); background: rgba(236,229,213,.05); }
.title-links .btn-text { color: #a8a08d; }
.title-links .btn-text:hover { color: #efe7d6; }
.btn-text { color: var(--ink-faint); font-size: 12.5px; letter-spacing: .14em; padding: 10px; }
.btn-text:hover { color: var(--ink-soft); }
.btn-wide { width: 100%; }

/* ---------- title ---------- */
#screen-title { justify-content: center; align-items: center; text-align: center; position: relative; }
#screen-title::after {
  content: ""; position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  width: min(900px, 92vw); height: 160px; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(var(--glow-2), .16), transparent 72%);
  filter: blur(18px);
}
.title-wrap { max-width: 600px; animation: title-in 1.8s var(--ease); position: relative; display: flex; flex-direction: column; align-items: center; }
.title-wrap::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(760px, 92vw); height: min(520px, 74vh); z-index: -1;
  background:
    radial-gradient(60% 55% at 50% 46%, rgba(6,8,6,.72), rgba(6,8,6,.3) 62%, transparent 84%);
  border-radius: 50%;
}
@keyframes title-in { from { opacity: 0; filter: blur(10px); transform: translateY(14px);} to { opacity: 1; filter: none; transform: none; } }
.title-lockup { display: flex; align-items: flex-start; justify-content: center; gap: 20px; }
.title {
  font-size: clamp(76px, 15vw, 156px);
  line-height: .9;
  margin: 0;
  font-weight: 600;
  letter-spacing: .14em;
  text-indent: .14em;
  color: #f6f0e0;
  text-shadow:
    0 1px 0 rgba(0,0,0,.85),
    0 4px 18px rgba(0,0,0,.95),
    0 0 60px rgba(255,246,220,.18),
    0 0 90px rgba(var(--glow-2), .3);
}
.title-seal {
  writing-mode: vertical-rl;
  font-size: 13px;
  letter-spacing: .3em;
  line-height: 1.5;
  color: var(--accent);
  border: 1px solid rgba(193,80,63,.55);
  padding: 8px 5px;
  margin-top: 12px;
  transform: rotate(3deg);
  opacity: .85;
}
.title-en {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .78em;
  text-indent: .78em;
  color: var(--accent);
  margin: 20px 0 0;
  opacity: .9;
}
.lede { color: #b6ae9d; text-shadow: 0 1px 12px rgba(0,0,0,.9); line-height: 2.1; font-size: 15px; margin: 32px 0 42px; letter-spacing: .04em; }
.title-actions { display: flex; flex-direction: column; gap: 11px; align-items: center; }
.foot-note { margin-top: 52px; font-family: var(--mono); font-size: 10px; color: #575349; letter-spacing: .1em; }
.title-meta {
  position: absolute; top: 30px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .22em; color: #565247;
  writing-mode: vertical-rl;
}
.title-meta-l { left: 10px; }
.title-meta-r { right: 10px; }

/* ---------- setup ---------- */
#screen-setup {
  padding: clamp(16px,2.6vh,28px) clamp(18px,2.8vw,36px);
  border: 1px solid rgba(236,229,213,.09);
  border-radius: 2px;
  background: linear-gradient(170deg, rgba(20,25,19,.74), rgba(11,14,11,.88));
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.screen-head { display: flex; align-items: center; gap: 18px; padding-bottom: 10px; }
.screen-head .kicker { margin: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink-dim);
  display: grid; place-items: center; font-size: 15px; transition: all .3s var(--ease);
  flex: none;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(255,255,255,.03); }
.screen-title { font-size: clamp(24px, 3vw, 32px); font-weight: 500; letter-spacing: .08em; margin: 10px 0 20px; }
.seed-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.seed {
  text-align: left; padding: 16px 14px; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255,255,255,.035), rgba(255,255,255,.008));
  transition: all .35s var(--ease); border-radius: 1px; min-height: 88px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  position: relative; overflow: hidden;
}
.seed::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 100% at 0% 0%, rgba(var(--glow), .12), transparent 70%);
  opacity: 0; transition: opacity .4s;
}
.seed:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.seed:hover::after { opacity: 1; }
.seed[aria-checked="true"] {
  border-color: #efe7d4;
  background: linear-gradient(160deg, rgba(239,231,212,.16), rgba(239,231,212,.05));
  box-shadow: inset 0 0 40px rgba(var(--glow-2), .1), 0 0 24px rgba(0,0,0,.35);
}
.seed-name { font-size: 13.5px; letter-spacing: .05em; position: relative; z-index: 1; }
.seed-idx { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); letter-spacing: .22em; position: relative; z-index: 1; }
.seed[aria-checked="true"] .seed-idx { color: var(--accent); }
.field-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .34em; color: var(--ink-faint); margin: 20px 0 10px; font-weight: 400; }
.difficulty-row { display: flex; gap: 10px; }
.difficulty {
  flex: 1; text-align: left; padding: 15px 18px; border: 1px solid var(--line); border-radius: 1px;
  transition: all .3s var(--ease); background: rgba(255,255,255,.012);
}
.difficulty:hover { border-color: var(--line-strong); }
.difficulty[aria-checked="true"] { border-color: rgba(236,229,213,.65); background: rgba(236,229,213,.06); }
.difficulty b { display: block; font-size: 14px; font-weight: 500; letter-spacing: .12em; margin-bottom: 4px; }
.difficulty span { font-size: 11.5px; color: var(--ink-faint); line-height: 1.65; }
.setup-actions { margin-top: auto; padding-top: 26px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- loading ---------- */
#screen-loading { justify-content: center; align-items: center; }
.loading-wrap { text-align: center; }
.paper-loader { width: 56px; height: 72px; margin: 0 auto 34px; position: relative; filter: drop-shadow(0 10px 24px rgba(0,0,0,.6)); }
.paper-loader span {
  position: absolute; inset: 0; background: linear-gradient(170deg, #e6ddc8, #c9bda2);
  animation: paper 2.6s var(--ease) infinite; border-radius: 1px;
}
.paper-loader span:nth-child(2) { animation-delay: .55s; }
.paper-loader span:nth-child(3) { animation-delay: 1.1s; }
@keyframes paper {
  0% { transform: translateY(16px) rotate(-4deg); opacity: 0; }
  28% { opacity: .92; }
  100% { transform: translateY(-34px) rotate(5deg); opacity: 0; }
}
.loading-line { font-size: 17px; letter-spacing: .14em; margin: 0 0 16px; min-height: 1.6em; color: var(--ink-soft); }

/* ---------- game ---------- */
.game-screen { gap: 12px; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.hud-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hud-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-place { font-size: 14px; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-turn { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); letter-spacing: .26em; }
.hud-time {
  text-align: right; display: flex; flex-direction: column; gap: 4px;
  padding-left: 22px; border-left: 1px solid var(--line);
}
.digital {
  font-family: var(--mono); font-size: 23px; letter-spacing: .1em; font-variant-numeric: tabular-nums;
  color: #efe8d8; text-shadow: 0 0 18px rgba(var(--glow-2), .28);
}
.hud-sub { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); letter-spacing: .18em; }

/* timeline */
.timeline { position: relative; height: 26px; margin: 2px 0 6px; }
.tl-track {
  position: absolute; left: 0; right: 0; top: 8px; height: 2px;
  background: rgba(236,229,213,.1);
}
.tl-track i {
  position: absolute; left: 0; top: 0; height: 100%; width: 12%;
  background: linear-gradient(90deg, rgba(var(--glow),.5), rgba(var(--glow-2),.85));
  transition: width 1.2s var(--ease);
  box-shadow: 0 0 10px rgba(var(--glow-2), .4);
}
.tl-track b {
  position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: #f0e7d2; box-shadow: 0 0 12px rgba(var(--glow-2), .9);
  transform: translateX(-4px); transition: left 1.2s var(--ease);
}
.tl-mark { position: absolute; top: 5px; width: 1px; height: 8px; background: rgba(236,229,213,.18); }
.tl-labels { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; }
.tl-labels i {
  font-family: var(--mono); font-style: normal; font-size: 8.5px; letter-spacing: .12em; color: #514d44;
  transform: translateX(-50%);
}
.tl-labels i:first-child { transform: none; }
.tl-labels i:last-child { transform: translateX(-100%); color: #6d5a4c; }

.meters { display: flex; gap: 26px; padding: 4px 0 14px; border-bottom: 1px solid var(--line); }
.meter { flex: 1; max-width: 230px; }
.meter-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9px; letter-spacing: .24em; color: var(--ink-faint); margin-bottom: 7px; }
.meter-head b { font-weight: 400; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 11px; }
.meter-track {
  height: 4px; background: rgba(236,229,213,.08); overflow: hidden; position: relative;
}
.meter-track::after {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 9px, rgba(10,10,9,.85) 9px 10px);
  pointer-events: none;
}
.meter-track i { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #a99f88, var(--sanity)); transition: width 1.2s var(--ease); }
.meter-corruption .meter-track i { background: linear-gradient(90deg, #6b2c33, var(--corrupt)); }
.meter-sanity.low .meter-track i { background: linear-gradient(90deg, #a4564a, #d07a64); animation: lowpulse 2.4s infinite; }
@keyframes lowpulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

.game-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: clamp(22px, 4vw, 56px); min-height: 0; }

.scene {
  overflow-y: auto; scrollbar-width: thin; position: relative;
  margin: 18px 0 0;
  padding: 30px clamp(20px, 2.6vw, 38px) 30px clamp(26px, 2.8vw, 40px);
  border: 1px solid rgba(236,229,213,.10);
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0) 22%),
    radial-gradient(70% 46% at 8% 4%, rgba(var(--glow-2), .18), transparent 66%),
    linear-gradient(180deg, rgba(22,27,22,.34) 0%, rgba(17,22,18,.58) 30%, rgba(14,18,15,.86) 66%, rgba(12,16,13,.94) 100%);
  box-shadow:
    0 30px 70px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 0 140px rgba(0,0,0,.3);
  backdrop-filter: blur(2px) saturate(1.05);
}
/* 卷宗左边的装订线 */
.scene::before {
  content: ""; position: absolute; left: clamp(12px, 1.4vw, 20px); top: 26px; bottom: 26px; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(193,80,63,.45) 12%, rgba(193,80,63,.28) 88%, transparent);
}
.scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 2px;
  background-image: repeating-linear-gradient(0deg, transparent 0 31px, rgba(236,229,213,.018) 31px 32px);
  mask-image: linear-gradient(180deg, #000, transparent 70%);
}
.scene-ghost {
  position: absolute; right: 10px; top: 4px; z-index: 0;
  font-family: var(--mono); font-size: clamp(60px, 9vw, 108px); font-weight: 700;
  letter-spacing: -.04em; color: rgba(236,229,213,.045); pointer-events: none; user-select: none;
  line-height: 1;
}
.scene > *:not(.scene-ghost):not(.scene-photo) { position: relative; z-index: 2; }
.scene-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.scene-case {
  font-family: var(--mono); font-size: 9px; letter-spacing: .2em;
  color: #d68d7d; border: 1px solid rgba(193,80,63,.42); padding: 3px 7px;
  background: rgba(193,80,63,.08);
}
.scene-location { font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; color: var(--ink-faint); }
.scene-danger { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: .2em; padding: 4px 9px; border: 1px solid var(--line); color: var(--ink-faint); background: rgba(0,0,0,.2); }
.scene-danger[data-danger="danger"] { color: #d49b72; border-color: rgba(212,155,114,.35); }
.scene-danger[data-danger="critical"] { color: #e08a7a; border-color: rgba(224,138,122,.45); animation: lowpulse 2s infinite; }
.scene-danger[data-danger="calm"] { color: #93a38c; border-color: rgba(147,163,140,.3); }

.narration {
  font-size: clamp(16px, 1.42vw, 18px);
  line-height: 2.15;
  letter-spacing: .025em;
  color: #eee7d6;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.narration p { margin: 0 0 1.15em; }
.narration p:first-child::first-letter {
  font-size: 2.6em; line-height: .92; float: left; padding: 6px 10px 0 0;
  color: #f3ecdc; text-shadow: 0 0 20px rgba(var(--glow-2), .3);
}
.narration p:last-child { margin-bottom: 0; }
.inner-voice {
  margin: 32px 0 6px; padding: 2px 0 2px 18px; border-left: 1px solid rgba(193,80,63,.45);
  font-size: 13.5px; color: #a89588; letter-spacing: .16em; min-height: 1em;
  text-shadow: 0 0 22px rgba(193,80,63,.18);
}
.scene-rule { margin: 34px 0 4px; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }

/* side */
.side {
  display: flex; flex-direction: column; min-height: 0; position: relative;
  margin: 18px 0 0; padding: 24px 20px 18px;
  border: 1px solid rgba(236,229,213,.14); border-radius: 2px;
  background:
    radial-gradient(80% 40% at 100% 0%, rgba(var(--glow), .08), transparent 70%),
    linear-gradient(170deg, rgba(38,44,36,.86), rgba(24,29,24,.92));
  box-shadow: 0 30px 70px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(3px);
}
.side-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.side-tab {
  font-family: var(--mono); font-size: 10px; letter-spacing: .22em; color: var(--ink-faint);
  padding: 0 0 11px; position: relative; transition: color .3s;
}
.side-tab b { font-weight: 400; opacity: .65; }
.side-tab:hover { color: var(--ink-soft); }
.side-tab.is-active { color: var(--ink); }
.side-tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--ink); box-shadow: 0 0 8px rgba(236,229,213,.5); }
.side-panel { display: none; flex: 1 1 auto; overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-width: thin; }
.side-panel.is-active { display: block; animation: panel-in .5s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* paper */
.paper {
  background:
    radial-gradient(circle at 14% 12%, rgba(120,96,55,.13), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(120,96,55,.11), transparent 30%),
    linear-gradient(168deg, #efe7d4 0%, #e2d8c2 52%, #d5c9af 100%);
  color: var(--paper-ink);
  padding: 24px 20px 28px;
  position: relative;
  box-shadow:
    0 24px 60px rgba(0,0,0,.55),
    0 3px 0 rgba(0,0,0,.25),
    inset 0 0 90px rgba(120,100,60,.12);
  transform: rotate(-.4deg);
}
.paper::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(0deg, transparent 0 25px, rgba(35,30,20,.045) 25px 26px);
  mix-blend-mode: multiply;
}
.paper::after {
  content: ""; position: absolute; top: -10px; left: 50%; width: 96px; height: 24px;
  transform: translateX(-50%) rotate(-1.5deg);
  background: linear-gradient(180deg, rgba(220,205,170,.55), rgba(196,180,145,.3));
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  opacity: .85;
}
.paper-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid rgba(35,30,20,.55); padding-bottom: 11px; margin-bottom: 15px; position: relative; }
.paper-title { font-size: 15.5px; font-weight: 700; letter-spacing: .16em; margin: 0; }
.paper-code { font-family: var(--mono); font-size: 8px; letter-spacing: .08em; opacity: .5; }
.rule {
  display: grid; grid-template-columns: 21px 1fr; gap: 8px;
  font-size: 12.2px; line-height: 1.85; padding: 8px 4px 8px 2px;
  border-bottom: 1px dotted rgba(35,30,20,.2);
  cursor: pointer; transition: background .3s, transform .3s; position: relative;
}
.rule:hover { background: rgba(35,30,20,.045); transform: translateX(2px); }
.rule:last-child { border-bottom: 0; }
.rule-num { font-family: var(--mono); font-size: 9.5px; padding-top: 3px; opacity: .5; }
.rule[data-style="handwritten"] .rule-text { font-family: "Kaiti SC", "KaiTi", "STKaiti", var(--serif); font-size: 13.4px; letter-spacing: .02em; }
.rule[data-style="torn"] .rule-text { opacity: .84; }
.rule[data-style="torn"] .rule-text::after { content: " ⌁"; opacity: .4; }
.rule-note { display: block; font-family: var(--mono); font-size: 8.5px; opacity: .48; margin-top: 4px; letter-spacing: .05em; }
.rule.is-violated { background: rgba(150,40,30,.09); }
.rule.is-violated .rule-num { color: #8d2b20; opacity: 1; }
.rule.is-violated .rule-text { text-decoration: line-through; text-decoration-color: rgba(150,40,30,.35); text-decoration-thickness: 1px; }
.rule.is-found { animation: found 2.6s var(--ease); }
@keyframes found { 0% { background: rgba(170,145,75,.4) } 100% { background: transparent } }
.rule.is-pulse .rule-text { animation: rulepulse 1.5s var(--ease); }
@keyframes rulepulse { 0%,100% { background: transparent } 40% { background: rgba(150,40,30,.24) } }
.side-foot { margin-top: 12px; }

.stamp {
  position: absolute; right: 14px; bottom: 10px;
  font-family: var(--mono); font-size: 8px; line-height: 1.5; letter-spacing: .12em;
  color: rgba(160,54,40,.5); border: 1.5px solid rgba(160,54,40,.4);
  padding: 5px 7px; transform: rotate(-7deg); border-radius: 2px; text-align: center;
  mix-blend-mode: multiply; pointer-events: none;
}

.rule-flash {
  margin-top: 16px; padding: 13px 15px; border-left: 2px solid var(--accent);
  background: linear-gradient(90deg, rgba(193,80,63,.12), rgba(193,80,63,.02));
  animation: flashin .55s var(--ease);
}
@keyframes flashin { from { opacity: 0; transform: translateX(-8px) } to { opacity: 1; transform: none } }
.rule-flash-label { font-family: var(--mono); font-size: 8.5px; letter-spacing: .24em; color: #cf8878; }
.rule-flash p { margin: 7px 0 0; font-size: 12.5px; line-height: 1.72; color: #b7afa0; }

.panel-label { font-family: var(--mono); font-size: 9px; letter-spacing: .28em; color: var(--ink-faint); margin: 22px 0 10px; font-weight: 400; text-transform: uppercase; }
.panel-label:first-child { margin-top: 0; }
.panel-label .count { color: var(--ink-dim); margin-left: 4px; }
.clue-list { display: flex; flex-direction: column; gap: 8px; }
.clue-item { font-size: 12.5px; line-height: 1.7; color: #b0a999; padding-left: 14px; position: relative; }
.clue-item::before { content: ""; position: absolute; left: 0; top: .78em; width: 5px; height: 1px; background: var(--ink-faint); }
.clue-item small { display: block; font-family: var(--mono); font-size: 8.5px; color: #5d594f; margin-top: 3px; }
.empty { font-size: 12px; color: #5d594f; font-style: italic; }
.objective { font-size: 14px; line-height: 1.95; margin: 0; color: #d3cbca; color: #d2caba; }
.canon-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.canon-list li { font-size: 11.8px; line-height: 1.8; color: #a49d8e; padding-left: 12px; border-left: 1px solid var(--line); }

/* inventory */
.inventory-list { display: flex; flex-direction: column; gap: 7px; }
.item-card {
  display: flex; align-items: flex-start; gap: 10px; text-align: left; width: 100%;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 1px;
  transition: all .3s var(--ease); background: linear-gradient(160deg, rgba(255,255,255,.03), rgba(255,255,255,.005));
  position: relative; overflow: hidden;
}
.item-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: transparent; transition: background .3s;
}
.item-card:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(236,229,213,.055); transform: translateX(2px); }
.item-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card:hover:not(:disabled)::before { background: rgba(236,229,213,.35); }
.item-card:disabled { opacity: .35; cursor: default; }
.item-card.is-armed { border-color: rgba(193,80,63,.6); background: rgba(193,80,63,.08); }
.item-card.is-armed::before { background: var(--accent); }
.item-glyph {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .04em; color: #8d897c;
  border: 1px solid var(--line); padding: 3px 5px; margin-top: 1px; white-space: nowrap;
}
.item-glyph[data-kind="cleanse"] { color: #9bb3a6; border-color: rgba(155,179,166,.32); }
.item-glyph[data-kind="calm"] { color: #c2b294; border-color: rgba(194,178,148,.32); }
.item-glyph[data-kind="talisman"] { color: #cd9a90; border-color: rgba(205,154,144,.4); }
.item-body { flex: 1; min-width: 0; }
.item-name { font-size: 13px; display: flex; justify-content: space-between; gap: 8px; color: #ddd5c5; }
.item-name i { font-family: var(--mono); font-style: normal; font-size: 9px; color: var(--ink-faint); }
.item-desc { font-size: 11.3px; color: #8d897d; line-height: 1.6; margin-top: 4px; }
.item-verb { font-family: var(--mono); font-size: 8.5px; letter-spacing: .14em; color: #9d9482; white-space: nowrap; margin-top: 2px; }
.item-card.is-armed .item-verb { color: #d99284; }

/* choices */
.choices { display: grid; grid-template-columns: 1fr; gap: 8px; padding-top: 4px; }
.choice {
  display: flex; align-items: center; gap: 16px; text-align: left; width: 100%;
  padding: 14px 20px; border: 1px solid var(--line); border-radius: 1px;
  transition: all .32s var(--ease); background: linear-gradient(90deg, rgba(255,255,255,.025), rgba(255,255,255,.006));
  animation: choice-in .55s var(--ease) backwards; position: relative; overflow: hidden;
}
.choice::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: rgba(236,229,213,.28); transform: scaleY(0); transform-origin: bottom; transition: transform .32s var(--ease);
}
.choice:nth-child(2) { animation-delay: .07s; }
.choice:nth-child(3) { animation-delay: .14s; }
@keyframes choice-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.choice:hover { border-color: rgba(236,229,213,.55); background: rgba(104,113,97,.55); padding-left: 24px; }
.choice:hover::before { transform: scaleY(1); }
.choice-idx { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); min-width: 18px; }
.choice-label { flex: 1; font-size: 14.5px; letter-spacing: .02em; line-height: 1.65; }
.choice-risk {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .18em; color: var(--ink-dim);
  border: 1px solid rgba(236,229,213,.14); padding: 2px 7px; border-radius: 999px;
}
.choice-risk[data-risk="high"] { color: #d08b7d; border-color: rgba(193,80,63,.4); background: rgba(193,80,63,.1); }
.choice-risk[data-risk="low"] { color: #96a88b; border-color: rgba(150,168,139,.3); }
.choice:disabled { opacity: .35; pointer-events: none; }
.choices.is-busy .choice { pointer-events: none; opacity: .26; filter: blur(.4px); }

.free-form { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.free-form input {
  background: rgba(74,84,70,.32); border: 1px solid rgba(236,229,213,.08);
  border-radius: 1px; padding: 10px 12px; transition: border-color .3s, background .3s;
}
.free-form input:hover { background: rgba(84,95,79,.4); }
.free-form input:focus { outline: none; border-color: rgba(236,229,213,.3); background: rgba(90,101,84,.45); }
.free-form input {
  flex: 1; background: transparent; border: 0; padding: 10px 2px; font-size: 13.5px; color: var(--ink);
  letter-spacing: .04em; min-width: 0; font-family: var(--serif);
}
.free-form input::placeholder { color: #57544b; }
.send-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); color: var(--ink-dim); border-radius: 50%;
  transition: all .3s; display: grid; place-items: center;
}
.send-btn:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(255,255,255,.04); }
.free-form input:disabled, .send-btn:disabled { opacity: .35; }

/* thinking */
.thinking {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; color: #8b8578;
  padding: 6px 2px 3px; min-height: 26px;
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: #938c7d; animation: dot 1.2s infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .18s; }
.thinking-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; transform: translateY(0) } 30% { opacity: 1; transform: translateY(-3px) } }

/* ---------- intro ---------- */
.game-screen { position: relative; }
.intro {
  position: absolute; inset: -10px; z-index: 30;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(var(--glow), .16), transparent 68%),
    rgba(10,12,10,.74);
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; padding: 7vh 0;
  animation: fade .9s var(--ease);
}
.intro-inner {
  max-width: 680px; width: 100%; padding: clamp(30px,4vh,48px) clamp(24px,4.6vw,52px);
  border: 1px solid rgba(236,229,213,.12);
  background:
    radial-gradient(70% 40% at 0% 0%, rgba(var(--glow-2), .12), transparent 70%),
    linear-gradient(168deg, rgba(32,38,31,.97), rgba(16,20,16,.985));
  box-shadow: 0 40px 100px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.05);
  border-radius: 2px;
  position: relative;
}
.intro-inner::before {
  content: ""; position: absolute; left: 0; top: 40px; bottom: 40px; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(193,80,63,.5) 18%, rgba(193,80,63,.25) 82%, transparent);
}
.intro-text { font-size: clamp(16px, 1.5vw, 18px); line-height: 2.15; color: #ddd6c6; margin-bottom: 38px; }
.intro-text p { margin: 0 0 1.1em; }
.intro-text p:first-child::first-letter {
  font-size: 2.4em; float: left; line-height: .95; padding: 5px 9px 0 0; color: #f2ecdc;
}
.intro .btn { width: 100%; }
.intro .micro { margin: 14px 0 0; text-align: center; }
.intro-kicker { color: var(--accent); }
.game-screen.intro-open .hud,
.game-screen.intro-open .timeline,
.game-screen.intro-open .meters,
.game-screen.intro-open .game-body,
.game-screen.intro-open .choices,
.game-screen.intro-open .free-form,
.game-screen.intro-open .thinking { filter: blur(8px); opacity: .14; pointer-events: none; user-select: none; }
.game-screen.intro-open { overflow: hidden; }

/* ---------- ending ---------- */
#screen-ending { justify-content: center; align-items: center; overflow-y: auto; padding: 24px 0; }
body[data-screen="ending"] .haze { background: linear-gradient(180deg, rgba(10,13,10,.15), rgba(8,10,8,.3) 55%, rgba(5,7,5,.6) 100%); }
.ending-card {
  max-width: 720px; width: 100%; padding: clamp(30px,3.8vw,48px) clamp(26px,3.8vw,54px) 42px;
  margin: auto;
  border: 1px solid rgba(236,229,213,.10);
  background:
    radial-gradient(90% 50% at 12% -6%, rgba(var(--glow-2), .16), transparent 62%),
    radial-gradient(70% 40% at 100% 100%, rgba(var(--glow), .08), transparent 70%),
    linear-gradient(168deg, rgba(45,52,43,.97), rgba(23,28,23,.99));
  box-shadow: 0 34px 90px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.05);
  border-radius: 2px;
  position: relative;
}
.ending-card::before {
  content: ""; position: absolute; left: 0; top: 34px; bottom: 34px; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(193,80,63,.45) 15%, rgba(193,80,63,.25) 85%, transparent);
}
.ending-title { font-size: clamp(32px, 5vw, 50px); font-weight: 500; letter-spacing: .1em; margin: 8px 0 14px; color: #f2ecdd; text-shadow: 0 0 40px rgba(var(--glow-2), .2); }
.ending-meta { font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; color: var(--ink-faint); margin: 0 0 34px; }
.ending-text { font-size: 16px; line-height: 2.15; color: #d9d2c2; }
.ending-text p { margin: 0 0 1.1em; }
.ending-text p:first-child::first-letter {
  font-size: 2.7em; float: left; line-height: .92; padding: 6px 10px 0 0; color: #f4eedd;
}
.epitaph { margin: 34px 0 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: #938c7d; letter-spacing: .1em; font-style: italic; }
.ending-stats { display: flex; gap: 26px; margin-top: 26px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; color: var(--ink-faint); flex-wrap: wrap; }
.ending-stats b { color: #ada697; font-weight: 400; }
.ending-fatal { margin-top: 22px; padding: 14px 16px; border-left: 2px solid rgba(193,80,63,.6); background: rgba(193,80,63,.06); }
.ending-fatal .panel-label { margin: 0 0 6px; color: #c58a7c; }
.ending-fatal p { margin: 0; font-size: 13px; line-height: 1.8; color: #aba394; }
.ending-actions { display: flex; gap: 12px; margin-top: 38px; }
.ending-actions .btn { flex: 1; }
.ending-home { display: block; margin: 18px auto 0; }

/* ---------- archive ---------- */
#screen-archive {
  overflow-y: auto;
  padding: clamp(16px,2.6vh,28px) clamp(18px,2.8vw,36px);
  border: 1px solid rgba(236,229,213,.09);
  background: linear-gradient(170deg, rgba(20,25,19,.76), rgba(12,15,12,.9));
  backdrop-filter: blur(2px);
  box-shadow: 0 30px 80px rgba(0,0,0,.5); border-radius: 2px;
}
.archive-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 30px; }
.archive-item {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; text-align: left;
  padding: 18px 20px; border: 1px solid var(--line); transition: all .3s var(--ease);
  background: linear-gradient(90deg, rgba(255,255,255,.02), transparent);
}
.archive-item:hover { border-color: var(--line-strong); background: rgba(255,255,255,.035); }
.archive-main { min-width: 0; }
.archive-name { font-size: 15px; margin-bottom: 5px; }
.archive-sub { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); letter-spacing: .1em; }
.archive-end { font-family: var(--mono); font-size: 9.5px; color: var(--accent); letter-spacing: .1em; white-space: nowrap; }
.archive-del { font-family: var(--mono); font-size: 9.5px; color: #575349; padding: 8px; }
.archive-del:hover { color: var(--accent); }

/* ---------- sheet & toast ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 950; background: rgba(4,5,4,.74); display: grid; place-items: center;
  backdrop-filter: blur(7px); animation: fade .35s;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet-card {
  width: min(390px, 88vw); background: linear-gradient(170deg, #191c17, #111310);
  border: 1px solid var(--line-strong); padding: 32px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.sheet-card h3 { margin: 0 0 4px; font-weight: 500; letter-spacing: .18em; }
.sheet-card .micro { margin: 0 0 14px; }
.sheet-card .btn { min-width: 0; padding: 12px; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 18px);
  background: rgba(24,27,22,.96); border: 1px solid var(--line-strong); padding: 13px 22px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .45s var(--ease); z-index: 1000; max-width: 88vw; text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,.6); line-height: 1.7;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(193,80,63,.55); color: #e6b8ae; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- responsive ---------- */

/* ---------------- generated art ---------------- */
.art {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
  transform: scale(1.03);
}
body[data-screen="title"] .art {
  background-image: url(/art/title.webp);
  opacity: .95; filter: saturate(.78) brightness(.92) contrast(1.04);
}
body[data-screen="auth"] .art {
  background-image: url(/art/auth.webp);
  opacity: .72; filter: saturate(.72) brightness(.5);
}
body[data-screen="setup"] .art {
  background-image: url(/art/setup.webp);
  opacity: .78; filter: saturate(.7) brightness(.52);
}
body[data-screen="archive"] .art {
  background-image: url(/art/archive.webp);
  opacity: .7; filter: saturate(.7) brightness(.48);
}
body[data-screen="loading"] .art {
  background-image: url(/art/loading.webp);
  opacity: .62; filter: saturate(.6) brightness(.5);
}
body[data-screen="game"] .art {
  background-image: var(--art, none);
  opacity: .38; filter: saturate(.7) brightness(.5) contrast(1.05) blur(3px);
}
body[data-screen="ending"] .art {
  background-image: var(--art, none);
  opacity: .28; filter: saturate(.7) brightness(.45) blur(4px);
}
body[data-screen="ending"][data-ending="death"] .art,
body[data-screen="ending"][data-ending="assimilated"] .art {
  background-image: url(/art/ending-dark.webp);
  opacity: .62; filter: saturate(.62) brightness(.52) blur(1px);
}
body[data-screen="ending"][data-ending="survived"] .art,
body[data-screen="ending"][data-ending="truth"] .art {
  background-image: url(/art/ending-dawn.webp);
  opacity: .6; filter: saturate(.72) brightness(.58) blur(1px);
}
body[data-screen="title"] .haze,
body[data-screen="auth"] .haze {
  background:
    radial-gradient(58% 50% at 50% 46%, rgba(8,10,8,.55) 0%, rgba(8,10,8,.2) 58%, transparent 82%),
    linear-gradient(180deg, rgba(8,10,8,.15) 0%, rgba(6,8,6,.35) 60%, rgba(4,5,4,.72) 100%);
}
body[data-screen="setup"] .haze,
body[data-screen="archive"] .haze,
body[data-screen="loading"] .haze {
  background: linear-gradient(180deg, rgba(8,10,8,.34) 0%, rgba(6,8,6,.46) 55%, rgba(4,5,4,.72) 100%);
}
body[data-screen="game"] .haze {
  background: linear-gradient(180deg, rgba(8,10,8,.28) 0%, rgba(6,8,6,.45) 55%, rgba(4,5,4,.75) 100%);
}
body[data-screen="ending"] .haze {
  background: linear-gradient(180deg, rgba(8,10,8,.2) 0%, rgba(6,8,6,.38) 60%, rgba(4,5,4,.68) 100%);
}

/* ---------------- scene photo plate ---------------- */
.scene-photo {
  position: absolute; inset: 0; z-index: 1;
  background-image: var(--art, none); background-size: cover; background-position: center 28%;
  filter: grayscale(.25) contrast(1.05) brightness(.95) saturate(.85);
  opacity: .46;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.95) 0%, rgba(0,0,0,.55) 26%, rgba(0,0,0,.1) 52%, transparent 66%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.95) 0%, rgba(0,0,0,.55) 26%, rgba(0,0,0,.1) 52%, transparent 66%);
  pointer-events: none;
}
.scene { overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(236,229,213,.18) transparent; }
.scene::-webkit-scrollbar { width: 4px; }
.scene::-webkit-scrollbar-thumb { background: rgba(236,229,213,.16); }

/* ---------------- item icons ---------------- */
.item-icon {
  width: 60px; height: 60px; flex: none; border-radius: 2px;
  background-size: cover; background-position: center;
  mix-blend-mode: screen;
  filter: brightness(1.5) contrast(1.1) saturate(.95);
  mask-image: radial-gradient(closest-side, #000 58%, rgba(0,0,0,.55) 78%, transparent 100%);
  -webkit-mask-image: radial-gradient(closest-side, #000 58%, rgba(0,0,0,.55) 78%, transparent 100%);
  align-self: center;
}
.item-card[data-kind="calm"] { --kind: #9fb7a8; }
.item-card[data-kind="cleanse"] { --kind: #9bb3a6; }
.item-card[data-kind="tool"] { --kind: #b7a98c; }
.item-card[data-kind="talisman"] { --kind: #c08a72; }
.item-card[data-kind="light"] { --kind: #cbb06a; }
.item-card[data-kind="offering"] { --kind: #a98fb0; }
.item-card::before { background: var(--kind, rgba(236,229,213,.3)); opacity: .55; }
.item-card { gap: 10px; }

/* ---------------- auth ---------------- */
.auth-screen { justify-content: center; align-items: center; padding: 24px 18px; }
.auth-card {
  width: min(430px, 94vw); display: flex; flex-direction: column; align-items: center;
  padding: clamp(26px,4vh,44px) clamp(22px,4vw,40px);
  border: 1px solid rgba(236,229,213,.13); border-radius: 2px;
  background:
    radial-gradient(80% 50% at 50% -10%, rgba(var(--glow-2), .12), transparent 66%),
    linear-gradient(168deg, rgba(30,35,29,.96), rgba(14,17,14,.985));
  box-shadow: 0 40px 100px rgba(0,0,0,.72), inset 0 1px 0 rgba(255,255,255,.05);
  text-align: center;
}
.auth-title {
  font-size: clamp(38px, 7vw, 54px); font-weight: 500; letter-spacing: .22em;
  margin: 6px 0 2px; text-indent: .22em; color: #f4eedf;
  text-shadow: 0 2px 16px rgba(0,0,0,.9), 0 0 50px rgba(var(--glow-2), .2);
}
.auth-lede { color: #a9a294; font-size: 13px; line-height: 2; margin: 8px 0 22px; }
.auth-tabs { display: flex; gap: 2px; margin-bottom: 18px; border: 1px solid var(--line); padding: 3px; border-radius: 2px; }
.auth-tab {
  background: none; border: 0; color: var(--ink-faint); font: inherit; font-size: 12.5px;
  letter-spacing: .18em; padding: 8px 22px; cursor: pointer; transition: all .3s var(--ease);
  border-radius: 1px;
}
.auth-tab.is-active { color: #1a1c17; background: #ded6c2; }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.auth-field > span { font-family: var(--mono); font-size: 9px; letter-spacing: .28em; color: var(--ink-faint); }
.auth-field input {
  background: rgba(74,84,70,.28); border: 1px solid rgba(236,229,213,.14); border-radius: 1px;
  color: #ece5d6; font: inherit; font-size: 15px; padding: 11px 13px; transition: all .25s;
}
.auth-field input:focus { outline: none; border-color: rgba(236,229,213,.4); background: rgba(90,101,84,.4); }
.title-links { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; }
.link-sep { color: #57534a; font-size: 11px; }
.title-account {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 20px 0 0; font-size: 11.5px; letter-spacing: .08em; color: #9a9280;
}
.account-dot {
  width: 5px; height: 5px; border-radius: 50%; background: #8fae8b;
  box-shadow: 0 0 8px rgba(143,174,139,.85);
}
.link-btn {
  background: none; border: 0; color: #a49b86; font: inherit; font-size: 11.5px;
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer; padding: 0 2px;
}
.link-btn:hover { color: #ded6c2; }

.auth-error { min-height: 18px; margin: 2px 0 0; font-size: 12px; color: #d0877a; text-align: left; }
.auth-error.is-ok { color: #9dba9a; }
.auth-hint { margin: 16px 0 0; font-size: 11.5px; line-height: 1.9; color: #6f6a5e; }
.account-row {
  display: flex; align-items: baseline; gap: 8px; padding: 12px 0 6px;
  border-top: 1px solid var(--line); margin-top: 6px;
}
.account-name { font-size: 14px; color: #ded6c2; letter-spacing: .06em; }
.account-note { font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; color: var(--ink-faint); margin-left: auto; }
.btn-danger-text { color: #b06a5c; }
.btn-danger-text:hover { color: #d0877a; }
.sheet-wide { width: min(460px, 92vw); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .btn { flex: 1; justify-content: center; }

/* ---------------- settings ---------------- */
.set-card { width: min(520px, 94vw); max-height: 90dvh; overflow-y: auto; gap: 14px; }
.set-head { display: flex; flex-direction: column; gap: 6px; }
.set-head h3 { margin: 0; }
.set-field { display: flex; flex-direction: column; gap: 7px; }
.set-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .26em; color: var(--ink-faint);
}
.set-input {
  background: rgba(74,84,70,.26); border: 1px solid rgba(236,229,213,.14); border-radius: 1px;
  color: #ece5d6; font: inherit; font-size: 14px; padding: 10px 12px; width: 100%;
  transition: border-color .25s, background .25s, box-shadow .25s;
}
.set-input:hover { background: rgba(84,95,79,.32); }
.set-input:focus { outline: none; border-color: rgba(236,229,213,.42); background: rgba(90,101,84,.38); }
.set-input::placeholder { color: #6b675c; }
.set-hint { font-size: 11.5px; line-height: 1.7; color: #7f796c; display: flex; align-items: center; gap: 6px; }
.set-key-row { display: flex; gap: 8px; align-items: stretch; }
.set-key-row .set-input { flex: 1; }
.eye-btn {
  flex: none; width: 42px; display: grid; place-items: center; cursor: pointer;
  background: rgba(74,84,70,.26); border: 1px solid rgba(236,229,213,.14); border-radius: 1px;
  color: #8e8878; transition: all .25s;
}
.eye-btn:hover { color: #ded6c2; border-color: rgba(236,229,213,.34); }
.eye-btn.is-on { color: #ded6c2; background: rgba(90,101,84,.4); }
.eye-btn .eye-slash { opacity: 1; transition: opacity .2s; }
.eye-btn.is-on .eye-slash { opacity: 0; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none; background: #6b675c;
  box-shadow: 0 0 0 3px rgba(107,103,92,.12);
}
.status-dot[data-state="configured"] { background: #8fae8b; box-shadow: 0 0 8px rgba(143,174,139,.75); }
.status-dot[data-state="missing"] { background: #b06a5c; box-shadow: 0 0 8px rgba(176,106,92,.55); }
.status-dot[data-state="fallback"] { background: #a89a6e; box-shadow: 0 0 8px rgba(168,154,110,.45); }
.set-clear { align-self: flex-start; font-size: 11px; }
.set-model-row { display: flex; gap: 8px; }
.set-model-row .set-input { flex: 1; }
.btn-compact { flex: none; font-size: 11.5px; padding: 0 14px; white-space: nowrap; }
.model-picker {
  border: 1px solid rgba(236,229,213,.14); border-radius: 1px; background: rgba(12,16,12,.72);
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
.model-picker-head { display: flex; align-items: center; gap: 8px; }
.model-picker-head .set-input { font-size: 12.5px; padding: 7px 10px; }
.model-count { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); min-width: 26px; text-align: right; }
.model-list {
  list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin;
}
.model-row {
  width: 100%; display: flex; align-items: baseline; gap: 10px; cursor: pointer;
  background: none; border: 0; border-radius: 1px; padding: 6px 8px; text-align: left;
  color: #cdc5b3; transition: background .2s, color .2s;
}
.model-row:hover { background: rgba(236,229,213,.08); color: #f0e9d8; }
.model-row.is-current { background: rgba(var(--glow-2), .10); color: #f0e9d8; box-shadow: inset 2px 0 0 rgba(193,80,63,.65); }
.model-id { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.model-name { font-size: 11px; color: #7f796c; margin-left: auto; }
.model-empty { padding: 10px 8px; font-size: 12px; color: #6f6a5e; }
.set-status { min-height: 18px; margin: 0; font-size: 12px; color: #9a9384; }
.set-status.is-ok { color: #9dba9a; }
.set-status.is-error { color: #d0877a; }

@media (max-width: 960px) {
  body { overflow: auto; }
  .scene-photo { height: 150px; }
  .auth-card { padding: 24px 18px; }
  .auth-title { font-size: 40px; }
  .item-icon { width: 40px; height: 40px; }
  .atmosphere { position: fixed; }
  .app { padding: 10px 12px 24px; }
  .app { height: auto; min-height: 100dvh; padding-bottom: 22px; }
  .screen { height: auto; min-height: calc(100dvh - 40px); }
  #screen-title { min-height: calc(100dvh - 40px); padding: 6vh 0; }
  .game-screen { min-height: 100dvh; }
  .seed-grid { grid-template-columns: repeat(2, 1fr); }
  .game-body { grid-template-columns: 1fr; gap: 20px; }
  .scene { overflow: visible; padding-right: 0; }
  .scene-ghost { font-size: 72px; top: -10px; }
  .side { padding-top: 4px; }
  .side-panel { max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .side { padding: 18px 14px 14px; }
  .scene { padding: 22px 18px 22px 26px; }
  .paper { padding: 20px 16px 24px; }
  .timeline { height: 22px; }
  .paper { transform: none; }
  .choices { padding-top: 10px; }
  .title-meta { display: none; }
}
@media (max-width: 560px) {
  .seed { min-height: 86px; padding: 15px 14px; }
  .difficulty-row { flex-direction: column; }
  .meters { gap: 16px; }
  .ending-actions { flex-direction: column; }
  .hud-sub { display: none; }
  .digital { font-size: 20px; }
  .narration { font-size: 16px; line-height: 2.05; }
  .timeline { margin-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
