/* Botones */
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: .65rem .9rem;
  font-weight: 800;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
  transition: transform .04s ease, filter .2s ease, background .2s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:disabled { background: #1e3a8a; cursor: not-allowed; opacity: .7; }
.btn-secondary { background: #0f172a; border: 1px solid #334155; }

/* ===== MODAL (estándar) ===== */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
.modal-content {
  position: relative; width: min(740px, 92vw);
  background: linear-gradient(180deg, rgba(10,16,30,.95), rgba(10,16,30,.90));
  border: 1px solid rgba(180,195,220,.22); border-radius: 16px; color: #e8eeff;
  box-shadow: 0 20px 60px rgba(0,0,0,.55); overflow: hidden; animation: modal-in .18s ease-out;
}
@keyframes modal-in { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header, .modal-footer { padding: .9rem 1rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(180,195,220,.18); }
.modal-footer { border-top: 1px solid rgba(180,195,220,.18); border-bottom: none; gap: .5rem; }
.modal-header h3 { margin: 0; font-size: 1.1rem; font-weight: 900; letter-spacing: .02em; }
.modal-close {
  appearance: none; border: 0; border-radius: 10px; background: #0f172a; color: #e2e8f0;
  border: 1px solid #2b3a54; font-weight: 900; padding: .4rem .6rem; cursor: pointer;
}
.modal-close:hover { filter: brightness(1.08); }
.modal-body { padding: 1rem; display: grid; gap: .75rem; }
.mini-label { font-size: .8rem; color: #a9b8d8; font-weight: 800; letter-spacing: .01em; }

/* Fila compacta en el cuerpo del modal (zona + stats globales) */
.modal-inline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
}
.modal-inline-right {
  display: flex;
  align-items: baseline;
  gap: .9rem;
}

/* Acentos para fondos/acciones en el modal */
.modal-accent { font-weight: 900; color: #ffd29b; }
.modal-accent-alt { font-weight: 900; color: #b7ffcf; }

/* ===== Lista de medidas ===== */
.measure-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.measure-item {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center;
  background: linear-gradient(180deg, rgba(15,22,40,.9), rgba(12,18,32,.9));
  border: 1px solid rgba(180,195,220,.18); border-radius: 12px; padding: .6rem .7rem;
}
.measure-title { font-weight: 900; letter-spacing: .02em; color: #e9efff; }
.measure-meta { font-size: .85rem; color: #aab8da; margin-top: .2rem; }
.measure-cost { font-weight: 900; color: #ffd29b; margin-right: .6rem; }
.measure-apply { white-space: nowrap; }

/* Coste en rojo cuando no alcanzan los fondos */
.cost-insufficient { color: #ff5a7d; }

/* ===== POPUP PERSONALIZADO (Nunito) ===== */
#app-dialog-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.app-dialog-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .15s ease;
}
.app-dialog {
  position: absolute; left: 50%; top: 20%;
  transform: translate(-50%, -10px);
  width: min(520px, 92vw);
  background: #0c1322;
  border: 1px solid rgba(180,195,220,.25);
  border-radius: 14px;
  color: #eaf0ff;
  font-family: "Nunito", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .15s ease, transform .15s ease;
  pointer-events: auto;
}
.app-dialog.show { opacity: 1; transform: translate(-50%, 0); }
.app-dialog-backdrop.show { opacity: 1; }

.app-dialog-head {
  display: grid; grid-template-columns: 36px 1fr; gap: .6rem;
  align-items: center; padding: .8rem 1rem .2rem 1rem;
}
.app-dialog-icon {
  width: 36px; height: 36px; border-radius: 999px;
  display: grid; place-items: center; font-size: 18px; font-weight: 900;
  background: radial-gradient(100% 100% at 30% 25%, rgba(255,255,255,.15), rgba(255,255,255,0)),
              linear-gradient(180deg, #2b3b66, #1c2a4a);
  border: 1px solid rgba(180,195,220,.35);
}
.app-dialog-title {
  margin: 0; font-weight: 900; letter-spacing: .02em; color: #eaf0ff; font-size: 1rem;
}

.app-dialog-body { padding: .2rem 1rem 1rem 1rem; font-size: 1rem; line-height: 1.35; color: #dfe7ff; }
.app-dialog-body p { margin: .25rem 0; }
.app-dialog-actions {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: .65rem 1rem; border-top: 1px solid rgba(180,195,220,.18);
}
.app-dialog .btn { background: #0f172a; border: 1px solid #2b3a54; color: #eaf0ff; }
.app-dialog .btn:hover { filter: brightness(1.08); }

/* =================================================================== */
/* ===================  STICKY VARS + HUD STICKY  ==================== */
/* =================================================================== */

/* Variables para offsets de sticky (ajústalas si cambias alturas) */
:root{
  --hud-stick-top: 1rem;   /* distancia del HUD al borde superior */
  --hud-height: 64px;      /* altura aproximada del HUD */
  --hud-gap: .6rem;        /* separación entre HUD y Objetivo */
}

/* 1) Regla funcional del HUD sticky */
.hud {
  position: sticky;
  top: var(--hud-stick-top);
  z-index: 30;
  align-self: start;
}

/* 2) Rail alternativo (por si algún layout aún lo rompe)
   Usa <div class="hud-rail"><div class="hud">…</div></div> */
.hud-rail {
  position: sticky;
  top: var(--hud-stick-top);
  z-index: 31;
}
.hud-rail .hud { position: static; }

/* 3) Seguridad contra ancestros que rompen sticky.
   (Mejor tener también en layout.css, pero lo duplicamos por robustez.) */
main.container,
.panel,
.game-layout {
  overflow: visible !important;
  contain: none !important;
  transform: none !important;
  filter: none !important;
}
