/* ============================================================
   Trade Ya Cards — Design System
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Core colours */
  --bg:           #06060e;
  --surface:      rgba(255, 255, 255, 0.025);
  --border:       rgba(255, 255, 255, 0.07);
  --text:         #e8e8f0;
  --text-muted:   #8888aa;
  --text-subtle:  #555577;

  /* Brand accents */
  --accent:       #a78bfa;
  --success:      #34d399;
  --gold:         #fbbf24;
  --blue:         #60a5fa;
  --danger:       #f87171;

  /* TCG game colours */
  --tcg-mtg:       #e05555;
  --tcg-lorcana:   #a78bfa;
  --tcg-pokemon:   #fbbf24;
  --tcg-onepiece:  #fb923c;
  --tcg-riftbound: #34d399;
  --tcg-gundam:    #60a5fa;

  /* Typography */
  --font-base: 'Exo 2', system-ui, sans-serif;

  /* Spacing scale (8px base) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Border radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast:  0.1s ease;
  --transition-base:  0.2s ease;
  --transition-slow:  0.35s ease;

  /* Z-index scale */
  --z-base:        1;
  --z-dropdown:   10;
  --z-sticky:     20;
  --z-fab:        99;
  --z-nav:       100;
  --z-lightbox:  200;
  --z-onboarding:300;
  --z-toast:     400;
}

/* --- Global reset / base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-base);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, video { max-width: 100%; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* --- Typography --- */
h1 { font-size: 2rem;    line-height: 1.15; font-weight: 800; color: var(--text); }
h2 { font-size: 1.5rem;  line-height: 1.2;  font-weight: 700; color: var(--text); }
h3 { font-size: 1.25rem; line-height: 1.3;  font-weight: 700; color: var(--text); }
h4 { font-size: 1.125rem;line-height: 1.35; font-weight: 600; color: var(--text); }
h5 { font-size: 1rem;    line-height: 1.4;  font-weight: 600; color: var(--text); }
h6 { font-size: 0.875rem;line-height: 1.4;  font-weight: 600; color: var(--text-muted); }

p, li, td { font-size: 1rem; line-height: 1.6; color: var(--text); }

.body-sm  { font-size: 0.875rem;  line-height: 1.5; color: var(--text); }
.caption  { font-size: 0.75rem;   line-height: 1.4; color: var(--text-muted); }
.label    { font-size: 0.8125rem; line-height: 1.4; font-weight: 600; color: var(--text-muted); }
.nav-label{ font-size: 0.6875rem; line-height: 1;   font-weight: 600; color: var(--text-muted); }

/* --- Animations --- */
@keyframes holo {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

@keyframes badge-glow-gold {
  0%, 100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.3); }
  50%       { box-shadow: 0 0 20px rgba(251, 191, 36, 0.65); }
}

@keyframes badge-glow-green {
  0%, 100% { box-shadow: 0 0 8px rgba(52, 211, 153, 0.25); }
  50%       { box-shadow: 0 0 18px rgba(52, 211, 153, 0.55); }
}

@keyframes ring-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.4)); }
  50%       { filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.8)); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* --- Holo text --- */
.holo-text {
  background: linear-gradient(90deg, #a78bfa, #34d399, #fbbf24, #a78bfa);
  background-size: 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: holo 5s ease infinite;
}

@media (prefers-reduced-motion: reduce) {
  .holo-text {
    -webkit-text-fill-color: unset;
    background: none;
    color: var(--accent);
    animation: none;
  }
}

/* --- Glass Panel --- */
.glass-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
}

