:root {
  --bg: #0f1419;
  --surface: #1c2838;
  --surface2: #2a3d54;
  --panel: #243447;
  --text: #f2f5f9;
  --muted: #b4c2d4;
  --accent: #ff5350;
  --accent2: #4d8dff;
  --caught: #4ade80;
  --locked: #7a8fa8;
  --tg-bg: var(--bg);
  --tg-text: var(--text);
}

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

html, body {
  height: 100%;
  background: var(--tg-bg, var(--bg));
  color: var(--tg-text, var(--text));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100%;
  padding: 12px 12px 24px;
  max-width: 520px;
  margin: 0 auto;
  color: var(--text);
}

.header {
  margin-bottom: 14px;
}

.title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.progress-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--tg-bg, var(--bg));
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--surface2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.search::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search:focus {
  border-color: var(--accent2);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.filter-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.filter-chip.active {
  border-color: var(--accent2);
  color: #fff;
  background: var(--accent2);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 400px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text);
}

.card:active {
  transform: scale(0.97);
}

.card.caught {
  border-color: rgba(74, 222, 128, 0.45);
}

.card.locked {
  opacity: 0.85;
}

.card-icon {
  font-size: 2rem;
  line-height: 1;
  filter: grayscale(0);
}

.card.locked .card-icon {
  filter: grayscale(1) brightness(0.7);
}

.card-name {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  line-height: 1.2;
  word-break: break-word;
  color: var(--text);
}

.card.locked .card-name {
  color: var(--muted);
}

.card-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.badge-shiny {
  font-size: 0.65rem;
  color: #fcd34d;
  font-weight: 600;
}

.loader, .error, .empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.pokeball {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent) 48%, #222 48%, #222 52%, #fff 52%);
  border: 3px solid #222;
  animation: spin 1s linear infinite;
}

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

.btn {
  margin-top: 12px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent2);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.modal {
  border: none;
  padding: 0;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-inner {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 28px;
  border: 1px solid var(--surface2);
  color: var(--text);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: capitalize;
  padding-right: 40px;
  color: var(--text);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}

.tag {
  font-size: 0.8rem;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--surface2);
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--panel);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

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

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}

.detail-section h3 {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 700;
}

.attack-row {
  background: var(--panel);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}

.attack-row strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 0.95rem;
}

.attack-row span,
.attack-row .attack-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.locked-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
  line-height: 1.45;
}

.locked-note strong {
  color: var(--text);
}

.matchups {
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--surface2);
  border-radius: 12px;
}

.matchups h3 {
  font-size: 0.82rem;
  margin: 10px 0 6px;
  color: var(--text);
}

.matchups h3:first-child {
  margin-top: 0;
}

.matchup-line {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 6px;
}

.mu-label {
  color: var(--text);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

.panel.hidden {
  display: none;
}

.ach-summary {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.ach-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
}

.ach-item {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 12px;
  padding: 12px;
}

.ach-item.unlocked {
  border-color: rgba(74, 222, 128, 0.4);
}

.ach-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ach-icon {
  font-size: 1.25rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.ach-body {
  flex: 1;
  min-width: 0;
}

.ach-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.ach-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

.ach-prog {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
}
