/* Self-hosted, not Google Fonts CDN - this app's CSP locks font-src
   and style-src to 'self', which is treated as protected security
   infrastructure throughout this project, not something to loosen for
   a font. Self-hosting also means zero external network dependency
   for the product app (unlike the marketing site, a different,
   more marketing-appropriate tradeoff). Font file is the genuine
   Anton family, SIL Open Font License, verified before use - not a
   substitute or lookalike. */
@font-face {
  font-family: "Anton";
  src: url("fonts/anton-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Dark theme — deep navy-black base, indigo/cyan brand accent, matching the marketing site */
  --bg: #0e0f16;
  --surface: #1a1b25;
  --surface-2: #23242f;
  --border: rgba(255, 255, 255, 0.09);
  --ink: #f4f3f7;
  --ink-muted: #9a96a8;

  /* Brand injection: dark + indigo/cyan/violet, matching the marketing
     site's established system - replaces the earlier amber accent
     entirely, not just a value change under the old name. */
  --primary: #7567ff;
  --primary-ink: #f5f4ff;

  --accent: #42e8ff;
  --accent-ink: #04262b;

  /* Vivid color-block palette — used as solid fills for badges/tags */
  --yellow: #f7c948;
  --yellow-ink: #4a3a06;
  --purple: #9a80f2;
  --purple-ink: #ffffff;
  --pink: #f49ac1;
  --pink-ink: #5c1638;
  --green: #3ecb96;
  --green-ink: #063d29;
  --blue: #5aa8e8;
  --blue-ink: #062a4a;
  --coral: #ff7a6a;
  --coral-ink: #ffffff;

  --good: #3ecb96;
  --bad: #ff7a6a;

  --hue-shopping: var(--green);
  --hue-combos: var(--purple);
  --hue-mydecks: var(--yellow);
  --hue-import: var(--blue);

  --w: #e8c34a;
  --u: #5aa8e8;
  --b: #a89bc4;
  --r: #ea6b5f;
  --g: #3ecb96;
  --c: #9a96a8;

  /* Brand display face for major moments only (hero titles, auth page
     headings) - the frozen brand spec's own guidance: "bold, premium,
     confident, readable - not heavy, aggressive, shouty." The rest of
     the app stays on the fast system-font stack; this is not a
     wholesale typography replacement. */
  --display-face: "Anton", "Arial Narrow", sans-serif;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --accent-warm: var(--yellow);
  --accent-soft: #2a2033;
  --slot: var(--surface);
  --slot-2: var(--surface-2);
  --slot-border: var(--border);
  --text: var(--ink);
  --text-muted: var(--ink-muted);

  /* Typography scale - a rational reference scale for new work.
     The existing stylesheet has ~24 distinct font-size values grown
     organically over many features (many differing by half a pixel).
     These tokens are deliberately NOT retrofitted onto the ~500
     existing font-size declarations in this file - that would be a
     large, high-risk, mostly-invisible rewrite touching hundreds of
     already-working, already-tested rules. New components should use
     these; existing ones can migrate opportunistically when touched
     for an unrelated reason, not as a dedicated sweep. */
  --font-display: 32px;
  --font-h1: 24px;
  --font-h2: 18px;
  --font-h3: 15px;
  --font-body: 14px;
  --font-small: 12.5px;
  --font-caption: 11px;

  /* Spacing scale - same rationale as typography above. ~21 distinct
     spacing values exist today, most (not all) already loosely on a
     4px grid. These tokens formalize that grid for new work. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  font-size: 15.5px;
  color-scheme: light;
}

button, select, input { font-family: inherit; }
button { cursor: pointer; transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease; }

/* One consistent focus treatment for every text-style input - before
   this, only #search had any custom focus styling; every other text/
   password/search field in the app silently fell back to the
   browser's default blue ring, which is functionally fine for
   accessibility but visually inconsistent with the rest of the brand. */
input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="email"]:focus {
  outline: none; border-color: var(--accent);
}
button:active { transform: scale(0.94); }
.grid-tile:active { transform: scale(0.96); }
.deck-card:active, .combo-card:active, .shop-row:active { transform: scale(0.985); }
a { color: inherit; }

/* ---------- SHELL / LAYOUT ---------- */

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-main { flex: 1; padding-bottom: 76px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px; border: none; background: transparent;
  color: var(--ink-muted); font-size: 11px; font-weight: 700;
}
.tab-btn.active { color: var(--purple); }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active:hover { color: var(--purple); }

.tabbar-logo { display: none; }

@media (min-width: 860px) {
  .app-shell { flex-direction: row; }
  .tabbar {
    position: sticky; top: 0; left: 0; bottom: auto;
    flex-direction: column; width: 200px; height: 100vh;
    border-top: none; border-right: 1px solid var(--border);
    box-shadow: none;
    padding: 20px 12px; gap: 6px; align-items: stretch;
  }
  .tabbar-logo { display: block; padding: 6px 10px 22px; }
  .tabbar-logo img { width: 100%; height: auto; display: block; }
  .tab-btn { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
  .tab-btn.active { background: var(--purple); color: #fff; }
  .tab-btn.active:hover { color: #fff; }
  .app-main { padding-bottom: 0; max-width: 1080px; }
  .card-list.grid-mode { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .overlay-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---------- HEADER ---------- */

.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 20px 18px 12px; }
.topbar h1 { margin: 0 0 10px; font-size: 32px; font-weight: 900; letter-spacing: -0.02em; color: var(--ink); }
.subhead { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-muted); line-height: 1.4; max-width: 480px; }
.sample-csv-link {
  display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--accent);
  text-decoration: none; border-bottom: 1.5px solid var(--accent); padding-bottom: 1px;
}
.sample-csv-link:hover { opacity: 0.8; }
.u-side-padding { padding: 0 16px 10px; }
.u-full-width { width: 100%; }
.u-toggle-spacing { margin: 0 16px 12px; }
.u-display-contents { display: contents; }
.u-padding-sm { padding: 6px; }
.u-padding-md { padding: 10px; }
.u-full-width-mt10 { width: 100%; margin-top: 10px; }
.u-mt16 { margin-top: 16px; }
.u-mt8 { margin-top: 8px; }
.u-mb4 { margin-bottom: 4px; }
.u-w120 { width: 120px; }
.empty-state-cta { text-align: center; padding: 20px 16px; }
.empty-state-cta p { margin: 0 0 14px; color: var(--ink-muted); font-size: 13.5px; }
.empty-state-cta button { padding: 11px 20px; border-radius: var(--radius-sm); border: none; background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: 14px; cursor: pointer; }
.change-password-form { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.change-password-form[hidden] { display: none; }
.change-password-form input { padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); font-size: 14px; }
.change-password-success { color: var(--green); font-size: 12.5px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; }
.stats span {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  padding: 12px 16px; border-radius: var(--radius-md); flex: 1; min-width: 92px;
}
.stats span:nth-child(1) { background: var(--yellow); color: var(--yellow-ink); }
.stats span:nth-child(2) { background: var(--purple); color: #fff; }
.stats span:nth-child(3) { background: var(--pink); color: var(--pink-ink); }
.stats span::after { content: attr(data-label); }
.stats b { font-weight: 900; font-size: 24px; line-height: 1.1; letter-spacing: -0.02em; }

/* ---------- HERO ---------- */

.hero {
  position: relative;
  min-height: 220px;
  margin: 14px 16px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: radial-gradient(circle at 30% 20%, #b8a4f0, #8b6fe8 70%);
  background-size: cover;
  background-position: center 20%;
  transition: background-image 0.4s ease;
  display: flex;
  align-items: flex-end;
  box-shadow: 0 10px 30px rgba(139,111,232,0.25);
}

.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(26,22,38,0.05) 0%, rgba(26,22,38,0.45) 55%, rgba(26,22,38,0.85) 100%);
}

.hero-content { position: relative; padding: 18px 20px 20px; width: 100%; }
.hero-content h1 { margin: 8px 0 4px; font-size: 30px; font-weight: 900; letter-spacing: -0.02em; color: #fff; }
.hero-content p { margin: 0; font-size: 12.5px; color: rgba(255,255,255,0.8); max-width: 420px; }

.format-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 8px 16px; border-radius: 999px; border: none;
  background: rgba(255,255,255,0.22); color: #fff; font-size: 12.5px; font-weight: 700;
  backdrop-filter: blur(6px);
}
.pill.active { background: #fff; color: var(--purple); }
.pill:hover:not(.active) { background: rgba(255,255,255,0.32); }

/* Shopping/Combos tabs use pills directly on the page background (not
   the colored hero image), so they need real contrast instead of the
   translucent-white-on-color treatment above. */
#shopFormatPills .pill, #comboMissingPills .pill {
  background: var(--surface); color: var(--ink-muted); border: 1.5px solid var(--border);
  backdrop-filter: none;
}
#shopFormatPills .pill.active, #comboMissingPills .pill.active {
  background: var(--purple); color: #fff; border-color: var(--purple);
}
#shopFormatPills .pill:hover:not(.active), #comboMissingPills .pill:hover:not(.active) {
  background: var(--surface-2); color: var(--ink);
}

/* ---------- CONTROLS ---------- */

.controls { padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }

#search {
  width: 100%; padding: 13px 14px 13px 38px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); font-size: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
