/* ============================================================================
 * NEXUSLAB — SCIENCE WORLD (3dgame.html)
 * Standalone stylesheet for the 3D Voxel Sandbox & Interactive Science Lab
 * ============================================================================ */
:root {
  --ui-scale: 1;
  --bg-glass: rgba(11, 18, 32, 0.84);
  --bg-panel: rgba(15, 23, 42, 0.92);
  --border: rgba(148, 163, 184, 0.24);
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --accent-3: #a855f7;
  --danger: #ef4444;
  --warn: #f59e0b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 10px;
}

body.high-contrast {
  --bg-glass: rgba(0, 0, 0, 0.95);
  --bg-panel: #000000;
  --border: #ffffff;
  --accent: #38e8ff;
  --text: #ffffff;
  --muted: #e2e8f0;
}

* { box-sizing: border-box; user-select: none; }
input, textarea, select { user-select: text; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden;
  background: #070d19;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: calc(14px * var(--ui-scale));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }

#game-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  touch-action: none;
}

#boot-error {
  position: fixed; inset: 20px; z-index: 9999;
  background: #1e1b2e; border: 2px solid var(--danger);
  border-radius: 12px; padding: 24px; color: #fecaca;
  max-width: 600px; max-height: 220px; margin: auto;
}

/* ==================== BUTTONS & INPUTS (FORTNITE ANGULAR STYLIZED) ==================== */
.nx-btn {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.96));
  color: var(--text);
  border: 2px solid rgba(148, 163, 184, 0.34);
  border-radius: 6px;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  padding: 10px 18px;
  font-size: 0.92em;
  font-weight: 800;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.1s, box-shadow 0.15s;
}
.nx-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(51, 65, 85, 0.98), rgba(30, 41, 59, 0.98));
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.25);
}
.nx-btn:active:not(:disabled) { transform: scale(0.97); }
.nx-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.nx-btn.primary {
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 55%, #ea580c 100%);
  border-color: #fef08a;
  color: #0b1220;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  box-shadow: 0 8px 24px rgba(250, 204, 21, 0.32);
}
.nx-btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #fef08a 0%, #facc15 55%, #f97316 100%);
  border-color: #ffffff;
  box-shadow: 0 10px 30px rgba(250, 204, 21, 0.5);
}
.nx-btn.accent {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-color: #7dd3fc;
  color: #fff;
}
.nx-btn.accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #38bdf8, #3b82f6);
  box-shadow: 0 8px 22px rgba(56, 189, 248, 0.4);
}
.nx-btn.danger { background: linear-gradient(135deg, #dc2626, #991b1b); border-color: #f87171; color: #fff; }
.nx-btn.running { background: linear-gradient(135deg, #d97706, #ea580c); border-color: #fbbf24; color: #fff; }
.nx-btn.sm { padding: 6px 13px; font-size: 0.84em; clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%); }
.nx-btn.xs { padding: 4px 9px; font-size: 0.77em; clip-path: none; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: 0.85em; padding: 0 4px; }

.nx-input, .nx-select {
  background: rgba(15, 23, 42, 0.92);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.9em;
  outline: none;
}
.nx-input:focus, .nx-select:focus { border-color: var(--accent); }
.nx-input.sm, .nx-select.sm { padding: 5px 8px; font-size: 0.84em; }

/* ==================== TITLE SCREEN (FORTNITE SHOWCASE) ==================== */
#title-screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: clamp(20px, 6vw, 72px);
  background: linear-gradient(105deg, rgba(7, 13, 28, 0.82) 0%, rgba(11, 20, 42, 0.45) 45%, rgba(7, 13, 28, 0.08) 100%);
}
.title-card {
  width: min(460px, 92vw);
  background: rgba(10, 17, 34, 0.82);
  border: 2px solid rgba(56, 189, 248, 0.55);
  border-top: 4px solid #facc15;
  border-radius: 14px;
  padding: 26px 26px 20px;
  text-align: left;
  backdrop-filter: blur(10px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62), 0 0 40px rgba(56, 189, 248, 0.16);
}
.title-eyebrow {
  display: inline-block;
  font-size: 0.72em; font-weight: 900; letter-spacing: 1.8px; text-transform: uppercase;
  padding: 3px 10px; margin-bottom: 8px;
  background: linear-gradient(90deg, #facc15, #f97316);
  color: #0b1220;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.title-logo {
  font-size: 2.15em; font-weight: 900; letter-spacing: 0.8px; line-height: 1.08;
  background: linear-gradient(95deg, #ffffff 10%, #38bdf8 55%, #facc15 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 0;
}
.title-sub { color: #e2e8f0; margin: 8px 0 15px; font-size: 0.92em; line-height: 1.4; }
.title-pills { display: flex; gap: 6px; justify-content: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.title-pill {
  font-size: 0.75em; font-weight: 700; padding: 4px 10px;
  border-radius: 5px;
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #e0f2fe;
}
.title-pill.gold {
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.55);
  color: #fef08a;
}
.title-menu { display: flex; flex-direction: column; gap: 9px; }
.title-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.title-foot { margin-top: 14px; font-size: 0.76em; color: var(--muted); }
@media (max-width: 720px) {
  #title-screen { justify-content: center; padding-left: 0; }
}

/* ==================== HUD & FORTNITE CIRCULAR DYNAMIC RETICLE ==================== */
#hud { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#hud button { pointer-events: auto; }

#crosshair {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  transition: width 0.14s cubic-bezier(.22,1,.36,1), height 0.14s cubic-bezier(.22,1,.36,1), transform 0.14s;
}
.reticle-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.2px solid rgba(255, 255, 255, 0.84);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.65), inset 0 0 4px rgba(0, 0, 0, 0.35);
  transition: border-color 0.14s, border-width 0.14s, box-shadow 0.14s, transform 0.16s;
}
.reticle-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.9), 0 0 8px rgba(255, 255, 255, 0.7);
  transition: background 0.14s, transform 0.14s, box-shadow 0.14s;
}
.reticle-tick {
  position: absolute; background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  transition: background 0.14s, transform 0.14s;
}
.reticle-tick.t-top    { top: -5px; left: 50%; transform: translateX(-50%); width: 2px; height: 5px; }
.reticle-tick.t-bottom { bottom: -5px; left: 50%; transform: translateX(-50%); width: 2px; height: 5px; }
.reticle-tick.t-left   { left: -5px; top: 50%; transform: translateY(-50%); width: 5px; height: 2px; }
.reticle-tick.t-right  { right: -5px; top: 50%; transform: translateY(-50%); width: 5px; height: 2px; }

