/* === CSS Variables & Theme === */
:root {
  --primary: #00c3e3;
  --primary-10: rgba(0, 195, 227, 0.1);
  --accent: #ff4554;
  --secondary: #c084fc;
  --bg: #ffffff;
  --bg-40: rgba(255, 255, 255, 0.4);
  --bg-50: rgba(255, 255, 255, 0.5);
  --bg-80: rgba(255, 255, 255, 0.8);
  --bg-95: rgba(255, 255, 255, 0.95);
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(0, 0, 0, 0.1);
  --border-40: rgba(0, 0, 0, 0.08);
  --border-50: rgba(0, 0, 0, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-full: 9999px;
  --max-width: 1152px;
  --font-sans: 'Nunito', system-ui, -apple-system, sans-serif;
  --header-h: 64px;
  --bottom-nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-40: rgba(15, 23, 42, 0.4);
  --bg-50: rgba(15, 23, 42, 0.5);
  --bg-80: rgba(15, 23, 42, 0.8);
  --bg-95: rgba(15, 23, 42, 0.95);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --border-40: rgba(255, 255, 255, 0.06);
  --border-50: rgba(255, 255, 255, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }

/* === Background Decoration === */
.bg-decor { position: fixed; inset: 0; z-index: -50; overflow: hidden; pointer-events: none; }
.bg-blob {
  position: absolute; border-radius: 50%; filter: blur(120px);
  opacity: 0.15; transition: opacity 0.3s;
}
[data-theme="dark"] .bg-blob { opacity: 0.08; }
.bg-blob-1 { width: 50vw; height: 50vw; left: -10%; top: -10%; background: var(--primary); }
.bg-blob-2 { width: 60vw; height: 60vw; right: -5%; bottom: -10%; background: var(--accent); }
.bg-blob-3 { width: 30vw; height: 30vw; left: 20%; top: 30%; background: var(--secondary); }

/* === Header === */
.header {
  position: sticky; top: 8px; z-index: 50;
  max-width: var(--max-width); margin: 0 auto;
  padding: 0 12px; transition: all 0.3s;
}
@media (min-width: 640px) { .header { padding: 0 16px; } }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-40);
  background: var(--bg-40);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  ring: 1px solid var(--border-50);
}
.logo {
  display: flex; align-items: center; gap: 8px;
  margin-right: 8px; flex-shrink: 0;
  transition: transform 0.2s;
}
.logo-letter { display: inline-block; }
.logo-letter:hover { animation: logo-bounce 0.4s ease; }
@keyframes logo-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
  50% { transform: translateY(-4px); }
  70% { transform: translateY(-6px); }
}
.logo-icon { width: 32px; height: 32px; }
.logo-text {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.1));
  -webkit-text-stroke: 3px var(--bg); paint-order: stroke fill;
}
@media (min-width: 640px) { .logo-text { font-size: 1.75rem; -webkit-text-stroke-width: 4px; } }

/* === Navigation === */
.nav-desktop { display: none; flex: 1; align-items: center; justify-content: center; gap: 4px; font-size: 0.875rem; font-weight: 600; }
@media (min-width: 768px) { .nav-desktop { display: flex; } }
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-full);
  color: var(--text-muted); transition: all 0.3s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--primary-10); color: var(--primary); }

.nav-dropdown { position: relative; }
.dropdown-menu {
  position: absolute; left: 0; top: 100%; padding-top: 16px;
  min-width: 220px; border-radius: var(--radius-lg);
  border: 1px solid var(--border-40); background: var(--bg-95);
  backdrop-filter: blur(40px); box-shadow: var(--shadow-xl);
  padding: 8px; opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: all 0.3s; z-index: 100;
}
.dropdown-menu-right { left: auto; right: 0; }
.nav-dropdown:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-menu a {
  display: block; padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 600; color: var(--text-muted);
  transition: all 0.3s;
}
.dropdown-menu a:hover { background: var(--primary-10); color: var(--primary); }

/* === Header Actions === */
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); color: var(--text-muted);
  transition: all 0.3s;
}
.btn-icon:hover { background: var(--primary-10); color: var(--primary); }
.btn-icon svg { width: 20px; height: 20px; }

.theme-toggle { position: relative; }
.icon-moon { position: absolute; }
[data-theme="dark"] .icon-sun { display: none; }
:not([data-theme="dark"]) .icon-moon { display: none; }

.mobile-menu-toggle { display: flex; }
@media (min-width: 768px) { .mobile-menu-toggle { display: none; } }

