/* ============================================
   POKEDEX V3 - CLEAN REBUILD
   No !important tags - Proper CSS hierarchy
   Modern, Bold, Beautiful
   ============================================ */

/* ============================================
   FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@600;700;800&display=swap');

/* ============================================
   CSS VARIABLES - BASE THEME
   ============================================ */
:root {
  /* Base Colors */
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  --surface: #1e1e24;
  --surface-elevated: #2a2a32;
  
  --text-primary: #ffffff;
  --text-secondary: #e4e4e7;
  --text-muted: #94a3b8;
  
  /* Default theme colors */
  --theme-primary: #3b82f6;
  --theme-primary-dark: #2563eb;
  --theme-primary-light: #60a5fa;
  --theme-secondary: #1e40af;
  --theme-secondary-dark: #1e3a8a;
  --theme-secondary-light: #3b82f6;
  
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  
  --border-subtle: rgba(63, 63, 70, 0.4);
  --border-emphasis: rgba(113, 113, 122, 0.6);
  
  /* Clean shadows */
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --shadow-depth-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-depth-md: 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow-depth-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
  --shadow-depth-xl: 0 12px 24px rgba(0, 0, 0, 0.35);
  
  --glass-bg: rgba(30, 30, 36, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

/* ============================================
   PERFORMANCE MODE
   ============================================ */
body.performance-mode *,
body.performance-mode *::before,
body.performance-mode *::after {
  animation: none;
  transition: none;
}

body.performance-mode .card img {
  animation: none;
}

body.performance-mode .thumb {
  transition: opacity 0.15s ease;
}

body.performance-mode .modern-stat-bar-fill {
  transition: width 0.2s ease;
}

/* ============================================
   COLOR THEMES - BOLD & VIBRANT
   ============================================ */

/* Water Type - Bold Blue */
:root[data-color="cyan"] {
  --theme-primary: #0ea5e9;
  --theme-primary-dark: #0284c7;
  --theme-primary-light: #38bdf8;
  --theme-secondary: #0369a1;
  --theme-secondary-dark: #075985;
  --theme-secondary-light: #0ea5e9;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(14, 165, 233, 0.3);
  --border-emphasis: rgba(14, 165, 233, 0.6);
}

/* Fire Type - Bold Orange/Red */
:root[data-color="red"] {
  --theme-primary: #f97316;
  --theme-primary-dark: #ea580c;
  --theme-primary-light: #fb923c;
  --theme-secondary: #dc2626;
  --theme-secondary-dark: #b91c1c;
  --theme-secondary-light: #ef4444;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(249, 115, 22, 0.3);
  --border-emphasis: rgba(249, 115, 22, 0.6);
}

/* Ice Type - Bold Cyan */
:root[data-color="blue"] {
  --theme-primary: #06b6d4;
  --theme-primary-dark: #0891b2;
  --theme-primary-light: #22d3ee;
  --theme-secondary: #0e7490;
  --theme-secondary-dark: #155e75;
  --theme-secondary-light: #06b6d4;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(6, 182, 212, 0.3);
  --border-emphasis: rgba(6, 182, 212, 0.6);
}

/* Grass Type - Bold Green */
:root[data-color="green"] {
  --theme-primary: #22c55e;
  --theme-primary-dark: #16a34a;
  --theme-primary-light: #4ade80;
  --theme-secondary: #15803d;
  --theme-secondary-dark: #166534;
  --theme-secondary-light: #22c55e;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(34, 197, 94, 0.3);
  --border-emphasis: rgba(34, 197, 94, 0.6);
}

/* Electric Type - Bold Yellow */
:root[data-color="yellow"] {
  --theme-primary: #eab308;
  --theme-primary-dark: #ca8a04;
  --theme-primary-light: #facc15;
  --theme-secondary: #f59e0b;
  --theme-secondary-dark: #d97706;
  --theme-secondary-light: #fbbf24;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(234, 179, 8, 0.3);
  --border-emphasis: rgba(234, 179, 8, 0.6);
}

/* Fighting Type - Bold Red */
:root[data-color="orange"] {
  --theme-primary: #dc2626;
  --theme-primary-dark: #b91c1c;
  --theme-primary-light: #ef4444;
  --theme-secondary: #991b1b;
  --theme-secondary-dark: #7f1d1d;
  --theme-secondary-light: #dc2626;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(220, 38, 38, 0.3);
  --border-emphasis: rgba(220, 38, 38, 0.6);
}

/* Psychic Type - Bold Pink/Magenta */
:root[data-color="purple"] {
  --theme-primary: #ec4899;
  --theme-primary-dark: #db2777;
  --theme-primary-light: #f472b6;
  --theme-secondary: #be185d;
  --theme-secondary-dark: #9f1239;
  --theme-secondary-light: #ec4899;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(236, 72, 153, 0.3);
  --border-emphasis: rgba(236, 72, 153, 0.6);
}

/* Fairy Type - Bold Pink */
:root[data-color="pink"] {
  --theme-primary: #f472b6;
  --theme-primary-dark: #ec4899;
  --theme-primary-light: #f9a8d4;
  --theme-secondary: #db2777;
  --theme-secondary-dark: #be185d;
  --theme-secondary-light: #f472b6;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(244, 114, 182, 0.3);
  --border-emphasis: rgba(244, 114, 182, 0.6);
}

/* Dragon Type - Bold Purple */
:root[data-color="teal"] {
  --theme-primary: #8b5cf6;
  --theme-primary-dark: #7c3aed;
  --theme-primary-light: #a78bfa;
  --theme-secondary: #6d28d9;
  --theme-secondary-dark: #5b21b6;
  --theme-secondary-light: #8b5cf6;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(139, 92, 246, 0.3);
  --border-emphasis: rgba(139, 92, 246, 0.6);
}

/* Dark Type - Bold Brown/Gray */
:root[data-color="indigo"] {
  --theme-primary: #78716c;
  --theme-primary-dark: #57534e;
  --theme-primary-light: #a8a29e;
  --theme-secondary: #44403c;
  --theme-secondary-dark: #292524;
  --theme-secondary-light: #78716c;
  --accent-primary: var(--theme-primary);
  --accent-secondary: var(--theme-primary-light);
  --border-subtle: rgba(120, 113, 108, 0.3);
  --border-emphasis: rgba(120, 113, 108, 0.6);
}

/* Light Theme */
:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #1e293b;
  --text-muted: #64748b;
  --border-subtle: rgba(226, 232, 240, 0.8);
  --border-emphasis: rgba(203, 213, 225, 1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* AMOLED Theme */
:root[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  --surface: #0f0f0f;
  --surface-elevated: #1a1a1a;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 500;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

/* ============================================
   HEADER
   ============================================ */
.header {
  position: relative;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .header {
    padding: 20px 32px;
  }
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.02em;
  color: var(--accent-primary);
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .brand h1 {
    font-size: 1.875rem;
  }
}

.brand img {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.2s ease;
}

@media (min-width: 768px) {
  .brand img {
    width: 44px;
    height: 44px;
  }
}

.brand img:hover {
  transform: scale(1.05);
}

.settings-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.settings-btn:active {
  transform: scale(0.95);
}

/* ============================================
   CONTROLS
   ============================================ */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-row-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 480px) {
  .controls-row-top {
    grid-template-columns: 1fr auto;
  }
}

@media (min-width: 768px) {
  .controls-row-top {
    grid-template-columns: 1fr 200px;
  }
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: var(--text-muted);
  color: var(--bg-primary);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.clear-search-btn:hover {
  opacity: 1;
  background: var(--accent-primary);
  transform: translateY(-50%) scale(1.1);
}

.clear-search-btn.visible {
  display: flex;
}

input,
select {
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 14px 16px;
  outline: none;
  width: 100%;
  font-size: 15px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
}

input#searchInput {
  padding-right: 44px;
}

input:focus,
select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.1);
}

input:hover,
select:hover {
  border-color: var(--border-emphasis);
}

input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.controls-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  font-size: 1.2rem;
}

