:root {
  --bg: #050608;
  --panel: rgba(16, 18, 24, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8eaee;
  --muted: #9aa0ab;
  --accent: #7cf7d4;
  --danger: #ff7a6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

[hidden] { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10;
}

#menu { background: radial-gradient(ellipse at center, rgba(5, 6, 8, 0.55) 0%, rgba(5, 6, 8, 0.15) 70%); }

.panel {
  width: min(420px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(6px);
}

.panel h1 { margin: 0; font-size: 34px; letter-spacing: 0.02em; }
.panel h2 { margin: 0 0 8px; }
.tagline { margin: 4px 0 20px; color: var(--muted); }

label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-transform: none;
}
#code { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 600; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.actions { display: flex; gap: 10px; margin-top: 6px; }
button {
  flex: 1;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  color: #04110d;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button.secondary { color: var(--text); background: rgba(255, 255, 255, 0.1); }
button:disabled { opacity: 0.5; cursor: wait; }

.hint { margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.error { margin: 12px 0 0; color: var(--danger); font-size: 14px; }
.help { color: var(--muted); font-size: 14px; line-height: 1.9; }
kbd {
  padding: 1px 6px;
  font: 12px ui-monospace, monospace;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 4px;
}

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  mix-blend-mode: difference;
}

#info {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#room-code { color: var(--accent); font-weight: 700; letter-spacing: 0.1em; }
#coords { color: var(--muted); font-variant-numeric: tabular-nums; }

#target {
  position: absolute;
  top: calc(50% + 22px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
}

#hotbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  display: flex;
  gap: 4px;
  max-width: calc(100% - 32px);
  padding: 5px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.slot {
  position: relative;
  width: 46px;
  height: 46px;
  border: 2px solid transparent;
  border-radius: 7px;
  display: grid;
  place-items: center;
}
.slot.active { border-color: var(--accent); }
.slot .swatch { width: 28px; height: 28px; border-radius: 4px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25); }
.slot .key { position: absolute; top: 1px; left: 4px; font-size: 10px; color: var(--muted); }

#toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* ---------- Supervivencia ---------- */
#mine-ring {
  position: absolute;
  inset: -9px;
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
  mix-blend-mode: normal;
}
#mine-ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 94.25;
  stroke-dashoffset: 94.25;
}
#clock { color: var(--muted); }

#bars {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  width: min(480px, calc(100% - 32px));
}
.bar { display: flex; align-items: center; gap: 6px; font-size: 12px; text-shadow: 0 1px 2px #000; }
.bar .label { width: 30px; color: var(--muted); }
.bar .value { width: 36px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.track { flex: 1; height: 8px; background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.fill { height: 100%; width: 100%; border-radius: 4px; transition: width 0.2s; }
#bar-health .fill { background: #ff6b6b; }
#bar-oxygen .fill { background: #4fc3f7; }
#bar-oxygen.low .fill { background: #ffb74d; animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
#pressure { grid-column: 1 / -1; text-align: center; font-size: 12px; color: var(--muted); text-shadow: 0 1px 2px #000; min-height: 16px; }
#pressure.on { color: var(--accent); }

#slot-name {
  position: absolute;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
}
.slot .count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}
.slot.empty .swatch { opacity: 0.25; }
.swatch.tool { border-radius: 50%; box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.35); }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(220, 30, 30, 0.6));
  transition: opacity 0.4s;
}

.panel.wide { width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel h3 { margin: 18px 0 6px; font-size: 15px; }
button.small { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
.inv-layout { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; }
@media (max-width: 700px) { .inv-layout { grid-template-columns: 1fr; } }

#inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.inv-item {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 4px;
  font: inherit;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.inv-item:hover { border-color: var(--accent); }
.inv-item .swatch { width: 26px; height: 26px; border-radius: 4px; }
.inv-item .count { position: absolute; top: 3px; right: 5px; font-weight: 700; font-size: 11px; }
.empty-note { color: var(--muted); font-size: 13px; }

.recipe {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.recipe.off { opacity: 0.55; }
.recipe .out { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.recipe .out .swatch { width: 18px; height: 18px; border-radius: 3px; }
.recipe .needs { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.chip { padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, 0.07); }
.chip.miss { color: var(--danger); }
.recipe button { grid-row: 1 / span 2; grid-column: 2; padding: 7px 12px; font-size: 13px; }
#station-status { font-weight: 400; font-size: 12px; color: var(--muted); }
#station-status.on { color: var(--accent); }
