/* Wood Texture Effect for Containers */
#box-container,
#tray-wrapper {
    background: rgba(62, 39, 35, 0.4);
    /* Dark wood tint */
    border: 2px solid #8d6e63;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.scattered-piece {
    position: absolute;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 5;
}

#target-container h2 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#target-preview {
    display: grid;
    gap: 2px;
    width: fit-content;
    justify-content: start;
    /* Size set by JS */
}

.preview-cell {
    width: var(--target-cell-size);
    height: var(--target-cell-size);
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.1);
}

#box-container {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border-radius: 12px;
    width: fit-content;
    /* Hug the grid content, don't expand */
}

#box-grid {
    display: grid;
    gap: var(--grid-gap);
    position: relative;
    /* Grid template columns set by JS */
}

.grid-cell {
    width: var(--grid-cell-size);
    height: var(--grid-cell-size);
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

#tray-wrapper {
    min-height: auto;
    height: auto;
    width: 100%;
    position: relative;
    border-radius: 12px;
    display: flex;
    overflow: hidden;
    flex-shrink: 0;
}

#tray-container {
    min-height: auto;
    height: auto;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    padding: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    --cell-size: 35px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.scroll-hint {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.scroll-hint.visible {
    opacity: 1;
    animation: glow-pulse 2s infinite;
}

.scroll-hint.left {
    left: 0;
    background: linear-gradient(to right, var(--scroll-glow-color), transparent);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.scroll-hint.right {
    right: 0;
    background: linear-gradient(to left, var(--scroll-glow-color), transparent);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Top and bottom scroll hints for vertical tray */
.scroll-hint.top,
.scroll-hint.bottom {
    left: 0;
    right: 0;
    top: auto;
    bottom: auto;
    width: 100%;
    height: 40px;
    display: none;
    /* Hidden by default, shown in ultra-compact mode */
}

.scroll-hint.top {
    top: 0;
    background: linear-gradient(to bottom, var(--scroll-glow-color), transparent);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.scroll-hint.bottom {
    bottom: 0;
    background: linear-gradient(to top, var(--scroll-glow-color), transparent);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Scrollbar styling */
#tray-container::-webkit-scrollbar {
    height: 8px;
}

#tray-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

#tray-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Pieces */
.piece {
    position: absolute;
    /* For dragging */
    display: grid;
    gap: var(--grid-gap);
    cursor: grab;
    transition: transform 0.1s ease, filter 0.2s ease;
    touch-action: none;
    z-index: 10;
}

#tray-container .piece {
    touch-action: pan-x;
}

.piece.dragging {
    cursor: grabbing;
    transform: scale(1.1);
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.4));
    z-index: 1000 !important;
}

.piece-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: width 0.2s ease, height 0.2s ease;

    /* Wood block look */
    background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.05) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0.05) 75%, transparent 75%, transparent);
    background-size: 10px 10px;
}