/* Active Voxel Target */
#crosshair.active { width: 38px; height: 38px; }
#crosshair.active .reticle-ring { border-color: #38bdf8; box-shadow: 0 0 12px rgba(56, 189, 248, 0.65); }
#crosshair.active .reticle-dot { background: #38bdf8; }
#crosshair.active .reticle-tick { background: #38bdf8; }

/* Hovering Giant Draggable Mega Equipment */
#crosshair.state-mega { width: 42px; height: 42px; }
#crosshair.state-mega .reticle-ring {
  border-color: #38bdf8; border-width: 2.6px;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.85), inset 0 0 8px rgba(56, 189, 248, 0.35);
}
#crosshair.state-mega .reticle-dot { background: #7dd3fc; transform: scale(1.25); }
#crosshair.state-mega .reticle-tick { background: #facc15; }

/* Hovering Giant Marble (ready to grab & roll!) */
#crosshair.state-marble { width: 40px; height: 40px; }
#crosshair.state-marble .reticle-ring {
  border-color: #4ade80; border-width: 2.6px;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.9), inset 0 0 8px rgba(74, 222, 128, 0.35);
}
#crosshair.state-marble .reticle-dot { background: #4ade80; transform: scale(1.35); }
#crosshair.state-marble .reticle-tick { background: #4ade80; }

/* Actively Grabbing & Dragging with Gravity Beam! */
@keyframes reticleSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#crosshair.state-grabbing { width: 50px; height: 50px; }
#crosshair.state-grabbing .reticle-ring {
  border-color: #facc15; border-width: 3px; border-style: dashed;
  box-shadow: 0 0 22px rgba(250, 204, 21, 0.9), inset 0 0 12px rgba(56, 189, 248, 0.55);
  animation: reticleSpin 2.4s linear infinite;
}
#crosshair.state-grabbing .reticle-dot { background: #facc15; transform: scale(1.45); box-shadow: 0 0 12px #facc15; }
#crosshair.state-grabbing .reticle-tick { background: #38bdf8; }

