/* 细胞工厂·夜班 — 全屏绘本 2D，不是网页课件 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #1a1410;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #2a2218;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
#boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #1a1410; color: #e8dcc8; letter-spacing: 0.12em;
  transition: opacity 0.45s ease;
}
#boot.hide { opacity: 0; pointer-events: none; }

#frame {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0e0b08;
}

/* 16:9 舞台 */
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  overflow: hidden;
  background: #1a1410;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

#scene {
  position: absolute; inset: 0;
  background: #2a2218 center/cover no-repeat;
  transition: opacity 0.35s ease, filter 0.4s ease;
}
#scene.dim { filter: brightness(0.55) saturate(0.85); }
#scene.fade { opacity: 0; }

#fx {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 2;
}

#hotspots {
  position: absolute; inset: 0;
  z-index: 3;
}
.hot {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed rgba(255, 236, 180, 0.55);
  background: radial-gradient(circle, rgba(255,220,140,0.18), transparent 70%);
  box-shadow: 0 0 18px rgba(255, 210, 120, 0.25);
  animation: breathe 2.4s ease-in-out infinite;
  cursor: pointer;
  transform: translate(-50%, -50%);
}
.hot.rect {
  border-radius: 14px;
  transform: translate(-50%, -50%);
}
.hot.done {
  border-style: solid;
  border-color: rgba(180, 220, 160, 0.45);
  background: radial-gradient(circle, rgba(160,220,140,0.12), transparent 70%);
  animation: none;
  opacity: 0.55;
}
.hot:hover, .hot:focus-visible {
  border-color: rgba(255, 245, 200, 0.9);
  background: radial-gradient(circle, rgba(255,230,160,0.28), transparent 70%);
}
.hot .hot-label {
  position: absolute; left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(30, 22, 14, 0.72);
  color: #f6ecd8;
  font-size: 13px;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.hot:hover .hot-label, .hot.show-label .hot-label { opacity: 1; }

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 12px rgba(255,210,120,0.2); transform: translate(-50%,-50%) scale(1); }
  50% { box-shadow: 0 0 22px rgba(255,210,120,0.45); transform: translate(-50%,-50%) scale(1.04); }
}

/* 底部旁白 — 像字幕，不像网页栏 */
#caption {
  position: absolute; left: 8%; right: 8%; bottom: 5%;
  z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  pointer-events: none;
}
#captionText {
  max-width: 42em;
  text-align: center;
  padding: 14px 22px;
  border-radius: 16px;
  background: rgba(22, 16, 10, 0.62);
  color: #f7efe2;
  font-size: clamp(15px, 2.1vw, 20px);
  line-height: 1.65;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  min-height: 1.2em;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#captionText.show { opacity: 1; }
.cap-btn {
  pointer-events: auto;
  padding: 10px 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3e2b8, #e0c48a);
  color: #3a2a14;
  font-weight: 600;
  letter-spacing: 0.12em;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.15s, filter 0.15s;
}
.cap-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.cap-btn:active { transform: translateY(1px); }

.book-btn, .mute-btn {
  position: absolute; z-index: 6;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(28, 20, 12, 0.55);
  color: #f3e6d0;
  font-size: 20px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,230,180,0.25);
  transition: background 0.2s, transform 0.15s;
}
.book-btn { right: 2.2%; bottom: 4.5%; }
.mute-btn { right: 2.2%; top: 3.5%; font-size: 18px; }
.book-btn:hover, .mute-btn:hover { background: rgba(48, 34, 18, 0.75); transform: scale(1.05); }
.mute-btn.off { opacity: 0.45; }

#toast {
  position: absolute; left: 50%; top: 12%;
  transform: translateX(-50%);
  z-index: 8;
  max-width: 36em;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(40, 28, 16, 0.82);
  color: #f6e8d0;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  animation: toastIn 0.35s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 叠层 */
.overlay {
  position: absolute; inset: 0;
  z-index: 20;
}
.title-overlay { z-index: 30; }
.title-bg {
  position: absolute; inset: 0;
  background: center/cover no-repeat;
  filter: brightness(0.72) saturate(1.05);
}
.title-veil {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,14,8,0.15), rgba(12,8,5,0.72) 70%);
}
.title-card {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -48%);
  text-align: center;
  color: #f8efe0;
  width: min(90%, 520px);
}
.title-sub { letter-spacing: 0.28em; font-size: 13px; opacity: 0.75; margin-bottom: 10px; }
.title-card h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-shadow: 0 4px 24px rgba(0,0,0,0.45);
  margin-bottom: 12px;
}
.title-tag { opacity: 0.85; margin-bottom: 14px; letter-spacing: 0.08em; }
.title-hook {
  margin: 0 auto 22px;
  max-width: 22em;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(20, 12, 6, 0.45);
  color: #f3e2b8;
  font-size: clamp(14px, 2vw, 17px);
  letter-spacing: 0.06em;
  line-height: 1.5;
  border: 1px solid rgba(255, 220, 160, 0.22);
}
.start-btn {
  display: inline-block;
  padding: 14px 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f6e4b4, #d9b56a);
  color: #3a2810;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  transition: transform 0.15s, filter 0.15s;
}
.start-btn:hover { filter: brightness(1.06); transform: translateY(-2px); }
.start-btn:active { transform: translateY(1px); }
.title-hint { margin-top: 14px; font-size: 12px; opacity: 0.55; letter-spacing: 0.06em; }

