:root {
  --cyan: #7fe0ff;
  --cyan-dim: #3d7f96;
  --amber: #ffc37a;
  --ink: #04060c;
  --panel: rgba(6, 12, 20, 0.82);
  --line: rgba(127, 224, 255, 0.22);
  --text: #cfe3ee;
  --mono: 'IBM Plex Mono', monospace;
  --disp: 'Rajdhani', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--ink); }
body { font-family: var(--disp); color: var(--text); }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

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

#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background: #eaf6ff; opacity: 0;
}

.letterbox {
  position: fixed; left: 0; right: 0; height: 9vh; background: #000;
  z-index: 4; transition: transform 1.4s cubic-bezier(.7,0,.3,1); pointer-events: none;
}
#lb-top { top: 0; }
#lb-bottom { bottom: 0; }
body.mode-dissection #lb-top { transform: translateY(-100%); }
body.mode-dissection #lb-bottom { transform: translateY(100%); }

#chapter {
  position: fixed; top: calc(9vh + 18px); left: 28px; z-index: 5;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.35em;
  color: var(--cyan-dim); text-transform: uppercase;
  opacity: 0; transition: opacity .8s;
}
#chapter.show { opacity: 1; }

#caption {
  position: fixed; bottom: calc(9vh + 30px); left: 50%; transform: translateX(-50%);
  z-index: 5; max-width: 80vw; text-align: center;
  font-size: clamp(17px, 2.2vw, 27px); font-weight: 500; letter-spacing: 0.14em;
  color: #e8f4fb; text-shadow: 0 0 18px rgba(127,224,255,.35), 0 2px 6px #000;
  opacity: 0; transition: opacity .7s; pointer-events: none; white-space: nowrap;
}
#caption.show { opacity: 1; }

#progress {
  position: fixed; bottom: 9vh; left: 0; right: 0; height: 2px; z-index: 5;
  background: rgba(127,224,255,.12); transition: opacity .8s;
}
#progress-fill { height: 100%; width: 0; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
body.mode-dissection #progress { opacity: 0; }

#top-controls {
  position: fixed; top: calc(9vh + 14px); right: 22px; z-index: 8;
  display: flex; gap: 10px; transition: top 1.4s cubic-bezier(.7,0,.3,1);
}
body.mode-dissection #top-controls { top: 16px; }

.hud-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--cyan); background: rgba(6,16,24,.7); border: 1px solid var(--line);
  padding: 8px 14px; cursor: pointer; backdrop-filter: blur(6px);
  transition: background .2s, color .2s, border-color .2s;
}
.hud-btn:hover { background: rgba(127,224,255,.14); border-color: var(--cyan); }
.hud-btn.toggle.on { background: rgba(127,224,255,.22); color: #fff; border-color: var(--cyan); }
body.mode-dissection #btn-skip { display: none; }

#sound-hint {
  position: fixed; bottom: calc(9vh + 8px); right: 22px; z-index: 8;
  font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: #5b7484;
  transition: opacity .8s; pointer-events: none;
}
#sound-hint.hide { opacity: 0; }
body.mode-dissection #sound-hint { display: none; }

/* ---------- dissection UI ---------- */
#dissect-header, #parts-panel, #dock, #info-panel {
  opacity: 0; pointer-events: none; transition: opacity .9s .3s;
}
body.mode-dissection #dissect-header,
body.mode-dissection #parts-panel,
body.mode-dissection #dock,
body.mode-dissection #info-panel { opacity: 1; pointer-events: auto; }

#dissect-header { position: fixed; top: 16px; left: 24px; z-index: 7; }
.ship-name { font-size: 24px; font-weight: 700; letter-spacing: .22em; color: #fff; text-shadow: 0 0 16px rgba(127,224,255,.4); }
.ship-sub { font-family: var(--mono); font-size: 10px; letter-spacing: .28em; color: var(--cyan-dim); margin-top: 3px; }

#parts-panel {
  position: fixed; top: 92px; left: 24px; z-index: 7; width: 232px;
  max-height: calc(100vh - 330px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px);
}
#parts-panel::-webkit-scrollbar { width: 4px; }
#parts-panel::-webkit-scrollbar-thumb { background: var(--cyan-dim); }
.panel-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .3em; color: var(--cyan-dim);
  padding: 10px 14px 8px; border-bottom: 1px solid var(--line);
}
.part-btn {
  display: block; width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid rgba(127,224,255,.07);
  font-family: var(--disp); font-size: 15px; font-weight: 600; letter-spacing: .08em;
  color: var(--text); padding: 9px 14px; cursor: pointer; transition: background .15s, color .15s;
}
.part-btn small { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: #5b7484; font-weight: 400; margin-top: 1px; }
.part-btn:hover { background: rgba(127,224,255,.1); color: #fff; }
.part-btn.active { background: rgba(127,224,255,.18); color: var(--cyan); border-left: 3px solid var(--cyan); padding-left: 11px; }

#info-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 7; width: min(430px, calc(100vw - 48px));
  max-height: calc(100vh - 140px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  padding: 20px 22px;
}
#info-panel::-webkit-scrollbar { width: 4px; }
#info-panel::-webkit-scrollbar-thumb { background: var(--cyan-dim); }
#info-close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: #5b7484; font-size: 14px; cursor: pointer; padding: 4px;
}
#info-close:hover { color: #fff; }
#info-content h2 { font-size: 22px; font-weight: 700; letter-spacing: .12em; color: #fff; margin-bottom: 2px; }
#info-content .tag { font-family: var(--mono); font-size: 10px; letter-spacing: .24em; color: var(--amber); margin-bottom: 12px; }
#info-content p { font-size: 14.5px; line-height: 1.55; font-weight: 500; color: #b9cfdb; margin-bottom: 10px; }
#info-content p strong { color: var(--cyan); font-weight: 600; }
#info-content table { width: 100%; border-collapse: collapse; margin-top: 12px; font-family: var(--mono); font-size: 11px; }
#info-content td { padding: 5px 6px; border-top: 1px solid rgba(127,224,255,.12); }
#info-content td:first-child { color: #5b7484; letter-spacing: .1em; white-space: nowrap; }
#info-content td:last-child { color: var(--cyan); text-align: right; }

#dock {
  position: fixed; left: 24px; bottom: 24px; z-index: 7;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px);
  padding: 14px 16px; width: 300px;
}
.dock-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dock-label { font-family: var(--mono); font-size: 10px; letter-spacing: .22em; color: var(--cyan-dim); white-space: nowrap; }
#explode { flex: 1; accent-color: var(--cyan); height: 3px; cursor: pointer; }
.dock-buttons { flex-wrap: wrap; gap: 6px; }
.dock-buttons .hud-btn { padding: 6px 9px; font-size: 10px; }
.dock-hint { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; color: #4d6472; margin-bottom: 0; }

#fatal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--ink); color: var(--text); font-size: 18px; text-align: center; padding: 40px;
}
#fatal[hidden] { display: none; }

@media (max-width: 900px) {
  #parts-panel { width: 190px; max-height: 40vh; }
  #info-panel { width: min(340px, calc(100vw - 48px)); max-height: 44vh; }
  #dock { width: 250px; }
  #caption { white-space: normal; }
}