/* Chess Window Styling */
.chess-window {
    width: 1000px;
    height: 700px;
    min-width: 800px;
    min-height: 600px;
    background: rgb(33, 33, 33);
    backdrop-filter: none;
    border: 1px solid #404040;
}

.chess-window.fullscreen {
    width: 100vw !important;
    height: calc(100vh - 32px) !important;
    min-width: unset !important;
    min-height: unset !important;
    position: fixed !important;
    top: 32px !important;
    left: 0 !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
}

.chess-window .title-bar {
    background: rgb(62, 62, 62);
    border-bottom: 1px solid #404040;
}

/* Title text uses standard finder-window focus logic from window-frame.css */
.chess-window.focused .title-text {
    color: #ffffff;
    font-weight: 600;
}

.chess-window:not(.focused) .title-text {
    color: rgb(112, 112, 112);
    font-weight: 600;
}

/* Traffic lights are handled by window-frame.css since chess-window inherits from finder-window */

.chess-content {
    padding: 0;
    background: rgb(33, 33, 33);
    height: calc(100% - 32px);
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.chess-layout {
    display: flex;
    flex: 1;
    gap: 20px;
    padding: 20px;
    align-items: center; /* Center vertically */
}

/* Chess Board Container (on left) */
.chess-board-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 520px; /* Ensure board fits */
    height: 100%; /* Take full height of parent */
}

.chess-board {
    width: 520px;
    height: 520px;
    background-image: url('../assets/chess/chessboard.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    border: 2px solid #404040;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
}

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

/* Coordinate markers inside squares */
.chess-square .file-coordinate {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 5;
}

.chess-square .rank-coordinate {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 5;
}

/* All coordinates default to dark square color */
.chess-square .file-coordinate,
.chess-square .rank-coordinate {
    color: rgb(235, 236, 208); /* Dark squares - default */
}

/* Light square coordinates - apply after JavaScript determines square color */
.chess-square.light-square .file-coordinate,
.chess-square.light-square .rank-coordinate {
    color: rgb(115, 149, 82); /* Light squares */
}

.chess-square.highlighted {
    background-color: rgba(255, 255, 0, 0.3);
}

.chess-square.possible-move {
    background-color: rgba(0, 255, 0, 0.2);
}

.chess-square.possible-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(0, 255, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
}

.chess-square.capture-move {
    background-color: rgba(0, 255, 0, 0.2);
}

.chess-square.capture-move::after {
    background: rgba(255, 0, 0, 0.6);
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 3px solid rgba(255, 0, 0, 0.8);
    box-sizing: border-box;
    z-index: 3;
}

.chess-square.drag-over {
    background-color: rgba(0, 150, 255, 0.3);
}

.chess-piece {
    width: 85%;
    height: 85%;
    object-fit: contain;
    pointer-events: auto;
    transition: transform 0.2s ease;
    z-index: 10;
    cursor: grab;
}

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

.chess-piece.dragging {
    /* All positioning and sizing handled by JavaScript to avoid conflicts */
    cursor: grabbing !important;
    transition: none !important; /* Disable any transition effects during drag */
}

.chess-square.selected {
    background-color: rgba(255, 255, 0, 0.5);
}

.chess-square.last-move {
    background-color: rgba(255, 255, 0, 0.2);
}

/* Info Panel (on right) */
.chess-info-panel {
    width: 280px;
    flex-shrink: 0;
    background: #252525;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #404040;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-self: stretch; /* Take available height */
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #2a2a2a;
    border-radius: 8px;
    border: 1px solid #404040;
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.player-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
}

.info-icon-container {
    display: flex;
    align-items: center;
}

.info-icon {
    color: #888888;
    font-size: 16px;
    cursor: help;
    transition: color 0.2s ease;
}

.info-icon:hover {
    color: #ffffff;
}

.player-rating {
    color: #aaaaaa;
    font-size: 12px;
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-btn {
    padding: 10px 16px;
    background: #333333;
    border: 1px solid #555555;
    border-radius: 6px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #404040;
    border-color: #666666;
}

.control-btn:active {
    background: #2a2a2a;
    transform: translateY(1px);
}

/* Ensure control buttons remain active even when game is over */
.control-btn:disabled {
    background: #222222;
    border-color: #444444;
    color: #666666;
    cursor: not-allowed;
}

/* Override any potential disabled appearance for undo button */
#undo-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Move History */
.move-history {
    flex-grow: 1;
    min-height: 350px;
}

.move-history h3 {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px 0;
    border-bottom: 1px solid #404040;
    padding-bottom: 8px;
}

.move-list {
    max-height: 350px;
    overflow-y: auto;
    padding-right: 8px;
}

.move-list::-webkit-scrollbar {
    width: 6px;
}

.move-list::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 3px;
}

.move-list::-webkit-scrollbar-thumb {
    background: #555555;
    border-radius: 3px;
}

.move-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 4px 8px;
    margin: 2px 0;
    background: #2a2a2a;
    border-radius: 4px;
    font-size: 12px;
    color: #cccccc;
    gap: 12px;
}

.move-number {
    color: #888888;
    font-weight: 500;
    min-width: 20px;
}

.move-notation {
    color: #ffffff;
    display: flex;
    gap: 8px;
}

.move-notation .white-move,
.move-notation .black-move {
    min-width: 40px;
}