.hud-top-left {
  position: fixed; top: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.hud-pill {
  background: rgba(10, 17, 34, 0.82); border: 1.5px solid rgba(148, 163, 184, 0.32);
  border-left: 3.5px solid var(--accent);
  border-radius: 6px; padding: 5px 11px; font-size: 0.82em; font-weight: 700;
  width: fit-content; backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}
.hud-pill.lab-inside { border-color: #22c55e; border-left-color: #4ade80; color: #bbf7d0; background: rgba(6, 78, 59, 0.86); }
.hud-pill.lab-outside { border-color: rgba(56, 189, 248, 0.45); color: #bae6fd; }
.hud-pill.gravity-pill { border-left-color: #facc15; color: #fef08a; background: rgba(15, 23, 42, 0.88); }
.hud-pill.score-pill { border-color: rgba(250, 204, 21, 0.55); border-left-color: #facc15; color: #fde047; background: rgba(30, 27, 15, 0.85); }
.hud-pill.slowmo-pill {
  border-color: #c084fc; border-left-color: #e879f9; color: #f5d0fe;
  background: linear-gradient(90deg, rgba(88, 28, 135, 0.92), rgba(49, 46, 129, 0.92));
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.55);
}

.hud-top-right {
  position: fixed; top: 10px; right: 10px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
}
.hud-keys-mini {
  background: rgba(10, 17, 34, 0.84); border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-right: 3.5px solid #facc15;
  border-radius: 7px; padding: 6px 10px; font-size: 0.71em; color: #e2e8f0;
  line-height: 1.48; text-align: right; max-width: 390px;
  backdrop-filter: blur(8px);
}
.hud-keys-mini b { color: #facc15; }

#pointer-hint {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 18; background: linear-gradient(135deg, rgba(2, 132, 199, 0.92), rgba(37, 99, 235, 0.92)); color: #fff;
  border: 1.5px solid #7dd3fc;
  padding: 6px 14px; border-radius: 99px; font-size: 0.78em; font-weight: 700;
  white-space: nowrap; max-width: 440px; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; box-shadow: 0 6px 20px rgba(2, 132, 199, 0.42);
}

#interact-prompt {
  position: fixed; bottom: 112px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 17, 34, 0.92); border: 2px solid #38bdf8;
  border-left: 5px solid #facc15;
  color: #f8fafc; padding: 8px 18px; border-radius: 8px;
  font-weight: 700; font-size: 0.9em; max-width: 92vw; text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
}

/* ==================== MEGA EXPERIMENT SPAWNER MODAL ([B]) ==================== */
.spawner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 10px;
}
.spawner-card {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 12px;
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.94));
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  color: var(--text); text-align: left; cursor: pointer;
  transition: transform 0.12s, border-color 0.14s, box-shadow 0.14s;
}
.spawner-card:hover {
  transform: translateY(-2px);
  border-color: #facc15;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.25);
  background: linear-gradient(160deg, rgba(30, 58, 95, 0.92), rgba(15, 23, 42, 0.96));
}
.spawner-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 9px; border: 2px solid #38bdf8;
  background: rgba(10, 17, 34, 0.88);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.spawner-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.spawner-cat { font-size: 0.7em; font-weight: 900; text-transform: uppercase; letter-spacing: 0.7px; }
