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

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: #222;
    color: white;
    font-family: Arial, sans-serif;
    min-height: 100%;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
}


/* =========================================================
   HEADER
   ========================================================= */

header {
    text-align: center;
    padding-top: 24px;
}

h1 {
    margin: 0;
    font-size: 36px;
    font-weight: 600;
}

.developer {
    margin: 6px 0 14px;
    font-size: 15px;
    color: #aaa;
}

.separator {
    width: 900px;
    max-width: 90%;
    height: 1px;
    margin: 0 auto;
    background: #444;
}


/* =========================================================
   GAME LAYOUT — DESKTOP
   ========================================================= */

.game {
    width: min(950px, calc(100vw - 40px));
    margin: 28px auto 0;
    display: grid;
    grid-template-columns: 650px 270px;
    gap: 30px;
    align-items: start;
}


/* =========================================================
   CHESSBOARD
   ========================================================= */

#board {
    width: 650px;
    max-width: 100%;
    margin: 0;
    /*
        Prevent the browser from interpreting touches
        on the board as scrolling/gesture interactions.
        "manipulation" keeps normal desktop behavior.
    */
    touch-action: manipulation;
    /*
        Prevent text/image selection on the board.
    */
    -webkit-user-select: none;
    user-select: none;
}


    /*
    Chessboard.js uses images for the pieces.
    Prevent the browser from treating them as draggable
    or selectable images.

    pointer-events: none means the square underneath
    receives the pointer event instead of the image.
*/

    #board img {
        width: 80% !important;
        height: 80% !important;
        margin: 10%;
        -webkit-user-drag: none;
        user-drag: none;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        pointer-events: none;
    }


/* =========================================================
   BOARD COLORS
   ========================================================= */

.white-1e1d7 {
    background-color: #E8EDF9 !important;
    color: #B7C0D8 !important;
}

.black-3c85d {
    background-color: #B7C0D8 !important;
    color: #E8EDF9 !important;
}


/* =========================================================
   PLAYER COLUMN
   ========================================================= */

.players {
    width: 270px;
    height: 650px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}


/* =========================================================
   PLAYER BOXES
   ========================================================= */

.player {
    width: 270px;
    background: #292929;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 16px;
}

    .player.active {
        border-color: #ff2028;
        box-shadow: 0 0 10px rgba(255, 32, 40, 0.25);
    }


/* =========================================================
   BOT
   ========================================================= */

.bot {
    min-height: 100px;
}


/* =========================================================
   HUMAN
   ========================================================= */

.human {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}


/* =========================================================
   PLAYER NAME
   ========================================================= */

.player-name {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
}


/* =========================================================
   CAPTURED PIECES
   ========================================================= */

.captured {
    min-height: 35px;
    margin-top: 10px;
    color: #aaa;
    font-size: 14px;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

button {
    padding: 7px 12px;
    border: 1px solid #555;
    border-radius: 5px;
    background: #333;
    color: white;
    cursor: pointer;
    font-size: 13px;
}

    button:hover {
        background: #444;
    }

    button.resign {
        background: #7d2525;
        border-color: #963333;
    }

        button.resign:hover {
            background: #963333;
        }


/* =========================================================
   MOVE HIGHLIGHTS
   ========================================================= */

#board .square-55d63 {
    position: relative;
}


/* Selected piece */

.selected-marker {
    position: absolute;
    inset: 0;
    border: 7px solid #ff2028;
    box-sizing: border-box;
    pointer-events: none;
}


/* Legal moves */

.move-marker {
    position: absolute;
    width: 35%;
    height: 35%;
    left: 32.5%;
    top: 32.5%;
    background: rgba(220, 60, 70, 0.75);
    pointer-events: none;
}


/* Off-turn movement hints */

.offturn-marker {
    position: absolute;
    width: 35%;
    height: 35%;
    left: 32.5%;
    top: 32.5%;
    background: rgba(120, 120, 120, 0.55);
    pointer-events: none;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    /*
        Give the browser the full mobile width.
    */

    body {
        width: 100%;
        overflow-x: hidden;
    }


    /* -----------------------------------------
       Header
       ----------------------------------------- */

    header {
        padding-top: 18px;
    }

    h1 {
        font-size: 28px;
    }

    .developer {
        margin: 5px 12px 12px;
        font-size: 13px;
    }

    .separator {
        width: calc(100% - 24px);
        max-width: none;
    }


    /* -----------------------------------------
       Main layout
       ----------------------------------------- */

    .game {
        width: 100%;
        margin: 18px 0 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }


    /*
        On mobile, .players becomes transparent
        to the layout so bot and human can be
        positioned around the board.
    */

    .players {
        display: contents;
    }


    /* -----------------------------------------
       Bot — above board
       ----------------------------------------- */

    .bot {
        order: 0;
        width: calc(100% - 24px);
        margin: 0 12px;
    }


    /* -----------------------------------------
       Board — full available width
       ----------------------------------------- */

    #board {
        order: 1;
        width: 100%;
        max-width: 100%;
        margin: 0;
        /*
            Disable browser gestures on the board
            for touch devices.

            This makes tapping a square immediate
            and prevents accidental scrolling while
            interacting with the board.
        */
        touch-action: none;
    }


    /* -----------------------------------------
       Human — below board
       ----------------------------------------- */

    .human {
        order: 2;
        width: calc(100% - 24px);
        margin: 0 12px;
    }


    /* -----------------------------------------
       Mobile player boxes
       ----------------------------------------- */

    .player {
        padding: 12px;
    }


    .player-name {
        text-align: left;
    }


    /* -----------------------------------------
       Mobile buttons
       ----------------------------------------- */

    .buttons {
        justify-content: flex-start;
    }
}
