/* ========================================
 * PHASE 1: CSS EXTRACTION
 * ========================================
 * 
 * This file contains all CSS styles extracted from index.html during Phase 1
 * of the refactoring project. This extraction reduced the HTML file by ~5,000 lines
 * and improved maintainability by separating concerns.
 * 
 * Purpose: All styling for the Excelsior Deckbuilder application
 * Created: Phase 1 of 12-phase refactoring project
 * Impact: Reduced HTML file size significantly
 * 
 * ======================================== */

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            margin: 0;
            padding: 20px;
            color: #ffffff;
            min-height: 100vh;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        /* View visibility: one view visible at a time, no overlap (avoids grid/stacking bugs) */
        #database-view.view-removed,
        #deck-builder.view-removed,
        #collection-view.view-removed {
            display: none !important;
        }


        .header h1 {
            margin: 0;
            font-size: 2.5rem;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .header p {
            margin: 10px 0 0 0;
            font-size: 1.2rem;
            color: #bdc3c7;
        }


        .characters-section {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .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;
        }

        .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%;
        }

        .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;
        }


        .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;
        }

        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;
        }

        /* Special cards controls styling */
        .special-cards-controls {
            margin-bottom: 15px;
            text-align: right;
        }
        
        /* Special cards header with toggle */
        .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; /* Prevent shrinking */
            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;
        }

        /* Character name search input */
        .character-name-search,
        .character-stack-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,
        .character-stack-name-search::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }

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


        /* 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;
        }

        .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);
        }

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

        /* Aspects controls styling */
        .aspects-controls {
            margin-bottom: 15px;
            text-align: right;
        }

        /* Hidden column styling */
        .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;
        }

        /* Aspects table column width adjustments */
        #aspects-table th:nth-child(5), /* Card Effect column */
        #aspects-table td:nth-child(5) {
            width: 35%;
            max-width: 35%;
        }

        #aspects-table th:nth-child(6), /* Fortifications column */
        #aspects-table td:nth-child(6) {
            width: 12%;
            min-width: 110px;
            white-space: nowrap;
        }

        #aspects-table th:nth-child(7), /* One Per Deck column */
        #aspects-table td:nth-child(7) {
            width: 9%;
            min-width: 90px;
            white-space: nowrap;
        }

        /* Advanced Universe controls styling */
        .advanced-universe-controls {
            margin-bottom: 15px;
            text-align: right;
        }

        /* One Per Deck Advanced column styling */
        .one-per-deck-advanced-column {
            text-align: center;
            color: #4ecdc4;
            font-weight: bold;
        }

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

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

        .threat-high { color: #ff6b6b; font-weight: bold; }
        .threat-medium { color: #feca57; font-weight: bold; }
        .threat-low { color: #48dbfb; font-weight: bold; }

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

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

        .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);
        }

        /* Inline Filter Controls Styling */

        .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);
        }

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

        .column-filters {
            display: flex;
            flex-direction: column;
            gap: 4px;
            align-items: 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;
        }

        /* 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;
        }

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

        #characters-table td:nth-child(1) img {
            max-width: min(520px, 100%);
            height: 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%;
        }

        /* Locations table — DTV column parity with Characters (image / actions / name / threat / special) */
        #locations-table {
            table-layout: fixed;
            width: 100%;
        }

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

        #locations-table td:nth-child(1) img {
            width: auto !important;
            max-width: min(520px, 100%) !important;
            max-height: none !important;
            height: 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 */
        #locations-table td:nth-child(4) {
            width: 6%;
        }

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

        /* Missions — DTV column parity (thead first row + tbody; filter row differs) */
        #missions-table {
            table-layout: fixed;
            width: 100%;
        }

        #missions-table thead tr:first-child th:nth-child(1),
        #missions-table tbody td:nth-child(1) {
            width: 22%;
        }

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

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

        #missions-table thead tr:first-child th:nth-child(3),
        #missions-table tbody td:nth-child(3) {
            width: 20%;
        }

        #missions-table thead tr:first-child th:nth-child(4),
        #missions-table tbody td:nth-child(4) {
            width: 33%;
        }

        #missions-table thead tr:first-child th:nth-child(5),
        #missions-table tbody td:nth-child(5) {
            width: 17%;
        }

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

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

        #events-table td:nth-child(1) img {
            width: auto !important;
            max-width: min(520px, 100%) !important;
            max-height: none !important;
            height: 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%;
        }

        .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;
        }

        /* Inherent Abilities filter styling */
        .inherent-abilities-filters {
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: center;
        }

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

        .ability-toggle {
            width: 16px;
            height: 16px;
            accent-color: rgba(78, 205, 196, 0.3);
            cursor: pointer;
            filter: brightness(0.7) saturate(0.8);
            opacity: 0.6;
        }

        .ability-toggle:checked {
            filter: none;
            opacity: 1;
        }

        .toggle-text {
            white-space: nowrap;
        }

        /* Modal Styles */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            background-color: #000000;
            padding-top: 20px;
        }

        .modal-content {
            margin: 20px auto;
            display: block;
            width: 400px; /* 5x the table image width (80px * 5) */
            height: auto;
            border-radius: 10px;
            border: 1px solid #4ecdc4;
            box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
            position: relative;
        }


        .modal-content img {
            width: auto;
            height: auto;
            max-width: 100%;
            max-height: 100%;
            display: block;
            object-fit: contain; /* Ensures no cropping, maintains aspect ratio */
        }

        /* Card image lightbox only — frame hugs artwork (see .layout-mobile #imageModal in mobile-layout.css). */
        #imageModal .modal-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: fit-content;
            width: -moz-fit-content;
            max-width: min(400px, 92vw);
            box-sizing: border-box;
        }

        #imageModal #modalImage {
            width: auto;
            height: auto;
            max-width: min(400px, 92vw);
            max-height: min(85vh, 900px);
            display: block;
            object-fit: contain;
        }

        #imageModal #modalCaption {
            width: auto;
            max-width: 100%;
            box-sizing: border-box;
            padding: 10px 12px 0;
        }

        /* Card Hover Modal Styles */
        .card-hover-modal {
            display: none;
            position: fixed;
            z-index: 2000;
            pointer-events: none;
            background: rgba(0, 0, 0, 0.8);
            border-radius: 8px;
            padding: 10px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(10px);
        }

        .card-hover-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
        }

        /* Tight wrapper around the image only — foil-shimmer is applied here
           so the shimmer is clipped to the image and never bleeds into the caption. */
        .card-hover-image-wrap {
            position: relative;
            display: inline-block;
            line-height: 0;
            border-radius: 6px;
            border: 2px solid rgba(78, 205, 196, 0.3);
        }

        .card-hover-image {
            max-width: 345px;
            max-height: 483px;
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 4px;
            display: block;
        }

        /* Landscape location/event art: default max-width was portrait-biased and squeezed wide cards */
        .card-hover-modal[data-card-type="location"] .card-hover-image,
        .card-hover-modal[data-card-type="event"] .card-hover-image {
            max-width: 480px;
            max-height: 483px;
        }

        /* Two-layer progressive load: full-res fades in over thumb; hide thumb when loaded to avoid edge bleed */
        .card-hover-image-wrap .card-hover-image-full {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: contain;
            object-position: center center;
            opacity: 0;
            transition: opacity 0.2s ease-out;
            z-index: 1;
        }
        .card-hover-image-wrap .card-hover-image-full.card-hover-image-full--loaded {
            opacity: 1;
        }
        .card-hover-image-wrap:has(.card-hover-image-full.card-hover-image-full--loaded) .card-hover-image:not(.card-hover-image-full) {
            visibility: hidden;
        }

        .card-hover-caption {
            color: #ffffff;
            font-size: 0.9rem;
            font-weight: 500;
            text-align: center;
            max-width: 280px;
            line-height: 1.3;
        }



        #modalCaption {
            margin: auto;
            display: block;
            width: 80%;
            max-width: 700px;
            text-align: center;
            color: #ccc;
            padding: 10px 0;
            font-size: 1.2rem;
        }

        /* Power Cards Filter Styles */
        .filter-bar {
            background: rgba(255, 255, 255, 0.05);
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 15px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            align-items: center;
        }

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

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

        .checkbox-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .checkbox-group label {
            display: flex;
            align-items: center;
            gap: 6px;
            cursor: pointer;
            color: rgba(255, 255, 255, 0.8);
            font-size: 0.85rem;
            font-weight: normal;
        }

        .checkbox-group input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: #4ecdc4;
            cursor: pointer;
        }

        /* Power Cards specific checkbox layout */
        .power-cards-checkbox-group {
            display: flex !important;
            flex-direction: row !important;
            gap: 20px !important;
            justify-content: center !important;
            align-items: flex-start !important;
        }

        .checkbox-column {
            display: flex !important;
            flex-direction: column !important;
            gap: 8px !important;
            min-width: 80px !important;
        }

        .range-inputs {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .range-inputs input[type="number"] {
            padding: 6px 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.85rem;
            text-align: center;
            transition: all 0.3s ease;
        }

        .range-inputs input[type="number"]:focus {
            outline: none;
            border-color: #4ecdc4;
            box-shadow: 0 0 6px rgba(78, 205, 196, 0.4);
            background: rgba(255, 255, 255, 0.15);
        }

        .range-inputs input[type="number"]::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }

        .range-inputs span {
            color: rgba(255, 255, 255, 0.6);
            font-weight: 500;
        }

        /* Center all table columns and filters for uniform appearance */
        /* Characters table */
        #characters-table th,
        #characters-table td {
            text-align: center;
        }
        /* Special cards table */
        #special-cards-table th,
        #special-cards-table td {
            text-align: center;
        }
        
        /* Advanced universe table */
        #advanced-universe-table th,
        #advanced-universe-table td {
            text-align: center;
        }
        
        /* Locations table */
        #locations-table th,
        #locations-table td {
            text-align: center;
        }
        
        /* Aspects table */
        #aspects-table th,
        #aspects-table td {
            text-align: center;
        }
        
        /* Missions table */
        #missions-table th,
        #missions-table td {
            text-align: center;
        }
        
        /* Events table */
        #events-table th,
        #events-table td {
            text-align: center;
        }

        /* Enable flexible column widths for all tables to accommodate text wrapping */
        #characters-table,
        #special-cards-table,
        #advanced-universe-table,
        #aspects-table,
        #teamwork-table,
        #ally-universe-table,
        #training-table,
        #power-cards-table {
            table-layout: auto;
        }

        /* 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,
        #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 {
            word-wrap: break-word;
            word-break: break-word;
            white-space: normal;
            vertical-align: top;
            padding: 8px 12px;
            line-height: 1.4;
        }

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

        /* Make sure tables can expand horizontally if needed */
        table {
            min-width: 100%;
        }
        
        /* Add to Collection button styling */
        .add-to-collection-btn {
            background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
            color: #1a1a2e;
            border: none;
            padding: 6px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 11px;
            font-weight: 600;
            transition: all 0.3s ease;
            min-width: 90px;
            box-sizing: border-box;
        }
        
        /* 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;
        }

        .add-to-collection-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(78, 205, 196, 0.4);
        }

        .add-to-collection-btn:active {
            transform: translateY(0);
        }

        /* Add to Deck button styling */
        .add-to-deck-btn {
            background: linear-gradient(135deg, #59CCBE, #4AB3A6);
            color: #2E3236;
            border: none;
            padding: 6px 18px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.3s ease;
            white-space: nowrap;
            min-width: 90px;
            box-sizing: border-box;
        }
        
        .add-to-deck-btn:hover {
            background: linear-gradient(135deg, #4AB3A6, #3A9B8E);
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }

        /* Prevent flash for guest users - buttons appear disabled by default */
        .add-to-deck-btn {
            transition: opacity 0.1s ease-in-out;
        }
        
        .add-to-deck-btn[data-guest-disabled="true"] {
            opacity: 0.5 !important;
            cursor: not-allowed !important;
        }
        
        .add-to-deck-btn:active {
            transform: translateY(0);
            box-shadow: 0 1px 2px rgba(0,0,0,0.2);
        }
        
        /* Teamwork table */
        #teamwork-table th,
        #teamwork-table td {
            text-align: center;
        }
        
        /* Ally universe table */
        #ally-universe-table th,
        #ally-universe-table td {
            text-align: center;
        }
        
        /* Training table */
        #training-table th,
        #training-table td {
            text-align: center;
        }
        
        /* Basic Universe table */
        #basic-universe-table th,
        #basic-universe-table td {
            text-align: center;
        }
        
        /* Power cards table */
        #power-cards-table th,
        #power-cards-table td {
            text-align: center;
        }
        
        /* Center all filter rows */
        .filter-row th {
            text-align: center;
        }
        
        /* Center all column filters */
        .column-filters {
            text-align: center;
        }
        
        /* Center all filter inputs */
        .filter-input {
            text-align: center;
        }
        
        /* Center all range inputs */
        .range-inputs {
            text-align: center;
        }
        
        /* Center all checkbox groups */
        .checkbox-group {
            text-align: center;
        }
        
        /* Center all filter groups */
        .filter-group {
            text-align: center;
        }

        /* Deck Builder Styles */

        .deck-list-container {
            padding: 20px 0;
        }

        .deck-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .deck-list {
            display: grid;
            gap: 20px;
        }

        .deck-card {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            padding: 20px;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            cursor: pointer;
            display: flex;
            flex-direction: row;
            align-items: stretch;
            justify-content: space-between;
            min-height: 140px;
            overflow: visible;
        }

        .deck-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
            border-color: rgba(78, 205, 196, 0.6);
            background: rgba(255, 255, 255, 0.15);
        }

        /* Special styling for "No decks yet" clickable tile */
        .deck-card[onclick="createNewDeck()"]:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 30px rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.8);
            background: rgba(78, 205, 196, 0.1);
        }

        .deck-card[onclick="createNewDeck()"]:hover h4 {
            color: #4ecdc4;
        }

        .deck-card[onclick="createNewDeck()"]:hover p {
            color: #ffffff;
        }

        .deck-header {
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            align-items: flex-start;
            flex: 1;
            padding: 24px 60px 24px 0;
            min-width: 0;
            height: 100%;
        }

        .deck-info {
            display: flex;
            flex-direction: column;
        }

        .deck-info h4 {
            margin: 0 0 8px 0;
            color: #4ecdc4;
            font-size: 1.8rem;
            font-weight: 700;
            word-wrap: break-word;
            overflow-wrap: break-word;
            line-height: 1.3;
        }

        .deck-meta {
            display: flex;
            gap: 20px;
            color: #bdc3c7;
            font-size: 0.8rem;
        }

        .deck-actions {
            display: flex;
            flex-direction: column;
            gap: 10px;
            flex: 0.5;
            justify-content: center;
            padding-left: 20px;
            min-width: 120px;
            height: 100%;
        }

        .deck-action-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: all 0.3s ease;
        }

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

        .deck-action-btn.danger {
            background: rgba(255, 107, 107, 0.2);
            border-color: rgba(255, 107, 107, 0.3);
            color: #ff6b6b;
        }

        .deck-action-btn.danger:hover {
            background: rgba(255, 107, 107, 0.3);
            border-color: rgba(255, 107, 107, 0.4);
        }

        .deck-action-btn:disabled {
            background: rgba(255, 255, 255, 0.05);
            border-color: rgba(255, 255, 255, 0.1);
            color: rgba(255, 255, 255, 0.3);
            cursor: not-allowed;
            opacity: 0.5;
        }

        .deck-action-btn.danger:disabled {
            background: rgba(255, 107, 107, 0.1);
            border-color: rgba(255, 107, 107, 0.2);
            color: rgba(255, 107, 107, 0.3);
        }

        /* Form Styles */
        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #ffffff;
            font-weight: 500;
        }

        .form-group input,
        .form-group textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            font-size: 14px;
        }

        .form-group textarea {
            height: 80px;
            resize: vertical;
        }

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

        .form-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }

        /* Create Deck Modal Styling */
        .create-deck-modal {
            max-width: 450px;
            width: 90%;
            padding: 25px 20px 30px 20px;
            box-sizing: border-box;
        }

        .modal-header {
            margin-bottom: 25px;
            text-align: center;
        }

        .modal-header h3 {
            margin: 0;
            color: #4ecdc4;
            font-size: 1.4rem;
            font-weight: 600;
        }

        .form-row {
            margin-bottom: 20px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-group label {
            color: #ffffff;
            margin-bottom: 8px;
            font-weight: 500;
            font-size: 0.95rem;
        }

        .form-group input,
        .form-group textarea,
        .character-dropdown {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            color: #ffffff;
            padding: 12px 14px;
            font-size: 0.95rem;
            transition: all 0.3s ease;
            width: 100%;
            box-sizing: border-box;
        }

        .form-group input:focus,
        .form-group textarea:focus,
        .character-dropdown:focus {
            outline: none;
            border-color: #4ecdc4;
            box-shadow: 0 0 6px rgba(78, 205, 196, 0.4);
        }

        .form-group input::placeholder,
        .form-group textarea::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }

        .form-group textarea {
            min-height: 70px;
            resize: vertical;
            margin-bottom: 0;
        }

        .character-selection {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .character-dropdown {
            width: 100%;
        }

        .selected-characters {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            min-height: 50px;
            padding: 10px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
        }

        .character-tag {
            display: inline-flex;
            align-items: center;
            background: rgba(78, 205, 196, 0.2);
            border: 1px solid rgba(78, 205, 196, 0.4);
            border-radius: 16px;
            padding: 4px 10px;
            color: #4ecdc4;
            font-size: 0.85rem;
            gap: 6px;
        }

        .character-tag .remove-btn {
            background: none;
            border: none;
            color: #ff6b6b;
            cursor: pointer;
            font-size: 1.1rem;
            padding: 0;
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.2s ease;
        }

        .character-tag .remove-btn:hover {
            background: rgba(255, 107, 107, 0.2);
            color: #ffffff;
        }

        .btn-primary {
            background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
            color: #1a1a2e;
            border: none;
            padding: 12px 24px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
        }

        .btn-secondary {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 12px 24px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
        }

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


        /* Draw Hand Section styles moved to /css/draw-hand.css */

        /* Screenshot View Section */
        .screenshot-view-section {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: #1a1a1a;
            z-index: 10000;
            display: flex;
            flex-direction: column;
        }


        .screenshot-view-close {
            position: absolute;
            top: 10px;
            right: 10px;
            background: #e74c3c;
            color: white;
            border: none;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1001;
        }

        .screenshot-view-close:hover {
            background: #c0392b;
        }

        .screenshot-view-content {
            flex: 1;
            padding: 20px;
            overflow: hidden;
            position: relative;
            /* Subtle grid over the existing background */
            background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        }
        /* Light grid overlay (10px cells with 50px bold lines) */
        .screenshot-view-content::before {
            content: '';
            position: absolute;
            inset: 0;
            pointer-events: none;
            background-image:
                linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
                linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
            background-size: 10px 10px, 10px 10px, 50px 50px, 50px 50px;
            background-position: 0 0, 0 0, 0 0, 0 0;
            z-index: 1;
        }

        .screenshot-cards-container {
            position: relative;
            width: 100%;
            height: 100%;
            min-height: 600px;
        }

        .screenshot-card-stack {
            position: absolute;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .screenshot-card-stack.horizontal {
            flex-direction: row;
        }

        .screenshot-card {
            position: relative;
            width: 100px;
            height: 150px;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
            transition: transform 0.2s ease;
            border: 2px solid rgba(255, 255, 255, 0.1);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }
        .screenshot-card.landscape {
            width: 150px;
            height: 100px;
        }

        .screenshot-card:hover {
            transform: scale(1.1) translateY(-5px);
            z-index: 100;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
        }
        .screenshot-card-quantity {
            position: absolute;
            top: 3px;
            right: 3px;
            background: rgba(0, 0, 0, 0.9);
            color: white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: bold;
            border: 1px solid rgba(255, 255, 255, 0.3);
        }

        .screenshot-card-stack-label {
            position: absolute;
            bottom: -25px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            color: #4ECDC4;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 10px;
            font-weight: bold;
            white-space: nowrap;
            z-index: 50;
        }

        /* Structured tabletop layout matching sample images */
        .screenshot-card-stack {
            position: absolute;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        .screenshot-card-stack.horizontal {
            flex-direction: row;
        }

        /* Characters - along left side with their specials overlapping next to them */
        .screenshot-card-stack.characters {
            top: 50px;
            left: 30px;
        }

        .screenshot-card-stack.characters .screenshot-card {
            margin-bottom: -25px;
            transform: rotate(-2deg);
        }

        .screenshot-card-stack.characters .screenshot-card:nth-child(2) {
            transform: rotate(1deg) translateX(5px);
        }

        .screenshot-card-stack.characters .screenshot-card:nth-child(3) {
            transform: rotate(-1deg) translateX(-3px);
        }

        .screenshot-card-stack.characters .screenshot-card:nth-child(4) {
            transform: rotate(2deg) translateX(8px);
        }

        /* Character specials - overlapping next to their character */
        .screenshot-card-stack.specials {
            top: 50px;
            left: 200px;
        }

        .screenshot-card-stack.specials .screenshot-card {
            margin-bottom: -30px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.specials .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateX(-5px);
        }

        .screenshot-card-stack.specials .screenshot-card:nth-child(3) {
            transform: rotate(2deg) translateX(3px);
        }

        .screenshot-card-stack.specials .screenshot-card:nth-child(4) {
            transform: rotate(-2deg) translateX(-8px);
        }

        .screenshot-card-stack.specials .screenshot-card:nth-child(5) {
            transform: rotate(1deg) translateX(10px);
        }

        /* Power cards - upper right, sorted by value in 2 rows */
        .screenshot-card-stack.power-cards {
            top: 50px;
            right: 30px;
        }

        .screenshot-card-stack.power-cards .screenshot-card {
            margin-right: -20px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateY(-8px);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(3) {
            transform: rotate(2deg) translateY(5px);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(4) {
            transform: rotate(-2deg) translateY(-12px);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(5) {
            transform: rotate(0.5deg) translateY(8px);
        }

        /* Second row of power cards */
        .screenshot-card-stack.power-cards .screenshot-card:nth-child(6) {
            position: absolute;
            top: 120px;
            right: 30px;
            transform: rotate(-1deg);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(7) {
            position: absolute;
            top: 120px;
            right: 50px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.power-cards .screenshot-card:nth-child(8) {
            position: absolute;
            top: 120px;
            right: 70px;
            transform: rotate(-0.5deg);
        }

        /* Teamwork - middle right */
        .screenshot-card-stack.teamwork {
            top: 200px;
            right: 30px;
        }

        .screenshot-card-stack.teamwork .screenshot-card {
            margin-bottom: -25px;
            transform: rotate(-1deg);
        }

        .screenshot-card-stack.teamwork .screenshot-card:nth-child(2) {
            transform: rotate(1deg) translateY(-6px);
        }

        .screenshot-card-stack.teamwork .screenshot-card:nth-child(3) {
            transform: rotate(-2deg) translateY(8px);
        }

        .screenshot-card-stack.teamwork .screenshot-card:nth-child(4) {
            transform: rotate(0.5deg) translateY(-10px);
        }

        /* Ally universe - middle right below teamwork */
        .screenshot-card-stack.ally-universe {
            top: 350px;
            right: 30px;
        }

        .screenshot-card-stack.ally-universe .screenshot-card {
            margin-bottom: -25px;
            transform: rotate(-1deg);
        }

        .screenshot-card-stack.ally-universe .screenshot-card:nth-child(2) {
            transform: rotate(1deg) translateY(-6px);
        }

        .screenshot-card-stack.ally-universe .screenshot-card:nth-child(3) {
            transform: rotate(-2deg) translateY(8px);
        }

        /* Any Character specials - along the bottom */
        .screenshot-card-stack.basic-universe {
            bottom: 30px;
            left: 50px;
        }

        .screenshot-card-stack.basic-universe .screenshot-card {
            margin-right: -20px;
            transform: rotate(0.5deg);
        }

        .screenshot-card-stack.basic-universe .screenshot-card:nth-child(2) {
            transform: rotate(-0.5deg) translateY(-6px);
        }

        .screenshot-card-stack.basic-universe .screenshot-card:nth-child(3) {
            transform: rotate(1deg) translateY(6px);
        }

        .screenshot-card-stack.basic-universe .screenshot-card:nth-child(4) {
            transform: rotate(-1deg) translateY(-10px);
        }

        .screenshot-card-stack.basic-universe .screenshot-card:nth-child(5) {
            transform: rotate(0.5deg) translateY(8px);
        }

        /* Aspect cards - tucked in with any character cards */
        .screenshot-card-stack.aspects {
            bottom: 30px;
            left: 300px;
        }

        .screenshot-card-stack.aspects .screenshot-card {
            margin-right: -20px;
            transform: rotate(-0.5deg);
        }

        .screenshot-card-stack.aspects .screenshot-card:nth-child(2) {
            transform: rotate(0.5deg) translateY(-6px);
        }

        .screenshot-card-stack.aspects .screenshot-card:nth-child(3) {
            transform: rotate(-1deg) translateY(6px);
        }

        /* Location - near a character in center */
        .screenshot-card-stack.locations {
            top: 250px;
            left: 400px;
        }

        .screenshot-card-stack.locations .screenshot-card {
            margin-bottom: -25px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.locations .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateX(6px);
        }

        .screenshot-card-stack.locations .screenshot-card:nth-child(3) {
            transform: rotate(2deg) translateX(-4px);
        }

        /* Missions - upper middle left */
        .screenshot-card-stack.missions {
            top: 100px;
            left: 150px;
        }

        .screenshot-card-stack.missions .screenshot-card {
            margin-bottom: -22px;
            transform: rotate(-2deg);
        }

        .screenshot-card-stack.missions .screenshot-card:nth-child(2) {
            transform: rotate(1deg) translateX(8px);
        }

        .screenshot-card-stack.missions .screenshot-card:nth-child(3) {
            transform: rotate(-1deg) translateX(-6px);
        }

        /* Events - upper middle right */
        .screenshot-card-stack.events {
            top: 100px;
            right: 200px;
        }

        .screenshot-card-stack.events .screenshot-card {
            margin-bottom: -22px;
            transform: rotate(2deg);
        }

        .screenshot-card-stack.events .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateX(-8px);
        }

        .screenshot-card-stack.events .screenshot-card:nth-child(3) {
            transform: rotate(1deg) translateX(6px);
        }

        /* Advanced universe - lower middle right */
        .screenshot-card-stack.advanced-universe {
            top: 450px;
            right: 150px;
        }

        .screenshot-card-stack.advanced-universe .screenshot-card {
            margin-bottom: -22px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.advanced-universe .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateX(-6px);
        }

        .screenshot-card-stack.advanced-universe .screenshot-card:nth-child(3) {
            transform: rotate(2deg) translateX(4px);
        }

        /* Training - middle right */
        .screenshot-card-stack.training {
            top: 300px;
            right: 150px;
        }

        .screenshot-card-stack.training .screenshot-card {
            margin-bottom: -22px;
            transform: rotate(1deg);
        }

        .screenshot-card-stack.training .screenshot-card:nth-child(2) {
            transform: rotate(-1deg) translateX(-7px);
        }

        .screenshot-card-stack.training .screenshot-card:nth-child(3) {
            transform: rotate(0.5deg) translateX(5px);
        }

        /* Blank screen styling */
        .screenshot-blank-screen {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #bdc3c7;
            font-size: 24px;
            font-weight: 300;
        }

        /* Character cards container - aligned along left side */
        .screenshot-characters-container {
            position: absolute;
            top: 55px;
            left: 30px;
            display: flex;
            flex-direction: column;
            gap: 0px;
            z-index: 10;
        }

        /* Individual character card group - contains character + specials */
        .screenshot-character-group {
            position: relative;
            margin-bottom: 25px;
            display: flex;
            align-items: flex-start;
            width: 100%;
            min-height: 200px; /* Ensure enough height for special cards */
        }

        /* Individual character card - rotated 90 degrees counter-clockwise */
        .screenshot-character-card {
            width: 200px;
            height: 140px;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            border: 2px solid #2c3e50;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            transform: rotate(-90deg);
            position: relative;
            transition: transform 0.2s ease;
            flex-shrink: 0;
            z-index: 1;
        }

        /* Special cards container - horizontal stack next to character */
        .screenshot-specials-container {
            position: absolute;
            left: 190px; /* Position a bit more to the right */
            top: -30px; /* Move up a bit more to align with character card */
            display: flex;
            flex-direction: row;
            z-index: 10;
        }

        /* Individual special card - overlapping stack */
        .screenshot-special-card {
            width: 140px;
            height: 200px;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            border: 2px solid #2c3e50;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            position: relative;
            transition: transform 0.2s ease;
            margin-right: -112px; /* Overlap by 80% (20% visible) - each card overlaps the right side of the next */
            z-index: 1;
        }

        .screenshot-special-card:last-child {
            margin-right: 0; /* Last card has no right margin */
        }
        
        .screenshot-location-container {
            position: absolute;
            left: 500px; /* Position to the right of specials */
            top: 0;
            z-index: 5;
        }
        
        .screenshot-location-card {
            width: 200px;
            height: 140px;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            transform: rotate(-90deg);
        }
        
        .screenshot-draggable-container {
            position: relative;
            width: 100%;
            height: 100%;
            min-height: 600px;
            touch-action: none;
        }
        
        .screenshot-draggable-card {
            position: absolute;
            width: 140px;  /* Rotated dimensions: height becomes width */
            height: 200px; /* Rotated dimensions: width becomes height */
            border-radius: 8px;
            border: 2px solid transparent; /* Clean border for grid snapping */
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
            cursor: move;
            /* No rotation on the container - only the inner image */
            transition: box-shadow 0.2s ease;
            z-index: 10;
            user-select: none;
            -webkit-user-drag: none;
        }
        
        .screenshot-card-image {
            width: 200px;  /* Original card width */
            height: 140px; /* Original card height */
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            transform: rotate(-90deg);
            transform-origin: center center;
            /* Position the rotated image to fit within the container */
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -70px;  /* Half of 140px height */
            margin-left: -100px; /* Half of 200px width */
        }
        
        .screenshot-draggable-card:hover {
            /* No magnification in screenshot view to prevent alignment issues */
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
            z-index: 100;
        }
        
        .screenshot-draggable-card.dragging {
            /* No scaling during drag to maintain alignment */
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
            z-index: 1000;
            opacity: 0.9;
        }
        
        .screenshot-draggable-card.selected {
            outline: 3px solid rgba(52, 152, 219, 0.9);
            outline-offset: 2px;
            box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.25), 0 8px 20px rgba(0,0,0,0.5);
        }
        
        .screenshot-selection-rect {
            position: absolute;
            border: 2px dashed rgba(255, 255, 255, 0.6);
            background: rgba(255, 255, 255, 0.15);
            pointer-events: none;
            z-index: 2000;
        }
        
        .screenshot-blank-screen {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            color: #bdc3c7;
            font-size: 18px;
        }

        .screenshot-special-card:hover {
            transform: scale(1.05);
            z-index: 1001;
        }

        .screenshot-character-card:hover {
            transform: rotate(-90deg) scale(1.05);
            z-index: 1001;
        }

        /* Quantity badge for multiple cards */
        .screenshot-character-card .screenshot-card-quantity {
            position: absolute;
            top: 5px;
            right: 5px;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            border-radius: 50%;
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: bold;
            z-index: 10;
        }

        .drawn-card.drag-target {
            transition: all 0.2s ease;
            transform: scale(0.95);
            opacity: 0.7;
        }

        .drawn-card.drag-target:hover {
            transform: scale(1.0);
            opacity: 0.9;
        }

        /* Draw Hand drag-over style moved to /css/draw-hand.css */

        /* Large Modal Styles - for general use */
        .large-modal {
            max-width: 90vw;
            max-height: 90vh;
            width: 90vw;
            height: 90vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Deck Editor Modal - specific styling for deck editor only */
        .deck-editor-modal {
            max-width: 96vw;
            max-height: 94vh;
            width: 96vw;
            height: 94vh;
            margin: 20px auto 10px auto;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Deck Editor Specific Body Padding Override */
        body.deck-editor-active {
            padding: 8px;
        }

        .modal-header {
            display: flex;
            flex-direction: column;
            padding: 20px 20px 5px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            margin-bottom: 4px;
            gap: 15px;
        }
        
        .deck-editor-top-row {
            display: flex;
            align-items: stretch;
            width: 100%;
            margin-bottom: 10px;
            position: relative;
            gap: 20px;
            min-height: 64px;
            height: auto;
        }

        /* DTV: tighter deck editor header vertical rhythm (other modals keep global .modal-header) */
        #deckEditorModal .modal-header {
            padding: 8px 16px 2px 16px;
            gap: 6px;
            margin-bottom: 3px;
        }

        /* Do not stretch title column to stats height (avoids dead space above/below title+meta) */
        #deckEditorModal .deck-editor-top-row {
            align-items: center;
            margin-bottom: 2px;
            min-height: 0;
        }

        #deckEditorModal .deck-editor-title-section {
            padding: 4px 0 4px 5px;
            justify-content: flex-start;
        }

        #deckEditorModal .deck-title-with-validation {
            gap: 4px;
        }

        #deckEditorModal .deck-stats-divider {
            height: 28px;
            min-height: 28px;
        }

        #deckEditorModal .deck-editor-top-row .deck-summary-stats {
            gap: 6px 10px;
        }

        #deckEditorModal .deck-editor-top-row .deck-summary-stats > .summary-stat {
            min-height: 0;
            gap: 2px;
            justify-content: center;
        }

        /* Title + desktop summary cluster (hamburger stays a sibling for MV collapse banner) */
        #deckEditorModal .dev-mobile-deck-header-expandable {
            display: flex;
            flex: 1 1 auto;
            min-width: 0;
            gap: 20px;
            align-items: stretch;
        }

        /* DTV: shrink header — no stretch-to-stats, title+meta one band; stats stay label-over-value with larger type */
        html.layout-desktop #deckEditorModal .modal-header {
            padding: 2px 12px 0 12px;
            gap: 0;
            margin-bottom: 0;
        }

        html.layout-desktop #deckEditorModal .deck-editor-top-row {
            margin-bottom: 0;
            gap: 12px;
        }

        html.layout-desktop #deckEditorModal .dev-mobile-deck-header-expandable {
            align-items: center;
            gap: 8px;
        }

        html.layout-desktop #deckEditorModal .deck-editor-title-section {
            padding: 0 0 0 5px;
            gap: 2px;
            margin-right: 0;
        }

        html.layout-desktop #deckEditorModal .deck-title-with-validation {
            flex-direction: row;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px 12px;
        }

        html.layout-desktop #deckEditorModal .deck-title-with-validation .deck-editor-deck-name.editable-title {
            flex: 1 1 auto;
            min-width: min(160px, 32vw);
            padding: 2px 6px;
        }

        html.layout-desktop #deckEditorModal .deck-editor-title-meta-row {
            flex-shrink: 0;
        }

        html.layout-desktop #deckEditorModal #deckEditorDescription.deck-description {
            margin: 0;
            padding: 0;
            line-height: 1.35;
            width: 100%;
            flex-basis: 100%;
        }

        html.layout-desktop #deckEditorModal #deckEditorDescription.deck-description:empty {
            display: none;
        }

        html.layout-desktop #deckEditorModal .deck-editor-top-row .deck-summary-stats > .summary-stat {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            min-height: 48px;
            height: auto;
        }

        html.layout-desktop #deckEditorModal .deck-summary-stats {
            align-items: center;
            justify-content: flex-start;
        }

        /* Stats hug the title: drop flex-grow so the strip isn’t a wide column with numbers stuck at its left edge */
        html.layout-desktop #deckEditorModal .deck-editor-top-row .deck-summary-section {
            flex: 0 0 auto;
            width: auto;
            min-width: 0;
            justify-content: flex-start;
        }

        html.layout-desktop #deckEditorModal .deck-editor-top-row .deck-summary-content {
            justify-content: flex-start;
            gap: 12px;
        }

        html.layout-desktop #deckEditorModal .deck-stats-divider {
            height: 40px;
            min-height: 40px;
            align-self: center;
        }

        html.layout-desktop #deckEditorModal .deck-editor-menu-toggle {
            width: 40px;
            min-width: 40px;
            height: 40px;
            min-height: 40px;
            max-height: 40px;
        }

        .modal-header .deck-editor-title-section {
            flex: 0 1 auto;
            margin-right: 20px;
            min-width: 0; /* allow flex shrink so meta row overflow-x works; avoid modal clipping */
            max-width: min(520px, 46vw);
        }

        .modal-header .deck-summary-section {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .modal-header .deck-editor-actions {
            flex: 0 0 auto;
            margin-left: auto;
        }

        /* Right-side controls cluster (utility + actions with divider) */
        .modal-header .deck-editor-right-controls {
            flex: 0 0 auto;
            margin-left: auto;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        /* Prevent the inner actions container from re-applying auto-margin inside the cluster */
        .modal-header .deck-editor-right-controls .deck-editor-actions {
            margin-left: 0;
        }

        /* Deck editor header: single hamburger opens all utility + file actions */
        .deck-editor-controls-menu {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            align-self: center;
            height: auto;
        }

        .deck-editor-menu-toggle {
            position: relative;
            z-index: 10051;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            min-width: 48px;
            height: 48px;
            min-height: 48px;
            max-height: 48px;
            flex-shrink: 0;
            padding: 0;
            margin: 0;
            border-radius: 8px;
            border: 1px solid rgba(78, 205, 196, 0.45);
            background: rgba(78, 205, 196, 0.12);
            color: #4ecdc4;
            cursor: pointer;
            transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
            box-sizing: border-box;
        }

        .deck-editor-menu-toggle:hover {
            background: rgba(78, 205, 196, 0.22);
            border-color: rgba(78, 205, 196, 0.65);
            box-shadow: 0 0 12px rgba(78, 205, 196, 0.2);
        }

        .deck-editor-menu-toggle:focus-visible {
            outline: 2px solid #4ecdc4;
            outline-offset: 2px;
        }

        .deck-editor-controls-menu-open .deck-editor-menu-toggle {
            background: rgba(78, 205, 196, 0.28);
            border-color: rgba(78, 205, 196, 0.75);
        }

        .deck-editor-menu-toggle-bars {
            display: block;
            width: 20px;
            height: 14px;
            background: linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
                linear-gradient(currentColor, currentColor) 0 6px / 100% 2px no-repeat,
                linear-gradient(currentColor, currentColor) 0 12px / 100% 2px no-repeat;
            opacity: 0.95;
        }

        .deck-editor-controls-menu-open {
            z-index: 10050;
        }

        .deck-editor-menu-backdrop {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 10049;
            background: rgba(0, 0, 0, 0.5);
            border: none;
            padding: 0;
            margin: 0;
        }

        .deck-editor-controls-menu-open .deck-editor-menu-backdrop {
            display: block;
        }

        /* [hidden] must win: a plain `display: flex` on the panel overrides the UA hidden rule */
        .deck-editor-controls-menu-panel[hidden] {
            display: none !important;
        }

        .deck-editor-menu-backdrop[hidden] {
            display: none !important;
        }

        .deck-editor-controls-menu-panel {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            z-index: 10051;
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-width: min(198px, calc(100vw - 48px));
            max-width: calc(100vw - 24px);
            max-height: min(70vh, 520px);
            overflow-y: auto;
            padding: 14px;
            box-sizing: border-box;
            background: linear-gradient(160deg, rgba(22, 22, 38, 0.98) 0%, rgba(18, 24, 42, 0.98) 100%);
            border: 1px solid rgba(78, 205, 196, 0.4);
            border-radius: 10px;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(78, 205, 196, 0.12);
        }

        .deck-editor-controls-menu-panel .deck-editor-utility-actions {
            display: flex !important;
            flex-direction: column;
            gap: 8px;
            grid-template-columns: unset !important;
            grid-auto-rows: unset !important;
        }

        .deck-editor-controls-menu-panel .deck-editor-utility-actions > .remove-all-btn {
            width: 100%;
            max-width: none;
            grid-column: auto !important;
            grid-row: auto !important;
        }

        .deck-editor-controls-menu-panel .deck-editor-actions {
            display: flex !important;
            flex-direction: column;
            gap: 8px;
            grid-template-columns: unset !important;
            grid-template-rows: unset !important;
            /* Full width like utility rows — header rule uses max-width: 200px */
            max-width: none !important;
            width: 100% !important;
            align-self: stretch !important;
            padding-right: 0 !important;
            justify-self: unset !important;
        }

        .deck-editor-controls-menu-panel .deck-editor-actions > * {
            width: 100% !important;
            grid-column: auto !important;
            grid-row: auto !important;
        }

        /* Row layout: label left, uniform 22px icons flush right (beats .cancel-btn display:block !important) */
        #deckEditorModal .deck-editor-controls-menu-panel .deck-editor-menu-panel-btn[hidden] {
            display: none !important;
        }

        #deckEditorModal .deck-editor-controls-menu-panel .deck-editor-menu-panel-btn {
            display: flex !important;
            flex-direction: row !important;
            align-items: center !important;
            justify-content: flex-start !important;
            gap: 10px !important;
            width: 100% !important;
            box-sizing: border-box !important;
            min-height: 44px !important;
            height: auto !important;
            padding: 8px 12px !important;
            text-align: left !important;
        }

        #deckEditorModal .deck-editor-controls-menu-panel .deck-editor-menu-item-label {
            flex: 1 1 auto;
            min-width: 0;
            text-align: left;
        }

        #deckEditorModal .deck-editor-controls-menu-panel .deck-editor-menu-item-icon {
            flex: 0 0 22px;
            width: 22px;
            height: 22px;
            display: flex !important;
            align-items: center;
            justify-content: center;
            margin-left: auto;
        }

        #deckEditorModal .deck-editor-controls-menu-panel .deck-editor-menu-item-icon svg {
            width: 22px;
            height: 22px;
            display: block;
            flex-shrink: 0;
        }

        .deck-editor-controls-menu-panel .deck-editor-controls-menu-divider {
            width: 100%;
            height: 2px;
            min-width: 0;
            min-height: 2px;
            background: linear-gradient(to right,
                transparent 0px,
                rgba(78, 205, 196, 0.12) 8px,
                rgba(78, 205, 196, 0.35) 50%,
                rgba(78, 205, 196, 0.12) calc(100% - 8px),
                transparent 100%);
        }

        @media (max-width: 480px) {
            /* Fixed placement: absolute + % left was relative to the narrow menu shell (wrong).
               `left` / `top` set in deck-editor-core.js when menu opens. Exclude card-row ⋯ flyout. */
            #deckEditorModal .deck-editor-controls-menu.deck-editor-controls-menu-open > .deck-editor-controls-menu-panel:not(.dev-mobile-deck-row-menu-panel) {
                position: fixed !important;
                right: auto !important;
                transform: none !important;
                width: min(280px, calc(100vw - 32px)) !important;
                max-width: calc(100vw - 32px) !important;
                min-width: 0 !important;
                box-sizing: border-box;
                z-index: 10051;
            }
        }

        .deck-editor-utility-actions {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
            grid-auto-rows: 24px;
            gap: 8px 10px;
            align-items: stretch;
            align-content: start;
            justify-items: stretch;
        }

        .deck-editor-utility-actions .remove-all-btn {
            height: 24px;
            min-height: 24px;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
            white-space: nowrap;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
            box-sizing: border-box;
            min-width: 0;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Utility button ordering (stable 2x2 grid) */
        .deck-editor-utility-actions #backgroundBtn {
            grid-column: 1;
            grid-row: 1;
        }

        .deck-editor-utility-actions #previewBtn {
            grid-column: 2;
            grid-row: 1;
        }

        .deck-editor-utility-actions #drawHandBtn {
            grid-column: 1;
            grid-row: 2;
        }

        .deck-editor-utility-actions #listViewBtn {
            grid-column: 2;
            grid-row: 2;
        }

        /* If enabled, place Screenshot View below the 2x2 grid */
        .deck-editor-utility-actions #screenshotViewBtn {
            grid-column: 1 / -1;
            grid-row: 3;
        }

        /* Preview button states */
        #previewBtn.preview-active {
            background: rgba(78, 205, 196, 0.3) !important;
            border-color: rgba(78, 205, 196, 0.4) !important;
        }

        #previewBtn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Vertical divider between utility and action button clusters */
        .deck-editor-controls-divider {
            width: 2px;
            min-width: 2px;
            height: 44px;
            background: linear-gradient(to bottom,
                transparent 0px,
                rgba(78, 205, 196, 0.08) 2px,
                rgba(78, 205, 196, 0.24) 6px,
                rgba(78, 205, 196, 0.4) 50%,
                rgba(78, 205, 196, 0.24) calc(100% - 6px),
                rgba(78, 205, 196, 0.08) calc(100% - 2px),
                transparent 100%);
            opacity: 0.95;
            flex-shrink: 0;
        }

        /* Prevent action grid from stretching vertically when Draw Hand UI is open */
        .deck-editor-right-controls .deck-editor-actions {
            grid-template-rows: auto auto !important;
            align-content: start;
        }
        
        .modal-header h3 {
            margin: 0;
            color: #4ecdc4;
            font-size: 1.5rem;
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .deck-editor-title-section {
            display: flex;
            flex-direction: column;
            gap: 4px;
            text-align: left;
            padding: 12px 0 12px 5px;
            justify-self: start;
            justify-content: center;
            max-width: min(520px, 46vw);
            min-width: 0;
            width: auto;
            flex: 0 1 auto;
        }

        .deck-title-with-validation {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
            flex-shrink: 0;
            margin-top: 0;
            width: 100%;
            min-width: 0;
            max-width: 100%;
        }

        .deck-title-with-validation h3 {
            margin: 0;
            line-height: 1.3;
        }

        /* Deck name line: 2× legibility-badge / meta row font (badge uses 0.8rem) */
        #deckEditorModal .deck-title-with-validation .deck-editor-deck-name.editable-title {
            font-size: 1.6rem;
            font-weight: 600;
            line-height: 1.2;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        #deckEditorModal .deck-editor-title-meta-row {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: center;
            gap: 8px 12px;
            font-size: 0.8rem;
            line-height: 1.2;
            color: rgba(255, 255, 255, 0.88);
            width: 100%;
            min-width: 0;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
        }

        #deckEditorModal .deck-editor-title-meta-row .deck-title-badges {
            flex-wrap: nowrap;
            flex-shrink: 0;
        }

        #deckEditorModal .deck-editor-title-meta-row .deck-validation-badge {
            margin-left: 0;
        }

        #deckEditorModal .deck-editor-header-cards-group {
            display: inline-flex;
            flex-direction: row;
            align-items: center;
            gap: 6px;
            white-space: nowrap;
            flex-shrink: 0;
        }

        #deckEditorModal .deck-editor-header-cards-icon {
            display: none;
            width: calc(18px * 1.3 * 1.15);
            height: calc(18px * 1.3 * 1.15);
            flex-shrink: 0;
            object-fit: contain;
            filter: brightness(0.95);
        }

        #deckEditorModal .deck-editor-header-cards-label-text {
            font-weight: 600;
            color: rgba(255, 255, 255, 0.62);
            text-transform: uppercase;
            letter-spacing: 0.04em;
            font-size: 0.8rem;
        }

        #deckEditorModal .deck-editor-header-cards-value,
        #deckEditorModal .deck-editor-header-cards-min {
            font-weight: 700;
            font-family: 'Courier New', monospace;
            color: #4ecdc4;
            font-size: 0.85rem;
        }

        #deckEditorModal .deck-editor-header-cards-min {
            color: rgba(255, 217, 61, 0.95);
        }

        #deckEditorModal .deck-editor-header-threat-group {
            display: inline-flex;
            flex-direction: row;
            align-items: center;
            gap: 6px;
            margin-left: 4px;
            white-space: nowrap;
            flex-shrink: 0;
        }

        #deckEditorModal .deck-editor-header-threat-icon {
            display: block;
            width: 18px;
            height: 18px;
            object-fit: contain;
            filter: brightness(0.95);
        }

        #deckEditorModal .deck-editor-header-threat-value {
            font-weight: 700;
            font-family: 'Courier New', monospace;
            color: #4ecdc4;
            font-size: 0.85rem;
            flex-shrink: 0;
            min-width: min-content;
        }

        .deck-title-badges {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            flex-wrap: nowrap;
            width: auto;
        }
        

        /* Inline editing styles */
        .editable-title {
            cursor: pointer;
            transition: all 0.2s ease;
            padding: 4px 8px;
            border-radius: 4px;
            border: 2px solid transparent;
            background: transparent;
        }

        .editable-title:hover {
            background: rgba(255, 255, 255, 0.05);
            border-color: rgba(78, 205, 196, 0.3);
        }

        .editable-title.editing {
            background: rgba(255, 255, 255, 0.1);
            border-color: #4ecdc4;
            cursor: text;
        }



        .edit-input {
            background: transparent;
            border: none;
            outline: none;
            color: inherit;
            font: inherit;
            width: 100%;
            padding: 0;
            margin: 0;
        }

        .edit-input::placeholder {
            color: #7f8c8d;
            font-style: italic;
        }

        /* Deck Summary Section */
        .deck-summary-section {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            padding: 10px 20px;
            margin-bottom: 0;
        }
        
        .deck-editor-top-row .deck-summary-section {
            background: transparent;
            border: none;
            padding: 0;
            height: auto;
            min-height: 0;
            max-height: none;
            display: flex;
            align-items: center;
            justify-content: center;
            flex: 1;
        }

        .deck-summary-content {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 20px;
            height: 100%;
            width: 100%;
        }

        .deck-editor-top-row .deck-summary-content {
            flex-wrap: wrap;
            height: auto;
            min-height: 0;
        }

        /* Deck stats divider - styled like resizable divider but scaled down and without handles */
        .deck-stats-divider {
            width: 2px;
            min-width: 2px;
            background: linear-gradient(to bottom, 
                transparent 0px,
                rgba(78, 205, 196, 0.08) 2px,
                rgba(78, 205, 196, 0.24) 6px,
                rgba(78, 205, 196, 0.4) 50%,
                rgba(78, 205, 196, 0.24) calc(100% - 6px),
                rgba(78, 205, 196, 0.08) calc(100% - 2px),
                transparent 100%);
            position: relative;
            flex-shrink: 0;
            margin: 0 8px;
            height: 40px;
            min-height: 40px;
            align-self: center;
            display: block;
            flex-grow: 0;
        }

        .deck-summary-stats {
            display: flex;
            gap: 15px;
            align-items: center;
            height: 60px;
            min-height: 60px;
            max-height: 60px;
        }

        .deck-editor-top-row .deck-summary-stats {
            height: auto;
            min-height: 0;
            max-height: none;
            flex-wrap: wrap;
            justify-content: center;
        }


        .summary-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            height: 60px;
            min-height: 60px;
            max-height: 60px;
            justify-content: center;
        }

        .deck-editor-top-row .deck-summary-stats > .summary-stat {
            height: auto;
            min-height: 48px;
            max-height: none;
        }

        /* Buttons in summary-stat should be stacked vertically by default */
        .summary-stat:has(button) {
            flex-direction: column;
            gap: 6px;
            height: 60px;
            min-height: 60px;
            max-height: 60px;
            justify-content: center;
        }
        
        /* Grid layout only when Background button exists (ADMIN role) */
        .summary-stat:has(#backgroundBtn) {
            display: grid;
            grid-template-columns: 1fr 1fr;
            grid-template-rows: 1fr 1fr;
            gap: 6px;
            height: 60px;
            min-height: 60px;
            max-height: 60px;
        }
        
        /* Position buttons in grid (only applies when Background button exists) */
        .summary-stat:has(#backgroundBtn) #listViewBtn {
            grid-column: 2;
            grid-row: 1;
        }
        
        .summary-stat:has(#backgroundBtn) #drawHandBtn {
            grid-column: 1;
            grid-row: 2;
        }
        
        .summary-stat:has(#backgroundBtn) #backgroundBtn {
            grid-column: 2;
            grid-row: 2;
        }
        
        .summary-stat:has(#backgroundBtn) #screenshotViewBtn {
            grid-column: 1;
            grid-row: 1;
        }

        /* Deck summary stats - more specific selector to override other stat-label rules */
        .deck-summary-stats .stat-label,
        .summary-stat .stat-label {
            font-size: 0.65rem !important;
            color: #888 !important;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 4px;
            line-height: 1.2;
        }

        /* Deck summary stats - use more specific selector */
        .deck-summary-stats .summary-stat .stat-label,
        .summary-stat .stat-label {
            font-size: 0.65rem !important;
            color: #888 !important;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 4px;
            line-height: 1.2;
        }

        .stat-label {
            font-size: 0.65rem;
            color: #888;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 4px;
            line-height: 1.2;
        }

        .stat-icon {
            width: 16px;
            height: 16px;
            object-fit: contain;
            filter: brightness(0.7);
        }

        .stat-icon-small {
            width: 16px;
            height: 16px;
            object-fit: contain;
            filter: brightness(0.7);
            margin-right: 4px;
            vertical-align: middle;
        }

        /* Deck summary stats - use more specific selector */
        .deck-summary-stats .summary-stat .stat-value,
        .summary-stat .stat-value {
            font-size: 0.85rem !important;
            color: #4ecdc4 !important;
            font-weight: 700;
            font-family: 'Courier New', monospace;
            line-height: 1.2;
        }

        /* Deck summary stats - more specific selector to override other stat-value rules */
        .deck-summary-stats .stat-value,
        .summary-stat .stat-value {
            font-size: 0.85rem !important;
            color: #4ecdc4 !important;
            font-weight: 700;
            font-family: 'Courier New', monospace;
            line-height: 1.2;
        }

        .stat-value {
            font-size: 0.85rem;
            color: #4ecdc4;
            font-weight: 700;
            font-family: 'Courier New', monospace;
            line-height: 1.2;
        }

        .deck-summary-validation {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 60px;
            min-height: 60px;
            max-height: 60px;
        }

        .deck-editor-top-row .deck-summary-validation {
            height: auto;
            min-height: 0;
            max-height: none;
            flex: 0 0 auto;
        }

        .deck-summary-validation .validation-errors-compact,
        .deck-summary-validation .validation-warnings-compact,
        .deck-summary-validation .validation-success-compact {
            font-size: 0.9rem;
            padding: 8px 16px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.1);
        }

        .close-btn {
            background: none;
            border: none;
            color: #ffffff;
            font-size: 24px;
            cursor: pointer;
            padding: 0;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.3s ease;
        }

        .close-btn:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .modal-body {
            overflow: hidden;
            flex: 1;
            padding: 0 2px 20px 2px;
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        /* Deck Info Section */
        .deck-info-section {
            margin-bottom: 30px;
        }

        .deck-metadata {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
        }
        .metadata-item {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        .metadata-item label {
            font-weight: 600;
            color: #4ecdc4;
            font-size: 0.9rem;
        }

        .metadata-item span {
            color: #ffffff;
            font-size: 1rem;
        }

        /* Deck Cards Section */
        .deck-cards-section {
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            padding-top: 20px;
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

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

        .add-cards-btn {
            background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
            color: #1a1a2e;
            border: none;
            padding: 10px 20px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .add-cards-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
        }

        .deck-cards-list {
            display: grid;
            gap: 15px;
        }

        .deck-card-item {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            padding: 15px;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .deck-card-image {
            width: 60px;
            height: 45px;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            border-radius: 8px;
            border: 1px solid rgba(78, 205, 196, 0.3);
            flex-shrink: 0;
        }

        .deck-card-info {
            flex: 1;
        }

        .deck-card-name {
            font-weight: 600;
            color: #ffffff;
            margin-bottom: 5px;
        }

        .deck-card-type {
            color: #bdc3c7;
            font-size: 0.8rem;
            text-transform: capitalize;
        }

        .deck-card-quantity {
            color: #4ecdc4;
            font-weight: 600;
        }

        .deck-card-actions {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .quantity-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .quantity-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
        }

        .quantity-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .quantity-btn.danger {
            background: rgba(255, 107, 107, 0.2);
            border-color: rgba(255, 107, 107, 0.3);
            color: #ff6b6b;
        }

        .quantity-btn.danger:hover {
            background: rgba(255, 107, 107, 0.3);
        }

        /* KO Button Styling - Similar to quantity-btn but red, inverted when active */
        .ko-btn {
            background: rgba(255, 107, 107, 0.2);
            color: #ff6b6b;
            border: 1px solid rgba(255, 107, 107, 0.3);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
        }

        .ko-btn:hover {
            background: rgba(255, 107, 107, 0.3);
            border-color: rgba(255, 107, 107, 0.4);
        }

        /* Inverted color scheme when character is KO'd */
        .ko-btn.active {
            background: #ff6b6b;
            color: rgba(26, 26, 46, 0.9);
            border-color: #ff6b6b;
        }

        .ko-btn.active:hover {
            background: #ff5252;
            border-color: #ff5252;
        }

        /* Dimmed state for KO'd characters and unusable cards */
        .deck-card-editor-item.ko-dimmed,
        .deck-card-card-view-item.ko-dimmed,
        .deck-list-item.ko-dimmed,
        .drawn-card.ko-dimmed {
            opacity: 0.375 !important; /* 25% more dimmed (was 0.5, now 0.375) */
            filter: grayscale(0.4);
        }

        .deck-card-editor-item.ko-dimmed:hover,
        .deck-card-card-view-item.ko-dimmed:hover,
        .deck-list-item.ko-dimmed:hover,
        .drawn-card.ko-dimmed:hover {
            opacity: 0.375 !important;
        }

        .deck-card-editor-reserve {
            position: absolute;
            top: 8px;
            right: 8px;
        }

        .reserve-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
            flex-shrink: 0;
            min-width: 52px;
            white-space: nowrap;
        }

        .reserve-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        /* Selected: darkened grey with pressed-in inset shadow — clearly distinct from unselected */
        .reserve-btn.active {
            background: rgba(100, 100, 100, 0.6);
            color: #ffffff;
            border-color: rgba(130, 130, 130, 0.65);
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
        }

        .reserve-btn.active:hover {
            background: rgba(120, 120, 120, 0.65);
            border-color: rgba(150, 150, 150, 0.7);
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
        }

        /* Reserve button in read-only mode (disabled but should still look selected) */
        .reserve-btn:disabled {
            cursor: not-allowed;
            opacity: 0.85;
        }

        .reserve-btn:disabled:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .reserve-btn.active:disabled,
        .reserve-btn.active:disabled:hover {
            background: rgba(100, 100, 100, 0.6);
            border-color: rgba(130, 130, 130, 0.65);
            color: #ffffff;
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
            opacity: 0.95;
        }

        /* Read-only reserve indicator styling - matches reserve-btn.active (darkened, pressed-in) */
        .reserve-indicator {
            background: rgba(100, 100, 100, 0.6);
            color: #ffffff;
            border: 1px solid rgba(130, 130, 130, 0.65);
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            font-size: 10px;
            font-weight: 500;
            text-align: center;
            cursor: default;
            display: none; /* Hidden by default, shown only in read-only mode for selected reserve */
        }

        /* Reserve button styling for list view */
        .deck-list-item .reserve-btn {
            font-size: 10px;
            padding: 2px 6px;
            margin-right: 8px;
        }

        /* Read-only reserve indicator styling for list view */
        .deck-list-item .reserve-indicator {
            font-size: 10px;
            padding: 2px 6px;
            margin-right: 8px;
        }

        /* Card Search Section */
        .card-search-section {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .search-controls {
            display: flex;
            gap: 15px;
            align-items: center;
        }

        .card-type-select {
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            font-size: 14px;
            min-width: 150px;
        }

        .card-type-select:focus {
            outline: none;
            border-color: #4ecdc4;
        }

        .card-search-input {
            flex: 1;
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            font-size: 14px;
        }

        .card-search-input:focus {
            outline: none;
            border-color: #4ecdc4;
        }

        .card-results {
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.05);
        }

        .card-result-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 15px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: background 0.3s ease;
        }

        .card-result-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .card-result-item:last-child {
            border-bottom: none;
        }

        .card-result-info {
            flex: 1;
        }

        .card-result-name {
            font-weight: 600;
            color: #ffffff;
            margin-bottom: 5px;
        }

        .card-result-type {
            color: #bdc3c7;
            font-size: 0.8rem;
            text-transform: capitalize;
        }

        .add-card-btn {
            background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
            color: #1a1a2e;
            border: none;
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .add-card-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
        }

        .add-card-btn:disabled {
            background: rgba(255, 255, 255, 0.2);
            color: rgba(255, 255, 255, 0.5);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        /* Deck Editor Styles */
        .deck-editor-actions {
            display: flex;
            flex-direction: column;
            gap: 8px;
            justify-self: end;
            padding-right: 20px;
            max-width: 200px;
        }

        /* Deck Editor Search Bar */
        .deck-editor-search-container {
            position: relative;
            width: 100%;
            justify-self: center;
            margin: 0 auto;
            flex-shrink: 0;
            box-sizing: border-box;
        }

        .deck-editor-search-input {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 25px;
            background: rgba(255, 255, 255, 0.1);
            color: white;
            font-size: 14px;
            outline: none;
            transition: all 0.3s ease;
            box-sizing: border-box;
            max-width: 100%;
        }

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

        .deck-editor-search-input:focus {
            background: rgba(255, 255, 255, 0.2);
            box-shadow: none !important;
            outline: none !important;
            border-bottom: none !important;
        }



        .deck-editor-search-results {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: rgba(20, 20, 20, 0.95);
            border: none;
            border-radius: 8px;
            max-height: 300px;
            overflow-y: auto;
            z-index: 1000;
            margin-top: 5px;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        }

        /* Scrollbar styling for WebKit browsers */
        .deck-editor-search-results::-webkit-scrollbar {
            width: 12px; /* Make scrollbar wider */
        }

        .deck-editor-search-results::-webkit-scrollbar-track {
            background: rgba(30, 30, 30, 0.8); /* Darker track */
            border-radius: 10px;
        }

        .deck-editor-search-results::-webkit-scrollbar-thumb {
            background-color: #4ecdc4; /* Teal color for the thumb */
            border-radius: 10px;
            border: 3px solid rgba(30, 30, 30, 0.8); /* Padding around thumb */
        }

        .deck-editor-search-results::-webkit-scrollbar-thumb:hover {
            background-color: #66e0d8; /* Lighter teal on hover */
        }

        .deck-editor-search-result {
            display: flex;
            align-items: center;
            padding: 10px 15px;
            cursor: pointer;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.2s ease;
        }

        .deck-editor-search-result:hover {
            background: rgba(78, 205, 196, 0.1);
            transform: translateY(-4px);
            z-index: 10;
            box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
        }

        .deck-editor-search-result:last-child {
            border-bottom: none;
        }

        .deck-editor-search-result-image {
            width: 40px;
            height: 56px;
            background-size: cover;
            background-position: center;
            border-radius: 4px;
            margin-right: 12px;
            flex-shrink: 0;
        }

        .deck-editor-search-result-info {
            flex: 1;
            min-width: 0;
        }

        .deck-editor-search-result-name {
            color: white;
            font-weight: 500;
            font-size: 14px;
            margin-bottom: 2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .deck-editor-search-result-type {
            color: rgba(255, 255, 255, 0.7);
            font-size: 12px;
        }

        .deck-editor-search-result-character {
            color: #4ecdc4;
            font-size: 12px;
            margin-top: 2px;
        }

        .deck-editor-layout {
            display: flex;
            height: 100%;
            overflow: hidden;
            flex: 1;
        }
        
        /* Force consistent two-pane layout - less aggressive approach */
        .deck-editor-layout.force-two-pane {
            display: flex;
            flex-direction: row;
        }
        
        .deck-editor-layout.force-two-pane .deck-pane {
            min-width: 150px;
            max-width: 77%;
        }
        
        .deck-editor-layout.force-two-pane .card-selector-pane {
            min-width: 150px;
            max-width: 77%;
            display: flex;
        }

        .deck-pane, .card-selector-pane {
            display: flex;
            flex-direction: column;
            gap: 15px;
            height: 100%;
            max-height: 100%;
            overflow: hidden;
            min-height: 0;
            min-width: 150px;
            padding: 0 8px;
        }

        .deck-pane {
            flex: 2.45; /* Default to 71% (71/29 ratio) */
            max-width: 77%; /* Prevent deck pane from taking too much space */
            min-width: 0; /* Allow flex shrinking */
        }

        .card-selector-pane {
            flex: 1; /* Default to 29% (29/71 ratio) */
            min-width: 0; /* Allow flex shrinking */
            overflow: hidden; /* Prevent content overflow */
            display: flex;
            flex-direction: column;
            max-width: 50%; /* Ensure card selector pane gets reasonable space */
            box-sizing: border-box;
        }
        
        .card-selector-pane .deck-editor-search-container {
            margin-top: 7px;
            margin-bottom: 0px;
            margin-left: 4px;
            margin-right: 4px;
            flex-shrink: 0;
            width: calc(100% - 8px);
            max-width: calc(100% - 8px);
            box-sizing: border-box;
            overflow: hidden;
        }

        /* Resizable divider */
        .resizable-divider {
            width: 4px;
            background: transparent;
            cursor: col-resize;
            position: relative;
            transition: all 0.2s ease;
            min-width: 4px;
            flex-shrink: 0;
        }


        .resizable-divider {
            background: linear-gradient(to bottom, 
                transparent 0px,
                rgba(78, 205, 196, 0.1) 6px,
                rgba(78, 205, 196, 0.3) 20px,
                rgba(78, 205, 196, 0.5) 50%,
                rgba(78, 205, 196, 0.3) calc(100% - 20px),
                rgba(78, 205, 196, 0.1) calc(100% - 6px),
                transparent 100%);
            position: relative;
        }

        /* Add small vertical lines to indicate grab handle */
        .resizable-divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) translateX(-3px);
            width: 1px;
            height: 24px;
            background: rgba(78, 205, 196, 0.8);
            border-radius: 1px;
        }

        .resizable-divider::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) translateX(3px);
            width: 1px;
            height: 24px;
            background: rgba(78, 205, 196, 0.8);
            border-radius: 1px;
        }


        .resizable-divider:hover {
            background: linear-gradient(to bottom, 
                transparent 0px,
                rgba(78, 205, 196, 0.2) 6px,
                rgba(78, 205, 196, 0.5) 20px,
                rgba(78, 205, 196, 0.7) 50%,
                rgba(78, 205, 196, 0.5) calc(100% - 20px),
                rgba(78, 205, 196, 0.2) calc(100% - 6px),
                transparent 100%);
        }

        /* Make grab handle lines more prominent on hover */
        .resizable-divider:hover::before,
        .resizable-divider:hover::after {
            background: rgba(78, 205, 196, 1);
            height: 30px;
        }


        .resizable-divider:active {
            background: linear-gradient(to bottom, 
                transparent 0px,
                rgba(78, 205, 196, 0.3) 6px,
                rgba(78, 205, 196, 0.6) 20px,
                rgba(78, 205, 196, 0.8) 50%,
                rgba(78, 205, 196, 0.6) calc(100% - 20px),
                rgba(78, 205, 196, 0.3) calc(100% - 6px),
                transparent 100%);
        }

        /* Make grab handle lines most prominent when actively dragging */
        .resizable-divider:active::before,
        .resizable-divider:active::after {
            background: rgba(78, 205, 196, 1);
            width: 2px;
            height: 36px;
        }


        .deck-pane h4, .card-selector-pane h4 {
            margin: 0 0 15px 0;
            color: #4ecdc4;
            font-size: 1.2rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            padding-bottom: 12px;
        }
        


        .deck-cards-editor {
            flex: 1;
            min-height: 200px;
            max-height: 100%;
            border: none;
            border-radius: 8px;
            padding: 20px;
            overflow-y: auto;
            overflow-x: hidden;
            background: rgba(255, 255, 255, 0.05);
            transition: none; /* Prevent transitions during resize */
        }
        
        /* Two-column layout when deck pane is wide */
        .deck-cards-editor.two-column {
            display: flex;
            gap: 20px;
            align-items: flex-start;
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        .deck-cards-editor.two-column .deck-column {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        .deck-cards-editor.two-column .deck-type-section {
            width: 100%;
            margin-bottom: 0;
        }
        

        
        /* Deck Type Sections */
        .deck-type-section {
            margin-bottom: 20px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            overflow: hidden;
            transition: none; /* Prevent transitions during resize */
        }
        
        .deck-type-header {
            background: rgba(78, 205, 196, 0.1);
            padding: 12px 16px;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.3s ease;
        }
        
        .deck-type-header:hover {
            background: rgba(78, 205, 196, 0.2);
        }
        
        .deck-type-header.collapsed {
            background: rgba(255, 255, 255, 0.05);
        }
        
        .deck-type-name {
            font-weight: 600;
            color: #4ecdc4;
            font-size: 1rem;
        }
        
        .deck-type-count {
            color: #bdc3c7;
            font-size: 0.9rem;
            font-weight: 500;
        }
        
        .deck-type-toggle {
            color: #4ecdc4;
            font-size: 0.8rem;
            font-weight: bold;
            transition: transform 0.3s ease;
        }

        .deck-type-info {
            color: #4ecdc4;
            font-size: 0.8rem;
            font-style: italic;
            margin-left: 8px;
        }

        .deck-type-left {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .deck-type-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .remove-all-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease;
            margin: 0;
            white-space: nowrap;
            min-width: 80px;
            width: 100%;
            height: auto;
            min-height: 24px;
            box-sizing: border-box;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        /* Increase width of "Remove Unusables" button in tile view */
        /* Target buttons with "Remove Unusables" text that are not in card view */
        .remove-all-btn:not(.card-view-remove-unusables-btn)[onclick*="removeUnusable"] {
            padding-left: 11px !important; /* 12px * 0.9 = 10.8px (10% reduction) */
            padding-right: 11px !important;
            width: auto !important; /* Override width: 100% to allow button to size to content */
            min-width: auto !important; /* Override min-width: 80px to allow natural sizing */
        }

        .remove-all-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.4);
        }

        .remove-all-btn:disabled {
            background: rgba(78, 205, 196, 0.1) !important;
            color: rgba(78, 205, 196, 0.5) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
            cursor: not-allowed !important;
            opacity: 0.5 !important;
        }

        .remove-all-btn:disabled:hover {
            background: rgba(78, 205, 196, 0.1) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
        }

        /* Export/Import buttons - same teal styling as Draw Hand/List View */
        .export-import-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease;
            margin-left: auto;
            margin-right: 8px;
            white-space: nowrap;
            min-width: 80px;
            height: 28px;
            min-height: 28px;
            box-sizing: border-box;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .export-import-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.4);
        }

        .export-import-btn:disabled {
            background: rgba(78, 205, 196, 0.1) !important;
            color: rgba(78, 205, 196, 0.5) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
            cursor: not-allowed !important;
            opacity: 0.5 !important;
        }

        .export-import-btn:disabled:hover {
            background: rgba(78, 205, 196, 0.1) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
        }

        /* Action Buttons (Save/Cancel) - Same styling as Draw Hand/List View buttons */
        .action-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease;
            width: 100%;
            text-align: center;
            display: block !important;
            position: static !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        .action-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.4);
        }

        .action-btn:disabled {
            background: rgba(78, 205, 196, 0.1) !important;
            color: rgba(78, 205, 196, 0.5) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
            cursor: not-allowed !important;
            opacity: 0.5 !important;
        }

        .action-btn:disabled:hover {
            background: rgba(78, 205, 196, 0.1) !important;
            border-color: rgba(78, 205, 196, 0.2) !important;
        }

        /* Save button - Match Draw Hand/List View button styling */
        .action-btn.save-btn {
            background: rgba(78, 205, 196, 0.2) !important;
            color: #4ecdc4 !important;
            border: 1px solid rgba(78, 205, 196, 0.3) !important;
            height: auto !important;
            min-height: 24px !important;
        }

        .action-btn.save-btn:hover {
            background: rgba(78, 205, 196, 0.3) !important;
            border-color: rgba(78, 205, 196, 0.4) !important;
        }

        /* Force save button styling with higher specificity */
        .deck-editor-actions .action-btn.save-btn {
            background: rgba(78, 205, 196, 0.2) !important;
            color: #4ecdc4 !important;
            border: 1px solid rgba(78, 205, 196, 0.3) !important;
            height: auto !important;
            min-height: 24px !important;
            padding: 4px 8px !important;
            box-sizing: border-box !important;
        }

        .deck-editor-actions .action-btn.save-btn:hover {
            background: rgba(78, 205, 196, 0.3) !important;
            border-color: rgba(78, 205, 196, 0.4) !important;
        }

        /* Additional specificity for save button */
        .modal-header .deck-editor-actions .action-btn.save-btn {
            background: rgba(78, 205, 196, 0.2) !important;
            color: #4ecdc4 !important;
            border: 1px solid rgba(78, 205, 196, 0.3) !important;
            height: auto !important;
            min-height: 24px !important;
            padding: 4px 8px !important;
            box-sizing: border-box !important;
        }

        .modal-header .deck-editor-actions .action-btn.save-btn:hover {
            background: rgba(78, 205, 196, 0.3) !important;
            border-color: rgba(78, 205, 196, 0.4) !important;
        }

        /* Cancel button - Black and white look */
        .action-btn.cancel-btn {
            background: rgba(255, 255, 255, 0.1) !important;
            color: #ffffff !important;
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
        }

        .action-btn.cancel-btn:hover {
            background: rgba(255, 255, 255, 0.2) !important;
            border-color: rgba(255, 255, 255, 0.3) !important;
        }

        /* Force cancel button to be visible */
        .deck-editor-actions .action-btn.cancel-btn {
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
            position: static !important;
            width: 100% !important;
            height: auto !important;
            min-height: 24px !important;
            min-width: 60px !important;
            padding: 4px 8px !important;
            box-sizing: border-box !important;
        }

        /* Additional specificity for cancel button */
        .modal-header .deck-editor-actions .action-btn.cancel-btn {
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
            position: static !important;
            width: 100% !important;
            height: auto !important;
            min-height: 24px !important;
            min-width: 60px !important;
            padding: 4px 8px !important;
            box-sizing: border-box !important;
        }
        
        /* Power Cards Sort Toggle */
        .power-cards-sort-toggle {
            display: flex;
            align-items: center;
            margin-right: 12px;
        }
        
        .sort-toggle-label {
            display: flex;
            align-items: center;
            cursor: pointer;
            font-size: 0.9rem;
            color: rgba(255, 255, 255, 0.8);
            transition: color 0.2s ease;
        }
        
        .sort-toggle-label:hover {
            color: rgba(255, 255, 255, 1);
        }
        
        .sort-toggle-label input[type="checkbox"] {
            margin-right: 6px;
            transform: scale(1.1);
        }
        
        .sort-toggle-text {
            user-select: none;
        }

        .add-all-special-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease;
            margin-left: auto;
            margin-right: 8px;
        }

        .add-all-special-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.4);
        }
        
        .deck-type-header.collapsed .deck-type-toggle {
            transform: rotate(-90deg);
        }
        
        /* Unified deck content tiles styling - single column by default */
        .deck-type-cards {
            padding: 16px;
            background: rgba(255, 255, 255, 0.02);
            display: grid;
            grid-template-columns: 1fr; /* Single column by default */
            gap: 16px;
        }

        /* Two-column layout for wide deck panes to prevent flash */
        .deck-cards-editor.two-column .deck-type-cards {
            grid-template-columns: 1fr; /* Single column within each section */
        }

        /* Force single column class for JavaScript override */
        .force-single-column {
            grid-template-columns: 1fr !important;
        }

        .deck-cards-editor.drag-over {
            border-color: #4ecdc4;
            background: rgba(78, 205, 196, 0.1);
        }

        /* List View Styles */
        .deck-cards-editor.list-view {
            padding: 20px;
            background: rgba(0, 0, 0, 0.432); /* Increased shading by 20% (was 0.36) */
            width: 100%;
            min-width: 100%;
            box-sizing: border-box;
        }
        
        /* Override: List view should never use 4-column layout, only responsive 1-2 columns */
        .deck-cards-editor.list-view .deck-type-cards {
            display: block !important;
            grid-template-columns: none !important;
            gap: 0 !important;
        }
        
        .deck-cards-editor.list-view .deck-list-view {
            display: block !important;
            grid-template-columns: none !important;
            gap: 0 !important;
        }

        
        
        
        .deck-list-section {
            margin-bottom: 30px;
        }

        .deck-list-section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 16px;
            background: rgba(78, 205, 196, 0.1);
            border: 1px solid rgba(78, 205, 196, 0.3);
            border-radius: 6px;
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .deck-list-section-header:hover {
            background: rgba(78, 205, 196, 0.2);
        }
        
        .deck-list-section-toggle {
            font-size: 1.0rem;
            color: #4ecdc4;
            transition: transform 0.2s ease;
        }
        
        .deck-list-section-header.collapsed .deck-list-section-toggle {
            transform: rotate(-90deg);
        }

        .deck-list-section-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: #4ecdc4;
        }

        .deck-list-section-count {
            font-size: 0.9rem;
            color: rgba(255, 255, 255, 0.7);
        }
        .deck-list-items {
            background: rgba(255, 255, 255, 0.02);
            border-radius: 6px;
            padding: 8px 0;
            width: 100%;
            min-width: 100%;
            box-sizing: border-box;
        }

        .deck-list-item {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            cursor: pointer;
            transition: all 0.2s ease;
            width: 100%;
            min-width: 100%;
            box-sizing: border-box;
        }

        .deck-list-item:last-child {
            border-bottom: none;
        }

        .deck-list-item:hover {
            background: rgba(78, 205, 196, 0.1);
        }

        .deck-list-item-quantity {
            font-weight: 600;
            color: #4ecdc4;
            margin-right: 12px;
            min-width: 40px;
            width: 40px;
            text-align: right;
            flex: 0 0 40px;
            box-sizing: border-box;
        }

        .deck-list-item-name {
            flex: 1;
            font-size: 1.0rem;
            font-weight: 400;
            color: #ffffff;
        }

        .deck-list-item-actions {
            display: flex;
            gap: 12px;
            align-items: center;
            margin-left: 16px;
        }

        .deck-list-item-remove {
            background: rgba(78, 205, 196, 0.2);
            border: 1px solid rgba(78, 205, 196, 0.4);
            color: #4ecdc4;
            width: 24px;
            height: 24px;
            border-radius: 4px;
            font-size: 1.0rem;
            font-weight: bold;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .deck-list-item-remove:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.6);
        }

        /* Force list view to always be horizontal */
        .deck-cards-editor.list-view .deck-list-item {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: nowrap !important;
            align-items: center !important;
            justify-content: flex-start !important;
            width: 100% !important;
            min-width: 100% !important;
            box-sizing: border-box !important;
        }
        
        /* Force child elements to be horizontal as well */
        .deck-cards-editor.list-view .deck-list-item .deck-list-item-quantity,
        .deck-cards-editor.list-view .deck-list-item .deck-list-item-name,
        .deck-cards-editor.list-view .deck-list-item .deck-list-item-actions {
            display: inline-block !important;
            white-space: nowrap !important;
        }
        
        .deck-cards-editor.list-view .deck-list-item .deck-list-item-name {
            flex: 1 !important;
        }
        
        .deck-cards-editor.list-view .deck-list-item .deck-list-item-actions {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: nowrap !important;
            align-items: center !important;
        }
        
        .deck-list-item-quantity-control {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .deck-list-item-quantity-btn {
            background: rgba(78, 205, 196, 0.2);
            border: 1px solid rgba(78, 205, 196, 0.4);
            color: #4ecdc4;
            width: 24px;
            height: 24px;
            border-radius: 4px;
            font-size: 0.8rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .deck-list-item-quantity-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.6);
        }

        /* Character groups within list view */
        .deck-list-items .character-group {
            margin: 8px 0;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.02);
        }

        .deck-list-items .character-group-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: rgba(78, 205, 196, 0.1);
            border-radius: 6px 6px 0 0;
            cursor: pointer;
            transition: background 0.2s ease;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .deck-list-items .character-group-header:hover {
            background: rgba(78, 205, 196, 0.2);
        }

        .deck-list-items .character-group-content {
            padding: 8px;
            max-height: none;
            overflow-y: visible;
            transition: all 0.3s ease;
        }
        
        .deck-list-items .character-group-content.collapsed {
            max-height: 0;
            padding: 0 8px;
            overflow: hidden;
        }

        /*
         * Read-only layout variants
         *
         * - Preview mode: hide Available Cards pane but keep deck padding stable
         * - Forced read-only: same layout behavior (full-width deck) for true view-only
         *
         * NOTE: The generic `read-only-mode` class is used for interaction restrictions.
         * Layout changes should be controlled by these more specific classes.
         */
        .preview-read-only-mode .card-selector-pane,
        .forced-read-only-mode .card-selector-pane {
            display: none !important;
        }
        
        .preview-read-only-mode .resizable-divider,
        .forced-read-only-mode .resizable-divider {
            display: none !important;
        }
        
        .preview-read-only-mode .deck-pane,
        .forced-read-only-mode .deck-pane {
            flex: 1 1 auto !important;
            min-width: 0 !important;
            max-width: none !important;
            /* Keep the normal `padding: 0 8px` from `.deck-pane` */
        }

        .preview-read-only-mode .deck-editor-layout.force-two-pane .deck-pane,
        .forced-read-only-mode .deck-editor-layout.force-two-pane .deck-pane {
            max-width: none !important;
        }
        
        /* Hide Remove All buttons in read-only mode, but preserve key header controls */
        .read-only-mode .remove-all-btn:not(#drawHandBtn):not(#listViewBtn):not(#previewBtn):not(#backgroundBtn) {
            display: none !important;
        }
        
        /* Hide Change Art buttons on individual cards in read-only mode */
        .read-only-mode .alternate-art-btn {
            display: none !important;
        }
        
        /* Hide - (remove) buttons on individual cards in read-only mode */
        .read-only-mode .quantity-btn {
            display: none !important;
        }
        
        .read-only-mode .deck-list-item-remove {
            display: none !important;
        }
        
        /* Hide +1/-1 quantity adjustment buttons in read-only mode */
        .read-only-mode .add-one-btn {
            display: none !important;
        }
        
        .read-only-mode .remove-one-btn {
            display: none !important;
        }
        
        .read-only-mode .deck-list-item-quantity-btn {
            display: none !important;
        }
        
        
        

        .deck-card-editor-item {
            background: transparent !important; /* No background - let card images show through */
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 6px;
            padding: 10px;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: move;
            position: relative;
            transition: all 0.2s ease;
        }

        .deck-card-editor-item:hover {
            background: transparent !important; /* Keep transparent on hover */
        }

        .deck-card-editor-item.dragging {
            opacity: 1;
            transform: rotate(3deg) scale(1.05);
            z-index: 1000;
        }

        /* Available cards drop zone styling */
        .card-category-content.available-drop-zone {
            background: rgba(78, 205, 196, 0.2);
            border: 2px dashed #4ecdc4;
            border-radius: 8px;
            transition: all 0.2s ease;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        }

        .deck-card-editor-item.drag-over {
            border-color: #4ecdc4;
            background: rgba(78, 205, 196, 0.2);
            transform: scale(1.02);
        }

        .deck-type-section.drag-over {
            background: rgba(78, 205, 196, 0.1);
            border-color: #4ecdc4;
        }

        .deck-card-editor-item.drag-placeholder {
            opacity: 0.3;
            background: rgba(78, 205, 196, 0.1);
            border: 2px dashed #4ecdc4;
            transform: scale(0.95);
        }

        .deck-card-editor-item.drag-target {
            transform: translateY(0);
            transition: transform 0.3s ease;
        }

        .deck-card-editor-item.drag-target.drag-above {
            transform: translateY(-60px);
        }

        .deck-card-editor-item.drag-target.drag-below {
            transform: translateY(60px);
        }

        .deck-card-editor-item.drag-space {
            height: 60px;
            background: rgba(78, 205, 196, 0.1);
            border: 2px dashed #4ecdc4;
            border-radius: 6px;
            margin: 4px 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #4ecdc4;
            font-size: 0.9rem;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .deck-card-editor-item.drag-space::before {
            content: "Drop here";
        }

        .deck-card-editor-info {
            flex: 1;
        }

        .deck-card-editor-name {
            font-weight: 600;
            color: #ffffff;
            margin-bottom: 8px;
            font-size: 1.3rem;
        }

        .deck-card-editor-type {
            color: #bdc3c7;
            font-size: 0.8rem;
            text-transform: capitalize;
        }
        
        .deck-card-editor-stats {
            margin-top: 8px;
        }
        
        .deck-card-editor-stats .character-stats {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        
        .deck-card-editor-stats .stat-labels,
        .deck-card-editor-stats .stat-values {
            display: flex;
            gap: 16px;
            align-items: center;
            font-size: 0.9rem;
        }
        
        .deck-card-editor-stats .stat-label,
        .deck-card-editor-stats .stat-value {
            text-align: center;
            display: block;
            min-width: 20px;
            width: 20px;
        }
        
        .deck-card-editor-stats .stat-label {
            color: #bdc3c7;
            font-size: 0.75rem;
            font-weight: 500;
            min-width: 20px;
            text-align: center;
        }
        
        .deck-card-editor-stats .stat-value {
            font-weight: bold;
            min-width: 16px;
            text-align: center;
        }
        
        .character-special-ability {
            color: #ffffff;
            font-size: 0.8rem;
            font-weight: 400;
            line-height: 1.3;
            text-align: left;
            opacity: 0.9;
            margin-top: 4px;
            margin-left: 0;
            min-height: 1.3em;
        }
        
        /* Card type specific stat styling */
        .deck-card-editor-stats .location-stats {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .deck-card-editor-stats .location-stats .stat-labels,
        .deck-card-editor-stats .location-stats .stat-values {
            display: flex;
            gap: 16px;
            align-items: center;
            font-size: 0.9rem;
        }
        .deck-card-editor-stats .location-stats .stat-label,
        .deck-card-editor-stats .location-stats .stat-value {
            text-align: center;
            display: block;
            min-width: 20px;
            width: 20px;
        }
        .deck-card-editor-stats .mission-stats,
        .deck-card-editor-stats .event-stats,
        .deck-card-editor-stats .special-stats,
        .deck-card-editor-stats .aspect-stats,
        .deck-card-editor-stats .power-stats {
            display: flex;
            gap: 8px;
            align-items: center;
            font-size: 0.9rem;
        }
        
        .deck-card-editor-stats .aspect-stats {
            flex-direction: column;
            gap: 4px;
        }
        
        .deck-card-editor-stats .aspect-stats > div {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        
        .deck-card-editor-stats .basic-universe-stats,
        .deck-card-editor-stats .teamwork-stats,
        .deck-card-editor-stats .ally-universe-stats,
        .deck-card-editor-stats .training-stats,
        .deck-card-editor-stats .advanced-universe-stats {
            display: flex;
            gap: 8px;
            align-items: center;
            font-size: 0.9rem;
        }
        
        /* Image view mode styling */
        .deck-card-editor-item.image-view {
            flex-direction: column;
            align-items: center;
            text-align: center;
            padding: 15px;
            min-height: 280px;
            justify-content: space-between;
        }
        
        .deck-card-editor-item.image-view .deck-card-editor-info {
            width: 100%;
        }
        
        .deck-card-editor-item.image-view .deck-card-editor-name {
            margin-bottom: 10px;
            font-size: 0.9rem;
        }
        
        .deck-card-editor-item.image-view .deck-card-editor-type {
            margin-bottom: 10px;
        }
        
        .deck-card-editor-item.image-view .deck-card-editor-stats {
            margin-bottom: 10px;
        }
        
        .deck-card-editor-item.image-view .deck-card-editor-actions {
            margin-top: 10px;
            width: 100%;
            display: flex;
            justify-content: center;
        }
        
        .deck-card-editor-item.image-view .card-image {
            max-width: 160px;
            max-height: 224px;
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 8px;
            border: 2px solid rgba(255, 255, 255, 0.2);
            display: block;
        }
        
        .deck-card-editor-item.image-view .card-image-container {
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            min-height: 0;
            margin-bottom: 10px;
            height: 230px;
        }
        
        .deck-card-editor-item.preview-view {
            flex-direction: row;
            align-items: center;
            text-align: left;
            padding: 15px;
            min-height: auto;
            justify-content: space-between;
        }

        /* Special card tiles need more height to accommodate the Change Art button */
        .deck-card-editor-item.preview-view.special-card {
            min-height: 50px;
            align-items: flex-start;
            padding-top: 10px;
        }
        /* Character background styling for deck editor tiles */
        .deck-card-editor-item.character-card {
            background: transparent !important; /* No background - let card images show through */
            position: relative;
            overflow: hidden;
        }

        .deck-card-editor-item.character-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 100% auto;
            background-position: right 10%;
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: 0; /* Behind content */
            border-radius: 6px;
        }
        
        /* Ensure tile content is above the card image */
        .deck-card-editor-item.character-card > * {
            position: relative;
            z-index: 1;
        }

        /* Special positioning for alternate art backgrounds */
        .deck-card-editor-item.character-card[data-bg-image*="/alternate/"]::before {
            background-position: right 5%;
        }

        /* Gray overlay to dim card images */
        .deck-card-editor-item.character-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: 0; /* Same level as ::before, but will be layered on top */
            border-radius: 6px;
            pointer-events: none;
        }

        /* Alternate Art Selection Modal */
        .alternate-art-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .alternate-art-content {
            background: rgba(20, 20, 20, 0.95);
            border: 1px solid rgba(78, 205, 196, 0.3);
            border-radius: 8px;
            padding: 2rem;
            max-width: 800px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        }

        .alternate-art-content h3 {
            color: #4ecdc4;
            text-align: center;
            margin-bottom: 1.5rem;
            font-size: 1.5rem;
            font-weight: 600;
        }

        .alternate-art-options {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        .art-option {
            cursor: pointer;
            border: 2px solid transparent;
            border-radius: 8px;
            padding: 0.75rem;
            text-align: center;
            transition: all 0.3s ease;
            background: rgba(255, 255, 255, 0.05);
        }

        .art-option:hover {
            border-color: #4ecdc4;
            background: rgba(78, 205, 196, 0.1);
            transform: translateY(-2px);
        }

        .art-option.selected {
            border-color: #4ecdc4;
            background: rgba(78, 205, 196, 0.2);
            box-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
        }

        .art-option img {
            width: 100%;
            height: 220px;
            object-fit: contain;
            border-radius: 6px;
            margin-bottom: 0.75rem;
            background: rgba(0, 0, 0, 0.3);
        }

        .art-option span {
            color: #e6e6e6;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .alternate-art-actions {
            text-align: center;
            border-top: 1px solid rgba(78, 205, 196, 0.2);
            padding-top: 1rem;
        }

        .alternate-art-actions button {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 0.75rem 1.5rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .alternate-art-actions button:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: #4ecdc4;
            transform: translateY(-1px);
        }

        /* Deck Card Editor Actions Column */

        /* Change Art Button */
        .alternate-art-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
            text-align: center;
        }

        .alternate-art-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.5);
            color: #ffffff;
        }

        /* Ensure alternate-art-btn for power cards matches quantity-btn size exactly */
        .deck-card-editor-item.power-card .alternate-art-btn {
            background: rgba(78, 205, 196, 0.2);
            color: #4ecdc4;
            border: 1px solid rgba(78, 205, 196, 0.3);
            padding: 3.3px 6.6px;
            border-radius: 3.3px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
            text-align: center;
        }

        .deck-card-editor-item.power-card .alternate-art-btn:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.5);
            color: #ffffff;
        }

        /* Power card background images in deck contents */
        .deck-card-editor-item.power-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 100% auto;
            background-position: right top; /* Aligned to upper right */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        /* Location card background images in deck contents */
        .deck-card-editor-item.location-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 100% auto;
            background-position: center top; /* Centered horizontally, anchored to top */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }
        .deck-card-editor-item.power-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Location card gray overlay */
        .deck-card-editor-item.location-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Special card background images in deck contents */
        .deck-card-editor-item.special-card {
            overflow: hidden;
        }
        .deck-card-editor-item.special-card::before {
            content: '';
            position: absolute;
            top: -85%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right top; /* Aligned to upper right */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        /* Special card gray overlay */
        .deck-card-editor-item.special-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Power card title styling */
        .deck-card-editor-item.power-card .deck-card-editor-name {
            font-size: 1.2rem;
            font-weight: 400;
        }

        /* Location card title styling */
        .deck-card-editor-item.location-card .deck-card-editor-name {
            font-size: 1.3rem;
            font-weight: 400;
        }

        /* Special card title styling */
        .deck-card-editor-item.special-card .deck-card-editor-name {
            font-size: 1.3rem;
            font-weight: 400;
        }

        /* Aspect card background images in deck contents */
        .deck-card-editor-item.aspect-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.aspect-card::before {
            content: '';
            position: absolute;
            top: -200%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right top; /* Aligned to upper right */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        /* Aspect card gray overlay */
        .deck-card-editor-item.aspect-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Aspect card title styling */
        .deck-card-editor-item.aspect-card .deck-card-editor-name {
            font-size: 1.3rem;
            font-weight: 400;
        }

        /* Mission card background images in deck contents */
        .deck-card-editor-item.mission-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.mission-card::before {
            content: '';
            position: absolute;
            top: -500%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right top; /* Aligned to upper right */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        /* Mission card gray overlay */
        .deck-card-editor-item.mission-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Mission card title styling */
        .deck-card-editor-item.mission-card .deck-card-editor-name {
            font-size: 1.3rem;
            font-weight: 400;
        }

        /* Event card background images in deck contents */
        .deck-card-editor-item.event-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.event-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 187.5% auto;
            background-position: left top; /* Aligned to upper left */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        /* Event card gray overlay */
        .deck-card-editor-item.event-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        /* Event card title styling */
        .deck-card-editor-item.event-card .deck-card-editor-name {
            font-size: 1.3rem;
            font-weight: 400;
        }

        .deck-card-editor-item.teamwork-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.teamwork-card::before {
            content: '';
            position: absolute;
            top: -60%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right center; /* Middle right of image aligned to middle right of tile */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        .deck-card-editor-item.teamwork-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }

        .deck-card-editor-item.teamwork-card .deck-card-editor-name {
            font-size: 1.0rem;
            font-weight: 400;
        }

        .deck-card-editor-item.ally-universe-card .deck-card-editor-name {
            font-size: 1.0rem;
            font-weight: 400;
        }

        .deck-card-editor-item.basic-universe-card .deck-card-editor-name {
            font-size: 1.0rem !important;
            font-weight: 400 !important;
        }
        
        /* Advanced universe cards in deck editor - match teamwork card styling */
        .deck-card-editor-item.advanced-universe-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.advanced-universe-card::before {
            content: '';
            position: absolute;
            top: -60%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right center; /* Middle right of image aligned to middle right of tile */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        .deck-card-editor-item.advanced-universe-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }
        
        .deck-card-editor-item.advanced-universe-card .deck-card-editor-name {
            font-size: 1.0rem;
            font-weight: 400;
        }
        
        /* Training cards in deck editor - match mission card styling */
        .deck-card-editor-item.training-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.training-card::before {
            content: '';
            position: absolute;
            top: -500%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right top; /* Aligned to upper right */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }
        
        /* Training card gray overlay */
        .deck-card-editor-item.training-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }
        
        /* Training card title styling */
        .deck-card-editor-item.training-card .deck-card-editor-name {
            font-size: 1.0rem;
            font-weight: 400;
        }


        .deck-card-editor-actions {
            position: absolute;
            bottom: 8px;
            right: 8px;
            display: flex;
            flex-direction: row;
            gap: 0.5rem;
            align-items: center;
            z-index: 10;
        }

        /* Tile View: action buttons must stay bottom-right (not vertically centered).
           This is intentionally scoped to Tile View so Card View / List View layouts are unaffected. */
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions {
            position: absolute !important;
            right: 8px !important;
            bottom: 8px !important;
            top: auto !important;
            left: auto !important;
            transform: none !important;
            align-self: auto !important;
        }

        /* Tile View: slightly shade action buttons for readability (subtle bump vs defaults).
           Keep this light — we don't want the heavy dark overlay look. */
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .quantity-btn,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .remove-one-btn,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .add-one-btn,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .reserve-btn {
            /* Reduce transparency by ~1/3 vs current bump (i.e., opacity * 4/3) */
            background: rgba(255, 255, 255, 0.20) !important; /* was 0.15 */
            border-color: rgba(255, 255, 255, 0.33) !important; /* was 0.25 */
        }

        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .quantity-btn:hover,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .remove-one-btn:hover,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .add-one-btn:hover,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .reserve-btn:hover {
            background: rgba(255, 255, 255, 0.33) !important; /* was 0.25 */
            border-color: rgba(255, 255, 255, 0.47) !important; /* was 0.35 */
        }

        /* Tile View: Reserve button active state — darkened with pressed-in look */
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .reserve-btn.active,
        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .reserve-btn.active:hover {
            background: rgba(100, 100, 100, 0.6) !important;
            border-color: rgba(130, 130, 130, 0.65) !important;
            color: #ffffff !important;
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6) !important;
        }

        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .alternate-art-btn {
            background: rgba(78, 205, 196, 0.33) !important; /* was 0.25 */
            border-color: rgba(78, 205, 196, 0.47) !important; /* was 0.35 */
        }

        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .alternate-art-btn:hover {
            background: rgba(78, 205, 196, 0.47) !important; /* was 0.35 */
            border-color: rgba(78, 205, 196, 0.73) !important; /* was 0.55 */
        }

        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .ko-btn {
            background: rgba(255, 107, 107, 0.33) !important; /* was 0.25 */
            border-color: rgba(255, 107, 107, 0.47) !important; /* was 0.35 */
        }

        .deck-cards-editor:not(.list-view):not(.card-view) .deck-card-editor-item.preview-view .deck-card-editor-actions .ko-btn:hover {
            background: rgba(255, 107, 107, 0.47) !important; /* was 0.35 */
            border-color: rgba(255, 107, 107, 0.60) !important; /* was 0.45 */
        }

        /* Remove One button styling - exactly matches quantity-btn */
        .remove-one-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 3.3px;
            padding: 3.3px 0;
            font-size: 11px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            width: 24px;
            min-width: 24px;
            max-width: 24px;
            font-family: monospace;
            box-sizing: border-box;
            line-height: 1;
        }

        /* Add One button styling - matches remove-one-btn */
        .add-one-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 3.3px;
            padding: 3.3px 0;
            font-size: 11px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            width: 24px;
            min-width: 24px;
            max-width: 24px;
            font-family: monospace;
            box-sizing: border-box;
            line-height: 1;
        }

        .remove-one-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .add-one-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }



        .card-categories {
            flex: 1;
            max-height: 100%;
            overflow-y: auto;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
            gap: 15px;
            padding-bottom: 30px;
        }

        .card-category {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            overflow: hidden;
        }

        .card-category-header {
            background: rgba(78, 205, 196, 0.2);
            padding: 10px 15px;
            color: #4ecdc4;
            font-weight: 600;
            font-size: 0.8rem;
            text-transform: capitalize;
            cursor: pointer;
            user-select: none;
            transition: all 0.3s ease;
            display: flex;
            justify-content: space-between;
            align-items: center;
            min-width: 0; /* Allow flex shrinking */
        }
        
        .card-category-header span {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-right: 10px;
        }

        .card-category-header:hover {
            background: rgba(78, 205, 196, 0.3);
        }

        .card-category-header .collapse-icon {
            font-size: 1.02rem;
            flex-shrink: 0; /* Prevent shrinking */
            min-width: 17px; /* Ensure minimum width */
        }

        .card-category-header.collapsed .collapse-icon {
            /* No rotation needed - using correct characters directly */
            transform: none;
        }

        .card-category-content {
            padding: 10px;
            max-height: 200px;
            overflow-y: auto;
            transition: all 0.3s ease;
        }

        .card-category-content.collapsed {
            max-height: 0;
            padding: 0 10px;
            overflow: hidden;
        }

        /* When a category is expanded, make it take up remaining space */
        .card-category-content:not(.collapsed) {
            flex: 1;
            max-height: none;
            min-height: 0;
        }

        /* Deck Validation Styles - Compact */
        .deck-validation {
            background: rgba(0, 0, 0, 0.9);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 4px;
            padding: 6px 10px;
            margin-bottom: 10px;
            font-family: 'Arial', sans-serif;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            gap: 6px;
            width: 100%;
            box-sizing: border-box;
            align-self: flex-start;
        }

        .validation-errors-compact {
            color: #ff6b6b;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .validation-warnings-compact {
            color: #ffd93d;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .validation-success-compact {
            color: #51cf66;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .validation-icon {
            font-size: 1.1rem;
        }

        .validation-text {
            font-weight: 500;
        }

        /* Deck validation badges in deck list */
        .deck-validation-badge {
            font-size: 0.8rem;
            padding: 4px 8px;
            border-radius: 4px;
            margin-left: 10px;
            font-weight: 500;
            vertical-align: middle;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            line-height: 1.2;
            height: 24px;
            min-height: 24px;
            max-height: 24px;
            box-sizing: border-box;
        }

        .deck-validation-badge.error {
            background: rgba(255, 68, 68, 0.2) !important;
            color: #ff4444 !important;
            border: 1px solid rgba(255, 68, 68, 0.3) !important;
            padding: 4px 8px !important;
            min-height: 24px !important;
            height: auto !important;
            cursor: pointer !important;
        }

        .deck-validation-badge.warning {
            background: rgba(255, 217, 61, 0.2);
            color: #ffd93d;
            border: 1px solid rgba(255, 217, 61, 0.3);
        }

        .deck-validation-badge.success {
            background: rgba(81, 207, 102, 0.2);
            color: #51cf66;
            border: 1px solid rgba(81, 207, 102, 0.3);
        }

        .deck-validation-badge.limited {
            background: rgba(210, 180, 140, 0.2);
            color: #d2b48c;
            border: 1px solid rgba(210, 180, 140, 0.3);
            cursor: pointer;
        }

        .deck-validation-badge.read-only {
            background: rgba(100, 149, 237, 0.2);
            color: #6495ed;
            border: 1px solid rgba(100, 149, 237, 0.3);
            white-space: nowrap;
        }

        /* Hidden on desktop; `.layout-mobile` overrides in deck-editor-mobile.css */
        #deckEditorModal .deck-validation-reasons-mv {
            display: none !important;
        }

        .card-item {
            padding: 8px 12px;
            margin: 4px 0;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            cursor: grab;
            transition: all 0.2s ease;
            color: #ffffff;
            font-size: 0.85rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .card-item:hover {
            background: rgba(255, 255, 255, 0.1);
            transform: translateY(-1px);
        }

        .card-item:active {
            cursor: grabbing;
        }

        .card-item.dragging {
            opacity: 0.5;
            transform: rotate(5deg);
        }

        .card-item-content {
            flex: 1;
        }
        .card-item-plus {
            background: rgba(78, 205, 196, 0.2);
            border: 1px solid rgba(78, 205, 196, 0.4);
            border-radius: 3px;
            color: #4ECDC4;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: bold;
            height: 20px;
            width: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            margin-left: auto;
            margin-right: 8px;
            flex-shrink: 0;
            position: relative;
        }
        

        .card-item-plus:hover {
            background: rgba(78, 205, 196, 0.3);
            border-color: rgba(78, 205, 196, 0.6);
            transform: scale(1.1);
        }

        .card-item-plus:active {
            transform: scale(0.95);
        }

        /* Ensure ally universe cards have consistent height and alignment */
        .card-item[data-type="ally-universe"] {
            min-height: 32px;
            align-items: center;
            padding: 6px 12px;
        }

        .card-item[data-type="ally-universe"] .card-item-content {
            line-height: 1.1;
            display: flex;
            align-items: center;
            font-size: 0.9rem;
        }
        
        /* Ally universe cards in deck editor - match teamwork card styling */
        .deck-card-editor-item.ally-universe-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.ally-universe-card::before {
            content: '';
            position: absolute;
            top: -60%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right center; /* Middle right of image aligned to middle right of tile */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        .deck-card-editor-item.ally-universe-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }
        
        /* Basic universe cards in deck editor - match teamwork card styling */
        .deck-card-editor-item.basic-universe-card {
            overflow: hidden;
        }
        
        .deck-card-editor-item.basic-universe-card::before {
            content: '';
            position: absolute;
            top: -60%;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: var(--bg-image, none);
            background-size: 125% auto;
            background-position: right center; /* Middle right of image aligned to middle right of tile */
            background-repeat: no-repeat;
            opacity: 1.0; /* Full opacity - gray overlay will dim */
            z-index: -1;
            border-radius: 6px;
        }

        .deck-card-editor-item.basic-universe-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.55); /* Black dimming overlay */
            z-index: -1;
            border-radius: 6px;
            pointer-events: none;
        }
        
        .character-card {
            padding: 16px;
            background: rgba(78, 205, 196, 0.15);
        }
        
        .character-name {
            font-weight: 600;
            margin-bottom: 8px;
            color: #ffffff;
        }
        
        .character-stats {
            display: flex;
            gap: 16px;
            align-items: baseline;
            font-size: 0.9rem;
            font-weight: 500;
            justify-content: flex-start;
        }
        
        .character-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            min-width: 24px;
        }
        
        .stat-label {
            color: #bdc3c7;
            font-size: 0.75rem;
            font-weight: 500;
            margin-bottom: 2px;
            line-height: 1;
        }
        
        .stat-value {
            font-weight: bold;
            font-size: 1rem;
            line-height: 1;
            text-align: center;
        }

        /* Disabled character cards when limit reached */
        .card-item.character-card.disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .card-item.character-card.disabled:hover {
            transform: none;
            box-shadow: none;
        }

        /* Location card styling - similar to character cards */
        .location-card {
            padding: 16px;
            background: rgba(78, 205, 196, 0.15);
        }
        
        .location-name {
            font-weight: 600;
            margin-bottom: 8px;
            color: #ffffff;
        }
        
        .location-stats {
            display: flex;
            gap: 16px;
            align-items: baseline;
            font-size: 0.9rem;
            font-weight: 500;
            justify-content: flex-start;
        }
        
        .location-stat {
            display: flex;
            flex-direction: column;
            align-items: center;
            min-width: 24px;
        }

        .location-special-ability {
            margin-top: 8px;
            font-size: 0.85rem;
            color: #bdc3c7;
            font-style: italic;
            line-height: 1.3;
        }

        /* Disabled location cards when limit reached */
        .card-item.location-card.disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .card-item.location-card.disabled:hover {
            transform: none;
            box-shadow: none;
        }

        /* Disabled mission cards when limit reached */
        .card-item[data-type="mission"].disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .card-item[data-type="mission"].disabled:hover {
            transform: none;
            box-shadow: none;
        }

        /* Disabled cards for One Per Deck (applies to all card types) */
        .card-item.disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .card-item.disabled:hover {
            transform: none;
            box-shadow: none;
        }

        /* Disabled location rows when limit reached - EXTREMELY SPECIFIC */
        #locations-tbody tr.disabled {
            opacity: 0.3 !important;
            pointer-events: none !important;
            background: rgba(255, 0, 0, 0.3) !important;
            border: 2px solid rgba(255, 0, 0, 0.8) !important;
            filter: grayscale(100%) !important;
        }

        #locations-tbody tr.disabled .add-to-deck-btn {
            opacity: 0.3 !important;
            cursor: not-allowed !important;
            pointer-events: none !important;
            background: rgba(255, 0, 0, 0.3) !important;
            border: 2px solid rgba(255, 0, 0, 0.8) !important;
            color: #ffffff !important;
        }

        #locations-tbody tr.disabled img {
            opacity: 0.3 !important;
            cursor: not-allowed !important;
            pointer-events: none !important;
            filter: grayscale(100%) !important;
        }

        /* Override any conflicting rules */
        #locations-tbody tr.disabled * {
            opacity: 0.3 !important;
            pointer-events: none !important;
        }

        .empty-deck-message {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: #bdc3c7;
            padding: 0 20px;
            font-style: italic;
            pointer-events: none;
        }

        /* Ensure the deck cards container/editor provide a positioning context */
        #deckCardsContainer,
        #deckCardsEditor {
            position: relative;
            min-height: 100%;
        }

        /* Center the simpler single-line empty message as well */
        .no-cards-message {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: #bdc3c7;
            padding: 0 20px;
            font-style: italic;
            pointer-events: none;
        }

        .drag-instructions {
            text-align: center;
            color: #bdc3c7;
            padding: 20px;
            font-size: 0.9rem;
        }

        /* Card categories container should use remaining space */
        #cardCategories {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            min-height: 0;
            gap: 0;
        }

        /* Individual card categories should not grow by default */
        .card-category {
            flex-shrink: 0;
        }

        /* Expanded category content should grow to fill space */
        .card-category-content.expanded {
            flex: 1;
            max-height: none;
            min-height: 0;
        }

        /* Character groups within special cards */
        .character-group {
            margin: 8px 0;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.02);
        }
        .character-group-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: rgba(78, 205, 196, 0.1);
            border-radius: 6px 6px 0 0;
            cursor: pointer;
            transition: background 0.2s ease;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .character-group-header:hover {
            background: rgba(78, 205, 196, 0.2);
        }

                   .character-group-content {
               padding: 8px;
               max-height: none;
               overflow-y: visible;
               transition: all 0.3s ease;
           }
           
           .character-group-content.collapsed {
               max-height: 0;
               padding: 0 8px;
               overflow: hidden;
           }
        /* Mission set groups within missions and events */
        .mission-set-group {
            margin: 8px 0;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.02);
        }

        .mission-set-group-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: rgba(78, 205, 196, 0.1);
            border-radius: 6px 6px 0 0;
            cursor: pointer;
            transition: background 0.2s ease;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .mission-set-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .add-all-btn {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.2s ease;
        }

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

        .mission-set-group-header:hover {
            background: rgba(78, 205, 196, 0.2);
        }

        .mission-set-group-content {
            padding: 8px;
            max-height: none;
            overflow-y: visible;
            transition: all 0.3s ease;
        }
        
        .mission-set-group-content.collapsed {
            max-height: 0;
            padding: 0 8px;
            overflow: hidden;
        }

        /* Login Modal Styles moved to /components/login/login.css */
        
        /* Prevent logo images from being clickable */
        .header img {
            cursor: default !important;
            pointer-events: none !important;
        }

        .user-info {
            position: absolute;
            top: 15px;
            right: 20px;
            display: flex;
            align-items: center;
            gap: 15px;
            min-width: 200px;
            justify-content: flex-end;
        }

        .user-info span {
            color: #bdc3c7;
            font-size: 1rem;
        }

