/* ============================================================
   静水病区 / STILL WARD
   All visuals are original CSS + procedural WebGL. No external assets.
   ============================================================ */

:root {
  --ink: #070b0a;
  --ink-2: #0b100f;
  --bone: #d9d4c4;
  --bone-dim: #a6a294;
  --hospital: #82988c;
  --hospital-deep: #3d5550;
  --amber: #d8a46a;
  --amber-hot: #ffd29a;
  --rust: #8b543b;
  --danger: #a84a3d;
  --line: rgba(202, 211, 197, 0.18);
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  --mono: "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #030504;
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body { cursor: default; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #030504;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  background: #030504;
  touch-action: none;
}

button, input, select { font: inherit; }
button { color: inherit; }

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- global film treatment ---------- */

.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.fx-vignette {
  background:
    radial-gradient(ellipse at 50% 48%, rgba(0,0,0,0) 32%, rgba(0,0,0,0.24) 64%, rgba(0,0,0,0.78) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.36), rgba(0,0,0,0) 18%, rgba(0,0,0,0) 80%, rgba(0,0,0,0.5));
}

.fx-grain {
  opacity: 0.075;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='.75'/></svg>");
  background-size: 200px 200px;
  animation: grainShift 0.32s steps(2) infinite;
  transition: opacity 0.5s ease;
}

.fx-grain.is-off { opacity: 0; }

@keyframes grainShift {
  0% { background-position: 0 0; }
  25% { background-position: -42px 28px; }
  50% { background-position: 33px -18px; }
  75% { background-position: -17px -39px; }
  100% { background-position: 21px 36px; }
}

.fx-scanlines {
  opacity: 0.055;
  background: repeating-linear-gradient(
    to bottom,
    rgba(210, 230, 218, 0.5) 0px,
    rgba(210, 230, 218, 0.5) 1px,
    rgba(0,0,0,0) 1px,
    rgba(0,0,0,0) 3px
  );
  mix-blend-mode: overlay;
}

.fx-flash {
  background: #dbe9e4;
  opacity: 0;
  mix-blend-mode: screen;
  z-index: 21;
}

.fx-flash.flash-on {
  animation: lightningFlash 0.55s ease-out;
}

@keyframes lightningFlash {
  0% { opacity: 0; }
  6% { opacity: 0.26; }
  12% { opacity: 0.03; }
  18% { opacity: 0.15; }
  30% { opacity: 0; }
  100% { opacity: 0; }
}

.fx-dread {
  opacity: 0;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(40,0,0,0) 25%, rgba(32,3,2,0.4) 100%),
    linear-gradient(90deg, rgba(70,10,5,0.12), transparent 20%, transparent 80%, rgba(70,10,5,0.12));
  transition: opacity 0.5s ease;
  z-index: 21;
}

.fx-dread.dread-on { opacity: 1; }

#glitchBars {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.15s linear;
}

#glitchBars.glitch-on { opacity: 0.34; }
#glitchBars i {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: rgba(210, 240, 225, 0.5);
  transform: translateX(-7%);
  animation: glitchSweep 0.25s steps(2) infinite;
}
#glitchBars i:nth-child(1) { top: 11%; animation-delay: -0.05s; height: 2px; opacity: .4; }
#glitchBars i:nth-child(2) { top: 18%; animation-delay: -0.18s; }
#glitchBars i:nth-child(3) { top: 33%; animation-delay: -0.11s; height: 3px; opacity: .25; }
#glitchBars i:nth-child(4) { top: 47%; animation-delay: -0.24s; }
#glitchBars i:nth-child(5) { top: 52%; animation-delay: -0.07s; height: 2px; opacity: .5; }
#glitchBars i:nth-child(6) { top: 68%; animation-delay: -0.21s; }
#glitchBars i:nth-child(7) { top: 79%; animation-delay: -0.13s; height: 4px; opacity: .2; }
#glitchBars i:nth-child(8) { top: 91%; animation-delay: -0.02s; }

@keyframes glitchSweep {
  0% { transform: translateX(-9%) scaleY(1); filter: brightness(1); }
  50% { transform: translateX(6%) scaleY(2.5); filter: brightness(2.2); }
  100% { transform: translateX(-2%) scaleY(0.6); filter: brightness(0.7); }
}

#fadeLayer {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #000;
  opacity: 1;
  pointer-events: none;
  transition: opacity 1s ease;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.9s ease;
}

#chapterLabel {
  position: absolute;
  top: clamp(22px, 4vh, 46px);
  left: clamp(22px, 4vw, 64px);
  color: rgba(208, 211, 192, 0.52);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px #000;
}

