:root {

    --card-size: 200px;
        /* Light Mode Defaults */
    --bg-color: #bbb;
    --bg2-color: #d5d5d5;
    --text-color: #000000;
    --text2-color: #272727;
    --accent-color: #954bb5;
    --accent2-color: #4c719c;
    --accent3-color: #bb45ed;
    --accent4-color: #0077ff;
    --card-background: transparent;
}

body.dark {
    /* Dark Mode Overrides */
    --bg-color: #1e1e1e;
    --bg2-color: #494949;
    --text-color: #ffffff;
    --text2-color: #cacaca;
    --accent-color: #4c719c;
    --accent2-color: #3c8176;
    --accent3-color: #0077ff;
    --accent4-color: #00ffd5;
}

html, body {
    height: 100%; width: 100%; margin: 0; padding: 0;
    /* Change overflow: hidden to allow the container to breathe */
    overflow: hidden; 
    background-color: var(--bg-color);
    /* Remove touch-action from here; we only want it on scrollable areas */
}

.hidden {
    display: none !important;
}
/* --- Custom Scrollbar Styles --- */

/* 1. Sets the width of the scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

/* 2. Styles the Track */
::-webkit-scrollbar-track {
    background: transparent;
}

/* 3. Styles the Handle */
::-webkit-scrollbar-thumb {
    background: var(--text2-color); 
    border-radius: 10px; 
    border: 2px solid var(--bg-color);
}

/* Optional: Styles the Handle when hovering over it */
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* --- Firefox Scrollbar Support --- */
#set-panel, #cards-panel,
.set-list, .cards-list {
    scrollbar-color: var(--bg2-color) transparent;
    scrollbar-width: thin;
}


#app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Dynamic height for mobile browsers */
    width: 100vw;
    position: relative;
    overflow: hidden;
}

#main-view { flex: 1; display: flex; width: 100%; min-height: 0; position: relative; }

#set-panel {
    display: flex;
    flex-direction: column;
    color: var(--text2-color);
}


.set-list, .cards-list {
    flex: 1;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}


.cards-list {
    display: grid; padding: 20px; gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr));
    align-content: start;
    background: var(--bg-color);
}

.card-item .card-name { 
    font-size: 1em; /* Smaller for mobile grid */
    font-weight: bold;
    margin: 5px 0;
    color: var(--text-color);
}
.card-footer {
    display: flex;
    justify-content: center; /* Centers the whole row */
    align-items: center;     /* Aligns them vertically */
    gap: 8px;                /* Space between ID and Rarity */
    width: 100%;
    margin-top: 4px;
}

.rarity-card-item {
    display: inline-flex;    /* Changed from flex to inline-flex */
    width: fit-content;      /* Ensures the border only wraps the text */
    white-space: nowrap;
    font-size: 0.8em;        /* Adjusted for the small card footer */
    border: none;
    border-radius: 8px;
    height: 20px;
    align-items: center;
    justify-content: center;
    background: var(--bg2-color);
    color: var(--text-color);
    padding: 0 4px;     
    min-width: 24px;     /* 4px left and right padding */
    font-size: 1em;
    opacity: 75%;
}

.card-id {
    font-size: 1em;
    opacity: 75%;
    margin-top: 2px;
    color: var(--text2-color);
    white-space: nowrap; 
}

#other-versions-container {
    width: 100%;
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 15px 5px;
    min-width: 0;
    box-sizing: border-box;

    /* 1. Hide scrollbar for Firefox */
    scrollbar-width: none; 

    /* 2. Hide scrollbar for IE and Edge */
    -ms-overflow-style: none; 
}

#other-versions-container::-webkit-scrollbar {
    display: none;
    /* OR use: width: 0; height: 0; */
}
.version-thumb-wrapper {
    flex: 0 0 75px; 
    width: 75px;
    height: 105px; /* Matches the image height exactly */
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: grayscale(40%);
}

.version-thumb-wrapper:hover {
    transform: translateY(-3px);
    filter: grayscale(0%);
}

.version-thumb-wrapper.current {
    filter: grayscale(0%);
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
    border-radius: 4px;
}

.version-thumb {
    width: 75px;
    height: 105px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.series-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 64px;
    background-color: var(--bg-color);
    z-index: 30;
    overflow: hidden;
    padding: 0;
    flex-shrink: 0;
}

.series-tabs {
    flex: 1; /* Allow tabs to take up the remaining space */
    display: flex;
    overflow-x: auto;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    height: 100%;
    align-items: center; 
    padding: 0;
    color: var(--text2-color);
}

.series-tab {
    color: var(--text2-color);
    border-radius: 8px;    
    font-size: 1.2em !important;
    font-weight: 400;
    padding: 5px 10px;
    cursor: pointer; 
    border: none; 
    background: none; 
    white-space: nowrap; 
}



/* Chrome/Safari/Opera */
.series-tabs::-webkit-scrollbar {
    display: none;
}


.series-tab:hover {
    border-left: 2px solid var(--bg2-color);
    border-right: 2px solid var(--bg2-color);
}

.series-tab.active {
    color:  var(--text-color);
    font-weight: bold; 
    background-color: var(--bg2-color);
}

/* info panel */
.card-item { 
    background: transparent; 
    border-radius: 4%;
    text-align: center; 
    position: relative; /* CRITICAL: Keeps badges inside the card */
    cursor: pointer;
    /* Prevents the default iOS context menu from popping up */
    -webkit-touch-callout: none !important; 
    /* Prevents text/image selection during the long press */
    -webkit-user-select: none;             
    user-select: none;
    /* Optimizes touch behavior */
    touch-action: manipulation;
}