/* 图鉴书 */
.codex-overlay {
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 8, 5, 0.55);
  backdrop-filter: blur(3px);
}
.book {
  position: relative;
  width: min(92%, 920px);
  height: min(78%, 560px);
  display: flex;
  background: linear-gradient(90deg, #6b3e22 0 18px, #f3e6cf 18px);
  border-radius: 6px 14px 14px 6px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.15);
  overflow: hidden;
}
.book-spine {
  position: absolute; left: 14px; top: 0; bottom: 0; width: 8px;
  background: linear-gradient(90deg, rgba(0,0,0,0.2), transparent);
  pointer-events: none;
}
.book-pages {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  margin-left: 18px;
}
.page {
  padding: 28px 22px 48px;
  overflow-y: auto;
  color: #3a2a1a;
  font-size: 14px;
  line-height: 1.55;
}
.page.left {
  background: linear-gradient(90deg, #efe2c8, #f7ecda);
  border-right: 1px solid rgba(120,80,40,0.12);
}
.page.right { background: linear-gradient(90deg, #f7ecda, #efe2c8); }
.page h3 {
  font-size: 16px; letter-spacing: 0.12em;
  margin-bottom: 12px; color: #5a3a18;
  border-bottom: 1px solid rgba(120,80,40,0.2);
  padding-bottom: 6px;
}
.note-card {
  margin-bottom: 10px; padding: 8px 10px;
  background: rgba(255,255,255,0.35);
  border-radius: 8px;
  border-left: 3px solid #c9a06a;
}
.note-card .tag { font-size: 11px; color: #8a6040; letter-spacing: 0.08em; }
.note-card .body { margin-top: 2px; }
.concept-lit {
  display: inline-block; margin: 6px 8px 0 0;
  padding: 6px 14px; border-radius: 999px;
  background: #e8d4a0; color: #4a3010; font-weight: 600;
}
.concept-dim {
  display: inline-block; margin: 6px 8px 0 0;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(0,0,0,0.06); color: #8a7a68;
}
.book-close {
  position: absolute; right: 14px; top: 12px; z-index: 2;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(60,40,20,0.12); color: #5a3a18;
  letter-spacing: 0.1em;
}
.book-close:hover { background: rgba(60,40,20,0.2); }
.book-tabs {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.book-tabs button {
  padding: 5px 14px; border-radius: 999px;
  background: rgba(60,40,20,0.08); color: #6a4a28; font-size: 13px;
}
.book-tabs button.on { background: #d4b078; color: #3a2810; font-weight: 600; }

.ink-flash {
  background: radial-gradient(circle at 50% 50%, rgba(40,28,16,0.15), rgba(20,12,6,0.65));
  display: flex; align-items: center; justify-content: center;
  color: #f6e8d0; font-size: 28px; letter-spacing: 0.3em;
  opacity: 0; transition: opacity 0.4s;
  pointer-events: none;
}
.ink-flash.show { opacity: 1; }

/* 交互浮层：零件 / 选项 — 仍是绘本风 */
.choice-row {
  position: absolute; left: 50%; bottom: 22%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center;
  max-width: 90%;
  pointer-events: auto;
}
.chip {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(28, 18, 10, 0.7);
  color: #f6ecd8;
  border: 1px solid rgba(255,220,160,0.35);
  font-size: 14px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
  transition: transform 0.12s, background 0.12s;
}
.chip:hover { background: rgba(50, 34, 16, 0.85); transform: translateY(-2px); }
.chip.picked { background: #d4b078; color: #3a2810; border-color: transparent; font-weight: 600; }
.chip.ghost { opacity: 0.45; }

.slot-board {
  position: absolute; left: 50%; top: 18%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex; flex-direction: column; gap: 8px;
  width: min(88%, 640px);
  pointer-events: auto;
}
.slot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(22, 14, 8, 0.62);
  color: #f4ead8;
  border: 1px dashed rgba(255,220,160,0.35);
  min-height: 44px;
  cursor: pointer;
}
.slot.filled {
  border-style: solid;
  background: rgba(40, 28, 14, 0.72);
}
.slot .idx { opacity: 0.6; width: 1.5em; }
.slot .val { flex: 1; }
.slot .ev { font-size: 12px; opacity: 0.75; }

.piece-tray {
  position: absolute; left: 50%; bottom: 20%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  max-width: 92%;
  pointer-events: auto;
}
.piece {
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 236, 200, 0.9);
  color: #3a2810;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  cursor: grab;
}
.piece.used { opacity: 0.35; pointer-events: none; }

.leak-drop {
  position: absolute;
  width: 10px; height: 14px;
  border-radius: 40% 40% 50% 50%;
  background: rgba(220, 60, 60, 0.7);
  pointer-events: none;
  animation: drip 1.6s ease-in forwards;
  z-index: 4;
}
@keyframes drip {
  0% { transform: translateY(0) scale(1); opacity: 0.9; }
  100% { transform: translateY(120px) scale(0.6); opacity: 0; }
}

.vesicle {
  position: absolute; width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe9a8, #e8a040);
  box-shadow: 0 0 12px rgba(255,180,60,0.6);
  pointer-events: none;
  z-index: 4;
  transition: left 1.2s ease, top 1.2s ease, opacity 0.4s;
}

.progress-dots {
  position: absolute; left: 50%; top: 3%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex; gap: 10px;
  pointer-events: none;
}
.progress-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,230,180,0.35);
}
.progress-dots span.on {
  background: #e8c878;
  box-shadow: 0 0 10px rgba(232,200,120,0.7);
}

@media (max-width: 700px) {
  #captionText { font-size: 14px; padding: 10px 14px; }
  .book { height: min(85%, 520px); }
  .book-pages { grid-template-columns: 1fr; }
  .page.left { display: none; }
}

/* hidden 必须真正不占事件，避免挡住旁白按钮 */
[hidden] { display: none !important; }
