/* ============================================================
   Cubecraft — interfaz
   ============================================================ */

:root {
  --panel: rgba(14, 16, 20, 0.92);
  --panel-border: #2f3540;
  --slot: rgba(0, 0, 0, 0.45);
  --slot-border: #555b66;
  --accent: #6fbf4a;
  --text: #e8ecf1;
  --muted: #9aa4b2;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  --ui-scale: 1;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #ffe36e;
  outline-offset: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0c10;
  color: var(--text);
  font-family: var(--mono);
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ---------- superposiciones de pantalla ---------- */

/* Filtro azul al sumergirse: tinte + viñeta más cerrada + un leve
   desenfoque, que es lo que vende la sensación de estar bajo el agua. */
#water-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(24, 108, 178, 0.34) 0%, rgba(10, 58, 112, 0.58) 55%, rgba(3, 26, 62, 0.80) 100%);
  backdrop-filter: blur(1.2px) saturate(1.35) hue-rotate(-8deg);
  -webkit-backdrop-filter: blur(1.2px) saturate(1.35) hue-rotate(-8deg);
  opacity: 0;
  transition: opacity 0.28s ease;
}
#water-overlay.on { opacity: 1; animation: waterSway 7s ease-in-out infinite; }

@keyframes waterSway {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

#damage-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(150, 20, 20, 0.45));
  opacity: 0;
  transition: opacity 0.2s ease;
}
#damage-overlay.on { opacity: 1; }

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

/* ---------- punto de mira ---------- */

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
  mix-blend-mode: difference;
}
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
}
#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; }

/* ---------- depuración ---------- */

#debug {
  position: fixed;
  left: 10px;
  top: 10px;
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: #d8f0ff;
  background: rgba(0, 0, 0, 0.52);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  pointer-events: none;
  white-space: pre;
  text-shadow: 0 1px 2px #000;
}

#loading {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  padding: 8px 16px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 130px;
  transform: translateX(-50%) translateY(8px);
  padding: 8px 18px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- barra rápida ---------- */

/* Botones flotantes: menú (las tres rayas) e inventario. Duplican las
   teclas Esc y E para que el juego también se pueda manejar con ratón. */
#hud-buttons {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 12;
}
#hud-buttons button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(24, 28, 34, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(3px);
}
#hud-buttons button:hover {
  background: rgba(48, 56, 66, 0.9);
  border-color: var(--accent);
}
#hud-buttons svg { width: 20px; height: 20px; fill: #dfe6ee; }

/* Con el inventario o el menú abiertos se esconde el HUD del juego: la
   barra rápida ya sale dentro del inventario y verla dos veces confunde. */
body.overlay-open #hud-bottom,
body.overlay-open #crosshair,
body.overlay-open #hit-marker,
body.overlay-open #objective-tracker { display: none; }

