/*
 * Card database view (#database-view) — layout, tabs, stats, grids, and shared DB chrome.
 * Depends on index.css for shell/base. Table column overrides: card-tables.css.
 * Mobile overrides: mobile-layout.css under html.layout-mobile. Roadmap: MOBILE_DESIGN.md (M2a–M2c).
 *
 * Section index (search for banner text): CARD IMAGE NAVIGATION ARROWS; DATABASE VIEW TABS;
 * CHARACTERS TABLE; SPECIAL CARDS; LOCATIONS; ASPECTS / MISSIONS / EVENTS (as labeled in file);
 * foil/utility blocks near file end. Major tab-specific mobile rules live in mobile-layout.css.
 */

/* ========================================
 * CARD IMAGE NAVIGATION ARROWS
 * ======================================== */

.card-image-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    flex-wrap: nowrap;
    position: relative;
}

.card-nav-arrow {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 0;
    width: auto;
    height: auto;
    font-size: 20px;
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
    user-select: none;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.card-nav-arrow:hover {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.card-nav-arrow:active {
    transform: translateY(0);
    color: rgba(255, 255, 255, 0.7);
}

.card-nav-prev {
    order: 1 !important;
}

.card-nav-next {
    order: 3 !important;
}

.card-image-container img {
    order: 2 !important;
    flex-shrink: 0;
}

/* ========================================
 * DATABASE VIEW LAYOUT & STRUCTURE
 * ======================================== */

.database-view-adjust {
    margin-top: 6px;
}

/* Container: section chrome around stats, tabs, and table area */
.database-section {
    background: transparent;
    border-radius: 15px;
    padding: 0 20px 20px 20px; /* remove top padding to raise content */
    backdrop-filter: none;
    border: none;
}

/* Row: title + actions within a database section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: #4ecdc4;
}

/* ========================================
 * STATS — grid container + cells
 * ======================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 8px; /* tighter space below stats */
}

/* Row cell: one stat block inside .stats */
.stat-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ========================================
 * TAB NAVIGATION — .tab-container stacks .tab-row bands
 * ======================================== */

.tab-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    padding: 6px 0; /* compact spacing */
    margin-top: 0;      /* pull buttons closer to global nav */
    margin-bottom: 16px; /* keep comfortable space to table */
    width: 100%;
}

/* Row: one wrap line of .tab-button elements */
.tab-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    min-width: 130px;
    text-align: center;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.tab-button.active {
    background: #4ecdc4;
    border-color: #4ecdc4;
    color: #1a1a2e;
}

/* ========================================
 * SEARCH CONTAINER
 * ======================================== */

.search-container {
    margin-bottom: 20px;
    text-align: center;
}

.search-input {
    padding: 10px 15px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    width: 300px;
    outline: none;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

/* ========================================
 * TABLE CONTAINER & STRUCTURE
 * ======================================== */

.table-container {
    overflow-x: auto;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    border-radius: 10px;
    overflow: hidden;
    min-width: 100%;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    font-weight: 600;
    position: sticky;
    top: 0;
    border-bottom: 2px solid rgba(78, 205, 196, 0.3);
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s ease;
}

tr:last-child td {
    border-bottom: none;
}

/* Enhanced table styling */
td {
    vertical-align: top;
}

td img {
    display: block;
    margin: 0 auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 120px !important;
    height: auto !important;
    max-height: 180px !important;
}

td img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

/* Special abilities column styling */
td:last-child {
    max-width: 300px;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Locations: last column is long rules text; global 300px cap squashes layout vs frame */
#locations-table td:last-child,
#locations-table th:last-child {
    max-width: none;
}

/* ========================================
 * FILTER SYSTEM
 * ======================================== */

/* Screen-reader-only labels (e.g. icon-only stat filter tabs on mobile) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Characters DBV: five stats merged into one th (desktop = five columns; mobile = tabbed, see mobile-layout.css) */
html:not(.layout-mobile) #characters-table .characters-stat-tablist {
    display: none;
}

html:not(.layout-mobile) #characters-table .characters-stat-filters-th {
    vertical-align: top;
    text-align: center;
}

html:not(.layout-mobile) #characters-table .characters-stat-filters {
    width: 100%;
}

html:not(.layout-mobile) #characters-table .characters-stat-inputs-and-clear {
    display: contents;
}

html:not(.layout-mobile) #characters-table .characters-filter-clear-inline {
    display: none !important;
}

html:not(.layout-mobile) #characters-table .characters-stat-panels {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}

html:not(.layout-mobile) #characters-table .characters-stat-panels .characters-stat-panel {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Table filter row styling */
.filter-row th {
    padding: 8px 4px;
    vertical-align: top;
    text-align: center;
}

.column-filters {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    text-align: center;
}

.filter-input {
    padding: 4px 6px;
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    width: 50px;
    transition: all 0.3s ease;
}

.filter-input:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow: 0 0 6px rgba(78, 205, 196, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.filter-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
}

.header-filter {
    padding: 4px 8px;
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    width: 100%;
    transition: all 0.3s ease;
}

.header-filter:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow: 0 0 6px rgba(78, 205, 196, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.header-filter::placeholder {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
}

/* Clear filters button */
.clear-filters-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
    width: 100%;
    max-width: 120px;
}

.clear-filters-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
    background: linear-gradient(135deg, #5fd8d0, #4ecdc4);
}

/* ========================================
 * CARD CATEGORY HEADERS & CONTROLS
 * ======================================== */

.card-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(78, 205, 196, 0.1);
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.category-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding-right: 8px;
    gap: 12px;
}

.category-header-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
    min-width: fit-content;
}

.filter-toggle:hover {
    background-color: rgba(78, 205, 196, 0.1);
}

.filter-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4ECDC4;
}

