* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #0a0518; overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  touch-action: none;
}
#game, #scene3d, #fg, #fx, #interior3d {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}
#game { z-index: 0; }
#scene3d { z-index: 1; }
#fg { z-index: 2; pointer-events: none; }
#fx { z-index: 3; pointer-events: none; }
#interior3d { z-index: 5; }

/* Viñeta / profundidad de microscopio sobre toda la escena */
#vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(4, 2, 12, 0.55) 100%),
    radial-gradient(ellipse 60% 40% at 50% 42%, rgba(120, 160, 255, 0.05), transparent 70%);
  mix-blend-mode: normal;
}
#vignette.hidden { display: none !important; }

#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }

.panel {
  background: rgba(15, 12, 32, 0.88);
  border: 1.5px solid rgba(128, 180, 255, 0.45);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(40, 80, 200, 0.25), inset 0 0 30px rgba(80, 120, 255, 0.04);
  backdrop-filter: blur(6px);
  color: #d7e4ff;
}

/* Top progress bar */
#topbar {
  position: absolute; top: 16px; left: 16px; width: min(300px, 56vw);
  padding: 10px 16px;
}
#progress-label {
  font-size: 13px; letter-spacing: 0.5px; color: #a9c5ff; font-weight: 600; margin-bottom: 6px;
}
#progress-track {
  width: 100%; height: 10px; border-radius: 6px; background: rgba(40, 40, 70, 0.6);
  overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, #4fa8ff, #7ee8ff);
  box-shadow: 0 0 10px rgba(120, 200, 255, 0.7);
  transition: width 0.4s ease;
}

/* Contador de sustancias flotantes */
#substance-chip {
  position: absolute; top: 78px; left: 16px;
  display: flex; gap: 12px; padding: 7px 14px; align-items: center;
}
.sub-item { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; color: #dbe6ff; }
.sub-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.sub-agua { background: #9fd8ff; color: #9fd8ff; }
.sub-ion { background: #ffe066; color: #ffe066; }
.sub-glucosa { background: #ffb066; color: #ffb066; }

/* Cargo / ruta de secreción */
#cargo-panel {
  position: absolute; top: 122px; left: 16px; width: min(280px, 70vw);
  padding: 12px 16px;
}
#cargo-title { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; color: #8fd8c8; margin-bottom: 8px; }
#cargo-steps { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.cargo-step {
  font-size: 12.5px; color: #6d7aa8; padding: 3px 8px; border-radius: 6px;
  border-left: 3px solid rgba(120, 140, 200, 0.25);
}
.cargo-step.active {
  color: #eaffef; background: rgba(80, 220, 170, 0.12); border-left-color: #58e0b0;
  font-weight: 600;
}
.cargo-step.done { color: #7fe0a8; border-left-color: #3ec98a; }
#cargo-status { font-size: 12.5px; color: #cfe0ff; line-height: 1.4; margin-bottom: 4px; }
#cargo-cycles { font-size: 11px; color: #7d8cb8; }

/* Minimapa */
#minimap-wrap {
  position: absolute; top: 16px; right: 16px; width: 152px; height: 96px; padding: 6px;
}
#minimap { width: 100%; height: 100%; display: block; border-radius: 8px; }

/* Bitácora button + panel */
#bitacora-btn {
  position: absolute; top: 122px; right: 16px;
  background: rgba(18, 15, 40, 0.9); border: 1.5px solid rgba(128, 180, 255, 0.5);
  color: #d7e4ff; font-size: 13px; font-weight: 700; letter-spacing: 1px;
  padding: 12px 18px; border-radius: 24px; cursor: pointer;
}
#bitacora-btn:active { background: rgba(30, 26, 60, 0.95); }

#bitacora {
  position: absolute; top: 176px; right: 16px; width: min(300px, 80vw);
  max-height: 50vh; padding: 14px;
  display: flex; flex-direction: column;
}
.bitacora-title { font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #cddcff; margin-bottom: 10px; }
#bitacora-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bitacora-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bitacora-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.bitacora-empty { font-size: 13px; color: #7d8cb8; font-style: italic; }

/* Ficha */
#ficha {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
  width: min(460px, 90vw); padding: 18px 22px 20px 26px;
}
#ficha-accent {
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  border-radius: 14px 0 0 14px; background: #7ec8ff;
}
#ficha-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: #9fb4e8; font-size: 18px; cursor: pointer; padding: 6px;
}
.ficha-body { display: flex; gap: 16px; align-items: flex-start; }
#ficha-icon { flex: none; width: 64px; height: 64px; }
#ficha-icon svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 8px rgba(130, 180, 255, 0.35)); }
.ficha-text { flex: 1; min-width: 0; }
.ficha-tag { font-size: 11px; letter-spacing: 1px; color: #7ec0ff; margin-bottom: 4px; }
#ficha-nombre { font-size: 22px; font-weight: 700; color: #f2f6ff; margin-bottom: 4px; }
#ficha-funcion { font-size: 14px; color: #a9c5ff; margin-bottom: 8px; }
#ficha-desc { font-size: 13.5px; line-height: 1.5; color: #ccd6f0; }

/* Scan / action button */
.scan-btn {
  position: absolute; bottom: 130px; right: 30px;
  background: linear-gradient(180deg, #1f6fa0, #144a70);
  border: 2px solid rgba(140, 210, 255, 0.85);
  color: #eef8ff; font-size: 17px; font-weight: 700; letter-spacing: 0.5px;
  padding: 15px 26px; border-radius: 30px; cursor: pointer;
  box-shadow: 0 4px 18px rgba(30, 130, 220, 0.5);
}
.scan-btn:active { transform: scale(0.96); }
.scan-btn[data-mode="pickup"] {
  background: linear-gradient(180deg, #a07a1f, #704e14); border-color: rgba(255, 224, 102, 0.85);
  box-shadow: 0 4px 18px rgba(220, 170, 30, 0.5);
}
.scan-btn[data-mode="deliver"] {
  background: linear-gradient(180deg, #1f9a6f, #146a4a); border-color: rgba(140, 255, 200, 0.85);
  box-shadow: 0 4px 18px rgba(30, 200, 130, 0.5);
}
.scan-btn[data-mode="info"] {
  background: linear-gradient(180deg, #4a3f8a, #302862); border-color: rgba(190, 170, 255, 0.85);
  box-shadow: 0 4px 18px rgba(120, 90, 220, 0.5);
}
.scan-btn[data-mode="enter"] {
  background: linear-gradient(180deg, #c4762a, #8a4d16); border-color: rgba(255, 190, 120, 0.9);
  box-shadow: 0 4px 18px rgba(220, 140, 40, 0.5);
}

/* Joystick */
#joystick {
  position: absolute; left: 34px; bottom: 34px; width: 168px; height: 168px;
}
#joystick-base {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(90, 140, 255, 0.08); border: 2px solid rgba(140, 190, 255, 0.28);
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 68px; height: 68px;
  margin-left: -34px; margin-top: -34px; border-radius: 50%;
  background: rgba(110, 170, 255, 0.22); border: 2px solid rgba(160, 210, 255, 0.65);
  transition: background 0.15s;
}

/* Boot screen */
#boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 30px; border-radius: 0; border: none;
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(30, 22, 66, 0.55), transparent 70%),
    linear-gradient(180deg, #0a0518 0%, #0b0722 55%, #080414 100%);
  overflow: hidden;
  backdrop-filter: none;
  animation: boot-in 0.6s ease both;
}
@keyframes boot-in { from { opacity: 0; } to { opacity: 1; } }

/* Lienzo de citoplasma vivo detrás del menú */
#menu-fx {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; display: block;
}
/* Viñeta encima del lienzo, debajo del contenido */
#boot::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 120% 100% at 50% 45%, transparent 50%, rgba(4, 2, 12, 0.75) 100%);
}

#boot-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; text-align: center; max-width: 940px; width: 100%;
}

