.deck-viewer-container {
    border: 3px solid #7d9b9b; /* Softened, cooler border color */
    border-radius: 12px; /* Slightly rounded corners for a smoother look */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(125, 155, 155, 0.3); /* Softer, lighter shadow effect */
    padding: 4px;
    padding-top: 5px; /* Slightly more padding on top */
    padding-bottom: 5px; /* Slightly more padding on the bottom */
    background-color: #000000; /* Darker background to create subtle contrast */
    margin-top: 2px; /* Slightly more space above */
    margin-bottom: 0;
    color: #ffffff; /* White text to ensure readability */
}

.deck-viewer-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column for the whole layout */
    gap: 1px;
}

.deck-viewer-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 cards per row */
    gap: 4px;
}

/* For tablet, set 5 cards per row */
@media (max-width: 1024px) {
    .deck-viewer-cards {
        grid-template-columns: repeat(5, 1fr); /* 5 cards per row on tablet */
    }
}

/* For mobile, we force 4 cards per row */
@media (max-width: 768px) {
    .deck-viewer-cards {
        grid-template-columns: repeat(4, 1fr); /* 4 cards per row on mobile */
        gap: 3px;
    }
}

.missing-card-code {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 5px;
}

.tcg_card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative; /* Important for positioning the quantity box */
    text-align: center;
    transition: transform 0.2s ease-in-out; /* Smooth transform transition */
    margin-bottom: 1px;
}

/* Hover effect for each card */
.tcg_card:hover {
    box-shadow: 0 0 10px #009fd4; /* Blue glow effect */
    transition: box-shadow 0.3s ease-in-out;
    transform: scale(1.05); /* Slightly enlarge the card on hover */
    cursor: pointer;
}



/* Centered (horizontally) at the top of the image */
.quantity-box {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 12px;
    font-size: 22px;
    line-height: 20px;
    font-weight: bold;
    color: #fff;
    background: rgba(20, 20, 20, 0.90);  
    border-radius: 9999px; 
	z-index: 3;
}

@media (max-width: 768px) {
    .quantity-box {

    padding: 4px 8px;
    font-size: 16px;
    line-height: 18px;

}}


/* Lightbox Styling */
.tcg_lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8); /* Dark transparent background */
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensures it's above all other elements */
    flex-direction: row; /* Default horizontal layout on desktop */
}

.tcg_lightbox-image {
    max-width: 85%;
    max-height: 85%;
    border: none; /* Remove the white border around the image */
    border-radius: 8px; /* Optional: Rounded corners */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7); /* Add a subtle shadow for the image */
	Margin-top: -25px;
}

/* Lightbox Link/Button Styling */
.tcg_lightbox-link {
     display: inline-block;
    background-color: hsl(212.02deg 100% 46.38%);  /* Default background color */
    color: #fff;                                   /* Light text for contrast */
    padding: 10px 20px;
    text-decoration: none;
    font-weight: bold;
    border-radius: 5px;
    margin-left: 20px;
    align-self: center;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.tcg_lightbox-link:hover {
    background-color: #36a8c9;  /* Hover background color */
    transform: scale(1.05);     /* Slight scale-up effect */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);  /* Subtle shadow for depth */
	 color: #fff;
}

/* Lightbox Close Button */
.tcg_lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    font-size: 28px; /* Slightly smaller font for a more refined look */
    font-weight: bold;
    border: none;
    border-radius: 50%;
    width: 45px; /* Slightly larger button */
    height: 45px; /* Consistent with width */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Softer shadow for a subtle effect */
    transition: background 0.3s ease, transform 0.2s ease; /* Smooth transition effects */
}

.tcg_lightbox-close:hover {
    background: rgba(255, 255, 255, 1); /* Solid background on hover */
    transform: scale(1.1); /* Slightly enlarge on hover */
}

.tcg_lightbox-close:active {
    transform: scale(1.05);
}

/* Responsive: On screens 767px or less, stack image and link vertically */
@media (max-width: 767px) {
    .tcg_lightbox {
        flex-direction: column;  /* Switch to vertical layout on mobile */
    }
    
    .tcg_lightbox-image {    
        margin-top: -50px;
    }
    
    .tcg_lightbox-link {
        margin-left: 0;
        margin-top: 10px; /* Add spacing above the button when stacked */
        padding: 8px 16px; /* Reduced padding for a smaller button */
        font-size: 0.9em;  /* Optionally reduce font size */
    }
}


.tcg_cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    justify-items: center;
    justify-content: center; /* Ensures single items are centered in the grid */
}