.toggle-label {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Power Cards filter active indicator */
.power-cards-filter-active .card-category-header {
    border-left: 4px solid #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
}

.power-cards-filter-active .toggle-label {
    color: #4ecdc4;
    font-weight: 600;
}

/* ========================================
 * SPECIAL CONTROLS & TOGGLES
 * ======================================== */

.special-cards-controls,
.aspects-controls,
.advanced-universe-controls {
    margin-bottom: 15px;
    text-align: right;
}

.toggle-button {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 5px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-button:hover {
    background: rgba(78, 205, 196, 0.3);
    border-color: rgba(78, 205, 196, 0.5);
}

.ability-toggle {
    width: 16px;
    height: 16px;
    accent-color: #4ECDC4;
}

/* ========================================
 * CHARACTER SEARCH
 * ======================================== */

.character-name-search {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 4px;
    color: white;
    padding: 4px 6px;
    font-size: 0.8rem;
    width: 150px;
    margin-left: 12px;
    transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.character-name-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.character-name-search:focus {
    outline: none;
    border-color: #4ECDC4;
    background: rgba(255, 255, 255, 0.15);
}

/* ========================================
 * INHERENT ABILITIES FILTERS
 * ======================================== */

.inherent-abilities-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

/* ========================================
 * COLUMN-SPECIFIC STYLING
 * ======================================== */

/* Cataclysm column styling */
.cataclysm-yes {
    color: #ff6b6b;
    font-weight: bold;
    text-align: center;
}

.cataclysm-no {
    color: #6c757d;
    text-align: center;
}

.cataclysm-column.hidden,
.cataclysm-cell.hidden {
    display: none;
}

/* Fortifications and One Per Deck column styling */
.fortifications-column, 
.one-per-deck-column {
    text-align: center;
}

.fortifications-column:not(.hidden), 
.one-per-deck-column:not(.hidden) {
    color: #4ecdc4;
    font-weight: bold;
}

.one-per-deck-advanced-column {
    text-align: center;
    color: #4ecdc4;
    font-weight: bold;
}

/* Threat level styling */
.threat-high { 
    color: #ff6b6b; 
    font-weight: bold; 
}

.threat-medium { 
    color: #feca57; 
    font-weight: bold; 
}

.threat-low { 
    color: #48dbfb; 
    font-weight: bold; 
}

/* ========================================
 * TABLE-SPECIFIC COLUMN WIDTHS
 * ======================================== */

/* Characters table column widths - percentage based */
#characters-table {
    table-layout: fixed;
    width: 100%;
}

#characters-table th,
#characters-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    text-align: center;
}


#characters-table th:nth-child(1), /* Image */
#characters-table td:nth-child(1) {
    width: 24%;
    text-align: center;
    vertical-align: middle;
}

/* Lock row height after initial render to prevent changes when cycling images */
/* Only apply to data rows, not header rows */
#characters-table tbody tr {
    min-height: fit-content; /* Allow natural sizing initially */
}

/* Once row is rendered, lock the image cell height to prevent changes */
#characters-table tbody td:nth-child(1) {
    min-height: 200px; /* Minimum height to accommodate portrait art up to max-width */
    /* Height will be set by JavaScript after initial render */
}

/* Characters: locked row/cell (desktop art cycling + applyCharacterImageRowHeightLock) — mirror Special/Power */
#characters-table tbody tr[data-height-locked="true"] {
    box-sizing: border-box;
    overflow: hidden;
}

#characters-table tbody td:nth-child(1)[data-height-locked="true"] {
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
}

/* Fill locked td so img max-height: % resolves to full cell (flex row: art + arrows) */
html:not(.layout-mobile) #characters-table tbody td:nth-child(1)[data-height-locked="true"] .card-image-container {
    height: 100%;
    min-height: 0;
}

#characters-table tbody td:nth-child(1)[data-height-locked="true"] img {
    max-height: 100% !important;
    max-width: min(520px, 100%) !important;
    object-fit: contain;
    display: block;
    min-width: 0;
}

/* Locked + with-nav: keep width auto so flex: 1 1 auto can grow between arrows */
html:not(.layout-mobile) #characters-table tbody td:nth-child(1)[data-height-locked="true"] .card-image-container.card-image-container--with-nav img {
    width: auto !important;
}

/* Special Cards Table - Lock row height after initial render to prevent changes when cycling images */
/* Only apply to data rows, not header rows */
#special-cards-table tbody tr {
    min-height: fit-content; /* Allow natural sizing initially */
}

/* Once row is rendered, lock the image cell height to prevent changes */
#special-cards-table tbody td:nth-child(1) {
    min-height: 200px; /* Minimum height to accommodate images */
    /* Height will be set by JavaScript after initial render */
}

/* Force locked heights to be respected - use inline styles set by JavaScript */
/* The JavaScript sets inline styles with !important, but we add CSS rules as backup */
/* IMPORTANT: These rules ensure locked rows don't change height when content changes */
#special-cards-table tbody tr[data-height-locked="true"] {
    /* Height is set via inline style with !important by JavaScript */
    /* This rule ensures the attribute selector matches and prevents any height changes */
    box-sizing: border-box;
    overflow: hidden; /* Prevent content from expanding the row */
}

#special-cards-table tbody td:nth-child(1)[data-height-locked="true"] {
    /* Height is set via inline style with !important by JavaScript */
    /* This rule ensures the attribute selector matches and prevents any height changes */
    overflow: hidden; /* Prevent content from expanding beyond locked height */
    box-sizing: border-box;
    position: relative; /* Allow absolute positioning of child elements */
}

/* Constrain images within locked cells to prevent expansion */
#special-cards-table tbody td:nth-child(1)[data-height-locked="true"] img {
    max-height: 100% !important; /* Never exceed the locked cell height */
    object-fit: contain; /* Maintain aspect ratio while fitting within bounds */
    display: block; /* Remove inline spacing */
}

/* Power Cards Table - Lock row height after initial render to prevent changes when cycling images */
/* Only apply to data rows, not header rows */
#power-cards-table tbody tr {
    min-height: fit-content; /* Allow natural sizing initially */
}

/* Once row is rendered, lock the image cell height to prevent changes */
#power-cards-table tbody td:nth-child(1) {
    min-height: 200px; /* Minimum height to accommodate images */
    /* Height will be set by JavaScript after initial render */
}

/* Force locked heights to be respected - use inline styles set by JavaScript */
/* The JavaScript sets inline styles with !important, but we add CSS rules as backup */
/* IMPORTANT: These rules ensure locked rows don't change height when content changes */
#power-cards-table tbody tr[data-height-locked="true"] {
    /* Height is set via inline style with !important by JavaScript */
    /* This rule ensures the attribute selector matches and prevents any height changes */
    box-sizing: border-box;
    overflow: hidden; /* Prevent content from expanding the row */
}