.card-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: filter 0.4s ease-in-out, opacity 0.4s ease-in-out;
    filter: blur(1px); /* Blur the thumbnail initially */
    opacity: 0.8;
    border-radius: 5px;
}

/* When the scroll-stop logic successfully swaps the image */
.card-item img.is-loaded {
    filter: blur(0);
    opacity: 1;
}

.set-item { 
    padding: 15px; 
    cursor: pointer;
    border-radius: 12px;
    font-size: large;
}
.set-item.active { 
    background: var(--bg2-color); 
    border-left: 4px solid var(--accent-color); 
    color: var(--text-color);
}

#info-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    max-width: 500px;
    max-height: 100dvh;
    background-color: var(--bg-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    overflow-y: auto !important; /* Force scrollable */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.498);
}

#info-panel::-webkit-scrollbar {
    display: none;
}

#info-panel .card-name {
    font-size: 1.5em;
    font-weight: bold;
}

.card-info-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 10px;
    width: 100%;
}

.info-column {
    display: flex; 
    flex-direction: column;
    gap: 4px; /* Adjusts vertical space between lines */
}

.info-column:last-child {
    align-items: flex-end; /* Pins right-column content to the right edge */
    text-align: right;
}

/* Horizontal alignment for Rarity and Block */
.rarity-block {
    display: flex;
    gap: 8px; /* Space between rarity and block */
    white-space: nowrap;
    font-size: 1.2em;
}

.rarity {
    border: 1px solid var(--text-color);
    border-radius: 8px;
    min-width: 24px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #d5d5d5;
    color: black !important;
    opacity: 75%;
    padding-left: 4px;
    padding-right: 4px;
}

.block {
    border: 1px solid var(--text-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;   /* Adjust size as needed */
    height: 20px;
    aspect-ratio: 1 / 1;
    background: #d5d5d5;
    color: black !important;
    opacity: 75%;
}


.type {
    opacity: 0.7; /* Subtly distinguishes type from name */
}

#info-panel .card-id  {
    font-size: 1.2em;
    margin-top: 5px;
    opacity: 100% !important;
}

#info-panel .type  {
    font-size: 1.2em;
    margin-top: 5px;
    opacity: 75%;
}

#info-panel .errata-text {
    font-size: 1.2em;
    font-style: italic; 
    margin-top: 20px;
    opacity: .8;
}

#info-panel img.gallery-image {
    max-width: 100%;
    height: auto;          /* Allows height to scale proportionally with width */
    display: block;
    margin: 0 auto;
    border-radius: 4%;
    object-fit: contain;   /* Ensures the image is never distorted */
}

.card-gallery {
    position: relative;
    width: 100%;
    text-align: center;
    padding: 0;
    background: transparent;
}

#card-images-container img {
    max-width: 100%;
    object-fit: contain;
    border-radius: 4%;
}

#gallery-bottom {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    /* This pushes the first item (text) to the left and the last item (button) to the right */
    justify-content: space-between; 
    width: 100%;
    gap: 10px;
    margin-top: 2px;
}

.card_sets {
    flex: 1;
    font-size: 1.2em;
    /* Explicitly align the text inside this div to the left */
    text-align: center; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text2-color);
    padding-left: 30px;
    padding-right: 30px;

}

.inventory-open-btn {
    flex-shrink: 0;
    background: none;
    border-radius: 25px;
    color: var(--text2-color);
    font-size: 1.2em;
    padding: 0 8px;
}

.inventory-open-btn:hover {
    border: 1px solid var(--text-color);
}
.card-info {
    padding: 5px;
    flex: 1;
}

.manager-box {
    /* Remove the 'popup' look */
    background: var(--bg-color);
    border: 2px solid var(--accent-color);
    border-radius: 15px;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: none; /* No shadow needed for inline elements */
}

.manager-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}

.manager-actions input {
    flex: 1; /* Input takes up all space except for the 'Add' button */
    min-width: 0; /* Prevents the input from forcing its own width */
    height: 48px; /* Match button height for alignment */
    padding: 0 10px;
    border-radius: 12px;
    border: 1px solid var(--bg-color);
    background: transparent;
    color: var(--text-color);
}

/* Ensure the list container stays below the actions */
.manager-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    
    flex: 1; /* Fills all available space below the actions */
    overflow-y: visible; /* Prevents an internal scrollbar */
    min-height: 0; /* Important fix for flex-item overflow */
}

.manager-item {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-bottom: 8px;
    width: 100%; /* Ensure the row takes full width */
    box-sizing: border-box; /* Prevents padding from adding to width */
}

.manager-item input {
    flex-grow: 1;
    min-width: 0; /* The critical fix to prevent horizontal overflow */
    background: var(--bg-color);
    color: var(--text-color);
    padding: 5px;
    border: none;
    border-bottom: 1px solid var(--bg2-color);
    font-size: 1.2em;
}

/* Ensure buttons don't shrink or get squashed */
.manager-item button {
    flex-shrink: 0;
}
.loc-mgnt-header {
    display: flex;
    justify-content: space-between; /* Pushes H3 left and button right */
    align-items: center;           /* Centers them vertically */
    width: 100%;
    margin-bottom: 15px;           /* Adds space below the header */
}

