@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('press-start-2p.woff2') format('woff2');
}

:root {
  --px: 'Press Start 2P', monospace;
  --c-core: #3ee6c4;
  --c-prod: #ff7a59;
  --c-staging: #b48cff;
  --c-grupovap: #ffd257;
  --hud-bg: rgba(10, 10, 26, 0.82);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #07071a;
  overflow: hidden;
  cursor: none;
  font-family: var(--px);
  user-select: none;
}

/* ---------- escenario ---------- */
#stage {
  position: absolute;
  /* JS lo dimensiona manteniendo la proporción del mapa, centrado */
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}
#map {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#world, #fx { position: absolute; inset: 0; }
#debug { position: absolute; inset: 0; pointer-events: none; display: none; }
body.debug #debug { display: block; }
body.debug { cursor: crosshair; }

/* ---------- actores ---------- */
.actor {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  transition: opacity .8s;
}
.actor.despawn { opacity: 0; }
.actor .badge {
  font-family: system-ui, sans-serif;
  line-height: 1;
  margin-bottom: 1px;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.6));
}
.actor .sw { position: relative; transform-origin: 50% 100%; }
.actor .sw .shadow {
  position: absolute;
  left: 50%; bottom: -2px;
  transform: translateX(-50%);
  width: 72%; height: 6px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.38) 0%, rgba(0,0,0,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}
.actor .sw canvas { position: relative; z-index: 1; }
.actor .body { image-rendering: pixelated; display: block; }
.actor .tag {
  margin-top: 2px;
  padding: 2px 4px 1px;
  background: rgba(8, 8, 22, 0.78);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 3px;
  color: #fff;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
}
.actor .tag .gw { display: block; margin-top: 2px; opacity: .85; }

.actor .bubble {
  position: absolute;
  top: -4px; left: 50%;
  transform: translate(-50%, -100%);
  font-family: system-ui, sans-serif;
  padding: 2px 4px;
  background: #fff;
  border-radius: 6px 6px 6px 0;
  border: 2px solid #10102a;
  line-height: 1;
  opacity: 0;
  transition: opacity .3s;
}
.actor .bubble.on { opacity: 1; }
.actor .bubble.typing::after {
  content: '';
  animation: typedots 1.2s steps(4) infinite;
}
@keyframes typedots { 0% {content:''} 25% {content:'.'} 50% {content:'..'} 75% {content:'...'} }

/* aparición */
.actor.spawn .body { animation: spawnpop .9s cubic-bezier(.2,1.6,.4,1); }
@keyframes spawnpop {
  0% { transform: scale(0); filter: brightness(6); }
  60% { transform: scale(1.25); filter: brightness(2.2); }
  100% { transform: scale(1); filter: none; }
}
.spark {
  position: absolute;
  width: 6px; height: 6px;
  background: #fff;
  image-rendering: pixelated;
  animation: spark .8s ease-out forwards;
}
@keyframes spark {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ---------- HUD ---------- */
#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  pointer-events: none;
}
#brand {
  display: flex; align-items: center; gap: 10px;
  background: var(--hud-bg);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 6px;
  padding: 10px 14px;
}
#brand .dot {
  width: 10px; height: 10px;
  background: var(--c-core);
  box-shadow: 0 0 8px var(--c-core);
  animation: blink 2.4s infinite;
}
@keyframes blink { 0%,100% {opacity:1} 50% {opacity:.35} }
#brand h1 { color: #fff; letter-spacing: 1px; }
#agent-count { color: var(--c-core); }
#clockbox {
  min-width: 12rem;
  text-align: right;
  background: var(--hud-bg);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 6px;
  padding: 10px 14px;
}
#clock { color: #fff; }
#date { color: #9aa0c8; margin-top: 6px; }

/* etiquetas de zona */
.zlabel {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 7px 3px;
  background: rgba(8, 8, 22, 0.72);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.12);
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 #000;
}
.zlabel .n { opacity: .9; margin-left: 6px; }

/* ---------- toast ---------- */
#toast {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translate(-50%, -30px);
  display: flex; align-items: center; gap: 12px;
  background: var(--hud-bg);
  border: 3px solid #fff;
  border-radius: 8px;
  padding: 16px 22px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s, transform .4s;
  text-shadow: 2px 2px 0 #000;
  z-index: 50;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast-emoji { font-family: system-ui, sans-serif; }

/* ---------- spotlight ---------- */
#spotlight {
  position: absolute;
  right: 16px; bottom: 64px;
  width: 12.5rem;
  background: var(--hud-bg);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  z-index: 40;
  transition: opacity .35s;
}
#spotlight.swap { opacity: 0; }
#sp-title { color: #9aa0c8; font-size: 0.45rem; letter-spacing: 1px; margin-bottom: 8px; }
#sp-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  image-rendering: pixelated;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,.12);
  background: #10142a;
  display: block;
}
#sp-name { color: #fff; font-size: 0.68rem; margin-top: 8px; text-shadow: 1px 1px 0 #000; }
#sp-meta { font-size: 0.45rem; margin-top: 6px; }
#sp-activity { color: #9aa0c8; font-size: 0.45rem; margin-top: 5px; }

#toast-img {
  width: 3.2rem; height: 3.2rem;
  image-rendering: pixelated;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,.2);
  object-fit: cover;
}

/* ---------- ticker ---------- */
#ticker {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--hud-bg);
  border-top: 2px solid rgba(255,255,255,.14);
  overflow: hidden;
  padding: 10px 0;
}
#ticker-inner {
  display: inline-block;
  white-space: nowrap;
  color: #d8dcf5;
  will-change: transform;
}
#ticker-inner .sep { color: #5a5f8f; margin: 0 18px; }
#ticker-inner .hl { color: var(--c-core); }

#offline-chip {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: #71203a;
  color: #ffd7e0;
  border: 2px solid #ff5c8a;
  border-radius: 4px;
  padding: 6px 10px;
  display: none;
  z-index: 60;
}
body.stale #offline-chip { display: block; }

/* ---------- tamaños (rem = escala del escenario, la fija JS) ---------- */
#brand h1 { font-size: 1.05rem; }
#agent-count { font-size: 0.72rem; }
#clock { font-size: 1.25rem; }
#date { font-size: 0.55rem; }
.zlabel { font-size: 0.58rem; }
.zlabel .n { font-size: 0.50rem; }
.actor .tag { font-size: 0.40rem; }
.actor .badge { font-size: 0.85rem; }
.actor .bubble { font-size: 0.75rem; min-width: 0.9rem; min-height: 0.75rem; }
#ticker { font-size: 0.62rem; }
#toast { font-size: 0.85rem; }
#toast-emoji { font-size: 1.6rem; }
#offline-chip { font-size: 0.55rem; }