#power-cards-table tbody td:nth-child(1)[data-height-locked="true"] {
    /* Height is set via inline style with !important by JavaScript */
    /* This rule ensures the attribute selector matches and prevents any height changes */
    overflow: hidden; /* Prevent content from expanding beyond locked height */
    box-sizing: border-box;
    position: relative; /* Allow absolute positioning of child elements */
}

/* Constrain images within locked cells to prevent expansion */
#power-cards-table tbody td:nth-child(1)[data-height-locked="true"] img {
    max-height: 100% !important; /* Never exceed the locked cell height */
    object-fit: contain; /* Maintain aspect ratio while fitting within bounds */
    display: block; /* Remove inline spacing */
}

/* Beat global `td img { width: 120px; max-height: 180px } !important` so row art can use flex + max-width */
#characters-table td:nth-child(1) img {
    width: auto !important;
    max-width: min(520px, 100%);
    max-height: none !important;
    height: auto;
    object-fit: contain; /* Ensure images scale properly */
}

/* DTV Characters: fill image cell — full-width flex row; art grows between tight arrows */
html:not(.layout-mobile) #characters-table td:nth-child(1) .card-image-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 3px;
}

html:not(.layout-mobile) #characters-table td:nth-child(1) .card-image-container.card-image-container--with-nav {
    justify-content: flex-start;
}

html:not(.layout-mobile) #characters-table td:nth-child(1) .card-image-container:not(.card-image-container--with-nav) {
    justify-content: center;
}

/* Single-art DTV rows: scale thumbnails up (width:auto follows intrinsic ~small thumb size) */
html:not(.layout-mobile) #characters-table td:nth-child(1) .card-image-container:not(.card-image-container--with-nav) img {
    width: min(520px, 100%) !important;
}

html:not(.layout-mobile) #characters-table td:nth-child(1) .card-image-container.card-image-container--with-nav img {
    flex: 1 1 auto;
    min-width: 0;
    max-width: min(520px, 100%);
}

html:not(.layout-mobile) #characters-table td:nth-child(1) .card-nav-arrow {
    padding: 0 2px;
    font-size: 16px;
    flex: 0 0 auto;
}

#characters-table th:nth-child(2), /* Add to Deck */
#characters-table td:nth-child(2) {
    width: 9%;
}

#characters-table th:nth-child(3), /* Name */
#characters-table td:nth-child(3) {
    width: 17%;
}

#characters-table th:nth-child(4), /* Energy */
#characters-table td:nth-child(4) {
    width: 5.8%;
}

#characters-table th:nth-child(5), /* Combat */
#characters-table td:nth-child(5) {
    width: 5.8%;
}

#characters-table th:nth-child(6), /* Brute Force */
#characters-table td:nth-child(6) {
    width: 5.8%;
}

#characters-table th:nth-child(7), /* Intelligence */
#characters-table td:nth-child(7) {
    width: 5.8%;
}

#characters-table th:nth-child(8), /* Threat Level */
#characters-table td:nth-child(8) {
    width: 5.8%;
}

#characters-table th:nth-child(9), /* Inherent Abilities */
#characters-table td:nth-child(9) {
    width: 21%;
}

/* DTV: narrower actions column — stack fills cell; drop default min-width/padding */
html:not(.layout-mobile) #characters-table td:nth-child(2) .add-to-deck-btn,
html:not(.layout-mobile) #characters-table td:nth-child(2) .add-to-collection-btn,
html:not(.layout-mobile) #characters-table td:nth-child(2) .remove-from-collection-btn {
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* ========================================
 * LOCATIONS TABLE (DTV — mirror Characters image/actions proportions)
 * ======================================== */

#locations-table {
    table-layout: fixed;
    width: 100%;
}

#locations-table th,
#locations-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    text-align: center;
}

#locations-table th:nth-child(1), /* Image */
#locations-table td:nth-child(1) {
    width: 24%;
    text-align: center;
    vertical-align: middle;
}

#locations-table tbody td:nth-child(1) {
    min-height: 200px;
}

/* Locations: locked row/cell (same navigateCardImage height-lock path as Characters) */
#locations-table tbody tr[data-height-locked="true"] {
    box-sizing: border-box;
    overflow: hidden;
}

#locations-table tbody td:nth-child(1)[data-height-locked="true"] {
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
}

html:not(.layout-mobile) #locations-table tbody td:nth-child(1)[data-height-locked="true"] .card-image-container {
    height: 100%;
    min-height: 0;
}

#locations-table tbody td:nth-child(1)[data-height-locked="true"] img {
    max-height: 100% !important;
    width: auto !important;
    max-width: min(520px, 100%) !important;
    object-fit: contain;
    display: block;
    min-width: 0;
}

#locations-table td:nth-child(1) img {
    width: auto !important;
    max-width: min(520px, 100%) !important;
    max-height: none !important;
    height: auto;
    object-fit: contain;
}

/* DTV Locations: same image-cell flex pattern as Characters */
html:not(.layout-mobile) #locations-table td:nth-child(1) .card-image-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 3px;
}

html:not(.layout-mobile) #locations-table td:nth-child(1) .card-image-container.card-image-container--with-nav {
    justify-content: flex-start;
}

html:not(.layout-mobile) #locations-table td:nth-child(1) .card-image-container:not(.card-image-container--with-nav) {
    justify-content: center;
}

html:not(.layout-mobile) #locations-table td:nth-child(1) .card-image-container.card-image-container--with-nav img {
    flex: 1 1 auto;
    min-width: 0;
    max-width: min(520px, 100%);
}

html:not(.layout-mobile) #locations-table td:nth-child(1) .card-nav-arrow {
    padding: 0 2px;
    font-size: 16px;
    flex: 0 0 auto;
}

#locations-table th:nth-child(2), /* Actions */
#locations-table td:nth-child(2) {
    width: 9%;
}

#locations-table th:nth-child(3), /* Name */
#locations-table td:nth-child(3) {
    width: 17%;
}

#locations-table th:nth-child(4), /* Threat Level */
#locations-table td:nth-child(4) {
    width: 6%;
}

#locations-table th:nth-child(5), /* Special Ability */
#locations-table td:nth-child(5) {
    width: 44%;
}

html:not(.layout-mobile) #locations-table td:nth-child(2) .add-to-deck-btn,
html:not(.layout-mobile) #locations-table td:nth-child(2) .add-to-collection-btn,
html:not(.layout-mobile) #locations-table td:nth-child(2) .remove-from-collection-btn {
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* Events table column widths — DTV parity with Characters/Locations image + actions */
#events-table {
    table-layout: fixed;
    width: 100%;
}

