/* Shared full-size chess board styles. Page CSS owns layout around the board. */
.chessboard-container {
    --board-light: #f4e6c8;
    --board-dark: #b58059;
    --board-dark-edge: #5f3f2b;
    --board-accent: var(--color-primary);
    width: 100%;
}

.board-with-coords {
    display: block;
}

.chessboard-wrapper {
    position: relative;
    padding: clamp(10px, 1.7vw, 18px);
    border-radius: 10px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.55)) padding-box,
        linear-gradient(135deg, rgba(249, 115, 22, 0.5), rgba(8, 145, 178, 0.25), rgba(17, 24, 39, 0.2)) border-box;
    border: 1px solid transparent;
    box-shadow: 0 18px 45px rgba(17, 24, 39, 0.16), 0 2px 8px rgba(17, 24, 39, 0.08);
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    aspect-ratio: 1;
    overflow: hidden;
    border: 2px solid var(--board-dark-edge);
    border-radius: 6px;
    background: var(--board-dark-edge);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.chessboard.game-over {
    opacity: 0.55;
    pointer-events: none;
    filter: grayscale(100%);
}

.chess-square {
    aspect-ratio: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    cursor: pointer;
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.chess-square.light {
    background: var(--board-light);
}

.chess-square.dark {
    background: var(--board-dark);
}

.chess-square:hover {
    opacity: 1;
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.08);
}

.chess-square.clicked {
    background: #FDC7A2 !important;
    box-shadow: none;
}

.chess-square.last-move {
    background: #FDC7A2 !important;
    box-shadow: none;
}

.chessboard.game-over .chess-square.last-move {
    background: #FDC7A2 !important;
    box-shadow: none;
}

.chess-piece {
    width: 88%;
    height: 88%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
    cursor: grab;
    filter: drop-shadow(0 5px 4px rgba(17, 24, 39, 0.24));
    transition: transform 120ms ease, filter 120ms ease;
}

.chess-piece:hover {
    filter: drop-shadow(0 7px 6px rgba(17, 24, 39, 0.28));
}

.chess-piece:active {
    cursor: grabbing;
}

.chess-piece img,
.chess-piece-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.file-label,
.rank-label {
    position: absolute;
    z-index: 2;
    font-size: clamp(9px, 1vw, 12px);
    font-weight: var(--font-bold);
    line-height: 1;
    pointer-events: none;
}

.file-label {
    right: 5px;
    bottom: 4px;
}

.rank-label {
    top: 5px;
    left: 5px;
}

.chess-square.light .file-label,
.chess-square.light .rank-label {
    color: rgba(95, 63, 43, 0.72);
}

.chess-square.dark .file-label,
.chess-square.dark .rank-label {
    color: rgba(244, 230, 200, 0.86);
}

.legal-move::after {
    content: '';
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.26);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.legal-capture::after {
    content: '';
    position: absolute;
    inset: 7%;
    border: 4px solid rgba(249, 115, 22, 0.72);
    border-radius: 50%;
    pointer-events: none;
}

.chess-square.drag-over {
    background: #FDC7A2 !important;
    transform: scale(1.025);
    z-index: 3;
}

.piece-animating {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    filter: drop-shadow(0 7px 6px rgba(17, 24, 39, 0.28));
}

@keyframes flashRed {
    0%,
    100% {
        background-color: rgba(239, 68, 68, 0);
    }

    50% {
        background-color: rgba(239, 68, 68, 0.6);
    }
}

.flash-red {
    animation: flashRed 0.5s ease-in-out;
}

.solid-red {
    background-color: rgba(239, 68, 68, 0.5) !important;
}

@media (max-width: 900px) {
    .chessboard-wrapper {
        padding: clamp(7px, 2vw, 12px);
        border-radius: 8px;
    }
}