.modal-header h3 {
    margin: 0;                     /* Removes default browser margins */
    font-size: 1.2em;
}

.location-row {
    display: flex;
    align-items: center;
    gap: 12px; /* Must match the gap in .loc-item */
    margin-bottom: 15px;
    width: 100%;
}

#inv-location-select, #new-loc-input {
    /* Must match the width of .loc-name to align columns */
    width: 180px; 
    height: 40px;
    padding: 5px;
    border-radius: 4px;
    border: none;
    border-bottom: 1px solid var(--bg2-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1.2em;
}

#location-manager-modal {
    /* Remove absolute/fixed positioning */
    position: static; 
    transform: none;
    
    /* Ensure it takes up the full width of the form */
    width: 100%;
    margin-top: 10px;
    margin-bottom: 15px;
}

#inventory-form {
    position: relative; 
    border: 2px solid var(--bg2-color);
    padding: 15px;
    border-radius: 25px;
}

.card-power-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 5px;
    font-size: 1em;
}

.card-power-row div span {
    font-weight: bold;
    font-size: 1.5em;
}

/* Ensure the text color is correct for your dark/light modes */
#info-panel .card-info div {
    color: var(--text-color);
}

.effect{
   font-size: 1.2em;
}

#info-panel {
    /* ... your existing styles ... */
    overscroll-behavior-x: contain; /* Prevents swipe-to-back browser gestures */
    touch-action: pan-y; /* Tells the browser to only handle vertical scrolling automatically */
}

/* Style the label in brackets */
.label-tag {
    display: inline-block; /* Required for padding/margin to work well */
    font-weight: bold;
    background-color: yellow;
    color: black;
    padding: 0 4px; /* Better than using a thick border for size */
    margin-right: 5px;
    border-radius: 4px;
    border-top-right-radius: 0 !important; /* Cuts off the top-right corner */
    text-transform: uppercase;
    font-size: 0.85em;
    clip-path: polygon(0% 0%, 100% 0%, 85% 100%, 0% 100%);
    
    /* Ensure padding covers the area where the slant "cuts" in */
    padding-right: 15px;
}

/* Ensure the value text stays aligned with the tag */
.trigger .field-value {
    display: inline;
    line-height: 1.4;
}

/* Ensure the trigger block looks right in the flow */
.trigger:not(.hidden) {
    display: block;
    margin-top: 10px;
    font-size: 1.1em;
}

.card-tag {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 4px;
    color: #ffffff !important; /* Force white text */
    font-weight: bold;
    font-size: 0.85em;
    line-height: 1;
}

.tag-once { background-color: #ad2e69; }
.tag-don { background-color: #000000; }
.tag-blue { background-color: #4c719c; }
.tag-brown { background-color: #db3f19; }
.tag-orange { 
    background-color: #e68433;
 }

.tag-brown {
    padding-left: 0 !important;
}
.tag-once, .tag-don, .tag-blue, .tag-brown, .tag-orange {
    border: 1px solid white;
    border-radius: 8px;
}
.category {
    text-align: center;
    width: 100%;
    padding: 0;
    margin-top: 15px;
}

.category .field-value {
    display: inline-block;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}
/* info panel */


/* --- Setting panel --- */
/* --- SETTINGS MODAL BASE --- */
#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 3000; /* Higher than info-panel (2000) */
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Mobile slide-up default */
    transition: opacity 0.3s ease;
    color: var(--text-color);
}

#settings-modal-content {
    position: relative;
    width: 100%; 
    max-width: 600px; 
    max-height: 0; /* Start collapsed */
    background-color: var(--bg-color);
    border-radius: 20px 20px 0 0;
    overflow: hidden; 
    transform: translateY(100%); 
    transition: transform 0.3s ease-out, max-height 0.3s ease-out;
    display: flex;
    flex-direction: column;
    color: var(--text2-color);
}

/* State when modal is active/sliding up */
#settings-modal-content.content-active {
    transform: translateY(0);
    max-height: 90vh;
}

/* --- HEADER & NAV --- */
#settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--bg2-color);
}

.settings-nav-group {
    display: flex;
    gap: 15px;
}


/* --- BODY & FORMS --- */
#settings-body-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: none; 
}

.settings-panel.hidden {
    display: none !important;
}

.settings-panel h2 {
    color: var(--accent-color);
}


.setting-group {
    margin-bottom: 20px;
}

.setting-group h2 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: var(--accent-color);
}

#settings-modal input[type="text"] {
    width: 100%;
    padding: 12px;
    background: var(--bg2-color);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-color);
    margin-bottom: 10px;
    box-sizing: border-box;
}

#settings-modal input:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* --- FOOTER --- */
#settings-footer {
    padding: 15px;
    border-top: 1px solid var(--bg2-color);
    display: flex;
    justify-content: flex-end;
}

#quick-access-toggles {
    display: flex;
    gap: 15px;
}

/* Container for the view mode selector */
.settings-view-mode-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 15px;
    border-left: 1px solid var(--bg2-color); /* Separates it from nav buttons */
}

/* Match select styling to your text inputs */
#view-mode-select {
    padding: 6px 12px;
    background: var(--bg2-color);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--accent-color); /* Highlight text color */
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9em;
    outline: none;
    transition: all 0.2s ease;
}

#view-mode-select:hover {
    background: var(--bg-color);
    border-color: var(--accent-color);
}

#view-mode-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(var(--accent-rgb), 0.3);
}