#events-table th,
#events-table td {
    text-align: center;
    vertical-align: top;
}

#events-table th:nth-child(1), /* Image */
#events-table td:nth-child(1) {
    width: 24%;
    vertical-align: middle;
}

#events-table tbody td:nth-child(1) {
    min-height: 200px;
}

#events-table td:nth-child(1) img {
    width: auto !important;
    max-width: min(520px, 100%) !important;
    max-height: none !important;
    height: auto;
    object-fit: contain;
}

html:not(.layout-mobile) #events-table td:nth-child(1) .card-image-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 3px;
    justify-content: center;
}

html:not(.layout-mobile) #events-table td:nth-child(1) .card-nav-arrow {
    padding: 0 2px;
    font-size: 16px;
    flex: 0 0 auto;
}

#events-table th:nth-child(2), /* Add To Deck */
#events-table td:nth-child(2) {
    width: 9%;
}

#events-table th:nth-child(3), /* Name */
#events-table td:nth-child(3) {
    width: 10%;
}

#events-table th:nth-child(4), /* Mission Set */
#events-table td:nth-child(4) {
    width: 14%;
}

#events-table th:nth-child(5), /* Game Effect */
#events-table td:nth-child(5) {
    width: 24%;
}

#events-table th:nth-child(6), /* Flavor Text */
#events-table td:nth-child(6) {
    width: 19%;
}

html:not(.layout-mobile) #events-table td:nth-child(2) .add-to-deck-btn,
html:not(.layout-mobile) #events-table td:nth-child(2) .add-to-collection-btn,
html:not(.layout-mobile) #events-table td:nth-child(2) .remove-from-collection-btn {
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* Missions table — DTV same image/actions pattern as Locations */
#missions-table {
    table-layout: fixed;
    width: 100%;
}

#missions-table thead tr:first-child th {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    font-weight: 600;
}

#missions-table th,
#missions-table td {
    text-align: center;
    vertical-align: top;
}

#missions-table thead tr:first-child th:nth-child(1), /* Image */
#missions-table tbody td:nth-child(1) {
    width: 22%;
    vertical-align: middle;
}

#missions-table tbody td:nth-child(1) {
    min-height: 200px;
}

#missions-table td:nth-child(1) img {
    width: auto !important;
    max-width: min(520px, 100%) !important;
    max-height: none !important;
    height: auto;
    object-fit: contain;
}

html:not(.layout-mobile) #missions-table td:nth-child(1) .card-image-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 3px;
    justify-content: center;
}

html:not(.layout-mobile) #missions-table td:nth-child(1) .card-nav-arrow {
    padding: 0 2px;
    font-size: 16px;
    flex: 0 0 auto;
}

#missions-table thead tr:first-child th:nth-child(2), /* Actions */
#missions-table tbody td:nth-child(2) {
    width: 8%;
}

#missions-table thead tr:first-child th:nth-child(3), /* Mission Set */
#missions-table tbody td:nth-child(3) {
    width: 20%;
    min-width: 0;
}

#missions-table thead tr:first-child th:nth-child(4), /* Card Name */
#missions-table tbody td:nth-child(4) {
    width: 33%;
    max-width: none;
}

#missions-table thead tr:first-child th:nth-child(5), /* Product set */
#missions-table tbody td:nth-child(5) {
    width: 17%;
    min-width: 0;
}

html:not(.layout-mobile) #missions-table td:nth-child(2) .add-to-deck-btn,
html:not(.layout-mobile) #missions-table td:nth-child(2) .add-to-collection-btn,
html:not(.layout-mobile) #missions-table td:nth-child(2) .remove-from-collection-btn {
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* DTV: mission-set <select> in Mission Set column (MV-style label + teal chrome); card-name row is MV-only */
#missions-table .missions-mobile-set-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#missions-table .missions-mobile-card-name-row {
    display: none;
}

/* Redundant with thead "Mission Set" on DTV; MV shows label in mobile-layout.css */
#missions-table .missions-mobile-set-row > .missions-mobile-set-label {
    display: none;
}

#missions-table .missions-mission-set-filter {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.9rem;
    line-height: 1.2;
    border-radius: 8px;
    border: 1px solid rgba(78, 205, 196, 0.35);
    background: rgba(18, 44, 50, 0.95);
    color: #fff;
}

/* Events: mission-set <select> same pattern as Missions (DTV); label redundant with column header */
#events-table .events-mobile-set-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#events-table .events-mobile-set-row > .events-mobile-set-label {
    display: none;
}

#events-table .events-mobile-set-select-clear-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#events-table .events-mission-set-filter {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.9rem;
    line-height: 1.2;
    border-radius: 8px;
    border: 1px solid rgba(78, 205, 196, 0.35);
    background: rgba(18, 44, 50, 0.95);
    color: #fff;
}

#events-table #clear-events-filters-mobile.clear-filters-btn--events-mobile-inline {
    display: none;
}

/* Teamwork: mobile-only filter row shell (see mobile-layout.css). On DTV hide the whole mobile row
   except we only need to hide each th — desktop filter row already has Clear All + column filters.
   teamwork-filter-clear-th was left visible by mistake and duplicated the desktop Clear button.
   Do not use !important here — mobile-layout.css uses higher-specificity selectors on
   .layout-mobile and in @media (max-width: 900px) #database-view; !important would block those overrides. */
#teamwork-table thead tr.teamwork-filter-row > th.teamwork-filter-clear-th {
    display: none;
}

#teamwork-table thead tr.teamwork-filter-row > th.teamwork-filter-controls-th {
    display: none;
}

#teamwork-table thead tr.teamwork-filter-row > th.teamwork-filter-spacer-th {
    display: none;
}

#teamwork-table .teamwork-mobile-filter-shell {
    display: none;
}

#teamwork-table #clear-teamwork-filters-mobile-inline.clear-filters-btn--teamwork-mobile-inline {
    display: none;
}

/* Teamwork DTV: per-column filter row (Power-style toggles + Basic-style numeric). Hidden on mobile in mobile-layout.css. */
#teamwork-table {
    /* Shared by .teamwork-desktop-bonus-stack (1st/2nd bonus + To Use value column) */
    --teamwork-dtv-numeric-stack-gap: 10px;
}

