html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    background: #2c2c2c;
    color: white;
    font-family: sans-serif;
    user-select: none;
}

.top-bar {
    margin-bottom: 20px;
    margin-left: 40px;
}

.top-bar h1 {
    margin: 0;
    font-size: 24px;
}

.main-layout {
    display: flex;
    gap: 40px;
    min-width: 0;
    max-width: 100%;
    margin-left: 40px;
}

.left-panel {
    width: 516px;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.inventory-heading {
    width: 100%;
    margin: 0.83em 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.inventory-stage {
    position: relative;
    width: 516px;
    height: 388px;
    max-width: 100%;
}

.inventory-heading h2 {
    margin: 0;
}

.inventory-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}

.inventory-action-button {
    padding: 8px 12px;
    border: 1px solid #999;
    background: #3a3a3a;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.inventory-action-button:hover {
    border-color: #ffd83d;
    background: #554d2f;
}

#clearInventory:hover {
    border-color: #ff7777;
    background: #643737;
}

.right-panel.shop-collapsed .tabs,
.right-panel.shop-collapsed .shop-viewport,
.right-panel.shop-collapsed .data-status {
    display: none;
}

#inventory {
    position: relative;
    width: 512px;
    height: 384px;
    border: 2px solid white;
    background:
        linear-gradient(#555 1px, transparent 1px),
        linear-gradient(90deg, #555 1px, transparent 1px);
    background-size: 64px 64px;
    overflow: visible;
    transform-origin: top left;
}

#inventory.shop-drag-over {
    border-color: #ffd83d;
    box-shadow: 0 0 0 2px rgba(255, 216, 61, 0.28);
}

#inventory.item-drag-active {
    z-index: 1000;
}

.shop-drop-preview {
    position: absolute;
    display: none;
    opacity: 0.48;
    pointer-events: none;
    z-index: 100;
}

.shop-drop-preview.visible {
    display: block;
}

.shop-drop-preview img {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

.player-haste-control {
    width: 100%;
    box-sizing: border-box;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #777;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-weight: 700;
}

.player-haste-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

#playerHaste {
    width: 82px;
    padding: 7px 8px;
    border: 1px solid #999;
    background: #222;
    color: white;
    font: inherit;
    text-align: right;
}

.stat-value.stat-value-buff {
    color: #62e875;
}

.stat-value.stat-value-debuff {
    color: #ff6262;
}

.right-panel {
    width: 430px;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#searchBox {
    padding: 10px;
    font-size: 16px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.tabs button {
    padding: 8px 16px;
    cursor: pointer;
}

.tabs button.active {
    background: gold;
    border: 2px solid white;
}

.shop-viewport {
    position: relative;
    margin-top: 10px;
    height: 280px;
}

#shop {
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    border: 1px solid #777;
    padding: 8px;
    background: #333;
}

#shop.item-return-active {
    border: 2px dashed #ff8585;
}

.shop-return-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(75, 18, 27, 0.86);
    color: #ffd9d9;
    font-size: 18px;
    font-weight: 800;
    text-align: center;
    pointer-events: none;
    z-index: 200;
}

#shop.item-return-active + .shop-return-overlay {
    display: flex;
}

#shop.item-return-hover + .shop-return-overlay {
    background: rgba(130, 27, 42, 0.93);
    color: white;
}

