* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: #0c0f14;
    color: #e5e7eb;
    line-height: 1.5;
}

.container {
    width: min(1200px, 92%);
    margin: 0 auto;
}

.page-header {
    background: linear-gradient(135deg, #0f172a 0%, #111827 100%);
    color: #ffffff;
    padding: 32px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid #1f2937;
}

.page-header h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.page-header p {
    margin-bottom: 12px;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.card {
    background: #0f172a;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    margin-bottom: 24px;
    border: 1px solid #1f2937;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 8px;
    background: #334155;
    color: #ffffff;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.button.primary {
    background: #2563eb;
}

.button.secondary {
    background: #475569;
}

.button.danger {
    background: #dc2626;
}

.button:hover {
    filter: brightness(1.08);
}

.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.list-item {
    border: 1px solid #1f2937;
    border-radius: 12px;
    padding: 16px;
    background: #111827;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta {
    color: #9ca3af;
    font-size: 14px;
}

.meta-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.save-status {
    font-size: 14px;
    color: #94a3b8;
}

.tier-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tier-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

.tier-form input[type="text"],
.tier-form textarea,
.tier-form select,
.share-row input {
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    background: #0b1220;
    color: #e5e7eb;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 120px 1.5fr 120px;
    gap: 12px;
    align-items: center;
    margin-top: 10px;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert.error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.4);
    color: #fca5a5;
}

.alert ul {
    padding-left: 18px;
    margin-top: 8px;
}

.share-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
}

.tier-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 32px;
}

.commander-pool {
    background: #0f172a;
    border: 1px solid #1f2937;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pool-header h2 {
    font-size: 18px;
    margin-bottom: 0;
}

.pool-header p {
    color: #94a3b8;
    font-size: 14px;
}

.pool-items {
    min-height: 120px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 12px;
    padding: 12px;
}

.upload-label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: #cbd5f5;
}

.tier-board {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tier-row {
    display: flex;
    gap: 8px;
    background: #111827;
    border-radius: 8px;
    border: 1px solid #1f2937;
    padding: 6px;
    min-height: 75px;
    align-items: stretch;
}

.label-holder {
    width: 60px;
    font-weight: 700;
    font-size: 18px;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #334155;
    outline: none;
    padding: 4px;
    text-align: center;
    min-height: 60px;
}

.label-holder:focus {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.6);
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.label-holder .label {
    pointer-events: none;
}

.tier-row[data-tier="1"] .label-holder {
    background: #b91c1c;
}

.tier-row[data-tier="2"] .label-holder {
    background: #c2410c;
}

.tier-row[data-tier="3"] .label-holder {
    background: #ca8a04;
}

.tier-row[data-tier="4"] .label-holder {
    background: #65a30d;
}

.tier-row[data-tier="5"] .label-holder {
    background: #16a34a;
}

.tier-row[data-tier="6"] .label-holder {
    background: #0ea5e9;
}

.tier-row[data-tier="7"] .label-holder {
    background: #2563eb;
}

.tier-row[data-tier="canyon"] .label-holder {
    background: #475569;
}

.tier-row[data-tier="extra"] .label-holder {
    background: #7c3aed;
}

.tier.sort,
.tier-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    flex: 1;
    min-height: 60px;
    padding: 4px;
    border-radius: 8px;
    position: relative;
}

.tier-item-container {
    min-height: 90px;
    border: 2px dashed #334155;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background 0.2s ease;
    position: relative;
}

.tier-item-container.has-item {
    border: 2px dashed transparent;
}

.tier-item-container.drag-over {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.15);
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}


.tier-item.drag-over-item {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.35);
    transform: scale(1.12);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.6), 0 0 20px rgba(37, 99, 235, 0.4);
    z-index: 10;
    animation: swap-pulse 0.6s ease-in-out infinite;
}

@keyframes swap-pulse {
    0%, 100% {
        transform: scale(1.12);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.6), 0 0 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.8), 0 0 30px rgba(37, 99, 235, 0.6);
    }
}

.tier-item-container.drag-over {
    border: 2px dashed #2563eb;
    background: rgba(37, 99, 235, 0.1);
    animation: container-glow 0.8s ease-in-out infinite;
}

@keyframes container-glow {
    0%, 100% {
        border-color: #2563eb;
        background: rgba(37, 99, 235, 0.1);
    }
    50% {
        border-color: #3b82f6;
        background: rgba(37, 99, 235, 0.2);
    }
}

.tier-item.swapping {
    animation: swap-animation 0.4s ease-in-out;
}

@keyframes swap-animation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        transform: scale(1);
    }
}

.tier-item-container.swapping {
    animation: container-swap 0.4s ease-in-out;
}

@keyframes container-swap {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.tier-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 1px solid #1f2937;
    border-radius: 8px;
    background: #0b1220;
    min-width: 90px;
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    position: relative;
    touch-action: pan-y pan-x;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.tier-item span {
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
    padding: 0 2px;
}


.tier-layout.hide-names .tier-item span,
.tier-board.hide-names .tier-item span {
    display: none !important;
}

.tier-layout.hide-names .tier-item,
.tier-board.hide-names .tier-item {
    gap: 0;
}

#toggle-names.show-names {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

#toggle-names.show-names:hover {
    background: #059669;
    border-color: #059669;
}

#toggle-names.hide-names {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