.spawner-name { font-size: 0.86em; font-weight: 800; color: #f8fafc; line-height: 1.25; }
.spawner-desc { font-size: 0.74em; color: #cbd5e1; line-height: 1.32; margin-top: 2px; }

.hotbar-wrap {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
#hotbar-item-name {
  background: rgba(11, 18, 32, 0.78); padding: 3px 11px; border-radius: 99px;
  font-size: 0.82em; color: #e2e8f0;
}
#hotbar {
  display: flex; gap: 5px; padding: 6px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 12px; backdrop-filter: blur(8px);
}
.hotbar-slot, .inv-slot {
  position: relative; width: 48px; height: 48px;
  background: rgba(30, 41, 59, 0.82); border: 2px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; color: var(--text);
}
.hotbar-slot.active, .inv-slot.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35); background: rgba(14, 165, 233, 0.18); }
.inv-slot.drag-over { border-color: #22c55e; background: rgba(34, 197, 94, 0.22); }
.inv-slot.dimmed { opacity: 0.25; }
.slot-num { position: absolute; top: 2px; left: 4px; font-size: 0.68em; color: var(--muted); }
.slot-qty { position: absolute; bottom: 2px; right: 4px; font-size: 0.74em; font-weight: 700; text-shadow: 0 1px 2px #000; }
.slot-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.slot-icon img { width: 32px; height: 32px; image-rendering: pixelated; border-radius: 4px; }
.slot-icon.big { width: 42px; height: 42px; }
.slot-icon.big img { width: 42px; height: 42px; }
.eq-badge {
  width: 30px; height: 30px; border-radius: 7px; border: 2px solid var(--accent);
  background: rgba(15, 23, 42, 0.85); display: flex; align-items: center; justify-content: center; font-size: 16px;
}

/* ==================== TOASTS ==================== */
#toast-container {
  position: fixed; top: 48px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-width: 460px; pointer-events: none;
}
.nx-toast {
  background: var(--bg-panel); border: 1px solid var(--accent);
  border-radius: 9px; padding: 8px 15px; font-size: 0.86em; font-weight: 600;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45); transition: opacity 0.35s;
}
.nx-toast-ok { border-color: #22c55e; color: #bbf7d0; }
.nx-toast-warn { border-color: #f59e0b; color: #fde68a; }
.nx-toast.fade { opacity: 0; }

/* ==================== MODALS (PAUSE / SETTINGS / WORLDS / INVENTORY) ==================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 10, 20, 0.74); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 15px; width: min(760px, 95vw); max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 65px rgba(0,0,0,0.6);
}
.modal-box.narrow { width: min(420px, 92vw); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.5);
}
.modal-head h3 { margin: 0; font-size: 1.08em; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

/* Inventory Layout */
.inv-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inv-tab-btn.active { border-color: var(--accent); background: rgba(14, 165, 233, 0.25); }
.inv-grid { display: grid; grid-template-columns: repeat(9, 48px); gap: 6px; justify-content: center; }
.inv-section-lbl { font-size: 0.78em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 4px 0; }
.inv-catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 7px; max-height: 290px; overflow-y: auto; }
.catalog-card {
  display: flex; align-items: center; gap: 9px; padding: 7px;
  background: rgba(30, 41, 59, 0.8); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text); text-align: left;
}
.catalog-card:hover { border-color: var(--accent); background: rgba(14, 165, 233, 0.16); }
.cat-name { font-size: 0.83em; font-weight: 600; }
.cat-sub { font-size: 0.74em; color: #34d399; }
.inv-detail-panel {
  border-top: 1px solid var(--border); padding-top: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.detail-head { display: flex; align-items: center; gap: 10px; }
.detail-head h4 { margin: 0; font-size: 0.98em; }
.detail-actions { display: flex; gap: 8px; }

/* Settings & Worlds */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 680px) { .settings-grid { grid-template-columns: 1fr; } }
.set-group { background: rgba(30, 41, 59, 0.48); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; display: flex; flex-direction: column; gap: 9px; }
.set-group h4 { margin: 0 0 2px; font-size: 0.9em; color: var(--accent); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.86em; }
.set-row input[type="range"] { width: 120px; }
.world-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(30, 41, 59, 0.65); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.world-name { font-weight: 700; }
.world-sub { font-size: 0.78em; color: var(--muted); }
.world-acts { display: flex; gap: 6px; }
.keybind-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(148,163,184,0.12); font-size: 0.88em; }

/* ==================== INTERACTIVE 3D LABORATORY UI ==================== */
#lab-ui {
  position: fixed; inset: 0; z-index: 30;
  pointer-events: none; /* Center stays click-through to the 3D workbench canvas! */
}
#lab-ui .lab-topbar, #lab-ui .lab-dock { pointer-events: auto; }

