/* ============================================================
   静区 QUIET ZONE // KX-0941
   CRT 磷光 + 颗粒 + 故障 恐怖氛围样式
   ============================================================ */

:root {
  --bg: #070709;
  --bg-2: #0d0d12;
  --panel: rgba(14, 14, 20, 0.72);
  --line: rgba(90, 255, 140, 0.18);
  --phosphor: #41ff6b;
  --phosphor-dim: #2fbf5a;
  --danger: #ff2b3a;
  --amber: #ffb347;
  --dim: #8a8a94;
  --faint: #4c4c56;
  --mono: "Courier New", "Consolas", "SimSun", "NSimSun", "Noto Sans SC", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--phosphor);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
  cursor: crosshair;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--phosphor); color: #000; }

a { color: var(--danger); text-decoration: none; }
a:hover { text-shadow: 0 0 6px var(--danger); }

/* ---------- 全局氛围层 ---------- */

#scanlines {
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 3px
  );
  mix-blend-mode: multiply;
}

#grain {
  position: fixed; inset: -200px; z-index: 8999; pointer-events: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%25" height="100%25" filter="url(%23n)"/></svg>');
  opacity: 0.055;
  animation: grain 1.2s steps(6) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-30px, 20px); }
  40%  { transform: translate(20px, -40px); }
  60%  { transform: translate(-40px, -20px); }
  80%  { transform: translate(30px, 40px); }
  100% { transform: translate(0, 0); }
}

#vignette {
  position: fixed; inset: 0; z-index: 8998; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 42%, rgba(0,0,0,0.55) 82%, rgba(0,0,0,0.9) 100%);
}

/* 屏幕撕裂闪白 */
#flash {
  position: fixed; inset: 0; z-index: 9500; pointer-events: none;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
}
#flash.on { animation: flash 90ms steps(2) 3; }
@keyframes flash {
  0%   { opacity: 0.7; }
  50%  { opacity: 0.1; }
  100% { opacity: 0.55; }
}

/* 跳杀 */
#jumpscare {
  position: fixed; inset: 0; z-index: 9600; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
}
#jumpscare.on { animation: scare 0.55s steps(3) 1; }
@keyframes scare {
  0%   { opacity: 0; transform: scale(0.6); }
  12%  { opacity: 1; transform: scale(1.05); }
  55%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}
#jumpscare-face {
  width: min(70vmin, 420px); aspect-ratio: 1;
  background:
    radial-gradient(circle at 32% 40%, rgba(255,255,255,0.85) 0 6%, rgba(0,0,0,0) 7%),
    radial-gradient(circle at 68% 40%, rgba(255,255,255,0.85) 0 6%, rgba(0,0,0,0) 7%),
    radial-gradient(ellipse at center, #0a0a0c 0 55%, #000 80%);
  filter: contrast(1.4) brightness(0.9) grayscale(0.6);
  box-shadow: 0 0 80px #000;
}

/* 光标拖尾颗粒 */
#trail { position: fixed; inset: 0; z-index: 8990; pointer-events: none; overflow: hidden; }
.trail-dot {
  position: absolute; width: 3px; height: 3px;
  background: var(--phosphor);
  opacity: 0.8; border-radius: 50%;
  animation: trailfade 0.7s linear forwards;
  mix-blend-mode: screen;
}
@keyframes trailfade { to { opacity: 0; transform: translateY(6px) scale(0.4); } }

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

#hud {
  position: fixed; top: 12px; left: 14px; z-index: 9100;
  font-size: 12px; letter-spacing: 0.12em; color: var(--dim);
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
#hud-rec { color: var(--danger); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }

#sound {
  position: fixed; bottom: 14px; right: 16px; z-index: 9100;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--dim); background: var(--panel);
  border: 1px solid var(--line); padding: 7px 12px;
  cursor: pointer; transition: all .2s;
}
#sound:hover { color: var(--phosphor); border-color: var(--phosphor); box-shadow: 0 0 12px rgba(65,255,107,0.25); }

/* ---------- 布局 ---------- */

#app {
  position: relative; z-index: 10;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 56px 20px 70px;
}

.scene { width: min(760px, 96vw); }

.scene-title {
  font-size: clamp(20px, 4vw, 30px);
  letter-spacing: 0.35em; text-transform: uppercase;
  margin-bottom: 6px;
}
.scene-sub { color: var(--dim); font-size: 12px; letter-spacing: 0.22em; margin-bottom: 28px; }

/* ---------- 终端 / 打字 ---------- */