/* --- Group Management in Setting panel --- */
.collection-item {
    border: 2px solid var(--bg2-color);
    margin-bottom: 5px;
    border-radius: 12px;
}

.group-mgmt-list {
    display: flex; 
    justify-content: space-between; 
    width: 100%; 
    align-items: center;
    padding-bottom: 5px;
}

.group-name {
    font-weight: bold; 
    color: var(--accent-color); 
    font-size: 1.5em;
}

.group-type {
    font-size: 0.8em; 
    opacity: 0.8;
}

.rename-group{
    cursor:pointer; 
    margin-left:10px; 
    font-size: .8em;
    border: 2px solid var(--bg2-color);
    border-radius: 50%;
    padding: 10px;
}
.del-group-btn:hover {
    background: #ff4444; 
    border: none; 
    color: white; 
    padding: 5px 10px; 
    border-radius: 8px;
    font-size: 1em;
}

.group-sets-manager {
    width: 100%; 
    display: flex; 
    flex-wrap: wrap; 
    gap: 5px;
}

.set-in-group {
    background: var(--bg2-color); 
    padding: 4px 8px; 
    border-radius: 25px; 
    font-size: 1em; 
    display: flex; 
    align-items: center; 
    gap: 8px;
    white-space: nowrap;
}

.del-set-from-group-btn {
    display: flex;
    color: #ff4444; 
    cursor: pointer; 
    font-weight: bold;
    border: 1px solid #ff4444;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    z-index: 2001;
    background: transparent;
}

/* --- Group Management in Setting panel --- */

/* Tablet/Desktop adjustment */
@media (min-width: 600px) {
    #settings-modal {
        align-items: center; /* Center on large screens instead of slide-up */
    }
    #settings-modal-content {
        border-radius: 20px;
        height: 80vh;
    }
}
/* --- Setting panel --- */





.button {
    width: 56px;
    height: 56px;
    background: var(--bg2-color);
    border: none;
    border-radius: 8px;
    /* Normalize appearance across browsers */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 1.2em;
    color: var(--text-color);
}

.button:hover, .text-button:hover {
    font-weight: bold;
}

.text-button {
    height: 48px;
    min-width: 48px;
    background: var(--bg2-color);
    border: none;
    border-radius: 8px;
    /* Normalize appearance across browsers */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    color: var(--text-color);
    padding: 0 12px;
    font-size: 1em;
}

.card-nav-button {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: var(--text2-color);
    border: none;
    font-size: 2rem;
    padding: 20px 10px;
    cursor: pointer;
    z-index: 2010;
    transition: background 0.2s;
}

.card-nav-button:hover {
    background: rgba(130, 130, 130, 0.343);
    scale: 1.2;
}

#prev-card { left: 0; border-radius: 0 5px 5px 0; }
#next-card { right: 0; border-radius: 5px 0 0 5px; }

.inventory-header, .inventory-footer {
    display: flex;
    align-items: center;      /* Centers items vertically */
    justify-content: space-between; /* Pushes button to far right */
    width: 100%;
}

.shopping-list-control {
    display: flex;
    align-items: center;
    gap: 12px; /* Space between the green circle and the label */
}

.form-actions {
    display: flex;
    align-items: center;
}

#total-inv-quantity, #inv-shopping-qty, .loc-inv-qty {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    
    line-height: normal; /* Prevents text from shifting off-center */
    
    font-size: x-large;
    font-weight: bold;
    color: var(--text-color); 
    cursor: pointer;
}

#inv-shopping-qty, .loc-inv-qty {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    
    /* Text Centering (The Fix) */
    text-align: center;
    padding: 0;
    line-height: 35px; /* Matches height for vertical centering */
    
    /* Remove default input styling */
    border: none; /* Added a subtle border so you can see the circle */
    outline: none;
    -moz-appearance: textfield; /* Removes arrows in Firefox */
    appearance: textfield;

    /* Typography */
    font-size: 16px; /* x-large is usually too big for a 32-35px circle */
    font-weight: bold;
    color: var(--text-color); 
    cursor: pointer;
    left: 0;
}

#inv-shopping-qty::-webkit-inner-spin-button,
.loc-inv-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* Container for the label text */
.shopping-list-control label {
    font-size: 1.2em; /* Change text size here */
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-color);
}

/* Hide the default browser checkbox */
#inv-shopping-list {
    appearance: none;
    -webkit-appearance: none;
    
    /* Control the size of the box */
    width: 20px;
    height: 20px;
    
    border: 2px solid #39944e; /* Match your shopping green */
    border-radius: 4px;
    background-color: transparent;
    display: inline-block;
    position: relative;
    margin-right: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Style for the 'Checked' state */
#inv-shopping-list:checked {
    background-color: #39944e;
}

/* The 'Checkmark' icon (using a CSS pseudo-element) */
#inv-shopping-list:checked::after {
    content: '✔';
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loc-item {
    display: flex;
    align-items: center;
    gap: 12px; /* Controls the space between the name and the circle */
    margin-bottom: 10px;
    width: 100%;
}

.loc-name {
    /* Set a fixed width so the circles start at the same spot */
    width: 95%; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    font-size: 1.3em;
}

.loc-controls {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between the circle and the X button */
    width: 100%; 
}

/* Ensure these are treated as fixed-size blocks */
.loc-inv-qty {
    flex-shrink: 0;
}
.loc-inv-qty::placeholder, #inv-shopping-qty::placeholder {
    color: var(--text-color);
    opacity: 0.5; /* Makes it look like a hint rather than filled data */
}
 
