/* ============================================================
   回程之旅 RETURN PASSAGE —— 舰载 AI 终端视觉层
   方向（GDD §10.1）：冷灰蓝 + 青绿磷光；琥珀 = 不确定；红 = 仅生命与核心危险
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg0: #04070b;         /* 舱外真空 */
  --bg1: #081019;         /* 面板底 */
  --bg2: #0c1722;         /* 面板面 */
  --line: #16283a;        /* 结构线 */
  --line2: #234258;       /* 亮结构线 */
  --ink: #a9c6cb;         /* 正文 */
  --ink-dim: #54707d;     /* 次级 */
  --phos: #46e0cf;        /* 磷光青 —— 稳定/确认信息 */
  --phos-dim: #1d6b64;
  --amber: #f0a63c;       /* 不确定 */
  --red: #ff5257;         /* 仅生命 / 核心危险 */
  --white: #dff3f0;
  font-size: 14px;
}
@property --none { syntax: "*"; inherits: false; }

body {
  background: var(--bg0);
  color: var(--ink);
  font-family: "Bahnschrift SemiCondensed", Bahnschrift, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  user-select: none;
}
.mono, kbd, .digits, #tl-list, .tc { font-family: "Cascadia Code", Consolas, monospace; }
.muted { color: var(--ink-dim); font-size: 12px; }
.hidden { display: none !important; }
kbd {
  font-size: 10px; color: var(--ink-dim);
  border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 3px;
  padding: 0 4px; margin-left: 4px;
}

/* ---- 全屏 CRT 质感（信息表达层之外的氛围，保持极低强度） ---- */
#crt-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 90;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.14) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 120% 90% at 50% 40%, transparent 60%, rgba(2,4,7,0.55) 100%);
  opacity: 0.5;
}

/* ---- 面板骨架：切角 + 眉标 ---- */
.panel-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; letter-spacing: 0.14em; color: var(--ink);
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(70,224,207,0.05), transparent);
  white-space: nowrap;
}
.panel-head .en {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px; letter-spacing: 0.22em; color: var(--phos);
  opacity: 0.75;
}
.panel, #wall, #timeline {
  background: var(--bg1);
  border: 1px solid var(--line);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

/* ============ 顶部仪表条 ============ */
#topbar {
  display: flex; align-items: stretch; gap: 0;
  height: 46px; padding: 0 12px;
  background: linear-gradient(180deg, #0b141e, #070d14);
  border-bottom: 1px solid var(--line2);
}
#topbar .brand {
  display: flex; flex-direction: column; justify-content: center;
  padding-right: 16px; margin-right: 4px;
  border-right: 1px solid var(--line);
}
#topbar .ship { color: var(--white); font-size: 14px; letter-spacing: 0.18em; }
#topbar .ai {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px; letter-spacing: 0.2em; color: var(--ink-dim);
}
#topbar .ai em { font-style: normal; color: var(--phos); }
#topbar .ai em.paused { color: var(--amber); }

.gauge {
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
  padding: 0 14px; border-right: 1px solid var(--line);
}
.gauge label {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 8px; letter-spacing: 0.2em; color: var(--ink-dim);
}
.gauge .digits { font-size: 16px; color: var(--white); letter-spacing: 0.06em; line-height: 1; }
.time-gauge { flex-direction: row; align-items: center; gap: 8px; }
.time-gauge label { writing-mode: initial; }
.time-gauge .speed {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px; color: var(--phos); border: 1px solid var(--phos-dim);
  padding: 1px 5px; border-radius: 2px;
}
.time-gauge .speed.paused { color: var(--amber); border-color: var(--amber); }

#cp-cells { display: flex; gap: 3px; }
#cp-cells .cell {
  width: 9px; height: 14px;
  background: #0d1b26; border: 1px solid var(--line2);
  transform: skewX(-12deg);
}
#cp-cells .cell.on { background: var(--phos); border-color: var(--phos); box-shadow: 0 0 6px rgba(70,224,207,0.6); }
#cp-cells .cell.busy { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 6px rgba(240,166,60,0.5); }