.glass-panel--elevated {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.badge-new, .badge--new {
  background: rgba(255, 255, 255, 0.08);
  color: #8888aa;
}

.badge-rising, .badge--rising {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: #1e3a5f;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.28);
}

.badge-verified, .badge--verified {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #064e3b;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.3);
}

.badge-elite, .badge--elite {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.4);
  animation: badge-glow-gold 3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .badge--elite, .badge-elite { animation: none; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  min-width: 44px;
  padding: 0 1.25rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border: none;
  outline: none;
  transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px rgba(167, 139, 250, 0.5);
}

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

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

.btn-primary, .btn--primary {
  background: var(--accent);
  color: #1a0f2e;
}
.btn-primary:hover:not(:disabled),
.btn--primary:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.35);
}

.btn-ghost, .btn--secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled),
.btn--secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.btn-danger, .btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.btn-danger:hover:not(:disabled),
.btn--danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.25);
}

.btn--success {
  background: var(--success);
  color: #022c22;
}
.btn--success:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 4px 20px rgba(52, 211, 153, 0.35);
}

.btn--icon { padding: 0; width: 48px; border-radius: 10px; }
.btn--sm { min-height: 36px; padding: 0 0.875rem; font-size: 0.8125rem; border-radius: 8px; }
.btn--full { width: 100%; }

/* --- Inputs --- */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
textarea,
select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
}

input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}