.lang-switcher { display: none; }
@media (min-width: 768px) { .lang-switcher { display: block; } }

/* === Mobile Menu === */
.mobile-menu {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg-95); backdrop-filter: blur(40px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.3s;
}
.mobile-menu.active { opacity: 1; visibility: visible; }
.mobile-nav { display: flex; flex-direction: column; gap: 4px; text-align: center; overflow-y: auto; max-height: 80vh; padding: 16px 0; }
.mobile-nav a {
  padding: 12px 32px; font-size: 1.125rem; font-weight: 600;
  border-radius: var(--radius-lg); transition: all 0.3s;
}
.mobile-nav a:hover { background: var(--primary-10); color: var(--primary); }
.mobile-nav-label {
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 12px 32px 4px;
  opacity: 0.6;
}
.mobile-nav-divider {
  width: 32px; height: 1px; background: var(--border-40); margin: 8px auto;
}

/* === Main Content === */
.main-content {
  max-width: var(--max-width); margin: 0 auto;
  padding: 24px 16px; min-height: calc(100vh - var(--header-h) - 200px);
}
@media (min-width: 640px) { .main-content { padding: 32px 24px; } }

.loading { text-align: center; padding: 60px 0; color: var(--text-muted); font-size: 1.125rem; }

/* === Footer === */
.footer {
  border-top: 1px solid var(--border-40);
  background: var(--bg-80); margin-top: 48px;
}
.footer-inner {
  max-width: var(--max-width); margin: 0 auto;
  padding: 32px 16px; display: grid; gap: 24px;
}
@media (min-width: 768px) {
  .footer-inner { grid-template-columns: 1fr auto 1fr; padding: 48px 24px; }
}
.logo-text-sm { font-size: 1.25rem; font-weight: 800; }
.footer-desc { color: var(--text-muted); font-size: 0.875rem; margin-top: 8px; max-width: 320px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-links a { color: var(--text-muted); font-size: 0.875rem; transition: color 0.3s; }
.footer-links a:hover { color: var(--primary); }
.footer-meta { font-size: 0.75rem; color: var(--text-muted); }
.footer-legal { display: flex; gap: 16px; margin-top: 8px; }
.footer-legal a { color: var(--text-muted); transition: color 0.3s; }
.footer-legal a:hover { color: var(--primary); }

/* === Bottom Mobile Nav === */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h); z-index: 50;
  background: var(--bg-95); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-40);
  justify-content: space-around; align-items: center; padding: 0 8px;
}
@media (max-width: 767px) {
  .bottom-nav { display: flex; }
  .main-content { padding-bottom: calc(var(--bottom-nav-h) + 24px); }
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.625rem; font-weight: 600; color: var(--text-muted);
  padding: 8px 12px; border-radius: var(--radius-md);
  transition: all 0.3s;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 20px; height: 20px; }

/* === Page Components === */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.875rem; color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep::before { content: '›'; }

.page-title {
  font-size: 1.5rem; font-weight: 800; margin-bottom: 8px;
}
@media (min-width: 640px) { .page-title { font-size: 2rem; } }
.page-desc { color: var(--text-muted); margin-bottom: 24px; max-width: 600px; }

/* Filter bar */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px;
}
.filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-full);
  font-size: 0.875rem; font-weight: 500;
  border: 1px solid var(--border-50); background: var(--bg-50);
  color: var(--text); transition: all 0.2s;
}
.filter-btn:hover { transform: scale(1.05); box-shadow: var(--shadow); background: var(--bg-80); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-btn img { width: 18px; height: 18px; flex-shrink: 0; }

.search-input {
  width: 100%; max-width: 400px; padding: 10px 16px;
  border-radius: var(--radius-full); border: 1px solid var(--border-50);
  background: var(--bg-50); color: var(--text);
  font-size: 0.875rem; outline: none; transition: all 0.3s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }
.search-input::placeholder { color: var(--text-muted); }

/* Grid layouts */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }
@media (min-width: 1024px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }

