/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --bg-input: #16213e;
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #e74c3c;
  --accent-hover: #c0392b;
  --border: #2a2a4a;
  --shadow: rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== Header ===== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span {
  color: var(--accent);
}

.logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: 20px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  text-decoration: none;
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Hero / Search Section ===== */
.hero {
  text-align: center;
  padding: 60px 16px 40px;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.hero p {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 1.05rem;
}

.search-wrapper {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar button {
  padding: 14px 24px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.search-bar button:hover {
  background: var(--accent-hover);
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 28px;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-scan:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ===== Card Grid ===== */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 32px 0 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding-bottom: 32px;
}

.card-item {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow);
  text-decoration: none;
}

.card-item-img {
  width: 100%;
  aspect-ratio: 63/88;
  object-fit: contain;
  background: var(--bg-primary);
  padding: 8px;
}

.card-item-info {
  padding: 8px 10px;
}

.card-item-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-item-price {
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Card Detail ===== */
.card-detail {
  padding: 24px 16px;
  max-width: 900px;
  margin: 0 auto;
}

.card-detail-top {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.card-detail-img-wrap {
  flex: 0 0 300px;
  position: relative;
}

.card-detail-img-wrap img {
  width: 100%;
  border-radius: var(--radius);
  cursor: zoom-in;
}

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

.card-detail-name {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-detail-set {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.price-section {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.price-section h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.price-avg {
  font-size: 2rem;
  font-weight: 700;
  color: #2ecc71;
  margin-bottom: 16px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

.price-row .label {
  color: var(--text-secondary);
}

.price-row .value {
  font-weight: 600;
}

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

.stat-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.stat-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-item .value {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

.external-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.external-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.2s;
}

.external-links a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.btn-back:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* ===== Sets / Series ===== */
.series-block {
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.series-header {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  transition: background 0.2s;
}

.series-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.series-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.series-header:hover {
  background: rgba(255,255,255,0.03);
}

.series-header .arrow {
  transition: transform 0.2s;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.series-header.open .arrow {
  transform: rotate(180deg);
}

.series-sets {
  display: none;
  padding: 0 16px 16px;
}

.series-sets.open {
  display: block;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.2s;
  color: inherit;
}

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

.set-row:hover {
  opacity: 0.8;
  text-decoration: none;
}

.set-row img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  flex-shrink: 0;
}

.set-row-info {
  flex: 1;
  min-width: 0;
}

.set-row-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.set-row-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Set Detail Header ===== */
.set-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0 16px;
}

.set-header img {
  width: auto;
  height: 60px;
  max-width: 160px;
  object-fit: contain;
}

.set-header h1 {
  font-size: 1.5rem;
}

.set-header .meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Scanner ===== */
.scanner-page {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.scanner-video {
  flex: 1;
  object-fit: cover;
  width: 100%;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-guide {
  width: 280px;
  height: 392px;
  border: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.scanner-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  pointer-events: auto;
}

.btn-capture {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-capture:hover {
  transform: scale(1.1);
}

.btn-capture:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-cancel {
  padding: 10px 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.scanner-status {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 0.95rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* ===== Loading & States ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1.1rem;
}

/* ===== Image Zoom Modal ===== */
.zoom-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.zoom-modal.active {
  opacity: 1;
  visibility: visible;
}

.zoom-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
}

/* ===== Type Background Colors ===== */
.type-bg-colorless  { background: linear-gradient(135deg, var(--bg-primary), #a8a878) !important; }
.type-bg-fire       { background: linear-gradient(135deg, var(--bg-primary), #8b2500) !important; }
.type-bg-water      { background: linear-gradient(135deg, var(--bg-primary), #1a5276) !important; }
.type-bg-grass      { background: linear-gradient(135deg, var(--bg-primary), #1e5631) !important; }
.type-bg-lightning  { background: linear-gradient(135deg, var(--bg-primary), #7d6608) !important; }
.type-bg-psychic    { background: linear-gradient(135deg, var(--bg-primary), #6c3483) !important; }
.type-bg-fighting   { background: linear-gradient(135deg, var(--bg-primary), #784212) !important; }
.type-bg-darkness   { background: linear-gradient(135deg, var(--bg-primary), #1c1c2e) !important; }
.type-bg-metal      { background: linear-gradient(135deg, var(--bg-primary), #515a5a) !important; }
.type-bg-dragon     { background: linear-gradient(135deg, var(--bg-primary), #6c3483) !important; }
.type-bg-fairy      { background: linear-gradient(135deg, var(--bg-primary), #a04070) !important; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .card-detail-top {
    flex-direction: column;
    align-items: center;
  }

  .card-detail-img-wrap {
    flex: none;
    width: 240px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero {
    padding: 40px 16px 24px;
  }

  .nav-links {
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (max-width: 400px) {
  .search-bar {
    flex-direction: column;
  }

  .search-bar button {
    width: 100%;
  }
}

/* ===== Features Grid ===== */
.features {
  padding-bottom: 32px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.feature-icon {
  color: var(--accent);
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ===== SEO Content ===== */
.seo-content {
  padding: 40px 16px;
  max-width: 800px;
  margin: 0 auto;
}

.seo-content h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.seo-content h3 {
  font-size: 1.1rem;
  margin-top: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.seo-content p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 12px;
}

/* ===== About Page ===== */
.about-hero {
  text-align: center;
  padding: 48px 16px 32px;
}

.about-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin: 0 auto 16px;
}

.about-hero h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.about-tagline {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.about-content {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.about-section {
  margin-bottom: 40px;
}

.about-section h2 {
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.about-section p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.sets-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.sets-list-col h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.sets-list-col ul {
  list-style: none;
  padding: 0;
}

.sets-list-col li {
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 4px 0;
}

.how-to-list {
  padding-left: 20px;
  color: var(--text-secondary);
}

.how-to-list li {
  margin-bottom: 12px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.faq-item h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.faq-item p {
  font-size: 0.85rem;
  margin: 0;
}

@media (max-width: 768px) {
  .sets-list {
    grid-template-columns: 1fr;
  }

  .about-hero h1 {
    font-size: 1.5rem;
  }
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-disclaimer {
  font-size: 0.7rem;
  margin-top: 8px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Auth Pages ===== */
.auth-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 16px 60px;
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.auth-field input::placeholder {
  color: var(--text-muted);
}

.auth-field input:focus {
  border-color: var(--accent);
}

.auth-btn {
  display: block;
  width: 100%;
  padding: 13px 24px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  margin-top: 4px;
}

.auth-btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.auth-btn-outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.auth-btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-alert p {
  margin: 0;
}

.auth-alert p + p {
  margin-top: 4px;
}

.auth-alert-error {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}

/* ===== Profile Page ===== */
.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.profile-info {
  text-align: left;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

.profile-label {
  color: var(--text-muted);
}

.profile-value {
  font-weight: 600;
}

/* ===== Nav Auth Link ===== */
.nav-links .nav-user {
  color: var(--accent);
  font-weight: 600;
}

.nav-links .nav-user:hover {
  color: var(--text-primary);
}
