.chessboard-container {
    display: flex;
    justify-content: center;
    margin: 10px auto;
    padding: 10px;
    width: 100%;
    max-width: 625px;
    box-sizing: border-box;
}

#chessboard {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Mobile responsive sizing */
@media (max-width: 768px) {
    .chessboard-container {
        width: 100%;
        max-width: 100%;
        padding: 5px;
        margin: 5px auto;
    }

    #chessboard {
        width: calc(100vw - 30px) !important;
        max-width: calc(100vw - 30px) !important;
    }
}

@media (max-width: 480px) {
    .chessboard-container {
        padding: 2px;
        margin: 2px auto;
    }

    #chessboard {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
    }
}

/* Mobile tap-to-move: selected square highlight */
.square-selected {
    background-color: rgba(255, 255, 50, 0.5) !important;
    box-shadow: inset 0 0 0 3px rgba(255, 200, 0, 0.8) !important;
}

/* Mobile tap-to-move: possible move dot (empty squares) - uses background-image to layer on top of square color */
.square-possible-move {
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.25) 24%, transparent 25%) !important;
}

/* Mobile tap-to-move: possible capture ring - uses background-image to layer on top of square color */
.square-possible-capture {
    background-image: radial-gradient(circle, transparent 55%, rgba(0, 0, 0, 0.25) 56%) !important;
}

/* Highlight for AI suggested moves - subtle green highlight */
.highlight-suggestion {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.7) inset !important;
    background-color: rgba(76, 175, 80, 0.25) !important;
    animation: suggestion-fade 3s ease-out forwards;
}

@keyframes suggestion-fade {
    0% {
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.8) inset !important;
        background-color: rgba(76, 175, 80, 0.3) !important;
    }
    70% {
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.6) inset !important;
        background-color: rgba(76, 175, 80, 0.2) !important;
    }
    100% {
        box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4) inset !important;
        background-color: rgba(76, 175, 80, 0.1) !important;
    }
}

/* Notification slide-in animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#notification-container .alert {
    animation: slideIn 0.3s ease-out;
}

.board-with-coords {
    position: relative;
    display: inline-block;
    /* No padding - coordinates are positioned absolutely */
    padding: 0;
    /* Add margin to make room for coordinates */
    margin: 30px 0 30px 30px;
}

.chessboard {
    display: grid;
    /* Grid columns and rows are set dynamically by JavaScript based on board dimensions */
    grid-template-columns: repeat(8, var(--square-size, 60px));
    grid-template-rows: repeat(8, var(--square-size, 60px));
    border: 3px solid #333;
    width: fit-content;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Board coordinates */
.board-coordinate {
    position: absolute;
    font-weight: bold;
    font-size: 14px;
    color: #666;
    user-select: none;
}

.board-coordinate.file {
    bottom: -25px;
    text-align: center;
}

.board-coordinate.rank {
    left: -25px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

.square {
    width: var(--square-size, 60px);
    height: var(--square-size, 60px);
    background-color: #f0d9b5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background-color 0.2s;
}

/* Board size variants */
.chessboard.size-small {
    --square-size: 45px;
}

.chessboard.size-medium {
    --square-size: 60px;
}

.chessboard.size-large {
    --square-size: 75px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chessboard {
        --square-size: 45px;
    }

    .chessboard.size-small {
        --square-size: 35px;
    }

    .chessboard.size-medium {
        --square-size: 45px;
    }

    .chessboard.size-large {
        --square-size: 55px;
    }
}

@media (max-width: 480px) {
    .chessboard {
        --square-size: 35px;
    }

    .chessboard.size-small {
        --square-size: 30px;
    }

    .chessboard.size-medium {
        --square-size: 35px;
    }

    .chessboard.size-large {
        --square-size: 45px;
    }
}

.square.dark {
    background-color: #b58863;
}

.square.drag-over {
    background-color: #7fb3d5;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.square.highlight-from {
    background-color: #f7ec70;
    box-shadow: inset 0 0 8px rgba(255, 200, 0, 0.7);
}

.square.highlight-to {
    background-color: #aaf770;
    box-shadow: inset 0 0 8px rgba(100, 255, 0, 0.7);
}

.piece {
    font-size: calc(var(--square-size, 60px) * 0.67);
    text-align: center;
    cursor: grab;
    user-select: none;
    line-height: 1;
}

.piece.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.piece.white {
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 4px #000;
}

.piece.black {
    color: #000;
    text-shadow: 0 0 2px #fff;
}

/* Move History Styles */
#move-list {
    max-height: 400px;
    overflow-y: auto;
}

.move-row {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
    font-family: monospace;
}

.move-row:last-child {
    border-bottom: none;
}

.move-header {
    font-weight: bold;
    background-color: #f8f9fa;
    padding: 8px 0;
    border-bottom: 2px solid #dee2e6;
}

.move-number {
    font-weight: bold;
    color: #6c757d;
    padding-left: 5px;
}

.move-white, .move-black {
    padding: 0 8px;
}

.coordinate-notation {
    color: #6c757d;
    font-size: 0.85em;
    margin-left: 2px;
}

.move-entry {
    padding: 5px 10px;
    margin: 3px 0;
    background-color: #f8f9fa;
    border-left: 3px solid #007bff;
    font-family: monospace;
}

.pattern-badge {
    display: inline-block;
    background-color: #d1ecf1;
    color: #0c5460;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    margin-left: 4px;
    cursor: help;
    position: relative;
}

.pattern-badge:hover {
    background-color: #bee5eb;
}

.pattern-info-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    background-color: #0c5460;
    color: white;
    font-size: 10px;
    font-weight: bold;
    margin-left: 3px;
    cursor: pointer;
}

/* Tooltip for pattern descriptions */
.pattern-tooltip {
    visibility: hidden;
    width: 300px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.pattern-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.pattern-badge:hover .pattern-tooltip {
    visibility: visible;
    opacity: 1;
}

.captured-piece {
    display: inline-block;
    font-size: 1.2em;
    margin-left: 4px;
    opacity: 0.7;
}

.captured-piece-img {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.8;
}

/* Button Styles */
#suggest-btn:disabled {
    cursor: not-allowed;
}

/* ============================================================================
 * Tabletop Mode - Rotate black pieces 180° so they face the player at the top
 * Used for face-to-face play where device is between two players
 * ============================================================================ */

/* Target black pieces in chessboard library (images with 'b' prefix in filename) */
/* Using multiple selectors to ensure we catch all black pieces */
.tabletop-mode img[src*="/bK"],
.tabletop-mode img[src*="/bQ"],
.tabletop-mode img[src*="/bR"],
.tabletop-mode img[src*="/bB"],
.tabletop-mode img[src*="/bN"],
.tabletop-mode img[src*="/bP"] {
    transform: rotate(180deg) !important;
}

/* Handle pieces inside data-piece containers */
.tabletop-mode [data-piece^="b"] img {
    transform: rotate(180deg) !important;
}

/* Handle dragging pieces that might be outside the board container */
body.tabletop-active img[src*="/bK"],
body.tabletop-active img[src*="/bQ"],
body.tabletop-active img[src*="/bR"],
body.tabletop-active img[src*="/bB"],
body.tabletop-active img[src*="/bN"],
body.tabletop-active img[src*="/bP"] {
    transform: rotate(180deg) !important;
}

/* Tabletop mode indicator badge */
.tabletop-mode-badge {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 10;
}