.terminal {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px 24px;
  min-height: 260px;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6), 0 0 30px rgba(65,255,107,0.05);
}
.terminal .line { white-space: pre-wrap; word-break: break-word; }
.terminal .dim { color: var(--dim); }
.terminal .danger { color: var(--danger); }
.terminal .amber { color: var(--amber); }
.caret::after {
  content: "▊"; color: var(--phosphor); animation: blink 0.8s steps(1) infinite;
}
.prompt { color: var(--phosphor); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-block;
  font-family: var(--mono); font-size: 15px; letter-spacing: 0.18em;
  color: var(--phosphor); background: transparent;
  border: 1px solid var(--phosphor);
  padding: 11px 26px; cursor: pointer;
  transition: all .15s; position: relative; overflow: hidden;
}
.btn:hover {
  background: var(--phosphor); color: #000;
  text-shadow: none; box-shadow: 0 0 22px rgba(65,255,107,0.45);
}
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #000; box-shadow: 0 0 22px rgba(255,43,58,0.5); }
.btn.ghost { color: var(--dim); border-color: var(--faint); }
.btn.ghost:hover { color: #000; background: var(--dim); border-color: var(--dim); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-row { display: flex; gap: 14px; margin-top: 26px; flex-wrap: wrap; }

/* ---------- 故障文字 ---------- */

.glitch { position: relative; display: inline-block; z-index: 0; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0; width: 100%;
  background: var(--bg); overflow: hidden;
}
.glitch::before { color: #0ff; z-index: -1; animation: glitch-a 2.4s infinite linear alternate-reverse; }
.glitch::after  { color: #f0f; z-index: -2; animation: glitch-b 3.1s infinite linear alternate-reverse; }
@keyframes glitch-a {
  0%   { clip-path: inset(12% 0 78% 0); transform: translate(-3px, -1px); }
  20%  { clip-path: inset(60% 0 8% 0);  transform: translate(2px, 1px); }
  40%  { clip-path: inset(30% 0 55% 0); transform: translate(-2px, 1px); }
  60%  { clip-path: inset(80% 0 4% 0);  transform: translate(3px, -1px); }
  80%  { clip-path: inset(5% 0 85% 0);  transform: translate(-3px, 1px); }
  100% { clip-path: inset(50% 0 40% 0); transform: translate(2px, -1px); }
}
@keyframes glitch-b {
  0%   { clip-path: inset(70% 0 15% 0); transform: translate(3px, 1px); }
  25%  { clip-path: inset(10% 0 80% 0); transform: translate(-3px, -1px); }
  50%  { clip-path: inset(45% 0 35% 0); transform: translate(2px, 1px); }
  75%  { clip-path: inset(85% 0 5% 0);  transform: translate(-2px, 1px); }
  100% { clip-path: inset(20% 0 70% 0); transform: translate(3px, -1px); }
}
.glitch:hover { animation: shake 0.2s steps(2) 2; }
@keyframes shake {
  0% { transform: translate(1px, -1px) skewX(-2deg); }
  50% { transform: translate(-1px, 1px) skewX(2deg); }
  100% { transform: translate(0,0); }
}

/* 涂抹 / 遮盖 */
.redact { background: #000; color: #000; padding: 0 6px; cursor: pointer; transition: color .3s; }
.redact:hover { color: var(--danger); text-shadow: 0 0 8px var(--danger); }
.redact.unlocked { color: var(--phosphor); background: rgba(65,255,107,0.08); }

/* ---------- 档案列表 ---------- */

.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px;
  border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; transition: all .18s; text-align: left; width: 100%;
  font-family: var(--mono); font-size: 14px; letter-spacing: 0.04em; color: var(--phosphor);
}
.file-item:hover {
  border-color: var(--phosphor); background: rgba(65,255,107,0.05);
  box-shadow: 0 0 18px rgba(65,255,107,0.18); transform: translateX(4px);
}
.file-item .tag { color: var(--dim); font-size: 12px; }
.file-item .badge { color: var(--amber); font-size: 12px; }
.file-item.locked { color: var(--faint); cursor: not-allowed; }
.file-item.locked:hover { border-color: var(--line); background: var(--panel); box-shadow: none; transform: none; }

.viewer {
  margin-top: 20px; border: 1px dashed var(--line);
  padding: 18px 20px; background: rgba(0,0,0,0.35);
  min-height: 120px; font-size: 14.5px; white-space: pre-wrap;
  animation: fadein .4s;
}
.viewer .hdr { color: var(--amber); letter-spacing: 0.18em; margin-bottom: 10px; font-size: 12px; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; } }

/* ---------- 表单 ---------- */

.field { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
input[type="text"], input[type="password"] {
  flex: 1; min-width: 200px;
  font-family: var(--mono); font-size: 16px; letter-spacing: 0.2em;
  color: var(--phosphor); background: rgba(0,0,0,0.5);
  border: 1px solid var(--line); padding: 11px 14px; outline: none;
  caret-color: var(--phosphor);
}
input:focus { border-color: var(--phosphor); box-shadow: 0 0 14px rgba(65,255,107,0.25); }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 1.2em; }

/* ---------- 信号调谐 ---------- */

.tuner { text-align: center; }
.freq-readout {
  font-size: clamp(30px, 7vw, 56px); letter-spacing: 0.08em;
  color: var(--phosphor); text-shadow: 0 0 16px rgba(65,255,107,0.5);
}
.freq-unit { color: var(--dim); font-size: 14px; letter-spacing: 0.3em; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; margin: 30px 0;
  background: linear-gradient(90deg, var(--faint), var(--phosphor));
  border: 1px solid var(--line); outline: none; cursor: ew-resize;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--phosphor); border: 2px solid #000;
  box-shadow: 0 0 14px var(--phosphor);
}

/* ---------- 注视 / 眼睛 ---------- */

.eyes { display: flex; gap: 40px; justify-content: center; margin: 30px 0; }
.eye {
  width: 90px; height: 60px; border-radius: 50%;
  background: #0b0b0e; border: 1px solid var(--line);
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 20px #000;
}
.pupil {
  position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 20%, #a11 60%, #200 100%);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.hold-bar { position: relative; width: 100%; height: 14px; border: 1px solid var(--line); background: rgba(0,0,0,0.5); margin: 20px 0; }
.hold-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--danger), var(--phosphor)); transition: width .1s linear; }

.center { text-align: center; }
.mono-block { text-align: left; max-width: 640px; margin: 0 auto; }

/* ---------- 响应式 ---------- */
@media (max-width: 520px) {
  body { font-size: 14px; }
  .terminal { padding: 16px; }
  .eyes { gap: 22px; }
  .eye { width: 64px; height: 44px; }
}
