/**
 * card_gallery.css - Card Gallery Styles
 * Extracted from card_gallery.php for better maintainability
 */

/* SET BANNER - transparent PNG, no shadow artifacts */
.set-banner,
.set-banner img {
    box-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}
.set-banner img {
    display: block;
}

/* HEADER ROW 1: Icon-Title and Set-Code */
.header-row-1 {
    display: flex;
    align-items: center;
    gap: 0px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

/* Set title group */
.set-title-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.set-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.set-icon-svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.set-icon-fallback {
    font-size: 16px;
}

.set-title-text {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

/* Set code badge */
.set-code-badge {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    gap: 4px;
}

html.dark-mode .set-code-badge {
    background: #374151;
    color: #9ca3af;
}

.set-code-text {
    margin-left: 4px;
}

/* Subset Tabs Styling - Folder Tab Style */
.subset-tabs-container {
    margin-bottom: 0;
    overflow: visible;
    position: relative;
}

.subset-tabs-wrapper {
    display: flex;
    gap: 2px;
    padding: 0;
    flex-wrap: wrap;
    align-items: flex-end;
}

.subset-tab {
    display: inline-block;
    padding: 8px 18px;
    background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
    border: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    border-radius: 6px 6px 0 0;
    color: #666;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s ease;
    position: relative;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.06);
}

.subset-tab:hover {
    background: linear-gradient(to bottom, #ffffff, #f0f0f0);
    color: #333;
    text-decoration: none;
}

.subset-tab.active {
    background: #ffffff;
    border-color: #ccc;
    border-bottom-color: transparent;
    color: #333;
    font-weight: 600;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.08);
    z-index: 1;
}

.subset-tab.active:hover {
    background: #ffffff;
    color: #333;
}

/* Dark mode */
html.dark-mode .subset-tab {
    background: linear-gradient(to bottom, #2d3748, #252d3a);
    border-color: #4b5563;
    color: #9ca3af;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.2);
}

html.dark-mode .subset-tab:hover {
    background: linear-gradient(to bottom, #374151, #2d3748);
    color: #d1d5db;
}

html.dark-mode .subset-tab.active {
    background: #1a1f2e;
    border-color: #4b5563;
    border-bottom-color: transparent;
    color: #f3f4f6;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.25);
}

html.dark-mode .subset-tab.active:hover {
    background: #1a1f2e;
    color: #f3f4f6;
}

/* Mobile */
@media (max-width: 768px) {
    .subset-tabs-container {
        margin-left: -10px;
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .subset-tab {
        font-size: 12px;
        padding: 6px 14px;
    }
}

.master-set-table {
    font-size: 0.9rem;
}

.master-table-thumb {
    width: 45px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.variant-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.variant-normal { background: #e9ecef; color: #495057; }
.variant-foil { background: linear-gradient(135deg, #ffd700, #ffec8b); color: #856404; }
.variant-holofoil { background: linear-gradient(135deg, #c0c0c0, #e8e8e8); color: #495057; }
.variant-reverseholofoil { background: linear-gradient(135deg, #87ceeb, #b0e0e6); color: #0c5460; }

.master-owned-checkbox {
    width: 1.2em;
    height: 1.2em;
    cursor: pointer;
}

html.dark-mode .master-set-table {
    color: #e2e8f0;
}

html.dark-mode .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}

html.dark-mode .table-success {
    background-color: rgba(40, 167, 69, 0.2) !important;
}

/* Header styles */
.header-row-1 {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    margin-bottom: 4px;
}

.title-tabs-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.set-title-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.set-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.set-icon-svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.set-icon-fallback {
    font-size: 16px;
}

.set-title-text {
    font-size: 1.2rem;
    line-height: 1.1;
}

/* Release date displayed next to set title */
.set-release-date {
    font-size: 12px;
    color: #888;
    font-weight: 400;
    white-space: nowrap;
    align-self: center;
    margin-left: 4px;
}

html.dark-mode .set-release-date {
    color: #aaa;
}

/* Owned count in stat items (e.g. "205/264") */
.owned-count {
    color: #28a745;
    font-weight: 700;
}

.owned-count.owned-count-master {
    color: #6f42c1;
}

.owned-separator {
    color: #999;
    margin: 0;
    font-weight: 400;
}

html.dark-mode .owned-separator {
    color: #777;
}

/* Flash animation when owned count updates */
@keyframes ownedCountFlash {
    0% { opacity: 1; }
    30% { opacity: 0.4; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}

.owned-count.flash {
    animation: ownedCountFlash 0.4s ease-out;
}

/* ============================================
   STICKY SET INFO - Pins set name & stats on scroll
   ============================================ */
.sticky-set-info {
    position: sticky;
    top: 0; /* Overridden by JS to sit below main header */
    z-index: 1040; /* Below main header (1050) but above content */
    background-color: #ffffff;
    padding-top: 2px; /* Reduced: transferred space to below the progress bar */
    padding-bottom: 0; /* Progress bar is the bottom edge */
    /* Extend background 2px upward to cover any subpixel gap between
       this element and the sticky main header above it */
    box-shadow: 0 -2px 0 2px #ffffff;
}

html.dark-mode .sticky-set-info {
    background-color: #182433;
    box-shadow: 0 -2px 0 2px #182433;
}

/* When stuck, no extra bottom padding — the bar itself is the bottom edge */
.sticky-set-info.is-stuck {
    padding-bottom: 0;
}

.sticky-set-info.is-stuck .header-row-1 {
    margin-bottom: 4px;
}

.sticky-set-info.is-stuck .info-row-2-fullwidth {
    margin-bottom: 0;
}

.info-row-2-fullwidth {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    align-items: center;
}

/* ============================================
   SET INFO PROGRESS BAR - Inside sticky-set-info,
   below badge numbers
   ============================================ */
.set-info-progress-bar-section {
    display: none; /* Hidden by default, shown via JS */
    width: 100%;
    padding: 6px 0 12px; /* 6px above bar, 12px below (includes transferred space from top) */
}

.set-info-progress-bar-section .header-progress-bar-container {
    width: 100%;
}

/* Cards don't scroll tight against the bar when stuck */
.sticky-set-info.is-stuck + * {
    margin-top: 12px;
}

/* No dash separators — spacing handles visual grouping */

/* Column 2: Tabs */
.col-tabs {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-left: 4px;
}

.col-tabs-empty {
    /* Empty space when no tabs exist */
}

.tab-buttons-container {
    display: flex;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 2px;
    gap: 1px;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background: #e9ecef;
    color: #333;
}

.tab-button.active {
    background: #0d6efd;
    color: white;
    font-weight: 500;
}

/* Column 3: Sort */
.col-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sort-label-fixed {
    font-size: 13px;
    margin: 0;
    color: #666;
}

.sort-select-fixed {
    min-width: 140px;
    font-size: 13px;
}

/* Tab Content */
.tab-content-area {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 15px;
}

.tab-content-panel h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1rem;
}

.tab-content-panel p {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Dark mode */
html.dark-mode .set-title-text {
    color: #e2e8f0;
}

html.dark-mode .info-row-2-fullwidth {
    color: #adb5bd;
}

html.dark-mode .set-icon-svg {
    fill: #adb5bd;
}

html.dark-mode .set-icon-fallback {
    color: #adb5bd;
}

html.dark-mode .tab-buttons-container {
    background: #374151;
}

html.dark-mode .tab-button {
    color: #adb5bd;
}

html.dark-mode .tab-button:hover {
    background: #4a5568;
    color: #e2e8f0;
}

html.dark-mode .tab-button.active {
    background: #6ea8fe;
    color: #1a202c;
}

html.dark-mode .sort-label-fixed {
    color: #adb5bd;
}

html.dark-mode .tab-content-area {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

/* =================================================================
 CRITICAL LAZY LOADING STYLES - PREVENTS LAYOUT SHIFT
 ================================================================= */

/* Give images proper dimensions so they don't all stack in a 0x0 box */
.card-image {
  width: 100%;
  aspect-ratio: 286/400; /* Adjust to your actual card ratio */
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease-in-out;
  /* Was #f5f5f5 — theme-blind, so lazy-loading placeholders flashed
     light grey in dark mode. Tokenised to match consolidated-styles.css. */
  background-color: var(--ms-bg-image-ph, #f5f5f5);
}

/* Images with data-src are waiting to be loaded */
img[data-src] {
  opacity: 0.8;
  background-image: 
      linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
      linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
      linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
      linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Loaded images */
img.lazyloaded {
  opacity: 1;
  background-image: none;
}

/* Ensure card containers maintain size and prevent layout thrashing */
.card-item {
  contain: layout style;
  will-change: auto;
}

.card-image-section:not(:has(.card-flip-container)) {
  aspect-ratio: 286/400;
}

/* Dark mode loading animation */
html.dark-mode img[data-src] {
  background-color: #3a3a3a;
  background-image: 
      linear-gradient(45deg, #4a4a4a 25%, transparent 25%), 
      linear-gradient(-45deg, #4a4a4a 25%, transparent 25%), 
      linear-gradient(45deg, transparent 75%, #4a4a4a 75%), 
      linear-gradient(-45deg, transparent 75%, #4a4a4a 75%);
}

/* =================================================================
 CARD GALLERY VIEW STYLES
 ================================================================= */

.card-grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 20px 0;
}

/* iPad / tablet — 3 columns (768px–1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .card-grid-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}
.card-item {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: none !important;
}
.card-item:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}
.card-image-section {
  position: relative;
  overflow: hidden;
}
.card-info-section {
  padding: 10px 12px 12px;
  text-align: center;
}
.card-number {
  font-size: 0.8em;
  color: #666;
  margin-bottom: 2px;
}
.card-name {
  font-weight: 600;
  font-size: 0.95em;
  color: #333;
  margin-bottom: 6px;
}

/* =================================================================
 OWNERSHIP BUTTON STYLES - NO CHECKMARK
 ================================================================= */

.ownership-button-new {
  display: none;
}

/* ============================================
   MS-OWN-BTN: NEW UNIQUE OWNERSHIP BUTTON STYLES
   ============================================ */
.ms-own-btn {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 500;
  background-color: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  transition: all 0.15s ease;
  position: relative;
}

.ms-own-btn.ms-owned {
  background-color: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.ms-own-btn:hover {
  opacity: 0.85;
}

html.dark-mode .ms-own-btn {
  background-color: #374151;
  color: #d1d5db;
  border-color: #4b5563;
}

html.dark-mode .ms-own-btn.ms-owned {
  background-color: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

/* =================================================================
 PURCHASE PRICE DISPLAY STYLES
 ================================================================= */

.purchase-price-display {
  font-size: 0.85em;
  font-weight: 600;
  margin-left: 4px;
}

.purchase-price-good {
  color: #28a745; /* Green - good deal */
}

.purchase-price-bad {
  color: #dc3545; /* Red - overpaid */
}

.purchase-price-neutral {
  color: #6c757d; /* Grey - no market price to compare */
}

html.dark-mode .purchase-price-good {
  color: #40e070;
}

html.dark-mode .purchase-price-bad {
  color: #ff6b6b;
}

html.dark-mode .purchase-price-neutral {
  color: #9ca3af;
}

/* =================================================================
 DOUBLE-FACED CARD FLIP STYLES
 ================================================================= */

.card-flip-container {
  position: relative;
  width: 100%;
  aspect-ratio: 286/400;
  perspective: 1000px;
}

.card-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s ease-in-out;
  transform-style: preserve-3d;
}

.card-flip-container.flipped .card-flip-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
}

.card-face-front {
  z-index: 2;
}

.card-face-back {
  transform: rotateY(180deg);
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-flip-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: all 0.2s ease;
  font-size: 18px;
  padding: 0;
}

.card-flip-button:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: white;
  transform: scale(1.1);
}

.card-flip-button:active {
  transform: scale(0.95);
}

.card-flip-container.flipped .card-flip-button {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.8);
  color: black;
}

.card-flip-container.flipped .card-flip-button:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: black;
}

.flip-icon-svg {
  width: 20px;
  height: 20px;
  fill: white;
  transition: fill 0.3s ease;
  pointer-events: none;
}

.card-flip-container.flipped .flip-icon-svg {
  fill: #333;
}

/* =================================================================
 PRICE AND MARKETPLACE STYLES
 ================================================================= */

.price-display {
  font-weight: 600;
  color: #111827; /* footer slate — neutral, no clash with card art or badges */
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.price-display.no-price {
  color: #6c757d;
  font-style: italic;
  font-weight: normal;
}

.button-adjacent-price-info {
  margin-left: 0px !important;
  display: inline-block !important;
  text-align: left !important;
}

.price-link {
  color: #111827 !important; /* footer slate */
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.price-link:hover {
  color: #000000 !important;
  text-decoration: underline;
}

.tcgp-icon {
  vertical-align: middle;
  margin-left: 2px;
  margin-bottom: 3px;
}

.marketplace-link {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 2px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  color: #0d6efd;
  text-decoration: none;
  font-size: 0.8em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.marketplace-link:hover {
  background-color: #e9ecef;
  border-color: #0d6efd;
  text-decoration: none;
}

.tcg-gallery-link {
  color: #0d6efd;
  text-decoration: none;
  font-weight: 500;
}

.tcg-gallery-link:hover {
  text-decoration: underline;
  color: #0a58ca;
}

/* =================================================================
 DARK MODE STYLES
 ================================================================= */

html.dark-mode .card-item {
  background: #2a3a50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

html.dark-mode .card-item:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

html.dark-mode .card-number {
  color: #adb5bd;
}

html.dark-mode .card-name {
  color: #dee2e6;
}

html.dark-mode .price-link {
  color: #4ade80 !important;
}

html.dark-mode .price-link:hover {
  color: #86efac !important;
}

html.dark-mode .price-display {
  color: #4ade80;
}

html.dark-mode .price-display.no-price {
  color: #adb5bd;
}

html.dark-mode .marketplace-link {
  background-color: #343a40;
  border-color: #495057;
  color: #6ea8fe;
}

html.dark-mode .marketplace-link:hover {
  background-color: #495057;
  border-color: #6ea8fe;
}

html.dark-mode .tcg-gallery-link {
  color: #6ea8fe;
}

html.dark-mode .tcg-gallery-link:hover {
  color: #a1c9ff;
}

html.dark-mode .card-flip-button {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  color: white;
}

html.dark-mode .card-flip-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: white;
}

html.dark-mode .card-flip-container.flipped .card-flip-button {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(0, 0, 0, 0.8);
  color: black;
}

html.dark-mode .card-flip-container.flipped .card-flip-button:hover {
  background: rgba(0, 0, 0, 0.5);
  border-color: black;
}

html.dark-mode .flip-icon-svg {
  fill: white;
}

html.dark-mode .card-flip-container.flipped .flip-icon-svg {
  fill: #333;
}

/* =================================================================
 RESPONSIVE STYLES
 ================================================================= */

/* ============================================================
   MOBILE — image-first, 2-col, minimal info
   ============================================================ */
@media (max-width: 767px) {

  /* Grid */
  .card-grid-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 8px 0 80px;
  }

  /* Card — image fills the tile, info collapses */
  .card-item {
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  }

  /* Image fills the card, no aspect-ratio override needed */
  .card-image-section img.card-image {
    width: 100%;
    height: auto;
    display: block;
  }

  /* Hide all card info text except the price */
  .card-info-section {
    padding: 4px 6px 6px;
  }
  .card-number { display: none; }
  .card-name {
    font-size: 0.72rem;
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Variant row: hide badge label, keep price compact */
  .variant-badge {
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
  }
  .price-line-entry {
    justify-content: center !important;
    gap: 4px;
    flex-wrap: wrap;
  }
  .ownership-column { display: none !important; }
  .slab-column { display: none !important; }
  .price-column {
    flex: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    gap: 4px !important;
  }
  .mscg-mkt-inline {
    justify-content: center !important;
    width: 100%;
  }
  .mscg-sold-row { text-align: center !important; }
  .card-info-section { text-align: center; }

  /* Price text smaller */
  .mscg-price-val {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
  }

  /* Buy buttons smaller */
  .mscg-mkt-btn { padding: 2px 4px !important; }
  .mscg-mkt-tcgp-img,
  .mscg-mkt-ebay-img { height: 11px !important; }

  /* Owned indicator: small dot overlay on image */
  .card-condition-badge {
    width: 20px !important;
    height: 20px !important;
    font-size: 0.5rem !important;
  }

  /* Section dividers */
  .card-section-divider { margin: 8px 0 4px; }
  .card-section-divider-label { font-size: 0.75rem; }

  /* Sold count */
  .mscg-sold-row { font-size: 0.58rem; }

  /* Sticky set info bar: compact */
  .sticky-set-info {
    padding: 4px 10px !important;
  }
  .header-row-1 {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
  }
  .set-title-text {
    font-size: 0.82rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
  }
  .set-release-date { display: none; }
  .set-icon { display: none; }
  .col-tabs { display: none !important; }
  .col-sort { display: none !important; }
  .info-row-2-fullwidth {
    font-size: 0.72rem;
    gap: 4px;
    flex-wrap: wrap;
  }
  .set-stat-item { font-size: 0.72rem; }
  .header-set-badge { font-size: 0.6rem !important; padding: 1px 3px !important; }

}


/* Core badge for base set cards */
.core-badge {
   position: absolute;
   top: -8px;
   left: 50%;
   transform: translateX(-50%);
   background: #28a745;
   color: white;
   font-size: 8px;
   font-weight: bold;
   padding: 1px 4px;
   border-radius: 2px;
   border: 1px solid #1e7e34;
   z-index: 10;
}

/* ============================================
   HEADER SET BADGES - Card Count Display
   ============================================ */

/* Container for each stat item to align badge with text */
.set-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Base badge style for header (similar to card .core-badge but inline) */
.header-set-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

/* BASE badge - Green (matches existing .core-badge) */
.header-set-badge.badge-base {
    background: #28a745;
    color: white;
    border: 1px solid #1e7e34;
}

/* COMPLETE badge - Cyan/Teal (matches site theme) */
.header-set-badge.badge-complete {
    background: #17a2b8;
    color: white;
    border: 1px solid #138496;
}

/* MASTER badge - Purple (premium/collector feel) */
.header-set-badge.badge-master {
    background: #6f42c1;
    color: white;
    border: 1px solid #5a32a3;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .set-stat-item {
        display: inline-flex;
        margin-bottom: 3px;
    }
    
    .header-set-badge {
        font-size: 8px;
        padding: 1px 4px;
    }
}

/* Tooltips for badges */
.header-set-badge[title] {
    cursor: help;
}

.card-grade-container {
   display: inline-flex !important;
   align-items: center !important;
   gap: 3px !important;
   background: transparent !important;
   border: none !important;
}

.grade-icon-image {
   /* Let external CSS handle the size */
   display: inline-block !important;
}

.grade-icon-empty {
   opacity: 0.4 !important;
}

.grade-number-beside {
   font-weight: bold !important;
   color: #666 !important;
   line-height: 1 !important;
}

html.dark-mode .grade-number-beside {
   color: #adb5bd !important;
}
/* ---- Mobile grid toggle & filter sheet ---- */
@media (max-width: 767px) {
  /* 1-col mode: full card name visible */
  .card-grid-container[style*="gridTemplateColumns: 1fr"] .card-name,
  .card-grid-container[style*="grid-template-columns: 1fr"] .card-name {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  /* Bottom bar 3rd button sizing */
  #mobGridToggle { font-size: 0.75rem; }

  /* Filter sheet input dark mode */
  html.dark-mode #mobCardFilter {
    background: rgba(255,255,255,0.07);
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.15);
  }
}

/* ---- Mobile grid toggle (class set by JS on body) ---- */
@media (max-width: 767px) {
  body.mob-grid-1col .card-grid-container {
    grid-template-columns: 1fr !important;
  }
  body.mob-grid-1col .card-name {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
  }
}

/* ---- Buying strip (one line, above the card grid) ---- */
.ms-buy-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  min-width: 0;
  margin: 0 0 12px;
  padding: 7px 12px;
  border: 1px solid rgba(34,197,94,.38);
  border-radius: 8px;
  background: rgba(34,197,94,.10);
  font-size: .85rem;
  line-height: 1.3;
}
.ms-buy-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(34,197,94,.9);
  color: #06240f;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.ms-buy-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #166534;
}
.ms-buy-link {
  flex: 0 0 auto;
  font-weight: 600;
  text-decoration: none;
  color: #15803d;
  white-space: nowrap;
}
.ms-buy-link:hover { text-decoration: underline; }

html.dark-mode .ms-buy-strip {
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.08);
}
html.dark-mode .ms-buy-text { color: #d6f5e0; }
html.dark-mode .ms-buy-link { color: #4ade80; }

@media (max-width: 575px) {
  .ms-buy-strip { gap: 8px; padding: 6px 10px; font-size: .78rem; }
  .ms-buy-tag { display: none; }
}
