#game-area {

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    position: relative;
}

#top-bar {

    width: 90%;

    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-bottom: 20px;
}

.timer {

    width: 180px;

    text-align: center;

    padding: 12px;

    background: rgba(0,0,0,0.4);

    border:
        1px solid rgba(0,229,255,0.3);

    font-size: 1.4rem;

    color: var(--cyan);

    box-shadow:
        0 0 12px rgba(0,229,255,0.15);
}

#status-display {

    font-size: 1.1rem;

    color: var(--magenta);

    letter-spacing: 3px;
}

#board-container {
    width: min(85vmin, 900px);
    height: min(85vmin, 900px);

    min-width: 280px;
    min-height: 280px;
}

#chessboard {

    width: min(82vw, 82vh);
    height: min(82vw, 82vh);

    display: grid;

    grid-template-columns:
        repeat(8, 1fr);

    grid-template-rows:
        repeat(8, 1fr);

    aspect-ratio: 1 / 1;

    width: 100%;
    height: 100%;

    border:
        3px solid rgba(0,229,255,0.4);

    box-shadow:
        0 0 30px rgba(0,229,255,0.25);

    position: relative;
}

.square {

    position: relative;

    width: 100%;
    height: 100%;

    display: flex;

    justify-content: center;
    align-items: center;

    overflow: hidden;
}

.board-coordinate {
    position:
        absolute;

    z-index:
        6;

    pointer-events:
        none;

    user-select:
        none;

    font-size:
        clamp(
            0.55rem,
            1.15vmin,
            0.82rem
        );

    font-weight:
        700;

    line-height:
        1;

    opacity:
        0.82;

    text-shadow:
        0 0 5px
            rgba(
                0,
                0,
                0,
                0.9
            );
}

.board-file-coordinate {
    right:
        5%;

    bottom:
        4%;
}

.board-rank-coordinate {
    left:
        5%;

    top:
        4%;
}

.square.light
.board-coordinate {
    color:
        rgba(
            30,
            110,
            140,
            0.9
        );
}

.square.dark
.board-coordinate {
    color:
        rgba(
            110,
            245,
            255,
            0.9
        );
}

.light {
    background: var(--square-light);
}

.dark {
    background: var(--square-dark);
}

.square.highlight::after {

    content: "";

    width: 24%;
    height: 24%;

    border-radius: 50%;

    background: rgba(0,229,255,0.7);

    position: absolute;
}

.square.capture-highlight::after {

    content: "";

    width: 80%;
    height: 80%;

    border-radius: 50%;

    border: 4px solid var(--danger);

    position: absolute;
}

.piece {

    width: 72%;
    height: 72%;

    object-fit: contain;

    pointer-events: none;

    user-select: none;

    transition:
        transform 0.12s ease,
        filter 0.12s ease;
}

.piece-pawn {
    width: 62%;
    height: 62%;
}

.piece-king,
.piece-queen {
    width: 95%;
    height: 95%;
}

.piece-rook {
    width: 80%;
    height: 80%;
}

.piece-bishop,
.piece-knight {
    width: 76%;
    height: 76%;
}

.piece:hover {

    transform: scale(1.08);

    box-shadow:
        0 0 15px rgba(5, 12, 243, 0.8);
}

.selected-square {

    outline:
        3px solid rgba(255, 0, 200, 0.9);

    box-shadow:
        inset 0 0 18px rgba(255, 0, 200, 0.55),
        0 0 18px rgba(255, 0, 200, 0.8);
}

.capture-highlight {

    box-shadow:
        inset 0 0 20px rgba(255, 48, 79, 0.65),
        0 0 16px rgba(255, 48, 79, 0.75);
    opacity: 0.9;
}

.highlight {

    box-shadow:
        inset 0 0 18px rgba(0, 255, 255, 0.55),
        0 0 14px rgba(0, 255, 255, 0.65);
}

