:root {
  --red: #EE1515;
  --red-dark: #C41010;
  --blue: #3B4CCA;
  --blue-dark: #2A35A0;
  --yellow: #FFCB05;
  --yellow-dark: #C7A008;
  --black: #1A1A1A;
  --white: #FFFFFF;
  --gray-light: #F0F0F0;
  --gray: #999999;
  --gray-dark: #555555;
  --bg-card: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --shadow-red: rgba(238, 21, 21, 0.15);
  --shadow-blue: rgba(59, 76, 202, 0.15);
}

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

body {
  font-family: 'Exo 2', 'Segoe UI', Tahoma, sans-serif;
  background-color: #f8f8f8;
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='60' cy='60' r='28' fill='none' stroke='%23ddd' stroke-width='2'/%3E%3Cpath d='M32 60 a28 28 0 0 1 56 0' fill='none' stroke='%23ddd' stroke-width='2'/%3E%3Cline x1='32' y1='60' x2='88' y2='60' stroke='%23ddd' stroke-width='2'/%3E%3Ccircle cx='60' cy='60' r='9' fill='none' stroke='%23ddd' stroke-width='2'/%3E%3Ccircle cx='60' cy='60' r='3' fill='%23ddd'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 120px 120px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
  transform: rotate(-15deg);
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(248, 248, 248, 0.55);
  pointer-events: none;
  z-index: 0;
}

.bg-pokeballs {
  display: none;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 30px 0 20px;
}

.logo-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.pokeball-logo {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
  animation: ballBounce 3s infinite ease-in-out;
}

@keyframes ballBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--red);
  line-height: 1;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.search-bar {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 14px 20px 14px 50px;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  background: var(--white);
  color: var(--text-primary);
  font-family: 'Exo 2', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-bar input::placeholder {
  color: var(--gray);
}

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

.gen-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.gen-btn {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 20px;
  border: 2px solid var(--red);
  border-radius: 30px;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.gen-btn:hover {
  background: var(--red);
  color: var(--white);
  box-shadow: 0 4px 15px var(--shadow-red);
}

.gen-btn.active {
  background: var(--red);
  color: var(--white);
  box-shadow: 0 4px 15px var(--shadow-red);
}

.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 20px;
  padding: 20px 0 40px;
}

.pokemon-card {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.75) 0%,
    rgba(255, 255, 255, 0.45) 40%,
    rgba(255, 255, 255, 0.35) 60%,
    rgba(255, 255, 255, 0.65) 100%
  );
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-radius: 22px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(0, 0, 0, 0.04);
}

.pokemon-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  border-radius: 22px 22px 0 0;
  pointer-events: none;
  z-index: 0;
}

.pokemon-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    ellipse at 30% 20%,
    rgba(255, 255, 255, 0.4) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 0;
}

.pokemon-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(238, 21, 21, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.03);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.85) 0%,
    rgba(255, 255, 255, 0.55) 40%,
    rgba(255, 255, 255, 0.45) 60%,
    rgba(255, 255, 255, 0.75) 100%
  );
}

.pokemon-card img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
  transition: transform 0.3s;
  position: relative;
  z-index: 1;
}

.pokemon-card:hover img {
  transform: scale(1.12) translateY(-3px);
}

.pokemon-card .pokemon-id {
  font-size: 0.8rem;
  color: var(--gray);
  margin-bottom: 4px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.pokemon-card .pokemon-name {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: capitalize;
  margin-top: 8px;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.pokemon-card .pokemon-types {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.type-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.loading {
  text-align: center;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading p {
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.loading.hidden {
  display: none;
}

.pokeball-spin {
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='48' fill='%23fff' stroke='%23111' stroke-width='4'/%3E%3Cpath d='M2 50 a48 48 0 0 1 96 0 Z' fill='%23EE1515'/%3E%3Ccircle cx='50' cy='50' r='48' fill='none' stroke='%23111' stroke-width='4'/%3E%3Cline x1='2' y1='50' x2='98' y2='50' stroke='%23111' stroke-width='5'/%3E%3Ccircle cx='50' cy='50' r='14' fill='%23fff' stroke='%23111' stroke-width='5'/%3E%3Ccircle cx='50' cy='50' r='5' fill='%23111'/%3E%3C/svg%3E") center/contain no-repeat;
}

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

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--white);
  border-radius: 24px;
  padding: 40px;
  max-width: 480px;
  width: 90%;
  position: relative;
  border: 2px solid var(--red);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 0 40px var(--shadow-red);
  overflow: hidden;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.04;
}

.modal-content::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0.04;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: var(--red);
  border: none;
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  font-weight: 700;
}

.modal-close:hover {
  background: var(--red-dark);
  transform: scale(1.1);
}

.modal-content > img {
  display: block;
  margin: 0 auto 16px;
  width: 200px;
  height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.15));
  position: relative;
  z-index: 1;
  animation: modalPokeEnter 0.4s ease;
}

@keyframes modalPokeEnter {
  from { transform: scale(0.5) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-content h2 {
  text-align: center;
  text-transform: capitalize;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.modal-content .modal-id {
  text-align: center;
  color: var(--gray);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.modal-types {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.modal-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-label {
  width: 110px;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-bar {
  flex: 1;
  height: 10px;
  background: #eee;
  border-radius: 5px;
  overflow: hidden;
}

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

.stat-value {
  width: 35px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-physical {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
}

.modal-physical span {
  display: flex;
  align-items: center;
  gap: 4px;
}

footer {
  text-align: center;
  padding: 40px 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-ball {
  opacity: 0.25;
}

footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

footer a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover {
  color: var(--red);
}

@media (max-width: 600px) {
  header h1 {
    font-size: 2.5rem;
    letter-spacing: 2px;
  }
  .pokeball-logo {
    width: 44px;
    height: 44px;
  }
  .pokemon-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 12px;
  }
  .pokemon-card {
    padding: 14px;
  }
  .pokemon-card img {
    width: 90px;
    height: 90px;
  }
  .modal-content {
    padding: 24px;
  }
  .modal-content > img {
    width: 150px;
    height: 150px;
  }
  .gen-btn {
    padding: 6px 14px;
    font-size: 0.7rem;
  }
}