#toggle-names.hide-names:hover {
    background: #dc2626;
    border-color: #dc2626;
}


.tier-item.dragging {
    opacity: 0.8;
    transform: scale(1);
    z-index: 1000;
    cursor: grabbing;
    width: 70px !important;
    height: auto !important;
}

.tier-item.dragging .tier-item-image-wrapper img {
    width: 70px !important;
    height: 70px !important;
}


.tier-item:hover {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.6);
}

.tier-item-image-wrapper {
    position: relative;
    display: inline-block;
}

.tier-item-image-wrapper img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #1f2937;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}


.settings-control {
    width: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-left: 1px solid #1f2937;
    padding-left: 8px;
}

.toggle-tier {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    color: #cbd5f5;
    flex-shrink: 0;
}

.toggle-tier:hover {
    background: #334155;
    border-color: #475569;
    transform: scale(1.1);
}

.toggle-tier:active {
    transform: scale(0.95);
}

.toggle-tier .toggle-icon {
    transition: transform 0.3s ease;
}

.tier-row.collapsed .toggle-tier .toggle-icon {
    transform: rotate(-90deg);
}

.tier-row:not(.collapsed) .toggle-tier .toggle-icon {
    transform: rotate(0deg);
}

.tier-row {
    transition: min-height 0.3s ease, padding 0.3s ease, gap 0.3s ease;
}

.tier-row.tier-hidden {
    display: none;
}

.add-tier-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid #1f2937;
}

.add-tier-button {
    background: #334155;
    border: 2px solid #334155;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.add-tier-button:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.add-tier-button.active {
    opacity: 0.7;
}

.add-tier-button.active::after {
    content: ' ✓';
}

.tier-row.collapsed .tier.sort {
    display: none;
}

.tier-row.collapsed .settings-control .settings,
.tier-row.collapsed .settings-control .move-buttons {
    display: none;
}

.tier-row.collapsed .settings-control .search-commander {
    display: flex;
}

.tier-row.collapsed {
    min-height: 60px;
    padding: 4px 6px;
    gap: 8px;
}

.tier-row.collapsed .label-holder {
    flex: 1;
    min-height: 50px;
    border-radius: 6px;
}

.tier-row.collapsed .settings-control {
    width: 32px;
    border-left: none;
    padding-left: 0;
    gap: 0;
}

.search-commander {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    color: #cbd5f5;
    flex-shrink: 0;
}

.search-commander:hover {
    background: #334155;
    border-color: #475569;
    transform: scale(1.1);
}

.search-commander:active {
    transform: scale(0.95);
}

.search-commander-item {
    cursor: pointer;
    padding: 8px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #1e293b;
    transition: all 0.2s ease;
    text-align: center;
}

.search-commander-item:hover {
    background: #334155;
    border-color: #475569;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.4);
    transform: none;
}

.search-commander-item img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 6px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: filter 0.2s ease;
}

.search-commander-item:hover img {
    filter: brightness(1.2);
}

.search-commander-item span {
    color: #f8fafc;
    font-size: 12px;
    display: block;
}

.settings,
.move-up,
.move-down {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0b1220;
    color: #e5e7eb;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.settings:hover,
.move-up:hover,
.move-down:hover {
    background: #1f2937;
}

.settings {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
}

.move-up {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2'%3E%3Cpath d='M18 15l-6-6-6 6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
}

.move-down {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
}

.move-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty {
    color: #64748b;
    font-style: italic;
}

.tier-item-container.filter-hidden {
    display: none;
}

.filter-modal-content {
    width: min(560px, 94%);
}

.filter-group {
    margin-bottom: 18px;
}

.filter-group h3 {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 10px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    border: 1px solid #334155;
    background: #111827;
    color: #e5e7eb;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.filter-chip:hover {
    border-color: #64748b;
}

.filter-chip.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.js-open-filter.has-filters {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #0f172a;
    border: 1px solid #1f2937;
    border-radius: 16px;
    padding: 24px;
    width: min(720px, 94%);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-header h2 {
    margin: 0;
    color: #f8fafc;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
    background: #1f2937;
    color: #f8fafc;
}

.modal-help {
    margin: 12px 0 16px;
    color: #94a3b8;
    font-size: 14px;
}

.tier-settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 6px;
}

.tier-settings-row {
    display: grid;
    grid-template-columns: 1fr 90px 1fr;
    gap: 10px;
    align-items: center;
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 12px;
    padding: 12px;
}

.tier-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.tier-input {
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 8px;
    background: #0b1220;
    color: #e5e7eb;
}

.tier-color {
    height: 40px;
    border-radius: 8px;
    border: 1px solid #1f2937;
    background: #0b1220;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

@media (max-width: 720px) {
    .item-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .share-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tier-row {
        flex-direction: column;
    }

    .label-holder {
        width: 100%;
    }

    .tier.sort,
    .tier-items {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tier-item-container {
        min-height: 120px;
        min-width: auto;
        width: 100%;
    }

    .tier-item {
        min-width: auto;
        width: 100%;
    }
    
    .tier-item span {
        font-size: 10px;
        max-width: 100%;
    }

    .tier-item-image-wrapper img {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }


    .settings-control {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        border-left: none;
        border-top: 1px solid #1f2937;
        padding-left: 0;
        padding-top: 8px;
    }

    .move-buttons {
        flex-direction: row;
    }
}
