/* Chess Board Container */
.chess-board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.chess-board-container {
    position: relative;
    display: inline-block;
    padding: 20px;
}

/* Chess Board - Larger size */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(90vw, 560px);
    aspect-ratio: 1;
    border: 3px solid var(--bs-dark);
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    user-select: none;
}

[data-bs-theme="dark"] .chess-board {
    border-color: var(--bs-gray-600);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Board Coordinates */
.board-coordinates {
    position: absolute;
    display: flex;
    pointer-events: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--bs-secondary);
}

.coords-left,
.coords-right {
    flex-direction: column;
    justify-content: space-around;
    top: 20px;
    bottom: 20px;
}

.coords-left {
    left: 4px;
    text-align: right;
}

.coords-right {
    right: 4px;
    text-align: left;
}

.coords-top,
.coords-bottom {
    flex-direction: row;
    justify-content: space-around;
    left: 20px;
    right: 20px;
}

.coords-top {
    top: 4px;
}

.coords-bottom {
    bottom: 4px;
}

.board-coordinates span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12.5%;
}

.coords-left span,
.coords-right span {
    width: auto;
    height: 12.5%;
}

/* Chess Square */
.chess-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.chess-square.light {
    background-color: #f0d9b5;
}

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

[data-bs-theme="dark"] .chess-square.light {
    background-color: #ababab;
}

[data-bs-theme="dark"] .chess-square.dark {
    background-color: #6b6b6b;
}

/* Square States */
.chess-square.selected {
    background-color: #829769 !important;
}

.chess-square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

.chess-square.legal-capture::after {
    content: '';
    position: absolute;
    width: 90%;
    height: 90%;
    border: 4px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    background: transparent;
}

.chess-square.last-move {
    background-color: #cdd26a !important;
}

[data-bs-theme="dark"] .chess-square.last-move {
    background-color: #a8a840 !important;
}

.chess-square.check {
    background: radial-gradient(circle, #ff6b6b 0%, #ff6b6b 25%, transparent 60%),
                linear-gradient(to bottom, #f0d9b5 0%, #f0d9b5 100%);
}

.chess-square.dark.check {
    background: radial-gradient(circle, #ff6b6b 0%, #ff6b6b 25%, transparent 60%),
                linear-gradient(to bottom, #b58863 0%, #b58863 100%);
}

.chess-square.hint {
    box-shadow: inset 0 0 0 4px #4CAF50;
}

/* Chess Piece */
.chess-piece {
    font-size: calc(min(90vw, 560px) / 10);
    line-height: 1;
    cursor: grab;
    transition: transform 0.1s ease;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

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

.chess-piece.white-piece {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 1px rgba(0, 0, 0, 0.8);
}

.chess-piece.black-piece {
    color: #1a1a1a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
}

.chess-piece.dragging {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transform: scale(1.1);
    opacity: 0.9;
}

.chess-square.drag-over {
    background-color: #aaa23a !important;
}

/* Player Info */
.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bs-tertiary-bg);
    border-radius: 8px;
    width: min(90vw, 560px);
    box-sizing: border-box;
}

.player-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 24px;
    flex-shrink: 0;
}

.player-avatar.white-player {
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.player-avatar.black-player {
    background: linear-gradient(135deg, #4a4a4a 0%, #1a1a1a 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-info.active-turn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: #fff;
}

/* Thinking Badge */
.thinking-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    background: var(--bs-warning);
    color: #000;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

.player-info.active-turn .thinking-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Captured pieces inline */
.captured-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 1.1rem;
    margin-left: auto;
    min-height: 24px;
}

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

.captured-inline .black-piece {
    color: #1a1a1a;
}

/* Game Info Bar */
.game-info-bar {
    background: var(--bs-tertiary-bg);
    border-radius: 8px;
    padding: 12px 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.material-info {
    flex-direction: column;
    gap: 4px;
}

/* Status Dot */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.white-turn {
    background: linear-gradient(135deg, #fff 0%, #ccc 100%);
    border: 2px solid #999;
}

.status-dot.black-turn {
    background: linear-gradient(135deg, #4a4a4a 0%, #1a1a1a 100%);
    border: 2px solid #333;
}

.status-dot.game-over {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    border: 2px solid #d32f2f;
}

/* Material Advantage Bar */
.material-bar {
    height: 8px;
    width: 120px;
    background: linear-gradient(to right, #1a1a1a 50%, #fff 50%);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
}

.material-indicator {
    height: 100%;
    background: #4CAF50;
    transition: width 0.3s ease;
}

/* Move History Details */
.move-history-details {
    background: var(--bs-tertiary-bg);
    border-radius: 8px;
    overflow: hidden;
}

.move-history-summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}

.move-history-summary:hover {
    background: var(--bs-secondary-bg);
}

.move-history-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.move-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.move-number {
    font-weight: 600;
    color: var(--bs-secondary);
    font-size: 0.875rem;
    min-width: 24px;
}

.move-white,
.move-black {
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-family: monospace;
    font-size: 0.9rem;
}

.move-white:hover,
.move-black:hover {
    background: var(--bs-primary);
    color: #fff;
}

/* Promotion Modal */
.promotion-pieces {
    padding: 10px 0;
}

.promotion-piece {
    font-size: 3rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.promotion-piece:hover {
    background: var(--bs-primary);
    transform: scale(1.1);
}

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

.promotion-piece.black-piece {
    color: #1a1a1a;
}

/* Game Over Modal */
.game-over-icon {
    font-size: 5rem;
    line-height: 1;
}

/* Chess piece icon in buttons */
.chess-piece-icon {
    font-size: 1.1em;
    line-height: 1;
}

/* Responsive */
@media (max-width: 576px) {
    .chess-board-container {
        padding: 16px;
    }

    .chess-piece {
        font-size: calc(90vw / 11);
    }

    .player-info {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .player-avatar {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }

    .captured-inline {
        font-size: 0.9rem;
    }

    .board-coordinates {
        font-size: 10px;
    }
}

/* Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.thinking-indicator {
    animation: pulse 1s infinite;
}

/* Board flip animation */
.chess-board.flipped {
    transform: rotate(180deg);
}

.chess-board.flipped .chess-piece {
    transform: rotate(180deg);
}

.chess-board.flip-animation {
    transition: transform 0.4s ease;
}