#search:focus { outline: none; border-color: var(--purple); }

.filter-row { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 9px 12px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); font-size: 13px; font-weight: 700;
}
.chip.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.chip:hover:not(.active) { border-color: var(--purple); color: var(--ink); }

.select-row { display: flex; gap: 8px; }
.select-row select { flex: 1; min-width: 0; }

/* One consistent select system for every dropdown in the app - closed
   state, focus state, disabled state, and (critically) the options
   list too, which browsers render as a separate popup that needs its
   own explicit styling or it silently falls back to a white background
   regardless of how the closed select looks. Previously only 3 of 13
   select elements across the app had any styling at all, and even
   those still showed a white options popup - this replaces all of
   that scattered, incomplete coverage with one rule everything uses. */
select.app-select {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 700;
}
select.app-select:focus { outline: none; border-color: var(--accent); }
select.app-select:disabled { opacity: 0.5; cursor: not-allowed; }
select.app-select option { background: var(--surface); color: var(--ink); }
#shopDeckSelect.app-select { width: 100%; }

.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.view-btn { padding: 10px 14px; border: none; background: var(--surface); color: var(--ink-muted); font-size: 13px; font-weight: 700; }
.view-btn.active { background: var(--purple); color: #fff; }
.view-btn:hover:not(.active) { color: var(--ink); }

.color-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-pips { display: flex; gap: 6px; }
.color-pip-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); font-size: 12px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.6; transition: opacity 0.15s ease, transform 0.15s ease;
}
.color-pip-btn:hover { opacity: 0.85; }
.color-pip-btn.active { opacity: 1; border-color: var(--ink); transform: scale(1.08); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.pip-w { background: var(--w); color: #6b5d1a; }
.pip-u { background: var(--u); color: #fff; }
.pip-b { background: var(--b); color: #fff; }
.pip-r { background: var(--r); color: #fff; }
.pip-g { background: var(--g); color: #fff; }
.pip-c { background: var(--c); color: #fff; }

.color-mode-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-left: auto; }
.deck-filter-controls { display: flex; gap: 10px; align-items: center; padding: 0 16px 14px; flex-wrap: wrap; }
.deck-filter-controls[hidden] { display: none; }
.deck-filter-controls .color-filter-row { flex: 0; }
#deckGamePlanFilter { padding: 9px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); font-size: 13px; }

.commander-synergies-section { padding: 0 16px 14px; }
.synergy-pair-card { background: var(--surface); border-radius: var(--radius-md); padding: 12px; margin-top: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.synergy-pair-header { display: flex; align-items: center; gap: 10px; }
.synergy-pair-images { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.synergy-pair-images img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.synergy-pair-names { font-size: 14px; font-weight: 800; color: var(--ink); }
.mode-btn { padding: 7px 12px; border: none; background: var(--surface); color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.mode-btn.active { background: var(--purple); color: #fff; }
.mode-btn:hover:not(.active) { color: var(--ink); }

/* ---------- CARD LIST / GRID ---------- */

.card-list { padding: 10px 12px 24px; display: flex; flex-direction: column; gap: 10px; }
.card-list.grid-mode { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 10px 12px 24px; }
.card-list.grid-mode .card-row { display: none; }
.card-list:not(.grid-mode) .grid-tile { display: none; }

.card-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-row:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.1); }

.card-row-clickable { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }

.row-thumb { width: 54px; height: 40px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); flex-shrink: 0; }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pip-stack { display: flex; flex-direction: column; gap: 2px; width: 6px; align-self: stretch; }
.pip { flex: 1; border-radius: 3px; min-height: 3px; background: var(--c); }

.card-main { flex: 1; min-width: 0; }
.card-name { font-size: 16.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.card-meta { font-size: 12px; color: var(--ink-muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }

.deck-tag, .tag-pill { font-size: 11px; background: var(--surface-2); color: var(--ink-muted); padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--border); }
.tag-pill { color: var(--purple); font-weight: 700; }

.qty { font-size: 13px; color: var(--ink-muted); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; font-weight: 700; }

.override-btn, .sub-btn {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink-muted);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px; white-space: nowrap; min-height: 36px; font-weight: 700;
}
.override-btn:hover, .sub-btn:hover { border-color: var(--purple); color: var(--purple); }
.override-btn.on { color: #fff; background: var(--green); border-color: var(--green); }

.empty-state { grid-column: 1 / -1; text-align: center; color: var(--ink-muted); padding: 40px 20px; font-size: 14.5px; line-height: 1.5; }

.load-more-wrap { display: flex; justify-content: center; padding: 14px 16px 30px; gap: 10px; flex-wrap: wrap; }
.load-more-wrap[hidden] { display: none; }

#loadMore, #refreshDecks, #refreshShopping, #refreshCombos, .import-panel button {
  padding: 13px 26px; border-radius: 999px; border: none;
  background: var(--purple); color: #fff; font-size: 14.5px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(139,111,232,0.3);
}
#loadMore:hover, #refreshDecks:hover, #refreshShopping:hover, #refreshCombos:hover, .import-panel button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(139,111,232,0.4); }
#loadMore:disabled, #refreshDecks:disabled, #refreshShopping:disabled, #refreshCombos:disabled, .import-panel button:disabled { opacity: 0.4; pointer-events: none; box-shadow: none; }

.deck-check-buttons { gap: 10px; flex-wrap: wrap; }
.secondary-btn {
  padding: 13px 26px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); font-size: 14.5px; font-weight: 800;
}
.secondary-btn:hover { border-color: var(--purple); color: var(--purple); }
.secondary-btn.stopping { border-color: var(--bad); color: var(--bad); }
.secondary-btn:disabled { opacity: 0.4; pointer-events: none; }

/* The one primary/CTA button style - matches the indigo pattern already
   used for auth submit buttons and empty-state CTAs, made reusable
   instead of redefined ad-hoc wherever a primary action shows up. */
.primary-btn {
  padding: 12px 24px; border-radius: var(--radius-sm); border: none;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: 14px;
}
.primary-btn:hover { opacity: 0.88; }
.primary-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.primary-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ---------- GRID TILES ---------- */

.grid-tile {
  position: relative; border-radius: var(--radius-md); overflow: hidden; aspect-ratio: 5 / 7;
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.grid-tile:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 14px 28px rgba(0,0,0,0.18); z-index: 2; }

.grid-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-tile .no-art { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; font-size: 11px; color: var(--ink-muted); line-height: 1.3; background: var(--surface-2); }
.grid-tile .tile-qty { position: absolute; top: 5px; right: 5px; background: rgba(26,22,38,0.85); color: #fff; font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; font-weight: 700; }
.grid-tile .tile-pips { position: absolute; top: 5px; left: 5px; display: flex; gap: 2px; }
.grid-tile .tile-pip { width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); background: var(--c); }
.grid-tile .tile-deck { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(26,22,38,0.92)); color: #fff; font-size: 9.5px; padding: 16px 6px 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }

.subs-panel { margin-top: 8px; padding: 10px; background: var(--surface-2); border: 1.5px dashed var(--border); border-radius: var(--radius-sm); font-size: 12.5px; }
.subs-panel .sub-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.subs-panel .sub-row:last-child { border-bottom: none; }
.sub-thumb { width: 30px; height: 42px; border-radius: 5px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.sub-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sub-info { flex: 1; min-width: 0; }
.sub-score { color: var(--purple); font-variant-numeric: tabular-nums; font-weight: 800; }
.conf-high { color: var(--good); }
.conf-mid { color: var(--yellow-ink); }
.conf-low { color: var(--ink-muted); }
.retry-btn {
  border: none; background: var(--purple); color: #fff;
  border-radius: 999px; padding: 8px 16px; font-size: 12.5px; font-weight: 800; margin-top: 8px;
}
.retry-btn:hover { transform: translateY(-1px); }

/* ---------- DECKS TAB ---------- */

.decks-list { padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.deck-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.deck-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.12); }

.deck-thumb { width: 58px; height: 80px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); flex-shrink: 0; box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.deck-thumb img { width: 100%; height: 100%; object-fit: cover; }

.deck-info { flex: 1; min-width: 0; }
.deck-name { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.deck-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; font-weight: 600; }
.deck-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.deck-actions button { font-size: 13px; padding: 9px 14px; min-height: 36px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--ink-muted); font-weight: 700; }
.deck-actions button:hover { border-color: var(--purple); color: var(--purple); }

.ring {
  --pct: 0; width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--surface-2) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-size: 11.5px; font-weight: 900; color: var(--ink); z-index: 1; }

.deck-detail { margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; }

.gap-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.gap-row:last-child { border-bottom: none; }
.gap-main { display: flex; align-items: center; gap: 8px; }
.gap-thumb { width: 46px; height: 33px; border-radius: 6px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.gap-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gap-name { flex: 1; font-weight: 700; font-size: 13.5px; color: var(--ink); }

.gap-sub {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 0 54px;
  padding: 8px; background: var(--surface); border-radius: var(--radius-sm); font-size: 12px;
}
.gap-sub-info { flex: 1; color: var(--ink-muted); }
.gap-sub-info b { color: var(--ink); font-weight: 800; }
.gap-sub-info .sub-score { display: block; font-size: 11px; margin-top: 1px; }

.progress-note { text-align: center; font-size: 12px; color: var(--ink-muted); padding: 8px 0; font-weight: 700; }

/* ---------- MY DECKS ---------- */

.mydeck-card { align-items: flex-start; }

.mydeck-card-compact { align-items: center; }
/* ---------- UNIFIED BADGE SYSTEM ----------
   Every badge across the app (deck bracket, format, game plan, value
   score, "you own this", combo piece, overlay corner tags) previously
   had its own font-size (ranged 9px-12.5px), its own padding, and in
   one case (.own-this-badge) wasn't even a pill shape at all. Badges
   now share one consistent shape/size/weight below; only background
   color is meaningful, which is what a real design system looks like
   instead of each one being styled in isolation as it was added. */
.mydeck-badge, .overlay-badge, .tile-value-badge, .own-this-badge {
  font-size: 10.5px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  line-height: 1.4; letter-spacing: 0.01em;
}
.mydeck-badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.mydeck-badge {
  background: var(--surface-2); color: var(--ink-muted);
}
.mydeck-badge.format { background: var(--blue); color: #fff; }
.mydeck-badge.bracket-1, .mydeck-badge.bracket-2 { background: var(--surface-2); color: var(--ink-muted); border: 1.5px solid var(--border); }
.mydeck-badge.bracket-3 { background: var(--purple); color: #fff; }
.mydeck-badge.bracket-4 { background: var(--yellow); color: var(--yellow-ink); }
.mydeck-badge.bracket-5 { background: var(--coral); color: #fff; }
.mydeck-badge.unowned-commander { background: var(--coral); color: #fff; }
.manage-deck-btn {
  border: none; background: var(--purple); color: #fff; font-weight: 800; font-size: 13px;
  padding: 10px 16px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
}
.manage-deck-btn:hover { transform: translateY(-1px); }

.mydeck-overlay-nav {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.mydeck-nav-btn {
  flex-shrink: 0; padding: 9px 15px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.mydeck-nav-btn.active { background: var(--purple); border-color: var(--purple); color: #fff; }
.mydeck-nav-btn:hover:not(.active) { border-color: var(--purple); color: var(--purple); }

.mydeck-overlay-body { padding: 16px; max-width: 640px; margin: 0 auto; }
@media (min-width: 860px) { .mydeck-overlay-body { max-width: 1100px; } }
.overview-block { background: var(--surface); border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.overview-label { font-size: 12px; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }

.sidegrade-pair-images { display: flex; align-items: center; gap: 6px; }
.sidegrade-pair-images .grid-tile { flex: 1; aspect-ratio: 5/7; }
.sidegrade-pair .sidegrade-arrow { flex-shrink: 0; font-size: 18px; color: var(--green); font-weight: 900; }
.sidegrade-label { font-size: 12px; font-weight: 700; color: var(--ink); text-align: center; }
.own-this-badge { color: #fff; background: var(--good); text-align: center; margin-top: 4px; display: inline-block; }

.deck-format-select { margin-top: 8px; padding: 7px 11px; font-size: 12.5px; }

.suggest-bracket-btn, .tokens-btn, .sideboard-btn, .breakdown-btn, .sidegrades-btn {
  font-size: 13px; padding: 9px 14px; min-height: 36px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); margin-top: 6px; font-weight: 700;
}
.suggest-bracket-btn:hover, .tokens-btn:hover, .sideboard-btn:hover, .breakdown-btn:hover { border-color: var(--purple); color: var(--purple); }
.sidegrades-btn { background: var(--green); border-color: var(--green); color: #fff; }
.sidegrades-btn:hover { transform: translateY(-1px); }

.bracket-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.bracket-row-label { font-size: 12.5px; color: var(--ink-muted); flex: 1; font-weight: 700; }
.bracket-pips { display: flex; gap: 4px; }
.bracket-pip {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); font-size: 14px; font-weight: 900;
}
.bracket-pip:hover { border-color: var(--purple); color: var(--purple); }
.bracket-pip.active { background: var(--purple); border-color: var(--purple); color: #fff; }
.bracket-pip[data-bracket="5"].active { background: var(--coral); border-color: var(--coral); color: #fff; }
.bracket-pip[data-bracket="4"].active { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }

.deck-commander-line { font-size: 13px; color: var(--ink-muted); margin-top: 8px; font-weight: 600; }
.deck-commander-line b { color: var(--ink); }
.change-commander-btn, .set-commander-btn, .confirm-commander-btn, .pick-commander-btn {
  font-size: 13px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); margin-left: 6px; min-height: 36px; font-weight: 700;
}
.change-commander-btn:hover, .set-commander-btn:hover, .confirm-commander-btn:hover, .pick-commander-btn:hover {
  border-color: var(--purple); color: var(--purple);
}
.set-commander-btn { margin-top: 8px; margin-left: 0; }

.commander-picker { margin-top: 8px; padding: 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12.5px; }
.commander-search-input {
  width: 100%; padding: 12px 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 15px; margin-bottom: 8px;
}
.commander-search-hint { font-size: 11px; color: var(--ink-muted); padding: 4px 0; font-weight: 700; }
.manual-commander-input {
  padding: 7px 10px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 12.5px; margin-top: 6px; margin-right: 6px;
}

.bracket-suggestion-box { margin-top: 8px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12.5px; }
.bracket-suggest-result { font-weight: 800; margin-bottom: 6px; color: var(--ink); }
.bracket-reasons { margin: 0 0 8px; padding-left: 18px; color: var(--ink-muted); }
.bracket-reasons li { margin-bottom: 3px; }
.bracket-caveat { font-size: 11px; color: var(--ink-muted); font-style: italic; margin-bottom: 8px; }
.apply-bracket-btn {
  font-size: 13px; font-weight: 800; padding: 9px 16px; min-height: 36px; border-radius: 999px;
  border: none; background: var(--purple); color: #fff;
}
.apply-bracket-btn:hover { transform: translateY(-1px); }

.sb-toggle-btn {
  font-size: 13px; padding: 8px 14px; min-height: 36px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink-muted); font-weight: 700;
}
.sb-toggle-btn.on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }

.breakdown-section { margin-bottom: 16px; }
.breakdown-section:last-child { margin-bottom: 0; }
.breakdown-title { font-size: 12px; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.breakdown-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 12.5px; }
.breakdown-label { width: 100px; flex-shrink: 0; color: var(--ink-muted); text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.breakdown-bar-track { flex: 1; height: 11px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.breakdown-bar-fill { height: 100%; background: var(--purple); border-radius: 999px; }
.breakdown-bar-fill.type { background: var(--yellow); }
.breakdown-count { width: 22px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 800; }

.sidegrade-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sidegrade-row:last-child { border-bottom: none; }
.sidegrade-card { text-align: center; }
.sidegrade-label { font-size: 11.5px; margin-top: 4px; font-weight: 600; color: var(--ink); }
.sidegrade-arrow { font-size: 18px; color: var(--green); font-weight: 900; }
.sidegrade-reasons { grid-column: 1 / -1; font-size: 11px; color: var(--good); text-align: center; margin-top: 4px; font-weight: 700; }

.missing-sub-inline { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }

/* ---------- SHOPPING LIST ---------- */

.shopping-list { padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.shop-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.shop-row:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }

.shop-thumb { width: 52px; height: 73px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; }

.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 14.5px; font-weight: 800; color: var(--ink); }
.shop-decks { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }

.shop-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.shop-count {
  font-size: 13px; font-weight: 900; color: var(--green-ink);
  background: rgba(62,203,150,0.16); padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.cardmarket-btn {
  font-size: 13px; font-weight: 800; padding: 8px 14px; border-radius: 999px; min-height: 36px;
  border: none; background: var(--coral); color: #fff; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
}
.cardmarket-btn:hover { transform: translateY(-1px); }

/* ---------- IMPORT TAB ---------- */

.import-panel { padding: 16px; display: flex; flex-direction: column; gap: 18px; max-width: 520px; }
.import-step { display: flex; gap: 12px; }
.more-menu { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.more-menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left; padding: 16px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer;
}
.more-menu-item:hover { border-color: var(--purple); }
.more-menu-title { font-size: 15px; font-weight: 800; color: var(--ink); }
.more-menu-desc { font-size: 12.5px; color: var(--ink-muted); }
.account-section {
  margin: 20px 16px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); display: flex; flex-direction: column; align-items: stretch; gap: 10px;
}
.account-email { font-size: 13px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-plan-section { margin: 14px 0; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.account-plan-label { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 4px; }
.account-plan-value { font-size: 18px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.account-plan-detail { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 10px; }
.account-plan-section .primary-btn, .account-plan-section .secondary-btn { margin-top: 4px; }
.billing-interval-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.interval-option {
  flex: 1; padding: 10px 8px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--bg); color: var(--ink-muted); font-size: 12.5px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
.interval-option.active { border-color: var(--primary); color: var(--ink); background: rgba(117,103,255,0.08); }
.interval-price { font-size: 14px; font-weight: 800; color: var(--ink); }
.interval-save { position: absolute; top: -8px; right: 6px; background: var(--good); color: #04260f; font-size: 9.5px; font-weight: 800; padding: 2px 6px; border-radius: 999px; }
.account-logout-btn {
  flex-shrink: 0; padding: 9px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--bad);
  background: none; color: var(--bad); font-weight: 700; font-size: 13px; cursor: pointer;
}
.account-logout-btn:hover { background: var(--bad); color: #fff; }

.danger-link-btn {
  background: none; border: none; color: var(--ink-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 4px; text-align: center; text-decoration: underline;
}
.danger-link-btn:hover { color: var(--bad); }
.delete-account-warning { font-size: 12.5px; color: var(--bad); line-height: 1.5; margin: 0 0 4px; }
.danger-btn {
  padding: 12px; border-radius: var(--radius-sm); border: none; background: var(--bad);
  color: #fff; font-weight: 800; font-size: 14px; cursor: pointer;
}
.danger-btn:hover { opacity: 0.88; }

.discover-search-row { display: flex; gap: 8px; padding: 0 16px 10px; align-items: center; }
.discover-search-row .commander-search-input { flex: 1; }
#discoverRefineBtn { flex-shrink: 0; white-space: nowrap; }
.discover-banner {
  margin: 0 16px 14px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-md);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.discover-banner[hidden] { display: none; }
.discover-banner:hover { background: var(--surface); border: 1px solid var(--border); }

/* ---------- HOME DASHBOARD ---------- */

.home-hero {
  position: relative; padding: 28px 20px 20px; overflow: hidden;
  background: linear-gradient(160deg, #1a1b25 0%, #241820 100%);
  background-size: cover; background-position: center; transition: background-image 0.4s ease;
}
.home-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(14,15,22,0.35) 0%, rgba(14,15,22,0.9) 100%);
}
.home-hero-content { position: relative; z-index: 1; }
.home-hero-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.home-hero-title { font-family: var(--display-face); font-weight: 400; text-transform: uppercase; font-size: 26px; color: var(--ink); margin-top: 6px; letter-spacing: 0.01em; }
.home-hero-sub { font-size: 13.5px; color: var(--ink-muted); margin-top: 6px; font-weight: 600; }
.home-hero-cta { margin-top: 16px; padding: 12px 22px; font-size: 14px; }

.home-stats { position: relative; z-index: 1; display: flex; gap: 10px; margin-top: 20px; }
.home-stats[hidden] { display: none; }
.home-stat { flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md); padding: 12px; backdrop-filter: blur(6px); }
.home-stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); }
.home-stat-value { font-size: 18px; font-weight: 900; color: var(--ink); margin-top: 3px; }

.home-section { padding: 20px 16px 4px; }
.home-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.home-section-header h2 { font-size: 16px; font-weight: 900; color: var(--ink); }
.home-view-all { font-size: 12.5px; font-weight: 700; color: var(--accent); background: none; border: none; cursor: pointer; }

.home-carousel { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.home-carousel::-webkit-scrollbar { display: none; }
.home-carousel-card { flex: 0 0 auto; width: 110px; scroll-snap-align: start; }
.home-carousel-card img { width: 100%; aspect-ratio: 5/7; object-fit: cover; border-radius: var(--radius-sm); box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.home-carousel-card-label { font-size: 11px; font-weight: 700; color: var(--ink); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.home-deck-tile { flex: 0 0 auto; width: 130px; scroll-snap-align: start; cursor: pointer; }
.home-deck-tile-art { width: 100%; aspect-ratio: 5/7; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2); box-shadow: 0 6px 18px rgba(0,0,0,0.4); position: relative; }
.home-deck-tile-art img { width: 100%; height: 100%; object-fit: cover; }
.home-deck-tile-name { font-size: 12.5px; font-weight: 800; color: var(--ink); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-deck-tile-sub { font-size: 10.5px; color: var(--ink-muted); font-weight: 600; }
.home-deck-tile-create {
  width: 100%; aspect-ratio: 5/7; border-radius: var(--radius-md); border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--ink-muted); background: var(--surface);
}
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-body { flex: 1; }
.step-title { font-size: 15px; font-weight: 800; color: var(--ink); }
.step-desc { font-size: 12.5px; color: var(--ink-muted); margin: 3px 0 10px; line-height: 1.4; }

.file-btn {
  display: inline-block; padding: 10px 18px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 700; margin-right: 8px; cursor: pointer; transition: border-color 0.15s ease;
}
.file-btn:hover { border-color: var(--blue); }

.step-status { font-size: 12.5px; color: var(--ink-muted); margin-top: 8px; min-height: 16px; font-weight: 600; }
.step-status.ok { color: var(--good); }
.step-status.err { color: var(--bad); }

/* ---------- DECK OVERLAY ---------- */

.deck-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 30; overflow-y: auto; }

.checkout-modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.checkout-modal[hidden] { display: none; }
.checkout-modal-inner {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 20px;
}
.checkout-modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 1; width: 32px; height: 32px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 20px;
  display: flex; align-items: center; justify-content: center; border: none; cursor: pointer;
}
#checkoutEmbedContainer { min-height: 300px; }

.overlay-hero {
  position: relative; min-height: 200px;
  background: radial-gradient(circle at 30% 20%, #b8a4f0, #8b6fe8 70%);
  background-size: cover; background-position: center 20%;
  display: flex; flex-direction: column;
}

.overlay-hero .close-btn {
  position: relative; align-self: flex-start; margin: 14px 16px 0;
  border: none; background: rgba(26,22,38,0.5); backdrop-filter: blur(6px);
  color: #fff; font-size: 13px; font-weight: 700; padding: 9px 15px; border-radius: 999px;
}
.overlay-hero .close-btn:hover { background: rgba(26,22,38,0.7); }

.overlay-hero-content { position: relative; padding: 14px 20px 20px; margin-top: auto; }
.overlay-title { font-size: 24px; font-weight: 900; color: #fff; }
.overlay-sub { font-size: 12.5px; color: rgba(255,255,255,0.8); margin-top: 4px; }

.overlay-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px; }

.overlay-tile { position: relative; border-radius: var(--radius-md); overflow: hidden; aspect-ratio: 5 / 7; background: var(--surface-2); border: 1px solid var(--border); transition: transform 0.18s ease; box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.overlay-tile:hover { transform: translateY(-3px) scale(1.02); z-index: 2; }
.overlay-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.overlay-tile.missing img { filter: grayscale(0.85) brightness(0.85); opacity: 0.6; }
.overlay-tile.missing .no-art { color: var(--ink-muted); opacity: 0.6; }
.overlay-tile .no-art { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: 10.5px; color: var(--ink-muted); line-height: 1.3; background: var(--surface-2); }

.overlay-badge { position: absolute; top: 5px; right: 5px; }
.overlay-badge.owned { background: var(--green); color: #fff; }
.overlay-badge.missing { background: var(--bad); color: #fff; }
.overlay-badge.commander { background: var(--yellow); color: var(--yellow-ink); }

.overlay-tile.is-commander { border: 2px solid var(--yellow); grid-column: span 2; grid-row: span 2; }

.overlay-tile .overlay-name { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(26,22,38,0.92)); color: #fff; font-size: 9.5px; padding: 16px 6px 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }

/* ---------- DRAFT TAB ---------- */

.new-draft-row { display: flex; gap: 8px; margin-top: 8px; }
.new-draft-row input {
  flex: 1; padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 15px;
}
#createDraftBtn { width: auto; padding: 12px 20px; border-radius: var(--radius-sm); border: none; background: var(--purple); color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap; }

.draft-card .deck-thumb { background: var(--surface-2); }

.draft-progress { padding: 16px; max-width: 640px; margin: 0 auto; }
.draft-add-section, .draft-picks-section, .draft-template-editor { padding: 0 16px 16px; max-width: 640px; margin: 0 auto; }
.draft-add-section .commander-search-input { margin-top: 8px; }

@media (min-width: 860px) {
  .draft-add-section, .draft-picks-section { max-width: 1100px; }
}
.draft-danger-zone { padding: 8px 16px 40px; max-width: 640px; margin: 0 auto; text-align: center; }
.draft-danger-zone .secondary-btn { border-color: var(--bad); color: var(--bad); width: auto; padding: 10px 20px; }

.template-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 600;
}
.template-edit-row:last-child { border-bottom: none; }
.template-target-input {
  width: 60px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; text-align: center;
}

.draft-progress-row.clickable { cursor: pointer; padding: 6px 4px; border-radius: var(--radius-sm); transition: background 0.15s ease; }
.draft-progress-row.clickable:hover { background: var(--surface-2); }

.draft-browse-panel {
  margin-top: 12px; padding: 14px; background: var(--surface); border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.browse-panel-header { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 800; margin-bottom: 10px; }
.close-browse-btn { border: none; background: var(--surface-2); color: var(--ink-muted); width: 28px; height: 28px; border-radius: 50%; font-size: 18px; line-height: 1; }

.creature-type-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.creature-type-chip { padding: 6px 12px; font-size: 12px; }
.filter-group-label { font-size: 11px; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }

.draft-browse-results { max-height: 70vh; overflow-y: auto; margin-top: 8px; }
.draft-browse-thumb { cursor: pointer; }

.draft-grid { display: grid; grid-template-columns: repeat(1, 1fr); gap: 16px; padding: 4px 0; }
.draft-grid-tile { display: flex; flex-direction: column; gap: 8px; }
.draft-grid-tile .grid-tile { aspect-ratio: 5/7; cursor: pointer; max-width: 280px; margin: 0 auto; width: 100%; }
.tile-overlap-badge {
  background: rgba(139,111,232,0.92); color: #fff; font-size: 11px; font-weight: 800;
  padding: 4px 8px; border-radius: 6px; text-align: center;
}
.tile-badge-stack {
  position: absolute; bottom: 5px; left: 5px; right: 5px;
  display: flex; flex-direction: column; gap: 3px;
}
.add-draft-card-btn {
  border: none; background: var(--green); color: #fff; font-weight: 800; font-size: 15px;
  padding: 12px 0; border-radius: 999px; max-width: 280px; width: 100%; margin: 0 auto; display: block;
}
.add-draft-card-btn:hover { transform: translateY(-1px); }

.pick-category-select { max-width: 280px; width: 100%; margin: 0 auto; display: block; }
.gap-thumb[data-card-id] { cursor: pointer; }

@media (min-width: 380px) { .draft-grid { grid-template-columns: repeat(2, 1fr); } .draft-grid-tile .grid-tile { max-width: none; } .add-draft-card-btn, .pick-category-select { max-width: none; } }
@media (min-width: 600px) { .draft-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) {
  .draft-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
}

.overlay-subs-section { padding: 8px 14px 30px; }
.overlay-subs-title { font-size: 13px; font-weight: 800; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }

.commander-spotlight {
  display: flex; flex-direction: column; align-items: center; padding: 20px 14px 8px;
}
.commander-spotlight-card {
  width: 190px; aspect-ratio: 5/7; border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 0 0 3px var(--yellow), 0 20px 50px rgba(139,111,232,0.4), 0 0 60px rgba(247,201,72,0.35);
  animation: spotlight-in 0.3s ease;
}
.commander-spotlight-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.commander-spotlight { flex-wrap: wrap; flex-direction: row; justify-content: center; gap: 10px; }
.commander-spotlight .commander-spotlight-label { width: 100%; text-align: center; order: 10; }
.commander-spotlight-card { width: 150px; }
.commander-spotlight-label {
  margin-top: 10px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--yellow-ink); background: var(--yellow); padding: 4px 14px; border-radius: 999px;
}
@keyframes spotlight-in { from { transform: scale(0.9) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.overlay-sub-row {
  display: flex; align-items: center; gap: 8px; padding: 12px;
  background: var(--surface); border-radius: var(--radius-md); margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.overlay-sub-arrow { font-size: 16px; color: var(--green); font-weight: 900; flex-shrink: 0; }
.overlay-sub-info { flex: 1; min-width: 0; font-size: 12.5px; }
.overlay-sub-info b { display: block; color: var(--ink); font-weight: 800; }

/* ---------- PER-TAB COLOR PERSONALITY ---------- */

#tab-shopping .topbar h1 { color: var(--green-ink); }
#tab-shopping #refreshShopping { background: var(--green); box-shadow: 0 6px 18px rgba(62,203,150,0.3); }
#tab-shopping #refreshShopping:hover { box-shadow: 0 8px 22px rgba(62,203,150,0.4); }

#tab-combos .topbar h1 { color: var(--purple); }
#tab-combos #refreshCombos { background: var(--purple); }
#tab-combos .combo-produces { color: var(--purple); }
#tab-combos .build-around-btn:hover { border-color: var(--purple); color: var(--purple); }

#tab-import .topbar h1 { color: var(--blue-ink); }

/* ---------- COMBOS TAB ---------- */

.combo-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 3px 14px rgba(0,0,0,0.06);
}
.combo-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.12); }

.combo-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.combo-tile { aspect-ratio: 5/7; }

.combo-info { margin-top: 12px; }
.combo-produces { font-size: 14px; font-weight: 800; }
.combo-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.build-around-btn {
  font-size: 13px; font-weight: 700; padding: 9px 14px; min-height: 36px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink-muted);
}

.combo-build-ideas { margin-top: 8px; padding: 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 12.5px; }

img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.image-lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(26,22,38,0.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade-in 0.15s ease;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox img {
  max-width: 92vw; max-height: 88vh; border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: lightbox-in 0.18s ease;
}
@keyframes lightbox-in { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

html.app-locked .app-shell { display: none !important; }
html.app-unlocked #lockScreen { display: none !important; }

.lock-screen {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(160deg, #14151f 0%, #1c1d2a 60%, #24202f 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lock-screen-inner { text-align: center; max-width: 340px; }
.lock-icon { font-size: 40px; margin-bottom: 8px; }
.lock-screen-inner h1 { font-size: 26px; font-weight: 900; margin: 0 0 6px; color: var(--ink); }
.lock-screen-inner p { font-size: 14px; color: var(--ink-muted); margin: 0 0 26px; }

.lock-lands { display: flex; flex-direction: column; gap: 10px; }
.lock-land {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-radius: 999px; border: none; background: var(--surface);
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  font-size: 15px; font-weight: 700; color: var(--ink);
}
.lock-land:active { transform: scale(0.97); }
.lock-land.selected {
  background: var(--good); color: #fff; box-shadow: 0 4px 16px rgba(47,174,122,0.35);
}
.lock-land-icon { width: 26px; height: 26px; flex-shrink: 0; object-fit: contain; }

@keyframes unlock-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
.lock-screen-inner.unlocking { animation: unlock-pulse 0.4s ease; }

/* ---------- CARD DETAIL MODAL ---------- */

.card-detail-modal { position: fixed; inset: 0; z-index: 60; }
.card-detail-backdrop { position: absolute; inset: 0; background: rgba(26,22,38,0.5); backdrop-filter: blur(4px); }

.card-detail-sheet {
  position: absolute; inset: 0; overflow-y: auto;
  background: var(--bg); animation: sheet-in 0.22s ease;
}
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.card-detail-close {
  position: sticky; top: 14px; left: 16px; z-index: 2;
  background: var(--surface); box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  border: none; color: var(--ink); font-size: 13px; font-weight: 700; padding: 9px 15px; border-radius: 999px;
}

.card-detail-body { padding: 4px 20px 40px; max-width: 720px; margin: 0 auto; }

.card-detail-image-wrap { display: flex; justify-content: center; margin-bottom: 20px; perspective: 1000px; }

.holo-card {
  position: relative; width: 100%; max-width: 340px;
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%; --holo-opacity: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.15s ease-out;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,0.4), 0 2px 10px rgba(0,0,0,0.35);
  cursor: pointer;
}
.holo-card img {
  width: 100%; display: block; border-radius: var(--radius-lg);
}
.holo-card img[hidden] { display: none; }
.holo-card-no-image {
  aspect-ratio: 5/7; background: linear-gradient(160deg, var(--surface-2), var(--surface));
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px;
}
.holo-card-no-image::after {
  content: "Image not loaded yet — update your card data in More → Import & Setup.";
  font-size: 13px; color: var(--ink-muted); line-height: 1.5;
}
.holo-shine {
  position: absolute; inset: 0; border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at var(--mx) var(--my), rgba(255,255,255,0.55) 0%, transparent 55%),
    conic-gradient(from 180deg at var(--mx) var(--my),
      rgba(255,90,120,0.45), rgba(255,180,70,0.45), rgba(250,240,90,0.45),
      rgba(90,220,150,0.45), rgba(90,180,255,0.45), rgba(190,120,255,0.45),
      rgba(255,90,120,0.45));
  mix-blend-mode: overlay;
  opacity: var(--holo-opacity);
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.card-detail-name { font-size: 27px; font-weight: 900; letter-spacing: -0.01em; color: var(--ink); }
.card-detail-typeline { font-size: 16px; color: var(--ink-muted); margin-top: 4px; font-weight: 600; }
.card-detail-oracle {
  font-size: 17px; line-height: 1.55; margin-top: 16px; white-space: pre-line; color: var(--ink);
  background: var(--surface); border-radius: var(--radius-md); padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.card-detail-meta { font-size: 14px; color: var(--ink-muted); margin-top: 12px; display: flex; gap: 14px; flex-wrap: wrap; font-weight: 600; }
.card-detail-actions { margin-top: 18px; }
.card-detail-similar { margin-top: 14px; }
.card-detail-value { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.value-score-badge { font-size: 12.5px; font-weight: 800; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); }
.value-score-badge.conf-high { background: rgba(47,174,122,0.15); color: var(--good); }
.value-score-badge.conf-mid { background: rgba(247,201,72,0.2); color: var(--yellow-ink); }
.value-score-badge.conf-low { background: var(--surface-2); color: var(--ink-muted); }
.value-score-note { font-size: 11.5px; color: var(--ink-muted); }
.tile-value-badge {
  position: absolute; top: 5px; left: 5px; background: rgba(26,22,38,0.85); color: #fff;
}
.tile-value-badge.conf-high { background: rgba(47,174,122,0.9); }
.tile-value-badge.conf-mid { background: rgba(247,201,72,0.9); color: #4a3a06; }
.tile-value-badge.conf-low { background: rgba(26,22,38,0.7); }

.game-plan-hint { font-size: 12px; color: var(--ink-muted); margin: 0 0 10px; line-height: 1.4; }
.game-plan-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.game-plan-chip { padding: 8px 14px; font-size: 12.5px; }
.game-plan-chip.recommended:not(.active) { border-color: var(--yellow); color: var(--yellow-ink); }

.emergent-plan-box { margin-top: 6px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-md); }
.emergent-plan-label { font-size: 11.5px; font-weight: 800; color: var(--ink-muted); margin-bottom: 8px; }
.emergent-plan-chip { background: var(--green); color: #fff; border: none; padding: 8px 14px; font-size: 12.5px; margin-right: 6px; margin-bottom: 6px; }
.emergent-count { opacity: 0.85; font-weight: 600; }
.game-plan-match-badge { background: rgba(62,203,150,0.92) !important; }
.combo-piece-badge { background: rgba(255,111,94,0.92) !important; }

@media (min-width: 700px) {
  .card-detail-body { display: flex; gap: 32px; align-items: flex-start; padding-top: 20px; }
  .card-detail-image-wrap { flex-shrink: 0; margin-bottom: 0; }
  .card-detail-info { flex: 1; }
}

/* ---------- TOASTS ---------- */

.toast-container {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
@media (min-width: 860px) { .toast-container { bottom: 24px; } }

.toast {
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.25s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--bad); }
.toast-icon::before { content: "✓"; }
.toast.error .toast-icon::before { content: "✕"; }
.toast-retry {
  border: 1.5px solid #fff; background: transparent; color: #fff;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 800; pointer-events: auto;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }
.toast.leaving { animation: toast-out 0.2s ease forwards; }

/* ---------- SKELETON LOADERS ---------- */

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

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #33323f 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 10px 12px; }
.skeleton-tile { aspect-ratio: 5/7; border-radius: var(--radius-md); }

.skeleton-row { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface); border-radius: var(--radius-md); margin-bottom: 4px; }
.skeleton-row .skeleton-thumb { width: 52px; height: 38px; border-radius: var(--radius-sm); flex-shrink: 0; }
.skeleton-row .skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-line { height: 12px; border-radius: 6px; }
.skeleton-line.short { width: 40%; }

.fade-in { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
