/* #region RESETS */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", "Helvetica Neue", "Helvetica", Arial, sans-serif;
}

:root {
    --theme-background: #fff;
    --theme-text: #000;
    --theme-link: indigo;
    --theme-link-hover: crimson;
}

body {
    color: var(--theme-text);
    background-color: var(--theme-background);
}

a {
    text-decoration: none;
    color: var(--theme-link);
    transition: color 300ms;
}

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

button {
    padding: 12px;
    border: 1px solid black;
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    transition: all 300ms;
}

button:hover {
    filter: brightness(1.2);
}

button:active {
    box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.5);
}

svg {
    width: 100%;
    height: 100%;
}


/* #endregion RESETS */


/* #region MAIN LAYOUT */

body {
    background-image: url(wood.jpg);
    background-position: center;
    color: white;
    text-shadow: 1px 1px 2px black;
}

.wrapper {
    display: grid;
    justify-content: center;
    grid-template-rows: auto 82px 1fr;
    min-height: 90vh;
    padding: 0 2.5vw;
}


/* #endregion MAIN LAYOUT */


/* #region HEADER */

.game {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.main-header {
    display: grid;
    grid-template-rows: 92px 56px 40px;
}

.title {
    padding-bottom: 8px;
}

.level-container {
    font-size: 1.2rem;
    font-weight: 700;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    max-width: 360px;
}

.level-text {
    color: lawngreen;
}

.margin-right {
    margin-right: 24px;
}

.game-nav {
    display: flex;
    justify-content: space-between;
    gap: 1vw;
}

.game-level__container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1vw;
}

.game-level {
    width: 64px;
    background-color: palegreen;
    box-shadow: 1px 1px 3px 0 rgba(0, 0, 0, 0.75);
}

.game-level svg,
.mode svg {
    max-height: 24px;
}

.game-level.selected {
    color: white;
    background-color: lawngreen;
    transform: scale(1.03);
    box-shadow: 3px 3px 6px 0 rgba(0, 0, 0, 0.5);
}

button.game-level.inactive {
    color: gray;
    background-color: darkgray;
    filter: brightness(1);
    box-shadow: 3px 3px 6px 0 rgba(0, 0, 0, 0.5);
}

button.game-level.inactive svg {
    fill: gray;
}

.explanation {
    display: flex;
    align-items: center;
}

.mode {
    width: 100%;
    max-width: 150px;
    margin-right: 16px;
}

.mode.fri {
    background-color: khaki;
}

.mode.streak {
    background-color: orange;
}


/* #endregion HEADER */


/* #region GAME BOARD */

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    background-color: black;
    border: 8px solid black;
    box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.75);
}

.field {
    --piece-icon-color: khaki;
    background-image: url(wood-piece.jpg);
    background-size: 300%;
    width: 25vw;
    height: 25vw;
    max-width: 20vh;
    max-height: 20vh;
    box-shadow: inset 3px 3px 6px 0 rgba(0, 0, 0, 0.75);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.field--0 {
    background-position: 0 80%;
}

.field--1 {
    background-position: 100% 90%;
}

.field--2 {
    background-position: 0 80%;
}

.field--3 {
    background-position: 200% 100%;
}

.field--4 {
    background-position: 0 80%;
}

.field--5 {
    background-position: 200% 100%;
}

.field--6 {
    background-position: 100% 90%;
}

.field--7 {
    background-position: 200% 100%;
}

.field--8 {
    background-position: 100% 90%;
}

.field-piece {
    background-image: url(wood-piece.jpg);
    background-position: 0 0;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    opacity: 0;
}

.field:hover .field-piece {
    opacity: 0.5;
    box-shadow: 5px 5px 10px 0 rgba(0, 0, 0, 0.75);
}

.field.placed .field-piece {
    opacity: 1;
    box-shadow: 5px 5px 10px 0 rgba(0, 0, 0, 0.75);
}

.field:hover {
    background-color: #bfff80;
}

.field.placed:hover {
    cursor: not-allowed;
}

.field svg {
    fill: var(--piece-icon-color);
}

.field.x .x {
    display: block;
}

.field.o .o {
    display: block;
}

.placed .field-piece {
    animation-name: bounce;
    animation-duration: 1200ms;
}

.placed .field-piece svg {
    animation-name: colorFade;
    animation-duration: 800ms;
}

@keyframes bounce {
    0% {
        transform: scale(1);
    }
    3% {
        transform: scale(1.5);
    }
    6% {
        transform: scale(0.1);
    }
    9% {
        transform: scale(1.25);
    }
    12% {
        transform: scale(0.75);
    }
    15% {
        transform: scale(1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes colorFade {
    0% {
        fill: gold;
    }
    20% {
        fill: gold;
    }
    100% {
        fill: var(--piece-icon-color);
    }
}


/* #endregion GAME BOARD */


/* #region WIN SCREEN */

.win-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: visible;
    opacity: 1;
    transform: scale(1);
    transition: all 150ms ease-out;
}

.win-screen__content {
    background-image: url(wood-piece.jpg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    border: 1vw solid white;
    border-radius: 8px;
    padding: 16px;
    min-height: 240px;
    box-shadow: 10px 10px 20px 0 black, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
}

.win-screen__padding-left {
    padding-left: 8px;
}

.win-screen__text {
    padding-right: 16px;
}

.win-screen__content .icon {
    width: 20vw;
    height: 20vw;
    max-width: 180px;
    max-height: 180px;
    fill: white;
}


/* #endregion WIN SCREEN */


/* #region LEVEL UP SCREEN */

.level-up-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: visible;
    opacity: 1;
    transform: scale(1);
    transition: all 150ms ease-out;
}

.level-up-screen.animation .level-up-screen__content {
    animation-name: levelUp;
    animation-duration: 4s;
}

.level-up-screen__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-image: url(wood-piece.jpg);
    background-color: white;
    border: 1vw solid gold;
    border-radius: 8px;
    padding: 64px;
    box-shadow: 10px 10px 20px 0 black, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
}

.level-up-screen__content .icon {
    width: 40vw;
    height: 40vw;
    max-width: 230px;
    max-height: 230px;
    margin-bottom: 16px;
    fill: gold;
}

@keyframes levelUp {
    0% {
        box-shadow: 10px 10px 20px 0 black, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
    }
    3% {
        box-shadow: 10px 10px 20px 0 black, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
    }
    10% {
        box-shadow: 0 0 100px 20px gold, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
    }
    100% {
        box-shadow: 10px 10px 20px 0 black, inset 4px 4px 10px 0 rgba(0, 0, 0, 0.75);
    }
}


/* #endregion LEVEL UP SCREEN */


/* #region JS SETs */

.hidden {
    display: none;
}

.transparent {
    visibility: hidden;
    opacity: 0;
    transform: scale(0);
}


/* #endregion JS SETs */


/* #region STATS */

.game-stats {
    max-width: 360px;
}

.game-stats__content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.game-stats__field {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
}

.game-stats__title {
    font-weight: 500;
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.game-stats__value {
    color: lawngreen;
    font-size: 1.4rem;
}

.stat-icon {
    width: 100%;
    height: 100%;
    fill: white;
}

.stat-icon--smaller {
    width: 80%;
    height: 80%;
}

.next-level {
    font-size: 0.9rem;
}

.next-level-value {
    font-size: 1.3rem;
    color: lawngreen;
}


/* #endregion STATS */