.meter {
  width: 86px; height: 8px; background: #0d1b26;
  border: 1px solid var(--line2); transform: skewX(-12deg);
}
.meter > div { height: 100%; width: 0%; background: var(--ink-dim); transition: width 0.2s; }
.alert-gauge .meter > div { background: linear-gradient(90deg, var(--phos-dim), var(--amber)); }
.alert-gauge.hot label { color: var(--amber); }
.meter.red > div { background: var(--red); box-shadow: 0 0 6px rgba(255,82,87,0.5); }
.meter.teal > div { background: var(--phos); }
.vital.hurt label { color: var(--red); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ============ 主区域 ============ */
#main { display: flex; gap: 10px; padding: 10px; height: calc(100vh - 46px - 126px); }

/* ---- 监控墙 ---- */
#wall { display: flex; flex-direction: column; }
#wall-grid {
  display: grid; grid-template-columns: repeat(2, 216px);
  gap: 8px; padding: 8px; align-content: start; overflow-y: auto;
}
.mon { background: #05090d; border: 1px solid var(--line); position: relative; }
.mon-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 6px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}
.mon-head select {
  background: transparent; color: var(--ink); border: none;
  font-family: inherit; font-size: 10px; max-width: 108px; cursor: pointer;
}
.mon-head select:focus { outline: 1px solid var(--phos-dim); }
.mon-head option { background: var(--bg2); }
.mon-head .tc { color: var(--phos); font-size: 9px; }
.mon-head .tc.glitch { color: var(--amber); animation: tcglitch 0.4s steps(2) infinite; }
@keyframes tcglitch { 50% { opacity: 0.25; transform: translateX(1px); } }
.mon canvas { display: block; width: 214px; height: 128px; }