#teamwork-table thead tr.teamwork-desktop-filter-row th {
    vertical-align: top;
}

/* To Use DTV: icon column + same flex stack as bonus columns for = / Max / Min */
#teamwork-table .teamwork-desktop-to-use-column-filters.column-filters {
    align-items: flex-start;
}

#teamwork-table .teamwork-desktop-to-use-split {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 8px;
}

#teamwork-table .teamwork-desktop-to-use-icons-column {
    display: flex;
    flex-direction: column;
    gap: var(--teamwork-dtv-numeric-stack-gap);
    flex-shrink: 0;
}

#teamwork-table .teamwork-desktop-to-use-icons-column .special-power-filter-toggles {
    margin-bottom: 0;
}

/* Nested .teamwork-desktop-bonus-stack under To Use uses same #teamwork-table .teamwork-desktop-bonus-stack rules as 1st/2nd bonus th */
#teamwork-table .teamwork-desktop-to-use-split .teamwork-desktop-bonus-stack {
    flex-shrink: 0;
}

/* 1st / 2nd Attack Bonus DTV: vertical stack (=, Max, Min); same gap as To Use numerics */
#teamwork-table .teamwork-desktop-bonus-stack {
    display: flex;
    flex-direction: column;
    gap: var(--teamwork-dtv-numeric-stack-gap);
    align-items: flex-start;
}

#teamwork-table .teamwork-desktop-bonus-stack-input {
    width: 3.25rem;
    min-width: 3rem;
    max-width: 4rem;
    box-sizing: border-box;
}

/* Ally: mobile-only filter shell (see mobile-layout.css); DTV uses ally-desktop-filter-row per-column filters. */
#ally-universe-table thead tr.ally-filter-row > th.ally-filter-controls-th {
    display: none;
}

#ally-universe-table thead tr.ally-filter-row > th.ally-filter-spacer-th {
    display: none;
}

#ally-universe-table .ally-mobile-filter-shell {
    display: none;
}

#ally-universe-table #clear-ally-filters-mobile-inline.clear-filters-btn--ally-mobile-inline {
    display: none;
}

/* Ally DTV: per-column filter row (Power-style type toggles + Basic-style bonus numerics). Hidden on mobile in mobile-layout.css. */
#ally-universe-table thead tr.ally-desktop-filter-row th {
    vertical-align: top;
}

#ally-universe-table thead tr.ally-desktop-filter-row .special-power-filter-toggles {
    margin-bottom: 0;
}

/* Training: DTV uses training-desktop-filter-row (name + Type1/Type2); entire training-filter-row hidden on DTV (see mobile-layout.css). */
#training-table thead tr.training-filter-row {
    display: none;
}

/* Legacy: mobile row cells (only relevant when row is shown on MV). */
#training-table thead tr.training-filter-row > th.training-filter-controls-th {
    display: none;
}

#training-table thead tr.training-filter-row > th.training-filter-spacer-th {
    display: none;
}

#training-table .training-mobile-filter-shell {
    display: none;
}

#training-table #clear-training-filters-mobile-inline.clear-filters-btn--training-mobile-inline {
    display: none;
}

/* Training DTV: per-column filter row (mirrors Ally desktop). */
#training-table thead tr.training-desktop-filter-row th {
    vertical-align: top;
}

#training-table thead tr.training-desktop-filter-row .special-power-filter-toggles {
    margin-bottom: 0;
}

/* Basic Universe: mobile-only filter shell (see mobile-layout.css); desktop keeps two header rows with column filters.
   Hide mobile row Clear th on DTV — same pattern as #teamwork-table .teamwork-filter-clear-th (avoids duplicate Clear All). */
#basic-universe-table thead tr.basic-universe-filter-row > th.basic-universe-filter-clear-th {
    display: none;
}

#basic-universe-table thead tr.basic-universe-filter-row > th.basic-universe-filter-controls-th {
    display: none;
}

#basic-universe-table thead tr.basic-universe-filter-row > th.basic-universe-filter-spacer-th {
    display: none;
}

#basic-universe-table .basic-universe-mobile-filter-shell {
    display: none;
}

#basic-universe-table #clear-basic-universe-filters-mobile-inline.clear-filters-btn--basic-universe-mobile-inline {
    display: none;
}

/* Basic Universe DTV: Card Name + Value/Bonus = / Max / Min vertical stack (aligned with Teamwork DTV numerics). */
#basic-universe-table {
    --basic-universe-dtv-numeric-stack-gap: 10px;
}

#basic-universe-table thead tr.basic-universe-desktop-filter-row th {
    vertical-align: top;
}

/* Fill the th so align-items: center actually centers the field under the header + tbody name column */
#basic-universe-table .basic-universe-desktop-card-name-filters.column-filters {
    width: 100%;
    align-items: center;
}

#basic-universe-table .basic-universe-desktop-card-name-input {
    width: min(100%, 14rem);
    min-width: 5.5rem;
    max-width: 14rem;
    box-sizing: border-box;
}

#basic-universe-table .basic-universe-desktop-numeric-stack {
    display: flex;
    flex-direction: column;
    gap: var(--basic-universe-dtv-numeric-stack-gap);
    align-items: center;
    width: 100%;
}

#basic-universe-table .basic-universe-desktop-numeric-stack-input {
    width: 3.25rem;
    min-width: 3rem;
    max-width: 4rem;
    box-sizing: border-box;
}

/* Power Cards DTV: Value column vertical stack (=, Max, Min), same pattern as Teamwork `.teamwork-desktop-bonus-stack` */
#power-cards-table {
    --power-dtv-value-stack-gap: 10px;
}

#power-cards-table thead tr.power-cards-desktop-filter-row th {
    vertical-align: top;
}

#power-cards-table .column-filters.power-cards-desktop-value-stack {
    display: flex;
    flex-direction: column;
    gap: var(--power-dtv-value-stack-gap);
    align-items: center;
}

#power-cards-table .power-cards-desktop-value-stack-input {
    width: 3.25rem;
    min-width: 3rem;
    max-width: 4rem;
    box-sizing: border-box;
}

/* Power Cards: mobile-only filter shell (see mobile-layout.css); desktop keeps desktop filter row. */
#power-cards-table thead tr.power-cards-filter-row > th.power-cards-filter-clear-th {
    display: none;
}