#objectiveWrap {
  position: absolute;
  top: calc(clamp(22px, 4vh, 46px) + 25px);
  left: clamp(22px, 4vw, 64px);
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: min(56vw, 620px);
  color: rgba(229, 225, 209, 0.9);
  font-family: var(--serif);
  font-size: clamp(15px, 1.5vw, 20px);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 12px #000, 0 1px 2px #000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#objectiveWrap.objective-pulse { animation: objectivePulse 1.4s ease; }

@keyframes objectivePulse {
  0% { opacity: 0; transform: translateY(7px); }
  20% { opacity: 1; transform: translateY(0); }
  80% { color: var(--amber-hot); }
  100% { color: rgba(229, 225, 209, 0.9); }
}

.objective-mark {
  width: 18px;
  height: 1px;
  flex: 0 0 auto;
  background: var(--amber);
  box-shadow: 0 0 7px rgba(216, 164, 106, 0.5);
  position: relative;
}
.objective-mark::after {
  content: "";
  position: absolute;
  right: -2px; top: -2px;
  width: 5px; height: 5px;
  border: 1px solid var(--amber);
  transform: rotate(45deg);
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#crosshair span {
  position: absolute;
  left: 50%; top: 50%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(233, 232, 219, 0.86);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.9);
}

#crosshair::before, #crosshair::after {
  content: "";
  position: absolute;
  background: rgba(225, 222, 204, 0.35);
  transition: all 0.2s ease;
}
#crosshair::before { left: 50%; top: 0; width: 1px; height: 5px; transform: translateX(-50%); }
#crosshair::after { left: 50%; bottom: 0; width: 1px; height: 5px; transform: translateX(-50%); }

#crosshair.is-target { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
#crosshair.is-target span { background: var(--amber-hot); box-shadow: 0 0 8px rgba(255, 210, 154, 0.8); }
#crosshair.is-target::before { height: 8px; background: var(--amber); }
#crosshair.is-target::after { height: 8px; background: var(--amber); }
#crosshair.is-hidden { opacity: 0 !important; }

#interactPrompt {
  position: absolute;
  left: 50%;
  top: calc(50% + 38px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(233, 229, 213, 0.9);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-shadow: 0 2px 8px #000;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}
#interactPrompt.is-visible { opacity: 1; transform: translateX(-50%) translateY(-2px); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid rgba(225, 222, 204, 0.44);
  border-radius: 2px;
  background: rgba(4, 8, 7, 0.55);
  color: var(--amber-hot);
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: inset 0 0 8px rgba(255,255,255,0.03);
}

#subtitles {
  position: absolute;
  left: 50%;
  bottom: clamp(64px, 11vh, 126px);
  transform: translateX(-50%);
  width: min(780px, 78vw);
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#subtitles.is-visible { opacity: 1; }

#speakerName {
  color: var(--amber);
  font-size: 9px;
  letter-spacing: 0.35em;
  margin-bottom: 8px;
  text-transform: uppercase;
  text-shadow: 0 1px 5px #000;
}
#speakerName:empty { display: none; }

#subtitleText {
  color: rgba(239, 235, 219, 0.96);
  font-family: var(--serif);
  font-size: clamp(16px, 1.55vw, 21px);
  line-height: 1.8;
  letter-spacing: 0.07em;
  text-shadow: 0 2px 7px #000, 0 0 24px rgba(0,0,0,0.7);
  white-space: pre-line;
}

#inventory {
  position: absolute;
  right: clamp(22px, 3vw, 50px);
  bottom: clamp(24px, 4vh, 44px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.inv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  color: rgba(209, 207, 190, 0.72);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 4px #000;
  background: linear-gradient(90deg, transparent, rgba(3,7,6,0.4));
  opacity: 0;
  transform: translateX(8px);
  animation: invIn 0.5s ease forwards;
}
@keyframes invIn { to { opacity: 1; transform: translateX(0); } }
.inv-item svg { width: 15px; height: 15px; opacity: .8; }
.inv-item.is-new { color: var(--amber-hot); }

#stanceHint {
  position: absolute;
  left: 50%;
  bottom: clamp(42px, 7vh, 72px);
  transform: translateX(-50%);
  width: 76px;
  height: 2px;
  background: rgba(220, 220, 205, 0.12);
  opacity: 0;
  transition: opacity .3s ease;
}
#stanceHint.is-visible { opacity: 1; }
#staminaBar {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(208, 188, 147, .6), rgba(231, 218, 185, .9));
  transform-origin: left;
  transform: scaleX(1);
}

#controlHint {
  position: absolute;
  left: clamp(22px, 4vw, 64px);
  bottom: clamp(24px, 4vh, 44px);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 17px;
  max-width: 52vw;
  color: rgba(207, 205, 188, 0.4);
  font-size: 9px;
  letter-spacing: 0.11em;
  text-shadow: 0 1px 4px #000;
  transition: opacity 1.2s ease;
}
#controlHint b { color: rgba(225, 219, 198, 0.62); font-weight: 500; }
#controlHint.is-faded { opacity: 0; }

