/* Chess Game Stylesheet */

.chess-app-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}

/* Theme Swatches in Dropdown */
.theme-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,0.2);
}
.emerald-swatch { background: linear-gradient(135deg, #ebecd0 50%, #739552 50%); }
.slate-swatch { background: linear-gradient(135deg, #dee3e6 50%, #8ca2ad 50%); }
.wood-swatch { background: linear-gradient(135deg, #eedab9 50%, #b88b4a 50%); }
.charcoal-swatch { background: linear-gradient(135deg, #e1e1e1 50%, #4e565c 50%); }

.chess-side-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}
.white-dot { background-color: #fff; border: 1px solid #999; }
.black-dot { background-color: #333; border: 1px solid #111; }

/* Player HUDs */
.player-hud {
    max-width: 560px;
}
.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.captured-pieces {
    min-height: 18px;
}
.captured-piece-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    opacity: 0.85;
}
.chess-timer {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 1.15rem;
    font-weight: 700;
    min-width: 75px;
    text-align: center;
    transition: background-color 0.2s, color 0.2s;
}
.chess-timer.active-timer {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.4);
}
.chess-timer.time-warning {
    background-color: #dc3545 !important;
    color: #fff !important;
    animation: fz-timer-pulse 1s infinite alternate;
}
@keyframes fz-timer-pulse {
    from { opacity: 1; }
    to { opacity: 0.6; }
}

/* Chess Board Container */
.chess-board-wrapper {
    position: relative;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    background-color: #2b2b2b;
    padding: 0;
    touch-action: manipulation;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
}

/* Board Themes */
/* Emerald Classic */
.theme-emerald .square-light { background-color: #ebecd0; color: #739552; }
.theme-emerald .square-dark { background-color: #739552; color: #ebecd0; }

/* Slate Blue */
.theme-slate .square-light { background-color: #dee3e6; color: #8ca2ad; }
.theme-slate .square-dark { background-color: #8ca2ad; color: #dee3e6; }

/* Warm Wood */
.theme-wood .square-light { background-color: #eedab9; color: #b88b4a; }
.theme-wood .square-dark { background-color: #b88b4a; color: #eedab9; }

/* Tournament Charcoal */
.theme-charcoal .square-light { background-color: #e1e1e1; color: #4e565c; }
.theme-charcoal .square-dark { background-color: #4e565c; color: #e1e1e1; }

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

/* Coordinates on edge squares */
.square-coord-file,
.square-coord-rank {
    position: absolute;
    font-size: 11px;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
    opacity: 0.8;
}
.square-coord-file {
    bottom: 3px;
    right: 4px;
}
.square-coord-rank {
    top: 3px;
    left: 4px;
}

/* Square Highlight States */
.chess-square.selected-square {
    background-color: #f6f669cc !important;
}
.chess-square.last-move-square {
    background-color: #f5f68280 !important;
}
.chess-square.in-check-square {
    background: radial-gradient(circle, #ff3333ee 0%, #cc0000bb 70%, transparent 100%) !important;
    animation: fz-check-pulse 1.2s infinite ease-in-out alternate;
}
@keyframes fz-check-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

/* Move Indicator Markers */
.move-dest-dot {
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.22);
    pointer-events: none;
    transition: transform 0.15s ease;
}
[data-bs-theme="dark"] .move-dest-dot {
    background-color: rgba(255, 255, 255, 0.35);
}
.chess-square:hover .move-dest-dot {
    transform: scale(1.2);
}

.move-dest-capture {
    position: absolute;
    width: 82%;
    height: 82%;
    border-radius: 50%;
    border: 4px solid rgba(220, 53, 69, 0.6);
    pointer-events: none;
    box-sizing: border-box;
    animation: fz-capture-ring 1s infinite alternate;
}
@keyframes fz-capture-ring {
    0% { transform: scale(0.96); opacity: 0.7; }
    100% { transform: scale(1.02); opacity: 1; }
}

/* Chess Pieces */
.chess-piece {
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: grab;
    transition: transform 0.1s ease;
    z-index: 2;
}
.chess-piece:active {
    cursor: grabbing;
}
.chess-piece svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
    transition: transform 0.12s ease;
}
.chess-piece:hover svg {
    transform: scale(1.08);
}
.chess-piece.dragging {
    opacity: 0.3;
}

/* Floating Drag Element */
.chess-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    width: 60px;
    height: 60px;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.35));
}
.chess-drag-ghost svg {
    width: 100%;
    height: 100%;
}

/* Move History Table */
.chess-move-history {
    max-height: 240px;
    overflow-y: auto;
    font-size: 0.85rem;
}
.move-history-table {
    width: 100%;
}
.move-history-table td {
    padding: 0.25rem 0.5rem;
    vertical-align: middle;
}
.move-history-table tr:hover {
    background-color: var(--bs-tertiary-bg);
}
.move-num-cell {
    width: 40px;
    font-weight: 600;
    color: var(--bs-secondary-color);
}
.move-san-cell {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px !important;
}
.move-san-cell:hover {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary);
}

/* Modals & Overlays */
.promotion-modal-overlay,
.gameover-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fz-fade-in 0.2s ease-out;
}
.promotion-modal-card {
    width: 90%;
    max-width: 360px;
    border-radius: 12px;
}
.gameover-modal-card {
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    animation: fz-pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes fz-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fz-pop-in {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.promotion-btn {
    width: 65px;
    height: 65px;
    border-radius: 8px;
    border: 2px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background-color 0.15s;
    padding: 6px;
}
.promotion-btn:hover {
    transform: translateY(-4px);
    border-color: var(--bs-primary);
    background-color: var(--bs-primary-bg-subtle);
}
.promotion-btn svg {
    width: 100%;
    height: 100%;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chess-board-wrapper {
        max-width: 100%;
    }
    .player-hud {
        max-width: 100%;
    }
    .square-coord-file,
    .square-coord-rank {
        font-size: 9px;
    }
    .chess-timer {
        font-size: 1rem;
        min-width: 65px;
    }
}