#power-cards-table thead tr.power-cards-filter-row > th.power-cards-filter-controls-th {
    display: none;
}

#power-cards-table thead tr.power-cards-filter-row > th.power-cards-filter-spacer-th {
    display: none;
}

#power-cards-table .power-cards-mobile-filter-shell {
    display: none;
}

#power-cards-table #clear-power-filters-mobile-inline.clear-filters-btn--power-mobile-inline {
    display: none;
}

/* Missions: leading th spans Image + actions columns (do not use display:none — it breaks column alignment). */
#missions-table .missions-filter-leading-th {
    padding: 0;
    border-bottom: 2px solid rgba(78, 205, 196, 0.3);
}

/* Special Cards Table Column Widths */
/* DEBUG: Special Cards Table Layout */
#special-cards-table {
    table-layout: fixed !important; /* DEBUG: Force fixed layout */
    width: 100% !important; /* DEBUG: Force full width */
    /* DEBUG: This should override any auto layout rules */
}

#special-cards-table th:nth-child(1), /* Image */
#special-cards-table td:nth-child(1) {
    width: 14% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(2), /* Add to Deck */
#special-cards-table td:nth-child(2) {
    width: 9% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 100px !important; /* Ensure button has enough room */
}

#special-cards-table th:nth-child(3), /* Name */
#special-cards-table td:nth-child(3) {
    width: 15% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(4), /* Character */
#special-cards-table td:nth-child(4) {
    width: 13% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(5), /* Card Effect */
#special-cards-table td:nth-child(5) {
    width: 21% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(6), /* Icon */
#special-cards-table td:nth-child(6) {
    width: 8% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(7), /* Value */
#special-cards-table td:nth-child(7) {
    width: 8% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#special-cards-table th:nth-child(8), /* Function */
#special-cards-table td:nth-child(8) {
    width: 12% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.special-power-icons-cell {
    display: grid;
    grid-template-columns: repeat(2, 20px);
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.column-header-icon {
    display: block;
    margin: 0 auto;
    cursor: default !important;
}

.special-power-type-icon {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px !important;
    max-height: 20px !important;
    object-fit: contain;
}

.special-icon-text-fallback {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.75);
}

.teamwork-acts-as-cell .teamwork-acts-as-type-label {
    margin-left: 2px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
}

.teamwork-value-icon-cell {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.followup-icons-cell {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}


.special-function-icons-cell {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.special-function-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px !important;
    max-height: 32px !important;
    flex: 0 0 32px;
    margin: 0 !important;
    object-fit: contain;
}

.special-function-icons-cell .special-function-icon:hover {
    transform: none;
    box-shadow: none;
}

.special-function-icons-empty {
    color: rgba(255, 255, 255, 0.45);
}

.special-function-filter-toggles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    justify-items: center;
}

.special-no-value-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    padding-top: 4px;
    white-space: nowrap;
}

.icon-filter-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.special-power-filter-toggles {
    display: grid;
    grid-template-columns: repeat(2, 36px);
    gap: 6px;
    justify-items: center;
}

.power-type-filter-toggle {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    padding: 0;
}

.power-type-filter-toggle:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

.power-type-filter-toggle.is-active {
    background: rgba(75, 198, 186, 0.35);
    border-color: rgba(75, 198, 186, 0.85);
    transform: translateY(-1px);
}

.power-type-filter-toggle.is-disabled,
.power-type-filter-toggle:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

.power-type-filter-toggle img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.power-type-filter-text {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.02em;
}

/* Special Cards: "No icon" matches power-type toggle chrome; checkbox is visually hidden */
.special-no-icon-toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
}

.special-no-icon-toggle-face {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-sizing: border-box;
}

.special-no-icon-toggle-label:hover .special-no-icon-toggle-face {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

#special-no-icon-toggle:checked + .special-no-icon-toggle-face {
    background: rgba(75, 198, 186, 0.35);
    border-color: rgba(75, 198, 186, 0.85);
    transform: translateY(-1px);
}

#special-no-icon-toggle:focus-visible + .special-no-icon-toggle-face {
    outline: none;
    box-shadow: 0 0 0 2px rgba(75, 198, 186, 0.7);
}

/* Match .filter-input::placeholder (Min/Max label tone) */
.special-no-icon-svg {
    width: 20px;
    height: 20px;
    display: block;
    color: rgba(255, 255, 255, 0.5);
}

#special-no-icon-toggle:checked + .special-no-icon-toggle-face .special-no-icon-svg {
    color: rgba(255, 255, 255, 0.5);
}

/* Special Cards value column: "No value" ban button (same checkbox semantics as Aspects text row) */
#special-cards-table .special-no-value-toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
    gap: 0;
    white-space: nowrap;
}

#special-cards-table .special-no-value-toggle-face {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-sizing: border-box;
}

#special-cards-table .special-no-value-toggle-label:hover .special-no-value-toggle-face {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

#special-cards-table #special-no-value-toggle:checked + .special-no-value-toggle-face {
    background: rgba(75, 198, 186, 0.35);
    border-color: rgba(75, 198, 186, 0.85);
    transform: translateY(-1px);
}

#special-cards-table #special-no-value-toggle:focus-visible + .special-no-value-toggle-face {
    outline: none;
    box-shadow: 0 0 0 2px rgba(75, 198, 186, 0.7);
}

/* Match .filter-input::placeholder (same as Min/Max placeholders) */
#special-cards-table .special-no-value-svg {
    width: 20px;
    height: 20px;
    display: block;
    color: rgba(255, 255, 255, 0.5);
}

#special-cards-table #special-no-value-toggle:checked + .special-no-value-toggle-face .special-no-value-svg {
    color: rgba(255, 255, 255, 0.5);
}

#special-cards-table .special-no-value-toggle-label input[type="checkbox"].visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Aspects value column: "No value" ban button (match Special Cards #special-cards-table chrome) */
#aspects-table .special-no-value-toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
    gap: 0;
    white-space: nowrap;
}

#aspects-table .special-no-value-toggle-face {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    box-sizing: border-box;
}

#aspects-table .special-no-value-toggle-label:hover .special-no-value-toggle-face {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

#aspects-table #aspect-no-value-toggle:checked + .special-no-value-toggle-face {
    background: rgba(75, 198, 186, 0.35);
    border-color: rgba(75, 198, 186, 0.85);
    transform: translateY(-1px);
}

