
:root {
  --bg: #0a0a0f;
  --s1: #12121a;
  --s2: #1a1a26;
  --s3: #22223a;
  --border: #2a2a3d;
  --accent: #f5c842;
  --red: #e8443a;
  --text: #e8e8f0;
  --muted: #6b6b8a;
  --green: #42c97a;
  /* Game accent colors */
  --pokemon: #f5c842;
  --mtg: #e8443a;
  --yugioh: #7b5ea7;
  --onepiece: #2196f3;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }
body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; min-height: 100vh; display: flex; flex-direction: column; opacity: 0; transition: opacity 0.2s; overflow-x: hidden; max-width: 100vw; }
body.fonts-ready { opacity: 1; }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(245,200,66,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,200,66,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}
.wrap { max-width: 900px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; width: 100%; flex: 1; }

/* Header */
/* padding-top = ad-top height (76px) + original spacing (36px).
   This keeps the logo/hero in the same position whether or not
   the ad network renders or removes the .ad-top element. */
header { padding: 36px 0 0; display: flex; align-items: center; justify-content: space-between; }
.logo { font-family: 'Bebas Neue', sans-serif; font-size: 30px; letter-spacing: 4px; color: var(--accent); cursor: pointer; text-decoration: none; display: inline-block; }
.logo span { color: var(--text); }

/* Hero */
.hero { padding: 48px 0 36px; }
.hero h1 { font-family: 'Bebas Neue', sans-serif; font-size: 72px; line-height: 0.9; letter-spacing: 2px; margin-bottom: 16px; }
.hero h1 em { font-style: normal; color: var(--game-color, var(--accent)); display: block; transition: color 0.3s; }
.hero p { color: var(--muted); font-size: 15px; line-height: 1.6; font-weight: 300; max-width: 400px; }

/* Game selector */
.game-tabs { display: flex; gap: 8px; margin-top: 28px; flex-wrap: wrap; }
.gtab {
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 2px;
  padding: 8px 18px; border-radius: 3px; border: 1px solid var(--border);
  color: var(--muted); background: var(--s1); cursor: pointer;
  transition: all 0.15s; text-transform: uppercase;
  border-left-width: 3px;
}
.gtab:hover { border-color: var(--muted); color: var(--text); }
.gtab.active { color: var(--bg); font-weight: 600; }
.gtab[data-game="pokemon"]         { border-left-color: var(--pokemon); }
.gtab[data-game="mtg"]             { border-left-color: var(--mtg); }
.gtab[data-game="yugioh"]          { border-left-color: var(--yugioh); }
.gtab[data-game="onepiece"]        { border-left-color: var(--onepiece); }
.gtab[data-game="pokemon"] .ti { color: var(--pokemon); }
.gtab[data-game="mtg"] .ti      { color: var(--mtg); }
.gtab[data-game="yugioh"] .ti   { color: var(--yugioh); }
.gtab[data-game="onepiece"] .ti { color: var(--onepiece); }
.gtab.active .ti { color: var(--bg); }
.gtab[data-game="pokemon"].active  { background: var(--pokemon); border-color: var(--pokemon); }
.gtab[data-game="mtg"].active      { background: var(--mtg);     border-color: var(--mtg); }
.gtab[data-game="yugioh"].active   { background: var(--yugioh);  border-color: var(--yugioh); }
.gtab[data-game="onepiece"].active { background: var(--onepiece);border-color: var(--onepiece); }

/* Search box */
/* Landing — search hidden until game is chosen */
@keyframes searchFadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
#search-box { display: none; }
#search-box.revealed { display: block; animation: searchFadeIn 0.45s cubic-bezier(0.22,1,0.36,1) forwards; }
#filters-row { display: none; }
#filters-row.revealed { display: flex; animation: searchFadeIn 0.5s cubic-bezier(0.22,1,0.36,1) forwards; }

/* "Choose your card game" landing label */
#hero-choose {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--muted);
  margin-top: 32px;
  opacity: 1;
  transition: opacity 0.3s;
}
#hero-choose.hidden { opacity: 0; pointer-events: none; }

.search-box {
  margin-top: 28px; background: var(--s1); border: 1px solid var(--border);
  border-radius: 8px; overflow: visible; position: relative;
  transition: border-color 0.3s;
}
.search-box.focused { border-color: var(--game-color, var(--accent)); }
.search-inner { display: flex; align-items: stretch; }
.search-icon { display: flex; align-items: center; padding: 0 18px; color: var(--muted); font-size: 20px; flex-shrink: 0; }
input#q {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: 17px; padding: 18px 0; min-width: 0;
}
input#q::placeholder { color: var(--muted); }
.search-btn {
  background: var(--game-color, var(--accent)); color: var(--bg); border: none;
  padding: 0 26px; font-family: 'DM Mono', monospace; font-size: 12px;
  letter-spacing: 2px; font-weight: 600; cursor: pointer; transition: opacity 0.15s;
  flex-shrink: 0;
}
.search-btn:hover { opacity: 0.85; }