.controls-toggle:hover {
  border-color: var(--accent-primary);
}

.controls-toggle:active {
  transform: scale(0.98);
}

.controls-toggle-icon {
  transition: transform 0.3s ease;
}

.controls-toggle.active .controls-toggle-icon {
  transform: rotate(180deg);
}

.controls-row-bottom {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.controls-row-bottom.expanded {
  max-height: 200px;
  opacity: 1;
}

@media (min-width: 768px) {
  .controls-toggle {
    display: none;
  }
  
  .controls-row-bottom {
    max-height: none;
    opacity: 1;
    overflow: visible;
  }
}

.team-btn,
.type-chart-btn,
.region-btn {
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

@media (min-width: 768px) {
  .team-btn,
  .type-chart-btn,
  .region-btn {
    font-size: 0.95rem;
  }
}

.team-btn:hover,
.type-chart-btn:hover,
.region-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.team-btn:active,
.type-chart-btn:active,
.region-btn:active {
  transform: scale(0.98);
}

.team-count {
  background: var(--accent-primary);
  color: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 24px;
  text-align: center;
}

/* ============================================
   GENERATION TABS
   ============================================ */
.gen-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) transparent;
  scroll-behavior: smooth;
}

.gen-tabs::-webkit-scrollbar {
  height: 4px;
}

