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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, #5d4037 0%, #3e2723 50%, #4e342e 100%);
    min-height: 100vh;
    color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(180deg, #6d4c41 0%, #5d4037 100%);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid #4e342e;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(180deg, #ffe082 0%, #ffca28 50%, #ffb300 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: bold;
    color: #d7ccc8;
}

.control-group select {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid #8d6e63;
    border-radius: 8px;
    background: linear-gradient(180deg, #4e342e 0%, #3e2723 100%);
    color: #f5f5f5;
    cursor: pointer;
    font-family: inherit;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.control-group select:focus {
    outline: none;
    border-color: #ffca28;
}

main {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 20px;
    align-items: start;
}

.history-panel,
.control-panel {
    background: linear-gradient(180deg, #6d4c41 0%, #5d4037 100%);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid #4e342e;
    min-height: 400px;
}

.history-panel h3,
.control-panel h3 {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #8d6e63;
    color: #ffca28;
}

#moveHistory {
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.move-item {
    padding: 5px 10px;
    margin: 2px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    display: flex;
    gap: 10px;
    font-size: 0.9rem;
}

.move-item .move-number {
    color: #bcaaa4;
    min-width: 30px;
}

.move-item .move-white,
.move-item .move-black {
    flex: 1;
}

.move-item .move-black:empty::before {
    content: "...";
    color: #bcaaa4;
}

.status {
    padding: 10px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    font-weight: bold;
    color: #ffcc80;
}

.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#board {
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 0 3px #4e342e;
}

#board .white-1e1d7 {
    background: linear-gradient(135deg, #f5deb3 0%, #deb887 50%, #d2b48c 100%);
}

#board .black-3d85d {
    background: linear-gradient(135deg, #8b4513 0%, #6b3410 50%, #5d2e0d 100%);
}

.highlight {
    box-shadow: inset 0 0 10px 3px rgba(255, 215, 0, 0.6);
}

.thinking {
    margin-top: 15px;
    padding: 15px 30px;
    background: linear-gradient(180deg, #6d4c41 0%, #5d4037 100%);
    border-radius: 25px;
    font-size: 1.1rem;
    color: #ffcc80;
    border: 2px solid #8d6e63;
    animation: pulse 1.5s ease-in-out infinite;
}

.thinking.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.btn {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    color: #f5f5f5;
    background: linear-gradient(180deg, #5d4037 0%, #4e342e 100%);
    border: 2px solid #8d6e63;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    background: linear-gradient(180deg, #6d4c41 0%, #5d4037 100%);
    border-color: #a1887f;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn.primary {
    background: linear-gradient(180deg, #ffca28 0%, #ffb300 50%, #ff8f00 100%);
    color: #3e2723;
    border-color: #ffb300;
}

.btn.primary:hover {
    background: linear-gradient(180deg, #ffd54f 0%, #ffca28 50%, #ffb300 100%);
}

.game-info {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row span:first-child {
    color: #bcaaa4;
}

.info-row span:last-child {
    color: #ffcc80;
    font-weight: bold;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(180deg, #6d4c41 0%, #5d4037 100%);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid #4e342e;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #ffca28;
    margin-bottom: 20px;
    font-size: 2rem;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #d7ccc8;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .history-panel,
    .control-panel {
        order: 2;
    }
    
    #board {
        max-width: 350px;
    }
}

@media (max-width: 500px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: center;
    }
    
    #board {
        max-width: 300px;
    }
    
    .history-panel,
    .control-panel {
        min-height: auto;
    }
}
