:root {
    --light-square: 225, 212, 203;
    --dark-square: 132, 161, 191;
    --checked-square: 205, 0, 0;
    --selected-square: 220, 195, 75;
    --light-selected-square: 246, 235, 114;

    --win-color: 133, 169, 78;
    --draw-color: 100, 100, 100;
    --lose-color: 168, 77, 77;

    --background-color: 25, 25, 25;
    --background-white-color: 230, 230, 230;

    --font-color: 238, 238, 238;
    --font: monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;

    color: rgba(var(--font-color), 1);
    font-family: var(--font);
}

body {
    width: 100vw;
    height: 100vh;

    display: flex;
    flex-direction: column;

    background-color: rgba(var(--background-color), 1);
}

ul {
    list-style: none;
}

.btn {
    padding: .5rem 1rem;

    outline: none;
    border: 1px solid rgba(var(--font-color), 1);
    background-color: transparent;

    font-size: 18px;

    cursor: pointer;
}
.btn:hover, .btn:focus {
    border: 1px solid rgba(var(--font-color), .5);

    color: rgba(var(--font-color), .5);
}


/* Main */
.menu-container {
    height: 100%;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;

    overflow: hidden;
}
.menu-container h1 {
    font-size: 48px;
    text-align: center;
}
.menu-container p {
    font-size: 24px;
    text-align: center;
}
.menu-container .menu-buttons {
    margin: 1rem 0;

    width: 36%;

    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.menu-container .menu-buttons > * {
    flex: 1 1 157px;
}

.menu-footer {
    padding: 1rem;

    display: flex;
    justify-content: flex-end;
}


/* Board */
.game-container {
    height: 100%;
    width: 100%;

    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;

    overflow: hidden;
}
.game-container .main {
    padding: 1rem 0;

    width: max-content;
    height: 100vh;

    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-container .board {
    position: relative;

    width: auto;
    height: 80%;
    aspect-ratio: 1 / 1;

    display: grid;
}
.square {
    width: 100%;
    height: 100%;

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

    outline: none;
    border: none;
    --bg-img: none;
    background-image: var(--bg-img);
    background-size: cover;
    background-color: rgba(var(--light-square), 1);

    font-size: 24px;

    cursor: pointer;
}
/* Checkerboard pattern */
.square:hover,.square:focus {
    background-color: rgba(var(--light-square), .5);
}
.square.dark {
    background-color: rgba(var(--dark-square), 1);;
}
.square.dark:hover, .square.dark:focus {
    background-color: rgba(var(--dark-square), .5);
}
.square.highlight {
    --circle: radial-gradient(circle, rgba(0,0,0,0.3) 0 40%, transparent 40%);
    background-image: var(--circle), var(--bg-img);
}
.square.checked {
    background-color: rgba(var(--checked-square), 1);
}
.square.checked:hover, .square.checked:focus {
    background-color: rgba(var(--checked-square), .5);
}
.square.selected {
    background-color: rgba(var(--selected-square), 1);;
}
.square.selected:hover, .square.selected:focus {
    background-color: rgba(var(--selected-square), .5);
}
.square.light-selected {
    background-color: rgba(var(--light-selected-square), 1);;
}
.square.light-selected:hover, .square.light-selected:focus {
    background-color: rgba(var(--light-selected-square), .5);
}
.square[data-rank='1']::after {
    content: attr(data-file);

    position: absolute;
    bottom: 1%;
    right: 5%;

    color: rgba(0, 0, 0, 0.4);
    font-size: 16px;
}
.square[data-file='a']::before {
    content: attr(data-rank);
    
    position: absolute;
    top: 1%;
    left: 5%;

    color: rgba(0, 0, 0, 0.4);
    font-size: 16px;
}
.square.bot-left {
    border-bottom-left-radius: .5rem;
}
.square.bot-right {
    border-bottom-right-radius: .5rem;
}
.square.top-left {
    border-top-left-radius: .5rem;
}
.square.top-right {
    border-top-right-radius: .5rem;
}

.drag-piece {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;

    width: 100%;
    height: 100%;

    --bg-img: none;
    background-image: var(--bg-img);
    background-size: cover;
    background-color: transparent;

    translate: -50% -50%;

    cursor: grab;
}
.drag-piece.hidden {
    display: none;
}

.game-container .main .opponent {
    margin: .5rem 0;

    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.game-container .main .opponent .captures {
    display: flex;
    gap: .75rem;
}
.game-container .main .opponent .captures ul {
    display: flex;
    gap: .3rem;
}

.game-container .sidebar {
    padding: 1rem;

    height: 80%;

    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.game-container .sidebar .turn {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
}
.game-container .sidebar .log {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;

    overflow: auto;
}
.game-container .sidebar .log ul {
    padding-right: 1rem;
    width: 100%;

    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    gap: 1rem;

    font-size: 18px;
    font-weight: 500;


    overflow-y: auto;
    overflow-x: hidden;

    scrollbar-color: rgba(var(--font-color), 1) transparent;
    scrollbar-width: thin;
    scrollbar-gutter: thin;
}
.game-container .sidebar .actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.game-container .sidebar span {
    font-size: 20px;
}
.game-container .sidebar div {
    font-size: 28px;
    font-weight: 600;
}


.popup-card {
    position: fixed;
    z-index: 90;

    width: 100vw;
    height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    background-color: rgba(var(--background-color), 0.5);
}
.popup-card.hidden {
    display: none;
}
.popup-card .card {
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;

    height: auto;
    aspect-ratio: 4/3;
}
.popup-card .card > * {
    width: 100%;

    display: flex;
    justify-content: center;
    align-items: center;
}
.popup-card .card header {
    padding: 1.5rem 2rem;

    flex-direction: column;
    gap: .5rem;

    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    background-color: rgba(var(--draw-color), 1);
}
.popup-card.won .card header {
    background-color: rgba(var(--win-color), 1);
}
.popup-card.draw .card header {
    background-color: rgba(var(--draw-color), 1);
}
.popup-card.lost .card header {
    background-color: rgba(var(--lose-color), 1);
}
.popup-card .card header p {
    font-size: 20px;
    text-align: center;
}
.popup-card .card main {
    padding: 2rem;

    justify-content: space-evenly;
    align-items: center;
    gap: 1rem;

    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    background-color: rgba(var(--background-color), 1);
}
.popup-card .card .back {
    position: absolute;
    z-index: 100;
    top: 0;

    width: fit-content;
}
.popup-card .card .back button {
    font-size: 200%;
}

.popup-promotion {
    position: absolute;
    z-index: 20;
    top: auto;
    left: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    border-radius: .5rem;
    background-color: rgba(var(--background-color), 1);
}
.popup-promotion.hidden {
    display: none;
}
.popup-promotion.black {
    flex-direction: column-reverse;
}

.popup-promotion:first-child {
    border-top-left-radius: .5rem;
    border-top-right-radius: .5rem;
}
.popup-promotion:last-child {
    border-bottom-left-radius: .5rem;
    border-bottom-right-radius: .5rem;
}
.popup-promotion .square {
    background-color: rgba(var(--background-white-color), 1);
}
.popup-promotion .square:hover, .popup-promotion .square:focus {
    background-color: rgba(var(--background-white-color), 0.5);
}

.back {
    position: fixed;
    z-index: 100;
    top: 1rem;
    left: 1rem;
}
.back button {
    outline: none;
    border: none;
    background: transparent;

    color: rgba(var(--font-color), 1);
    font-size: 300%;

    cursor: pointer;
}
.back button:hover, .back button:focus {
    color: rgba(var(--font-color), .5);
}

@media (orientation: portrait) {
    .game-container {
        min-height: 170%;

        flex-direction: column;
        gap: 1rem;
    }
    .game-container .main {
        padding: 0;

        width: 95%;
    }
    .game-container .main > * {
        margin: 0 auto;
    }
    .game-container .main .board {
        width: 100%;
        height: auto;
    }
    .game-container .main .opponent {
        align-items: flex-end;
    }

    .game-container .sidebar {
        padding: 0;

        width: 90%
    }
    .game-container .sidebar .log {
        flex: none;
    }
    .game-container .sidebar .log ul {
        padding-right: 0;
        padding-bottom: 1rem;

        grid-auto-flow: column;
        grid-template-columns: unset;
        grid-template-rows: repeat(2, minmax(0, 1fr));

        justify-items: start;

        overflow-y: hidden;
        overflow-x: auto;
    }
    .game-container .sidebar .log ul li {
        text-align: center;
        width: 100%;
    }
}