.gen-tabs::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 2px;
}

.gen-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  transition: all 0.2s ease;
}

@media (min-width: 768px) {
  .gen-btn {
    padding: 14px 24px;
    font-size: 0.95rem;
  }
}

.gen-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--border-emphasis);
  transform: translateY(-2px);
}

.gen-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-primary);
  font-weight: 800;
  box-shadow: var(--shadow-md);
}

.gen-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============================================
   MAIN GRID - POKEMON CARDS
   ============================================ */
.main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .main {
    padding: 32px;
  }
}

.status {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

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

@media (min-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
  }
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
  }
}

.card {
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.03));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-lg);
}

.card:hover::before {
  opacity: 1;
}

.card:active {
  transform: translateY(-2px);
}

.card-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
  transition: transform 0.2s ease;
}

.card:hover .card-img {
  transform: scale(1.05);
}

.card-number,
.card-id {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: 'Space Grotesk', monospace;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-family: 'Space Grotesk', sans-serif;
  text-transform: capitalize;
}

@media (min-width: 768px) {
  .card-name {
    font-size: 1.05rem;
  }
}

.card-types {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.type-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

@media (min-width: 768px) {
  .type-badge {
    font-size: 0.75rem;
    padding: 5px 12px;
  }
}

/* ============================================
   POKEMON DETAIL DIALOG
   ============================================ */
dialog.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 900px;
  width: calc(100% - 32px);
  max-height: 90vh;
  background: var(--surface);
  border: 2px solid var(--border-subtle);
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

dialog.dialog[open] {
  opacity: 1;
  pointer-events: auto;
  animation: dialogFadeIn 0.3s ease;
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

dialog.dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-header {
  position: relative;
  flex-shrink: 0;
  z-index: 10;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1.5px solid var(--border-subtle);
  padding: 20px 24px;
  padding-right: 64px;
}

.dialog .close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 11;
}

.dialog .close-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-primary);
  transform: rotate(90deg) scale(1.1);
}

.dialog .close-btn:active {
  transform: rotate(90deg) scale(0.95);
}

.dialog-content {
  padding: 24px;
  padding-bottom: 48px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.dialog-content::-webkit-scrollbar {
  width: 8px;
}

.dialog-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.dialog-content::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

/* Dialog content styling - HIGH SPECIFICITY */
.dialog-content h2 {
  font-size: 2rem;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: capitalize;
  letter-spacing: -0.02em;
}

.dialog-content h3 {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin-top: 0;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-emphasis);
  display: block;
}

.dialog-content p {
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.dialog-content ul,
.dialog-content ol {
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 16px;
  padding-left: 24px;
}

.dialog-content li {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.dialog-content strong {
  color: var(--accent-primary);
  font-weight: 700;
}

.dialog-content em {
  color: var(--text-primary);
  font-style: italic;
}

.dialog-content section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border-subtle);
}

.dialog-content section:last-child {
  border-bottom: none;
  margin-bottom: 24px;
  padding-bottom: 0;
}

/* Pokemon image in dialog */
.thumb-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-tertiary);
  border: 2px solid var(--accent-primary);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.thumb {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

@media (min-width: 768px) {
  .thumb {
    width: 150px;
    height: 150px;
  }
}

/* ============================================
   MODERN INFO CARDS & STAT BARS - CRITICAL FIX
   Matches JavaScript-generated HTML structure
   ============================================ */

/* Modern info card containers */
.modern-info-card {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  overflow: hidden;
}

/* Ensure last card has margin for scrolling */
.modern-info-card:last-child,
.info-card:last-child {
  margin-bottom: 24px;
}

/* Text inside modern-info-card */
.modern-info-card p {
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.modern-info-card p:last-child {
  margin-bottom: 0;
}

.modern-info-card strong {
  color: var(--accent-primary);
  font-weight: 700;
}

/* Info rows for structured data */
.modern-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 8px;
}

.modern-info-row:last-child {
  border-bottom: none;
}

.modern-info-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 120px;
}

