/* CSS cho Cờ Vua */
.chess-container {
    max-width: 600px;
    margin: 80px auto 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chess-header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-family: 'Outfit', sans-serif;
}

.chess-header h2 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.chess-status {
    font-size: 16px;
    color: #f1c40f;
    font-weight: 600;
    min-height: 24px;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 550px; /* To hơn trên Desktop */
    aspect-ratio: 1 / 1;
    border: 4px solid #2c3e50;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    background-color: #f0d9b5; /* Light squares fallback */
}

.chess-square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}

.chess-square.light {
    background-color: #f0d9b5;
}

.chess-square.dark {
    background-color: #b58863;
}

.chess-square.selected {
    background-color: rgba(46, 204, 113, 0.6) !important;
}

.chess-square.valid-move::after {
    content: '';
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.2);
    position: absolute;
    pointer-events: none;
}

.chess-square.valid-capture::after {
    content: '';
    width: 80%;
    height: 80%;
    border-radius: 50%;
    border: 4px solid rgba(0, 0, 0, 0.2);
    background-color: transparent;
    position: absolute;
    pointer-events: none;
}

.chess-square.check {
    background: radial-gradient(circle, rgba(255,0,0,0.8) 0%, rgba(255,0,0,0) 70%) !important;
}

.chess-piece {
    width: 90%;
    height: 90%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
    transition: transform 0.2s;
    user-select: none;
    -webkit-user-drag: none;
}

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

/* Hiển thị lượt đi */
.player-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 550px;
    margin: 10px 0;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48%;
}

.player-card.active {
    background: rgba(46, 204, 113, 0.3);
    border: 1px solid #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

/* New Layout Classes */
.chess-layout { display: flex; justify-content: center; align-items: flex-start; gap: 20px; width: 100%; }
.board-area { display: flex; flex-direction: column; align-items: center; flex: 1; max-width: 550px; }
.captured-sidebar { width: 150px; background: rgba(255,255,255,0.05); border-radius: 12px; padding: 15px; box-sizing: border-box; display: none; }
.captured-sidebar.left-sidebar { border-left: 4px solid #34495e; }
.captured-sidebar.right-sidebar { border-right: 4px solid #ecf0f1; }
.sidebar-title { color: white; font-weight: bold; border-bottom: 2px solid rgba(255,255,255,0.2); padding-bottom: 5px; margin-bottom: 10px; font-size: 14px; text-align: center; }
.captured-list { display: flex; flex-wrap: wrap; gap: 5px; min-height: 50px; }
.captured-piece { width: 30px; height: 30px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.captured-mobile-btn { background: rgba(52, 152, 219, 0.8); color: white; border: 2px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 8px 16px; font-size: 14px; font-weight: bold; cursor: pointer; margin-bottom: 10px; display: none; margin: 0 auto 15px; }

@media (max-width: 768px) { .chess-layout { flex-direction: column; } .captured-sidebar { display: none !important; } }
@media (min-width: 769px) { .captured-sidebar.active-sidebar { display: block; } }

/* Responsive adjustments cho iPad và Mobile */
@media (max-width: 768px) {
    .chess-container {
        padding: 10px;
        margin-top: 70px;
    }
    .player-info {
        font-size: 12px;
    }
    .player-card {
        padding: 6px 10px;
    }
}

/* Các nút điều khiển */
.chess-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    width: 100%;
}

.chess-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    color: white;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.chess-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
    background: linear-gradient(135deg, #2980b9, #3498db);
}

.chess-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.4);
}

.chess-btn.danger {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.chess-btn.danger:hover {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.chess-btn.danger:active {
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

.chess-btn.success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}
.chess-btn.success:hover {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}
.chess-btn.success:active { box-shadow: 0 2px 10px rgba(46, 204, 113, 0.4); }

.chess-btn.purple {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.4);
}
.chess-btn.purple:hover {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.6);
}
.chess-btn.purple:active { box-shadow: 0 2px 10px rgba(155, 89, 182, 0.4); }

/* Wikipedia SVG Pieces URLs */
.piece-wp { background-image: url('https://upload.wikimedia.org/wikipedia/commons/4/45/Chess_plt45.svg'); }
.piece-wn { background-image: url('https://upload.wikimedia.org/wikipedia/commons/7/70/Chess_nlt45.svg'); }
.piece-wb { background-image: url('https://upload.wikimedia.org/wikipedia/commons/b/b1/Chess_blt45.svg'); }
.piece-wr { background-image: url('https://upload.wikimedia.org/wikipedia/commons/7/72/Chess_rlt45.svg'); }
.piece-wq { background-image: url('https://upload.wikimedia.org/wikipedia/commons/1/15/Chess_qlt45.svg'); }
.piece-wk { background-image: url('https://upload.wikimedia.org/wikipedia/commons/4/42/Chess_klt45.svg'); }

.piece-bp { background-image: url('https://upload.wikimedia.org/wikipedia/commons/c/c7/Chess_pdt45.svg'); }
.piece-bn { background-image: url('https://upload.wikimedia.org/wikipedia/commons/e/ef/Chess_ndt45.svg'); }
.piece-bb { background-image: url('https://upload.wikimedia.org/wikipedia/commons/9/98/Chess_bdt45.svg'); }
.piece-br { background-image: url('https://upload.wikimedia.org/wikipedia/commons/f/ff/Chess_rdt45.svg'); }
.piece-bq { background-image: url('https://upload.wikimedia.org/wikipedia/commons/4/47/Chess_qdt45.svg'); }
.piece-bk { background-image: url('https://upload.wikimedia.org/wikipedia/commons/f/f0/Chess_kdt45.svg'); }

/* Modal Khuyến Mãi (Promotion) */
.promotion-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 10px;
    border-radius: 12px;
    display: none;
    gap: 10px;
    z-index: 100;
    border: 2px solid #f1c40f;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
}
.promotion-option {
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: transform 0.2s;
}
.promotion-option:hover { transform: scale(1.2); }