/* Autocomplete */
.ac-drop {
  position: fixed;
  background: var(--s2); border: 1px solid var(--border); border-radius: 6px;
  z-index: 9999; overflow-y: auto; display: none; box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  max-height: 60vh;
}
.ac-item {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s;
  /* Stagger pop-in: each row fades + slides in 60ms after the previous.
     Per-row delay is set inline via --d so renderAC can control the cascade. */
  opacity: 0; transform: translateY(-4px);
  animation: ac-pop 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes ac-pop {
  to { opacity: 1; transform: translateY(0); }
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--s3); }
.ac-img { width: 32px; height: 44px; object-fit: contain; border-radius: 3px; background: #000; flex-shrink: 0; }
.ac-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ac-meta { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); }
.ac-price { margin-left: auto; font-family: 'Bebas Neue', sans-serif; font-size: 18px; color: var(--game-color, var(--accent)); flex-shrink: 0; }

/* Stub state — shown while we have a name but no print info yet (set/num/img/usd).
   Shimmering placeholders for image/meta/price tell the user "loading print info". */
.ac-stub-img,
.ac-stub-meta,
.ac-stub-price {
  background: linear-gradient(90deg, var(--s3) 0%, var(--border) 50%, var(--s3) 100%);
  background-size: 200% 100%;
  animation: ac-shimmer 1.2s ease-in-out infinite;
  border-radius: 3px;
  display: inline-block;
}
.ac-stub-img { width: 32px; height: 44px; flex-shrink: 0; }
.ac-stub-meta { width: 80px; height: 10px; margin-top: 4px; }
.ac-stub-price { width: 50px; height: 18px; margin-left: auto; flex-shrink: 0; }
@keyframes ac-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* (Skeleton loading rows removed — they were causing perceived sluggishness.
   We now show nothing during the brief 80ms+RTT window, then pop in real
   results with a quick fade. Matches reference behavior.) */

/* Filters */
.filters { display: flex; gap: 10px; margin-top: 12px; flex-wrap: nowrap; align-items: center; position: relative; z-index: 100; }
.filter-label { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); letter-spacing: 1px; flex-shrink: 0; }
select {
  background: var(--s1); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; padding: 7px 12px; font-family: 'DM Sans', sans-serif;
  font-size: 13px; outline: none; cursor: pointer; transition: border-color 0.15s;
  flex: 1; min-width: 0;
}
#lang-select { flex: 0 0 auto; width: 80px; }

/* Results header */
.results-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin: 36px 0 16px; flex-wrap: wrap; gap: 10px;
}
.results-title { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 3px; color: var(--muted); }
.results-count { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); }
.results-count strong { color: var(--text); }