.modern-info-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  flex: 1;
  text-align: right;
}

/* Card section titles */
.modern-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-emphasis);
}

/* Stat bar container - wrapper for each stat */
.modern-stat-bar-container {
  margin-bottom: 12px;
}

/* Stat header - contains name and value */
.modern-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

/* Stat name label */
.modern-stat-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Space Grotesk', sans-serif;
}

/* Stat numeric value */
.modern-stat-value {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent-primary);
  font-family: 'Space Grotesk', sans-serif;
}

/* Stat bar background container */
.modern-stat-bar-bg {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  height: 32px;
  overflow: hidden;
  position: relative;
}

/* Stat bar fill - the animated gradient bar */
.modern-stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding: 0 12px;
  justify-content: flex-end;
  font-weight: 700;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.9);
  min-width: 50px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
}

/* Legacy stat label support (if used elsewhere) */
span.stat-label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-primary);
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Space Grotesk', sans-serif;
  pointer-events: none;
}

/* Info cards */
.info-card {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  overflow: hidden;
}

.info-card p {
  margin-bottom: 6px;
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 0.95rem;
}

.info-card p:last-child {
  margin-bottom: 0;
}

.info-card strong {
  color: var(--accent-primary);
  font-weight: 700;
}

/* Tables */
.dialog-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--border-subtle);
}

.dialog-content th,
.dialog-content td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.dialog-content th {
  background: var(--bg-tertiary);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dialog-content td {
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 500;
}

.dialog-content tr:last-child td {
  border-bottom: none;
}

/* ============================================
   MODALS - SHARED STYLING
   ============================================ */
.settings-overlay,
.team-overlay,
.type-chart-overlay,
.region-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.settings-overlay.active,
.team-overlay.active,
.type-chart-overlay.active,
.region-overlay.active {
  display: flex;
}

/* Modal base styling */
.settings-modal,
.team-modal,
.type-chart-modal,
.region-modal {
  background: var(--surface);
  border: 2px solid var(--border-subtle);
  border-radius: 20px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease;
  display: flex;
  flex-direction: column;
}

.type-chart-modal,
.region-modal {
  max-width: 900px;
  display: flex;
  flex-direction: column;
}

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

/* Modal headers - COMPACT */
.settings-header,
.team-header,
.type-chart-header,
.region-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1.5px solid var(--border-subtle);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.settings-header h2,
.team-header h2,
.type-chart-header h2,
.region-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  letter-spacing: -0.01em;
  margin: 0;
}

/* Close buttons in headers */
.settings-header .close-settings,
.team-header .close-settings,
.type-chart-header .close-btn,
.region-header .close-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.settings-header .close-settings:hover,
.team-header .close-settings:hover,
.type-chart-header .close-btn:hover,
.region-header .close-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-primary);
  transform: rotate(90deg);
}

/* Scrollable content areas */
.settings-content,
.team-content {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
}

.type-chart-instructions {
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent-primary);
  margin: 0;
  border-radius: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.4;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* Type wheel - keep it flexible but not scrollable */
/* Type wheel and info panel - BOTH SCROLLABLE TOGETHER */
.type-wheel-container {
  position: relative;
  max-width: 480px;
  width: 100%;
  margin: 12px auto 0;
  padding: 16px;
  /* No flex-shrink - let it scroll! */
}

/* Wrapper for scrolling - apply to parent */
.type-chart-modal > .type-wheel-container {
  flex: 0 0 auto;  /* Don't shrink, but allow scrolling */
}

/* Create one scrollable area */
.type-chart-modal::after {
  content: '';
  display: block;
  height: 1px;
}