.highlight::after {

    content: "";

    width: 26%;

    height: 26%;

    border-radius: 50%;

    background:
        rgba(0, 255, 255, 0.7);

    box-shadow:
        0 0 12px rgba(0, 255, 255, 0.9);
}

.piece {
    cursor:
        pointer;
}

.board-standby .piece,
.board-active.game-over .piece {
    cursor:
        default;
}

.animated-piece {
    position: absolute;

    object-fit: contain;

    width: 12%;
    height: 12%;

    pointer-events: none;

    z-index: 999;

    transition:
        transform 0.24s ease-in-out;

    will-change:
        transform;

    filter:
        drop-shadow(0 0 12px rgba(0, 229, 255, 0.65));
}

.piece-animation-hidden {
    opacity: 0;
}

.capture-blue-glow::before {
    content: "";

    position: absolute;
    inset: 10%;

    border-radius: 14px;

    background:
        radial-gradient(
            circle,
            rgba(0, 229, 255, 0.45),
            rgba(0, 229, 255, 0.05) 65%,
            transparent 75%
        );

    box-shadow:
        inset 0 0 18px rgba(0, 255, 255, 0.55),
        0 0 14px rgba(0, 255, 255, 0.65);

    pointer-events: none;

    animation:
        captureBlueGlow 0.26s ease;
}

@keyframes captureBlueGlow {
    0% {
        opacity: 0;
        transform: scale(0.75);
    }

    45% {
        opacity: 1;
        transform: scale(1.08);
    }

    100% {
        opacity: 0.55;
        transform: scale(1);
    }
}

.king-check-glow {
    filter:
        drop-shadow(0 0 10px rgba(180, 70, 255, 0.95))
        drop-shadow(0 0 20px rgba(120, 0, 255, 0.65));
}

.king-checkmate-glow {
    filter:
        drop-shadow(0 0 10px rgba(255, 40, 40, 1))
        drop-shadow(0 0 24px rgba(255, 0, 0, 0.85));
}

/* Tablet / mobile board scaling */
@media (max-width: 1100px) {

    #game-area {
        width: 100%;

        padding:
            18px 0 24px;

        align-items: center;
        justify-content: flex-start;
    }

    #board-container {
        width:
            min(
                96vw,
                calc(100svh - 170px),
                900px
            );

        height: auto;

        aspect-ratio:
            1 / 1;

        min-width: 0;
        min-height: 0;
    }

    #chessboard {
        width: 100%;
        height: 100%;
    }

    #top-bar {
        width:
            min(
                96vw,
                900px
            );

        display: flex;

        justify-content: center;
        align-items: center;

        flex-wrap: wrap;

        gap: 10px 14px;

        margin:
            0 auto 14px;
    }

    .timer {
        width: 135px;

        padding: 9px;

        font-size: 1rem;

        flex:
            0 0 auto;
    }

    #status-display {
        min-width: 150px;

        text-align: center;

        font-size: 0.9rem;

        letter-spacing: 2px;
    }

    #capture-announcer {
        flex-basis: 100%;

        width: 100%;

        text-align: center;

        margin: 0 auto;

        min-height: 1.2em;
    }
}

/* Phones */
@media (max-width: 700px) {

    #game-area {
        padding:
            10px 0 18px;
    }

    #board-container {
        width:
            min(
                98vw,
                calc(100svh - 145px)
            );
    }

    #top-bar {
        width: 98vw;

        gap: 7px;

        margin-bottom: 9px;
    }

    .timer {
        width:
            calc(50% - 12px);

        max-width: 145px;

        padding: 7px;

        font-size: 0.88rem;
    }

    #status-display {
        order: -1;

        flex-basis: 100%;

        width: 100%;

        min-width: 0;

        text-align: center;

        font-size: 0.78rem;

        letter-spacing: 1.4px;
    }

    #capture-announcer {
        flex-basis: 100%;

        width: 100%;

        padding: 0 6px;

        text-align: center;

        font-size: 0.68rem;
    }
}