/* ==========================================================================
   KME Guías · Puntúa mis Armamentos
   Tema morado / negro. Sistema de puntuación por Davor (@davor5647).
   ========================================================================== */

:root {
  /* Fondos */
  --bg-0: #0b0713;
  --bg-1: #120b1f;
  --bg-2: #1a1030;
  --surface: #181026;
  --surface-2: #211538;
  --surface-hover: #2a1a48;

  /* Bordes */
  --border: #2e2247;
  --border-strong: #3d2c63;

  /* Morados de acento */
  --accent: #a855f7;
  --accent-2: #8b5cf6;
  --accent-bright: #c084fc;
  --accent-soft: rgba(168, 85, 247, 0.15);
  --accent-glow: rgba(168, 85, 247, 0.45);

  /* Texto */
  --text: #ece7f7;
  --text-2: #b7abd6;
  --text-3: #8578a6;

  /* Rareza de inscripciones (colores del juego) */
  --special: #fdd451;
  --special-bg: rgba(253, 212, 81, 0.12);
  --rare: #60a5fa;
  --rare-bg: rgba(96, 165, 250, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 15% -5%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(168, 85, 247, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ---------------------------------------------------------------- Hero --- */
.hero { text-align: center; margin-bottom: 26px; }

.hero-title {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #fff 20%, var(--accent-bright) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-title .byline {
  font-size: 0.5em;
  font-weight: 600;
  color: var(--text-2);
  -webkit-text-fill-color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hero-title .davor-icon {
  width: 30px; height: 45px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

.hero-sub {
  color: var(--text-2);
  margin: 0;
  font-size: clamp(14px, 2vw, 17px);
}

/* --------------------------------------------------------------- Tabs ---- */
.tabbar {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.tab.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* -------------------------------------------------------------- Panels --- */
.panel {
  background: linear-gradient(180deg, rgba(33, 21, 56, 0.55), rgba(24, 16, 38, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(4px);
}

.intro p { margin: 0; color: var(--text-2); font-size: 14.5px; }
.intro strong { color: var(--accent-bright); font-weight: 600; }

.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 700;
  margin: 4px 0 10px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.grid-2col + .grid-2col { margin-top: 22px; }
.col { min-width: 0; }

/* La primera cuadrícula estira sus columnas para que la lista de comandantes
   rellene el hueco a la izquierda de Formación + Inscripciones. */
.grid-2col:not(.stats-row) > .col { display: flex; flex-direction: column; }

/* --------------------------------------------------- Troop selector ------ */
.troop-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.selector-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.selector-btn img { width: 22px; height: 22px; object-fit: contain; }
.selector-btn:hover { background: var(--surface-hover); color: var(--text); }
.selector-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent) inset, 0 4px 18px var(--accent-glow);
}

/* --------------------------------------------------- Pairing list -------- */
.pairing-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 0;          /* crece para rellenar la altura de la columna */
  min-height: 0;        /* permite el scroll interno al rellenar */
  overflow-y: auto;
  padding-right: 6px;
  transition: opacity .15s;
}
.pairing-selector.fade-out { opacity: 0; }

.pairing-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.pairing-item:hover { background: var(--surface-hover); }
.pairing-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pairing-item span { font-size: 14.5px; color: var(--text); }

.pairing-images { position: relative; display: flex; flex-shrink: 0; }
.commander-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-strong);
  background: var(--bg-2);
}
.commander-icon.secondary { margin-left: -14px; }

/* --------------------------------------------------- Formations ---------- */
.formation-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.formation-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.formation-btn img { width: 34px; height: 34px; object-fit: contain; }
.formation-btn:hover { background: var(--surface-hover); color: var(--text); }
.formation-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent) inset, 0 4px 18px var(--accent-glow);
}

/* --------------------------------------------------- Inscriptions -------- */
.search {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search::placeholder { color: var(--text-3); }

.inscription-box {
  max-height: 230px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(11, 7, 19, 0.4);
  transition: opacity .15s;
}
.inscription-box.fade-out { opacity: 0; }

.inscription-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.inscription-tag {
  --chip: var(--text-2);
  --chip-bg: var(--surface-2);
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--chip);
  background: var(--chip-bg);
  border: 1px solid var(--border-strong);
  user-select: none;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.inscription-tag:hover { transform: translateY(-1px); }
.inscription-tag.special {
  --chip: var(--special);
  --chip-bg: var(--special-bg);
  border-color: rgba(253, 212, 81, 0.5);
}
.inscription-tag.rare {
  --chip: var(--rare);
  --chip-bg: var(--rare-bg);
  border-color: rgba(96, 165, 250, 0.5);
}
.inscription-tag.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: var(--accent-bright);
  box-shadow: 0 3px 14px var(--accent-glow);
}

.inscription-placeholder {
  color: var(--text-3);
  font-size: 13.5px;
  text-align: center;
  padding: 24px 12px;
  margin: 0;
}

/* --------------------------------------------------- Stat inputs --------- */
.stat-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: start;
}
.stat-field { display: flex; flex-direction: column; gap: 6px; }
.stat-field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.stat-field input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.stat-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat-field input::placeholder { color: var(--text-3); }