/* Make the modal itself handle scrolling */
.type-chart-modal {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Reset info panel - it's now part of scroll context */
.type-info-panel {
  padding: 16px 24px 32px;
  overflow-y: visible;  /* Let parent handle scroll */
}

.region-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.region-content::-webkit-scrollbar {
  width: 8px;
}

.region-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.region-content::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

/* ============================================
   TYPE EFFECTIVENESS CHART
   ============================================ */

/* Type wheel container - PART OF SCROLLABLE CONTENT */
.type-wheel-container {
  position: relative;
  max-width: 550px;
  width: 100%;
  margin: 24px auto 24px;
  aspect-ratio: 1;
  padding: 20px;
  max-height: 550px;
}

svg.type-wheel {
  width: 100%;
  height: auto;
  display: block;
}

/* Type wheel text - LARGER AND MORE VISIBLE */
.type-wheel text {
  text-anchor: middle;
  dominant-baseline: middle;
  font-weight: 800;
  font-size: 16px;
  fill: #ffffff;
  text-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: 'Space Grotesk', sans-serif;
}

/* Center circle - PERFECTLY CENTERED */
div.type-wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 190px;
  height: 190px;
  background: var(--surface);
  border: 4px solid var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  padding: 28px;
  z-index: 10;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.type-wheel-center .center-text {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}

.type-wheel-segment {
  transition: all 0.2s ease;
  cursor: pointer;
  stroke: rgba(0, 0, 0, 0.3);
  stroke-width: 1;
}

.type-wheel-segment:hover {
  opacity: 0.85;
  filter: brightness(1.3);
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 2;
}

.type-wheel-segment.active {
  filter: brightness(1.4) saturate(1.2);
  stroke: #ffffff;
  stroke-width: 4;
}

/* Mobile adjustments for type wheel */
@media (max-width: 767px) {
  .type-wheel-container {
    max-width: 100%;
    padding: 10px;
  }
  
  .type-wheel text {
    font-size: 13px;
  }
  
  div.type-wheel-center {
    width: 160px;
    height: 160px;
    padding: 20px;
    border-width: 3px;
  }
  
  .type-wheel-center .center-text {
    font-size: 0.95rem;
  }
}

/* Type effectiveness sections */
.type-info-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
}

.type-info-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.type-badges-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}

.type-badges-container:empty::after {
  content: 'None';
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.875rem;
}

.mini-type-badge {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease;
}

.mini-type-badge:hover {
  transform: scale(1.05);
}

/* ============================================
   REGION EXPLORER
   ============================================ */
