/* ========== CHESS PAGE ========== */

#chessMain {
    width: 100%;
    background-color: var(--burgundy);
    padding: 2rem 1rem;
}

#chessGame {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    background: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid rgba(255,215,0,0.18);
    border-radius: 8px;
}

#chessGame h2 {
    position: relative;
    display: inline-block;
    padding-bottom: 0.6rem;
    margin-bottom: 0.5rem;
}

#chessGame h2::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 6rem; height: 3px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    border-radius: 2px;
}

#chessGame > p {
    font-size: 2.2rem;
    color: rgba(255,255,255,0.85);
    max-width: 65ch;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

/* Info bar */
#chessInfo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    flex-wrap: wrap;
    font-size: 2.4rem;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: 1.5rem;
}

#chessStatus {
    font-size: 2.2rem;
    color: var(--white);
    font-weight: normal;
}

/* Layout: board + captured side by side on large screens */
#chessLayout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#chessBoardWrap {
    display: inline-block;
}

/* Board */
#chessBoard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    border: 3px solid var(--gold);
    width: min(56rem, 90vw);
    height: min(56rem, 90vw);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

.chess-sq {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.4rem, 6vw, 5.5rem);
    cursor: pointer;
    position: relative;
    transition: background-color 0.12s;
    user-select: none;
}

.chess-sq.light { background-color: #f0d9b5; }
.chess-sq.dark  { background-color: #b58863; }

.chess-sq.selected {
    background-color: #f6f669 !important;
    box-shadow: inset 0 0 0 3px rgba(0,0,0,0.3);
}

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

.chess-sq.legal-capture {
    box-shadow: inset 0 0 0 4px rgba(180,0,0,0.4);
}

.chess-sq.in-check {
    background-color: #e74c3c !important;
}

.chess-sq.last-move {
    background-color: #cdd16f !important;
}

/* Rank/file labels */
.chess-sq .sq-label {
    position: absolute;
    font-size: 1.2rem;
    font-family: var(--body-fonts);
    font-weight: bold;
    color: rgba(0,0,0,0.4);
    line-height: 1;
}
.chess-sq.light .sq-label { color: rgba(181,136,99,0.8); }
.chess-sq.dark  .sq-label { color: rgba(240,217,181,0.8); }
.sq-label.file  { bottom: 1px; right: 2px; }
.sq-label.rank  { top: 1px; left: 2px; }

/* Captured pieces */
#chessCaptured {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.captured-group {
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 6px;
    padding: 1rem 1.5rem;
    min-width: 18rem;
    text-align: left;
}

.captured-label {
    font-size: 1.8rem !important;
    color: var(--gold);
    font-weight: bold;
    padding: 0 !important;
    margin-bottom: 0.5rem !important;
}

#capturedByWhite,
#capturedByBlack {
    font-size: 2.8rem;
    line-height: 1.4;
    min-height: 2rem;
    letter-spacing: 0.1rem;
}

/* Pawn promotion dialog */
#promoDialog {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#promoDialog .promo-box {
    background: var(--white);
    border: 3px solid var(--gold);
    border-radius: 10px;
    padding: 2rem 3rem;
    text-align: center;
}

#promoDialog h3 {
    font-size: 3rem;
    color: var(--burgundy);
    margin-bottom: 1.5rem;
    padding: 0;
}

#promoDialog .promo-options {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

#promoDialog .promo-btn {
    font-size: 5rem;
    background: none;
    border: 2px solid var(--burgundy);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s;
    color: var(--burgundy);
}

#promoDialog .promo-btn:hover {
    background-color: var(--yellow);
}

/* Large screen side-by-side */
@media screen and (min-width: 700px) {
    #chessLayout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
    }

    #chessCaptured {
        flex-direction: column;
        justify-content: flex-start;
    }
}