.rename-loc-btn, .delete-loc-btn, .add-loc-btn {
    height: 48px;
    display: flex;            /* Added to make centering work */
    align-items: center;      /* Centers 'X' vertically */
    justify-content: center;   /* Centers 'X' horizontally */
    font-family: serif;
    
    font-weight: bold;
    font-size: 1.2em;
    cursor: pointer;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--bg2-color);
    border-radius: 12px;
    transition: background 0.2s;
}
.rename-loc-btn:hover, .delete-loc-btn:hover, .add-loc-btn:hover {
    background: var(--bg2-color);
}

.close-inventory, #save-inventory-btn, 
#manage-locations-btn, .remove-loc-btn, 
.close-loc-mgnt-btn, .btn-primary {
    aspect-ratio: 1 / 1;      /* Forces 1:1 ratio */
    flex-shrink: 0;           /* Prevents the button from being squashed in flexbox layouts */
    box-sizing: border-box;
    width: 48px;
    height: 48px;
    display: flex;            /* Added to make centering work */
    align-items: center;      /* Centers 'X' vertically */
    justify-content: center;   /* Centers 'X' horizontally */
    font-family: serif;
    
    font-weight: bold;
    font-size: 1.2em;
    cursor: pointer;
    background: transparent;
    color: var(--text-color);
    
    border-radius: 50%;
    transition: background 0.2s;
}

.close-inventory, #save-inventory-btn {
    border: 1px solid var(--bg2-color);
    font-style: italic;
}

#manage-locations-btn, .remove-loc-btn, 
.close-loc-mgnt-btn, .btn-primary {
    border: 1px solid var(--bg2-color);
}


#manage-locations-btn:hover, .remove-loc-btn:hover, 
.close-loc-mgnt-btn:hover, .btn-primary:hover {
    background: var(--bg-color);
}


.close-inventory:hover, #save-inventory-btn:hover {
    background: var(--bg2-color);
}

/* Style for each existing location row */
.manager-row {
    display: flex;
    align-items: center;
    gap: 10px; 
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-family: serif;
    font-style: italic;
    font-weight: bold;
    font-size: 1.2em;
    cursor: pointer;
    z-index: 2001;
    background: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 20px;
    border: 1px solid var(--bg2-color);
}

.close-button:hover {
    background: var(--bg2-color);
    scale: 1.3;
}

.settings-nav-btn {
    background: none;
    border: none;
    color: var(--text2-color);
    font-size: 1.1em;
    cursor: pointer;
    padding: 5px 0;
    opacity: 0.6;
}

.settings-nav-btn.active {
    opacity: 1;
    font-weight: bold;
    border-bottom: 2px solid var(--accent-color);
}

.btn-scrape {
    background-color: var(--accent-color) !important;
    color: white !important;
    font-weight: bold !important;
    margin-bottom: 5px;
    flex: 0 0 100% !important; /* Make it full width of the card */
}

.mgmt-actions hr {
    opacity: 0.3;
}

@media (min-width: 768px) {
    #set-panel {
        width: 20%; height: calc(100% - 64px);
        background-color: var(--bg-color);
        display: flex; flex-direction: column;
    }
    #cards-panel { width: 80%; height: 100%; background-color: var(--bg-color); display: flex; flex-direction: column; }
    .series-row {
        position: absolute; bottom: 0; left: 0;
        width: 20%; height: 64px;
        background-color: var(--bg-color);
        z-index: 100;
    }
    .card-item .card-name {
        font-size: 1.5em; /* Larger for desktop grid */
    }
}

@media (max-width: 767px) {
    #set-panel, #cards-panel {
        width: 100%; 
        position: absolute; 
        top: 0; 
        /* Ensure height is strictly defined so child scrolling works */
        height: calc(100dvh - 64px); 
        display: flex; 
        flex-direction: column;
        overflow: hidden; /* Parent stays still */
    }

    /* 1. Boost the search panel z-index to be higher than the bottom bar */
    .search-slide-container {
        z-index: 1000 !important; 
        /* Ensure it sits slightly above the bottom bar (999) */
        bottom: 64px; /* Matches height of series-row */
    }

    #set-panel { 
        left: 0; 
        z-index: 1; 
        background-color: var(--bg-color); 
        overflow: visible !important; 
    }
    
    #set-panel:has(.search-slide-container:not(.hidden-slide)) {
        z-index: 1001 !important;
    }

    /* Alternatively, if your browser doesn't support :has yet, use a helper class */
    #set-panel.searching {
        z-index: 1001 !important;
        overflow: visible !important;
    }

    #cards-panel { 
        left: 100%; z-index: 2; transition: left 0.3s ease; 
        background-color: var(--bg2-color);
        box-shadow: -5px 0 15px rgba(0,0,0,0.2);
    }
    .cards-list, .set-list { padding-bottom: 80px; }

    #app-container.show-cards #cards-panel { left: 0; }
    .series-row {
        position: fixed; bottom: 0; left: 0;
        width: 100vw; height: 64px;
        z-index: 999
    }

    /* Ensure the list areas are explicitly scrollable */
    .set-list, .cards-list {
        flex: 1;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch; /* Essential for smooth iOS scroll */
        touch-action: auto; /* Re-enable default touch behavior for scrolling */
    }
}