textarea {
  min-height: 120px;
  padding: 0.75rem 1rem;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder, input::placeholder, textarea::placeholder { color: var(--text-subtle); }

.input:hover, input:hover, textarea:hover, select:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

.input--error, input.field_with_errors, .field_with_errors input {
  border-color: var(--danger);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-hint { font-size: 0.75rem; color: var(--text-subtle); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }

/* --- Card Thumbnails --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tcg-color, var(--border));
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
}

.card-thumb:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.card-thumb[data-tcg="mtg"]       { --tcg-color: var(--tcg-mtg); }
.card-thumb[data-tcg="lorcana"]   { --tcg-color: var(--tcg-lorcana); }
.card-thumb[data-tcg="pokemon"]   { --tcg-color: var(--tcg-pokemon); }
.card-thumb[data-tcg="onepiece"]  { --tcg-color: var(--tcg-onepiece); }
.card-thumb[data-tcg="riftbound"] { --tcg-color: var(--tcg-riftbound); }
.card-thumb[data-tcg="gundam"]    { --tcg-color: var(--tcg-gundam); }

.card-thumb__label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.375rem 0.5rem;
  background: linear-gradient(transparent, rgba(6, 6, 14, 0.85));
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

/* TCG label badge */
.tcg-label {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tcg-label[data-tcg="mtg"]       { background: rgba(224,85,85,0.15); color: var(--tcg-mtg); border: 1px solid rgba(224,85,85,0.3); }
.tcg-label[data-tcg="lorcana"]   { background: rgba(167,139,250,0.15); color: var(--tcg-lorcana); border: 1px solid rgba(167,139,250,0.3); }
.tcg-label[data-tcg="pokemon"]   { background: rgba(251,191,36,0.15); color: var(--tcg-pokemon); border: 1px solid rgba(251,191,36,0.3); }
.tcg-label[data-tcg="onepiece"]  { background: rgba(251,146,60,0.15); color: var(--tcg-onepiece); border: 1px solid rgba(251,146,60,0.3); }
.tcg-label[data-tcg="riftbound"] { background: rgba(52,211,153,0.15); color: var(--tcg-riftbound); border: 1px solid rgba(52,211,153,0.3); }
.tcg-label[data-tcg="gundam"]    { background: rgba(96,165,250,0.15); color: var(--tcg-gundam); border: 1px solid rgba(96,165,250,0.3); }

/* --- Rep Score Ring --- */
.rep-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rep-ring svg { transform: rotate(-90deg); }

.rep-ring__track { fill: none; stroke: rgba(255, 255, 255, 0.07); }
.rep-ring__fill  { fill: none; stroke-linecap: round; transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

.rep-ring--new      .rep-ring__fill { stroke: #555577; }
.rep-ring--rising   .rep-ring__fill { stroke: #60a5fa; }
.rep-ring--verified .rep-ring__fill { stroke: #34d399; }
.rep-ring--elite    .rep-ring__fill { stroke: #fbbf24; animation: ring-pulse 2s ease-in-out infinite; }

.rep-ring__score { position: absolute; text-align: center; line-height: 1; }
.rep-ring__score-number { display: block; font-size: 1.25rem; font-weight: 800; color: var(--text); }
.rep-ring__score-label  { display: block; font-size: 0.5625rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* --- Bottom Nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(6, 6, 14, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.6875rem;
  font-weight: 600;
  transition: color 0.15s ease;
  min-width: 44px;
  padding: 0.25rem;
}

.bottom-nav__tab:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.5);
  outline-offset: -2px;
  border-radius: 8px;
}

.bottom-nav__tab svg, .bottom-nav__tab .icon { width: 22px; height: 22px; }

.bottom-nav__tab--active { color: var(--accent); }
.bottom-nav__tab--active svg, .bottom-nav__tab--active .icon {
  filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.5));
}

.page-body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

/* --- Sidebar (desktop only) --- */
.sidebar { display: none; }

/* --- FAB --- */
.fab {
  position: fixed;
  bottom: calc(64px + 1rem + env(safe-area-inset-bottom));
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a0f2e;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  font-size: 1.5rem;
  line-height: 1;
}

.fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(167, 139, 250, 0.55); }
.fab:active { transform: scale(0.96); }
.fab:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px rgba(167, 139, 250, 0.5); }

/* --- Drawer --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 14, 0.7);
  z-index: 150;
  backdrop-filter: blur(4px);
}

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 15, 28, 0.98);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1rem 2rem;
  z-index: 160;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.drawer.open { transform: translateY(0); }

/* --- Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 14, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lightbox-overlay.is-open { opacity: 1; }

.lightbox-content {
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 1.5rem;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  position: relative;
}

.lightbox-overlay.is-open .lightbox-content { transform: scale(1); }

.lightbox-image {
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
}

/* --- Onboarding Overlay --- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 14, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  z-index: 300;
}

.onboarding-card { max-width: 400px; width: 100%; text-align: center; }
.onboarding-icon { font-size: 3.5rem; margin-bottom: 1.25rem; line-height: 1; }
.onboarding-title { font-size: 1.5rem; font-weight: 800; color: var(--text); margin-bottom: 0.75rem; }
.onboarding-body  { font-size: 1rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 2rem; }

.onboarding-card[data-step="1"] .onboarding-title { color: #a78bfa; }
.onboarding-card[data-step="2"] .onboarding-title { color: #34d399; }
.onboarding-card[data-step="3"] .onboarding-title { color: #fbbf24; }
.onboarding-card[data-step="4"] .onboarding-title { color: #60a5fa; }
.onboarding-card[data-step="5"] .onboarding-title { color: #fb923c; }
.onboarding-card[data-step="6"] .onboarding-title { color: #a78bfa; }

.onboarding-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease, transform 0.2s ease;
}

.onboarding-dot.active, .onboarding-dot--active {
  background: var(--accent);
  transform: scale(1.3);
}

.onboarding-dot--complete { background: rgba(167, 139, 250, 0.4); }

.onboarding-actions { display: flex; flex-direction: column; gap: 0.75rem; }

.onboarding-skip {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-decoration: none;
  margin-top: 1rem;
  display: inline-block;
}
.onboarding-skip:hover { color: var(--text-muted); }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: rgba(30, 30, 50, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 0.25s ease forwards;
}

.toast-success, .toast--success { border-left: 3px solid var(--success); }
.toast-danger, .toast--danger   { border-left: 3px solid var(--danger); }
.toast--info                     { border-left: 3px solid var(--accent); }

.toast__message, .toast span { flex: 1; font-size: 0.875rem; color: var(--text); line-height: 1.4; }

.toast-exit, .toast.is-leaving { animation: toast-out 0.2s ease forwards; }

/* --- Filter Pills --- */
.filter-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  min-height: 36px;
}
.filter-pill:hover { background: rgba(255, 255, 255, 0.05); }
.filter-pill--active { background: rgba(167, 139, 250, 0.12); border-color: var(--accent); color: var(--accent); }

.filter-pill--active[data-tcg="mtg"]       { background: rgba(224,85,85,0.12);   border-color: var(--tcg-mtg);       color: var(--tcg-mtg); }
.filter-pill--active[data-tcg="pokemon"]   { background: rgba(251,191,36,0.12);  border-color: var(--tcg-pokemon);   color: var(--tcg-pokemon); }
.filter-pill--active[data-tcg="onepiece"]  { background: rgba(251,146,60,0.12);  border-color: var(--tcg-onepiece);  color: var(--tcg-onepiece); }
.filter-pill--active[data-tcg="riftbound"] { background: rgba(52,211,153,0.12);  border-color: var(--tcg-riftbound); color: var(--tcg-riftbound); }
.filter-pill--active[data-tcg="gundam"]    { background: rgba(96,165,250,0.12);  border-color: var(--tcg-gundam);    color: var(--tcg-gundam); }
.filter-pill--active[data-tcg="lorcana"]   { background: rgba(167,139,250,0.12); border-color: var(--tcg-lorcana);   color: var(--tcg-lorcana); }

/* --- Tab switching --- */
.tab-btn { cursor: pointer; }
.tab-btn.active, .tab-btn[aria-selected="true"] {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* --- Star rating --- */
.star-rating { display: flex; gap: 0.25rem; }
.star-rating input[type="radio"] { display: none; }
.star-rating label {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-subtle);
  transition: color 0.15s ease;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: var(--gold); }

/* Stars in correct order */
.star-rating { flex-direction: row-reverse; justify-content: flex-end; }
.star-rating input:checked ~ label { color: var(--gold); }

/* --- Card list row (non-thumb style) --- */
.card-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; }

/* --- Stat grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

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

.stat-card__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Skeleton --- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: 6px;
}

/* --- Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(6, 6, 14, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Responsive layout --- */
@media (min-width: 640px) {
  .bottom-nav  { display: none; }
  .fab         { display: none; }
  .page-body   { padding-bottom: 0; }

  .app-layout  { display: flex; min-height: 100vh; }

  .sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100vh;
    width: 200px;
    flex-shrink: 0;
    flex-direction: column;
    padding: 1.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.015);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  .sidebar__logo {
    padding: 0 0.5rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 800;
  }

  .sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
  }

  .sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    min-height: 44px;
  }

  .sidebar__link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }

  .sidebar__link--active {
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent);
  }

  .sidebar__link svg, .sidebar__link .icon { width: 20px; height: 20px; flex-shrink: 0; }

  .sidebar__footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
  }

  .main-content { flex: 1; min-width: 0; padding: 1.5rem; }

  .toast-container { left: auto; max-width: 360px; }

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

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

@media (min-width: 900px) {
  .sidebar     { width: 220px; }
  .main-content { padding: 2rem 2.5rem; }
  .card-grid   { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* --- Utility --- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.text-gold { color: var(--gold); }

/* --- Focus ring global --- */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px rgba(167, 139, 250, 0.5);
}

/* --- Error messages from Rails form helpers --- */
.field_with_errors { display: contents; }
.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea {
  border-color: var(--danger);
}

#error_explanation {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
#error_explanation h2 {
  font-size: 0.9375rem;
  color: var(--danger);
  margin-bottom: 0.5rem;
}
#error_explanation ul { list-style: none; }
#error_explanation li { font-size: 0.875rem; color: var(--danger); padding: 0.125rem 0; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .holo-text {
    -webkit-text-fill-color: unset;
    background: none;
    color: var(--accent);
  }
}