#clockHud {
  position: absolute;
  right: clamp(22px, 4vw, 62px);
  top: clamp(22px, 4vh, 46px);
  color: rgba(198, 202, 184, 0.32);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-shadow: 0 1px 5px #000;
}

/* ---------- chapter card ---------- */

#chapterCard {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(1,3,3,0.15), rgba(1,3,3,0.58));
  opacity: 1;
  transition: opacity 1.2s ease;
}

#chapterCard::before, #chapterCard::after {
  content: "";
  position: absolute;
  left: 50%;
  width: min(440px, 62vw);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(202, 206, 189, 0.3), transparent);
}
#chapterCard::before { top: calc(50% - 114px); }
#chapterCard::after { bottom: calc(50% - 114px); }

#chapterNumber {
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.55em;
  margin-bottom: 15px;
  text-shadow: 0 2px 10px #000;
}
#chapterTitle {
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 74px);
  letter-spacing: 0.18em;
  color: rgba(232, 227, 211, 0.96);
  text-shadow: 0 2px 30px #000;
}
#chapterSub {
  color: rgba(198, 202, 184, 0.5);
  font-size: 10px;
  letter-spacing: 0.35em;
  margin-top: 18px;
  text-transform: uppercase;
}

#toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%) translateY(6px);
  z-index: 38;
  padding: 9px 22px;
  color: var(--amber-hot);
  font-size: 10px;
  letter-spacing: 0.28em;
  border-top: 1px solid rgba(216, 164, 106, 0.2);
  border-bottom: 1px solid rgba(216, 164, 106, 0.2);
  background: rgba(2,5,4,0.48);
  text-shadow: 0 1px 5px #000;
  opacity: 0;
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
  white-space: nowrap;
}
#toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- generic overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vh 5vw;
  background: radial-gradient(ellipse at center, rgba(3,7,6,0.72), rgba(0,0,0,0.92));
  backdrop-filter: blur(3px) saturate(0.7);
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease, visibility .3s;
}

/* ---------- notes ---------- */

.paper {
  position: relative;
  width: min(620px, 91vw);
  max-height: 82vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(34px, 5vw, 58px) clamp(30px, 5vw, 60px) 26px;
  color: #23231d;
  background:
    linear-gradient(115deg, rgba(72, 62, 40, 0.11), transparent 26%),
    linear-gradient(0deg, rgba(84, 71, 45, 0.09), transparent 18%),
    #d9d2bd;
  box-shadow: 0 28px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(240, 233, 208, 0.1) inset;
  clip-path: polygon(0.4% 0.8%, 98.9% 0%, 100% 2.1%, 99.3% 99.2%, 96% 99.7%, 2% 100%, 0% 97.8%);
  transform: rotate(-0.22deg);
  scrollbar-width: thin;
  scrollbar-color: rgba(50,45,32,.35) transparent;
}
.paper::-webkit-scrollbar { width: 7px; }
.paper::-webkit-scrollbar-track { background: transparent; }
.paper::-webkit-scrollbar-thumb { background: rgba(50,45,32,.3); border-radius: 8px; }

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, rgba(59, 51, 33, 0.024) 0, rgba(59, 51, 33, 0.024) 1px, transparent 1px, transparent 4px),
    radial-gradient(circle at 16% 22%, rgba(105, 78, 34, 0.13), transparent 22%),
    radial-gradient(circle at 84% 78%, rgba(99, 72, 29, 0.1), transparent 25%);
  mix-blend-mode: multiply;
}

.paper-fold {
  position: absolute;
  top: 0; right: 0;
  width: 78px; height: 78px;
  background: linear-gradient(225deg, rgba(0,0,0,0.18), transparent 46%);
  pointer-events: none;
}