#aspects-table #aspect-no-value-toggle:focus-visible + .special-no-value-toggle-face {
    outline: none;
    box-shadow: 0 0 0 2px rgba(75, 198, 186, 0.7);
}

#aspects-table .special-no-value-svg {
    width: 20px;
    height: 20px;
    display: block;
    color: rgba(255, 255, 255, 0.5);
}

#aspects-table #aspect-no-value-toggle:checked + .special-no-value-toggle-face .special-no-value-svg {
    color: rgba(255, 255, 255, 0.5);
}

#aspects-table .special-no-value-toggle-label input[type="checkbox"].visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Locations: inline clear in threat strip on mobile only (see mobile-layout.css) */
#locations-table #clear-location-filters-mobile.clear-filters-btn--locations-mobile-inline {
    display: none;
}

/* Aspects: mobile Clear lives in icon row (.aspect-icon-mobile-trailing); hidden on desktop */
#aspects-table .aspect-icon-mobile-trailing {
    display: none;
}

#aspects-table .aspects-value-inputs-and-clear {
    display: block;
    box-sizing: border-box;
}

#aspects-table .aspects-value-inputs-and-clear .special-value-filters-inner {
    width: 100%;
    min-width: 0;
}

#locations-table .locations-threat-inputs-and-clear {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

#locations-table .locations-threat-inputs-and-clear .filter-input {
    width: auto;
    min-width: 3.25rem;
}

/* Desktop: keep Min/Max threat inputs readable (narrow th otherwise clips placeholders) */
#locations-table thead .locations-filter-threat-th {
    min-width: 140px;
}

.special-no-value-toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #4ecdc4;
}

#special-cards-table .filter-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.function-filter-toggle {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.function-filter-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

.function-filter-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(75, 198, 186, 0.7);
}

.function-filter-toggle.is-active {
    background: rgba(75, 198, 186, 0.35);
    border-color: rgba(75, 198, 186, 0.85);
    transform: translateY(-1px);
}

.function-filter-toggle img {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    max-width: 24px;
    max-height: 24px;
    margin: 0;
    object-fit: contain;
}

/* All other tables - center aligned */
#special-cards-table th,
#special-cards-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    overflow: hidden;
    box-sizing: border-box;
}

#special-cards-table th,
#special-cards-table td,
#advanced-universe-table th,
#advanced-universe-table td,
#locations-table th,
#locations-table td,
#aspects-table th,
#aspects-table td,
#teamwork-table th,
#teamwork-table td,
#ally-universe-table th,
#ally-universe-table td,
#training-table th,
#training-table td,
#power-cards-table th,
#power-cards-table td,
#basic-universe-table th,
#basic-universe-table td {
    text-align: center;
}

/* Enable flexible column widths for all tables to accommodate text wrapping */
/* #characters-table, #locations-table, #missions-table, #events-table omitted: fixed layout + DTV parity */
#aspects-table,
#ally-universe-table,
#training-table,
#power-cards-table,
#basic-universe-table,
#teamwork-table {
    table-layout: auto; /* DEBUG: This rule applies to all tables - may conflict with fixed layout */
}

/* Aspects Table Column Widths */
#aspects-table {
    table-layout: fixed;
}

#aspects-table th:nth-child(1), /* Image */
#aspects-table td:nth-child(1) {
    width: 12% !important;
}

#aspects-table th:nth-child(2), /* Add to Deck */
#aspects-table td:nth-child(2) {
    width: 9% !important;
    min-width: 100px !important;
}

#aspects-table th:nth-child(3), /* Card Name */
#aspects-table td:nth-child(3) {
    width: 13% !important;
}

#aspects-table th:nth-child(4), /* Location */
#aspects-table td:nth-child(4) {
    width: 12% !important;
}

#aspects-table th:nth-child(5), /* Card Effect */
#aspects-table td:nth-child(5) {
    width: 22% !important;
}

#aspects-table th:nth-child(6), /* Icon */
#aspects-table td:nth-child(6) {
    width: 8% !important;
}

#aspects-table th:nth-child(7), /* Value */
#aspects-table td:nth-child(7) {
    width: 7% !important;
}

#aspects-table th:nth-child(8), /* Fortifications */
#aspects-table td:nth-child(8) {
    width: 8.5% !important;
}

#aspects-table th:nth-child(9), /* One Per Deck */
#aspects-table td:nth-child(9) {
    width: 8.5% !important;
}

/* Advanced Universe Table Column Widths */
#advanced-universe-table {
    table-layout: fixed;
}

#advanced-universe-table th:nth-child(1), /* Image column */
#advanced-universe-table td:nth-child(1) {
    width: 20%;
}

#advanced-universe-table th:nth-child(2), /* Empty column */
#advanced-universe-table td:nth-child(2) {
    width: 5%;
}

#advanced-universe-table th:nth-child(3), /* Name column */
#advanced-universe-table td:nth-child(3) {
    width: 20%;
}

#advanced-universe-table th:nth-child(4), /* Character column - increased width */
#advanced-universe-table td:nth-child(4) {
    width: 25%;
}

#advanced-universe-table th:nth-child(5), /* Card Effect column - decreased width */
#advanced-universe-table td:nth-child(5) {
    width: 20%;
}

#advanced-universe-table th:nth-child(6), /* One Per Deck column */
#advanced-universe-table td:nth-child(6) {
    width: 10%;
}

/* Advanced Universe Search Input Styling - Moved to inline CSS in index.html for higher specificity */

/* Enable text wrapping for all table cells */
#missions-table th,
#missions-table td,
#events-table th,
#events-table td,
#locations-table th,
#locations-table td,
#characters-table th,
#characters-table td,
#special-cards-table th,
#special-cards-table td,
#advanced-universe-table th,
#advanced-universe-table td,
#aspects-table th,
#aspects-table td,
#ally-universe-table th,
#ally-universe-table td,
#training-table th,
#training-table td,
#power-cards-table th,
#power-cards-table td,
#basic-universe-table th,
#basic-universe-table td,
#teamwork-table th,
#teamwork-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    padding: 8px 12px;
    line-height: 1.4;
}

/* ========================================
 * ADD TO DECK BUTTON
 * ======================================== */

