* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #111317;
  color: #e6e6e6;
  font-family: system-ui, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  width: min(360px, calc(100vw - 32px));
  background: #1c1f26;
  border: 2px solid #343a46;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel h1, .panel h2 { margin: 0 0 8px; text-align: center; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

input, button {
  font: inherit;
  padding: 8px 10px;
  border: 2px solid #343a46;
  background: #111317;
  color: inherit;
}

button { background: #3b6fd4; border-color: #3b6fd4; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.secondary { background: transparent; }
button.link { background: none; border: none; color: #8aa4d6; text-decoration: underline; }

.msg { min-height: 1.2em; margin: 0; color: #ff8a80; font-size: 14px; }
.msg.ok { color: #9ccc65; }

#char-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#char-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; background: #111317; border: 2px solid #343a46; }
#char-list li.empty { color: #888; justify-content: center; }

/* Juego */
#game {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;   /* escalado nítido en pantallas de alta densidad */
}

#hud {
  position: fixed;
  top: 8px;
  left: 8px;
  width: 230px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.6);
  font: 13px/1.4 monospace;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#hud-name { font-weight: bold; color: #f2c14e; }
#hud-silver { color: #cfd8dc; }
#hud-info { color: #9e9e9e; font-size: 11px; }

/* Barras de vida / XP */
.bar {
  position: relative;
  height: 14px;
  background: #2a2a2a;
  border: 1px solid #000;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; }
.bar .fill.hp { background: #c62828; }
.bar .fill.xp { background: #7e57c2; }
.bar span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 11px;
  line-height: 14px;
  text-shadow: 1px 1px 0 #000;
}

#hud-stats { color: #bdbdbd; font-size: 11px; border-top: 1px solid #333; padding-top: 4px; }

/* Objetivo */
#target-frame {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.6);
  font: 13px/1.4 monospace;
  text-align: center;
  pointer-events: none;
}
#target-note { color: #ffb74d; font-size: 11px; min-height: 1.2em; }

#help {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.5);
  font: 11px monospace;
  color: #aaa;
  pointer-events: none;
  white-space: nowrap;
}

/* Ventanas (inventario) */
.window {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: min(330px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 10px;
  background: rgba(20, 22, 28, 0.95);
  border: 2px solid #343a46;
  font: 13px/1.4 monospace;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.window-head { display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
.window-head .link { font-size: 18px; padding: 0 4px; }
#inv-count { color: #9e9e9e; font-weight: normal; }
.window-sub { color: #bbb; border-top: 1px solid #333; padding-top: 6px; }
.window-foot { color: #777; font-size: 11px; }
#mastery-list { font-size: 11px; color: #ccc; display: flex; flex-direction: column; gap: 2px; }

#equip-slots { display: flex; gap: 8px; justify-content: center; }
#inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }

.slot {
  position: relative;
  aspect-ratio: 1;
  background: #111317;
  border: 1px solid #2c313b;
}
.slot.equip { width: 64px; border-color: #5c6370; }
.slot-label {
  position: absolute;
  bottom: -14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: #888;
}
#equip-slots { padding-bottom: 14px; }

.item {
  position: absolute;
  inset: 2px;
  border: 3px solid #fff;   /* color = calidad */
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  user-select: none;
}
.item .glyph { font-size: 18px; text-shadow: 0 0 2px #fff; }
.item .tier {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 9px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}
.item.locked { filter: grayscale(0.7) brightness(0.6); }
.item.locked::after {
  content: '🔒';
  position: absolute;
  top: 0;
  left: 1px;
  font-size: 10px;
}

/* Tooltip */
#tooltip {
  position: fixed;
  z-index: 10;
  max-width: 300px;
  padding: 8px 10px;
  background: rgba(10, 10, 14, 0.96);
  border: 1px solid #555;
  font: 12px/1.4 monospace;
  pointer-events: none;
}
#tooltip .title { font-weight: bold; font-size: 14px; }
#tooltip .muted { color: #9e9e9e; }
#tooltip .stat { margin-top: 2px; }
#tooltip .calc { color: #8a8a8a; font-size: 11px; padding-left: 8px; }
#tooltip .req-ok { color: #9ccc65; margin-top: 4px; }
#tooltip .req-bad { color: #ff6b6b; margin-top: 4px; }

/* Avisos */
#toasts {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}
.toast {
  padding: 6px 12px;
  font: 13px monospace;
  background: rgba(120, 20, 20, 0.9);
  border: 1px solid #000;
}
.toast.ok { background: rgba(30, 100, 40, 0.9); }
.toast.info { background: rgba(40, 40, 50, 0.9); }

#death-overlay {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: rgba(80, 0, 0, 0.75);
  font-size: 20px;
  pointer-events: none;
}

#conn-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  font-size: 20px;
}
