:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #eab308;
  --info: #3b82f6;
  --border: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 2rem 1rem;
  text-align: center;
  border-bottom: 2px solid var(--accent);
}

.app-header h1 {
  margin: 0;
  font-size: 2rem;
  color: var(--accent);
}

.app-header p {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
}

.franchise-nav {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.franchise-btn {
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s;
}

.franchise-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.franchise-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.control-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.control-group input,
.control-group select {
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.control-group input:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.control-group.buttons {
  flex-direction: row;
  align-items: flex-end;
  gap: 0.5rem;
}

.btn-secondary {
  padding: 0.625rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--accent);
  color: var(--bg);
}

.progress-by-series {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.series-progress {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.series-progress h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.series-progress p {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
}

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

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.card.owned {
  border-color: var(--success);
}

.card.missing {
  border-color: var(--danger);
}

.card.duplicate {
  border-color: var(--warning);
}

.card-image {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}

.card-image .no-image {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

.card-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--bg);
}

.card-badge.ultra-rare { background: var(--warning); color: #000; }
.card-badge.captain { background: var(--info); }
.card-badge.crystal { background: #a855f7; }
.card-badge.gold { background: #fbbf24; color: #000; }
.card-badge.neon { background: #ec4899; }

.card-body {
  padding: 0.875rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.card-actions .btn {
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-own {
  background: var(--success);
  color: #fff;
}

.btn-own.active {
  background: #15803d;
}

.btn-missing {
  background: var(--danger);
  color: #fff;
}

.btn-missing.active {
  background: #b91c1c;
}

.duplicate-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.duplicate-control button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.duplicate-control button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.duplicate-control span {
  flex: 1;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.app-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 600px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .control-group.buttons {
    flex-direction: column;
    align-items: stretch;
  }
}