/* ---- 舰图 ---- */
#center { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#center .panel-head { background: var(--bg1); border: 1px solid var(--line); }
.legend { margin-left: auto; letter-spacing: 0; font-size: 10px; color: var(--ink-dim); display: flex; gap: 10px; align-items: center; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: -1px; }
.lg-confirm { background: #ff7a70; transform: rotate(45deg); }
.lg-suspect { border: 1px dashed var(--amber); border-radius: 50%; }
.lg-blind { background: repeating-linear-gradient(45deg, #223140 0 2px, transparent 2px 4px); }
#map {
  background: var(--bg0);
  border: 1px solid var(--line);
  align-self: center;
  height: min(620px, calc(100% - 78px));
  aspect-ratio: 700 / 540;
  max-width: 100%;
}

/* ---- 命令轨 ---- */
#controls { display: flex; gap: 6px; align-items: center; }
button {
  background: linear-gradient(180deg, #10202c, #0b1620);
  color: var(--ink); border: 1px solid var(--line2);
  padding: 6px 14px; cursor: pointer; font-size: 13px;
  font-family: inherit; letter-spacing: 0.08em;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
button:hover { border-color: var(--phos); color: var(--white); }
button.active { border-color: var(--phos); color: var(--phos); box-shadow: inset 0 0 12px rgba(70,224,207,0.12); }
button:disabled { opacity: 0.4; cursor: default; }
button.sonar { color: var(--phos); }
.dev { color: var(--ink-dim); font-size: 10px; margin-left: auto; font-family: "Cascadia Code", Consolas, monospace; letter-spacing: 0.1em; }

/* ---- 右侧栏 ---- */
#side { width: 236px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.panel > div:last-child { padding: 8px; }
#sel-body { font-size: 12px; line-height: 1.65; min-height: 72px; }
#sel-body b { color: var(--phos); }
#sel-body .warn { color: var(--amber); }
#sel-body button { margin-top: 6px; font-size: 12px; padding: 4px 12px; }
#sel-body label { display: block; margin-top: 4px; font-size: 12px; cursor: pointer; }

.inv-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; margin-bottom: 4px; font-size: 12px;
  background: #0c1620; border: 1px solid var(--line);
  border-left: 3px solid var(--line2);
  cursor: pointer;
}
.inv-item:hover { border-color: var(--phos-dim); color: var(--white); }
.inv-item.selected {
  border-color: var(--phos); border-left-color: var(--phos);
  color: var(--phos); background: rgba(70,224,207,0.06);
  box-shadow: inset 0 0 14px rgba(70,224,207,0.08);
}
.inv-item .spec { font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; color: var(--ink-dim); }

#cp-free { margin-left: auto; letter-spacing: 0; font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; color: var(--phos); }
.cp-chip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 7px; margin-bottom: 3px; font-size: 11.5px;
  background: #0b141d; border: 1px solid transparent;
  border-left: 3px solid #23333f; cursor: pointer;
}
.cp-chip:hover { border-color: var(--phos-dim); }
.cp-chip.on { border-left-color: var(--phos); color: var(--white); }
.cp-chip.on .st { color: var(--phos); }
.cp-chip.degraded { border-left-color: var(--amber); }
.cp-chip.dead { border-left-color: var(--red); opacity: 0.55; cursor: default; }
.cp-chip.passive { cursor: default; border-left-color: #2c516b; }
.cp-chip .st { color: var(--ink-dim); font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; }
.cp-chip.busy .st { color: var(--amber); }

/* ============ 事件时间线 ============ */
#timeline { height: 116px; margin: 0 10px 10px; display: flex; flex-direction: column; }
#tl-list { list-style: none; font-size: 11.5px; line-height: 1.7; padding: 4px 12px; overflow: hidden; }
#tl-list li { border-left: 2px solid transparent; padding-left: 8px; }
#tl-list .t { color: var(--ink-dim); margin-right: 10px; }
#tl-list .sev-CRITICAL { color: var(--red); border-left-color: var(--red); }
#tl-list .sev-HIGH { color: #f2b463; border-left-color: var(--amber); }
#tl-list .sev-MEDIUM { color: #c3b089; }
#tl-list .sev-LOW { color: var(--ink-dim); }

/* ============ 浮层 ============ */
#pause-banner {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  background: rgba(10,16,23,0.95); border: 1px solid var(--amber); color: var(--amber);
  padding: 5px 22px; font-size: 13px; letter-spacing: 0.15em; z-index: 95;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
#tooltip {
  position: fixed; z-index: 96; pointer-events: none;
  background: rgba(6,10,15,0.97); border: 1px solid var(--line2);
  border-left: 2px solid var(--phos);
  padding: 7px 10px; font-size: 12px; line-height: 1.55; max-width: 270px;
}
#tooltip b { color: var(--phos); }
#toast {
  position: fixed; bottom: 140px; left: 50%; transform: translateX(-50%);
  background: rgba(26,18,8,0.96); border: 1px solid var(--amber); color: var(--amber);
  padding: 7px 18px; font-size: 13px; z-index: 97;
}
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3,6,9,0.94); display: flex; align-items: center; justify-content: center;
}
.overlay-box {
  max-width: 660px; background: var(--bg1); border: 1px solid var(--line2);
  padding: 30px 38px; line-height: 1.75;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  box-shadow: 0 0 80px rgba(70,224,207,0.06);
}
.boot-log {
  display: flex; flex-direction: column; gap: 1px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 11px;
  color: var(--ink-dim); margin-bottom: 16px;
}
.boot-log .warn, .boot-log b.warn { color: var(--amber); font-weight: normal; }
.overlay-box h1 {
  color: var(--white); font-size: 30px; letter-spacing: 0.3em; margin-bottom: 4px;
  text-shadow: 0 0 24px rgba(70,224,207,0.45);
}
.overlay-box h1 .sub {
  display: block; font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px; letter-spacing: 0.35em; color: var(--phos); margin-top: 4px;
}
.overlay-box .mission { margin: 10px 0 6px; color: var(--ink); }
.overlay-box ul { margin: 10px 0 12px 18px; font-size: 13px; }
.overlay-box li { margin-bottom: 5px; }
.overlay-box li b { color: var(--white); }
.keys { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--ink-dim); margin-bottom: 10px; }
.overlay-box .lose-hint { color: var(--amber); font-size: 12.5px; letter-spacing: 0.05em; }
.overlay-box button {
  margin-top: 16px; padding: 10px 30px; font-size: 15px; letter-spacing: 0.2em;
  border-color: var(--phos); color: var(--phos);
}
.overlay-box button:hover { background: rgba(70,224,207,0.1); }
#end-stats {
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px;
  margin-top: 12px; color: var(--ink-dim); line-height: 1.9;
  border-top: 1px solid var(--line); padding-top: 10px;
}
#end-stats b { color: var(--white); }