.add-to-deck-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-deck-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-deck-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.add-to-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-collection-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-collection-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.remove-from-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.remove-from-collection-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.remove-from-collection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure buttons match width when in table cells */
table td .add-to-deck-btn {
    width: 100% !important;
    display: block;
}

table td .add-to-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

table td .remove-from-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

/* ========================================
 * UTILITY CLASSES
 * ======================================== */

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #bdc3c7;
}

.error {
    text-align: center;
    padding: 40px;
    color: #ff6b6b;
}

/* ========================================
 * RESPONSIVE DESIGN
 * ======================================== */

/* Ensure long text content wraps properly */
.table-container {
    overflow-x: auto;
}

/* Make sure tables can expand horizontally if needed */
table {
    min-width: 100%;
}

/* ========================================
 * FILTER BAR STYLES (Power Cards)
 * ======================================== */

.filter-bar {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.filter-group label {
    font-weight: 600;
    color: #4ecdc4;
    font-size: 0.9rem;
}

#teamwork-table th,
#teamwork-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    padding: 8px 12px;
    line-height: 1.4;
}

/* ========================================
 * ADD TO DECK BUTTON
 * ======================================== */

.add-to-deck-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-deck-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-deck-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.add-to-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-collection-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-collection-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.remove-from-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.remove-from-collection-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.remove-from-collection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure buttons match width when in table cells */
table td .add-to-deck-btn {
    width: 100% !important;
    display: block;
}

table td .add-to-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

table td .remove-from-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

/* ========================================
 * UTILITY CLASSES
 * ======================================== */

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #bdc3c7;
}

.error {
    text-align: center;
    padding: 40px;
    color: #ff6b6b;
}

/* ========================================
 * RESPONSIVE DESIGN
 * ======================================== */

/* Ensure long text content wraps properly */
.table-container {
    overflow-x: auto;
}

/* Make sure tables can expand horizontally if needed */
table {
    min-width: 100%;
}

/* ========================================
 * FILTER BAR STYLES (Power Cards)
 * ======================================== */

.filter-bar {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.filter-group label {
    font-weight: 600;
    color: #4ecdc4;
    font-size: 0.9rem;
}

#teamwork-table th,
#teamwork-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    padding: 8px 12px;
    line-height: 1.4;
}

/* ========================================
 * ADD TO DECK BUTTON
 * ======================================== */

.add-to-deck-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-deck-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-deck-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.add-to-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-collection-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-collection-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.remove-from-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.remove-from-collection-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.remove-from-collection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure buttons match width when in table cells */
table td .add-to-deck-btn {
    width: 100% !important;
    display: block;
}

table td .add-to-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

table td .remove-from-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

/* ========================================
 * UTILITY CLASSES
 * ======================================== */

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #bdc3c7;
}

.error {
    text-align: center;
    padding: 40px;
    color: #ff6b6b;
}

/* ========================================
 * RESPONSIVE DESIGN
 * ======================================== */

/* Ensure long text content wraps properly */
.table-container {
    overflow-x: auto;
}

/* Make sure tables can expand horizontally if needed */
table {
    min-width: 100%;
}

/* ========================================
 * FILTER BAR STYLES (Power Cards)
 * ======================================== */

.filter-bar {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.filter-group label {
    font-weight: 600;
    color: #4ecdc4;
    font-size: 0.9rem;
}

#teamwork-table th,
#teamwork-table td {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    vertical-align: top;
    padding: 8px 12px;
    line-height: 1.4;
}

/* ========================================
 * ADD TO DECK BUTTON
 * ======================================== */

.add-to-deck-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-deck-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-deck-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.add-to-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 90px;
    box-sizing: border-box;
}

.add-to-collection-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.add-to-collection-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.remove-from-collection-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.remove-from-collection-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.remove-from-collection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ensure buttons match width when in table cells */
table td .add-to-deck-btn {
    width: 100% !important;
    display: block;
}

table td .add-to-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

table td .remove-from-collection-btn {
    width: 100% !important;
    display: block;
    margin-top: 4px;
}

/* ========================================
 * UTILITY CLASSES
 * ======================================== */

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #bdc3c7;
}

.error {
    text-align: center;
    padding: 40px;
    color: #ff6b6b;
}

/* ========================================
 * RESPONSIVE DESIGN
 * ======================================== */

/* Ensure long text content wraps properly */
.table-container {
    overflow-x: auto;
}

/* Make sure tables can expand horizontally if needed */
table {
    min-width: 100%;
}

/* ========================================
 * FILTER BAR STYLES (Power Cards)
 * ======================================== */

.filter-bar {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.filter-group label {
    font-weight: 600;
    color: #4ecdc4;
    font-size: 0.9rem;
}


/* ========================================
 * ALL CARDS TAB STYLES
 * ======================================== */

#all-cards-tab {
    padding: 0;
}

#all-cards-filter-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.all-cards-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 14px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    outline: none;
}

.all-cards-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.all-cards-search-input:focus {
    border-color: #4ecdc4;
    box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.25);
}

#all-cards-type-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
}

.card-type-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    user-select: none;
}

.card-type-filter:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
}

.card-type-filter input {
    margin: 0;
    accent-color: #4ecdc4;
    cursor: pointer;
}

#all-cards-grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    padding: 15px;
}

.all-cards-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    transition: background 0.2s ease;
    min-height: 100%;
}

.all-cards-cell:hover {
    background: rgba(0, 0, 0, 0.4);
}

.all-cards-cell .card-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Inner wrapper for foil cards — sized to the image so overflow:hidden clips correctly */
.all-cards-img-wrap {
    display: block;
    max-width: 200px;
    width: 100%;
    border-radius: 5px;
    line-height: 0;
}

.all-cards-cell img {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 5px;
    cursor: pointer;
}

.all-cards-cell img.horizontal-card {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 300px;
}

.all-cards-cell .card-content-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: auto;
}

.all-cards-cell .add-to-deck-btn,
.all-cards-cell .add-to-collection-btn,
.all-cards-cell .remove-from-collection-btn {
    width: 100%;
    margin-top: 4px;
}

/* Responsive: 3 columns on smaller screens */
@media (max-width: 1200px) {
    #all-cards-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Responsive: 1 column at narrow widths (matches layout-mode 900px band) */
@media (max-width: 900px) {
    #all-cards-grid-container {
        grid-template-columns: minmax(0, 1fr);
    }
}