/* Responsive adjustments */
@media (max-width: 1200px) {
    .chess-window {
        width: 900px;
        height: 650px;
    }
    
    .chess-board {
        width: 480px;
        height: 480px;
    }
    
    .chess-info-panel {
        width: 260px;
    }
}

@media (max-width: 1000px) {
    .chess-layout {
        flex-direction: column;
        gap: 15px;
    }
    
    .chess-info-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .player-info {
        flex: 1;
        min-width: 200px;
    }
    
    .move-history {
        flex: 2;
        min-width: 300px;
    }
}

/* Game Result Modal - Proper modal overlay with selective transparency */
.game-result-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    backdrop-filter: blur(5px);
    pointer-events: none; /* Allow clicks to pass through */
}

.game-result-content {
    pointer-events: auto; /* Re-enable clicks on modal content */
}

.game-result-content {
    width: 380px;
    height: 520px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* Top third - darker background */
.result-header {
    background: #1E1D1A;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 20px 15px 20px;
    position: relative;
}

/* Bottom two-thirds - lighter background */
.result-body {
    background: #262421;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px 40px 20px;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
}

.modal-close-btn img {
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-close-btn:hover img {
    opacity: 1;
}

.result-title {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 28px;
    font-weight: 900; /* Heavy */
    margin: 0 0 8px 0;
    color: #EBECD0;
    text-transform: lowercase;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.result-subtitle {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 14px;
    font-weight: 500; /* Bold */
    margin: 0;
    color: #EBECD0;
    text-transform: lowercase;
}

/* Character avatar with exact styling */
.character-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
    margin-top: -70px;
}

.avatar-stack {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px auto;
}

.avatar-shadow {
    width: 120px;
    height: 120px;
    background: #739552;
    border-radius: 15px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.avatar-main {
    width: 100px;
    height: 100px;
    background: #82A85D;
    border-radius: 7px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.character-image {
    width: 100px;
    height: 100px;
    border-radius: 4px;
    object-fit: cover;
    object-position: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.character-name {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 18px;
    font-weight: 700; /* Bold */
    color: #EBECD0;
    margin-bottom: 35px;
}

.result-quote {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 14px;
    font-weight: 600; /* Semibold */
    font-style: italic;
    color: #EBECD0;
    margin: 0 0 40px 0;
    line-height: 1.4;
    text-align: center;
    padding: 0 15px;
}

/* 3D Button Effect */
.button-container {
    position: relative;
    width: 100%;
    max-width: 260px;
}

.button-shadow {
    width: 100%;
    height: 50px;
    background: #627F40;
    border-radius: 10px;
    position: absolute;
    top: 6px;
    left: 0;
}

.result-action-btn {
    width: 100%;
    height: 50px;
    background: #8CB55B;
    border: none;
    border-radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-size: 18px;
    font-weight: 900; /* Heavy */
    color: #FFFFFF;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: all 0.1s ease;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25);
}

.result-action-btn:hover {
    background: #9FC766;
}

.result-action-btn:active {
    transform: translateY(3px);
    background: #7DA350;
}

/* Confetti Animation */
@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-10px) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(800px) rotate(720deg);
    }
}

/* Confirmation Modal Styling */
.confirmation-modal {
    max-width: 400px;
    height: auto;
    background: #1E1D1A !important;
    padding: 40px 30px;
    text-align: center;
}

.confirmation-modal .result-title {
    margin-bottom: 15px;
}

.confirmation-modal .result-quote {
    margin-bottom: 35px;
}

.confirmation-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.confirmation-buttons .button-container {
    width: 140px;
}

.cancel-shadow {
    background: #374151;
}

.confirm-shadow {
    background: #941717;
}

.confirmation-modal .cancel-btn {
    background: #4b5563;
    font-weight: 600;
}

.confirmation-modal .cancel-btn:hover {
    background: #6b7280;
}

.confirmation-modal .confirm-btn {
    background: #e62a2a;
    font-weight: 600;
}

.confirmation-modal .confirm-btn:hover {
    background: #ef4444;
}

/* Enhanced capture move indicators - green dots under enemy pieces */
.chess-square.capture-move::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(34, 197, 94, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    border: 2px solid rgba(34, 197, 94, 1);
}

/* Avatar color variations for different game results */
.result-lost .avatar-main {
    background: #A85D5D; /* Reddish for small square when user wins */
}

.result-lost .avatar-shadow {
    background: #955252; /* Darker reddish for big square when user wins */
}

/* Pawn Promotion Modal */
.promotion-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(3px);
}

.promotion-content {
    background: #2a2a2a;
    border: 2px solid #555555;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.promotion-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

.promotion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 10px;
}

.promotion-option {
    width: 80px;
    height: 80px;
    background: #404040;
    border: 2px solid #666666;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
}

.promotion-option:hover {
    background: #4a4a4a;
    border-color: #888888;
    transform: scale(1.05);
}

.promotion-option:active {
    background: #333333;
    transform: scale(0.98);
}

.promotion-option.selected {
    background: #5a8f3a;
    border-color: #7ab84a;
    box-shadow: 0 0 15px rgba(122, 184, 74, 0.4);
}

.promotion-piece {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.promotion-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.promotion-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-confirm {
    background: #5a8f3a;
    color: #ffffff;
}

.promotion-confirm:hover {
    background: #6ba044;
}

.promotion-confirm:disabled {
    background: #666666;
    cursor: not-allowed;
    opacity: 0.6;
} 