.lab-topbar {
  position: fixed; top: 8px; left: 8px; right: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--bg-panel); border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 11px; padding: 7px 12px; backdrop-filter: blur(8px);
}
.lab-top-left { display: flex; align-items: center; gap: 10px; }
#lab-bench-title { font-weight: 800; color: #7dd3fc; font-size: 0.96em; }
.lab-hint { font-size: 0.76em; color: var(--muted); }
.lab-top-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.lab-dock {
  position: fixed; top: 58px; bottom: 10px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; backdrop-filter: blur(8px);
  display: flex; flex-direction: column; overflow: hidden;
}
.lab-dock-left { left: 8px; width: min(305px, 28vw); }
.lab-dock-right { right: 8px; width: min(385px, 34vw); }

.dock-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.lab-ltab {
  background: transparent; border: none; color: var(--muted);
  padding: 9px 8px; font-weight: 700; font-size: 0.84em; cursor: pointer;
}
.lab-ltab.active { color: #fff; background: rgba(14, 165, 233, 0.22); border-bottom: 2px solid var(--accent); }

.dock-pane { padding: 9px; display: flex; flex-direction: column; gap: 7px; flex: 1; overflow-y: auto; }
.filter-row { display: flex; gap: 5px; }
.filter-row > * { flex: 1; min-width: 0; }

#lab-exp-list { display: flex; flex-direction: column; gap: 6px; }
.exp-card {
  text-align: left; padding: 8px 9px; border-radius: 8px;
  background: rgba(30, 41, 59, 0.75); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); cursor: pointer; color: var(--text);
}
.exp-card.subj-physics { border-left-color: #3b82f6; }
.exp-card.subj-chemistry { border-left-color: #10b981; }
.exp-card.subj-biology { border-left-color: #a855f7; }
.exp-card.active { background: rgba(14, 165, 233, 0.22); border-color: var(--accent); }
.exp-card-top { display: flex; justify-content: space-between; font-size: 0.72em; color: var(--muted); margin-bottom: 2px; }
.exp-card-title { font-weight: 700; font-size: 0.83em; line-height: 1.25; }
.exp-card-topic { font-size: 0.73em; color: var(--muted); margin-top: 2px; }

#lab-eq-tray { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.eq-drag-card {
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: rgba(30, 41, 59, 0.82); border: 1px solid var(--border);
  border-radius: 8px; cursor: grab; font-size: 0.76em;
}
.eq-drag-card:hover { border-color: var(--accent); background: rgba(14, 165, 233, 0.16); }
.eq-ico { width: 24px; height: 24px; flex-shrink: 0; border-radius: 6px; border: 1.5px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.eq-lbl { line-height: 1.18; }

#lab-selection-info {
  padding: 7px 10px; border-top: 1px solid var(--border);
  font-size: 0.76em; background: rgba(15, 23, 42, 0.9);
}

/* Right Dock Simulation Content */
.right-scroll { padding: 10px 11px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; }
#lab-active-title { margin: 0; font-size: 0.98em; color: #e0f2fe; }
#lab-active-desc { margin: 0; font-size: 0.81em; color: #cbd5e1; line-height: 1.35; }
#lab-safety-note {
  background: rgba(180, 83, 9, 0.25); border: 1px solid #f59e0b; color: #fde68a;
  border-radius: 7px; padding: 5px 8px; font-size: 0.76em;
}

.req-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.8em; font-weight: 700; margin-bottom: 5px; }
.req-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.req-chip { font-size: 0.74em; padding: 3px 7px; border-radius: 99px; border: 1px solid var(--border); }
.req-chip.ok { background: rgba(22, 163, 74, 0.25); border-color: #22c55e; color: #bbf7d0; }
.req-chip.missing { background: rgba(217, 119, 6, 0.25); border-color: #f59e0b; color: #fde68a; cursor: pointer; }

#lab-prediction-box {
  background: rgba(88, 28, 135, 0.24); border: 1px solid rgba(168, 85, 247, 0.55);
  border-radius: 9px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.pred-title { font-weight: 700; font-size: 0.82em; color: #e9d5ff; }
.pred-q { font-size: 0.82em; color: #f8fafc; }
.pred-opts { display: flex; flex-direction: column; gap: 4px; }
.pred-opt { font-size: 0.8em; display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
.pred-done { font-size: 0.8em; color: #d8b4fe; }

.sim-btn-row { display: flex; flex-wrap: wrap; gap: 5px; }
.param-row { display: flex; flex-direction: column; gap: 3px; font-size: 0.81em; }
.param-head { display: flex; justify-content: space-between; }
.param-val { color: var(--accent); font-weight: 700; font-family: monospace; }

#lab-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.readout-card {
  background: rgba(15, 23, 42, 0.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px;
}
.ro-label { font-size: 0.72em; color: var(--muted); }
.ro-val { font-size: 0.94em; font-weight: 700; color: #38bdf8; font-family: monospace; }
.ro-val span { font-size: 0.8em; color: #94a3b8; font-weight: 400; }

#lab-graph-canvas, #lab-view-canvas {
  width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; background: #0b1220;
}
#lab-graph-canvas { height: 185px; }
#lab-view-canvas { height: 170px; }

#lab-data-table table { width: 100%; border-collapse: collapse; font-size: 0.74em; font-family: monospace; }
#lab-data-table th, #lab-data-table td { border: 1px solid rgba(148,163,184,0.18); padding: 3px 5px; text-align: right; }
#lab-data-table th { background: rgba(30, 41, 59, 0.8); color: #94a3b8; }
.trials-meta { font-size: 0.76em; color: #34d399; margin-top: 4px; }

#lab-result-box {
  background: rgba(6, 78, 59, 0.28); border: 1px solid #10b981;
  border-radius: 9px; padding: 9px 10px; display: flex; flex-direction: column; gap: 5px; font-size: 0.8em;
}
.res-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.res-badge.pass { background: #16a34a; color: #fff; padding: 2px 7px; border-radius: 99px; font-size: 0.84em; }
.res-badge.diff { background: #d97706; color: #fff; padding: 2px 7px; border-radius: 99px; font-size: 0.84em; }
.res-explain { color: #cbd5e1; line-height: 1.38; }
.res-challenge { color: #fde68a; }

/* ==================== PWR-1000 NUCLEAR REACTOR CONTROL ROOM OVERLAY ==================== */
#pwr-console {
  position: fixed; inset: 0; z-index: 45;
  display: flex; flex-direction: column; padding: 8px; gap: 8px;
  pointer-events: none; /* Center stays open so the live 14m 3D Reactor gleams in front! */
}
#pwr-console .pwr-topbar, #pwr-console .pwr-dock { pointer-events: auto; }
.pwr-topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: rgba(8, 15, 30, 0.94); border: 2px solid #00e5ff;
  border-radius: 10px; padding: 7px 12px; backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 229, 255, 0.22);
}
.pwr-title { font-weight: 900; font-size: 0.9em; color: #7dd3fc; letter-spacing: 0.4px; }
.pwr-badge {
  font-size: 0.78em; font-weight: 900; padding: 3px 10px; border-radius: 99px;
  border: 2px solid #38bdf8; background: rgba(15, 23, 42, 0.9);
}
.pwr-docks-row {
  flex: 1; min-height: 0;
  display: flex; justify-content: space-between; align-items: stretch; gap: 12px;
  pointer-events: none;
}
.pwr-dock {
  width: min(318px, 31vw); max-height: 100%;
  background: rgba(8, 15, 30, 0.88); border: 1.5px solid rgba(56, 189, 248, 0.42);
  border-radius: 12px; padding: 11px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 9px; backdrop-filter: blur(10px);
}
.pwr-sec-title { font-size: 0.78em; font-weight: 900; color: #facc15; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid rgba(148,163,184,0.2); padding-bottom: 4px; }
.pwr-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pwr-metric {
  background: rgba(15, 23, 42, 0.85); border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 7px; padding: 6px 8px;
}
.pwr-metric .k { font-size: 0.7em; color: #94a3b8; }
.pwr-metric .v { font-size: 0.94em; font-weight: 800; color: #38bdf8; font-family: monospace; margin-top: 2px; }
.pwr-ctrl { display: flex; flex-direction: column; gap: 4px; font-size: 0.82em; }
.pwr-ctrl-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.pwr-ctrl input[type="range"] { width: 100%; accent-color: #00e5ff; cursor: pointer; }
.pwr-scram-btn {
  width: 100%; padding: 12px; font-size: 0.96em; font-weight: 900; letter-spacing: 0.8px;
  background: linear-gradient(135deg, #ef4444, #991b1b); border: 2px solid #fca5a5;
  color: #fff; border-radius: 8px; cursor: pointer;
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.55);
}
.pwr-scram-btn:hover { background: linear-gradient(135deg, #f87171, #dc2626); }
.pwr-step { font-size: 0.77em; color: #cbd5e1; padding: 4px 6px; border-radius: 6px; background: rgba(30, 41, 59, 0.55); }
.pwr-step.done { color: #86efac; background: rgba(22, 163, 74, 0.22); border: 1px solid rgba(74, 222, 128, 0.45); }
#pwr-scope-canvas { width: 100%; height: 145px; border-radius: 8px; border: 1px solid rgba(56, 189, 248, 0.35); display: block; }
.pwr-logs { display: flex; flex-direction: column; gap: 4px; font-size: 0.72em; color: #bae6fd; font-family: monospace; }
.pwr-log-line { background: rgba(15, 23, 42, 0.75); padding: 4px 6px; border-left: 2px solid #38bdf8; border-radius: 4px; }

@media (max-width: 960px) {
  .lab-dock-left { width: 235px; }
  .lab-dock-right { width: 295px; }
  .inv-grid { grid-template-columns: repeat(9, 36px); }
  .hotbar-slot, .inv-slot { width: 38px; height: 38px; }
}

/* ==================== CENTERED WEBGL ERROR MODAL ==================== */
#boot-error.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.78); backdrop-filter: blur(8px);
}
#boot-error.hidden { display: none !important; }
.webgl-err-box { border-color: rgba(248, 113, 113, 0.55); max-width: 480px; }
.webgl-err-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.webgl-err-actions .nx-btn { flex: 1; min-width: 120px; }

/* ==================== HUD QUICK ACTION BAR & BADGES ==================== */
.hud-quick-tools {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px;
  margin-bottom: 6px; pointer-events: auto;
}
.hud-tool-btn {
  padding: 5px 10px; border-radius: 8px; font-size: 11px; font-weight: 800;
  color: #e2e8f0; background: rgba(10, 18, 36, 0.86);
  border: 1px solid rgba(56, 189, 248, 0.35); cursor: pointer;
  transition: all 0.16s ease; backdrop-filter: blur(8px);
}
.hud-tool-btn:hover { background: rgba(14, 116, 144, 0.55); border-color: #38bdf8; }
.hud-tool-btn.active { background: rgba(6, 182, 212, 0.35); border-color: #22d3ee; color: #ffffff; box-shadow: 0 0 12px rgba(34, 211, 238, 0.45); }
.hud-tool-btn.danger-active { background: rgba(239, 68, 68, 0.75); border-color: #fca5a5; color: #fff; animation: nxPulseDanger 0.9s infinite alternate; }
.hover-pill { border-color: #22d3ee !important; color: #67e8f9 !important; background: rgba(8, 47, 73, 0.85) !important; }
.drone-pill { border-color: #c084fc !important; color: #e9d5ff !important; background: rgba(59, 7, 100, 0.82) !important; }

/* ==================== SHIFT MISSIONS PANEL (KỸ SƯ TRỰC CA) ==================== */
.shift-panel {
  margin-top: 6px; width: 295px; max-width: 82vw; pointer-events: auto;
  background: rgba(8, 15, 32, 0.86); border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 11px; padding: 8px 10px; backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.shift-panel.collapsed .shift-list,
.shift-panel.collapsed .shift-chief-badge { display: none; }
.shift-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 900; color: #38bdf8; letter-spacing: 0.3px;
}
.shift-xp-pill {
  font-size: 10.5px; font-family: monospace; font-weight: 800; color: #fde047;
  background: rgba(250, 204, 21, 0.16); border: 1px solid rgba(250, 204, 21, 0.4);
  padding: 2px 6px; border-radius: 999px;
}
.shift-toggle-btn {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(30, 41, 59, 0.8); color: #e2e8f0; cursor: pointer; font-size: 11px;
}
.shift-chief-badge {
  margin-top: 6px; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 900;
  text-align: center; color: #fef08a;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.32), rgba(234, 88, 12, 0.25));
  border: 1px solid rgba(250, 204, 21, 0.65);
}
.shift-list { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
.shift-step {
  padding: 5px 7px; border-radius: 7px; font-size: 10.8px; line-height: 1.35;
  background: rgba(15, 23, 42, 0.72); border: 1px solid rgba(148, 163, 184, 0.18); color: #e2e8f0;
}
.shift-step.done {
  background: rgba(22, 163, 74, 0.2); border-color: rgba(74, 222, 128, 0.45); color: #bbf7d0;
}
.shift-step-meta { font-size: 10px; font-family: monospace; color: #7dd3fc; margin-top: 2px; padding-left: 18px; }
.shift-step.done .shift-step-meta { color: #86efac; }

/* ==================== ATLAS STATUS DOTS (XANH / VÀNG / ĐỎ) ==================== */
.atlas-status-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.atlas-status-dot.status-green  { background: #22c55e; color: #22c55e; }
.atlas-status-dot.status-yellow { background: #facc15; color: #facc15; }
.atlas-status-dot.status-red    { background: #ef4444; color: #ef4444; animation: nxPulseDanger 0.7s infinite alternate; }

/* ==================== SCI-SCANNER THERMAL & RAYCAST INSPECTOR ==================== */
.scanner-thermal-bar {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  background: rgba(8, 15, 32, 0.88); border: 1px solid rgba(56, 189, 248, 0.5);
  font-size: 11px; font-weight: 800; color: #f8fafc; pointer-events: none;
}
.thermal-grad {
  width: 140px; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9 0%, #22d3ee 32%, #facc15 66%, #ef4444 100%);
}
.scanner-inspect-card {
  position: fixed; top: 56%; left: 50%; transform: translate(-50%, 0); z-index: 42;
  min-width: 280px; max-width: 390px; padding: 10px 13px; border-radius: 12px;
  background: rgba(6, 13, 28, 0.9); border: 1.5px solid rgba(34, 211, 238, 0.65);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65); pointer-events: none; backdrop-filter: blur(10px);
}
.sci-insp-title { font-size: 12px; font-weight: 900; color: #38bdf8; margin-bottom: 5px; letter-spacing: 0.3px; }
.sci-insp-line { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: #cbd5e1; margin: 2px 0; }
.sci-insp-line b { color: #f8fafc; font-family: monospace; text-align: right; }
.sci-insp-dist { margin-top: 5px; padding-top: 4px; border-top: 1px solid rgba(148, 163, 184, 0.2); font-size: 10px; font-family: monospace; color: #94a3b8; }

/* ==================== STRESS TEST RED VIGNETTE & ALERT CARD ==================== */
#stress-red-vignette {
  position: fixed; inset: 0; z-index: 35; pointer-events: none;
  box-shadow: inset 0 0 120px 35px rgba(239, 68, 68, 0.85);
}
.stress-alert-card {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 65;
  width: min(460px, 92vw); padding: 12px 15px; border-radius: 14px; pointer-events: auto;
  background: rgba(30, 8, 12, 0.93); border: 2px solid #ef4444;
  box-shadow: 0 12px 40px rgba(239, 68, 68, 0.45); backdrop-filter: blur(10px);
}
.stress-alert-title { font-size: 13px; font-weight: 900; color: #fca5a5; margin-bottom: 5px; }
.stress-alert-desc { font-size: 11.5px; line-height: 1.5; color: #fee2e2; margin-bottom: 10px; }
.stress-recover-btn { width: 100%; font-weight: 900; }

/* ==================== PHOTO MODE FLASH ==================== */
#photo-flash {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: #ffffff; opacity: 0; transition: opacity 0.24s ease;
}
#photo-flash.active { opacity: 0.72; }

/* ==================== 30s NEW-PLAYER GUIDE DRONE CARD ==================== */
.guide-drone-card {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%); z-index: 55;
  width: min(500px, 92vw); padding: 11px 14px; border-radius: 14px; pointer-events: auto;
  background: rgba(8, 17, 36, 0.92); border: 1.5px solid rgba(56, 189, 248, 0.65);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6); backdrop-filter: blur(10px);
}
.guide-drone-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 900; color: #38bdf8; margin-bottom: 6px;
}
.guide-drone-list { margin: 0; padding-left: 16px; font-size: 11.5px; line-height: 1.55; color: #e2e8f0; }
.guide-drone-list code {
  background: rgba(56, 189, 248, 0.18); color: #7dd3fc; padding: 1px 5px; border-radius: 4px; font-family: monospace; font-weight: 800;
}

@keyframes nxPulseDanger {
  from { opacity: 0.72; }
  to { opacity: 1; }
}
