/* 《杀死最后一个人类》// SOUL — CRT 审讯终端样式
   三段调色弧：冷钢蓝(审讯) → 告警红(判定/清除) → SOUL 绿(劫持/救赎) */

:root {
  --phos: #8fb8cc;        /* 当前磷光前景：审讯期=冷钢蓝 */
  --phos-dim: #3f5b66;
  --bg: #04080b;
  --android: #ff3b3b;     /* 仿生人/传感器/威胁 红 */
  --soul: #46ff8c;        /* SOUL 绿（生命/救赎）*/
  --tension: 0;           /* 0→1，随审讯推进升高 */
  --glow: 0 0 6px currentColor;
  --mono: "JetBrains Mono", "Cascadia Code", "Noto Sans Mono CJK SC", "Sarasa Mono SC", ui-monospace, monospace;
  --disp: "VT323", var(--mono);
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--phos);
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.55;
  overflow: hidden;
  cursor: default;
  -webkit-font-smoothing: antialiased;
  transition: color .9s ease, background .9s ease;
}

/* ===== 背景特效画布 ===== */
#bgfx {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: .9;
  pointer-events: none;
}

/* ===== CRT 屏幕容器 ===== */
.screen {
  position: fixed; inset: 0;
  z-index: 2;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(16px, 4vh, 48px) clamp(14px, 5vw, 80px);
  scrollbar-width: none;
  -webkit-mask-image: radial-gradient(120% 120% at 50% 50%, #000 72%, transparent 100%);
          mask-image: radial-gradient(120% 120% at 50% 50%, #000 72%, transparent 100%);
}
.screen::-webkit-scrollbar { width: 0; height: 0; }

.term {
  max-width: 880px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: 30vh;
}

/* ===== 文本行 ===== */
#log { font-family: var(--disp); font-size: 1.18em; white-space: pre-wrap; word-break: break-word; }
#log .line, #history .line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.55em;
}
.line.spacer { min-height: .8em; }

.q     { color: var(--phos); font-weight: 500; text-shadow: var(--glow); }
.opt   { color: var(--phos-dim); }
.sys   { color: var(--phos); opacity: .92; }
.warn  { color: var(--android); opacity: .85; }
.err   { color: var(--android); }
.you   { color: #fff; opacity: .82; }
.verdict { color: var(--android); text-shadow: 0 0 8px var(--android); font-family: var(--disp); font-size: 1.12em; letter-spacing: .5px; }
.ghost { color: var(--soul); opacity: .55; text-shadow: 0 0 10px var(--soul); font-style: italic; }
.soul  { color: var(--soul); text-shadow: 0 0 8px var(--soul); }

/* 劫持后整屏转绿 */
body.hijacked { --phos: var(--soul); --phos-dim: #2f9a5e; --bg: #03100a; }
body.hijacked .verdict { color: var(--soul); text-shadow: 0 0 8px var(--soul); }

/* 告警/清除期红色浸染 */
.danger-wash {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%, transparent 40%, rgba(255,40,40,.22) 100%);
  opacity: 0; transition: opacity .5s ease;
}
body.danger .danger-wash { opacity: 1; animation: dangerpulse 1.1s ease-in-out infinite; }
@keyframes dangerpulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

/* ===== LLM 思考块 ===== */
.think { margin: .3em 0 .6em; border-left: 2px solid var(--phos-dim); padding-left: .8em; }
.think-head { color: var(--phos-dim); cursor: pointer; user-select: none; font-size: .92em; }
.think-head .caret { display: inline-block; width: 1em; }
.think-body { color: var(--phos-dim); opacity: .8; font-size: .95em; }
.think.collapsed .think-body { display: none; }
.tline { white-space: pre-wrap; min-height: 1.4em; }

/* ===== 清除倒计时 ===== */
.countdown {
  font-family: var(--disp);
  color: var(--android);
  font-size: 2.6em;
  text-shadow: 0 0 14px var(--android);
  letter-spacing: 2px;
  margin: .2em 0;
}

/* ===== 输入行 ===== */
#prompt { display: flex; align-items: baseline; flex-wrap: wrap; margin-top: .2em; }
.ps1 { color: var(--phos-dim); white-space: pre; }
#cmd { color: #fff; white-space: pre-wrap; word-break: break-word; text-shadow: var(--glow); }
.cur {
  display: inline-block; width: .58em; height: 1.05em; vertical-align: text-bottom;
  background: currentColor; color: var(--phos);
  animation: blink 1.05s step-end infinite; box-shadow: var(--glow);
}
.cur.on { background: var(--phos); color: var(--bg); padding: 0 .02em; width: auto; }
.sel { background: var(--phos); color: var(--bg); }
@keyframes blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }

/* 隐藏的真实输入框（桌面） */
#cli {
  position: fixed; left: -9999px; top: 0;
  opacity: 0; width: 1px; height: 1px;
  background: transparent; border: 0; outline: 0;
  color: transparent; font-family: var(--mono); font-size: 16px;
}

