:root {
  --health: #e74c3c;
  --armor: #3498db;
  --hunger: #e67e22;
  --thirst: #5dade2;
  --energy: #f1c40f;
  --money: #2ecc71;
  --text: rgba(255, 255, 255, 0.95);
  --text-dim: rgba(255, 255, 255, 0.55);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  --bar-w: 210px;
  --ring-c: 97.4;
  --ui-scale: 1;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent !important;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  pointer-events: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#playerHud {
  position: fixed;
  top: 18px;
  right: 18px;
  opacity: 0;
  transition: opacity 0.25s ease;
  transform-origin: top right;
  transform: scale(var(--ui-scale));
}

#playerHud.visible { opacity: 1; }
#playerHud.hidden { opacity: 0; display: none; }

.hud-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Fila superior: nombre + icono (estilo GTA) */
.hand-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: var(--bar-w);
}

.hand-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  padding-right: 2px;
}

/* Cuadro arma/objeto */
.hand-slot {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hand-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  display: none;
}

.hand-img.visible { display: block; }

.hand-fallback {
  width: 42px;
  height: 42px;
  fill: var(--text);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

.hand-fallback.hidden { display: none; }

.bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: var(--bar-w);
}

.bar-track {
  height: 9px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.bar-health { background: var(--health); }
.bar-armor { background: var(--armor); }

.bar-row.low .bar-fill { animation: pulse-bar 1.2s ease infinite; }

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.needs {
  display: flex;
  gap: 10px;
}

.need-ring {
  position: relative;
  width: 44px;
  height: 44px;
}

.need-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  fill: var(--text);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
  z-index: 1;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 3;
}

.ring-fill {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-c);
  stroke-dashoffset: var(--ring-c);
  transition: stroke-dashoffset 0.35s ease;
}

.ring-hunger { stroke: var(--hunger); }
.ring-thirst { stroke: var(--thirst); }
.ring-energy { stroke: var(--energy); }

.need-ring.low .need-icon { fill: #ff6b6b; }
.need-ring.low .ring-fill { stroke: #ff6b6b; }

.money {
  font-size: 26px;
  font-weight: 700;
  color: var(--money);
  letter-spacing: 0.02em;
  text-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.money.negative { color: #e74c3c; }

.hand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-shadow: var(--shadow);
}

.hand-badge.weapon { color: #ff7675; }
.hand-badge.object { color: #74b9ff; }

.hand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-shadow: var(--shadow);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  line-height: 1.1;
}

body.dev-preview {
  background:
    linear-gradient(180deg, rgba(93, 173, 226, 0.9) 0%, rgba(174, 214, 241, 0.85) 45%, rgba(120, 120, 120, 0.6) 100%) !important;
}

body.dev-preview::after {
  content: "Vista previa — cef/playerhud/playerhud.html";
  position: fixed;
  bottom: 10px;
  left: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}
