@import url('https://fonts.googleapis.com/css2?family=Noto+Sans&family=Roboto&display=swap');
@import './modules/css/spinner.css';

:root {
    --board-size: 100vmin;
    --max-board-size: 800px;
    --piece-size: 12.5%;
    --metal-bg: linear-gradient(to bottom, #3c3934, #33312e 100%);
    --metal-clr: #ccc;
    --metal-clr-hover: #fff;
    --metal-bg-hover: linear-gradient(to bottom, #44413b, #3b3935 100%);
    --panel-bg: #262421;
    --range-width: 35px;
    --range-height: 20px;
    --anim-normal: transform 0.3s ease;
    --anim-fast: transform 0.1s ease;
    --anim-slow: transform 0.5s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: 0;
    outline: none;
    font-family: 'Noto Sans', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: auto;
}

.hidden {
    display: none !important;
}

body {
    display: flex;
    /* justify-content: center; */
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    /* background-color: hsl(45, 10%, 8%); */
    background: #161512 linear-gradient(to bottom, #2e2a24, #161512 116px) no-repeat;
    gap: 10px;
}

header {
    width: 100%;
    display: flex;
    align-items: center;
    z-index: 100;
    padding: 10px 20px;
    flex-wrap: wrap;
    gap: 5px;
}

header .sign-in:not(.hidden),
header .sign-out:not(.hidden) {
    margin-left: auto;
}

header a,
header button {
    color: var(--metal-clr);
    padding: 10px 15px;
    cursor: pointer;
    text-align: center;
    user-select: none;
    white-space: nowrap;
    border-radius: 3px;
    text-decoration: none;
    font-family: 'Roboto', Sans-Serif;
    font-size: 0.9rem;
    background-color: transparent;
}

header a.sign-in {
    color: #3692e7;
    font-weight: 600;
}

header a:hover,
header button:hover {
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.225);
    background: linear-gradient(to bottom, #3c3934, #33312e 100%);
}

.ping-wrapper {
    margin-left: auto;
}

.ping-wrapper,
.info-wrapper {
    color: var(--metal-clr);
    font-size: 0.7rem;
}

.ping-wrapper div > span:first-child,
.info-wrapper div > span:first-child {
    font-weight: bold;
    font-size: 0.75rem;
}

header .preferences {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    padding: 5px;
}

board {
    width: var(--board-size);
    height: var(--board-size);
    max-width: var(--max-board-size);
    max-height: var(--max-board-size);
    position: relative;
    margin: 20px 0 100px 0;
}

board .board-content {
    position: relative;
    background-size: 100% 100%;
    width: 100%;
    height: 100%;
    position: relative;
    background-image: url(assets/board/skins/brown.svg);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    --light-color: #f0d9b5;
    --dark-color: #b58863;
}

board.flipped .board-content {
    transform: rotate(180deg);
}

board.flipped .board-content piece > img {
    transform: rotate(180deg);
}

.board-options .playing-as {
    margin-left: auto;
}

.board-options .color-to-move.black,
.board-options .playing-as.black {
    color: white;
    background-color: black;
    border: 2px solid white;
}

.board-options .color-to-move.white,
.board-options .playing-as.white {
    color: black;
    background-color: white;
    border: 2px solid black;
}

.board-options > * {
    user-select: none;
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
    background: hsl(0 0% 90%);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 1rem;
}

.board-options > button:hover {
    background: hsl(0 0% 85%);
}

.board-options .stop-btn {
    background: hsl(0 30% 70%);
    font-size: 1.1rem;
}

.board-options .stop-btn:hover {
    background: hsl(0 30% 65%);
}

.board-options .auto-flip input {
    cursor: pointer;
}

.board-options .flip-btn::before {
    content: '';
    background-image: url(assets/board/flip.svg);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    height: 100%;
    width: 1.5rem;
}

.board-options {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* transform: translateY(-100%); */
    display: flex;
    cursor: default;
    z-index: 2;
}

/* board.flipped .board-options { */
/* transform: rotate(180deg); */
/* top: 0; */
/* bottom: unset; */
/* } */

board .timer,
board .player-info {
    position: absolute;
    right: 0;
    cursor: default;
    padding: 2px 10px;
    font-size: 1.2rem;
    text-align: right;
    background-color: #262421;
    color: #bababa;
}

board .timer.running {
    background-color: #384722;
    color: #fff;
}

/* board.flipped .timer { */
/* right: unset; */
/* left: 0; */
/* } */

board .player-info {
    background-color: transparent;
    right: unset;
    left: 0;
}

board .player-info .username::after {
    content: '●';
    padding: 0 10px;
    color: hsl(0, 0%, 65%);
}

board .player-info .username {
    color: #fff;
    font-size: 1rem;
}

board .player-info .elo {
    color: #bababa;
    font-size: 0.85rem;
}

board .timer.timer-black,
board .player-info.info-black {
    top: 0;
    transform: translateY(-100%);
}

board .timer.timer-white,
board .player-info.info-white {
    bottom: 0;
    transform: translateY(100%);
}

board.flipped .timer.timer-black,
board.flipped .player-info.info-black {
    top: 100%;
    transform: none;
}

board.flipped .timer.timer-white,
board.flipped .player-info.info-white {
    bottom: 100%;
    transform: none;
}

board .loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: default;
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
}

/* board.flipped .timer.timer-black { */
/* transform: rotate(180deg) translateY(100%); */
/* } */
/* board.flipped .timer.timer-white { */
/* transform: rotate(180deg) translateY(-100%); */
/* } */

piece,
.tile {
    position: absolute;
    width: var(--piece-size);
    height: var(--piece-size);
    user-select: none;
    top: 0;
    left: 0;
    -webkit-tap-highlight-color: transparent;
}

.tile {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.tile.selected {
    background-color: hsla(129, 62%, 21%, 0.5);
}

.tile.move {
    /* background-image: url(assets/board/pointer.png); */
    /* background-size: 80% 80%; */
    /* opacity: 0.75; */
    background: radial-gradient(hsla(129, 62%, 21%, 0.5) 19%, rgba(0, 0, 0, 0) 20%);
}

.tile.lastMove {
    background-color: hsla(73, 100%, 39%, 0.41);
}

.tile.capture {
    /* background-image: url(assets/board/capture.png); */
    background: radial-gradient(transparent 0%, transparent 79%, rgba(20, 85, 0, 0.3) 80%);
    z-index: 2;
}

.tile.check {
    background: radial-gradient(
        ellipse at center,
        red 0%,
        #e70000 25%,
        rgba(169, 0, 0, 0) 89%,
        rgba(158, 0, 0, 0) 100%
    );
    z-index: 1;
}

.tile:hover:not(.lastMove):not(.check):not(.selected) {
    background: hsla(129, 62%, 21%, 0.3);
}

piece {
    /* cursor: grab; */
    transition: var(--anim-normal);
    z-index: 2;
}

piece.ghost {
    opacity: 0.4;
    pointer-events: none;
}

piece:active {
    /* cursor: grabbing; */
    z-index: 3;
    transition: none !important;
    /* pointer-events: none; */
}

piece.dragging {
    pointer-events: none;
}

piece img {
    width: 100%;
    height: 100%;
    pointer-events: none;
    object-fit: contain;
}

board.flipped coords {
    transform: rotate(180deg);
}

coords {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    font-size: 0.7em;
    color: white;
    display: flex;
}

coord {
    font-weight: 600;
}

coords.rows {
    right: 0;
    top: 0;
    flex-direction: column-reverse;
    height: 100%;
}

board.flipped coords.rows {
    flex-direction: column;
    right: unset;
    left: 0;
}

coords.rows coord {
    flex: 1;
    padding: 5px;
}

coords.columns {
    left: 0;
    bottom: 0;
    flex-direction: row;
    width: 100%;
}

board.flipped coords.columns {
    flex-direction: row-reverse;
    bottom: unset;
    top: 0;
}

coords.columns coord {
    flex: 1;
    padding: 1px 4px;
}

board[moves-indicator='0'] .tile.move,
board[moves-indicator='0'] .tile.capture {
    opacity: 0;
}

board[animation-speed='0'] piece {
    transition: none;
}
board[animation-speed='1'] piece {
    transition: var(--anim-fast);
}
board[animation-speed='2'] piece {
    transition: var(--anim-normal);
}
board[animation-speed='3'] piece {
    transition: var(--anim-slow);
}

coords.rows coord:nth-child(1),
coords.rows coord:nth-child(3),
coords.rows coord:nth-child(5),
coords.rows coord:nth-child(7),
coords.columns coord:nth-child(2),
coords.columns coord:nth-child(4),
coords.columns coord:nth-child(6),
coords.columns coord:nth-child(8) {
    color: var(--dark-color);
}

coords.rows coord:nth-child(2),
coords.rows coord:nth-child(4),
coords.rows coord:nth-child(6),
coords.rows coord:nth-child(8),
coords.columns coord:nth-child(1),
coords.columns coord:nth-child(3),
coords.columns coord:nth-child(5),
coords.columns coord:nth-child(7) {
    color: var(--light-color);
}

board.flipped coords.rows coord:nth-child(1),
board.flipped coords.rows coord:nth-child(3),
board.flipped coords.rows coord:nth-child(5),
board.flipped coords.rows coord:nth-child(7),
board.flipped coords.columns coord:nth-child(2),
board.flipped coords.columns coord:nth-child(4),
board.flipped coords.columns coord:nth-child(6),
board.flipped coords.columns coord:nth-child(8) {
    color: var(--light-color);
}

board.flipped coords.rows coord:nth-child(2),
board.flipped coords.rows coord:nth-child(4),
board.flipped coords.rows coord:nth-child(6),
board.flipped coords.rows coord:nth-child(8),
board.flipped coords.columns coord:nth-child(1),
board.flipped coords.columns coord:nth-child(3),
board.flipped coords.columns coord:nth-child(5),
board.flipped coords.columns coord:nth-child(7) {
    color: var(--dark-color);
}

div.waiting {
    color: white;
    font-size: 3rem;
    text-align: center;
}

div.waiting a {
    font-size: 1rem;
    background-color: #fff;
    color: blue;
    padding: 5px 10px;
    border-radius: 5px;
}

div.waiting button {
    font-size: 1.5rem;
    background-color: #fff;
    color: black;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

div.waiting button:hover {
    background-color: #ccc;
}

div.play h2 {
    color: white;
    padding: 6px 12px;
    /* border-radius: 5px; */
    background: linear-gradient(to bottom, #3c3934, #33312e 100%);
    border-radius: 3px;
}

div.play,
div.waiting {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: hsl(0 0% 0% / 50%);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

div.play div.content {
    padding: 10px;
    gap: 20px;
    display: flex;
    flex-direction: column;
    max-width: 95%;
}

div.waiting {
    padding: 10px;
    gap: 20px;
    display: flex;
    flex-direction: column;
}

div.play div.content button a {
    color: inherit;
    transition: inherit;
}

div.play div.content button {
    background: var(--metal-bg);
    color: var(--metal-clr);
    transition: all 150ms;
    border-radius: 3px;
    font-size: 1.1rem;
}

div.play div.content button:not(.selected):hover {
    background: var(--metal-bg-hover);
    color: var(--metal-clr-hover);
}

div.play .gamemode,
div.play .online {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    /* justify-content: center; */
    /* align-items: center; */
}

div.play .gamemode button,
div.play .online button {
    flex: 1 1 180px;
}

.selected:not(.tile) {
    background: #de7233 !important;
    transition: none;
    color: var(--metal-clr-hover) !important;
}

div.play button {
    cursor: pointer;
    padding: 10px 15px;
    font-size: 1rem;
}

div.play button.puzzle {
    padding: 0;
}

div.play button a {
    text-decoration: none;
    padding: 5px 10px;
    display: block;
}

div.play .play-btn {
    font-size: 2rem;
    padding: 10px 20px;
}

/* board.flipped div.info { */
/* transform: rotate(180deg) translate(50%, 50%); */
/* } */

div.info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-height: 50%;
    max-height: 600px;
    background-color: hsl(0 0% 40% / 80%);
    backdrop-filter: blur(3px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    text-align: center;
    cursor: default;
    box-shadow: 0 0 5px 0 hsl(0 0% 0% / 40%);
    min-width: 280px;
    z-index: 3;
    color: white;
}

div.info .buttons {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

div.info .buttons button {
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}

div.info.white {
    color: black;
    background-color: hsl(0 0% 90% / 80%);
    border: 2px solid hsl(0 0% 10% / 80%);
}

div.info.black {
    color: white;
    background-color: hsl(0 0% 10% / 80%);
    border: 2px solid hsl(0 0% 90% / 80%);
}

div.info.white .buttons button {
    color: white;
    background-color: hsl(0 0% 10% / 70%);
    border: 2px solid hsl(0 0% 10% / 100%);
}

div.info.white .buttons button:hover {
    background-color: hsl(0 0% 10% / 60%);
}

div.create-game,
div.join-game,
div.level-selector,
div.finding-game {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: hsl(0 0% 0% / 50%);
    backdrop-filter: blur(3px);
    font-size: 1.6rem;
    color: white;
}

div.time-selector,
div.join-game .inner,
div.level-selector .inner,
div.finding-game .inner {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 3px;
    max-width: 95%;
    position: relative;
}

div.time-selector *,
div.level-selector .inner *,
div.finding-game .inner * {
    border-radius: 3px;
}

div.time-selector button,
div.time-selector select,
div.level-selector .inner button,
div.finding-game .inner button {
    font-size: 1.7rem;
    padding: 5px 10px;
    cursor: pointer;
}

div.time-selector label,
div.level-selector .inner label {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    text-align: center;
    flex-direction: column;
}

div.time-selector label span,
div.level-selector .inner label span {
    display: flex;
    gap: 10px;
    font-weight: normal;
    font-size: 1.5rem;
    justify-content: center;
    align-items: center;
}

div.time-selector b {
    font-size: 1.8rem;
    font-weight: bold !important;
}

div.time-selector input,
div.time-selector select,
div.level-selector .inner input {
    width: 100%;
    min-width: 100px;
}

div.time-selector .btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

div.time-selector .btns div {
    flex: 1;
    background: var(--metal-bg);
    color: var(--metal-clr);
    cursor: pointer;
    padding: 5px 10px;
    user-select: none;
}

div.time-selector .btns div:not(.selected):hover {
    background: var(--metal-bg-hover);
}

div.time-selector .color-selection,
div.level-selector .color-selection {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
}

div.time-selector button,
div.level-selector .inner button {
    background: var(--metal-bg);
    color: var(--metal-clr);
}

div.time-selector button:hover,
div.level-selector .inner button:hover {
    background: var(--metal-bg-hover);
    color: var(--metal-clr-hover);
}

.color-btn {
    width: 80px;
    /* height: 80px; */
    cursor: pointer;
    position: relative;
    background: var(--metal-bg);
    aspect-ratio: 1;
}

.color-btn:hover {
    background: var(--metal-bg-hover);
}

.color-btn::after {
    content: '';
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    position: absolute;
    inset: 5px;
}

.color-btn.random {
    width: 100px;
    /* height: 100px; */
}

.color-btn.white::after {
    background-image: url('assets/pieces/skin0/wK.svg');
}

.color-btn.black::after {
    background-image: url('assets/pieces/skin0/bK.svg');
}

.color-btn.random::after {
    background-image: url('assets/pieces/skin0/white-black-king.svg');
}

div.time-selector .cancel-btn,
div.join-game .cancel-btn,
div.level-selector .close-btn,
div.finding-game .close-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    transform: translate(30%, -30%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 21px;
    font-weight: bold;
    cursor: pointer;
    background: var(--metal-bg);
    color: var(--metal-clr);
    transition: all 150ms;
}

div.time-selector .cancel-btn:hover,
div.join-game .cancel-btn:hover,
div.level-selector .close-btn:hover {
    background: var(--metal-bg-hover);
    color: var(--metal-clr-hover);
}

.range {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    outline: none;
    background-color: transparent;
    position: relative;
}

.range::-webkit-slider-runnable-track {
    width: 100%;
    height: var(--range-height);
    cursor: pointer;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #000000;
    background: #4d4d4d;
    border-radius: 50px;
    border: 0px solid #000;
}

.range::-webkit-slider-thumb {
    /* all: unset; */
    -webkit-appearance: none;
    border: 1px solid #6b6b6b;
    height: var(--range-height);
    width: var(--range-width);
    border-radius: 50px;
    background: #262421;
    cursor: pointer;
}

.range::-moz-range-track {
    width: 100%;
    height: var(--range-height);
    cursor: pointer;
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #000000;
    background: #4d4d4d;
    border-radius: 50px;
    border: 0px solid #000;
}

.range::-moz-range-thumb {
    box-shadow: 0px 0px 0px #000000, 0px 0px 0px #000000;
    border: 1px solid #6b6b6b;
    height: var(--range-height);
    width: var(--range-width);
    border-radius: 50px;
    background: #262421;
    cursor: pointer;
}

.range::-ms-track {
    width: 100%;
    height: var(--range-height);
    cursor: pointer;
    background: transparent;
    border-color: transparent;
    border-width: 39px 0;
    color: transparent;
}

table {
    border-collapse: collapse;
    width: 90%;
    text-align: left;
    color: #bababa;
    overflow: auto;
}

table td,
table th {
    padding: 8px 12px;
}

table td {
    border-bottom: 1px solid #404040;
}

table tr:last-child td {
    border-bottom: 0px solid #404040;
}

table tr:not(:first-child):hover {
    background-color: hsl(22 100% 62% / 20%);
    transition: background-color 100ms;
    cursor: pointer;
}

table a {
    color: #ddd;
    background-color: #3692e7;
    text-decoration: none;
    border-radius: 3px;
    padding: 5px 10px;
    font-size: 1.4rem;
}

table a:hover {
    color: #fff;
    background-color: #56a3eb;
}

table th {
    color: #fff;
}

.join-game > .inner {
    max-height: 600px;
    max-width: 95%;
    width: unset;
    text-align: center;
}

.join-game > .inner .game-list {
    overflow: auto;
    flex: 1;
    padding: 20px;
    width: 100%;
}

div.finding-game .inner {
    align-items: center;
    gap: 50px;
}

board[theme='blue'] .board-content {
    /* background-image: url(assets/board/skins/solid/blue.svg); */
    --light-color: #dee3e6;
    --dark-color: #8ca2ad;
}
board[theme='green'] .board-content {
    /* background-image: url(assets/board/skins/solid/green.svg); */
    --light-color: #ffffdd;
    --dark-color: #86a666;
}
board[theme='purple'] .board-content {
    /* background-image: url(assets/board/skins/solid/purple.svg); */
    --light-color: #ffffdd;
    --dark-color: #86a666;
}
board[theme='ic'] .board-content {
    /* background-image: url(assets/board/skins/solid/ic.svg); */
    --light-color: #ffffdd;
    --dark-color: #86a666;
}

board[theme='blue2'] .board-content {
    /* background-image: url(assets/board/skins/texture/blue2.jpg); */
    --light-color: #dee3e6;
    --dark-color: #8ca2ad;
}
