/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #00ccff 0%, #11ad4d 100%);
    min-height: 100vh;
    color: #333;
}

/* Game Container */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.game-header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-header h1 i {
    color: #8B4513;
}

.game-controls {
    display: flex;
    gap: 10px;
}

/* Button Styles */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Main Game Board Container */
.game-board-container {
    display: grid;
    grid-template-columns: 300px 1fr 250px;
    gap: 20px;
    flex: 1;
    align-items: start;
}

/* Game Info Panel */
.game-info {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.player-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.player-piece {
    font-size: 2rem;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

.status-message {
    padding: 15px;
    background: #e8f5e8;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
    font-weight: 500;
    margin-bottom: 20px;
}

.status-message.check {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.status-message.checkmate {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.captured-pieces {
    margin-top: 20px;
}

.captured-white, .captured-black {
    margin-bottom: 15px;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
    min-height: 30px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.captured-piece {
    font-size: 1.5rem;
    opacity: 0.7;
}

/* Chess Board Wrapper */
.chess-board-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Chess Board */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 70px);
    grid-template-rows: repeat(8, 70px);
    border: 4px solid #000000;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: #fff;
}

/* Board Squares */
.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.square.light {
    background-color: #0011ff;
}

.square.dark {
    background-color: #ffffff;
}

.square:hover {
    box-shadow: inset 0 0 0 3px rgba(52, 152, 219, 0.5);
}

.square.selected {
    box-shadow: inset 0 0 0 4px #3498db;
    background-color: rgba(52, 152, 219, 0.3) !important;
}

.square.valid-move {
    box-shadow: inset 0 0 0 3px #27ae60;
}

.square.valid-move::after {
    content: '';
    width: 20px;
    height: 20px;
    background: #27ae60;
    border-radius: 50%;
    opacity: 0.7;
}

.square.valid-capture {
    box-shadow: inset 0 0 0 4px #e74c3c;
}

.square.valid-capture::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #e74c3c;
    border-radius: 50%;
    margin: 3px;
}

.square.last-move {
    background-color: rgba(255, 255, 0, 0.4) !important;
}

.square.in-check {
    background-color: rgba(220, 53, 69, 0.4) !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Chess Pieces */
.piece {
    font-size: 3rem;
    cursor: grab;
    transition: transform 0.2s ease;
    user-select: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.piece:hover {
    transform: scale(1.1);
}

.piece.dragging {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(1.2);
    z-index: 1000;
}

.piece.white {
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.piece.black {
    color: #000000;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
}

/* Board Coordinates */
.board-coordinates {
    position: absolute;
    top: -4px;
    left: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    pointer-events: none;
}

.files,
.ranks {
    position: absolute;
    display: flex;
    font-weight: bold;
    color: #c53c3c;
    font-size: 0.9rem;
}

/* File Letters (Bottom of Board) */
.files {
    position: absolute;
    display: flex;
    bottom: -10px;
    left: 150px ;
    right: 260px;
    width: 350%;
    justify-content: space-between;
    padding: 0 4px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #c53c3c;
}

.files span {
    width: 60px;
    text-align: center;
}

.ranks {
    position: absolute;
    display: flex;
    flex-direction: column;
    top: 0;
    left: -25px;
    height: 100%;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: bold;
    color: #c53c3c;
}

.ranks span {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Move History */
.move-history {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: 600px;
    overflow-y: auto;
}

.move-history h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.move-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.move-pair {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    background: #f8f9fa;
    align-items: center;
}

.move-number {
    font-weight: bold;
    color: #666;
    text-align: center;
}

.move-notation {
    padding: 6px 8px;
    background: white;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 500;
    border: 1px solid #ddd;
    text-align: center;
}

.move-notation.white {
    background: #f9f9f9;
}

.move-notation.black {
    background: #e9e9e9;
}

/* Game Messages */
.game-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.game-message.hidden {
    display: none;
}

.message-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 500px;
    position: relative;
}

.message-content span {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    display: block;
    margin-bottom: 20px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

/* Footer */
.game-footer {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-footer p {
    margin-bottom: 5px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-board-container {
        grid-template-columns: 250px 1fr 200px;
    }
    
    .chess-board {
        grid-template-columns: repeat(8, 60px);
        grid-template-rows: repeat(8, 60px);
    }
    
    .piece {
        font-size: 2.5rem;
    }
}



/* Update coordinates for 60px squares */
    .files {
        width: 480px; /* 8 squares × 60px each */
    }
    
    .files span {
        width: 60px;
    }
    
    .ranks {
        height: 480px; /* 8 squares × 60px each */
    }


@media (max-width: 992px) {
    .game-board-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
    }
    
    .game-info {
        order: 1;
    }
    
    .chess-board-wrapper {
        order: 2;
    }
    
    .move-history {
        order: 3;
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .chess-board {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
    }
    
    .piece {
        font-size: 2rem;
    }





      /* Update coordinates for 45px squares */
    .files {
        width: 360px; /* 8 squares × 45px each */
    }
    
    .files span {
        width: 45px;
    }
    
    .ranks {
        height: 360px; /* 8 squares × 45px each */
    }







    
    .game-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .chess-board {
        grid-template-columns: repeat(8, 40px);
        grid-template-rows: repeat(8, 40px);
    }
    
    .piece {
        font-size: 1.8rem;
    }
    
 
     


     /* Update coordinates for 40px squares */
    .files {
        width: 320px; /* 8 squares × 40px each */
    }
    
    .files span {
        width: 40px;
    }
    
    .ranks {
        height: 320px; /* 8 squares × 40px each */
    }
    








    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .game-header, .game-footer, .move-history, .game-info {
        display: none;
    }
    
    .game-board-container {
        grid-template-columns: 1fr;
        justify-items: center;
    }
}
