:root {
    --color-theme-dark: rgb(22, 20, 20);
    --color-theme-grey: rgb(92, 84, 84);
    --color-theme-light: rgb(230, 219, 219);
    --color-theme-numix: rgb(214, 29, 29);
    --color-theme-sky: rgb(135, 224, 232);
    --color-theme-blue: rgb(8, 53, 125);

    --board-length: min(30rem, 90vw);
    --tile-length: calc(var(--board-length) / 3);
    --fs-player-mark: calc(var(--tile-length) * 0.9);

    --nav-height: 5rem;
    --footer-height: 4rem;
    --main-height: max(
        calc(var(--board-length) + var(--nav-height)),
        calc(100vh - var(--nav-height) - var(--footer-height))
    );

    /* Used to set up the initial animation */
    --max-range: calc(var(--board-length) - var(--tile-length));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Courier New", Courier, monospace;
}

body {
    background-color: var(--color-theme-sky);
    /* display: flex;
    justify-content: center;
    align-items: center; */
    display: grid;
    grid-template: var(--nav-height) 1fr var(--footer-height) / 1fr;
    grid-template-areas:
        "nav"
        "game"
        "footer";
    width: 100%;
    height: auto;
    overflow: auto;
}

nav {
    height: var(--nav-height);
    width: 100%;
    background-color: var(--color-theme-dark);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    grid-area: nav;
}

nav > h1.logo {
    font-size: 2.5rem;
    color: var(--color-theme-light);
}

nav > ul {
    display: flex;
    list-style-type: none;
}

nav > ul > li > button {
    margin: 0 0.5rem;
    height: 2.5rem;
    width: 9rem;
    border-radius: 0;
    border: 0 none;
    font-size: 1rem;
    font-weight: bold;
    background-color: var(--color-theme-light);
}

nav > ul > li > button:hover {
    cursor: pointer;
    background-color: var(--color-theme-numix);
}

#game-container {
    grid-area: game;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    /* max-width: calc(var(--board-length)+1px); */
    /* height: var(--main-height); */
    width: 100%;
    height: var(--main-height);
}

.score-board {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    width: var(--board-length);
}

.score-board > #game-header {
    font-size: 1.8rem;
    font-weight: bold;
    text-align: center;
    width: var(--board-length);
    height: fit-content;
    margin-bottom: 1rem;
}

.score-board > .player1-info,
.score-board > .player2-info {
    width: calc(var(--board-length) / 2);
    font-size: 1.3rem;
    color: var(--color-theme-grey);
}

.score-board > .player1-info {
    text-align: left;
}

.score-board > .player2-info {
    text-align: right;
}

.active-player {
    color: var(--color-theme-dark) !important;
}

footer {
    height: var(--footer-height);
    width: 100%;
    background-color: var(--color-theme-dark);
    position: fixed;
    bottom: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    grid-area: footer;
}

footer a {
    color: var(--color-theme-light);
    font-size: 1.5rem;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    color: var(--color-theme-numix);
}

/*********************************************************************/

#board {
    outline: 4px solid var(--color-theme-dark);
    height: var(--board-length);
    width: var(--board-length);
    background-color: var(--color-theme-light);
    display: flex;
    flex-wrap: wrap;
}

#board > .tile {
    height: var(--tile-length);
    width: var(--tile-length);
    background-color: var(--color-theme-light);
    border: 4px solid var(--color-theme-dark);
    display: flex;
    justify-content: center;
    align-items: center;
}

#board > .tile:hover {
    border-color: var(--color-theme-numix);
    cursor: pointer;
}

#board > .tile > .tile-value {
    font-size: var(--fs-player-mark);
    font-weight: bold;
}

/********************  Initial Animation *************************/
#board .animated-container {
    width: var(--tile-length);
    height: var(--tile-length);
    background-color: red;
    position: relative;
    animation-name: myAnimation;
    animation-duration: 4s;
    animation-iteration-count: infinite;
}

@keyframes myAnimation {
    0% {
        background-color: red;
        left: 0px;
        top: 0px;
    }
    25% {
        background-color: yellow;
        left: var(--max-range);
        top: 0px;
    }
    50% {
        background-color: blue;
        left: var(--max-range);
        top: var(--max-range);
    }
    75% {
        background-color: green;
        left: 0px;
        top: var(--max-range);
    }
    100% {
        background-color: red;
        left: 0px;
        top: 0px;
    }
}

/* ***********************  Popup (Modal)  ************************* */
/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 20vh; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0, 0, 0); /* Fallback color */
    background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
    position: relative;
    background-color: var(--color-theme-light);
    margin: auto;
    padding: 0;
    border: 1px solid var(--color-theme-grey);
    width: min(var(--board-length), 90%);
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s;
}

/* Add Animation */
@-webkit-keyframes animatetop {
    from {
        top: -300px;
        opacity: 0;
    }
    to {
        top: 0;
        opacity: 1;
    }
}

@keyframes animatetop {
    from {
        top: -300px;
        opacity: 0;
    }
    to {
        top: 0;
        opacity: 1;
    }
}

/* The Close Button */
.close {
    color: var(--color-theme-light);
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    padding: 2px 1rem;
    background-color: var(--color-theme-blue);
    color: var(--color-theme-light);
    height: 3rem;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.modal-body {
    padding: 2px 1rem;
}

form {
    display: grid;
    gap: 1rem;
    grid-template: auto / repeat(
        auto-fit,
        minmax(13rem, 1fr)
    );
}

form select {
    font-size: 1rem;
    border: none;
    background-color: var(--color-theme-sky);
    height: 2rem;
    width: 10rem;
}

form select:hover {
    cursor: pointer;
    background-color: var(--color-theme-numix);
}

fieldset {
    margin: 1rem 0;
    padding: 0.5rem;
    width: 100%;
}

label {
    display: block;
}

input {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.modal-footer {
    padding: 2px 1rem;
    background-color: var(--color-theme-blue);
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-footer > button {
    height: 2rem;
    width: 6rem;
    background-color: var(--color-theme-light);
    font-size: 1rem;
    font-weight: bold;
    border: none;
}

.modal-footer > button:hover {
    cursor: pointer;
    background-color: var(--color-theme-numix);
}