.card-grid-sm {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

/* Card */
.card {
  border-radius: var(--radius-lg); border: 1px solid var(--border-40);
  background: var(--bg-50); padding: 16px;
  transition: all 0.3s; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}
.card-img {
  width: 80px; height: 80px; object-fit: contain; margin-bottom: 8px;
}
.card-img-lg { width: 120px; height: 120px; }
.card-name { font-weight: 700; font-size: 0.875rem; margin-bottom: 4px; }
.card-number { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.card-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 0.7rem; font-weight: 600; text-transform: capitalize;
  background: var(--bg-80); border: 1px solid var(--border-40);
}
.badge img { width: 14px; height: 14px; }

/* Detail page */
.detail-page { max-width: 800px; margin: 0 auto; }
.detail-header { display: flex; align-items: center; gap: 24px; margin-bottom: 24px; }
@media (max-width: 639px) { .detail-header { flex-direction: column; text-align: center; } }
.detail-img { width: 160px; height: 160px; object-fit: contain; }
.detail-name { font-size: 2rem; font-weight: 800; margin: 0; line-height: 1.2; }
.detail-section { margin-bottom: 24px; }
.detail-section h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 12px; }

/* Tag list */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 600;
  background: var(--bg-50); border: 1px solid var(--border-40);
}
.tag img { width: 16px; height: 16px; }

/* Stats/info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-card {
  padding: 16px; border-radius: var(--radius-md);
  background: var(--bg-50); border: 1px solid var(--border-40);
}
.info-card-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em; }
.info-card-value { font-size: 1rem; font-weight: 600; margin-top: 4px; }

/* Pagination / Nav */
.page-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border-40);
}
.page-nav a {
  padding: 12px 24px; border-radius: var(--radius-lg);
  background: var(--bg-50); border: 1px solid var(--border-40);
  font-weight: 600; font-size: 0.875rem; transition: all 0.3s;
}
.page-nav a:hover { background: var(--primary-10); color: var(--primary); border-color: var(--primary); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { text-align: left; padding: 12px; font-weight: 700; border-bottom: 2px solid var(--border-50); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border-40); }
.data-table tr:hover td { background: var(--primary-10); }

/* Recipe card for cooking/crafting */
.recipe-card {
  display: grid; gap: 16px; padding: 20px;
  border-radius: var(--radius-lg); border: 1px solid var(--border-40);
  background: var(--bg-50);
}
@media (min-width: 640px) { .recipe-card { grid-template-columns: auto 1fr; } }
.recipe-ingredients { display: flex; flex-wrap: wrap; gap: 8px; }
.ingredient {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-sm);
  background: var(--bg-80); font-size: 0.8rem;
}

/* Category tabs */
.tab-bar { display: flex; gap: 8px; margin-bottom: 24px; overflow-x: auto; padding-bottom: 8px; }
.tab-btn {
  padding: 8px 20px; border-radius: var(--radius-full);
  font-size: 0.875rem; font-weight: 600;
  border: 1px solid var(--border-50); background: var(--bg-50);
  transition: all 0.2s; white-space: nowrap;
}
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Toast */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: var(--radius-full);
  background: var(--text); color: var(--bg); font-size: 0.875rem;
  font-weight: 600; z-index: 200; opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }

/* Total count */
.total-count {
  font-size: 0.875rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.total-count span { color: var(--primary); }

/* === Habitat Cards Grid === */
.habitat-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
@media (max-width: 639px) {
  .habitat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}

.habitat-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-40);
  background: var(--bg-50);
  padding: 16px;
  transition: all 0.3s;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.habitat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}

.habitat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.habitat-card-id {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.habitat-card-img-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.habitat-card-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.habitat-card-name {
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 8px;
}

.habitat-card-materials {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
}
.habitat-mat {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-80);
  color: var(--text-muted);
  border: 1px solid var(--border-40);
}

.habitat-card-pokemon {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.habitat-card-pokemon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-80);
}
.habitat-more {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* === Habitat Detail Page === */
.habitat-hero {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 32px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-50);
  border: 1px solid var(--border-40);
}
@media (max-width: 639px) {
  .habitat-hero { flex-direction: column; text-align: center; gap: 16px; }
}
.habitat-hero-img-wrap {
  flex-shrink: 0;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--bg-80);
}
.habitat-hero-img {
  width: 140px;
  height: 140px;
  object-fit: contain;
}
.habitat-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.habitat-hero-id {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.habitat-hero-dot {
  color: var(--text-muted);
}
.habitat-hero-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
}
@media (min-width: 640px) {
  .habitat-hero-title { font-size: 2.5rem; }
}

.habitat-recipe {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.habitat-recipe-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-50);
  border: 1px solid var(--border-40);
}
.habitat-recipe-item img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.habitat-recipe-name {
  font-size: 0.875rem;
  font-weight: 600;
}
.habitat-recipe-qty {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
}