/* Export JSON Overlay Styles */
.export-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.export-overlay-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid #4ecdc4;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    height: 80%;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(78, 205, 196, 0.4);
    overflow: hidden;
}

.export-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(78, 205, 196, 0.3);
    background: rgba(0, 0, 0, 0.2);
}

.export-overlay-header h3 {
    margin: 0;
    color: #4ecdc4;
    font-size: 1.4rem;
    font-weight: 600;
}

.export-close-btn {
    background: none;
    border: none;
    color: #4ecdc4;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.export-close-btn:hover {
    background: rgba(78, 205, 196, 0.2);
}

.export-overlay-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.json-container {
    position: relative;
    flex: 1;
    margin: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.copy-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(78, 205, 196, 0.2);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    color: #4ecdc4;
    transition: all 0.2s ease;
    z-index: 10;
}

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

.copy-button svg {
    display: block;
}

/* Copy button flash animation */
.copy-button.copy-flash {
    animation: copyFlash 0.15s ease-out;
}

@keyframes copyFlash {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(78, 205, 196, 0);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 25px rgba(78, 205, 196, 1), 0 0 50px rgba(78, 205, 196, 0.6);
    }
    100% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(78, 205, 196, 0.8), 0 0 40px rgba(78, 205, 196, 0.4);
    }
}

