:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-hover: #212634;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --rarity-5: #f59e0b;
  --rarity-4: #a855f7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 2rem 1.25rem;
}

.site-header {
  max-width: 1100px;
  margin: 0 auto 2rem;
  text-align: center;
}

.site-header h1 {
  font-size: 2rem;
  letter-spacing: 0.03em;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.25rem;
}

.controls {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

#searchInput {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid #2e3446;
  background: var(--surface);
  color: var(--text);
  min-width: 240px;
  font-size: 0.95rem;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid #2e3446;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* Gallery Grid */
.gallery-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.char-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #2a3040;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.char-card:hover {
  transform: translateY(-4px);
  background: var(--surface-hover);
}

.char-card.rarity-5 {
  border-color: var(--rarity-5);
}

.char-card.rarity-5:hover {
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.22);
}

.char-card.rarity-4 {
  border-color: var(--rarity-4);
}

.char-card.rarity-4:hover {
  box-shadow: 0 8px 20px rgba(168, 85, 247, 0.22);
}

.card-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  display: block;
  background: #12151e;
}

.card-info {
  padding: 0.9rem;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.card-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.card-series {
  font-size: 0.85rem;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: #262b3a;
  color: #cbd5e1;
}

/* Modal */
.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid #2e3446;
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.75rem;
  cursor: pointer;
}

.modal-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

.modal-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border-radius: 10px;
}

.modal-quote {
  font-style: italic;
  color: #cbd5e1;
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
  margin: 0.75rem 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  margin-top: 2rem;
}

.site-footer {
  max-width: 1100px;
  margin: 3rem auto 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .modal-grid {
    grid-template-columns: 1fr;
  }
}