.region-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.region-card {
  background: var(--surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.region-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.region-card:active {
  transform: translateY(-2px);
}

.region-card-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.region-card-name {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.region-card-generation {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Region details */
.region-details {
  display: block;
}

.region-details-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-subtle);
  flex-wrap: wrap;
}

.region-back-btn {
  padding: 10px 18px;
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.region-back-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-primary);
  transform: translateX(-4px);
}

.region-back-btn:active {
  transform: translateX(-2px) scale(0.98);
}

.region-details-title {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.region-map-container {
  width: 100%;
  max-height: 500px;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  margin-bottom: 24px;
  background: var(--bg-tertiary);
}

.region-map {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.region-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.region-info-card {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
}

.region-info-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.region-info-card p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.region-info-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.region-info-card li {
  color: var(--text-secondary);
  padding: 6px 0;
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
}

.region-info-card li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 1.2rem;
}

.region-lore {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.region-lore h3 {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent-primary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.region-lore p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.95rem;
}

/* ============================================
   TEAM BUILDER
   ============================================ */
.team-slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .team-slots {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

.team-slot {
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.team-slot:hover {
  border-color: var(--accent-primary);
  background: var(--surface);
  transform: translateY(-2px);
}

.team-slot.filled {
  border-style: solid;
  border-color: var(--accent-primary);
  background: var(--surface);
  cursor: default;
}

.team-slot.filled:hover {
  transform: none;
}

.team-slot-empty {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.3;
}

.team-pokemon-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.team-pokemon-name {
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  text-align: center;
  font-size: 1rem;
  margin-bottom: 8px;
  text-transform: capitalize;
}

.team-pokemon-types {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.team-type-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: inline-block;
}

.remove-from-team {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
}

.team-slot.filled:hover .remove-from-team {
  opacity: 1;
}

.remove-from-team:hover {
  background: #dc2626;
  transform: scale(1.15);
}

.remove-from-team:active {
  transform: scale(0.95);
}

.team-actions {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  border-top: 1.5px solid var(--border-subtle);
}

.team-action-btn {
  flex: 1;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  background: var(--accent-primary);
  color: var(--bg-primary);
  font-weight: 700;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.team-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.team-action-btn:active {
  transform: scale(0.98);
}

.team-action-btn.secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1.5px solid var(--border-subtle);
}

.team-stats {
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}

.add-to-team-btn {
  background: var(--accent-primary);
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  color: var(--bg-primary);
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-shadow: var(--shadow-md);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.add-to-team-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.add-to-team-btn:active {
  transform: scale(0.98);
}

.add-to-team-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.add-to-team-btn.in-team {
  background: #22c55e;
}

/* ============================================
   SETTINGS
   ============================================ */
.setting-group {
  margin-bottom: 24px;
}

.setting-group label {
  display: block;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Space Grotesk', sans-serif;
}

.setting-select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.setting-select:hover {
  border-color: var(--border-emphasis);
}

.setting-select:focus {
  border-color: var(--accent-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.1);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-subtle);
  border-radius: 28px;
  transition: all 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-input:checked + .toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-input:checked + .toggle-slider::before {
  transform: translateX(24px);
  background: var(--bg-primary);
}

/* ============================================
   LOADING SCREEN
   ============================================ */
.loading {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 24px;
}

.loading.hidden,
.loading[hidden] {
  display: none;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#loadingText {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--accent-primary);
  border: none;
  border-radius: 50%;
  color: var(--bg-primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(100px);
}

.back-to-top.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-8px) scale(1.1);
  box-shadow: var(--shadow-xl);
}

.back-to-top:active {
  transform: scale(0.95);
}

/* Fixed: Removed conflicting display:none rule to allow back-to-top button on all devices when visible class is applied */

/* ============================================
   TYPE COLORS
   ============================================ */
.type-normal {
  background: #a8a878;
}

.type-fire {
  background: #f08030;
}

.type-water {
  background: #6890f0;
}

.type-electric {
  background: #f8d030;
}

.type-grass {
  background: #78c850;
}

.type-ice {
  background: #98d8d8;
}

.type-fighting {
  background: #c03028;
}

.type-poison {
  background: #a040a0;
}

.type-ground {
  background: #e0c068;
}

.type-flying {
  background: #a890f0;
}

.type-psychic {
  background: #f85888;
}

.type-bug {
  background: #a8b820;
}

.type-rock {
  background: #b8a038;
}

.type-ghost {
  background: #705898;
}

.type-dragon {
  background: #7038f8;
}

.type-dark {
  background: #705848;
}

.type-steel {
  background: #b8b8d0;
}

.type-fairy {
  background: #ee99ac;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
  display: none;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 767px) {
  button,
  a,
  [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  .dialog {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  input,
  select,
  textarea {
    font-size: 16px;
  }
  
  .dialog-content {
    transform: translateZ(0);
    will-change: scroll-position;
  }
}

@media (max-width: 480px) {
  dialog.dialog[open] {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    transform: translate(-50%, -50%);
  }

  .dialog-header {
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-right: 64px;
  }

  .dialog-content {
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    max-height: calc(100vh - 100px);
  }

  .dialog .close-btn {
    top: max(20px, env(safe-area-inset-top));
    right: 16px;
  }

  button,
  .dialog button,
  .dialog-content button {
    min-height: 44px;
  }
}

/* ============================================
   DESKTOP OPTIMIZATIONS
   ============================================ */
@media (min-width: 768px) {
  .dialog-content {
    scroll-behavior: smooth;
    padding: 32px;
    padding-bottom: 64px;
  }
  
  .dialog-header {
    padding: 24px 32px;
    padding-right: 80px;
  }
  
  /* Ensure info cards don't get cut off */
  .modern-info-card,
  .info-card {
    overflow: visible;
    max-width: 100%;
  }
  
  /* Better text sizing on desktop */
  .dialog-content p,
  .modern-info-card p,
  .info-card p {
    font-size: 1rem;
  }
  
  /* Ensure rows wrap properly */
  .modern-info-row {
    min-height: 40px;
  }
  
  .dialog-content::-webkit-scrollbar {
    width: 12px;
  }
  
  .dialog-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 6px;
  }
  
  .dialog-content::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 6px;
    transition: background 0.2s ease;
  }
  
  .dialog-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .header,
  .back-to-top,
  dialog::backdrop {
    display: none;
  }
  
  dialog[open] {
    position: static;
    max-width: none;
    max-height: none;
    border: none;
    box-shadow: none;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
    scroll-behavior: auto;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