#app-dialog-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 4000; /* Higher than settings modal */
    display: flex;
    justify-content: center;
    align-items: center;
}

.dialog-box {
    background: var(--bg2-color);
    border: 2px solid var(--accent-color);
    padding: 15px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    text-align: center;
}

#dialog-input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    background: #000;
    border: 1px solid #444;
    color: #fff;
    font-size: 16px; /* Critical for mobile */
    border-radius: 8px;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dialog-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
}

.btn-secondary { background: #444; color: white; }


/* --- Inventory Badges --- */
.badge-container {
    position: absolute;
    bottom: 8px; /* Increased from 5px for better art visibility */
    left: 8px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 4px;
    z-index: 100;
    pointer-events: none;
}

.owned-badge-group {
    position: relative; /* Anchor point for the pop-up */
    display: flex;
    flex-direction: column;
    align-items: flex-start; 
    pointer-events: auto;
    z-index: 10001; /* Higher than the shop badge */
}
.card-badge {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    font-size: large;
    color: var(--text-color); 
}

.owned-badge, #total-inv-quantity, .loc-inv-qty { 
    background-color: #cbad50; 
}

.shop-badge, #inv-shopping-qty { 
    background-color: #39944e; 
}


.badge-location-list {
    position: fixed; /* Breaks out of all parent containers */
    z-index: 9999;
    width: max-content;
    min-width: 120px;
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    font-size: large;
}

.badge-loc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    color: var(--text-color);
    font-size: 0.9em;
    /* Reduce this value from 12px to 4px or 6px */
    padding: 5px 0; 
}


.badge-loc-row span { 
    text-align: left;
    white-space: nowrap;
}

.badge-loc-row strong {
    text-align: right;
    font-weight: bold; /* Matches your shop badge color to pop */
    background: #cbad50;
    border-radius: 25%;
    width: auto;
    padding: 5px;
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    /* 1. Ensure it doesn't stretch to fill a flex container */
    height: fit-content; 
    align-self: flex-start; 
    
    /* 2. Remove any accidental white-space */
    line-height: 0; 
    font-size: 0;
}

/* Ensure badges stay within the rounded corners of your image */
.card-image-wrapper img {
    width: 100%;            /* Changed from max-width to width to fill wrapper */
    height: auto;           /* Maintains ratio */
    display: block;         /* Removes the bottom inline gap */
    
    /* 3. Align to bottom to kill the 'ghost' pixel gap */
    vertical-align: bottom; 
    
    border-radius: 4%;
    /* 4. 'Contain' can leave gaps if height is fixed; use 'initial' to follow auto height */
    object-fit: initial;    
}

#global-location-tooltip {
    position: fixed;
    z-index: 10002;
    max-width: 90vw; /* Prevents overflow on mobile */
    max-height: 40vh; /* Adds scroll if list is very long */
    overflow-y: auto;
    pointer-events: auto;
}



/* --- SECTION: CONTEXT MENU & GROUPING --- */

/* 1. Context Menu Core */
.context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg2-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    min-width: 180px;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
}

.context-menu li {
    padding: 10px 15px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2em;
    position: relative;
}

.context-menu li:hover {
    background: var(--accent-color);
    color: white;
}

/* 2. Submenu & Mobile Toggle Logic */
.submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--bg2-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    min-width: 150px;
}

/* Desktop Hover */
.has-submenu:hover .submenu {
    display: block;
}

/* Mobile Click Toggle */
.context-menu li.submenu-open > .submenu {
    display: block !important;
    left: 0;
    top: 100%;
    position: relative;
    box-shadow: none;
    border-top: 1px solid var(--bg2-color);
}

/* 3. Isolated Group Modal (The .grp- namespace) */
.grp-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
}

.grp-modal-box {
    background: var(--bg-color);
    border: 2px solid var(--accent-color);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    color: var(--text-color);
    
}

.grp-modal-box input, .grp-modal-box select {
    width: 90%;
    padding: 10px;
    margin-top: 10px;
    background: var(--bg2-color);
    border: 1px solid var(--text-color);
    color: var(--text-color);
    border-radius: 4px;
    align-items: center;

}

#new-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;

    margin: 20px 0;
}

.grp-mode-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grp-actions {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

/* 4. Sidebar Item Styling */
.group-item {
    padding-left: 12px !important;
}

.nested-set-list {
    margin-top: 5px;
    margin-left: 10px;
}

.set-item.sub-set {
    padding-bottom: 15px;
    background: transparent;
}

.set-item.sub-set:hover {
    background: var(--bg-color);
}
/* 1. Context Menu Core */


/* Search */
/* Base mobile style (default) */
#set-panel {
    position: relative; /* Anchor for the panel */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Clips the panel when hidden */
}

.search-slide-container {
    position: absolute;
    bottom: 0; /* Sits at the bottom of the sidebar */
    left: 0;
    width: 100%; /* Automatically matches sidebar width */
    background: var(--bg2-color);
    z-index: 1000 !important; 
    transition: transform 0.3s ease-in-out;
    padding: 15px;
    box-sizing: border-box;
}

.search-slide-container.hidden-slide {
    transform: translateY(100%); /* Slides down inside the sidebar div */
}

