/* 医院孢子危机 —— 深色医院主题，竖屏像素风。
   画布固定 360×640 逻辑像素，按整数倍缩放，禁止平滑。 */

:root {
  --bg: #0a0e14;
  --stage: #0d1117;
  --panel: #151d26;
  --panel-2: #1b2530;
  --line: #2b3a4a;
  --fg: #e8f0f8;
  --dim: #8fa3b8;
  --accent: #7fc8ff;
  --good: #5ed08a;
  --warn: #ffd479;
  --bad: #ff6b7a;
  --pink: #e79ac0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage {
  position: relative;
  background: var(--stage);
  box-shadow: 0 0 0 1px #1d2833, 0 18px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  touch-action: none;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------------- 技能按钮 ---------------- */
.skills {
  position: absolute;
  right: 10px;
  bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.skill {
  position: relative;
  width: 58px; height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(21, 29, 38, 0.92);
  color: var(--fg);
  font: 600 11px/1.15 ui-sans-serif, system-ui, "PingFang SC", sans-serif;
  padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s;
}
.skill:active { transform: scale(0.94); }
.skill .n { position: relative; z-index: 2; }
.skill .c { position: relative; z-index: 2; font: 700 9px monospace; color: var(--accent); }
.skill::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--cdp, 0%);
  background: rgba(10, 14, 20, 0.75);
  z-index: 1;
  transition: height 0.1s linear;
}
.skill.ready { border-color: rgba(127, 200, 255, 0.5); }
.skill.disabled { opacity: 0.45; }

.icon-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(21, 29, 38, 0.85);
  color: var(--dim);
  font: 700 10px/1 monospace;
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 6;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------------- 虚拟摇杆 ---------------- */
.stick {
  position: absolute;
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(127, 200, 255, 0.35);
  background: rgba(20, 30, 42, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
}
.stick i {
  position: absolute;
  left: 50%; top: 50%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: rgba(127, 200, 255, 0.45);
  border: 1px solid rgba(200, 235, 255, 0.6);
}

/* ---------------- 覆盖层 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 10;
}
.overlay.on { display: block; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  gap: 12px;
  background: linear-gradient(180deg, #080c12, #0e151d);
  overflow-y: auto;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.brand { text-align: center; margin-top: 18px; }
.brand h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 3px;
  color: var(--fg);
  text-shadow: 0 2px 0 #123, 0 0 18px rgba(127, 200, 255, 0.35);
}
.brand .sub { color: var(--dim); font-size: 11px; letter-spacing: 4px; margin-top: 6px; }
.brand .spore {
  width: 54px; height: 54px; margin: 16px auto 0;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 34% 30%, #d9ffd0, #8fd07a 45%, #4d7d46 100%);
  box-shadow: 0 0 26px rgba(140, 230, 130, 0.35), inset 0 -6px 12px rgba(0, 0, 0, 0.35);
  position: relative;
}
.brand .spore::before, .brand .spore::after {
  content: ""; position: absolute; top: 20px;
  width: 6px; height: 6px; border-radius: 50%; background: #1d2a1a;
}
.brand .spore::before { left: 15px; }
.brand .spore::after { right: 15px; }

.tagline { color: var(--dim); font-size: 12px; line-height: 1.7; text-align: center; padding: 0 6px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  border-radius: 12px;
  padding: 13px 16px;
  font: 600 14px/1.2 ui-sans-serif, system-ui, "PingFang SC", sans-serif;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #2a6f9e, #1d4e72);
  border-color: #3d8cc0;
  box-shadow: 0 4px 18px rgba(60, 140, 200, 0.28);
}
.btn.ghost { background: transparent; color: var(--dim); }
.btn.small { padding: 9px 12px; font-size: 12px; border-radius: 10px; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.h2 { font-size: 13px; color: var(--dim); letter-spacing: 2px; margin: 4px 0 0; }
.h2 b { color: var(--fg); }

/* 选人 */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: inherit;
  transition: transform 0.08s ease, border-color 0.15s, background 0.15s;
}
.card:active { transform: scale(0.98); }
.card.on { border-color: var(--accent); background: var(--panel-2); }
.card .nm { font-size: 13px; font-weight: 700; }
.card .tg { font-size: 10px; color: var(--accent); letter-spacing: 1px; }
.card .bl { font-size: 10px; color: var(--dim); line-height: 1.5; }
.card .sk { font-size: 10px; color: var(--warn); line-height: 1.5; }

.card.wide { grid-column: 1 / -1; }

/* 关卡 / 升级 / 结算 */
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
}
.panel .k { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.panel .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.panel .desc { font-size: 12px; color: var(--dim); line-height: 1.7; margin-top: 8px; }
.panel.challenge { border-color: rgba(255, 212, 121, 0.4); background: rgba(60, 48, 20, 0.5); }
.panel.challenge .v { color: var(--warn); font-size: 16px; }

.upgrades { display: flex; flex-direction: column; gap: 8px; }
.upgrade {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: transform 0.08s ease, border-color 0.15s;
}
.upgrade:active { transform: scale(0.98); }
.upgrade:hover { border-color: var(--accent); }
.upgrade .t { font-size: 14px; font-weight: 700; }
.upgrade .d { font-size: 11px; color: var(--dim); margin-top: 3px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--panel);
}
.stat .l { font-size: 10px; color: var(--dim); }
.stat .v { font-size: 16px; font-weight: 700; margin-top: 2px; }

.result-title { text-align: center; font-size: 22px; letter-spacing: 3px; margin: 6px 0 0; }
.result-title.good { color: var(--good); }
.result-title.bad { color: var(--bad); }

.hint { font-size: 11px; color: var(--dim); line-height: 1.7; }
.hint b { color: var(--fg); }

textarea.code {
  width: 100%;
  min-height: 92px;
  background: #0b1016;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font: 11px/1.5 monospace;
  resize: vertical;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: rgba(21, 29, 38, 0.96);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  z-index: 20;
  animation: toastIn 0.18s ease;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

.spacer { flex: 1; }

/* 贴底的按钮区：屏幕不高时也不会被挤出可视区 */
.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 max(6px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8, 12, 18, 0), #080c12 28%);
}
.actions .row { display: flex; gap: 8px; }
