* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: #242424;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 30px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5em;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 25px;
    text-align: center;
}

.main-container {
    display: grid;
    grid-template-columns: 180px 1fr 220px;
    gap: 40px;
    align-items: start;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    gap: 0;
    border: 3px solid #333;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    background: #333;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: all 0.2s ease;
}

.square.light {
    background: #f0d9b5;
}

.square.dark {
    background: #b58863;
}

.square.selected {
    background: #baca44 !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.square.valid-move {
    position: relative;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: radial-gradient(circle, #999 30%, transparent 70%);
    border-radius: 50%;
}

.square.valid-capture::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid #999;
    border-radius: 50%;
}

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

.piece {
    cursor: grab;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

.piece:hover {
    transform: scale(1.1);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn {
    padding: 12px 20px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #667eea;
}

.btn-primary:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: #555;
}

.btn-secondary:hover {
    background: #666;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.game-level {
    background: #333;
    padding: 15px;
    border-radius: 8px;
    width: 100%;
}

.game-level label {
    font-weight: 600;
    color: #fff;
    display: block;
    margin-bottom: 12px;
    font-size: 0.95em;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.difficulty-btn {
    padding: 10px 15px;
    border: 2px solid #555;
    background: #2a2a2a;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9em;
}

.difficulty-btn:hover {
    border-color: #667eea;
    background: #333;
}

.difficulty-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.game-status {
    background: #333;
    border: 2px solid #667eea;
    padding: 15px;
    border-radius: 10px;
    width: 100%;
}

.status-text {
    font-weight: bold;
    color: #67f3da;
    font-size: 0.95em;
    margin-bottom: 12px;
}

.move-history {
    font-size: 0.95em;
    color: #aaa;
    height: 72px;
    max-height: 72px;
    overflow-y: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    background: #2a2a2a;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #555;
}

.players-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.player-info {
    background: #333;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.player-label {
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.player-piece {
    font-size: 2.4em;
    text-align: center;
    margin-top: 6px;
    color: #fff;
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    min-height: 25px;
}

.captured-piece {
    font-size: 1.1em;
    background: #2a2a2a;
    padding: 3px 5px;
    border-radius: 3px;
    border: 1px solid #555;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #2a2a2a;
    margin: 15% auto;
    padding: 30px;
    border: 2px solid #667eea;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-content h2 {
    color: #fff;
    margin-bottom: 15px;
}

.modal-content p {
    color: #aaa;
    margin-bottom: 10px;
}

#modalTitle {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.color-selection-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.color-btn {
    font-size: 1.2em;
    padding: 15px 20px;
    background: #667eea;
}

.color-btn:hover {
    background: #764ba2;
}

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

.promotion-btn {
    padding: 15px;
    font-size: 2em;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.promotion-btn:hover {
    background: #444;
    border-color: #667eea;
    transform: scale(1.1);
}

.game-over-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.game-over-buttons .btn {
    background: #667eea;
}

.game-over-buttons .btn:hover {
    background: #764ba2;
}

#gameOverMessage {
    font-size: 1.1em;
    color: #67f3da;
    margin: 15px 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .board-container {
        margin: 20px 0;
    }

    .left-panel {
        flex-direction: row;
        gap: 15px;
    }

    .chessboard {
        grid-template-columns: repeat(8, 50px);
        grid-template-rows: repeat(8, 50px);
    }
}

@media (max-width: 768px) {
    .chessboard {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
    }

    .square {
        font-size: 1.8em;
    }

    header h1 {
        font-size: 2em;
    }

    .promotion-options {
        grid-template-columns: repeat(2, 1fr);
    }
}
