:root {
  --bg: #070b14;
  --surface: #0f172a;
  --surface-2: #16223a;
  --border: rgba(148, 163, 184, 0.2);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --gold: #fbbf24;
  --danger: #ef4444;
  --success: #22c55e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background: radial-gradient(circle at 18% 0%, #172554 0%, #070b14 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px;
  background: rgba(7, 11, 20, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
}
.topbar h1 { font-size: 18px; letter-spacing: 0.2px; }
.subtitle { font-size: 12px; color: var(--muted); }

.main-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-tab {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.nav-tab:hover { transform: translateY(-1px); border-color: var(--accent); }
.nav-tab.active { background: #0284c7; border-color: #38bdf8; }
.nav-tab.accent { background: linear-gradient(135deg, #7c3aed, #ec4899); border-color: transparent; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cache-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 8px 5px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; color: var(--muted);
}
.cache-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.cache-dot.stale { background: var(--gold); }
.cache-dot.miss { background: var(--accent); }
.btn-clear-cache {
  background: rgba(239, 68, 68, 0.16); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.btn-clear-cache:hover { background: rgba(239, 68, 68, 0.35); color: #fff; }
.btn-binder {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.badge-count {
  background: var(--gold); color: #0f172a; font-weight: 800; font-size: 11px;
  border-radius: 999px; padding: 1px 7px;
}

.shell { max-width: 1420px; margin: 0 auto; padding: 18px 20px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.search-hero { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-input-wrap {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.search-input-wrap input {
  flex: 1; background: transparent; border: none; color: var(--text); font-size: 15px; outline: none; min-width: 0;
}
.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb); color: #fff; border: none;
  border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; font-size: 13px;
}
.quick-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-label { font-size: 12px; color: var(--muted); }
.quick-chip {
  background: rgba(56, 189, 248, 0.12); color: #bae6fd; border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.quick-chip:hover { border-color: var(--accent); background: rgba(56, 189, 248, 0.24); }

.type-ribbon {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 12px;
  background: rgba(15, 23, 42, 0.72); border: 1px solid var(--border); border-radius: 14px;
}
.type-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--surface-2); color: var(--text); transition: transform 0.12s ease;
}
.type-pill:hover { transform: translateY(-1px); }
.type-pill.active { outline: 2px solid #fff; box-shadow: 0 0 14px rgba(56, 189, 248, 0.45); }

.filter-bar {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px;
}
.filter-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
}
.filter-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.filter-grid select, .filter-grid input, .sets-controls input {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; width: 100%;
}
.hp-inputs { display: flex; align-items: center; gap: 4px; }
.toolbar-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.results-summary { font-size: 13px; color: var(--muted); }
.view-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 11px; font-size: 12px; cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.view-btn {
  background: var(--surface-2); color: var(--muted); border: none; padding: 6px 11px;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.view-btn.active { background: #0284c7; color: #fff; }

/* Card Ready Grid View */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px;
}
.card-tile {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(165deg, rgba(22, 34, 58, 0.94), rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border); border-radius: 16px; padding: 10px;
  cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card-tile:hover {
  transform: translateY(-5px) scale(1.015);
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(2, 132, 199, 0.28);
}
.card-art-wrap {
  position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 734 / 1024;
  background: #0b1120;
}
.card-art-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-save-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(15, 23, 42, 0.84); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px; width: 30px; height: 30px; display: grid; place-items: center;
  cursor: pointer; font-size: 14px; color: #cbd5e1;
}
.card-save-btn.saved { color: #f43f5e; border-color: #f43f5e; background: rgba(244, 63, 94, 0.18); }
.card-tile-meta { display: flex; flex-direction: column; gap: 4px; }
.card-tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.card-tile-name { font-size: 14px; font-weight: 700; line-height: 1.25; }
.card-tile-hp { font-size: 12px; font-weight: 800; color: #fca5a5; white-space: nowrap; }
.card-tile-sub { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.price-tag { color: #4ade80; font-weight: 700; }

/* List / Table View */
.cards-list-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.cards-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cards-table th, .cards-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.cards-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(2, 6, 23, 0.35); }
.cards-table tr.card-row { cursor: pointer; transition: background 0.12s ease; }
.cards-table tr.card-row:hover { background: rgba(56, 189, 248, 0.1); }
.list-thumb { width: 38px; height: 53px; object-fit: cover; border-radius: 5px; display: block; }

/* Sets Grid */
.sets-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.set-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  cursor: pointer; transition: transform 0.14s ease, border-color 0.14s ease;
}
.set-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.set-logo-wrap { height: 56px; display: flex; align-items: center; justify-content: center; }
.set-logo-wrap img { max-height: 52px; max-width: 100%; object-fit: contain; }
.set-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

/* Pagination */
.pagination-bar { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 22px; }
.page-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 3D Look-Around & Zoom-Out Modal */
.card-modal { display: none; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; padding: 16px; }
.card-modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.82); backdrop-filter: blur(8px); }
.modal-sheet {
  position: relative; z-index: 2; width: 100%; max-width: 1120px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid rgba(56, 189, 248, 0.35); border-radius: 20px;
  padding: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.modal-close {
  position: sticky; float: right; top: 0; z-index: 5; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); cursor: pointer; font-weight: 700;
}
.inspector-layout { display: grid; grid-template-columns: minmax(320px, 1.08fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.stage-column { display: flex; flex-direction: column; gap: 10px; }
.three-stage {
  position: relative; width: 100%; height: 470px; border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #1e293b 0%, #090d16 78%);
  border: 1px solid var(--border); cursor: grab;
}
.three-stage:active { cursor: grabbing; }
.three-loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent);
  font-size: 13px; font-weight: 600; pointer-events: none;
}
.stage-hint { text-align: center; font-size: 12px; color: var(--muted); }
.stage-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ctrl-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.ctrl-btn.active { background: #0284c7; border-color: #38bdf8; }

.details-column { display: flex; flex-direction: column; gap: 14px; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding-right: 36px; }
.detail-header h2 { font-size: 24px; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.info-pill {
  background: rgba(56, 189, 248, 0.14); border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700;
}
.detail-section {
  background: rgba(2, 6, 23, 0.38); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.detail-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px; }
.attack-item { margin-bottom: 10px; }
.attack-item:last-child { margin-bottom: 0; }
.attack-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.attack-text { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12px; }
.stat-box { background: var(--surface-2); border-radius: 8px; padding: 8px; }
.stat-box small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }

/* Binder Drawer */
.binder-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(92vw, 380px); z-index: 70;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(105%); transition: transform 0.22s ease;
  display: flex; flex-direction: column; box-shadow: -12px 0 36px rgba(0, 0, 0, 0.55);
}
.binder-drawer.open { transform: translateX(0); }
.binder-head, .binder-foot {
  padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;
}
.binder-foot { border-bottom: none; border-top: 1px solid var(--border); }
.binder-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.binder-row {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.binder-row img { width: 42px; border-radius: 5px; }
.btn-danger-sm {
  background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 700; font-size: 12px;
}

.empty-state {
  text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--border);
  border-radius: 16px; color: var(--muted);
}
.toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast-item {
  background: #0f172a; color: #f8fafc; border: 1px solid var(--accent); border-radius: 10px;
  padding: 9px 14px; font-size: 13px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

@media (max-width: 860px) {
  .inspector-layout { grid-template-columns: 1fr; }
  .three-stage { height: 340px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
}

/* Pokémon Pokéball Loading Logo */
.poke-loader-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 54px 20px; width: 100%;
}
.pokeball-spin {
  width: 64px; height: 64px;
  animation: pokeball-wobble 1.35s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  filter: drop-shadow(0 8px 20px rgba(56, 189, 248, 0.35));
}
.pokeball-core-pulse {
  animation: core-glow 1.1s ease-in-out infinite alternate;
}
.poke-loader-text { font-size: 14px; font-weight: 600; color: var(--muted); }
@keyframes pokeball-wobble {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(18deg) scale(1.06); }
  50% { transform: rotate(-16deg) scale(1); }
  75% { transform: rotate(360deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes core-glow {
  from { fill: #38bdf8; }
  to { fill: #facc15; }
}

/* Set Card Actions & TCGP Booster Pack Simulator */
.set-card-actions { display: flex; gap: 6px; margin-top: 6px; }
.set-card-actions button { flex: 1; }
.btn-primary-xs {
  background: linear-gradient(135deg, #0284c7, #6366f1); color: #fff; border: none;
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.pack-top-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px;
}
.pack-controls-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.pack-select-wrap { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; flex: 1; min-width: 240px; }
.pack-select-wrap select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 13px;
}
.pack-session-stats {
  display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted);
  padding-top: 6px; border-top: 1px solid var(--border);
}
.pack-odds-details { font-size: 12.5px; color: var(--muted); cursor: pointer; }
.pack-odds-details summary { font-weight: 700; color: var(--accent); }

.pack-foil-showcase { display: flex; justify-content: center; padding: 22px 10px; cursor: pointer; }
.pack-foil-pack {
  width: 250px; border-radius: 16px; overflow: hidden;
  border: 2px solid rgba(56, 189, 248, 0.55);
  background: linear-gradient(155deg, #1e1b4b 0%, #0f172a 55%, #312e81 100%);
  box-shadow: 0 22px 48px rgba(56, 189, 248, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.pack-foil-pack:hover { transform: translateY(-6px) scale(1.03); box-shadow: 0 26px 56px rgba(236, 72, 153, 0.35); }
.pack-foil-crimp {
  height: 16px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0 4px, rgba(15,23,42,0.5) 4px 8px);
}
.pack-foil-body {
  padding: 28px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
}
.pack-foil-logo { max-width: 170px; max-height: 76px; object-fit: contain; }
.pack-foil-title { font-weight: 800; font-size: 17px; }
.pack-foil-sub { font-size: 12px; color: var(--muted); }
.pack-foil-cta {
  margin-top: 8px; padding: 7px 14px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: linear-gradient(135deg, #f59e0b, #ec4899); color: #fff;
}

.pack-result-sub { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.god-pack-banner {
  text-align: center; padding: 12px; border-radius: 12px; margin-bottom: 14px; font-weight: 900;
  background: linear-gradient(90deg, #ec4899, #f59e0b, #22c55e, #38bdf8, #a855f7);
  color: #0f172a; box-shadow: 0 10px 30px rgba(251, 191, 36, 0.45);
}
.pack-slots-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 14px;
}
.pack-slot-card {
  cursor: pointer; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); padding: 10px; min-height: 310px;
  display: flex; flex-direction: column; transition: transform 0.16s ease, border-color 0.16s ease;
}
.pack-slot-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.pack-slot-card.is-chase { box-shadow: 0 0 22px rgba(244, 114, 182, 0.28); border-color: rgba(244, 114, 182, 0.65); }
.pack-card-back {
  flex: 1; border-radius: 12px; padding: 16px;
  background: radial-gradient(circle at center, #1d4ed8 0%, #0f172a 85%);
  border: 3px solid #fbbf24;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
}
.pack-slot-badge { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: #cbd5e1; }
.pack-back-emblem { font-size: 48px; }
.pack-odds-hint { font-size: 12px; font-weight: 700; }
.pack-card-front { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.pack-tier-pill {
  font-size: 11px; font-weight: 800; border: 1px solid; border-radius: 999px;
  padding: 3px 8px; text-align: center; background: rgba(2, 6, 23, 0.55);
}
.pack-card-front img { width: 100%; border-radius: 10px; object-fit: contain; }
.pack-card-caption { display: flex; flex-direction: column; font-size: 12px; text-align: center; }
.pack-card-caption small { color: var(--muted); font-size: 11px; }
