/* ================================================
   game.css — Juego estilo pastel girlie ✨
   ================================================ */

/* ── Keyframes locales (por si base.css no carga) ── */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.97); }
}
@keyframes bounceIn {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  33%       { transform: scale(1.15) rotate(8deg); opacity: 0.85; }
  66%       { transform: scale(0.9) rotate(-5deg); opacity: 0.9; }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-4px); }
}

/* ── Pantalla creación de personaje ── */

#playerCreation {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 15% 20%, rgba(232,130,154,0.09) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(184,153,216,0.11) 0%, transparent 50%);
}

.create-wrapper {
  max-width: 680px;
  width: 100%;
  animation: floatUp 0.5s ease both;
}

.create-logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}
.create-logo .npc   { color: var(--rose); }
.create-logo .forge { color: var(--lavender); }
.create-logo .game  { color: var(--text-mute); font-size: 15px; font-weight: 400; font-family: var(--font-body); }

.create-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
  margin-bottom: 4px;
}

.create-sub {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 22px;
  font-style: italic;
}

.create-editor-wrap {
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.create-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ── Contenedor del juego ── */

#gameContainer {
  position: fixed;
  inset: 0;
  background: #2a1a2e;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

#gameCanvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── HUD ── */

.hud-hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
  background: rgba(42, 26, 46, 0.75);
  backdrop-filter: blur(8px);
  padding: 7px 16px;
  border: 1px solid rgba(232,130,154,0.2);
  border-radius: 99px;
  pointer-events: none;
  white-space: nowrap;
}

.hud-back {
  position: fixed;
  top: 14px;
  left: 16px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  background: rgba(42, 26, 46, 0.8);
  backdrop-filter: blur(8px);
  padding: 8px 14px;
  border: 1px solid rgba(232,130,154,0.25);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: all 0.2s;
  z-index: 50;
}
.hud-back:hover {
  color: var(--rose-light);
  border-color: rgba(232,130,154,0.6);
  background: rgba(42, 26, 46, 0.95);
  text-decoration: none;
}

/* ── Overlay diálogo ── */

#dialogOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 16px;
  z-index: 100;
  pointer-events: none;
}
#dialogOverlay:not(.hidden) {
  pointer-events: auto;
}

/* ── Caja de diálogo ── */

.dialog-box {
  background: rgba(255, 248, 254, 0.96);
  backdrop-filter: blur(20px);
  border: 2px solid var(--border-lit);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-lg) var(--radius-lg);
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(232,130,154,0.25), 0 0 0 1px rgba(232,130,154,0.1);
  animation: bounceIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--rose-pale), var(--lavender-pale));
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

#dialogNpcSprite {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  border: 2px solid var(--border-lit);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: var(--surface-2);
}

#dialogNpcName {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text);
  margin-bottom: 2px;
}

#dialogNpcArch {
  font-size: 12px;
  color: var(--lavender);
  font-style: italic;
}

.dialog-close {
  margin-left: auto;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-mute);
  font-size: 13px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  transition: all 0.15s;
  flex-shrink: 0;
}
.dialog-close:hover {
  border-color: var(--rose-light);
  color: var(--rose);
  background: var(--rose-pale);
}

/* Historial */
#dialogHistory {
  min-height: 80px;
  max-height: 180px;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--surface-1);
}

.dmsg {
  display: flex;
  gap: 10px;
  font-size: 15px;
  line-height: 1.55;
  align-items: baseline;
}

.dname {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
  min-width: 48px;
}

.dtext { color: var(--text); }