/* Card grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 40px; }
.card-tile {
  background: var(--s1); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; cursor: pointer; transition: transform 0.15s, border-color 0.15s;
}
.card-tile:hover { transform: translateY(-3px); border-color: var(--s3); }
.rarity-stripe { height: 3px; width: 100%; }
.rs-common   { background: var(--muted); }
.rs-uncommon { background: var(--green); }
.rs-rare     { background: #4a9eff; }
.rs-holo     { background: linear-gradient(90deg, #9b6dff, #4a9eff, var(--accent)); }
.rs-ultra    { background: linear-gradient(90deg, var(--accent), var(--red)); }
.rs-mythic   { background: linear-gradient(90deg, var(--red), #ff8c42); }
.card-img-wrap { aspect-ratio: 2.5/3.5; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-tile-info { padding: 11px 13px; }
.tile-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-set  { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-price { font-family: 'Bebas Neue', sans-serif; font-size: 22px; color: var(--game-color, var(--accent)); line-height: 1; }
.tile-price.na { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); }
.tile-rarity { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin: 8px 0 48px; flex-wrap: wrap; }
.pg-btn {
  background: var(--s1); border: 1px solid var(--border); color: var(--muted);
  font-family: 'DM Mono', monospace; font-size: 12px; padding: 8px 14px;
  border-radius: 4px; cursor: pointer; transition: all 0.15s;
}
.pg-btn:hover:not(:disabled) { border-color: var(--game-color, var(--accent)); color: var(--game-color, var(--accent)); }
.pg-btn.active { border-color: var(--game-color, var(--accent)); color: var(--game-color, var(--accent)); background: rgba(245,200,66,0.05); }
.pg-btn:disabled { opacity: 0.3; cursor: default; }

/* Loading / Empty */
.loading { display: flex; align-items: center; gap: 14px; padding: 48px 0; color: var(--muted); font-family: 'DM Mono', monospace; font-size: 14px; }
.spin { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--game-color, var(--accent)); border-radius: 50%; animation: rot 0.7s linear infinite; flex-shrink: 0; }
@keyframes rot { to { transform: rotate(360deg); } }
.empty { padding: 64px 0; text-align: center; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty p { font-size: 15px; }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-bg.open { display: flex; }
.modal { background: var(--s1); border: 1px solid var(--border); border-radius: 10px; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--s3); }
.modal-body { padding: 24px; display: grid; grid-template-columns: 170px 1fr; gap: 24px; }
@media(max-width:500px) { .modal-body { grid-template-columns: 1fr; } }
.modal-card-img { width: 100%; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.6); }
.modal-info { display: flex; flex-direction: column; gap: 12px; }
.modal-set { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); }
.modal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: 'DM Mono', monospace; font-size: 11px; padding: 4px 10px; border-radius: 3px; background: var(--s2); border: 1px solid var(--border); color: var(--muted); }
.chip.hl { border-color: var(--game-color, var(--accent)); color: var(--game-color, var(--accent)); }
.price-box { background: var(--s2); border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.pb-main-label { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.pb-main-val { font-family: 'Bebas Neue', sans-serif; font-size: 46px; color: var(--game-color, var(--accent)); line-height: 1; }
.pb-variants { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.pbv { text-align: center; }
.pbv-label { font-family: 'DM Mono', monospace; font-size: 9px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 3px; }
.pbv-val { font-family: 'Bebas Neue', sans-serif; font-size: 18px; color: var(--text); }

.ext-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ext-btn { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); text-decoration: none; border: 1px solid var(--border); padding: 6px 12px; border-radius: 3px; transition: all 0.15s; letter-spacing: 1px; }
.ext-btn:hover { border-color: var(--game-color, var(--accent)); color: var(--game-color, var(--accent)); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp 0.2s ease forwards; }

/* Top banner — static, stays at top, doesn't scroll with page */
.top-banner {
  position: static;
  width: 100%; display: flex; justify-content: center; align-items: center;
  padding: 8px 24px; height: 76px;
  box-sizing: border-box;
}
.bottom-banner {
  width: 100%; display: flex; justify-content: center;
  padding: 8px 24px; margin-top: 16px;
}
.banner-slot {
  width: 100%; max-width: 728px; height: 60px;
  border: 1px solid rgba(255,255,255,0.015); border-radius: 4px;
}

.img-zoom-bg{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.92);z-index:400;align-items:center;justify-content:center;cursor:zoom-out;pointer-events:none;}
.img-zoom-bg.open{display:flex;pointer-events:all;}
.img-zoom-bg img{max-height:85vh;max-width:85vw;border-radius:10px;box-shadow:0 16px 64px rgba(0,0,0,0.8);}
.coming-soon-tip { position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); background:var(--s1); border:1px solid var(--border); color:var(--muted); font-family:'DM Mono',monospace; font-size:10px; padding:4px 8px; border-radius:4px; white-space:nowrap; pointer-events:none; z-index:100; }

/* ── Subpage (About / Privacy / Terms) ─────────────────────────── */
#subpage { display: none; }
body.subpage-active .wrap > *:not(header) { display: none !important; }
body.subpage-active #subpage { display: block !important; padding: 48px 0 64px; }
.subpage-back { display: inline-flex; align-items: center; gap: 6px; font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 1px; color: var(--muted); text-decoration: none; margin-bottom: 36px; transition: color 0.15s; }
.subpage-back:hover { color: var(--accent); }
.subpage-title { font-family: 'Bebas Neue', sans-serif; font-size: 52px; letter-spacing: 3px; color: var(--text); margin-bottom: 32px; line-height: 1; }
.subpage-section-title { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; margin-top: 28px; }
.subpage-section-title:first-of-type { margin-top: 0; }
.subpage-body p { font-family: 'DM Sans', sans-serif; font-size: 15px; color: var(--muted); line-height: 1.8; margin-bottom: 16px; }
.subpage-body p:last-child { margin-bottom: 0; }
.subpage-body strong { color: var(--text); font-weight: 500; }
.subpage-divider { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
#set-sheet-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 99998; backdrop-filter: blur(2px);
}
#set-sheet-overlay.open { display: block; }
#set-sheet {
  display: none; position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--s1); border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0; z-index: 99999;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 80vh; display: flex; flex-direction: column;
}
#set-sheet.open { transform: translateY(0); display: flex; }
#set-sheet-handle {
  width: 36px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 10px auto 0; flex-shrink: 0;
}
#set-sheet-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 18px; letter-spacing: 3px;
  color: var(--muted); padding: 10px 16px 8px; flex-shrink: 0;
}
#set-sheet-search-wrap { padding: 0 12px 8px; flex-shrink: 0; }
#set-sheet-search {
  width: 100%; box-sizing: border-box; font-family: 'DM Mono', monospace;
  font-size: 13px; background: var(--s2); border: 1px solid var(--border);
  color: var(--text); padding: 9px 12px; border-radius: 6px; outline: none;
}
#set-sheet-list { overflow-y: auto; flex: 1; }