.search-set-badge {
    position: absolute;
    bottom: 0;
    
    display: flex;       /* Required for justify-content */
    align-items: center; 
    justify-content: center;
    text-align: center;  /* Centers multi-line text */
    
    background: var(--bg2-color);
    color: var(--text2-color);
    font-size: 0.9em;
    font-weight: bold;
    padding: 2px;   /* Adjusted padding to be more balanced */
    
    line-height: 1.2;    /* CRITICAL: Prevents characters from overlapping */
    word-wrap: break-word; /* Ensures long names don't overflow the box */
    
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    width: 100%;
}

.stat-input-group {
    font-size: 1.5em !important;
}

#filter-color, #filter-category, #filter-cost_life, #filter-counter, #filter-power, #filter-attribute, #filter-block_icon, #filter-rarity {
    font-size: 1em;
    border-radius: 8px;
}

.stat-input-group {
    position: relative;
    display: inline-block; /* Flex or inline-block works better than grid here */
    width: 31%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden; /* Prevents children from leaking out */
    vertical-align: top;
    padding-bottom: 10px;
}

.search-filters-body {
    margin-bottom: 15px;
}
#search-header, .search-header {
    display: flex;
    align-items: center;
    gap: 8px; /* Spacing between select and input */
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 15px;
}

#search-target-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    outline: none;
    color: var(--accent-color); /* Matches your label theme */
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0; /* Prevents the dropdown from squishing */
    padding: 0 5px;
}

#main-search-input {
    flex-grow: 1; /* Makes the search bar take up all remaining space */
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color);
    font-size: 1.5em;
    min-width: 0; /* Important for flex items to prevent overflow */
}

/* Remove individual margins/paddings that cause wrapping */
#main-search-input, #search-target-select {
    margin-bottom: 0; 
    box-sizing: border-box;
}

.card-main-img {
    display: block;
    /* Ensure this matches your --card-size from :root */

    background: var(--bg2-color);
    display: block;
    vertical-align: bottom;
}

.stat-input-group select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    outline: none;
    
    color: var(--text-color);
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    padding: 5px 0;
    
    /* CRITICAL FIXES */
    width: 100%;           /* Force it to stay within the 32% div */
    max-width: 100%;       /* Hard limit */
    white-space: nowrap;   /* Keeps it on one line */
    overflow: hidden;      /* Required for ellipsis */
    display: block;
}

.stat-input-group select:hover {
    color: var(--accent-color);
}

/* Optional: Add a small indicator so users know it's a menu */
.stat-input-group select::after {
    content: ' ▾';
    font-size: 12px;
}


.filter-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    border: 2px solid var(--bg-color);
    border-radius: 8px;
    padding: 4px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--text-color);
}

.checkbox-container input[type="checkbox"] {
    /* 1. Increase size (1.5 is 50% larger, 2.0 is double) */
    transform: scale(1.6);
    
    /* 2. Add some margin to the right so it doesn't hit the text */
    margin-right: 12px;
    
    /* 3. Ensure the cursor changes on the box itself */
    cursor: pointer;
}

/* Optional: Change the color of the checkmark area to match your theme */
.checkbox-container input[type="checkbox"]:checked {
    accent-color: var(--accent-color);
}

/* Search */

.illustrated_by {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2em;
    color: var(--text2-color);
    padding-top: 30px;
}
/* Market Links */
.tcgplayer-link-container {
    border-radius: 25px;
    background: transparent;
    padding-left: 8px;
    padding-right: 2px;

    padding-bottom: 1px;
    max-width: fit-content;
    font-size: 1.2em;
}

.tcgplayer-link-container:hover {
    background: #3759d4;
}


.tcg-market-link {
    color: #3759d4;
    text-decoration: none; /* Removes the underline */
    display: block; /* Makes the whole area clickable */
    font-weight: bold;
}

/* Optional: Change color on hover */
.tcg-market-link:hover {
    color: white !important; /* Changes text to blue on hover */
}


.market-price {
    color: var(--text-color); /* Green for pricing */
    background: var(--bg2-color);
    border-radius: 8px;
    padding: 0 4px;
    font-family: monospace;
}

/* Hide the pin button on screens narrower than 800px (standard mobile) */
@media (max-width: 800px) {
    .pin-btn {
        display: none !important;
    }
}

/* Also hide it if the phone is in portrait mode, regardless of width */
@media (orientation: portrait) {
    .pin-btn {
        display: none !important;
    }
}

@media (min-width: 600px) {
    #settings-modal {
        align-items: center; /* Center modal on desktop */
    }
    
    #settings-modal-content {
        width: 90%;
        max-height: 80vh;
        border-radius: 16px; /* Rounded look for desktop */
        transform: translateY(20px); /* Smaller slide-up for desktop */
    }

    #settings-modal:not(.hidden) #settings-modal-content {
        transform: translateY(0);
    }
}

/* Hide nav buttons on very small screens if they block the card */
@media (max-width: 480px) {
    .card-nav-button {
        padding: 15px 5px;
        font-size: 1.5rem;
    }
}