#boot-eyebrow {
  font-size: 12px; letter-spacing: 4px; font-weight: 700;
  color: #7fb0ff; opacity: 0.85;
  padding: 5px 14px; border: 1px solid rgba(120, 170, 255, 0.28);
  border-radius: 999px; background: rgba(120, 170, 255, 0.06);
  animation: boot-rise 0.6s 0.05s ease both;
}

#boot-title {
  position: relative;
  font-size: clamp(28px, 7vw, 52px); font-weight: 800; letter-spacing: 1px; line-height: 1.05;
  background: linear-gradient(180deg, #ffffff 0%, #cfe1ff 45%, #7fb4ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 26px rgba(120, 190, 255, 0.45));
  animation: boot-rise 0.6s 0.12s ease both;
}
/* Barrido de luz sobre el título */
#boot-title::after {
  content: attr(data-text); position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 42%, rgba(255,255,255,0.85) 50%, transparent 58%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  background-size: 300% 100%; background-position: 120% 0;
  animation: boot-sheen 4.5s 1s ease-in-out infinite;
}
@keyframes boot-sheen {
  0% { background-position: 160% 0; }
  40%, 100% { background-position: -60% 0; }
}

#boot-sub { max-width: 480px; font-size: 14px; line-height: 1.5; color: #97a6d6;
  animation: boot-rise 0.6s 0.18s ease both; }