/* ---------- barras de estado (supervivencia) ---------- */
#vitals {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.vbar {
  position: relative;
  width: 260px;
  height: 16px;
  background: rgba(12, 14, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.vbar i {
  display: block;
  height: 100%;
  width: 100%;
  transition: width 0.18s ease, background 0.3s ease;
}
.vbar.health i { background: linear-gradient(90deg, #C4342E, #E8564A); }
/* al bajar mucho, la barra avisa por color y por parpadeo */
.vbar.health.low i { background: linear-gradient(90deg, #8E1410, #C4342E); }
.vbar.health.low { animation: hurtPulse 0.9s ease-in-out infinite; }
@keyframes hurtPulse { 50% { border-color: #E8564A; } }
.vbar.health span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}
/* ---------- barra de hambre: diez muslitos ----------
   Se dibujan con SVG en línea, como los botones del HUD, para que no
   dependan del atlas ni de ninguna imagen externa. Cada muslito tiene
   tres estados: lleno, medio y vacío, porque el hambre baja de medio en
   medio. */
.hunger {
  display: flex;
  flex-direction: row-reverse;   /* se vacían de derecha a izquierda */
  gap: 2px;
  height: 18px;
}
.hunger .leg {
  position: relative;
  width: 17px;
  height: 17px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.75));
}
.hunger .leg svg { width: 100%; height: 100%; display: block; }
/* el fondo apagado siempre está; encima se recorta la parte llena */
.hunger .leg .bg { fill: #2A2420; opacity: 0.72; }
.hunger .leg .fg { fill: #C6712A; }
.hunger .leg .fg-bone { fill: #E8DCC6; }
.hunger .leg.empty .fg, .hunger .leg.empty .fg-bone { display: none; }
.hunger .leg.half .fill-clip { clip-path: inset(0 50% 0 0); }
/* con la barra a cero el jugador está perdiendo vida: que se note */
.hunger.starving .leg { animation: hungerPulse 0.8s ease-in-out infinite; }
@keyframes hungerPulse { 50% { transform: translateY(-2px); } }

/* ---------- barra de protección ----------
   Una sola barra horizontal sobre 80 en vez de la fila de iconos del
   original: se lee de un vistazo cuánto te queda de armadura y encaja
   con la barra de vida, que ya es una barra con su cifra dentro. El
   color va con el material que domina: cuero pardo, oro, hierro claro
   y diamante turquesa, que es lo que la hace informativa sin leer el
   número. */
.vbar.armor { width: 220px; height: 12px; }
.vbar.armor i { background: linear-gradient(90deg, #6E6E78, #A8AEBC); }
.vbar.armor.leather i { background: linear-gradient(90deg, #6B4522, #A9743F); }
.vbar.armor.gold i { background: linear-gradient(90deg, #A8800E, #F2CB4A); }
.vbar.armor.iron i { background: linear-gradient(90deg, #7C7C86, #DCDCE4); }
.vbar.armor.diamond i { background: linear-gradient(90deg, #1E8A85, #6FEFE7); }
/* con el juego completo la barra remata con un borde propio: es el
   tope del juego y merece notarse */
.vbar.armor.full { border-color: rgba(120, 240, 232, 0.85); }
.vbar.armor span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}
/* sin nada puesto la barra estorba: se queda tenue pero visible, que
   es lo que dice "aquí iría tu protección" */
.vbar.armor.empty { opacity: 0.45; }

/* ---------- huecos de armadura en el inventario ---------- */
.armor-row { display: flex; gap: 6px; }
.armor-piece { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.armor-piece .slot { width: 42px; height: 42px; }
/* el hueco vacío lleva la silueta de lo que admite, apagada */
.armor-piece .slot.empty-slot { border-style: dashed; border-color: #4a5462; }
.armor-piece .armor-label {
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.armor-piece .slot.armor-ok { border-color: var(--accent); }
#armor-total { color: var(--text); font-weight: 700; }

.vbar.air { width: 200px; height: 9px; }
.vbar.air i { background: linear-gradient(90deg, #2E7ED8, #6EC0F0); }
/* aguas profundas: la barra se vuelve fría y late, para que se note
   que el aire se está yendo más rápido de lo normal */
.vbar.air.deep i { background: linear-gradient(90deg, #123E86, #2E7ED8); }
.vbar.air.deep { animation: pressure 1.1s ease-in-out infinite; }
@keyframes pressure { 50% { box-shadow: 0 0 0 2px rgba(46, 126, 216, 0.45); } }

/* progreso de picado, justo bajo la mira */
#mine-progress {
  position: fixed;
  left: 50%;
  top: calc(50% + 16px);
  transform: translateX(-50%);
  width: 78px;
  height: 7px;
  background: rgba(10, 12, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  overflow: hidden;
  z-index: 6;
}
#mine-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #C8CDD4, #FFFFFF);
}
/* sin el nivel necesario el bloque se rompe pero no suelta nada */
#mine-progress.nodrop i { background: linear-gradient(90deg, #8A5A2A, #C4883E); }

/* elegir modo de juego */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  text-align: left;
  background: var(--slot);
  border: 1px solid #3a424e;
  border-radius: 8px;
  cursor: pointer;
}
.mode:hover { border-color: var(--accent); background: #2b313a; }
.mode.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode strong { font-size: 13px; color: #eaf1f8; }
.mode span { font-size: 11px; line-height: 1.45; color: var(--muted); }

#hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#block-name {
  font-size: 13px;
  color: #fff;
  text-shadow: 0 2px 4px #000;
  min-height: 18px;
  opacity: 0;
}
#block-name.fade { animation: fadeName 2.4s ease forwards; }
@keyframes fadeName {
  0% { opacity: 0; }
  10% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

#hotbar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.42);
  border: 2px solid rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  pointer-events: auto;
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  background: var(--slot);
  border: 2px solid #3a4049;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.1s ease, transform 0.1s ease;
}
.slot:hover { border-color: #6a7280; }
.slot.active {
  border-color: #ffffff;
  transform: translateY(-3px);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.slot .icon {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
  border-radius: 2px;
}
.slot .num {
  position: absolute;
  left: 3px;
  bottom: 1px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px #000;
}

/* ---------- paneles ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow: auto;
  z-index: 10;
}
.overlay.hidden, .hidden { display: none !important; }

.panel {
  width: min(560px, 100%);
  padding: 26px 30px 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.panel.wide { width: min(880px, 100%); }

.panel h1 {
  margin: 0 0 4px;
  font-size: 34px;
  letter-spacing: 0.06em;
  color: #fff;
}
.panel h2 { margin: 0 0 6px; font-size: 20px; }
.panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.panel .sub, .panel .hint, .panel .foot {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.panel .foot { margin: 18px 0 0; }

.row.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

button {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #232830;
  border: 1px solid #3a414d;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
button:hover { background: #2c323c; border-color: #4c5563; }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent);
  border-color: #7fd158;
  color: #0b1207;
  font-weight: 700;
  flex: 1 1 160px;
}
button.primary:hover { background: #7fd158; }
button.danger { color: #ffb4b4; border-color: #58353a; }
button.danger:hover { background: #3a2428; }

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 26px;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--muted);
}
label span {
  float: right;
  color: var(--text);
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
}
input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 7px;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

ul.keys {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  line-height: 2.05;
  color: var(--muted);
}
ul.keys li { display: flex; align-items: baseline; gap: 5px; }
ul.keys span { margin-left: auto; color: var(--text); text-align: right; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
  text-align: center;
  color: #dfe6ee;
  background: #1c2027;
  border: 1px solid #3d444f;
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ---------- inventario ---------- */

/* Disposición de dos paneles, al estilo del inventario de Bedrock:
   a la izquierda lo tuyo, a la derecha el catálogo completo. */
.inv-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(1040px, 100%);
  max-height: calc(100vh - 24px);
}
.inv-panels {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 0;
}
/* En supervivencia no hay paleta creativa: se oculta el panel derecho
   y el izquierdo se queda con todo el ancho. */
.inv-panels.no-palette {
  grid-template-columns: minmax(0, max-content);
  justify-content: center;
}
.inv-panels.no-palette > .bpanel:last-child { display: none; }
/* el catálogo necesita ancho aunque el panel se encoja */
.inv-panels.no-palette .slot-grid.recipes { min-width: 430px; }

.bpanel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* pestañas que sobresalen por encima del panel */
.tabs { display: flex; gap: 3px; padding-left: 6px; }
#cat-tabs { flex-wrap: wrap; }
.tabs .tab {
  padding: 7px 13px 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #262c35;
  border: 1px solid #39414d;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  line-height: 1;
}
.tabs .tab:hover { color: #d7dee8; background: #2e353f; }
.tabs .tab.active {
  color: #eaf1f8;
  background: #333b46;
  border-color: #4a5462;
  box-shadow: inset 0 2px 0 var(--accent);
}
/* pestañas de categoría: sólo icono de bloque */
.tabs .tab.icon-tab { padding: 5px 9px; }
.tabs .tab.icon-tab .icon {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  border-radius: 2px;
  display: block;
}

.bbody {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #333b46;
  border: 1px solid #4a5462;
  border-radius: 0 9px 9px 9px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.bbody .close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.bbody .close:hover { color: #fff; }

.pane { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.pane.hidden { display: none; }

.craft-box {
  padding: 8px 10px 10px;
  background: rgba(20, 24, 30, 0.45);
  border: 1px solid #454e5b;
  border-radius: 6px;
  width: max-content;
}
.craft-row { display: flex; align-items: center; gap: 12px; }
.craft-arrow { font-size: 20px; color: var(--muted); }

/* --- horno --- */
.furnace-row { align-items: center; }
.furnace-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }

/* llama: se vacía de arriba abajo según el combustible que queda */
.flame {
  width: 20px; height: 20px;
  background: #22272e;
  border: 1px solid #454e5b;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.flame-fill {
  width: 100%; height: 0%;
  background: linear-gradient(to top, #F7C33F, #E2731A);
  transition: height 0.12s linear;
}

/* barra de cocción */
.cook {
  width: 62px; height: 12px;
  background: #22272e;
  border: 1px solid #454e5b;
  border-radius: 3px;
  overflow: hidden;
}
.cook-fill {
  height: 100%; width: 0%;
  background: linear-gradient(to right, #6E9E45, #A8D66A);
  transition: width 0.12s linear;
}

#smelt-list {
  margin: 0; padding: 0; list-style: none;
  max-height: 250px; overflow-y: auto;
  font-size: 11.5px; line-height: 1.72; color: var(--muted);
}
#smelt-list li { border-bottom: 1px solid #2b323b; padding-right: 6px; }
#smelt-list li:last-child { border-bottom: 0; }

/* etiqueta del contenido de un recipiente, dentro del hueco */
.slot .fluid {
  position: absolute;
  left: 2px; right: 2px; bottom: 1px;
  height: 4px;
  border-radius: 2px;
  background: #2E62C8;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
.slot .fluid.lava { background: #E2731A; }
.slot .fluid > i { display: block; height: 100%; border-radius: 2px; background: rgba(255,255,255,0.55); }

/* desgaste de una herramienta: sólo se pinta cuando ya se ha usado */
.slot .wear {
  position: absolute;
  left: 3px; right: 3px; bottom: 2px;
  height: 3px;
  background: #1a1a1a;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}
.slot .wear > i { display: block; height: 100%; }

/* rótulos pequeños encima de cada rejilla */
.cap {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.cap.centered { text-align: center; margin-bottom: 0; }

.bfoot { display: flex; align-items: center; gap: 10px; }
#btn-craft-clear, #btn-inv-sort { padding: 6px 12px; font-size: 11.5px; }
.extra-slots { display: flex; align-items: end; gap: 9px; }
.extra-slots .cap { margin-bottom: 3px; }
.slot.trash {
  width: 34px;
  height: 34px;
  border-color: #6a4444;
  background: rgba(90, 40, 40, 0.35);
  cursor: pointer;
}
.slot.trash:hover { border-color: #c86a6a; background: rgba(130, 50, 50, 0.5); }
.slot.trash svg { width: 17px; height: 17px; fill: #d59a9a; }

/* barra de categoría del panel derecho */
.cat-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: #232931;
  border: 1px solid #454e5b;
  border-radius: 6px;
}
#cat-name { flex: 1; font-size: 12.5px; font-weight: 700; color: #e6edf5; }
#inv-search {
  width: 150px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11.5px;
  color: #e6edf5;
  background: #171b21;
  border: 1px solid #454e5b;
  border-radius: 4px;
}
#inv-search:focus { outline: 0; border-color: var(--accent); }

/* --- catálogo de recetas --- */
.recipe-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.only-doable { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }

.slot-grid.recipes {
  grid-template-columns: repeat(auto-fill, 42px);
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  align-content: start;
  padding-right: 4px;
}
/* Lo que no puedes fabricar se marca en rojo y apagado, en vez de
   esconderlo: así ves qué te falta por conseguir. */
.slot-grid.recipes .slot.locked {
  border-color: #7A3A3A;
  background: rgba(90, 34, 34, 0.28);
}
.slot-grid.recipes .slot.locked .icon { filter: grayscale(0.7) brightness(0.62); }
.slot-grid.recipes .slot.locked .count { color: #F09090; }
.slot-grid.recipes .slot.chosen { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slot-grid.recipes:empty::after {
  content: 'Todavía no puedes fabricar nada';
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- herramientas agrupadas ----------
   Un hueco por tipo con un «+» en la esquina. El signo se ve encima
   del icono, así que lleva su propia sombra para leerse igual sobre un
   pico claro que sobre uno oscuro. */
.slot.tool-group { border-color: #5d6b52; background: rgba(60, 90, 45, 0.22); }
.slot.armor-group { border-color: #59667d; background: rgba(65, 78, 110, 0.25); }
.slot.tool-group:hover, .slot.armor-group:hover { border-color: var(--accent); }
.slot.tool-group.open, .slot.armor-group.open {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.slot.tool-group .plus, .slot.armor-group .plus {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: #eaf1f8;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
}
/* las variantes desplegadas van marcadas para que se vea que son las
   de ese «+» y no huecos sueltos del catálogo */
.slot-grid .slot[data-tool-kind] { border-color: #4f5a46; }
.slot-grid .slot[data-armor-slot] { border-color: #515e78; }

/* ficha de la receta montada */
.craft-info { display: flex; flex-direction: column; gap: 3px; max-width: 190px; }
.craft-info strong { font-size: 12px; color: #eaf1f8; text-transform: uppercase; letter-spacing: 0.04em; }
.craft-info span { font-size: 11px; line-height: 1.45; color: var(--muted); }

.craft-needs { margin-top: 10px; }
.craft-needs > div { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.need {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.need .icon { width: 22px; height: 22px; image-rendering: pixelated; border-radius: 2px; }
.need b { color: #dfe6ee; font-weight: 600; }
/* en rojo lo que no tienes suficiente */
.need.short b, .need.short { color: #F09090; }

.hotbar-row { justify-content: center; }
.inv-help { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.bbody .hint.tight { margin: 0; font-size: 11px; }

/* rejillas de huecos */
.slot-grid { display: grid; gap: 3px; width: max-content; }
.slot-grid.c1 { grid-template-columns: repeat(1, 42px); }
.slot-grid.c2 { grid-template-columns: repeat(2, 42px); }
.slot-grid.c3 { grid-template-columns: repeat(3, 42px); }
.slot-grid.c9 { grid-template-columns: repeat(9, 42px); }
.slot-grid.palette {
  grid-template-columns: repeat(auto-fill, 42px);
  width: 100%;
  flex: 1;
  min-height: 132px;
  align-content: start;
  overflow-y: auto;
  padding-right: 4px;
}
.slot-grid.palette:empty::after {
  content: 'Sin resultados';
  color: var(--muted);
  font-size: 11.5px;
}

.slot-grid .slot { width: 42px; height: 42px; }
.slot-grid .slot .icon { width: 31px; height: 31px; }
.slot-grid .slot.result {
  border-color: #5d6b52;
  background: rgba(60, 90, 45, 0.28);
}
.slot-grid .slot.result:hover { border-color: var(--accent); }

/* contador de la pila */
.slot .count {
  position: absolute;
  right: 3px;
  top: 1px;
  min-width: 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
}

/* pila enganchada al puntero */
#cursor-stack {
  position: fixed;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  pointer-events: none;
  z-index: 40;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}
#cursor-stack .icon {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  border-radius: 3px;
}
#cursor-stack .count {
  position: absolute;
  right: -2px;
  bottom: -4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}

/* ---------- error fatal ---------- */

#fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  font-size: 15px;
  color: #ffb4b4;
  background: #0a0c10;
  z-index: 100;
}

/* ============================================================
   Menú principal estilo voxel
   ============================================================ */
.main-menu-overlay {
  z-index: 30;
  padding: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.16);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  align-items: center;
  justify-items: center;
}

.menu-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(30,66,108,.58), rgba(79,129,153,.22) 44%, rgba(11,17,23,.55) 100%);
}
.menu-sky::before {
  content: '';
  position: absolute;
  inset: -12%;
  background:
    radial-gradient(circle at 72% 22%, rgba(255,245,194,.92) 0 3%, rgba(255,226,143,.28) 7%, transparent 17%),
    linear-gradient(180deg, rgba(118,181,219,.28), rgba(35,69,92,.08) 55%, rgba(8,11,14,.58));
  animation: menuSkyDrift 18s ease-in-out infinite alternate;
}
.menu-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 18%, rgba(0,0,0,.18) 58%, rgba(0,0,0,.74) 100%);
}
.menu-glow {
  position: absolute;
  width: 34vmax;
  height: 34vmax;
  right: 10vw;
  top: 8vh;
  border-radius: 50%;
  background: rgba(255, 221, 131, .10);
  filter: blur(24px);
  animation: menuGlow 6s ease-in-out infinite alternate;
}
.menu-clouds {
  position: absolute;
  width: 54vw;
  height: 11vh;
  min-height: 60px;
  left: -8vw;
  opacity: .16;
  filter: blur(7px);
  background:
    radial-gradient(ellipse at 15% 45%, rgba(255,255,255,.95) 0 8%, transparent 9%),
    radial-gradient(ellipse at 33% 55%, rgba(255,255,255,.9) 0 11%, transparent 12%),
    radial-gradient(ellipse at 54% 35%, rgba(255,255,255,.85) 0 9%, transparent 10%),
    radial-gradient(ellipse at 75% 54%, rgba(255,255,255,.9) 0 12%, transparent 13%);
  animation: menuCloudMove 32s linear infinite;
}
.cloud-a { top: 15%; }
.cloud-b { top: 28%; left: 42vw; opacity: .11; animation-duration: 46s; animation-direction: reverse; }

.mc-menu {
  position: relative;
  z-index: 2;
  width: min(560px, 92vw);
  margin-top: -4vh;
  text-align: center;
}
.menu-title-wrap { margin-bottom: 28px; }
.menu-logo-shadow,
.menu-logo {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-weight: 900;
  font-size: clamp(42px, 8vw, 86px);
  line-height: .84;
  letter-spacing: .055em;
  transform: skewX(-2deg);
}
.menu-logo-shadow {
  position: absolute;
  width: 100%;
  color: rgba(0,0,0,.76);
  transform: translate(7px, 9px) skewX(-2deg);
}
.menu-logo {
  position: relative;
  color: #f5f5f5;
  text-shadow:
    0 2px 0 #7f8790,
    0 4px 0 #464c51,
    0 7px 12px rgba(0,0,0,.8);
  -webkit-text-stroke: 1px rgba(255,255,255,.15);
}
.menu-subtitle {
  margin-top: 11px;
  font: 700 11px/1 var(--mono);
  letter-spacing: .24em;
  color: rgba(255,255,255,.84);
  text-shadow: 0 2px 4px rgba(0,0,0,.7);
}

.menu-main-buttons {
  display: grid;
  gap: 10px;
  width: min(420px, 82vw);
  margin: 0 auto;
}
.mc-button {
  position: relative;
  min-height: 52px;
  padding: 0 20px;
  border: 2px solid rgba(255,255,255,.24);
  border-top-color: rgba(255,255,255,.38);
  border-left-color: rgba(255,255,255,.32);
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(#5b6167, #444a4f 48%, #363b40);
  box-shadow: 0 4px 0 rgba(0,0,0,.45), 0 9px 20px rgba(0,0,0,.24);
  font: 800 17px/1 var(--mono);
  letter-spacing: .04em;
  text-shadow: 0 2px 2px rgba(0,0,0,.8);
}
.mc-button:hover {
  background: linear-gradient(#777d82, #595f64 48%, #484e53);
  border-color: rgba(255,255,255,.52);
  transform: scale(1.015);
}
.mc-button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.45); }
.mc-button-primary {
  background: linear-gradient(#83c94f, #67ad3d 48%, #4e8e31);
  border-color: #b6ed88;
  color: #fff;
  text-shadow: 0 2px 2px rgba(23,50,12,.75);
}
.mc-button-primary:hover { background: linear-gradient(#98d85f, #72be47 48%, #5ca63a); }

.menu-status {
  margin: 15px 0 8px;
  color: rgba(255,255,255,.72);
  font-size: 11px;
  text-shadow: 0 2px 4px #000;
}
.menu-separator { margin: 0 7px; opacity: .55; }
.menu-extra-buttons {
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}
.mc-small-button {
  padding: 7px 10px;
  background: rgba(16,19,22,.60);
  border: 1px solid rgba(255,255,255,.23);
  color: rgba(255,255,255,.86);
  border-radius: 2px;
  font: 700 10px/1 var(--mono);
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 2px 7px rgba(0,0,0,.28);
}
.mc-small-button:hover { background: rgba(51,56,60,.82); border-color: rgba(255,255,255,.42); }

.menu-details {
  width: min(560px, 92vw);
  margin: 12px auto 0;
  padding: 14px 16px 16px;
  background: rgba(8,11,14,.87);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  box-shadow: 0 16px 40px rgba(0,0,0,.40);
  text-align: left;
}
.menu-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #fff;
}
.menu-details-head strong { font-size: 13px; letter-spacing: .10em; text-transform: uppercase; }
.mc-close { padding: 2px 8px; font-size: 18px; background: transparent; border: 0; color: #fff; }
.menu-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.settings-action { grid-column: 1 / -1; margin-top: 4px; }

.menu-options-grid label { margin-bottom: 8px; }
.menu-options-grid label.check { margin: 3px 0; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.controls-grid > div { display: flex; align-items: center; gap: 6px; min-height: 26px; color: var(--muted); font-size: 11px; }
.controls-grid span { margin-left: auto; color: var(--text); text-align: right; }
.menu-footer {
  margin-top: 15px;
  color: rgba(255,255,255,.58);
  font-size: 10px;
  text-shadow: 0 2px 4px #000;
}

@keyframes menuSkyDrift {
  from { transform: translate3d(-1.5%, 0, 0) scale(1.03); }
  to { transform: translate3d(1.5%, -1%, 0) scale(1.06); }
}
@keyframes menuGlow {
  from { opacity: .55; transform: scale(.96); }
  to { opacity: 1; transform: scale(1.05); }
}
@keyframes menuCloudMove {
  from { transform: translateX(-12vw); }
  to { transform: translateX(118vw); }
}

@media (max-width: 620px) {
  .mc-menu { margin-top: -1vh; }
  .menu-title-wrap { margin-bottom: 19px; }
  .menu-logo { font-size: 48px; }
  .menu-main-buttons { gap: 8px; }
  .mc-button { min-height: 47px; font-size: 15px; }
  .menu-options-grid, .controls-grid { grid-template-columns: 1fr; }
}

.world-list { display:grid; gap:7px; max-height:35vh; overflow:auto; margin-bottom:12px; }
.world-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px; background:rgba(26,30,34,.88); border:1px solid rgba(255,255,255,.12); border-radius:3px; }
.world-row.active { border-color:rgba(142,214,91,.7); box-shadow:inset 3px 0 #80c84d; }
.world-row-main { min-width:0; display:grid; gap:4px; }
.world-row-main strong { color:#fff; font-size:12px; }
.world-row-main span { color:var(--muted); font-size:10px; }
.world-row-actions { display:flex; gap:5px; flex-wrap:wrap; justify-content:flex-end; }
.world-delete { color:#ffb0b0; }
.world-new-btn { width:100%; margin-top:2px; }
.world-empty { padding:20px; text-align:center; color:var(--muted); font-size:11px; }
.world-create-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.world-create-grid label { display:grid; gap:5px; color:var(--muted); font-size:10px; font-weight:700; text-transform:uppercase; }
.world-create-grid input { width:100%; box-sizing:border-box; padding:9px; background:#14181c; color:#fff; border:1px solid #4b5259; border-radius:2px; font:700 11px var(--mono); }
.mode-choice-title { margin:14px 0 7px; color:#fff; font:800 11px var(--mono); text-transform:uppercase; }
.world-mode-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.mode-choice { min-height:74px; display:grid; gap:5px; text-align:left; }
.mode-choice strong { font-size:12px; }
.mode-choice span { color:rgba(255,255,255,.65); font:600 10px var(--mono); line-height:1.35; }
.mode-choice.active { outline:2px solid #9add69; background:linear-gradient(#668b4f,#465e38); }
.world-check { display:flex; align-items:center; gap:6px; margin:10px 0 !important; color:rgba(255,255,255,.8) !important; font:700 10px var(--mono) !important; }
.achievement-list { display:grid; gap:7px; max-height:38vh; overflow:auto; }
.achievement-row { display:flex; gap:10px; align-items:center; padding:9px; background:rgba(24,28,32,.8); border:1px solid rgba(255,255,255,.1); border-radius:3px; opacity:.55; }
.achievement-row.unlocked { opacity:1; border-color:rgba(255,215,106,.55); background:rgba(74,61,28,.34); }
.achievement-badge { width:30px; height:30px; display:grid; place-items:center; flex:0 0 30px; border-radius:3px; background:#343a40; color:#777; font-size:15px; box-shadow:inset 0 0 0 1px rgba(255,255,255,.08); }
.achievement-row.unlocked .achievement-badge { background:#a58130; color:#ffe57c; }
.achievement-row strong { display:block; color:#fff; font-size:11px; }
.achievement-row span { display:block; margin-top:3px; color:var(--muted); font-size:9px; }
@media (max-width:620px){ .world-create-grid,.world-mode-grid{grid-template-columns:1fr;} .world-row{align-items:flex-start; flex-direction:column;} .world-row-actions{width:100%; justify-content:flex-start;} }

.world-note{margin:10px 0 12px;padding:8px;background:rgba(255,255,255,.05);border-left:2px solid rgba(255,255,255,.2);color:var(--muted);font:600 9px/1.4 var(--mono);}

/* ============================================================
   Guía, objetivos, combate y accesibilidad
   ============================================================ */
#hit-marker {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  z-index: 13;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.7);
}
#hit-marker::before,
#hit-marker::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 13px;
  width: 22px;
  height: 2px;
  background: #fff;
  box-shadow: 0 1px 2px #000;
}
#hit-marker::before { transform: rotate(45deg); }
#hit-marker::after { transform: rotate(-45deg); }
#hit-marker.show { animation: hitMarker .24s ease-out; }
#hit-marker.kill::before,
#hit-marker.kill::after { background: #ffcf48; height: 3px; }

#objective-tracker {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 11;
  max-width: min(660px, 80vw);
  padding: calc(7px * var(--ui-scale)) calc(11px * var(--ui-scale));
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 3px;
  background: rgba(8,11,14,.68);
  color: #f4f7fa;
  font: 700 calc(10px * var(--ui-scale))/1.35 var(--mono);
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#objective-tracker strong { color: #ffe277; }

.tutorial-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font: 600 calc(10px * var(--ui-scale))/1.45 var(--mono);
}
.tutorial-list { display: grid; gap: 7px; max-height: 40vh; overflow: auto; }
.tutorial-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 3px;
  background: rgba(24,28,32,.78);
  opacity: .62;
}
.tutorial-step.current { opacity: 1; border-color: #8ac95d; box-shadow: inset 3px 0 #75b94a; }
.tutorial-step.done { opacity: .82; border-color: rgba(135,211,91,.42); }
.tutorial-step-mark {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; background: #343a40; color: #cbd2d9;
  font: 800 11px var(--mono);
}
.tutorial-step.done .tutorial-step-mark { background: #568b38; color: #fff; }
.tutorial-step strong { display:block; color:#fff; font-size:11px; }
.tutorial-step span { display:block; margin-top:3px; color:var(--muted); font-size:9px; line-height:1.35; }
.tutorial-actions { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-top:12px; }
.tutorial-actions .mc-button { min-height: 38px; font-size: 12px; }

.menu-options-grid select {
  width: 100%;
  margin-top: 5px;
  padding: 7px;
  border: 1px solid #555d66;
  border-radius: 2px;
  background: #14181c;
  color: #fff;
  font: 700 11px var(--mono);
}
.graphics-presets {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 0;
  color: var(--muted);
  font: 700 10px var(--mono);
}
.graphics-presets span { margin-right: auto; }
.graphics-presets .active { border-color:#a8df78; color:#dfffbd; background:#365428; }

/* La escala se concentra en texto y controles; el lienzo 3D conserva
   sus coordenadas exactas y el ratón no se desajusta. */
.mc-button {
  min-height: calc(50px * var(--ui-scale));
  font-size: calc(16px * var(--ui-scale));
}
.mc-small-button { font-size: calc(10px * var(--ui-scale)); }
.menu-details,
.menu-status,
.menu-footer,
#toast { font-size: calc(11px * var(--ui-scale)); }

@keyframes hitMarker {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.16); }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================
   BOSERHAFT — interfaz de acceso. Todo queda aislado dentro de
   #menu para no recolorear el HUD ni el inventario del juego.
   ============================================================ */
#menu {
  --access-cyan: #48baff;
  --access-blue: #1169c7;
  --access-ice: #b9e8ff;
  --access-panel: rgba(5, 15, 29, .90);
  --access-line: rgba(119, 190, 239, .28);
  font-family: "Segoe UI", "Arial Narrow", var(--mono);
}
#menu.main-menu-overlay {
  padding: 18px 24px 22px;
  overflow: hidden;
  background: rgba(1, 7, 15, .28);
}
#menu .menu-sky {
  background:
    linear-gradient(180deg, rgba(3, 16, 33, .40), rgba(4, 22, 43, .32) 45%, rgba(1, 8, 17, .88)),
    radial-gradient(circle at 76% 22%, rgba(129, 205, 255, .18), transparent 28%);
  filter: saturate(.88) contrast(1.08);
}
#menu .menu-sky::before {
  background:
    radial-gradient(circle at 78% 19%, rgba(222, 245, 255, .85) 0 1.8%, rgba(69, 174, 255, .18) 6%, transparent 17%),
    linear-gradient(180deg, rgba(3, 24, 48, .18), rgba(1, 8, 17, .74));
}
#menu .menu-glow { right: 14vw; top: 5vh; background: rgba(52, 166, 255, .13); }
#menu .menu-vignette {
  background:
    linear-gradient(90deg, rgba(0, 5, 12, .74), transparent 23%, transparent 72%, rgba(0, 5, 12, .62)),
    radial-gradient(ellipse at center, transparent 20%, rgba(0, 4, 11, .30) 62%, rgba(0, 3, 8, .86) 100%);
}
.menu-horizon {
  position: absolute;
  left: -3%; right: -3%; bottom: -3%;
  height: 34%;
  opacity: .38;
  background:
    linear-gradient(90deg, rgba(3, 18, 32, .92), rgba(8, 38, 65, .82) 50%, rgba(2, 15, 28, .94)),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(65, 163, 218, .20) 43px 44px);
  clip-path: polygon(0 58%,5% 58%,5% 42%,9% 42%,9% 63%,14% 63%,14% 34%,17% 34%,17% 55%,23% 55%,23% 72%,29% 72%,29% 49%,33% 49%,33% 60%,39% 60%,39% 27%,42% 27%,42% 51%,47% 51%,47% 67%,52% 67%,52% 38%,56% 38%,56% 59%,62% 59%,62% 46%,67% 46%,67% 71%,72% 71%,72% 30%,77% 30%,77% 53%,82% 53%,82% 39%,87% 39%,87% 65%,93% 65%,93% 48%,100% 48%,100% 100%,0 100%);
  filter: drop-shadow(0 -12px 30px rgba(41, 160, 231, .18));
}
#menu .mc-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 36px);
  margin: 0;
  text-align: center;
}
#menu .menu-title-wrap { width: 100%; margin: 0 0 clamp(18px, 3vh, 32px); }
#menu .menu-logo-shadow,
#menu .menu-logo {
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-size: clamp(58px, 8.5vw, 112px);
  letter-spacing: .045em;
  line-height: .82;
}
#menu .menu-logo-shadow {
  color: rgba(0, 0, 0, .78);
  transform: translate(8px, 10px) skewX(-2deg);
}
#menu .menu-logo {
  color: #cdd8e2;
  background: linear-gradient(180deg,#f7fbff 0%,#aab9c7 24%,#e4edf3 45%,#718497 47%,#c7d2da 72%,#657789 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1px rgba(230, 247, 255, .48);
  filter: drop-shadow(0 3px 0 #34485a) drop-shadow(0 8px 12px rgba(0, 0, 0, .82));
  text-shadow: none;
}
#menu .menu-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 15px;
  color: #eef9ff;
  font: 800 clamp(10px, 1.15vw, 14px)/1 var(--mono);
  letter-spacing: .30em;
}
#menu .menu-subtitle i {
  width: 5px; height: 5px;
  background: var(--access-cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 10px var(--access-cyan);
}
.access-stage {
  display: grid;
  grid-template-columns: minmax(430px, 610px) 288px;
  align-items: stretch;
  justify-content: center;
  gap: clamp(24px, 5vw, 64px);
  width: 100%;
}
#menu .menu-main-buttons { display: grid; align-content: center; gap: 10px; width: 100%; margin: 0; }
#menu .mc-button {
  position: relative;
  min-height: 61px;
  padding: 0 58px 0 76px;
  overflow: hidden;
  border: 1px solid rgba(150, 192, 221, .30);
  border-radius: 4px;
  color: #e9f5ff;
  background: linear-gradient(90deg,rgba(25,43,61,.96),rgba(6,17,31,.94) 68%,rgba(12,29,49,.96));
  box-shadow: inset 0 1px rgba(255,255,255,.08),inset 0 -1px rgba(0,0,0,.78),0 5px 0 rgba(0,0,0,.35),0 12px 26px rgba(0,0,0,.28);
  font: 750 clamp(16px, 1.75vw, 22px)/1 "Arial Narrow", "Segoe UI", sans-serif;
  letter-spacing: .09em;
  text-align: left;
  text-shadow: 0 2px 3px #000;
  transform: none;
}
#menu .mc-button::before {
  content: attr(data-icon);
  position: absolute;
  left: 13px; top: 9px;
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border: 1px solid rgba(151, 208, 247, .30);
  color: #c9eaff;
  background: rgba(4, 16, 29, .68);
  box-shadow: inset 0 0 15px rgba(66, 175, 255, .08);
  font: 700 18px/1 var(--mono);
}
#menu .mc-button::after {
  content: '›';
  position: absolute;
  right: 19px; top: 50%;
  color: #cfeeff;
  font: 300 38px/1 sans-serif;
  transform: translateY(-54%);
}
#menu .mc-button:hover {
  border-color: rgba(105, 197, 255, .72);
  background: linear-gradient(90deg,rgba(24,73,116,.98),rgba(7,30,55,.97) 72%,rgba(12,50,83,.96));
  box-shadow: inset 3px 0 var(--access-cyan),0 0 24px rgba(40,154,240,.18),0 5px 0 rgba(0,0,0,.35);
  transform: translateX(3px);
}
#menu .mc-button:active { transform: translate(3px, 2px); }
#menu .mc-button-primary {
  border-color: rgba(109, 203, 255, .88);
  color: #fff;
  background: linear-gradient(90deg,rgba(20,105,188,.98),rgba(11,69,137,.98) 58%,rgba(8,45,92,.98));
  box-shadow: inset 0 1px rgba(229,249,255,.40),inset 4px 0 #67ceff,0 0 0 2px rgba(17,98,179,.38),0 0 28px rgba(31,151,255,.30),0 5px 0 rgba(0,0,0,.38);
}
#menu .mc-button-primary:hover { background: linear-gradient(90deg,#1983df,#0f5db3 62%,#0a458d); }

.access-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 344px;
  padding: 15px 17px 16px;
  border: 1px solid var(--access-line);
  border-radius: 5px;
  background: linear-gradient(180deg,rgba(15,31,48,.94),rgba(3,12,23,.94));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.025),0 16px 42px rgba(0,0,0,.38);
}
.profile-heading { display: flex; align-items: center; gap: 9px; width: 100%; color: #ddecf8; font: 800 13px/1 var(--mono); letter-spacing: .12em; }
.profile-heading span { flex: 1; height: 1px; background: linear-gradient(90deg,transparent,var(--access-line)); }
.profile-heading span:last-child { background: linear-gradient(90deg,var(--access-line),transparent); }
.voxel-avatar {
  position: relative;
  width: 112px; height: 112px;
  margin: 16px 0 10px;
  overflow: hidden;
  border: 3px solid #20364b;
  border-radius: 50%;
  background: radial-gradient(circle,#264d6b,#071321 70%);
  box-shadow: 0 0 0 1px #607b91,0 0 24px rgba(55,171,246,.20);
  cursor: pointer;
}
.voxel-avatar span { position: absolute; display: block; image-rendering: pixelated; }
.avatar-face { left: 30px; top: 29px; width: 53px; height: 50px; background: #c88a58; box-shadow: inset 7px -7px #a96843; }
.avatar-hair { z-index: 2; left: 27px; top: 22px; width: 58px; height: 25px; background: #5a321c; box-shadow: 9px 9px #6b3b21,-4px 14px #422514; }
.avatar-eye { z-index: 3; top: 52px; width: 7px; height: 7px; background: #75d5ff; box-shadow: inset 3px 0 #effbff; }
.avatar-eye.eye-left { left: 42px; }
.avatar-eye.eye-right { right: 38px; }
.avatar-body { left: 23px; bottom: -19px; width: 68px; height: 52px; background: #126e9e; box-shadow: inset 11px 0 #0d4d75,inset -11px 0 #0a3859; }
.profile-name { color: #fff; font: 800 19px/1 "Arial Narrow",sans-serif; letter-spacing: .08em; }
.profile-online { margin-top: 6px; color: #9eb2c3; font-size: 11px; }
.profile-online i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--access-cyan); box-shadow: 0 0 8px var(--access-cyan); }
.profile-stats { width: 100%; margin: 13px 0 9px; border-top: 1px solid var(--access-line); border-bottom: 1px solid var(--access-line); }
.profile-stats div { display: flex; justify-content: space-between; padding: 8px 3px; color: #9db0c1; font-size: 11px; }
.profile-stats div + div { border-top: 1px solid rgba(119,190,239,.12); }
.profile-stats strong { color: #fff; }
.access-profile p { margin: 0 0 11px; color: #8195a7; font-size: 9px; line-height: 1.45; }
.profile-login { width: 100%; padding: 10px; border: 1px solid #43a9ed; color: #eefaff; background: linear-gradient(#1679c8,#0d5198); font: 800 10px/1 var(--mono); letter-spacing: .05em; }

#menu .menu-status {
  margin: 12px 0 8px;
  padding: 6px 13px;
  border: 1px solid rgba(114,180,224,.18);
  border-radius: 999px;
  color: rgba(214,237,251,.76);
  background: rgba(2,10,19,.58);
  font: 600 10px/1 var(--mono);
}
#menu .menu-extra-buttons {
  display: flex;
  justify-content: center;
  gap: 6px;
  max-width: 940px;
  padding: 7px;
  border: 1px solid rgba(119,190,239,.14);
  border-radius: 4px;
  background: rgba(3,12,23,.58);
  backdrop-filter: blur(5px);
}
#menu .mc-small-button { padding: 8px 10px; border: 1px solid rgba(117,176,215,.28); border-radius: 3px; color: #b9cada; background: rgba(7,22,38,.88); font: 700 9px/1 var(--mono); }
#menu .mc-small-button:hover,
#menu .mc-small-button.active { border-color: rgba(74,186,255,.70); color: #fff; background: rgba(13,74,124,.92); }
#menu .mode-button.active { outline: 1px solid var(--access-cyan); }
.access-version {
  position: fixed;
  left: 22px; bottom: 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid rgba(118,187,233,.30);
  color: #9eb5c7;
  background: rgba(2,10,19,.78);
  box-shadow: inset 0 0 18px rgba(33,135,213,.08);
  font: 650 9px/1 var(--mono);
}
.access-version strong { color: #e7f7ff; }
.version-cube { color: var(--access-cyan); font-size: 18px; text-shadow: 0 0 10px var(--access-cyan); }
#menu .menu-footer { position: fixed; right: 22px; bottom: 21px; margin: 0; color: rgba(175,204,223,.62); font: 600 9px/1 var(--mono); letter-spacing: .05em; }

#menu .menu-details {
  position: fixed;
  z-index: 10;
  left: 50%; top: 50%;
  width: min(900px, calc(100vw - 44px));
  max-height: min(700px, calc(100vh - 44px));
  margin: 0;
  padding: 18px 20px 20px;
  overflow: auto;
  border: 1px solid rgba(112,190,241,.34);
  border-radius: 5px;
  background: linear-gradient(180deg,rgba(10,28,48,.97),rgba(2,10,20,.98));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.025),0 24px 80px rgba(0,0,0,.72);
  transform: translate(-50%,-50%);
  text-align: left;
}
#menu .menu-details-head { padding-bottom: 12px; border-bottom: 1px solid var(--access-line); }
#menu .menu-details-head strong { color: #eef9ff; font-size: 15px; }
#menu .mc-close { color: #a9c8dc; cursor: pointer; }
#menu .mc-close:hover { color: #fff; background: rgba(42,143,208,.22); }
#menu .world-row { padding: 11px 12px; border-color: rgba(115,179,221,.18); background: linear-gradient(90deg,rgba(14,37,61,.88),rgba(5,17,31,.90)); }
#menu .world-row.active { border-color: rgba(71,185,255,.70); box-shadow: inset 3px 0 var(--access-cyan); }
#menu .world-row-main strong { color: #eff9ff; }
#menu .world-create-grid input,
#menu .access-code-input,
#menu select { border-color: rgba(104,173,219,.35); color: #eef9ff; background: #061321; }
#menu .mode-choice.active { outline-color: var(--access-cyan); background: linear-gradient(#185c91,#103d66); }

.access-panel-intro { margin: -2px 0 15px; color: #8ca5b8; font-size: 11px; line-height: 1.5; }
.multiplayer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.access-card { display: flex; flex-direction: column; gap: 10px; min-height: 255px; padding: 17px; border: 1px solid rgba(105,179,226,.24); background: rgba(4,17,30,.72); }
.access-card p { min-height: 34px; margin: 0; color: #8ca3b5; font-size: 10px; line-height: 1.55; }
.access-card .mc-button { width: 100%; min-height: 48px; margin-top: auto; padding-left: 16px; text-align: center; font-size: 13px; }
#menu .access-card .mc-button::before,
#menu .access-card .mc-button::after { display: none; }
.access-code-input { width: 100%; padding: 13px; border: 1px solid; font: 800 17px/1 var(--mono); letter-spacing: .12em; text-align: center; }
.code-status { color: #8498a9; font-size: 10px; }
.code-status.success { color: #66dcba; }
.code-status.error { color: #ff8b91; }
.generated-code { display: grid; place-items: center; flex: 1; min-height: 70px; border: 1px dashed rgba(76,185,255,.42); color: var(--access-ice); background: rgba(9,47,79,.34); font: 800 20px/1 var(--mono); letter-spacing: .10em; }
.local-profile-summary { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid rgba(106,178,225,.20); background: rgba(4,17,30,.65); }
.profile-emblem { display: grid; place-items: center; width: 66px; height: 66px; border: 1px solid #4f9ed0; color: #eaf8ff; background: linear-gradient(135deg,#1578bd,#082b4d); font: 900 20px/1 var(--mono); }
.local-profile-summary > div:last-child { display: grid; gap: 6px; }
.local-profile-summary strong { color: #fff; font-size: 17px; }
.local-profile-summary span { color: #8ba4b7; font-size: 10px; }
.profile-local-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 12px; }
.profile-local-stats div { display: grid; gap: 5px; padding: 12px; border: 1px solid rgba(106,178,225,.17); background: rgba(3,14,26,.66); }
.profile-local-stats span { color: #8299aa; font-size: 9px; text-transform: uppercase; }
.profile-local-stats strong { color: #eaf7ff; font-size: 12px; }

@media (max-height: 760px) and (min-width: 641px) {
  #menu .menu-title-wrap { margin-bottom: 14px; }
  #menu .menu-logo-shadow,
  #menu .menu-logo { font-size: clamp(48px,7.5vw,82px); }
  #menu .menu-subtitle { margin-top: 10px; }
  #menu .mc-button { min-height: 51px; }
  #menu .mc-button::before { top: 7px; width: 36px; height: 36px; }
  .access-profile { min-height: 300px; padding-top: 11px; }
  .voxel-avatar { width: 88px; height: 88px; margin: 0 0 -3px; transform: scale(.82); }
  #menu .menu-status { margin: 8px 0 6px; }
  #menu .menu-extra-buttons { padding: 5px; }
}
@media (max-width: 820px) {
  #menu.main-menu-overlay { padding: 14px; overflow: auto; }
  #menu .mc-menu { width: min(720px,calc(100vw - 28px)); max-height: none; }
  .access-stage { grid-template-columns: minmax(340px,1fr) 220px; gap: 16px; }
  .access-profile { min-height: 320px; padding: 12px; }
  .voxel-avatar { width: 86px; height: 86px; margin: 5px 0 -3px; transform: scale(.82); }
  #menu .menu-extra-buttons { max-width: 100%; }
}
@media (max-width: 640px) {
  #menu.main-menu-overlay { align-items: start; overflow: auto; }
  #menu .mc-menu { padding-bottom: 18px; }
  #menu .menu-title-wrap { margin: 16px 0 20px; }
  #menu .menu-logo-shadow,
  #menu .menu-logo { font-size: clamp(43px,14vw,68px); }
  #menu .menu-subtitle { gap: 8px; font-size: 8px; letter-spacing: .12em; }
  .access-stage { grid-template-columns: 1fr; gap: 12px; }
  #menu .menu-main-buttons { gap: 7px; }
  #menu .mc-button { min-height: 51px; padding-left: 64px; font-size: 15px; }
  #menu .mc-button::before { left: 9px; top: 7px; width: 35px; height: 35px; }
  .access-profile { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto auto; min-height: 0; gap: 3px 12px; padding: 11px 13px; text-align: left; }
  .profile-heading,
  .profile-stats,
  .access-profile p { display: none; }
  .voxel-avatar { grid-row: 1 / 4; width: 62px; height: 62px; margin: 0; transform: none; }
  .voxel-avatar span { transform: none; }
  .voxel-avatar .avatar-face { left: 16px; top: 16px; width: 30px; height: 28px; box-shadow: inset 4px -4px #a96843; }
  .voxel-avatar .avatar-hair { left: 14px; top: 11px; width: 33px; height: 14px; box-shadow: 5px 5px #6b3b21,-2px 8px #422514; }
  .voxel-avatar .avatar-eye { top: 29px; width: 4px; height: 4px; box-shadow: inset 2px 0 #effbff; }
  .voxel-avatar .avatar-eye.eye-left { left: 23px; }
  .voxel-avatar .avatar-eye.eye-right { right: 21px; }
  .voxel-avatar .avatar-body { left: 12px; bottom: -10px; width: 38px; height: 30px; box-shadow: inset 6px 0 #0d4d75,inset -6px 0 #0a3859; }
  .profile-name { align-self: end; font-size: 15px; }
  .profile-online { align-self: start; margin: 0; }
  .profile-login { grid-column: 2; width: max-content; padding: 7px 10px; }
  #menu .menu-status { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #menu .menu-extra-buttons { overflow-x: auto; justify-content: flex-start; flex-wrap: nowrap; width: 100%; }
  #menu .menu-extra-buttons { scrollbar-width: none; }
  #menu .menu-extra-buttons::-webkit-scrollbar { display: none; }
  #menu .mc-small-button { flex: 0 0 auto; }
  .access-version,
  #menu .menu-footer { position: static; margin-top: 10px; }
  #menu .menu-footer { display: none; }
  #menu .menu-details { inset: 10px; width: auto; max-height: calc(100vh - 20px); padding: 14px; transform: none; }
  .multiplayer-grid,
  .profile-local-stats,
  #menu .menu-options-grid,
  #menu .controls-grid,
  .world-create-grid,
  .world-mode-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Controles configurables
   ============================================================ */

#menu .controls-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(250px, .75fr);
  gap: 12px;
  align-items: start;
}

#menu .controls-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid rgba(105, 179, 226, .22);
  border-radius: 4px;
  background: rgba(3, 15, 27, .62);
  box-shadow: inset 0 0 22px rgba(33, 135, 213, .055);
}

#menu .controls-keyboard-card { grid-row: span 2; }

#menu .controls-card-head {
  display: grid;
  gap: 4px;
  margin-bottom: 11px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(105, 179, 226, .16);
}

#menu .controls-card-head strong {
  color: #edf9ff;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
}

#menu .controls-card-head span {
  margin: 0;
  color: #839bad;
  font-size: 9px;
  line-height: 1.45;
  text-align: left;
}

.keybindings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.keybinding-row,
.control-binding-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 35px;
  padding: 5px 6px 5px 9px;
  border: 1px solid rgba(118, 187, 233, .13);
  border-radius: 3px;
  color: #a9becd;
  background: rgba(8, 28, 44, .64);
  font-size: 9.5px;
}

.keybinding-row > span,
.control-binding-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#menu .keybind-button,
#menu [data-bind-action] {
  flex: 0 0 auto;
  min-width: 74px;
  min-height: 27px;
  padding: 5px 8px;
  border-color: rgba(86, 180, 240, .38);
  color: #eefaff;
  background: linear-gradient(#123d61, #09243d);
  font: 750 9px/1 var(--mono);
  cursor: pointer;
}

#menu .keybind-button:hover,
#menu [data-bind-action]:hover {
  border-color: var(--access-cyan);
  background: linear-gradient(#185a8b, #0b3457);
}

#menu .keybind-button.listening,
#menu .keybind-button.is-listening,
#menu [data-bind-action].listening,
#menu [data-bind-action].is-listening {
  border-color: #ffe36e;
  color: #161b20;
  background: #ffe36e;
  box-shadow: 0 0 0 2px rgba(255, 227, 110, .18), 0 0 16px rgba(255, 227, 110, .22);
}

.keybind-status {
  min-height: 27px;
  margin: 9px 0 7px;
  padding: 7px 9px;
  border-left: 2px solid rgba(75, 183, 249, .55);
  color: #91a9bb;
  background: rgba(13, 49, 76, .33);
  font-size: 9px;
  line-height: 1.45;
}

.keybind-status.error { border-color: #ff7d85; color: #ffb5ba; }
.keybind-status.success { border-color: #67dfb9; color: #98efd4; }

#menu .controls-reset-button { width: 100%; }

#menu .controls-fixed-grid {
  grid-template-columns: 1fr;
  gap: 5px;
}

#menu .controls-grid > .control-fixed-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  color: #91a7b8;
  font-size: 9px;
}

#menu .control-fixed-row kbd { flex: 0 0 auto; }
#menu .control-fixed-row span { margin-left: auto; color: #d8e9f4; text-align: right; }

#menu .touch-sensitivity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 11px;
}

#menu .touch-sensitivity > span {
  float: none;
  color: #c7dce9;
  font-size: 9.5px;
}

#menu .touch-sensitivity output {
  color: var(--access-cyan);
  font-size: 9.5px;
}

#menu .touch-sensitivity input { grid-column: 1 / -1; margin-top: 2px; }

#menu .mobile-layout-actions { display: grid; gap: 7px; }
#menu .mobile-layout-actions .mc-button {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  text-align: center;
  font-size: 10px;
}
#menu .mobile-layout-actions .mc-button::before,
#menu .mobile-layout-actions .mc-button::after { display: none; }
#menu .mobile-layout-actions .mc-small-button { width: 100%; min-height: 31px; }

.mobile-controls-note {
  margin: 10px 0 0;
  color: #7f97a9;
  font-size: 8.5px;
  line-height: 1.55;
}

/* ============================================================
   Capa táctil del juego
   ============================================================ */

#mobile-controls {
  --mobile-joystick-size: clamp(88px, 24vw, 124px);
  --mobile-action-size: clamp(42px, 10.8vw, 54px);
  --mobile-action-gap: clamp(4px, 1.2vw, 7px);
  position: fixed;
  inset: 0;
  z-index: 9;
  display: none;
  overflow: hidden;
  pointer-events: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.mobile-capable #mobile-controls,
#mobile-controls.active,
body.mobile-layout-edit #mobile-controls { display: block; }
body.mobile-layout-edit #mobile-controls { z-index: 45; }
.mobile-context-hidden { display: none !important; }

.mobile-joystick {
  position: absolute;
  width: var(--mobile-joystick-size);
  height: var(--mobile-joystick-size);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(183, 225, 250, .38);
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 38%, rgba(92, 183, 238, .22), rgba(8, 27, 43, .52) 54%, rgba(1, 9, 17, .68));
  box-shadow: inset 0 0 0 5px rgba(3, 17, 29, .32), 0 3px 15px rgba(0, 0, 0, .36);
  opacity: .76;
  pointer-events: auto;
  touch-action: none;
}

#mobile-move-joystick {
  left: var(--mobile-move-x, 18%);
  top: var(--mobile-move-y, 79%);
}

.mobile-joystick-ring {
  position: absolute;
  inset: 11%;
  border: 1px dashed rgba(189, 229, 252, .30);
  border-radius: 50%;
  pointer-events: none;
}

.mobile-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 43%;
  height: 43%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(226, 247, 255, .70);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(145, 218, 255, .78), rgba(26, 107, 166, .78) 60%, rgba(7, 46, 80, .92));
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45), inset 0 0 8px rgba(219, 246, 255, .30);
  pointer-events: none;
  will-change: transform;
}

.mobile-joystick-label {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  color: rgba(229, 247, 255, .74);
  font: 750 7px/1 var(--mono);
  letter-spacing: .10em;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.mobile-action-group {
  position: absolute;
  display: grid;
  gap: var(--mobile-action-gap);
  pointer-events: none;
}

.mobile-action {
  width: var(--mobile-action-size);
  height: var(--mobile-action-size);
  min-width: 0;
  min-height: 0;
  padding: 3px;
  display: grid;
  place-content: center;
  gap: 2px;
  border: 1px solid rgba(196, 230, 250, .42);
  border-radius: 10px;
  color: #effaff;
  background: linear-gradient(155deg, rgba(31, 92, 137, .82), rgba(3, 24, 42, .88));
  box-shadow: inset 0 1px rgba(255, 255, 255, .14), 0 3px 9px rgba(0, 0, 0, .36);
  opacity: .84;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-action b { font: 800 clamp(15px, 4.6vw, 22px)/.9 var(--mono); }
.mobile-action span { font: 750 clamp(5px, 1.6vw, 7px)/1 var(--mono); letter-spacing: .03em; }
.mobile-action-primary { border-color: rgba(98, 197, 255, .68); background: linear-gradient(155deg, rgba(24, 121, 190, .90), rgba(5, 46, 80, .94)); }
.mobile-action-small { width: auto; min-width: var(--mobile-action-size); }
.mobile-action-round { border-radius: 50%; }
.mobile-action-round b { font-size: clamp(26px, 8vw, 36px); line-height: .6; }

.mobile-action:active,
.mobile-action.is-held,
.mobile-action.active {
  opacity: 1;
  transform: translateY(2px) scale(.96);
  border-color: #fff;
  background: linear-gradient(155deg, rgba(48, 160, 228, .98), rgba(8, 69, 114, .98));
  box-shadow: inset 0 0 12px rgba(255, 255, 255, .22), 0 0 12px rgba(64, 183, 255, .28);
}

#inventory #btn-inv-quick.active {
  border-color: #7dd5ff;
  color: #e8f9ff;
  background: #14547e;
}

.mobile-top-actions {
  top: max(9px, env(safe-area-inset-top));
  right: max(9px, env(safe-area-inset-right));
  grid-template-columns: repeat(3, auto);
}

.mobile-top-actions .mobile-action {
  width: clamp(48px, 13vw, 65px);
  height: clamp(38px, 9.8vw, 46px);
}

.mobile-move-actions {
  left: max(8px, env(safe-area-inset-left));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 21vh + 54px);
  grid-template-columns: repeat(2, var(--mobile-action-size));
}

.mobile-build-actions {
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + 68px);
  grid-template-columns: repeat(2, var(--mobile-action-size));
}

.mobile-hotbar-nav {
  left: 50%;
  bottom: calc(max(7px, env(safe-area-inset-bottom)) + 41px);
  grid-template-columns: repeat(2, var(--mobile-action-size));
  gap: clamp(42px, 17vw, 105px);
  transform: translateX(-50%);
}

#mobile-layout-toolbar {
  position: absolute;
  left: 50%;
  top: max(10px, env(safe-area-inset-top));
  width: min(620px, calc(100vw - max(20px, env(safe-area-inset-left)) - max(20px, env(safe-area-inset-right))));
  min-height: 48px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid rgba(110, 200, 255, .62);
  border-radius: 7px;
  color: #e9f8ff;
  background: rgba(2, 16, 29, .94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .52);
  pointer-events: auto;
  touch-action: manipulation;
}

#mobile-layout-toolbar span { margin-right: auto; font-size: 9px; }
#mobile-layout-toolbar button {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(105, 190, 245, .42);
  border-radius: 3px;
  color: #dff5ff;
  background: #0b3555;
  font: 750 8px/1 var(--mono);
}
#mobile-layout-toolbar #btn-mobile-layout-done { border-color: #64c7ff; background: #116cae; }

body.overlay-open:not(.mobile-layout-edit) #mobile-controls {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body.mobile-layout-edit .mobile-action-group { opacity: .22; pointer-events: none; }
body.mobile-layout-edit .mobile-action { pointer-events: none; }
body.mobile-layout-edit .mobile-joystick {
  opacity: 1;
  border-color: #ffe36e;
  cursor: grab;
  box-shadow: 0 0 0 4px rgba(255, 227, 110, .18), 0 0 24px rgba(255, 227, 110, .24);
  animation: mobileEditPulse 1.15s ease-in-out infinite alternate;
}
body.mobile-layout-edit .mobile-joystick:active { cursor: grabbing; }

@keyframes mobileEditPulse {
  from { filter: brightness(.96); }
  to { filter: brightness(1.18); }
}

@media (pointer: coarse), (max-width: 760px), (max-width: 950px) and (max-height: 560px) {
  #mobile-controls { display: block; }
  #hud-buttons { display: none; }

  button,
  .slot,
  .tab {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }

  #hud-bottom {
    z-index: 8;
    bottom: max(3px, env(safe-area-inset-bottom));
    gap: 3px;
  }

  #block-name { min-height: 14px; font-size: 10px; }

  #hotbar {
    gap: 2px;
    max-width: calc(100vw - 12px);
    padding: 2px;
    border-width: 1px;
  }

  #hotbar > .slot {
    width: clamp(29px, calc((100vw - 52px) / 9), 44px);
    height: clamp(29px, calc((100vw - 52px) / 9), 44px);
    border-width: 1px;
  }

  #hotbar > .slot .icon {
    width: 72%;
    height: 72%;
  }

  #hotbar > .slot .num { left: 2px; bottom: 0; font-size: 7px; }
  #hotbar > .slot .count { right: 1px; bottom: -1px; font-size: 9px; }

  #vitals { gap: 2px; margin-bottom: 1px; transform: scale(.82); transform-origin: center bottom; }
  #toast { bottom: max(118px, calc(env(safe-area-inset-bottom) + 108px)); max-width: calc(100vw - 24px); text-align: center; }
}

/* El inventario pasa a una sola columna en teléfonos estrechos. Las
   rejillas mantienen las nueve casillas, pero se reducen sin recortar. */
@media (max-width: 760px) {
  #menu .controls-layout { grid-template-columns: 1fr; }
  #menu .controls-keyboard-card { grid-row: auto; }
  .keybindings-list { grid-template-columns: 1fr; }

  #inventory.overlay {
    place-items: start center;
    padding:
      calc(max(6px, env(safe-area-inset-top)))
      calc(max(6px, env(safe-area-inset-right)))
      calc(max(6px, env(safe-area-inset-bottom)))
      calc(max(6px, env(safe-area-inset-left)));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #inventory .inv-wrap {
    width: 100%;
    max-height: none;
    align-items: stretch;
    gap: 8px;
  }

  #inventory .inv-panels,
  #inventory .inv-panels.no-palette {
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    gap: 8px;
  }

  #inventory .bpanel { width: 100%; }
  #inventory .bbody {
    width: 100%;
    padding: 9px;
    overflow-x: auto;
    border-radius: 0 7px 7px 7px;
  }

  #inventory .bpanel:last-child .bbody { min-height: 245px; max-height: 58vh; }
  #inventory .inv-panels.no-palette .slot-grid.recipes { min-width: 0; }
  #inventory .tabs {
    max-width: 100%;
    padding-left: 3px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  #inventory .tabs::-webkit-scrollbar { display: none; }
  #inventory .tabs .tab { flex: 0 0 auto; min-height: 34px; padding: 7px 10px 8px; }

  #inventory .slot-grid {
    --inv-slot-size: clamp(29px, calc((100vw - 58px) / 9), 42px);
  }
  #inventory .slot-grid.c1 { grid-template-columns: repeat(1, var(--inv-slot-size)); }
  #inventory .slot-grid.c2 { grid-template-columns: repeat(2, var(--inv-slot-size)); }
  #inventory .slot-grid.c3 { grid-template-columns: repeat(3, var(--inv-slot-size)); }
  #inventory .slot-grid.c9 { grid-template-columns: repeat(9, var(--inv-slot-size)); margin-inline: auto; }
  #inventory .slot-grid.palette,
  #inventory .slot-grid.recipes { grid-template-columns: repeat(auto-fill, var(--inv-slot-size)); }
  #inventory .slot-grid .slot { width: var(--inv-slot-size); height: var(--inv-slot-size); }
  #inventory .slot-grid .slot .icon { width: 73%; height: 73%; }
  #inventory .slot-grid .slot .count { font-size: 9px; }
  #inventory .slot-grid .slot .plus { font-size: 10px; }

  #inventory .craft-box { max-width: 100%; padding: 7px; }
  #inventory .craft-row { gap: 7px; }
  #inventory .craft-arrow { font-size: 15px; }
  #inventory .craft-info { max-width: min(150px, 32vw); }
  #inventory .armor-row { flex-wrap: wrap; }
  #inventory .bfoot { flex-wrap: wrap; }
  #inventory .bfoot button { min-height: 34px; }
  #inventory .inv-help { padding: 0 4px 6px; font-size: 8px; line-height: 1.45; }
  #inventory #cursor-stack { pointer-events: none; }
}

@media (max-width: 430px) {
  #menu .controls-card { padding: 10px; }
  #menu .keybind-button,
  #menu [data-bind-action] { min-width: 68px; }

  .mobile-top-actions .mobile-action span { display: none; }
  .mobile-top-actions .mobile-action { width: var(--mobile-action-size); }
  .mobile-controls-note { font-size: 8px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  #mobile-controls {
    --mobile-joystick-size: clamp(78px, 22vh, 104px);
    --mobile-action-size: clamp(36px, 10.5vh, 46px);
    --mobile-action-gap: 4px;
  }

  #mobile-move-joystick { left: var(--mobile-move-x, 12%); top: var(--mobile-move-y, 70%); }
  .mobile-move-actions { bottom: calc(max(5px, env(safe-area-inset-bottom)) + 30vh + 53px); }
  .mobile-build-actions { bottom: calc(max(5px, env(safe-area-inset-bottom)) + 51px); }
  .mobile-hotbar-nav { bottom: calc(max(5px, env(safe-area-inset-bottom)) + 48px); gap: 10px; }
  .mobile-action span { display: none; }
  .mobile-top-actions .mobile-action { width: var(--mobile-action-size); height: var(--mobile-action-size); }
  .mobile-joystick-label { display: none; }
  #vitals { transform: scale(.72); margin-bottom: -3px; }
  #toast { bottom: 82px; }
}

@media (prefers-reduced-motion: reduce) {
  body.mobile-layout-edit .mobile-joystick { animation: none; }
}