.shop-item {
    width: 64px;
    height: 64px;
    border: 1px solid white;
    background: #444;
    cursor: grab;
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shop-item:hover {
    background: #555;
}

.shop-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.item {
    position: absolute;
    cursor: grab;
    overflow: visible;
    pointer-events: none;
    touch-action: none;
}

.shop-item.dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.item.selected {
    z-index: 20;
}

.rotate-box {
    position: absolute;
    left: 0;
    top: 0;
    overflow: visible;
    z-index: 2;
    transition: transform 0.12s ease-out;
}

.sprite {
    position: absolute;
    left: 0;
    top: 0;
    overflow: visible;
    z-index: 2;
}

.sprite img {
    pointer-events: none;
    display: block;
}

.socket-layer {
    position: absolute;
    left: 0;
    top: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 10;
}

.socket-icon {
    position: absolute;
    width: 38px;
    height: 38px;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    justify-content: center;
}

.hit-layer {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 20;
}

.hit-cell {
    position: absolute;
    width: 64px;
    height: 64px;
    pointer-events: auto;
    touch-action: none;
}

@media (max-width: 760px) {
    body {
        padding: 12px;
    }

    .top-bar {
        margin: 0 0 12px;
    }

    .top-bar h1 {
        font-size: 20px;
    }

    .main-layout {
        margin: 0;
        gap: 20px;
        flex-direction: column;
        align-items: stretch;
    }

    .left-panel,
    .right-panel {
        width: 100%;
    }

    .inventory-heading {
        margin-top: 0.45em;
    }

    .inventory-action-button {
        padding: 10px 12px;
        min-height: 44px;
    }

    .tabs {
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .tabs button {
        flex: 0 0 auto;
        min-height: 44px;
    }

    .shop-viewport {
        height: 240px;
    }

    .shop-item {
        width: 68px;
        height: 68px;
    }
}

.socket-icon img {
    width: 38px;
    height: 38px;
    image-rendering: pixelated;
}

.item.selected .socket-icon {
    display: flex;
}

#itemInfo {
    margin-top: 16px;
    padding: 14px;
    min-height: 180px;
    border: 2px solid #7650a5;
    background: #17121f;
}

#itemInfo h3 {
    margin: -14px -14px 14px;
    padding: 10px 14px;
    color: white;
    background: #482071;
}

#itemInfo p {
    margin: 8px 0;
    line-height: 1.4;
}

.empty-info {
    color: #aaa;
}

.item-description {
    min-height: 42px;
    color: #f3e8ff;
    white-space: pre-line;
}

.stat-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 14px 0;
}

.stat-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    color: #eee;
}

.stat-label {
    min-width: 48px;
    font-weight: bold;
}

.stat-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    image-rendering: pixelated;
}

.stat-value {
    min-width: 0;
    overflow: hidden;
    color: white;
    font-weight: bold;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-colon {
    color: #bba7c8;
    font-weight: bold;
}

.tag-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #4d315f;
    overflow-x: auto;
    white-space: nowrap;
}

.tag-label {
    flex: 0 0 auto;
    color: #b9a7c8;
    font-weight: bold;
}

.tag-list {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #f4c9e8;
    font-weight: bold;
}

.tag-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    background: #f13cb2;
    image-rendering: pixelated;
    -webkit-mask: var(--tag-icon) center / contain no-repeat;
    mask: var(--tag-icon) center / contain no-repeat;
}

.tag-separator {
    color: #b9a7c8;
}

.synergy-inline {
    width: 16px;
    height: 16px;
    margin: 0 2px;
    vertical-align: -4px;
    image-rendering: pixelated;
}

.description-status-icon {
    width: 17px;
    height: 17px;
    margin-right: 3px;
    vertical-align: -3px;
    image-rendering: pixelated;
}

.status-token {
    white-space: nowrap;
}

.description-trigger {
    color: #ffe0a8;
    font-weight: bold;
}

.description-value,
.synergy-trigger {
    color: #ffd83d;
    font-weight: bold;
}

.description-custom-color {
    font-weight: bold;
}

.socket-summary {
    color: #c9b2db;
}

.active-effect {
    color: gold;
    font-weight: bold;
}

.selection-layer {
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    pointer-events: none;
    z-index: 8;
}

.item.selected .selection-layer {
    display: block;
}

.selection-cell {
    position: absolute;
    width: 64px;
    height: 64px;
    box-sizing: border-box;
}

.selection-cell.edge-top {
    border-top: 3px solid gold;
}

.selection-cell.edge-right {
    border-right: 3px solid gold;
}

.selection-cell.edge-bottom {
    border-bottom: 3px solid gold;
}

.selection-cell.edge-left {
    border-left: 3px solid gold;
}

.data-status {
    margin: 8px 0 0;
    color: #aaa;
    font-size: 13px;
}

.data-status.error {
    color: #ff9b9b;
}

.empty-shop {
    margin: auto;
    color: #aaa;
}