.json-container pre {
    flex: 1;
    background: transparent;
    color: #ffffff;
    padding: 20px;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

/* JSON container flash animation when copied */
.json-container.json-copied-flash {
    animation: jsonContainerFlash 0.4s ease-out;
}

@keyframes jsonContainerFlash {
    0% {
        border-color: rgba(78, 205, 196, 0.3);
        box-shadow: none;
        background: rgba(0, 0, 0, 0.4);
    }
    50% {
        border-color: #4ecdc4;
        box-shadow: 0 0 40px rgba(78, 205, 196, 0.8), inset 0 0 30px rgba(78, 205, 196, 0.3);
        background: rgba(78, 205, 196, 0.1);
    }
    100% {
        border-color: rgba(78, 205, 196, 0.3);
        box-shadow: none;
        background: rgba(0, 0, 0, 0.4);
    }
}

/* JSON text flash animation */
.json-container pre.json-text-flash {
    animation: jsonTextFlash 0.3s ease-out;
}

@keyframes jsonTextFlash {
    0% {
        color: #ffffff;
        text-shadow: none;
    }
    50% {
        color: #4ecdc4;
        text-shadow: 0 0 10px rgba(78, 205, 196, 0.8), 0 0 20px rgba(78, 205, 196, 0.4);
    }
    100% {
        color: #ffffff;
        text-shadow: none;
    }
}

/* JSON Tree Viewer Styles */
.json-viewer {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow: auto;
    position: relative;
}

.json-node {
    position: relative;
}

.json-line {
    position: relative;
    min-height: 20px;
}

.json-line-content {
    display: flex;
    align-items: center;
    min-height: 20px;
    position: relative;
    white-space: nowrap;
    flex-wrap: wrap;
}

.json-toggle {
    cursor: pointer;
    user-select: none;
    color: #858585;
    font-size: 10px;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.json-toggle:hover {
    color: #4ecdc4;
}

.json-toggle::before {
    content: '▶';
    display: inline-block;
    transition: transform 0.2s ease;
}

.json-toggle[data-collapsed="true"]::before {
    transform: rotate(0deg);
}

.json-toggle[data-collapsed="false"]::before {
    transform: rotate(90deg);
}

.json-key {
    color: #9cdcfe;
    font-weight: normal;
}

.json-value {
    color: #ce9178;
}

.json-string {
    color: #ce9178;
}

.json-number {
    color: #b5cea8;
}

.json-boolean {
    color: #569cd6;
}

.json-null,
.json-undefined {
    color: #569cd6;
    font-style: italic;
}

.json-brace,
.json-bracket {
    color: #d4d4d4;
    font-weight: normal;
}

.json-colon {
    color: #d4d4d4;
    margin: 0 4px;
}

.json-comma {
    color: #d4d4d4;
    margin-left: 4px;
}

.json-collapsed-indicator {
    color: #858585;
    font-style: italic;
    margin: 0 8px;
    user-select: none;
    font-size: 11px;
}

.json-children {
    margin-left: 0;
}

.json-children .json-line {
    display: block;
}

/* JSON viewer scrollbar styling */
.json-viewer::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.json-viewer::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.json-viewer::-webkit-scrollbar-thumb {
    background: rgba(78, 205, 196, 0.3);
    border-radius: 4px;
}

.json-viewer::-webkit-scrollbar-thumb:hover {
    background: rgba(78, 205, 196, 0.5);
}

/* ========================================
 * DECK IMPORT COMPONENT STYLES
 * ========================================
 * 
 * Import JSON Overlay Styles
 * Refactored from deck-export.js module
 * ======================================== */
.import-json-textarea {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    padding: 20px;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    border: none;
    outline: none;
    resize: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: auto;
    width: 100%;
    box-sizing: border-box;
}

.import-json-textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.import-error-messages {
    margin: 20px;
    padding: 15px;
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.5);
    border-radius: 8px;
    color: #e74c3c;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

.import-error-messages ul {
    margin: 0;
    padding-left: 20px;
}

.import-error-messages li {
    margin: 8px 0;
}

.import-actions {
    padding: 20px;
    border-top: 1px solid rgba(78, 205, 196, 0.3);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.import-button {
    background: rgba(78, 205, 196, 0.2);
    border: 1px solid rgba(78, 205, 196, 0.4);
    border-radius: 6px;
    padding: 12px 24px;
    color: #4ecdc4;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.import-button:hover:not(:disabled) {
    background: rgba(78, 205, 196, 0.3);
    border-color: rgba(78, 205, 196, 0.6);
}

.import-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Deck Editor Actions - L-shaped layout */
.deck-editor-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 8px 6px !important;
    align-items: start !important;
}

/* Export Button - Top Left - Dark modal styling */
.deck-editor-actions #exportBtn {
    grid-column: 1 !important;
    grid-row: 1 !important;
    background: rgba(78, 205, 196, 0.2) !important; /* teal to match Draw Hand/List View */
    color: #4ecdc4 !important;      /* bright teal text */
    border: 1px solid rgba(78, 205, 196, 0.3) !important; /* teal border */
    height: auto !important;
    min-height: 24px !important;    /* match Save/Cancel buttons */
    padding: 4px 8px !important;    /* match Save/Cancel buttons */
    width: 100% !important;         /* match Save/Cancel buttons */
    box-sizing: border-box !important;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px !important;  /* match Save/Cancel buttons */
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.deck-editor-actions #exportBtn:hover {
    background: rgba(78, 205, 196, 0.3) !important;
    border-color: rgba(78, 205, 196, 0.4) !important;
}

/* Import Button - Same styling as Export Button */
.deck-editor-actions #importBtn {
    grid-column: 1 !important;
    grid-row: 2 !important;
    background: rgba(78, 205, 196, 0.2) !important; /* teal to match Draw Hand/List View */
    color: #4ecdc4 !important;      /* bright teal text */
    border: 1px solid rgba(78, 205, 196, 0.3) !important; /* teal border */
    height: auto !important;
    min-height: 24px !important;    /* match Save/Cancel buttons */
    padding: 4px 8px !important;    /* match Save/Cancel buttons */
    width: 100% !important;         /* match Save/Cancel buttons */
    box-sizing: border-box !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.deck-editor-actions #importBtn:hover {
    background: rgba(78, 205, 196, 0.3) !important;
    border-color: rgba(78, 205, 196, 0.4) !important;
}


/* Save Button - Top Right */
.deck-editor-actions #saveDeckButton {
    grid-column: 2 !important;
    grid-row: 1 !important;
}

/* Cancel Button - Bottom Right */
.deck-editor-actions .cancel-btn {
    grid-column: 2 !important;
    grid-row: 2 !important;
}

/* Responsive design for small screens */
@media (max-width: 700px) {
    .deck-pane, .card-selector-pane {
        min-width: 120px;
    }
    
    .deck-editor-layout.force-two-pane .deck-pane,
    .deck-editor-layout.force-two-pane .card-selector-pane {
        min-width: 120px;
    }
}

@media (max-width: 500px) {
    .deck-pane, .card-selector-pane {
        min-width: 100px;
    }
    
    .deck-editor-layout.force-two-pane .deck-pane,
    .deck-editor-layout.force-two-pane .card-selector-pane {
        min-width: 100px;
    }
}

