:root {
    --primary: #2c3e50;
    --secondary: #7f8c8d;
    --accent: #e74c3c;
    --light: #ecf0f1;
    --dark: #34495e;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #c0392b;
    --info: #3498db;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 10px;
    font-size: 14px;
	overflow-x: hidden;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    padding: 12px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-group {
    flex: 1;
    min-width: 180px;
}

.player-filter-group > div:not(.player-suggestions) {
    display: flex;
    gap: 5px;
    align-items: flex-end;
}

.player-filter-group input {
    flex: 1;
    min-width: 250px;
}

/* Player filter row */
.player-filter-row {
    display: flex;
    gap: 5px;
}

.player-filter-input {
    flex: 1;
}

/* Quick filter button already has .quick-filter-btn; 
   but we removed its inline height/align-self – 
   ensure .quick-filter-btn includes these properties */
.quick-filter-btn {
    height: 30px;
    align-self: flex-end;
    /* keep any existing properties */
}

/* Sort group label container */
.sort-group-label {
    flex: 1;
}

/* Sort direction buttons container */
.sort-direction-buttons {
    display: flex;
    gap: 4px;
}

/* Share buttons row */
.share-buttons-row {
    display: flex;
    gap: 8px;
}

/* Individual share buttons */
.share-btn.share-link {
    margin-top: 6px;
    white-space: nowrap;
}

.share-btn.help-btn {
    margin-top: 6px;
    flex: 1;
}

/* Range tag info text */
.range-tag-info {
    margin-top: 5px;
    font-size: 0.7rem;
    color: #666;
}

/* Hidden class for elements initially hidden (used by activeFilters, variantCount) */
.hidden {
    display: none !important;
}

/* Centered modal header */
.modal-header-centered {
    text-align: center;
}

.sort-group {
    flex: 1;
    min-width: 140px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.sort-direction {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sort-btn {
    padding: 6px;
    border: 1px solid #ddd;
    background-color: #f8f8f8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-btn.active {
    background-color: var(--info);
    color: white;
    border-color: var(--info);
}

label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: var(--dark);
    font-size: 0.85rem;
}

select, input, textarea {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

textarea {
    min-height: 60px;
    resize: vertical;
}

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    padding: 12px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 200px;
    height: auto;
}

.tag-filter-group {
    flex: 1;
    min-width: 180px;
}

.tag-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.tag-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tag-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tag-btn.active {
    font-weight: bold;
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.tag-weapon { background-color: var(--info); color: white; }
.tag-equipment { background-color: var(--warning); color: white; }
.tag-range { background-color: var(--success); color: white; }
.tag-type { background-color: var(--primary); color: white; }
.tag-tech { background-color: var(--secondary); color: white; }
.tag-engine { background-color: var(--danger); color: white; }

.assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    overflow: visible;
}

.asset-card {
    background-color: white;
    border-radius: 6px;
    overflow: visible;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.asset-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
	z-index: 100;
}

.asset-header {
    background-color: var(--primary);
    color: white;
    padding: 12px;
}

.asset-name {
    font-size: 0.95rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.asset-variant {
    font-size: 0.75rem;
    opacity: 0.95;
}

.asset-body {
    padding: 12px;
    overflow: visible;
}

.asset-details {
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.detail-label {
    font-weight: bold;
    color: var(--dark);
    font-size: 0.8rem;
}

.detail-value {
    font-size: 0.8rem;
}

.equipment-list {
    overflow: visible !important;
}

.weapons-list {
    margin-top: 8px;
    overflow: visible !important;
}

.weapon-item {
    padding: 3px 0;
    border-bottom: 1px dashed #eee;
    font-weight: bold;
    font-size: 0.75rem;
}

.weapon-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    overflow: visible !important;
}

.weapons-list .weapon-tag:first-child {
    font-weight: bold;
    padding: 3px 16px;
    background-color: #3571a2;
}

.equipment-list .weapon-tag {
    background-color: #99879e;
}

.equipment-list .weapon-tag:first-child {
    font-weight: normal;
    padding: 2px 6px;
    background-color: #99879e;
}

.weapon-tag.active {
    background-color: var(--danger) !important;
    font-weight: bold;
}

.weapon-tag {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    background-color: var(--info);
    color: white;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.weapon-tag:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.tag {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    background-color: var(--secondary);
    color: white;
    white-space: nowrap;
}

.tag-range-short { background-color: var(--danger); }
.tag-range-medium { background-color: var(--warning); }
.tag-range-long { background-color: var(--success); }
.tag-range-extreme { background-color: #8e44ad; }
.tag-type-mech { background-color: var(--primary); }
.tag-type-vehicle { background-color: #16a085; }
.tag-type-vtol { background-color: #8e44ad; }
.tag-type-aerospace { background-color: #d35400; }
.tag-type-battlearmor { background-color: #27ae60; }

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-controls-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    height: auto;
}

.active-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background-color: #eaf7ff;
    border-radius: 4px;
    font-size: 0.75rem;
    max-height: 120px;
    overflow-y: auto;
    min-height: 30px;
}

.active-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.active-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    background-color: var(--info);
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    height: fit-content;
    flex-shrink: 0;
}

.active-filter button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
}

.share-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}

.share-btn {
    padding: 6px 12px;
    background-color: var(--info);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.85rem;
}

.share-btn:hover {
    background-color: #2980b9;
}

.loading {
    text-align: center;
    padding: 30px;
    font-size: 1rem;
}

.scrollable-tags {
    max-height: 240px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-top: 5px;
}

.search-help {
    margin-top: 5px;
    font-size: 0.75rem;
    color: #666;
}

.search-examples {
    margin-top: 5px;
    font-size: 0.7rem;
    color: #888;
}

.variant-count {
    margin-bottom: 0;
    padding: 6px;
    background-color: white;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
    font-size: 0.8rem;
    border: 1px solid #eee;
    min-height: 20px;
    height: auto;
}

/* Player purchase modal */
.player-purchase-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none; /* Start hidden */
}

.player-purchase-modal .modal-content {
    overflow-x: auto;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Ensure modal content can scroll horizontally if needed */
.modal-content {
    padding: 20px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.player-list {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.player-list th,
.player-list td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.player-list th {
    background-color: #f8f9fa;
    font-weight: bold;
    text-align: left;
}

.player-list th:nth-child(2),
.player-list th:nth-child(3),
.player-list th:nth-child(4) {
    text-align: center;
}

.player-list td:nth-child(2),
.player-list td:nth-child(3),
.player-list td:nth-child(4) {
    text-align: center;
}

.player-list th {
    cursor: pointer;
    user-select: none;
}

.player-list th:hover {
    background-color: #e9ecef;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align items to top */
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    gap: 10px; /* Add gap between elements */
}

.player-name {
    flex-shrink: 0; /* Don't shrink the name */
    min-width: 120px; /* Ensure name has enough space */
}

.player-name-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.player-name:hover {
    text-decoration: underline;
    color: #2980b9;
}

.player-count {
    flex-shrink: 0; /* Don't shrink the count */
    min-width: 60px; /* Ensure count has enough space */
}

.player-purchase-count {
    color: #FF7263;
    font-weight: bold;
    margin-left: 4px;
}        

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Purchase count clickable style */
.purchase-count {
    cursor: pointer;
    text-decoration: underline;
    color: var(--info);
    transition: color 0.2s;
}

.purchase-count:hover {
    color: #2980b9;
}

.purchase-rank {
    color: #D1DEDE;
    font-size: 0.7rem;
    margin-left: 4px;
}

.quick-filter-btn {
    height: 30px;
    align-self: flex-end;
}

.quick-filter-btn:hover {
    background-color: #2980b9;
}

.partial-match-toggle {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.partial-match-toggle input {
    width: auto;
    margin-right: 5px;
}

.partial-match-toggle label {
    font-weight: normal;
    font-size: 0.8rem;
}


.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.75rem;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    white-space: normal;
    width: 200px;
    bottom: 100%;
    left: 50%;
    transform: translateX(-30%);
    margin-bottom: 8px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.tooltip .tooltiptext::after {
    display: none;
}

.weapon-composition {
    margin-top: 10px;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.weapon-composition-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.75rem;
    border-bottom: 1px dotted #eee;
}

.weapon-name {
    font-weight: bold;
    font-size: 0.7rem;
    color: #2c3e50;
}

.weapon-percentage {
    color: #e74c3c;
    font-weight: bold;
}

.property-summary {
    margin-top: 10px;
}

.property-category {
    margin-bottom: 8px;
    padding: 5px;
    background-color: #f0f0f0;
    border-radius: 3px;
}

.property-category-title {
    font-weight: bold;
    color: #34495e;
    font-size: 0.75rem;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
}

.property-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 0.7rem;
}

.property-name {
    color: #2c3e50;
}

.property-percentage {
    color: #c0392b;
    font-weight: bold;
}

.player-preference {
    font-size: 0.7rem;
    color: #666;
    margin-left: 10px;
    font-style: italic;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    flex: 1; /* Take available space */
    min-width: 1000px; /* Ensure minimum width */
    text-align: right; /* Align to right */
}

.preference-summary {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    border-left: 4px solid #3498db;
}

.preference-summary h4 {
    margin: 0 0 5px 0;
    color: #2c3e50;
}

.preference-summary p {
    margin: 0;
    font-size: 0.8rem;
    color: #7f8c8d;
}

/* Add styles for player suggestions dropdown */
.player-suggestions {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto; /* Ensure vertical scrollbar appears when needed */
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    z-index: 1000;
    width: 15%; /* Adjust width to account for filter button */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
}

.player-suggestion {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.player-suggestion:hover {
    background-color: #f5f5f5;
}

.player-suggestion:last-child {
    border-bottom: none;
}

.player-filter-container {
    position: relative;
}

.tag-common { background-color: var(--success); color: white; }

.back-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 16px;
    background-color: var(--info);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-size: 1rem;
    font-weight: bold;
}

.back-link:hover {
    background-color: #2980b9;
}

.tag-btn.and-mode {
    border: 3px solid var(--warning);
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(243, 156, 18, 0.4);
}

.tag-btn.not-mode {
    border: 3px solid var(--danger);
    text-decoration: line-through;
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(192, 57, 43, 0.4);
    opacity: 0.9;
}

.tag-common.active {
    font-weight: bold;
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(39, 174, 96, 0.4);
    border: 2px solid white;
}

@media (max-width: 768px) {
    body {
        padding: 8px;
        font-size: 13px;
    }
    
    .controls, .tag-filters {
        flex-direction: column;
    }
    
    .sort-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sort-direction {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .assets-grid {
        grid-template-columns: 1fr;
    }
    
    .tag-btn {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
    
    .asset-card {
        font-size: 0.8rem;
    }
    
    /* Ensure modal is above everything */
    .player-purchase-modal, .modal-overlay {
        z-index: 1001;
    }
    
    .tooltip .tooltiptext {
        width: 180px;
        font-size: 0.7rem;
    }
}

@media (min-width: 1200px) {
    .assets-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (min-width: 1600px) {
    .assets-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}