/* ==========================================
   2180.info - Chessboard Styles
   ========================================== */

.game-layout {
    display: flex;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
}

/* Board Container */
.board-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    overflow: hidden;
    touch-action: none; /* Disable default gestures during drag */
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* Squares */
.square {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
}

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

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

/* Coordinates */
.coordinate {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

.coordinate.file {
    bottom: 2px;
    right: 4px;
}

.coordinate.rank {
    top: 2px;
    left: 4px;
}

.square.light .coordinate {
    color: var(--board-dark);
}

.square.dark .coordinate {
    color: var(--board-light);
}

/* Pieces */
.piece {
    width: 92%;
    height: 92%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: grab;
    z-index: 10;
    transition: transform var(--transition-fast);
}

.piece:active {
    cursor: grabbing;
}

.piece.dragging {
    position: fixed; /* absolute positioning relative to body for dragging */
    z-index: 1000;
    pointer-events: none;
    transform: scale(1.1);
    transition: none; /* Disable transition during drag */
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
}

/* Highlights & Indicators */
.square.selected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(124, 58, 237, 0.35) !important; /* Soft violet overlay */
    z-index: 1;
    pointer-events: none;
}

.square.last-move::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(247, 247, 105, 0.35) !important; /* Soft yellow overlay */
    z-index: 1;
    pointer-events: none;
}

.square.check {
    box-shadow: inset 0 0 20px 5px var(--board-highlight-check);
    animation: check-pulse 1.5s infinite alternate;
}

@keyframes check-pulse {
    0% { box-shadow: inset 0 0 15px 2px rgba(239, 68, 68, 0.4); }
    100% { box-shadow: inset 0 0 25px 8px rgba(239, 68, 68, 0.8); }
}

/* Legal Move Dots */
.legal-dot {
    width: 24%;
    height: 24%;
    border-radius: 50%;
    pointer-events: none;
}

.square.light .legal-dot {
    background-color: var(--board-highlight-legal);
}

.square.dark .legal-dot {
    background-color: var(--board-highlight-legal-dark);
}

/* Capture Indicators on piece squares */
.legal-capture {
    position: absolute;
    width: 80%;
    height: 80%;
    border: 5px solid;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.3;
}

.square.light .legal-capture {
    border-color: var(--board-highlight-legal);
}

.square.dark .legal-capture {
    border-color: var(--board-highlight-legal-dark);
}

/* Promotion Modal */
.promotion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.promotion-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.promotion-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    box-shadow: var(--shadow-premium);
}

.promotion-choice {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    cursor: pointer;
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    transition: all var(--transition-fast);
}

.promotion-choice:hover {
    background-color: var(--color-primary-glow);
    border-color: var(--color-primary);
    transform: scale(1.1);
}

/* Square Move Classification Badges */
.square-classification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    z-index: 15; /* Render above pieces (z-index 10) and selections */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    user-select: none;
}

.square-classification-badge.badge-brilliant { background-color: #1baca6; }
.square-classification-badge.badge-great { background-color: #22ac38; }
.square-classification-badge.badge-best { background-color: #96bc4b; }
.square-classification-badge.badge-book { background-color: #a5753f; color: #ffd8a8; }
.square-classification-badge.badge-good { background-color: #8c8c8c; }
.square-classification-badge.badge-inaccuracy { background-color: #56b4e9; }
.square-classification-badge.badge-mistake { background-color: #e58f2a; }
.square-classification-badge.badge-miss { background-color: #ff3366; }
.square-classification-badge.badge-blunder { background-color: #ca3431; }
