/* ===============================
   CONTENEDOR GENERAL
================================ */

.chess-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ===============================
   WRAPPER DEL TABLERO
================================ */

.board-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 20px;
    overflow-x: auto;
}

/* ===============================
   TABLERO DE AJEDREZ (RESPONSIVE)
================================ */

#chessboard {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);

    width: min(90vw, 420px); /* móvil / escritorio */
    aspect-ratio: 1 / 1; /* siempre cuadrado */

    border: 3px solid #333;
}

/* ===============================
   CASILLAS
================================ */

.square {
    transition:
        background-color 0.15s ease,
        outline 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: clamp(1.6rem, 5vw, 2.4rem); /* piezas adaptables */
    cursor: pointer;
    user-select: none;
}

/* ===============================
   COLORES DEL TABLERO
================================ */

.white {
    background-color: #f0d9b5;
}

.black {
    background-color: #b58863;
}

/* ===============================
   PIEZAS NEGRAS (SOMBRA)
================================ */

.square.black-piece {
    color: #111;
    text-shadow: 0 0 2px #000;
}

/* ===============================
   FICHA SELECCIONADA
================================ */

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: clamp(1.6rem, 5vw, 2.4rem);
    cursor: pointer;
    user-select: none;
}

.square {
    transition:
        transform 0.12s ease-out,
        box-shadow 0.12s ease-out;
}

.square.selected {
    transform: scale(1.08);
    z-index: 5;
    outline: 3px solid gold;
}

/* halo visual elegante */
.square.selected::after {
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    box-shadow:
        0 0 0 2px rgba(255, 215, 0, 0.9),
        0 4px 10px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

/* ===============================
   BOTÓN VOLVER
================================ */

.chess-boton {
    display: block;
    margin: 20px auto;

    padding: 10px 20px;
    font-size: 16px;

    color: #fff;
    background-color: #007bff;

    border: none;
    border-radius: 5px;
    text-decoration: none;
    text-align: center;
}
/*Boton reiniciar*/
.chess-boton.small {
    margin-top: 40px;
    font-size: 14px;
    padding: 6px 14px;
}

/* Promoción de peón */
.promotion-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    z-index: 999;
}

.promotion-btn {
    font-size: 40px;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 8px;
    border: none;
}
promotion-btn:hover {
    background-color: #f0f0f0;
}

#message {
    min-height: 24px; /* reserva espacio */
    margin-bottom: 10px;
    font-weight: bold;
    color: #ff4d4d; /* rojo jaque */
    text-align: center;
}
#message.checkmate {
    color: #d40000; /* rojo mate */
}

/* Tablero online */
.chessboard.flipped {
    transform: rotate(180deg);
}

.chessboard.flipped .square {
    transform: rotate(180deg);
}