/* ============================================================
   动画层 —— 舒适的过渡与微交互
   ============================================================ */

/* 通用按钮：按压反馈 + 平滑高亮 */
button { transition: border-color .16s, color .16s, background .16s, transform .08s, box-shadow .16s; }
button:active:not(:disabled) { transform: translateY(1px) scale(0.985); }

/* 侧栏条目：平滑 hover */
.inv-item, .cp-chip { transition: border-color .16s, background .16s, color .16s, transform .1s; }
.inv-item:hover, .cp-chip:hover { transform: translateX(2px); }

/* ---- 开场：引导页入场 ---- */
.overlay-box { animation: boxIn .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes boxIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.boot-log span { opacity: 0; animation: bootLine .38s ease-out forwards; }
.boot-log span:nth-child(1) { animation-delay: .15s; }
.boot-log span:nth-child(2) { animation-delay: .45s; }
.boot-log span:nth-child(3) { animation-delay: .75s; }
.boot-log span:nth-child(4) { animation-delay: 1.05s; }
@keyframes bootLine {
  from { opacity: 0; transform: translateX(-8px); filter: blur(1px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.overlay-box h1 { animation: boxIn .5s cubic-bezier(.2,.7,.2,1) both; animation-delay: 1.15s; }

.intro-actions { display: flex; gap: 12px; align-items: center; }
button.ghost {
  border-color: var(--line2); color: var(--ink-dim);
  background: transparent;
}
button.ghost:hover { border-color: var(--phos-dim); color: var(--ink); background: rgba(70,224,207,0.04); }

/* 引导页淡出 */
#intro { transition: opacity .35s ease; }
#intro.closing { opacity: 0; }

/* ---- 进入战斗：面板逐个升起 ---- */
body.playing #topbar { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
body.playing #wall   { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .06s; }
body.playing #center { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .13s; }
body.playing #side   { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .2s; }
body.playing #timeline { animation: rise .55s cubic-bezier(.2,.7,.2,1) both .27s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---- 事件时间线：新条目滑入 ---- */
#tl-list li { transition: none; }
#tl-list li.fresh { animation: logIn .4s cubic-bezier(.2,.7,.2,1) both; }
@keyframes logIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}
#tl-list li.fresh.sev-CRITICAL, #tl-list li.fresh.sev-HIGH {
  animation: logInFlash .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes logInFlash {
  0%   { opacity: 0; transform: translateX(-10px); background: rgba(240,166,60,0.18); }
  60%  { background: rgba(240,166,60,0.10); }
  100% { opacity: 1; transform: none; background: transparent; }
}

/* ---- 浮层：暂停横幅 / toast 平滑进出 ---- */
#pause-banner { animation: dropIn .28s cubic-bezier(.2,.7,.2,1) both; }
@keyframes dropIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
#toast { animation: toastIn .3s cubic-bezier(.2,.7,.2,1) both; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
#tooltip { animation: fadeIn .14s ease-out both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* AI 状态点：在线时缓慢呼吸 */
#topbar .ai em { transition: color .3s; animation: aiPulse 2.6s ease-in-out infinite; }
#topbar .ai em.paused { animation: none; }
@keyframes aiPulse { 50% { opacity: 0.55; } }

/* 声纳按钮：可用时的微微磷光呼吸 */
button.sonar:not(:disabled) { animation: sonarReady 2.4s ease-in-out infinite; }
@keyframes sonarReady {
  50% { box-shadow: 0 0 14px rgba(70,224,207,0.18); border-color: var(--phos); }
}

/* ============================================================
   新手引导 coach-marks
   ============================================================ */
#coach {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  display: none; opacity: 0; transition: opacity .32s ease;
}
#coach.on { opacity: 1; }
#coach-hole {
  position: absolute; border: 1px solid var(--phos); border-radius: 4px;
  box-shadow:
    0 0 0 9999px rgba(3,6,9,0.82),
    inset 0 0 22px rgba(70,224,207,0.28),
    0 0 26px rgba(70,224,207,0.22);
  transition: left .42s cubic-bezier(.4,0,.2,1), top .42s cubic-bezier(.4,0,.2,1),
              width .42s cubic-bezier(.4,0,.2,1), height .42s cubic-bezier(.4,0,.2,1),
              opacity .3s ease;
  pointer-events: none;
}
#coach-hole::after {
  /* 四角取景框 */
  content: ""; position: absolute; inset: -4px; pointer-events: none;
  background:
    linear-gradient(var(--phos),var(--phos)) 0 0/12px 2px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 0 0/2px 12px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 100% 0/12px 2px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 100% 0/2px 12px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 0 100%/12px 2px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 0 100%/2px 12px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 100% 100%/12px 2px no-repeat,
    linear-gradient(var(--phos),var(--phos)) 100% 100%/2px 12px no-repeat;
  opacity: 0.9;
}
#coach-callout {
  position: absolute; width: 320px; pointer-events: auto;
  background: linear-gradient(180deg, #0d1925, #0a141d);
  border: 1px solid var(--line2); border-left: 2px solid var(--phos);
  padding: 14px 17px 13px; line-height: 1.6; font-size: 13px; color: var(--ink);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 30px rgba(70,224,207,0.06);
  transition: left .42s cubic-bezier(.4,0,.2,1), top .42s cubic-bezier(.4,0,.2,1);
}
#coach-callout.pop { animation: calloutPop .34s cubic-bezier(.2,.7,.2,1); }
@keyframes calloutPop {
  from { opacity: .4; transform: scale(.97); }
  to   { opacity: 1; transform: none; }
}
.ct-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 9px;
  letter-spacing: 0.2em; margin-bottom: 6px;
}
#ct-eyebrow { color: var(--phos); }
#ct-step { color: var(--ink-dim); }
#coach-callout h4 {
  font-size: 15px; color: var(--white); letter-spacing: 0.06em;
  font-weight: 600; margin-bottom: 7px;
}
#ct-text { color: var(--ink); }
#ct-text b { color: var(--phos); font-weight: 600; }
#ct-text kbd { color: var(--ink); }
#ct-text .try { color: var(--amber); font-size: 12px; display: inline-block; margin-top: 6px; }
#ct-text .dot { display: inline-block; width: 9px; height: 9px; vertical-align: 0; margin-right: 1px; }
#ct-text .dot.confirm { background: #ff7a70; transform: rotate(45deg); }
#ct-text .dot.suspect { border: 1px dashed var(--amber); border-radius: 50%; }
.ct-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line);
}
.ct-actions button { padding: 5px 15px; font-size: 12px; letter-spacing: 0.1em; }
#ct-next { border-color: var(--phos); color: var(--phos); }
#ct-next:hover { background: rgba(70,224,207,0.1); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