/* --------------------------------------------------- Selected panel ------ */
.selected-box {
  min-height: 120px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(11, 7, 19, 0.4);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.selected-box.filled {
  min-height: 0;
  align-items: flex-start;
  justify-content: flex-start;
}
.selected-box .inscription-grid {
  align-self: flex-start;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  padding: 0;
}

/* --------------------------------------------------- Result bar ---------- */
.result-bar {
  margin-top: 24px;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(168, 85, 247, 0.08));
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.score { font-size: 18px; color: var(--text-2); }
.score strong {
  font-size: 30px;
  color: #fff;
  font-weight: 800;
  margin-left: 6px;
  text-shadow: 0 2px 14px var(--accent-glow);
}
.score.pulse strong { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }

.result-actions { display: flex; gap: 10px; }
.btn {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: var(--accent-bright);
  color: #fff;
}
.btn.primary:hover { box-shadow: 0 4px 18px var(--accent-glow); }
.btn.copied { border-color: #34d399; color: #6ee7b7; }

.last-updated {
  text-align: right;
  color: var(--text-3);
  font-size: 12.5px;
  font-style: italic;
  margin: 12px 2px 0;
}

/* --------------------------------------------------- About --------------- */
.about h2 { margin: 0 0 12px; font-size: 20px; color: var(--text); }
.about p { color: var(--text-2); font-size: 14.5px; margin: 0 0 12px; }
.about .support {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  font-weight: 600;
}

.footer-note {
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  margin-top: 26px;
}

/* --------------------------------------------------- Tooltip ------------- */
.inscription-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 300px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(16, 10, 28, 0.97);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .14s ease, transform .14s ease;
  display: none;
  backdrop-filter: blur(6px);
}
.inscription-tooltip.visible { opacity: 1; transform: translateY(0); }
.inscription-tooltip strong {
  display: block;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-bright);
}
.inscription-tooltip .cooldown {
  display: block;
  margin-top: 8px;
  color: #ff9b9b;
  font-weight: 600;
}

/* --------------------------------------------- Aviso de límite ----------- */
.warn-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  z-index: 1100;
  max-width: min(90vw, 440px);
  padding: 13px 20px;
  border-radius: 12px;
  background: rgba(34, 14, 20, 0.97);
  border: 1px solid rgba(248, 113, 113, 0.6);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  color: #fecaca;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(6px);
}
.warn-toast.visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes tag-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}
.inscription-tag.blocked {
  animation: tag-shake .3s ease;
  border-color: rgba(248, 113, 113, 0.8);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.5);
}

/* --------------------------------------------------- Scrollbars ---------- */
.pairing-selector::-webkit-scrollbar,
.inscription-box::-webkit-scrollbar { width: 9px; }
.pairing-selector::-webkit-scrollbar-thumb,
.inscription-box::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.pairing-selector::-webkit-scrollbar-track,
.inscription-box::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------- Responsive ---------- */
@media (max-width: 760px) {
  .grid-2col { grid-template-columns: 1fr; gap: 22px; }
  .grid-2col:not(.stats-row) > .col { display: block; }
  .pairing-selector { max-height: 360px; }
  .troop-selector { gap: 8px; }
  .selector-btn { flex-direction: column; gap: 6px; padding: 12px 6px; font-size: 13px; }
  .result-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .result-actions { justify-content: center; }
  .last-updated { text-align: center; }
}