.paper-close {
  position: sticky;
  float: right;
  top: 0;
  z-index: 4;
  width: 28px;
  height: 28px;
  margin: -12px -14px 0 12px;
  border: 1px solid rgba(67, 61, 43, 0.28);
  border-radius: 50%;
  background: rgba(218, 210, 188, 0.75);
  color: rgba(58, 52, 38, 0.75);
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.paper-close:hover { background: rgba(190, 178, 146, .9); color: #2b2417; }

.paper-kicker {
  position: relative;
  color: #756d55;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.paper h2 {
  position: relative;
  margin: 0 0 22px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(23px, 3vw, 33px);
  letter-spacing: 0.12em;
  line-height: 1.35;
  color: #25251d;
}

.paper-body {
  position: relative;
  z-index: 2;
  font-family: var(--serif);
  font-size: clamp(14px, 1.35vw, 17px);
  line-height: 2.05;
  letter-spacing: 0.035em;
  color: #39382d;
  white-space: pre-line;
}

.paper-body .strike { text-decoration: line-through; text-decoration-thickness: 1px; opacity: .65; }
.paper-body .red { color: #7f2f23; }
.paper-body .small { font-size: 0.86em; color: #615d4c; }

.paper-stamp {
  position: absolute;
  right: clamp(28px, 6vw, 64px);
  bottom: 92px;
  z-index: 0;
  padding: 8px 8px 6px;
  border: 2px double rgba(127, 40, 29, 0.55);
  color: rgba(127, 40, 29, 0.6);
  font-family: var(--serif);
  font-size: 9px;
  line-height: 1.3;
  text-align: center;
  letter-spacing: 0.1em;
  transform: rotate(-7deg);
  opacity: .28;
  pointer-events: none;
}

.paper-footer {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid rgba(55, 49, 33, 0.18);
  color: #726b54;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.note-help {
  position: absolute;
  left: 50%;
  bottom: 17px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(211, 207, 190, 0.48);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-shadow: 0 1px 5px #000;
  pointer-events: none;
}
.note-help kbd { height: 20px; min-width: 20px; font-size: 9px; }

.text-btn {
  background: transparent;
  border: 0;
  padding: 5px 2px;
  color: #615a44;
  border-bottom: 1px solid rgba(80, 70, 48, 0.4);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.15em;
}
.text-btn:hover { color: #291f12; border-color: #291f12; }

/* ---------- keypad ---------- */

.keypad-case {
  width: min(344px, 88vw);
  padding: 22px;
  background: linear-gradient(160deg, #6d746d, #3b413d 58%, #2b302d);
  border-radius: 7px;
  box-shadow: 0 28px 70px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.16), inset 0 -8px 20px rgba(0,0,0,.35);
  border: 1px solid rgba(205, 210, 195, 0.18);
  transform: rotate(0.2deg);
}

.keypad-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(213, 219, 205, 0.55);
  font-size: 9px;
  letter-spacing: 0.23em;
  margin-bottom: 14px;
}
.keypad-led {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #7e2b24;
  box-shadow: 0 0 9px rgba(255, 75, 53, .8);
}

.keypad-display {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0e1811;
  border: 1px solid #090d0a;
  border-radius: 3px;
  color: #9ec5a3;
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.4em;
  text-shadow: 0 0 10px rgba(120, 220, 140, .35);
  box-shadow: inset 0 2px 12px rgba(0,0,0,.8);
  margin-bottom: 17px;
}
.keypad-display.err { color: #d26a58; text-shadow: 0 0 10px rgba(230, 80, 55, .4); animation: padShake .28s ease; }
@keyframes padShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.keypad-grid button {
  height: 48px;
  border: 1px solid rgba(225, 230, 217, 0.18);
  border-radius: 3px;
  background: linear-gradient(180deg, #545c55, #3b423d);
  color: rgba(224, 227, 214, .85);
  font-family: var(--mono);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.1);
  transition: transform .08s ease, background .15s ease;
}
.keypad-grid button:hover { background: linear-gradient(180deg, #626a62, #464e48); }
.keypad-grid button:active { transform: translateY(2px); box-shadow: none; }
.keypad-grid button[data-key="C"] { color: #d2a078; font-size: 11px; }
.keypad-grid button[data-key="E"] { color: #9fc5a4; font-size: 11px; }

.keypad-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  color: rgba(216, 220, 207, .42);
  font-size: 9px;
  letter-spacing: .12em;
}
.keypad-foot .text-btn { color: rgba(228, 223, 205, .6); border-color: rgba(228, 223, 205, .3); }

/* ---------- screens / menus ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030504;
  opacity: 1;
  visibility: visible;
  transition: opacity .9s ease, visibility .9s;
}

#titleScreen {
  background: transparent;
  z-index: 65;
  align-items: stretch;
  justify-content: flex-start;
  transition: opacity 1.4s ease, visibility 1.4s;
}

.title-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 48%, rgba(4,9,7,.1), rgba(2,4,3,.68) 55%, rgba(1,2,2,.94) 100%),
    linear-gradient(90deg, rgba(1,3,2,.9) 0%, rgba(2,5,4,.55) 40%, rgba(2,4,3,.2) 72%, rgba(1,2,2,.7) 100%),
    linear-gradient(180deg, rgba(0,0,0,.6), transparent 22%, transparent 72%, rgba(0,0,0,.84));
  pointer-events: none;
}

.title-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image:
    repeating-linear-gradient(104deg, transparent 0 24px, rgba(190, 215, 205, .5) 24px 25px, transparent 25px 44px);
  background-size: 120px 140px;
  animation: rainSlide 1.7s linear infinite;
  mix-blend-mode: screen;
}
@keyframes rainSlide {
  from { background-position: 0 0; }
  to { background-position: -50px 140px; }
}

.title-inner {
  position: relative;
  z-index: 2;
  margin-left: clamp(28px, 8vw, 140px);
  margin-top: auto;
  margin-bottom: auto;
  max-width: 690px;
  padding: 8vh 0 10vh;
}

.title-eyebrow {
  color: rgba(197, 204, 188, 0.46);
  font-size: clamp(8px, .75vw, 10px);
  letter-spacing: .34em;
  text-transform: uppercase;
  margin-bottom: clamp(20px, 4vh, 42px);
  text-shadow: 0 2px 10px #000;
}

.title-lockup h1 {
  position: relative;
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(62px, 10.5vw, 152px);
  line-height: .98;
  letter-spacing: .12em;
  color: #e3dfcf;
  text-shadow:
    0 0 24px rgba(217, 226, 204, 0.09),
    0 6px 34px rgba(0,0,0,.8),
    2px 0 0 rgba(151, 54, 35, 0.14),
    -2px 0 0 rgba(65, 113, 101, 0.18);
  animation: titleFlicker 7s infinite;
}
@keyframes titleFlicker {
  0%, 34%, 37%, 55%, 58%, 100% { opacity: 1; filter: brightness(1); }
  35% { opacity: .76; filter: brightness(1.35); }
  36% { opacity: .93; filter: brightness(.8); }
  56% { opacity: .88; filter: brightness(1.18); }
  57% { opacity: .97; filter: brightness(.92); }
}

.title-en {
  margin-top: 17px;
  color: rgba(184, 193, 175, 0.42);
  font-family: var(--mono);
  font-size: clamp(8px, .8vw, 11px);
  letter-spacing: .72em;
  text-indent: .72em;
}

.title-tagline {
  margin: clamp(24px, 4vh, 38px) 0 0;
  color: rgba(211, 208, 192, 0.66);
  font-family: var(--serif);
  font-size: clamp(14px, 1.3vw, 18px);
  line-height: 2;
  letter-spacing: .2em;
  text-shadow: 0 2px 15px #000;
}

.title-actions {
  display: flex;
  align-items: stretch;
  gap: 14px;
  margin-top: clamp(28px, 4.5vh, 44px);
}

.primary-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 24px;
  min-width: 220px;
  padding: 16px 22px;
  border: 1px solid rgba(211, 164, 105, 0.55);
  background: linear-gradient(90deg, rgba(155, 102, 55, 0.12), rgba(155, 102, 55, 0.02));
  color: #e9dac2;
  cursor: pointer;
  text-align: left;
  transition: background .3s ease, border-color .3s ease, transform .2s ease;
}
.primary-btn span { font-family: var(--serif); font-size: 15px; letter-spacing: .28em; }
.primary-btn small { margin-left: auto; font-family: var(--mono); font-size: 8px; letter-spacing: .22em; color: rgba(222, 193, 155, .5); }
.primary-btn::before {
  content: ""; position: absolute; left: -1px; top: -1px; width: 8px; height: 8px;
  border-left: 1px solid var(--amber); border-top: 1px solid var(--amber);
}
.primary-btn:hover { background: rgba(168, 111, 62, .18); border-color: rgba(242, 198, 143, .9); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.primary-btn.compact { min-width: 170px; padding: 13px 18px; }

.ghost-btn {
  min-width: 104px;
  padding: 14px 22px;
  border: 1px solid rgba(196, 202, 187, 0.16);
  background: rgba(5, 10, 8, .25);
  color: rgba(218, 214, 198, 0.62);
  font-size: 11px;
  letter-spacing: .26em;
  cursor: pointer;
  transition: border-color .3s, color .3s, background .3s;
}
.ghost-btn:hover { color: #e3ddca; border-color: rgba(218, 211, 191, .5); background: rgba(14, 21, 18, .4); }

.content-warning {
  max-width: 540px;
  margin: clamp(30px, 5vh, 52px) 0 0;
  color: rgba(177, 184, 169, 0.3);
  font-size: 9px;
  line-height: 1.8;
  letter-spacing: .08em;
}

.title-bottom {
  position: absolute;
  left: clamp(28px, 8vw, 140px);
  right: clamp(24px, 5vw, 70px);
  bottom: 24px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: rgba(201, 204, 189, 0.29);
  font-size: 8px;
  letter-spacing: .14em;
  text-shadow: 0 1px 5px #000;
}

.pause-inner, .settings-inner, .ending-inner {
  position: relative;
  z-index: 2;
  width: min(620px, 90vw);
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6vh 12px 6vh 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(207, 196, 170, .24) transparent;
}
.ending-inner::-webkit-scrollbar, .settings-inner::-webkit-scrollbar, .pause-inner::-webkit-scrollbar { width: 7px; }
.ending-inner::-webkit-scrollbar-thumb, .settings-inner::-webkit-scrollbar-thumb, .pause-inner::-webkit-scrollbar-thumb { background: rgba(207, 196, 170, .22); border-radius: 8px; }

#pauseScreen, #settingsScreen, #endingScreen {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(20, 31, 27, .72), rgba(1,3,2,.97) 72%),
    #020403;
}
#pauseScreen::before, #settingsScreen::before, #endingScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.62' numOctaves='3' stitchTiles='stitch'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='.5'/></svg>");
  opacity: .04;
  pointer-events: none;
}

.pause-kicker, .ending-kicker {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .44em;
  margin-bottom: 12px;
}

.pause-inner h2, .settings-inner h2, .ending-inner h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 500;
  letter-spacing: .2em;
  color: var(--bone);
}
.pause-line {
  margin: 0 0 32px;
  color: rgba(196, 201, 184, .38);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .16em;
}

.menu-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.menu-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: rgba(222, 218, 202, .78);
  cursor: pointer;
  text-align: left;
  transition: padding .25s ease, color .25s ease, background .25s ease;
}
.menu-btn span { font-family: var(--serif); font-size: 17px; letter-spacing: .2em; }
.menu-btn small { font-family: var(--mono); font-size: 8px; letter-spacing: .2em; color: rgba(201, 195, 174, .3); }
.menu-btn:hover { padding-left: 14px; color: var(--amber-hot); background: linear-gradient(90deg, rgba(172, 119, 62, .08), transparent); }
.pause-tip { margin-top: 24px; color: rgba(192, 196, 180, .24); font-size: 9px; letter-spacing: .18em; }

/* ---------- settings ---------- */

.screen-close {
  position: absolute;
  top: clamp(18px, 3vh, 32px);
  right: clamp(18px, 3vw, 38px);
  z-index: 6;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(204, 199, 180, 0.22);
  border-radius: 50%;
  background: rgba(4, 9, 7, 0.4);
  color: rgba(220, 215, 198, 0.6);
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.screen-close:hover { background: rgba(30, 40, 34, .55); color: var(--bone); border-color: rgba(216, 164, 106, .55); }

.settings-inner h2 { margin-bottom: 38px; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(150px, 1.5fr) 54px;
  align-items: center;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid rgba(199, 205, 189, .1);
}
.setting-row label { color: rgba(218, 214, 198, .74); font-size: 12px; letter-spacing: .12em; }
.setting-row output { color: rgba(213, 181, 132, .7); font-family: var(--mono); font-size: 10px; text-align: right; letter-spacing: .08em; }
.setting-row input[type="range"] { -webkit-appearance: none; appearance: none; height: 2px; background: rgba(210, 206, 188, .16); outline: none; }
.setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #b98b5c; border: 1px solid #e1c39c; cursor: pointer; box-shadow: 0 0 10px rgba(216,164,106,.25);
}
.setting-row input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #b98b5c; border: 1px solid #e1c39c; cursor: pointer; }
.setting-row select {
  padding: 7px 8px;
  border: 1px solid rgba(205, 210, 195, .18);
  background: #0a100d;
  color: rgba(222, 218, 201, .8);
  font-size: 11px;
  outline: none;
}
.setting-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 34px; height: 18px; justify-self: start;
  border: 1px solid rgba(205,210,195,.25); border-radius: 20px;
  background: rgba(4,8,6,.7); position: relative; cursor: pointer; transition: background .2s;
}
.setting-row input[type="checkbox"]::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: rgba(203, 200, 183, .4); transition: transform .2s, background .2s;
}
.setting-row input[type="checkbox"]:checked { background: rgba(125, 87, 48, .45); border-color: rgba(216,164,106,.6); }
.setting-row input[type="checkbox"]:checked::after { transform: translateX(16px); background: var(--amber-hot); }
.settings-note { margin: 26px 0 30px; color: rgba(187, 191, 175, .3); font-size: 9px; line-height: 1.8; letter-spacing: .07em; }

/* ---------- ending ---------- */

#endingScreen { z-index: 75; }
.ending-inner h2 { font-size: clamp(38px, 6vw, 64px); margin-bottom: 25px; }
.ending-body {
  color: rgba(218, 214, 198, .76);
  font-family: var(--serif);
  font-size: clamp(13px, 1.15vw, 16px);
  line-height: 1.95;
  letter-spacing: .08em;
  white-space: pre-line;
  max-width: 640px;
}
.ending-stats {
  margin-top: 26px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: rgba(198, 193, 174, .4);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.95;
  letter-spacing: .12em;
  white-space: pre-line;
}
.ending-inner { padding-bottom: 130px; }
.ending-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px;
  background: #050807;
  border-top: 1px solid rgba(207, 196, 170, .12);
}

#endingScreen.ending-dawn {
  background:
    radial-gradient(ellipse at 56% 32%, rgba(255, 244, 207, .95), rgba(210, 196, 158, .9) 27%, rgba(139, 129, 100, .94) 62%, rgba(55, 52, 42, .98) 100%),
    #d8cfb5;
}
#endingScreen.ending-dawn .ending-body { color: rgba(37, 35, 27, .9); }
#endingScreen.ending-dawn h2 { color: #26251c; text-shadow: 0 0 38px rgba(255,244,208,.32); }
#endingScreen.ending-dawn .ending-kicker { color: rgba(70, 54, 30, .8); }
#endingScreen.ending-dawn .ending-stats { color: rgba(42, 38, 29, .62); border-color: rgba(55,50,39,.3); }
#endingScreen.ending-dawn .pause-kicker, #endingScreen.ending-dawn .ending-kicker { color: rgba(70,54,30,.8); }
#endingScreen.ending-dawn .primary-btn { color: #2e291e; border-color: rgba(54, 47, 32, .55); background: rgba(255, 248, 220, .3); }
#endingScreen.ending-dawn .primary-btn small { color: rgba(54, 47, 32, .4); }
#endingScreen.ending-dawn .ghost-btn { color: rgba(46, 42, 32, .72); border-color: rgba(54,47,32,.3); background: rgba(255,255,240,.15); }
#endingScreen.ending-dawn .ending-actions { background: #cfc5a9; border-top-color: rgba(55, 50, 39, .24); }

/* ---------- death ---------- */

#deathScreen {
  z-index: 74;
  background: radial-gradient(ellipse at center, rgba(24, 4, 3, .78), rgba(0,0,0,.98));
  transition: opacity .6s ease, visibility .6s;
}
.death-inner { text-align: center; max-width: 560px; }
.death-kicker { color: rgba(175, 64, 49, .8); font-family: var(--mono); font-size: 9px; letter-spacing: .46em; margin-bottom: 18px; }
.death-inner h2 { margin: 0 0 18px; font-family: var(--serif); font-size: clamp(38px, 6vw, 64px); font-weight: 500; letter-spacing: .2em; color: rgba(224, 214, 197, .9); }
.death-inner p { color: rgba(196, 190, 174, .45); font-family: var(--serif); letter-spacing: .12em; font-size: 13px; }
.death-loader { width: 120px; height: 1px; margin: 34px auto 0; background: rgba(190, 180, 158, .15); overflow: hidden; }
.death-loader span { display: block; height: 100%; width: 40%; background: rgba(167, 74, 57, .55); animation: deathLoad 2.4s ease-in-out infinite; }
@keyframes deathLoad { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ---------- loading ---------- */

#loadingScreen {
  z-index: 100;
  background: #020302;
  transition: opacity 1s ease, visibility 1s;
}
.load-inner { width: min(420px, 84vw); text-align: center; }
.load-cross {
  width: 30px; height: 30px; margin: 0 auto 26px; position: relative; opacity: .65;
}
.load-cross::before, .load-cross::after { content: ""; position: absolute; background: rgba(207, 210, 192, .7); }
.load-cross::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
.load-cross::after { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
.load-text { color: rgba(201, 205, 187, .44); font-family: var(--serif); font-size: 12px; letter-spacing: .42em; }
.load-bar { height: 1px; margin-top: 26px; background: rgba(211, 208, 189, .1); overflow: hidden; }
.load-bar span { display: block; width: 30%; height: 100%; background: linear-gradient(90deg, transparent, rgba(218, 164, 100, .8), transparent); animation: loadSlide 1.1s ease-in-out infinite; }
@keyframes loadSlide { from { transform: translateX(-120%); } to { transform: translateX(440%); } }
.load-error { margin-top: 20px; color: #b46b5e; font-family: var(--mono); font-size: 10px; line-height: 1.7; white-space: pre-wrap; }
.load-inner h2 { font-family: var(--serif); font-weight: 400; letter-spacing: .2em; }
.load-inner p { color: rgba(200, 200, 184, .4); font-size: 12px; line-height: 1.9; letter-spacing: .08em; }

/* Touch controls sit above the HUD, below notes, menus and story fades. */
#touchControls {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  touch-action: none;
  -webkit-touch-callout: none;
}
#touchControls.is-hidden > * { pointer-events: none !important; }
#touchStick {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border: 1px solid rgba(222, 227, 210, .35);
  border-radius: 50%;
  background: rgba(10, 18, 15, .35);
  pointer-events: auto;
  touch-action: none;
}
#touchThumb {
  position: absolute;
  width: 46px;
  height: 46px;
  left: calc(50% - 23px);
  top: calc(50% - 23px);
  border-radius: 50%;
  border: 1px solid rgba(225, 233, 212, .6);
  background: rgba(174, 192, 164, .24);
  pointer-events: none;
}
.touch-stick-label { position: absolute; bottom: 9px; width: 100%; text-align: center; font-size: 11px; opacity: .65; }
.touch-button {
  position: absolute;
  min-width: 56px;
  min-height: 52px;
  border: 1px solid rgba(224, 230, 209, .4);
  border-radius: 16px;
  background: rgba(7, 15, 12, .68);
  color: #e3e6d7;
  font-size: 13px;
  pointer-events: auto;
  touch-action: none;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}
.touch-button small { display: block; font-size: 9px; opacity: .6; margin-top: 2px; }
.touch-button:focus-visible { outline: 2px solid #d2c79c; outline-offset: 3px; }
.touch-button:active, .touch-button.is-active, #touchStick.is-active { background: rgba(83, 111, 80, .55); }
#touchInteract { right: max(28px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); width: 78px; height: 78px; border-radius: 50%; }
#touchInteract.has-target { border-color: #efdc9c; color: #fff0bc; box-shadow: 0 0 14px rgba(234, 204, 124, .18); }
#touchFlashlight { right: calc(max(28px, env(safe-area-inset-right)) + 92px); bottom: max(28px, env(safe-area-inset-bottom)); }
#touchSprint { right: max(28px, env(safe-area-inset-right)); bottom: calc(max(28px, env(safe-area-inset-bottom)) + 94px); }
#touchPause { top: max(20px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); }
.touch-look-hint { position: absolute; right: 24%; bottom: 32%; opacity: .45; font-size: 11px; letter-spacing: .1em; }
.touch-mode #controlHint, .touch-mode #clockHud, .touch-mode .note-help { display: none; }
.touch-mode #interactPrompt kbd { min-width: 36px; font-size: 11px; }
.touch-mode #subtitles { bottom: max(184px, calc(env(safe-area-inset-bottom) + 170px)); width: min(620px, 80vw); }
.touch-mode #inventory { bottom: max(170px, calc(env(safe-area-inset-bottom) + 156px)); }
.touch-mode #stanceHint { bottom: max(164px, calc(env(safe-area-inset-bottom) + 150px)); }
.touch-mode #objectiveWrap { max-width: calc(100vw - 130px); }
.touch-mode .screen, .touch-mode .overlay { overscroll-behavior: contain; }
.touch-mode .paper { touch-action: pan-y; }
.touch-mode .screen:not(#loadingScreen):not(#deathScreen) { overflow-y: auto; }
.touch-mode .title-inner { padding-top: max(30px, env(safe-area-inset-top)); }
.touch-mode #titleScreen { display: block; }
.touch-mode .title-inner { margin-top: 0; margin-right: 24px; padding-bottom: 30px; }
.touch-mode .title-bottom { position: relative; left: auto; right: auto; bottom: auto; padding: 0 24px 20px; }
.touch-mode .pause-inner, .touch-mode .settings-inner { margin-top: auto; margin-bottom: auto; flex-shrink: 0; }
body.is-background *, body.is-background *::before, body.is-background *::after { animation-play-state: paused !important; }

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

@media (max-width: 760px) {
  .title-inner { margin-left: 24px; margin-right: 24px; padding-right: 0; }
  .title-lockup h1 { font-size: clamp(54px, 15vw, 92px); }
  .title-bottom { flex-direction: column; gap: 7px; left: 24px; right: 24px; bottom: 16px; }
  .title-actions { flex-direction: column; align-items: stretch; max-width: 270px; }
  .primary-btn { min-width: 0; }
  #objectiveWrap { max-width: 75vw; }
  #controlHint { display: none; }
  .paper { padding: 30px 24px 20px; }
  .paper-stamp { display: none; }
  .setting-row { grid-template-columns: 1fr 1.4fr 44px; gap: 10px; }
  #subtitles { width: 88vw; bottom: 96px; }
  .ending-inner { padding: 4vh 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

@media (max-height: 540px) and (pointer: coarse) {
  .title-inner { margin-top: 0; padding-bottom: 62px; }
  .title-lockup h1 { font-size: 48px; }
  .title-tagline { margin: 12px 0; font-size: 13px; }
  .title-actions { flex-direction: row; }
  .content-warning { margin-top: 12px; font-size: 10px; max-width: 75vw; }
  .title-bottom { font-size: 9px; }
  .pause-inner, .settings-inner { padding-top: 30px; padding-bottom: 30px; }
  .touch-mode #subtitles { bottom: 125px; width: 55vw; font-size: 12px; }
  .touch-look-hint { display: none; }
  #touchStick { width: 112px; height: 112px; bottom: max(16px, env(safe-area-inset-bottom)); }
  #touchInteract { width: 64px; height: 64px; bottom: max(16px, env(safe-area-inset-bottom)); }
  #touchFlashlight { right: calc(max(28px, env(safe-area-inset-right)) + 78px); bottom: max(16px, env(safe-area-inset-bottom)); }
  #touchSprint { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 76px); }
}