.habitat-pokemon-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.habitat-pokemon-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-50);
  border: 1px solid var(--border-40);
}
.habitat-pokemon-img-wrap {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.habitat-pokemon-img-wrap img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.habitat-pokemon-info {
  min-width: 0;
}
.habitat-pokemon-name {
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.habitat-pokemon-id {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.habitat-tips {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.habitat-tip {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-50);
  border: 1px solid var(--border-40);
}
.habitat-tip-label {
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 8px;
  color: var(--primary);
}
.habitat-tip p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.habitat-related {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.habitat-related-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-50);
  border: 1px solid var(--border-40);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  font-size: 0.875rem;
  font-weight: 600;
}
.habitat-related-card:hover {
  border-color: var(--primary);
  background: var(--primary-10);
}
.habitat-related-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

/* === Pokedex Card Grid (PokopiaGuide parity) === */
.pokedex-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 12px 0 28px;
}
.pokedex-title {
  max-width: 860px;
  font-size: 1.5rem;
}
@media (min-width: 768px) { .pokedex-title { font-size: 2.25rem; } }
@media (min-width: 1024px) { .pokedex-title { font-size: 3rem; } }
.pokedex-subtitle { margin-bottom: 0; }
.pokedex-total-pill {
  flex-shrink: 0;
  border-radius: 1rem;
  background: var(--primary-10);
  color: var(--primary);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  padding: 10px 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.pokedex-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.pokedex-tab {
  border-radius: var(--radius-full);
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 800;
  background: var(--bg-50);
  color: var(--text-muted);
  transition: all 0.25s ease;
}
.pokedex-tab:hover { background: var(--bg-80); color: var(--text); }
.pokedex-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}
.pokedex-filter-panel { margin-bottom: 24px; }
.pokedex-filter-section { margin-bottom: 12px; }
.pokedex-page .filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pokedex-page .filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
}
.pokedex-page .filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid var(--border-50);
  background: var(--bg-50);
  color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.pokedex-page .filter-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  background: var(--bg-80);
}
.pokedex-page .filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.pokedex-page .filter-btn img { width: 18px; height: 18px; flex-shrink: 0; }
.pokedex-search {
  position: relative;
  margin-bottom: 24px;
}
.pokedex-search .search-input {
  max-width: none;
  width: 100%;
  border-radius: 0.75rem;
  background: var(--bg);
  padding: 11px 40px;
}
.pokedex-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--text-muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.pokedex-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) { .pokedex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1024px) { .pokedex-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.poke-card {
  position: relative;
  min-width: 0;
  border-radius: 1.25rem;
  border: 1px solid var(--border-40);
  background: var(--bg-40);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.5s ease, box-shadow 0.5s ease, background 0.5s ease, border-color 0.5s ease;
  overflow: hidden;
}
@media (min-width: 640px) { .poke-card { border-radius: 2rem; } }
.poke-card:hover {
  transform: translateY(-4px);
  background: var(--bg-50);
  border-color: var(--border-50);
  box-shadow: var(--shadow-xl);
}
@media (min-width: 640px) { .poke-card:hover { transform: translateY(-8px); } }
.poke-card.hidden { display: none; }
.poke-card.catching { animation: card-catch-pulse 0.6s ease; }
.poke-card.caught { border-color: color-mix(in srgb, var(--accent) 40%, var(--border-40)); }
.poke-card-link {
  position: relative;
  display: flex;
  min-height: 128px;
  height: 100%;
  color: inherit;
  text-decoration: none;
  outline: none;
}
.poke-card-link:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent);
}
.poke-card-glow {
  position: absolute;
  left: -24px;
  top: 50%;
  z-index: 0;
  width: 128px;
  height: 128px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--type-glow);
  filter: blur(40px);
  opacity: 0.4;
  transition: transform 0.7s ease, opacity 0.7s ease;
}
.poke-card:hover .poke-card-glow {
  transform: translateY(-50%) scale(1.35);
  opacity: 0.68;
}
.poke-card-media {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 105px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border-40);
}
.poke-card-number-pill {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--text-muted) 12%, var(--bg));
  color: var(--text-muted);
  border: 1px solid var(--border-40);
  box-shadow: var(--shadow);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 2px 7px;
}
.poke-card-img-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin-top: 8px;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.poke-card-img-wrap img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 10px 10px rgba(0,0,0,0.15));
}
.poke-card:hover .poke-card-img-wrap { transform: scale(1.1); }
.poke-card-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 14px 48px 14px 12px;
}
.poke-card-desktop-title { display: none; }
.poke-card-mobile-title {
  width: 100%;
  margin-top: 8px;
  text-align: center;
}
.poke-card-name {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.2;
  transition: color 0.3s ease;
}
.poke-card:hover .poke-card-name { color: var(--primary); }
.poke-card-types,
.poke-info-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.poke-card-types { justify-content: center; }
.poke-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: var(--radius-full);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 2px 7px 2px 5px;
  white-space: nowrap;
}
.poke-type-badge img { width: 14px; height: 14px; }
.poke-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poke-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.72rem;
}
.poke-info-label {
  flex-shrink: 0;
  min-width: 34px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 800;
}
.poke-spec-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--type-color) 12%, var(--bg));
  color: var(--type-color);
  border: 1px solid color-mix(in srgb, var(--type-color) 22%, var(--border-40));
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
}
.poke-spec-badge img { width: 13px; height: 13px; flex-shrink: 0; }
.poke-info-icons img { width: 16px; height: 16px; }
.poke-card-meta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-40);
}
.poke-card-meta span {
  flex-shrink: 0;
  color: color-mix(in srgb, var(--text-muted) 80%, transparent);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.poke-card-meta strong {
  min-width: 0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .poke-card-link {
    min-height: 348px;
    flex-direction: column;
  }
  .poke-card-glow {
    left: 50%;
    top: 108px;
    width: 192px;
    height: 192px;
    transform: translateX(-50%);
    filter: blur(60px);
  }
  .poke-card:hover .poke-card-glow {
    transform: translateX(-50%) scale(1.5);
  }
  .poke-card-media {
    flex: none;
    min-height: 210px;
    border-right: 0;
    padding: 48px 20px 18px;
  }
  .poke-card-number-pill {
    left: 50%;
    top: 16px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    padding: 4px 16px;
  }
  .poke-card-img-wrap {
    width: 140px;
    height: 140px;
    margin: 0;
  }
  .poke-card-img-wrap img {
    width: 140px;
    height: 140px;
  }
  .poke-card-mobile-title { display: none; }
  .poke-card-desktop-title {
    display: block;
    margin-bottom: 14px;
    text-align: center;
  }
  .poke-card-body {
    justify-content: flex-start;
    padding: 0 20px 18px;
  }
  .poke-card-name {
    font-size: 1.25rem;
    margin-bottom: 10px;
  }
  .poke-card-types { gap: 6px; }
  .poke-type-badge {
    gap: 5px;
    font-size: 0.875rem;
    padding: 5px 12px 5px 7px;
  }
  .poke-type-badge img { width: 18px; height: 18px; }
  .poke-card-info { gap: 7px; }
  .poke-info-row { justify-content: center; font-size: 0.75rem; }
  .poke-info-label { min-width: auto; }
  .poke-info-value { justify-content: center; }
  .poke-card-meta { margin-top: auto; padding-top: 12px; }
}
.pokeball-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 5px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-40);
  background: var(--bg-80);
  color: color-mix(in srgb, var(--text-muted) 80%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
@media (min-width: 640px) {
  .pokeball-btn { top: 16px; right: 16px; }
}
.pokeball-btn:hover,
.pokeball-btn:focus-visible {
  color: var(--accent);
  transform: scale(1.12);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 25%, transparent);
}
.pokeball-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}
.pokeball-icon { width: 100%; height: 100%; }
.pokeball-btn.catching {
  color: var(--accent);
  animation: pokeball-catch 0.6s ease;
}
.pokeball-btn.caught {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.pokeball-btn.caught .pokeball-icon {
  animation: pokeball-caught-pulse 2.4s ease-in-out infinite;
}
@keyframes card-catch-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-2px) rotate(-0.6deg); }
  50% { transform: translateY(0) rotate(0.6deg); }
  75% { transform: translateY(-1px) rotate(-0.3deg); }
}
@keyframes pokeball-catch {
  0%, 100% { transform: scale(1) rotate(0deg); }
  20% { transform: scale(0.9) rotate(-18deg); }
  45% { transform: scale(1.18) rotate(18deg); }
  70% { transform: scale(0.96) rotate(-8deg); }
}
@keyframes pokeball-caught-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .poke-card,
  .poke-card-glow,
  .poke-card-img-wrap,
  .pokeball-btn,
  .pokeball-btn.catching,
  .pokeball-btn.caught .pokeball-icon,
  .poke-card.catching {
    animation: none !important;
    transition: none !important;
  }
  .poke-card:hover,
  .poke-card:hover .poke-card-img-wrap,
  .pokeball-btn:hover {
    transform: none;
  }
}
