/* ============================================================================
   AoE Guesser — CSS propio del plugin.
   El plugin core aporta las variables medievales (--aoe2mg-*).
   Este CSS usa esas vars cuando están disponibles y tiene fallbacks.
   ============================================================================ */

.ag-game {
  /* Ancho completo: el grid de civs es auto-fill, así que cuantos más
     píxeles, más cards por fila (4 a 760px, ~12 en pantallas anchas). */
  max-width: none;
  margin: 24px auto;
  padding: 0 22px;
  font-family: var(--aoe2mg-font-body, "Segoe UI", system-ui, sans-serif);
  color: var(--aoe2mg-text, #f1e6d2);
  box-sizing: border-box;
}

/* El theme envuelve las páginas en .aoe2mg-page (max-width 760px).
   Cuando la página contiene el juego, liberamos ese límite desde aquí:
   el theme no debe conocer los minijuegos (SoC), así que el override
   vive en el CSS del plugin. */
.aoe2mg-page:has(.ag-game) {
  max-width: none;
}

.ag-game *,
.ag-game *::before,
.ag-game *::after {
  box-sizing: border-box;
}

/* ----- Flash ---------------------------------------------------------- */
.ag-flash {
  padding: 12px 16px;
  border-radius: var(--aoe2mg-radius, 6px);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
}
.ag-flash--success {
  background: rgba(110, 163, 74, 0.18);
  color: #b6dba0;
  border-color: #6ea34a;
}
.ag-flash--error {
  background: rgba(193, 74, 58, 0.2);
  color: #f0a89d;
  border-color: #c14a3a;
}
.ag-flash--info {
  background: rgba(252, 171, 89, 0.12);
  color: var(--aoe2mg-accent, #fcab59);
}

/* ----- Hero ----------------------------------------------------------- */
.ag-game__pill {
  display: inline-block;
  padding: 4px 12px;
  background: var(--aoe2mg-panel-2, #362820);
  color: var(--aoe2mg-text, #f1e6d2);
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  position: relative;
}

.ag-game__pill strong {
  color: var(--aoe2mg-accent, #fcab59);
}

/* ----- Pista ---------------------------------------------------------- */
/* Fila: card completa de la civ pista a la izquierda + panel de "Pistas
   desbloqueadas" a su derecha. */
.ag-pista-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 320px);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 18px;
}

@media (max-width: 860px) {
  .ag-pista-row {
    grid-template-columns: 1fr;
  }
}

.ag-pista {
  background: linear-gradient(
    135deg,
    #2d3540 0%,
    var(--aoe2mg-bg-alt, #1a1410) 100%
  );
  border: 2px solid var(--aoe2mg-accent, #fcab59);
  border-radius: var(--aoe2mg-radius-lg, 10px);
  padding: 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
}

.ag-pista__shield {
  width: 96px;
  height: 96px;
  border-radius: var(--aoe2mg-radius, 6px);
  border: 2px solid var(--aoe2mg-border, #4a3a2d);
}

.ag-pista__name {
  font-size: 22px;
  font-weight: 700;
  color: var(--aoe2mg-accent, #fcab59);
  margin-bottom: 8px;
}

.ag-pista__props {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 10px;
}

/* ----- Panel "Pistas desbloqueadas" ----------------------------------- */
.ag-pista-unlocked {
  background: var(--aoe2mg-panel, #2b211a);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius-lg, 10px);
  padding: 12px 14px;
}

.ag-pista-unlocked__title {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--aoe2mg-accent, #fcab59);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ag-pista-unlocked__title i {
  margin-right: 5px;
}

.ag-pista-unlocked__props {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Chips compactos en fila (icono + prop + valor). */
.ag-pista-unlocked__props .ag-prop {
  flex-direction: row;
  align-items: center;
  min-height: 0;
  padding: 5px 9px;
}

/* Prop aun bloqueada: candado, sin revelar el valor. */
.ag-pista-unlocked__props .ag-prop--locked {
  background: var(--aoe2mg-bg-alt, #221a14);
  border: 1px dashed var(--aoe2mg-border, #4a3a2d);
  color: #777;
}
.ag-pista-unlocked__props .ag-prop--locked i {
  color: #777;
  font-size: 11px;
}
.ag-pista-unlocked__props .ag-prop--locked strong {
  color: #999;
  font-weight: 600;
}

.ag-pista__badge {
  background: var(--aoe2mg-accent, #fcab59);
  color: var(--aoe2mg-bg, #1a1410);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* ----- Reveal (final de partida) -------------------------------------- */
.ag-reveal {
  background: linear-gradient(135deg, #3a7a3a 0%, #2d5a2d 100%);
  border: 2px solid #5b9e5b;
  border-radius: var(--aoe2mg-radius-lg, 10px);
  padding: 20px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
}

.ag-reveal--gave_up {
  background: linear-gradient(135deg, #a44 0%, #7a2d2d 100%);
  border-color: #d44;
}

.ag-reveal__shield {
  width: 110px;
  height: 110px;
  border-radius: var(--aoe2mg-radius, 6px);
  border: 3px solid rgba(255, 255, 255, 0.2);
}

.ag-reveal__name {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}

.ag-reveal__meta {
  color: #fff;
  opacity: 0.85;
  font-size: 13px;
  margin-top: 4px;
}

/* ----- Props coloreados ---------------------------------------------- */
.ag-prop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--aoe2mg-text, #f1e6d2);
  padding: 8px 10px;
  border-radius: var(--aoe2mg-radius, 6px);
  min-height: 58px;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  text-align: left;
}

.ag-prop i {
  color: var(--aoe2mg-accent, #fcab59);
  font-size: 13px;
  line-height: 1;
}
.ag-prop strong {
  color: #e8e8e8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.ag-prop--match {
  background: #2d5a2d !important;
  color: #b8e0b8 !important;
  border: 1px solid #3a7a3a;
}
.ag-prop--partial {
  background: #7a5a2d !important;
  color: #f0d090 !important;
  border: 1px solid #b8862d;
}
.ag-prop--none {
  background: var(--aoe2mg-panel, #2b211a) !important;
  color: #999 !important;
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
}

/* ----- Attempts (lista de intentos previos) -------------------------- */
.ag-attempts-title,
.ag-grid-title {
  font-family: var(--aoe2mg-font-display, Georgia, serif);
  color: var(--aoe2mg-text, #f1e6d2);
  font-size: 18px;
  margin: 18px 0 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ag-attempts-count {
  background: var(--aoe2mg-accent, #fcab59);
  color: var(--aoe2mg-bg, #1a1410);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.ag-attempts {
  list-style: none;
  padding: 0;
  margin: 0 0 18px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ag-attempt {
  background: var(--aoe2mg-panel, #2b211a);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius, 6px);
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
}

.ag-attempt--correct {
  background: linear-gradient(135deg, #3a7a3a 0%, #2d5a2d 100%);
  border-color: #5b9e5b;
}

.ag-attempt__shield {
  width: 56px;
  height: 56px;
  border-radius: var(--aoe2mg-radius, 6px);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
}

.ag-attempt__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--aoe2mg-text, #f1e6d2);
  margin-bottom: 6px;
}

.ag-attempt--correct .ag-attempt__name {
  color: #fff;
}

.ag-attempt__props {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}

.ag-attempt__props .ag-prop {
  min-height: 0;
  padding: 4px 6px;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.ag-attempt__props .ag-prop i {
  font-size: 10px;
}
.ag-attempt__props .ag-prop strong {
  display: none;
}

/* ----- Grid clickeable ------------------------------------------------ */
.ag-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 18px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.ag-civ {
  background: var(--aoe2mg-panel, #2b211a);
  border: 2px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius, 6px);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  user-select: none;
}

.ag-civ:hover:not(.is-attempted):not(.is-disabled) {
  border-color: var(--aoe2mg-accent, #fcab59);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(252, 171, 89, 0.2);
}

.ag-civ.is-attempted {
  background: #15110d;
  opacity: 0.7;
  cursor: default;
}

.ag-civ.is-attempted::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.04) 6px,
    rgba(255, 255, 255, 0.04) 12px
  );
  border-radius: var(--aoe2mg-radius, 6px);
  pointer-events: none;
}

.ag-civ.is-disabled {
  cursor: default;
  opacity: 0.7;
}

.ag-civ.is-loading {
  cursor: wait;
  border-color: var(--aoe2mg-accent, #fcab59);
  animation: ag-pulse 1.2s ease-in-out infinite;
}

@keyframes ag-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(252, 171, 89, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(252, 171, 89, 0);
  }
}

.ag-grid.is-busy {
  pointer-events: none;
  opacity: 0.85;
}

/* ----- Aviso de límite alcanzado ------------------------------------- */
.ag-limit-warning {
  background: rgba(193, 74, 58, 0.2);
  color: #f0a89d;
  border: 1px solid #c14a3a;
  border-radius: var(--aoe2mg-radius, 6px);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ag-limit-warning i {
  color: #f0a89d;
  font-size: 18px;
}

/* ----- Bienvenida (estado idle) -------------------------------------- */
.ag-welcome {
  background: linear-gradient(
    135deg,
    var(--aoe2mg-panel, #2b211a) 0%,
    var(--aoe2mg-bg-alt, #221a14) 100%
  );
  border: 1px dashed var(--aoe2mg-accent, #fcab59);
  border-radius: var(--aoe2mg-radius-lg, 10px);
  padding: 22px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--aoe2mg-text, #f1e6d2);
}
.ag-welcome i {
  color: var(--aoe2mg-accent, #fcab59);
  font-size: 28px;
}
.ag-welcome p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}
.ag-welcome strong {
  color: var(--aoe2mg-accent, #fcab59);
}

.ag-civ__shield {
  width: 56px;
  height: 56px;
  border-radius: var(--aoe2mg-radius, 6px);
  margin: 0 auto 8px;
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  display: block;
}

.ag-civ__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--aoe2mg-text, #f1e6d2);
}

/* ----- Botones -------------------------------------------------------- */
.ag-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 18px 0;
  flex-wrap: wrap;
}

.ag-actions--top {
  margin: 0 0 18px 0;
  padding: 12px 18px;
  background: linear-gradient(
    135deg,
    var(--aoe2mg-panel, #2b211a) 0%,
    var(--aoe2mg-bg-alt, #221a14) 100%
  );
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius-lg, 10px);
  position: sticky;
  top: 12px;
  z-index: 50;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  justify-content: flex-end;
  align-items: center;
}

/* Descripción del juego, integrada en la barra (a la izquierda). */
.ag-actions__desc {
  flex: 1 1 260px;
  margin: 0;
  text-align: left;
  font-size: 13px;
  color: var(--aoe2mg-text-muted, #b5a48a);
}

.ag-actions--top .ag-btn {
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.ag-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--aoe2mg-radius, 6px);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.ag-btn--primary {
  background: var(--aoe2mg-accent, #fcab59);
  color: var(--aoe2mg-bg, #1a1410);
}
.ag-btn--primary:hover {
  background: var(--aoe2mg-accent-dim, #c9843d);
}

.ag-btn--ghost {
  background: var(--aoe2mg-panel-2, #362820);
  color: var(--aoe2mg-text, #f1e6d2);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
}
.ag-btn--ghost:hover {
  background: var(--aoe2mg-border, #4a3a2d);
}

.ag-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----- Leaderboard ---------------------------------------------------- */
.ag-leaderboard {
  max-width: 720px;
  margin: 24px auto;
  padding: 0 22px;
  font-family: var(--aoe2mg-font-body, "Segoe UI", system-ui, sans-serif);
  color: var(--aoe2mg-text, #f1e6d2);
}

.ag-leaderboard__title {
  font-family: var(--aoe2mg-font-display, Georgia, serif);
  font-size: 22px;
  color: var(--aoe2mg-accent, #fcab59);
  margin: 0 0 4px 0;
}

.ag-leaderboard__sub {
  color: var(--aoe2mg-text-muted, #b5a48a);
  font-size: 13px;
  margin: 0 0 16px 0;
}

.ag-leaderboard__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ag-leaderboard__row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--aoe2mg-panel, #2b211a);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius, 6px);
  padding: 10px 14px;
  margin-bottom: 6px;
}

.ag-leaderboard__rank {
  font-family: var(--aoe2mg-font-display, Georgia, serif);
  color: var(--aoe2mg-accent, #fcab59);
  font-weight: 700;
}

.ag-leaderboard__name {
  font-weight: 600;
}

.ag-leaderboard__score {
  color: var(--aoe2mg-accent, #fcab59);
  font-weight: 700;
}

.ag-leaderboard__games {
  grid-column: 1 / -1;
  color: var(--aoe2mg-text-muted, #b5a48a);
  font-size: 12px;
  margin-top: 2px;
}

.ag-leaderboard__empty {
  color: var(--aoe2mg-text-muted, #b5a48a);
  font-style: italic;
  padding: 20px;
  text-align: center;
  background: var(--aoe2mg-panel, #2b211a);
  border: 1px dashed var(--aoe2mg-border, #4a3a2d);
  border-radius: var(--aoe2mg-radius, 6px);
}

/* ============================================================================
   Detalle inline de card attempted — al adivinar una civ, la card crece
   sutilmente hacia abajo para mostrar el feedback de cada prop.
   ============================================================================ */
.ag-civ__detail {
  display: none; /* Oculto por defecto (cards no intentadas) */
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--aoe2mg-border, #4a3a2d);
  flex-direction: column;
  gap: 4px;
  text-align: left;
  width: 100%;
}

.ag-civ.is-attempted .ag-civ__detail {
  display: flex;
}

.ag-civ.is-attempted .ag-civ__detail .ag-prop {
  /* Las props de las cards son compactas, iguales que en la lista de attempts. */
  min-height: 0;
  padding: 4px 8px;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.35;
}

.ag-civ.is-attempted .ag-civ__detail .ag-prop i {
  font-size: 11px;
}

/* ----- Modal de fin de partida ----------------------------------------- */
.ag-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(14, 11, 8, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
}

.ag-modal-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.ag-modal-content {
  background: var(--aoe2mg-panel, #2b211a);
  background-image: linear-gradient(135deg, #2b211a 0%, #1c1511 100%);
  border: 3px solid #c5a059;
  border-radius: var(--aoe2mg-radius-lg, 10px);
  padding: 30px 40px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(197, 160, 89, 0.15);
  position: relative;
  transform: translateY(-30px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ag-modal-overlay.is-active .ag-modal-content {
  transform: translateY(0) scale(1);
}

.ag-modal-close {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 28px;
  color: #c5a059;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
}

.ag-modal-close:hover {
  color: #fcab59;
}

.ag-modal-title {
  font-family: var(--aoe2mg-font-display, Georgia, serif);
  font-size: 28px;
  color: #fcab59;
  margin: 0 0 10px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

.ag-modal-congrats {
  font-size: 14px;
  color: var(--aoe2mg-text-muted, #b5a48a);
  margin: 0 0 24px 0;
  font-style: italic;
}

.ag-modal-civ-info {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--aoe2mg-border, #4a3a2d);
  border-radius: 8px;
  padding: 20px 40px;
  margin-bottom: 24px;
  min-width: 180px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.ag-modal-shield {
  width: 72px;
  height: 72px;
  margin-bottom: 12px;
  border: 1px solid #c5a059;
  border-radius: var(--aoe2mg-radius, 6px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: ag-bounce-in 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ag-bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.ag-modal-civ-name {
  font-family: var(--aoe2mg-font-display, Georgia, serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--aoe2mg-text, #f1e6d2);
}

.ag-modal-meta {
  font-size: 14px;
  color: var(--aoe2mg-text, #f1e6d2);
  line-height: 1.6;
  margin: 0 0 26px 0;
}

.ag-modal-meta strong {
  color: #10b981;
  font-size: 16px;
}

.ag-modal-restart-btn {
  background: var(--aoe2mg-accent, #fcab59);
  color: var(--aoe2mg-bg, #1a1410);
  border: none;
  font-size: 15px;
  padding: 12px 30px;
  border-radius: var(--aoe2mg-radius, 6px);
  box-shadow: 0 4px 0 #c9843d, 0 6px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ag-modal-restart-btn:hover {
  background: #fdbb74;
}

.ag-modal-restart-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c9843d, 0 4px 10px rgba(0, 0, 0, 0.3);
}

.ag-modal-content--gave-up {
  border-color: #ef4444;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(239, 68, 68, 0.1);
}

.ag-modal-content--gave-up .ag-modal-title {
  color: #f87171;
}

.ag-modal-content--gave-up .ag-modal-shield {
  border-color: #ef4444;
}
