:root {
  --red: #cc0000;
  --red-dark: #990000;
  --yellow: #ffcb05;
  --yellow-dark: #d4a800;
  --blue: #3b4cca;
  --ink: #2b2b33;
  --muted: #8a8a93;
  --card-bg: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  --shadow-hover: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Baloo 2", "Comic Sans MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 203, 5, 0.18) 0, transparent 35%),
    radial-gradient(circle at 85% 10%, rgba(204, 0, 0, 0.12) 0, transparent 35%),
    radial-gradient(circle at 90% 85%, rgba(59, 76, 202, 0.14) 0, transparent 35%),
    linear-gradient(180deg, #fff8e1 0%, #ffefc0 40%, #ffe9a8 100%);
  min-height: 100vh;
  background-attachment: fixed;
}

/* ---------- Header ---------- */
.header {
  position: relative;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  text-align: center;
  padding: 2.6rem 1rem 2.2rem;
  box-shadow: 0 6px 20px rgba(204, 0, 0, 0.4);
  border-bottom: 6px solid var(--yellow);
  overflow: hidden;
}

.header-text {
  position: relative;
  z-index: 2;
}

.logo {
  font-family: "Luckiest Guy", "Baloo 2", cursive;
  font-size: clamp(3rem, 8vw, 5rem);
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--blue), 5px 5px 0 rgba(0, 0, 0, 0.35);
  line-height: 1.1;
}

.logo span {
  color: #fff;
  text-shadow: 3px 3px 0 var(--blue), 5px 5px 0 rgba(0, 0, 0, 0.35);
}

.tagline {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  margin-top: 0.5rem;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

/* Pokébola decorativa */
.pokeball {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #fff 0 48%, #222 48% 52%, #fafafa 52% 100%);
  border: 5px solid #222;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.35);
  opacity: 0.28;
  animation: spin 14s linear infinite;
}

.pokeball::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid #222;
  box-shadow: inset 0 0 0 4px #fff;
}

.pokeball-left { left: -20px; top: 20px; }
.pokeball-right { right: -20px; top: 20px; animation-direction: reverse; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------- Toolbar ---------- */
.toolbar {
  max-width: 1400px;
  margin: 1.6rem auto 0;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.search-box { flex: 1 1 320px; max-width: 560px; }

.search-box input {
  width: 100%;
  padding: 0.85rem 1.2rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border: 3px solid var(--yellow);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 76, 202, 0.2), 0 4px 12px rgba(0, 0, 0, 0.12);
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  border: 3px solid var(--yellow);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.sort-box label { font-weight: 700; font-size: 0.95rem; }

.sort-box select {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  background: transparent;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

/* ---------- Filtros de tipo ---------- */
.type-filters {
  max-width: 1400px;
  margin: 1.2rem auto 0;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.type-filter {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  opacity: 0.45;
  transform: scale(0.95);
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.type-filter:hover { opacity: 0.8; transform: scale(1.02); }
.type-filter.active { opacity: 1; transform: scale(1.05); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }

.type-filter-all {
  background: linear-gradient(135deg, var(--red), var(--blue));
  opacity: 1;
  color: #fff;
}
.type-filter-all.active { box-shadow: 0 0 0 3px var(--yellow); }

/* ---------- Contador ---------- */
.counter {
  max-width: 1400px;
  margin: 1.4rem auto 0;
  padding: 0 1rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--blue);
  text-align: center;
}

/* ---------- Grid ---------- */
.grid {
  max-width: 1400px;
  margin: 1.4rem auto 0;
  padding: 0 1rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.8rem;
}

/* ---------- Carta Pokémon ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border: 3px solid #fff;
  outline: none;
  animation: card-in 0.45s ease both;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-hover);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-top {
  background: var(--t1, #ccc);
  background: linear-gradient(135deg, var(--t1, #ccc), color-mix(in srgb, var(--t1, #ccc) 55%, #111));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.8rem 1.1rem;
}

.dex-id {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.card-name {
  font-family: "Luckiest Guy", "Baloo 2", cursive;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

.card-img {
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.9) 0, rgba(240, 240, 240, 0.55) 60%, transparent 70%),
    linear-gradient(180deg, #f6f6f6, #e8e8ec);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 0.8rem;
}

.card-img img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.22));
  transition: transform 0.25s ease;
}

.card:hover .card-img img,
.card:focus-visible .card-img img {
  transform: scale(1.12) rotate(-4deg);
}

.card-body {
  padding: 0.9rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1;
}

.card-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.type-chip {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.card-desc {
  font-size: 0.9rem;
  line-height: 1.35;
  color: #555;
  font-weight: 600;
}

.card-stats {
  display: grid;
  gap: 0.3rem;
  background: #f4f4f7;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
}

.stat-row {
  display: grid;
  grid-template-columns: 34px 1fr 32px;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.stat-value {
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.stat-track {
  height: 8px;
  border-radius: 999px;
  background: #ddd;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.section {
  border-top: 2px dashed #e5e5ea;
  padding-top: 0.7rem;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--blue);
  margin-bottom: 0.4rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.muted {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Evoluciones ---------- */
.evo-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.evo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  background: #f4f4f7;
  border-radius: 12px;
  padding: 0.35rem 0.5rem;
  border: 2px solid transparent;
}

.evo-node img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.evo-node span {
  font-size: 0.68rem;
  font-weight: 800;
  color: #555;
}

.evo-node.is-current {
  border-color: var(--yellow);
  background: #fffbe8;
  box-shadow: 0 0 0 3px rgba(255, 203, 5, 0.4);
}

.evo-node.is-current span { color: var(--blue); }

.evo-arrow {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--red);
}

.evo-branch {
  display: flex;
  gap: 0.3rem;
}

.evo-none {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Estado vacío ---------- */
.empty {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--blue);
  padding: 3rem 1rem;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #232a7a);
  border-top: 6px solid var(--yellow);
  font-weight: 700;
}

.footer-note {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 0.3rem;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 40, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #fff;
  border-radius: 22px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  animation: pop-in 0.3s ease;
  border: 4px solid var(--yellow);
}

@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-top {
  position: relative;
  background: var(--t1, #ccc);
  background: linear-gradient(135deg, var(--t1, #ccc), color-mix(in srgb, var(--t1, #ccc) 50%, #111));
  color: #fff;
  padding: 1.4rem 1.4rem 4.5rem;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(90deg);
}

.modal-title {
  font-family: "Luckiest Guy", "Baloo 2", cursive;
  font-size: 2rem;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.modal-dex {
  font-size: 0.85rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  display: inline-block;
  margin-top: 0.3rem;
}

.modal-img-wrap {
  display: flex;
  justify-content: center;
  margin-top: -60px;
  position: relative;
  z-index: 2;
}

.modal-img-wrap img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.3));
}

.modal-body {
  padding: 1rem 1.4rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.modal-types { display: flex; justify-content: center; gap: 0.5rem; }

.modal-desc {
  text-align: center;
  font-size: 0.95rem;
  color: #555;
  font-weight: 600;
  line-height: 1.4;
}

.modal-facts {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.fact {
  background: #f4f4f7;
  border-radius: 12px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: #555;
}

.fact b { display: block; color: var(--blue); font-size: 0.95rem; }

.modal-section .section-title { font-size: 0.9rem; }

.mult { font-size: 0.6rem; vertical-align: super; font-weight: 800; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .pokeball { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .sort-box { justify-content: center; }
}