@media (orientation: landscape) and (min-height: 400px) {
    #info-panel {
        display: flex;
        flex-direction: row; /* Side-by-side layout */
        width: 95vw;
        max-width: 1200px; /* Wider for landscape */
        height: 740px;
        max-height: 95dvh;
        align-items: stretch;
        padding: 25px;
        padding-top: 3px;
        padding-bottom: 3px;
        gap: 20px;
        overflow-y: hidden !important; /* Panel itself shouldn't scroll */
        border-radius: 30px !important;
    }

    /* Left Side: Vertical Scroll Gallery */
    .card-gallery {
        flex: 0.9; /* Reduced from 1 to 0.8 */
        height: 100%;
        overflow-y: auto;
        scrollbar-width: none;
        padding-right: 5px;
    }
        #card-images-container {
        display: flex;
        flex-direction: column; /* Stack images vertically */
        gap: 25px;
        align-items: center;
    }

    /* 2. Shrink the actual images */
    #card-images-container img {
        width: 100%;
        height: auto;
        flex: 0 0 auto;
        border-radius: 15px; /* Optional: slightly tighter corners for smaller images */
    }

    /* 3. Let the info side expand to fill the gap */
    .card-info {
        flex: 1.2;
        display: flex;
        flex-direction: column;
        height: 100%;
        /* Change auto to hidden to kill the scrollbars if content fits */
        /* Use overflow-y: auto only if the text is longer than the 535px height */
        overflow-y: auto; 
        overflow-x: hidden; /* Specifically kills the bottom scrollbar */
        padding-right: 15px;
        box-sizing: border-box; /* Ensures padding doesn't add to width */
    }
    .card-info::-webkit-scrollbar {
        display: none;
    }
    

    
    #other-versions-container {
        margin-top: auto; 
        padding-top: 20px;
        width: 100%;
        flex-shrink: 0; 
    }
    #other-versions-container::-webkit-scrollbar {
        display: none;
    }

    
}

/* new buttons */
button {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mask-icon {
    display: inline-block;
    width: 56px;
    height: 56px;
    
    /* 1. Use the gradient here instead of a solid color */
    background: linear-gradient(to bottom, var(--accent2-color), var(--accent-color));
    
    /* 2. Mask properties */
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
}

button:hover .mask-icon {
    background: linear-gradient(to bottom, var(--accent4-color), var(--accent3-color));
    transform: scale(1.1);
}

.icon-search {
    -webkit-mask-image: url('/static/icons/search.svg');
    mask-image: url('/static/icons/search.svg');
}

.icon-setting {
    -webkit-mask-image: url('/static/icons/setting.svg');
    mask-image: url('/static/icons/setting.svg');
}

.icon-theme-light {
    -webkit-mask-image: url('/static/icons/theme-light.svg');
    mask-image: url('/static/icons/theme-light.svg');
}
.icon-theme-dark {
    -webkit-mask-image: url('/static/icons/theme-dark.svg');
    mask-image: url('/static/icons/theme-dark.svg');
}

.qty-adjuster {
    display: flex;
    align-items: center;
    gap: 4px;
}

.adjust-btn {
    width: 24px;
    height: 24px;
    background: var(--bg2-color);
    color: var(--text-color);
    border: 1px solid #555;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    width: 32px;
}

.minus {
    border-top-left-radius: 50%;
    border-bottom-left-radius: 50%;
}

.plus {
    border-top-right-radius: 50%;
    border-bottom-right-radius: 50%;
}

.adjust-btn:hover {
    background: var(--accent-color);
    color: white;
}
.shopping-list-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.shopping-list-control .qty-adjuster {
    /* Ensures the buttons and input stay tight together */
    display: inline-flex;
}


/* The Pin Button Style */
.pin-btn {
    position: absolute; /* This pulls it out of the layout flow */
    top: 10px;         /* Adjust to match the close button height */
    left: 10px;        /* Moves it to the left edge */
    z-index: 3000;     /* Ensures it stays above the image */
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    border: 1px solid var(--bg2-color);
}

.pin-btn:hover {
    background: var(--bg2-color);
    scale: 1.3;
}


/* THE PINNED STATE */
/* THE PINNED SIDEBAR (Mobile Layout) */
body.is-pinned #info-panel:not(.hidden) {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important; /* Stack vertically */
    overflow-y: auto !important;      /* Scroll the whole panel */
    padding: 0 !important;            /* Mobile usually has edge-to-edge content */
    border-radius: 0 !important;
    box-shadow: none;
    background-color: var(--bg-color);
}

/* Force standard vertical flow for gallery and info sections */
body.is-pinned .card-gallery,
body.is-pinned .card-info {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    flex: none !important;
    padding: 15px !important;
    box-sizing: border-box;
}

/* Fix the Image Container to grow naturally */
body.is-pinned #card-images-container {
    width: 100% !important;
    height: auto !important;
    margin-bottom: 10px;
}

body.is-pinned #card-images-container img {
    width: 100% !important;
    height: auto !important;
    max-height: none !important; /* Remove any height limits */
    display: block;
    border-radius: 20px;
}

/* Center the Inventory Button below the image */
body.is-pinned #gallery-bottom {
    display: flex;
    justify-content: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--bg2-color);
}

/* Pin and Close Button Positioning */
body.is-pinned .pin-btn,
body.is-pinned .close-button {
    position: absolute !important;
    top: 15px;
    z-index: 3000;
}

body.is-pinned #inventory-form {
    width: 100% !important;
    margin-top: 10px;
    padding: 0 !important;
}

body.is-pinned .inventory-form-content {
    background: transparent;
    box-shadow: none;
    border: none;
}

.clickable-set {
    color: var(--accent-color);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
    display: inline-block;
}

.clickable-set:hover {
    color: var(--accent3-color);
    filter: brightness(1.2);
}

/* Optional: Add a small icon or badge style to make it pop */
.card_sets .field-value {
    font-weight: bold;
}

#other-versions-container {
    min-height: 100px; /* Adjust to roughly the height of your thumbnails */
    display: flex;
    overflow-x: auto;
}