.dmsg.user  .dname { color: var(--mint); }
.dmsg.npc   .dname { color: var(--rose); }
.dmsg.sys-err .dname { color: #e05555; }
.dmsg.thinking .dtext {
  color: var(--text-mute);
  font-style: italic;
  animation: pulse-soft 1.2s ease-in-out infinite;
}

/* Opciones */
.dialog-options {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: linear-gradient(135deg, var(--rose-pale), var(--lavender-pale));
}
.dialog-options.hidden { display: none; }

.dialog-option-btn {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--border-lit);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  line-height: 1.4;
}
.dialog-option-btn::before {
  content: '✦ ';
  color: var(--rose);
  font-size: 10px;
}
.dialog-option-btn:hover {
  background: white;
  border-color: var(--rose-light);
  color: var(--rose);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

/* Campo de entrada */
.dialog-input-row {
  display: flex;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.dialog-input-row input {
  flex: 1;
  background: var(--surface-1);
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
}
.dialog-input-row input::placeholder { color: var(--text-mute); font-style: italic; }
.dialog-input-row input:focus { background: white; }

.dialog-input-row button {
  background: linear-gradient(135deg, var(--rose), var(--lavender));
  border: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  padding: 12px 20px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.dialog-input-row button:hover { opacity: 0.88; }

/* ── Panel de misiones ── */

#missionsPanel {
  position: fixed;
  bottom: 52px;
  right: 16px;
  width: 250px;
  background: rgba(255,248,254,0.95);
  backdrop-filter: blur(16px);
  border: 2px solid var(--border-lit);
  border-radius: var(--radius-xl);
  z-index: 200;
  pointer-events: auto;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.missions-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: linear-gradient(135deg, var(--rose-pale), var(--lavender-pale));
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.missions-title {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--rose);
  text-transform: uppercase;
}

.missions-npc-label {
  font-size: 9px;
  color: var(--text-dim);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.missions-npc-label b { color: var(--lavender); }

.missions-counter {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mint);
  flex-shrink: 0;
}

.missions-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.mission-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 6px 12px;
  transition: background 0.15s;
}
.mission-item:hover { background: var(--rose-pale); }
.mission-item.done .mission-text {
  color: var(--text-mute);
  text-decoration: line-through;
}
.mission-item.done .mission-check { color: var(--rose); }

.mission-check {
  background: none;
  border: 1.5px solid var(--border-lit);
  color: var(--text-mute);
  font-size: 9px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 4px;
  transition: all 0.15s;
  padding: 0;
}
.mission-check:hover { border-color: var(--rose); color: var(--rose); }

.mission-icon { font-size: 12px; flex-shrink: 0; line-height: 1.4; }
.mission-text { font-size: 11px; color: var(--text); line-height: 1.45; }

/* ── Notificación misión ── */

/* ================================================
   NOTIFICACIONES DE MISIÓN (Refinado) ✨
   ================================================ */

/* Contenedor base de la notificación */
.mission-notif {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%); /* Fuera de pantalla al inicio */
  width: 100%;
  max-width: 380px;
  background: rgba(255, 248, 254, 0.9); /* --surface-1 con transparencia */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--rose-light);
  border-radius: var(--radius-xl);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 1000;
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

/* Estado visible (activado por JS) */
.mission-notif.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Icono/Emoji con animación de brillo */
.notif-icon {
  font-size: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sparkle 3s ease-in-out infinite;
}

/* Bloque de texto */
.notif-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Título de la notificación (Misión Lograda) */
.notif-text b {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--rose);
  text-transform: uppercase;
}

/* Descripción de la misión */
.notif-text span {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  font-weight: 500;
}

/* ── Estilo Especial: Vínculo Fortalecido ── */
.mission-notif-special {
  border-color: var(--lavender-light);
  background: rgba(250, 245, 255, 0.92);
  box-shadow: 0 0 30px rgba(184, 153, 216, 0.35), var(--shadow-md);
}

.mission-notif-special .notif-text b {
  color: var(--lavender);
}

.mission-notif-special .notif-icon {
  filter: drop-shadow(0 0 8px var(--lavender-pale));
}

/* Responsivo: Ajuste para móviles */
@media (max-width: 480px) {
  .mission-notif {
    width: 90%;
    padding: 12px 18px;
    top: 16px;
  }
  .notif-icon { font-size: 24px; }
  .notif-text span { font-size: 13px; }
}

/* ── Indicador stats ── */

.dmsg.stat-changes { padding: 3px 0; opacity: 0.9; }

.stat-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.stat-chip {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border: 1.5px solid;
  border-radius: 99px;
  white-space: nowrap;
}
.stat-chip.stat-up {
  color: var(--mint);
  border-color: var(--mint-light);
  background: var(--mint-pale);
}
.stat-chip.stat-down {
  color: var(--rose);
  border-color: var(--rose-light);
  background: var(--rose-pale);
}

/* ── Nivel de relación ── */

.relation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 4px;
  border-bottom: 1px solid var(--border);
}

.relation-label {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  text-transform: uppercase;
}

.relation-badge {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border: 1.5px solid;
  border-radius: 99px;
  transition: all 0.4s ease;
  letter-spacing: 0.02em;
}

/* ── Misiones dinámicas ── */
.missions-history-label {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mint);
  padding: 5px 12px 6px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.mission-notif-special {
  border-color: var(--lavender-light) !important;
  box-shadow: 0 0 30px rgba(184,153,216,0.4) !important;
}
.mission-notif-special .notif-text b {
  color: var(--lavender) !important;
}

/* ── Notificación de logro ── */
.achiev-notif {
  position: fixed;
  top: 20px;
  right: -320px;
  width: 280px;
  background: rgba(255,248,254,0.97);
  backdrop-filter: blur(16px);
  border: 2px solid var(--gold);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 400;
  box-shadow: 0 4px 24px rgba(201,168,76,0.3);
  transition: right 0.45s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}
.achiev-notif.visible { right: 16px; }

.achiev-notif-icon { font-size: 24px; flex-shrink: 0; }

.achiev-notif-text { display: flex; flex-direction: column; gap: 1px; }
.achiev-notif-text b {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
}
.achiev-notif-text span { font-size: 13px; color: var(--text); font-weight: 600; }
.achiev-notif-text small { font-size: 11px; color: var(--text-dim); font-style: italic; }

/* ================================================
   ANIMACIÓN DE CONFETI ✨
   ================================================ */

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 500; /* Por encima de la aldea, por debajo del diálogo si es necesario */
  pointer-events: none; /* Crucial: para que el confeti no bloquee el ratón */
}