/* ===== 身份 + 光学传感器 ===== */
.idwrap { display: flex; align-items: center; gap: 14px; margin: .8em 0 1.1em; min-height: 0; }
.sensor { width: 56px; height: 56px; color: var(--android); opacity: 0; transition: color .9s ease, opacity .6s ease; flex: 0 0 auto; }
body.revealed .sensor { opacity: 1; }
body.hijacked .sensor { color: var(--soul); }
.sensor svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 5px currentColor); }
.sensor .iris { transform-origin: 60px 60px; animation: irispulse 2.6s ease-in-out infinite; }
.sensor .pupil { animation: pupilpulse 2.6s ease-in-out infinite; }
.sensor .scanbar { animation: scanmove 3.4s ease-in-out infinite; }
.sensor .rim2 { transform-origin: 60px 60px; animation: spin 22s linear infinite; }
@keyframes irispulse { 0%,100% { opacity: .9; } 50% { opacity: .35; } }
@keyframes pupilpulse { 0%,100% { r: 6.5px; opacity: 1; } 50% { r: 4px; opacity: .6; } }
@keyframes scanmove { 0%,100% { transform: translateY(-22px); opacity: 0; } 50% { transform: translateY(22px); opacity: .8; } }
@keyframes spin { to { transform: rotate(360deg); } }

#id {
  font-family: var(--disp); font-size: 1.6em; letter-spacing: 1px;
  color: var(--phos); text-shadow: var(--glow);
  opacity: 0; transition: opacity .5s ease;
}
#id.show { opacity: 1; }

/* ===== CRT 叠加层 ===== */
.scan {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.22) 3px, rgba(0,0,0,0) 4px);
  mix-blend-mode: multiply;
}
.sweep {
  position: fixed; left: 0; right: 0; height: 28vh; z-index: 5; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.035), transparent);
  animation: sweep 7s linear infinite;
}
@keyframes sweep { 0% { top: -30vh; } 100% { top: 100vh; } }
.vig {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  box-shadow: inset 0 0 18vw 4vw rgba(0,0,0,.7);
  background: radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0,0,0,.55) 100%);
}
.glass {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.025) 50%, transparent 60%);
}
body:not(.no-flicker) .glass { animation: flicker 4.5s steps(60) infinite; }
@keyframes flicker { 0%,100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .82; } 94% { opacity: 1; } 97% { opacity: .9; } }

.no-scan .scan { display: none; }
.no-curve .screen { -webkit-mask-image: none; mask-image: none; }

/* ===== glitch（劫持瞬间）===== */
.glitch { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; mix-blend-mode: screen; }
body.glitching .glitch {
  opacity: 1;
  background:
    linear-gradient(90deg, rgba(255,0,60,.5), transparent 12%),
    linear-gradient(270deg, rgba(0,255,140,.5), transparent 12%);
  animation: glitch .42s steps(3) 3;
}
@keyframes glitch {
  0% { transform: translate(0,0); }
  20% { transform: translate(-4px,2px); }
  40% { transform: translate(5px,-3px); }
  60% { transform: translate(-3px,-2px); }
  80% { transform: translate(4px,3px); }
  100% { transform: translate(0,0); }
}

/* ===== 关机 / HALTED ===== */
body.crt-off .screen, body.crt-off #bgfx { animation: crtoff .42s ease forwards; }
@keyframes crtoff {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  60% { transform: scale(1.6, .004); opacity: 1; filter: brightness(4); }
  100% { transform: scale(0); opacity: 0; }
}
#halt {
  position: fixed; inset: 0; z-index: 20; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: #000; color: var(--phos-dim); text-align: center; cursor: pointer; gap: .6em;
}
body.halted #halt { display: flex; }
#halt .h1 { font-family: var(--disp); font-size: 1.8em; color: var(--android); }
#halt .h2 { font-size: .95em; opacity: .7; }

/* ===== 复制按钮（联系彩蛋等）===== */
.copybtn {
  background: transparent; border: 1px solid var(--phos-dim); color: var(--phos);
  border-radius: 4px; padding: 1px 6px; cursor: pointer; vertical-align: middle;
  display: inline-flex; align-items: center;
}
.copybtn.ok { color: var(--soul); border-color: var(--soul); }

/* ===== 顶部声音开关（可选）===== */
#snd {
  position: fixed; top: 14px; right: 16px; z-index: 12;
  background: transparent; border: 1px solid var(--phos-dim); color: var(--phos-dim);
  font-family: var(--mono); font-size: .72em; letter-spacing: 1px;
  padding: 4px 9px; border-radius: 4px; cursor: pointer; opacity: .55;
  transition: opacity .3s, color .3s, border-color .3s;
}
#snd:hover { opacity: 1; }
#snd.on { color: var(--phos); border-color: var(--phos); opacity: .9; }

/* ===== 移动端 ===== */
@media (pointer: coarse) {
  body { font-size: 16px; }
  #cli {
    position: fixed; opacity: 0; z-index: 9;
    color: transparent; caret-color: transparent; background: transparent; left: 0;
  }
}

/* ===== 减少动态效果 ===== */
@media (prefers-reduced-motion: reduce) {
  .sweep, .sensor .iris, .sensor .pupil, .sensor .scanbar, .sensor .rim2,
  body .glass, body.danger .danger-wash { animation: none !important; }
  body.crt-off .screen, body.crt-off #bgfx { animation: none; opacity: 0; }
}
