* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #ecf0f1;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    max-width: 1200px;
    width: 100%;
}

h1 {
    color: #ecf0f1;
    font-size: 3rem;
    font-weight: 300;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.game-info {
    display: flex;
    gap: 25px;
    align-items: flex-start;
    background: rgba(52, 73, 94, 0.8);
    padding: 25px;
    border-radius: 20px;
    backdrop-filter: blur(15px);
    width: 100%;
    max-width: 700px;
    justify-content: space-between;
    border: 1px solid rgba(236, 240, 241, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.current-player,
.game-status {
    color: #ecf0f1;
    font-weight: 600;
    font-size: 1.2rem;
}

.game-status {
    font-size: 1rem;
    opacity: 0.8;
    color: #bdc3c7;
}

.controls {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

button,
select {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

select {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
}

select:hover {
    background: linear-gradient(145deg, #8e44ad, #7d3c98);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}

button:hover {
    background: linear-gradient(145deg, #2980b9, #21618c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

button:disabled {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#reset-btn {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

#reset-btn:hover {
    background: linear-gradient(145deg, #c0392b, #a93226);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

#test-btn {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

#test-btn:hover {
    background: linear-gradient(145deg, #e67e22, #d35400);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

.move-history, .ai-suggestion {
    color: #ecf0f1;
    min-width: 220px;
}

.move-history h3, .ai-suggestion h3 {
    margin-bottom: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #3498db;
}

.ai-suggestion h3 {
    color: #e74c3c;
}

#move-list, #ai-suggestion-text {
    max-height: 140px;
    overflow-y: auto;
    font-size: 0.9rem;
    background: rgba(44, 62, 80, 0.6);
    padding: 12px;
    border-radius: 12px;
    line-height: 1.5;
    border: 1px solid rgba(236, 240, 241, 0.1);
}

#ai-suggestion-text {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #ecf0f1;
    font-weight: 500;
}

.move-item {
    margin-bottom: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(52, 73, 94, 0.3);
    transition: background 0.2s;
}

.move-item:hover {
    background: rgba(52, 73, 94, 0.5);
}

.chessboard-container {
    background: rgba(44, 62, 80, 0.4);
    padding: 30px;
    border-radius: 25px;
    backdrop-filter: blur(20px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(236, 240, 241, 0.1);
}

#chessboard {
    display: grid;
    grid-template-columns: repeat(8, 65px);
    grid-template-rows: repeat(8, 65px);
    border: 4px solid #2c3e50;
    border-radius: 15px;
    overflow: hidden;
    margin: 0 auto;
    width: 520px;
    height: 520px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.square {
    width: 65px;
    height: 65px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-size: 42px;
}

.square.light {
    background-color: #ecf0f1;
    color: #2c3e50;
}

.square.dark {
    background-color: #34495e;
    color: #ecf0f1;
}

.square.selected {
    background-color: #3498db !important;
    box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.6), 0 0 20px rgba(52, 152, 219, 0.4);
    color: white;
}

.square.valid-move {
    background-color: #27ae60 !important;
    box-shadow: inset 0 0 10px rgba(39, 174, 96, 0.5);
    color: white;
}

.square.last-move {
    background-color: #f39c12 !important;
    box-shadow: inset 0 0 10px rgba(243, 156, 18, 0.5);
    color: white;
}

.square:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.square.piece {
    cursor: grab;
    user-select: none;
}

.square.piece:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.square.piece:active {
    cursor: grabbing;
}

.square.piece.dragging {
    opacity: 0.6;
    cursor: grabbing;
    transform: scale(0.95);
}

.square.drag-over {
    background-color: #2ecc71 !important;
    box-shadow: inset 0 0 15px rgba(46, 204, 113, 0.7), 0 0 25px rgba(46, 204, 113, 0.5);
    transform: scale(1.08);
    color: white;
}

/* Improve drag feedback */
.square.valid-move::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background-color: rgba(46, 204, 113, 0.8);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.4);
}

.square.valid-move.drag-over::after {
    background-color: rgba(46, 204, 113, 1);
    width: 32px;
    height: 32px;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.6);
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .container {
        gap: 20px;
    }

    h1 {
        font-size: 2.2rem;
        letter-spacing: 1px;
    }

    .game-info {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
        max-width: 100%;
    }

    .controls {
        flex-direction: row;
        width: 100%;
        gap: 8px;
    }

    button,
    select {
        min-width: auto;
        flex: 1;
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .move-history {
        min-width: auto;
        width: 100%;
    }

    .chessboard-container {
        padding: 20px;
    }

    #chessboard {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
        width: 360px;
        height: 360px;
    }

    .square {
        width: 45px;
        height: 45px;
        font-size: 32px;
    }
}