@keyframes boot-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* Menú de inicio: dos tarjetas de modo */
#boot-menu {
  display: flex; gap: 20px; flex-wrap: wrap; justify-content: center;
  max-width: 900px;
}
.menu-card {
  position: relative; overflow: hidden;
  width: 340px; max-width: 90vw; text-align: left;
  background: linear-gradient(180deg, rgba(28, 22, 54, 0.82), rgba(16, 12, 34, 0.9));
  border: 1.5px solid rgba(128, 180, 255, 0.32);
  border-radius: 18px; padding: 22px 22px 20px; cursor: pointer;
  color: #d7e4ff; font-family: inherit;
  box-shadow: 0 10px 34px rgba(6, 10, 40, 0.5);
  transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s, background 0.18s;
  animation: card-in 0.5s ease both;
}
.menu-card:nth-child(1) { animation-delay: 0.24s; }
.menu-card:nth-child(2) { animation-delay: 0.34s; }
@keyframes card-in { from { opacity: 0; transform: translateY(22px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Línea de acento superior que respira */
.menu-card::before {
  content: ''; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, transparent, rgba(120, 190, 255, 0.9), transparent);
  opacity: 0.6; transition: opacity 0.2s;
}
.menu-card:hover { transform: translateY(-5px); border-color: rgba(150, 200, 255, 0.85);
  background: linear-gradient(180deg, rgba(34, 27, 66, 0.92), rgba(18, 14, 40, 0.95));
  box-shadow: 0 16px 44px rgba(30, 70, 180, 0.4); }
.menu-card:hover::before { opacity: 1; }
.menu-card:active { transform: translateY(-1px); }

.menu-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; margin-bottom: 12px; font-size: 28px;
  border-radius: 14px; background: rgba(120, 170, 255, 0.1);
  border: 1px solid rgba(140, 190, 255, 0.28);
  box-shadow: inset 0 0 20px rgba(120, 170, 255, 0.12);
}
.menu-card-title { font-size: 16px; font-weight: 800; letter-spacing: 0.8px; color: #eaf2ff; margin-bottom: 8px; }
.menu-card-desc { font-size: 13px; line-height: 1.5; color: #aebde6; margin-bottom: 10px; }
.menu-card-reqs-label { font-size: 11px; letter-spacing: 0.4px; color: #ffc98f; margin-bottom: 8px; }
#boot-mito-reqs { display: flex; flex-direction: column; gap: 6px; }
#boot-mito-reqs .req-row { font-size: 12px; }
#boot-mito-reqs .req-check { width: 16px; height: 16px; font-size: 10px; }

.menu-card.locked {
  border-color: rgba(255, 170, 100, 0.28); cursor: default; opacity: 0.9;
}
.menu-card.locked::before { background: linear-gradient(90deg, transparent, rgba(255, 180, 110, 0.5), transparent); opacity: 0.35; }
.menu-card.locked:hover { transform: none; box-shadow: 0 10px 34px rgba(6, 10, 40, 0.5);
  background: linear-gradient(180deg, rgba(28, 22, 54, 0.82), rgba(16, 12, 34, 0.9)); border-color: rgba(255, 170, 100, 0.28); }
.menu-card.locked:hover::before { opacity: 0.35; }
/* Modo desbloqueado: acento cálido (mitocondria) */
.menu-card:not(.locked) { border-color: rgba(255, 190, 120, 0.65); }
.menu-card:not(.locked)::before { background: linear-gradient(90deg, transparent, rgba(255, 180, 110, 0.95), transparent); }
.menu-card:not(.locked) .menu-card-icon { background: rgba(255, 180, 110, 0.12); border-color: rgba(255, 190, 130, 0.35); box-shadow: inset 0 0 20px rgba(255, 170, 90, 0.14); }
.menu-card:not(.locked):hover { border-color: rgba(255, 210, 150, 0.95); box-shadow: 0 16px 44px rgba(255, 150, 60, 0.28); }
.menu-card.locked .menu-card-title::after { content: '  🔒'; font-size: 13px; }
.menu-card:not(.locked) .menu-card-title::after { content: '  ✓'; font-size: 13px; color: #6ff0b8; }

@media (max-width: 480px) {
  #boot-menu { gap: 14px; }
  .menu-card { padding: 16px 18px; width: 100%; }
}

/* Atajo de administrador: discreto, no compite visualmente con el menú real */
#boot-admin-btn {
  margin-top: 18px; background: none; border: 1px dashed rgba(140, 150, 190, 0.4);
  color: #6d7aa8; font-size: 11.5px; padding: 8px 14px; border-radius: 20px;
  cursor: pointer; font-family: inherit;
}
#boot-admin-btn:hover { color: #9fb0e0; border-color: rgba(160, 175, 220, 0.6); }
#boot-admin-btn:active { transform: scale(0.97); }

#interior-admin-badge { color: #ffb066; font-weight: 700; }

/* ---------------- Panel de desbloqueo ---------------- */
#unlock-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(430px, 90vw); padding: 22px 24px;
}
#unlock-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: #9fb4e8; font-size: 18px; cursor: pointer; padding: 6px;
}
#unlock-title { font-size: 13px; letter-spacing: 1.4px; color: #ffb066; font-weight: 700; margin-bottom: 6px; }
#unlock-sub { font-size: 15px; color: #eaf2ff; font-weight: 600; margin-bottom: 14px; }
#unlock-reqs { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.req-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.req-check { width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  border: 2px solid rgba(140,170,230,0.4); color: #7d8cb8; }
.req-row.ok .req-check { background: rgba(60,220,150,0.2); border-color: #4ce0a0; color: #6ff0b8; }
.req-label { flex: 1; color: #b9c8ea; }
.req-row.ok .req-label { color: #dff5ea; }
.req-count { font-weight: 700; color: #cfe0ff; font-variant-numeric: tabular-nums; }
.req-row.ok .req-count { color: #6ff0b8; }
.scan-btn-inline {
  width: 100%; background: linear-gradient(180deg, #c4762a, #8a4d16);
  border: 2px solid rgba(255, 190, 120, 0.9); color: #fff6ea;
  font-size: 16px; font-weight: 700; letter-spacing: 0.5px;
  padding: 14px; border-radius: 28px; cursor: pointer;
  box-shadow: 0 4px 18px rgba(220, 140, 40, 0.45);
}
.scan-btn-inline:active { transform: scale(0.97); }

/* ---------------- Modo interior (primera persona) ---------------- */
#interior-hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#interior-hud > * { pointer-events: auto; }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 22px; height: 22px;
  margin: -11px 0 0 -11px; pointer-events: none;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: rgba(255, 220, 170, 0.75);
  box-shadow: 0 0 6px rgba(255, 180, 100, 0.8);
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

#interior-topbar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; text-align: center; width: min(480px, 92vw);
  border-color: rgba(255, 170, 100, 0.45);
}
#interior-name { font-size: 14px; font-weight: 800; letter-spacing: 1.5px; color: #ffcf9a; }
#interior-hint { font-size: 11.5px; color: #d8bfa4; margin-top: 3px; }

#interior-exit {
  position: absolute; top: 16px; right: 16px;
  background: rgba(40, 18, 10, 0.9); border: 1.5px solid rgba(255, 170, 100, 0.5);
  color: #ffd8b0; font-size: 13px; font-weight: 700; letter-spacing: 1px;
  padding: 12px 18px; border-radius: 24px; cursor: pointer;
}

#station-prompt {
  position: absolute; top: 52%; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; text-align: center; border-color: rgba(255, 190, 120, 0.5);
}
#station-name { font-size: 15px; font-weight: 700; color: #ffe0b8; }
#station-sub { font-size: 12px; color: #d0b294; }

#station-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(460px, 90vw); padding: 20px 24px 22px 28px;
  border-color: rgba(255, 190, 120, 0.55);
}
#station-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  border-radius: 14px 0 0 14px; background: #ffb066; }
#station-close { position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: #d8b89a; font-size: 18px; cursor: pointer; padding: 6px; }
#station-card-name { font-size: 24px; font-weight: 700; color: #fff3e4; margin-bottom: 3px; }
#station-card-sub { font-size: 14px; color: #ffc98f; margin-bottom: 10px; }
#station-card-desc { font-size: 13.5px; line-height: 1.55; color: #e8d7c6; }

#interior-action { bottom: 130px; right: 30px;
  background: linear-gradient(180deg, #c4762a, #8a4d16);
  border-color: rgba(255, 190, 120, 0.9); }

.hidden { display: none !important; }

@media (max-width: 480px) {
  #topbar { width: min(250px, 52vw); }
  #substance-chip { top: 74px; gap: 8px; padding: 6px 10px; }
  .sub-item { font-size: 11.5px; }
  #cargo-panel { width: min(210px, 58vw); padding: 10px 12px; top: 116px; }
  #minimap-wrap { width: 108px; height: 72px; top: 12px; right: 12px; }
  #bitacora-btn { padding: 10px 14px; font-size: 11px; top: 92px; right: 12px; }
  #bitacora { top: 138px; right: 12px; }
  #ficha { top: auto; bottom: 210px; }
  .ficha-body { gap: 10px; }
  #ficha-icon { width: 48px; height: 48px; }
  .scan-btn { bottom: 120px; right: 20px; padding: 13px 20px; font-size: 15px; }
  #unlock-panel { padding: 18px; }
  #interior-topbar { top: 10px; padding: 8px 14px; }
  #interior-name { font-size: 12px; }
  #interior-hint { font-size: 10.5px; }
  #interior-exit { padding: 10px 14px; font-size: 11px; top: 12px; right: 12px; }
  #station-card { padding: 16px 18px 18px 22px; }
  #station-card-name { font-size: 20px; }
}