.tcg_cards-grid .tcg_card {
    max-width: 370px;
    text-align: center;
}

.tcg_cards-grid .tcg_card img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Media Query for Mobile Devices (up to 768px) */
@media (max-width: 768px) {
    .tcg_cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Flexible columns */
        gap: 6px; /* Smaller gap for mobile */
        justify-content: center; /* Keep single cards centered */
    }
}

/* Media Query for Narrower Screens (up to 480px) */
@media (max-width: 480px) {
    .tcg_cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); /* Flexible columns */
        gap: 3px; /* Smaller gap for very narrow screens */
        justify-content: center; /* Keep single cards centered */
    }
    .tcg_cards-grid .tcg_card {
        max-width: 250px; /* Further reduce card size for very narrow screens */
    }
}

.deck-viewer-button-wrapper {
    display: flex;
    justify-content: flex-start; /* Keeps the buttons aligned to the left */
    align-items: center; /* Vertically centers the content */
    grid-column: 1; /* Ensure the button spans the full grid width */
    padding: 5px; /* Adds padding around the button */
    background: linear-gradient(145deg, #5567a2, #7e83c4); /* More muted gradient background */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    border-radius: 8px; /* Rounded corners for a smoother look */
    margin-top: 10px; /* Space above the button wrapper */
	gap: 10px;
}


/* --- COPY DECK BUTTON --- */
.copy-deck-code {
    background-color: hsl(212.02deg 100% 46.38%);
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 7px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 0;
}

.copy-deck-code:hover {
    background-color: #36a8c9;
    transition: background-color 0.3s ease;
}

/* --- DOWNLOAD DECK BUTTON --- */
.download-deck-image {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 7px 12px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin: 0;
    transition: background-color 0.3s ease;
    box-sizing: border-box;
}

.download-deck-image:hover {
    background-color: #218838;
}

/* --- TOTAL CARDS BADGE --- */
.total-cards {
    background: linear-gradient(90deg, #f1c40f 0%, #f39c12 100%);
    color: #fff;
    padding: 6px 14px;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    font-size: 14px;
	margin-left: auto;
}

/* --- ICONS --- */
.copy-deck-code i,
.download-deck-image i {
    font-size: 16px;
    margin-right: 5px;
}

/* --- RESPONSIVE DESIGN --- */

/* Tablets (≤ 768px) */
@media (max-width: 768px) {
    .copy-deck-code,
    .download-deck-image,
    .total-cards {
        padding: 6px 10px;
        font-size: 12px;
    }

    .deck-viewer-button-wrapper {
        gap: 6px;
    }
}

/* Mobile Devices (≤ 480px) */
@media (max-width: 480px) {
    .deck-viewer-button-wrapper {
        flex-direction: row;   /* Keep buttons in a row */
        align-items: center;   /* Center align vertically */
        gap: 4px;              /* Reduce spacing between buttons */
        flex-wrap: nowrap;     /* Prevent wrapping */
    }

    .copy-deck-code,
    .download-deck-image,
    .total-cards {
        padding: 4px 8px;      /* Smaller padding */
        font-size: 12px;       /* Smaller text */
        width: auto;           /* Keep natural width */
    }

    .copy-deck-code i,
    .download-deck-image i {
        font-size: 14px;       /* Slightly smaller icons */
        margin-right: 3px;
    }
}

.deck-card-image {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
 
}


/* 1) Reserve space and base styling for each card cell */
.deck-viewer-cards .tcg_card {
  position: relative;
  background-color: #2a2a2a;
  overflow: hidden;

  /* Reserve an aspect ratio so each cell keeps its height.
     If your cards are ~190×266, use 266/190≈1.4 → padding-top:140% */
  padding-top: 140%;
}

/* 2) Absolutely position the image over its container */
.deck-viewer-cards .tcg_card img.deck-card-image {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  z-index: 2; /* sit above the shimmer */
}


/* 4) Shimmer keyframes */
@keyframes shimmer {
  0%   { background-position: -150% 0; }
  100% { background-position: 150% 0; }
}

/* 5) Shimmer placeholder behind each card */
.deck-viewer-cards .tcg_card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(
    90deg,
    rgba(51,51,51,0.8) 0%,
    rgba(68,68,68,0.6) 50%,
    rgba(51,51,51,0.8) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite ease-in-out;
  z-index: 1;
}
.deck-viewer-cards .tcg_card.loaded img.deck-card-image {
  opacity: 1 !important;
}
/* 6) Hide shimmer once the card’s <img> fires its load event */
.deck-viewer-cards .tcg_card.loaded::before {
  display: none;
}