/* Bootstrap */
.tooltip {
	--bs-tooltip-color: #e16d6d !important;
	--bs-tooltip-bg: #ffdede !important;
	--bs-tooltip-opacity: 1 !important;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
	touch-action: manipulation;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Helvetica, Arial, sans-serif;
	font-weight: 600;
}

html,
body {
	width: 100%;
	height: 100%;
}

body {
	overflow: hidden;
	background-color: #121213 !important;
}

#header-ui {
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 5px;
}

#header-ui .header-spacer {
	width: 1dvmin;
	height: 100%;
}

#header-ui > p {
	display: inline;
	font-size: 16px;
	margin-bottom: 0;
}

#header-ui > label {
	white-space: nowrap;
}

#header-ui input:not(#think-time) {
	width: max(500px, 30vw);
	height: 50%;
	text-align: center;
	border-radius: 10px;
	color: black;
	background-color: transparent;
	border-color: black;
	transition: color 250ms ease-in-out, background-color 250ms ease-in-out, border-color 250ms ease-in-out;
	font-size: 14px;
	white-space: nowrap;
}

#think-time {
	width: 50px !important;
}

#header-ui input.invalid,
#header-ui input.invalid:focus {
	color: rgb(200, 0, 0);
	background-color: rgba(255, 0, 0, 0.1);
	border-color: rgba(255, 0, 0, 0.5);
}

#header-ui button {
	width: max(100px, 5vw);
	height: 50%;
	border-radius: 10px;
	transition: color 250ms ease-in-out, background-color 250ms ease-in-out, border-color 250ms ease-in-out;
	color: rgb(0, 50, 0);
	background-color: rgba(0, 200, 0, 0.2);
	border: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: inherit;
	padding: 0 8px;
	white-space: nowrap;
}

@media (hover: hover) {
	#header-ui button:hover {
		color: rgb(0, 25, 0);
		background-color: rgba(0, 175, 0, 0.5);
	}
}

#header-ui button:active {
	color: rgb(0, 25, 0);
	background-color: rgba(0, 150, 0, 0.5);
	transition: color 75ms ease-in-out, background-color 75ms ease-in-out, border-color 75ms ease-in-out;
}

#header-ui button.invalid {
	color: rgb(200, 0, 0);
	background-color: rgba(255, 0, 0, 0.2);
	cursor: not-allowed;
	pointer-events: inherit;
}

#header-container {
	display: flex;
	justify-content: center;
}

#header {
	width: 95%;
	height: max(75px, 8dvmin);
	background-color: white;
	border-radius: 0px 0px max(75px, 8dvmin) max(75px, 8dvmin);
	overflow-y: hidden;
}

#board-container {
	position: relative;
	display: flex;
	width: 100%;
	height: calc(100% - max(75px, 8dvmin));
	justify-content: center;
	align-items: center;
}

#board {
	display: absolute;
	width: 82.5dvmin;
	height: 82.5dvmin;
	background-color: white;
}

.board-rank {
	position: absolute;
	top: 0;
	left: 0;
	margin: calc(82.5dvmin / 8 / 18);
	font-size: calc(82.5dvmin / 8 / 4);
}

.board-file {
	position: absolute;
	bottom: 0;
	right: 0;
	margin: calc(82.5dvmin / 8 / 18);
	font-size: calc(82.5dvmin / 8 / 4);
}

.square {
	position: relative;
	width: calc(82.5dvmin / 8);
	height: calc(82.5dvmin / 8);
	display: inline-flex;
	vertical-align: top;
	justify-content: center;
	align-items: center;
	transition: background-color 250ms ease-out, box-shadow 50ms ease-out;
}

.square:has(img) {
	cursor: grab;
}

.previously-moved-square:has(img) {
	z-index: 2;
}

.square > img {
	width: calc(82.5dvmin / 8 * 0.9);
	height: calc(82.5dvmin / 8 * 0.9);
	z-index: 1;
	transition: opacity 150ms ease-in-out, top 500ms linear, left 500ms linear;
	opacity: 1;
}

.light {
	background-color: #edd6b0;
	color: #b88762;
}

.light.selected-square {
	background-color: #f6eb72;
	color: #d4ab6a;
}

.light.previously-moved-square {
	background-color: #f6eb72;
	color: #d4ab6a;
}

.dark {
	background-color: #b88762;
	color: #edd6b0;
}

.dark.selected-square {
	background-color: #dcc34b;
	color: #b88762;
}

.dark.previously-moved-square {
	background-color: #dcc34b;
	color: #b88762;
}

.hovered-square:not(:has(img + .legal-circle)):not(.hovered-square-off) {
	box-shadow: inset 0 0 0 calc(82.5dvmin / 8 / 18) rgba(255, 255, 255, 0.5);
}

.hovered-square:has(.legal-circle):not(.hovered-square-off) > .legal-circle {
	border-color: rgba(255, 255, 255, 0.5);
}

@media (hover: hover) {
	.square:not(:has(img + .legal-circle)):not(.hovered-square-off):hover {
		box-shadow: inset 0 0 0 calc(82.5dvmin / 8 / 18) rgba(255, 255, 255, 0.5);
	}

	.square:has(.legal-circle):not(.hovered-square-off):hover > .legal-circle {
		border-color: rgba(255, 255, 255, 0.5);
	}
}

.legal-circle {
	position: absolute;
	width: calc(82.5dvmin / 8 / 3);
	height: calc(82.5dvmin / 8 / 3);
	border-radius: 50%;
	background-color: rgba(0, 0, 0, 0.15);
	pointer-events: none;
}

.square:has(.legal-circle) {
	cursor: pointer;
}

img + .legal-circle {
	border: calc(82.5dvmin / 8 / 12) solid rgba(0, 0, 0, 0.15);
	background-color: transparent;
	width: calc(82.5dvmin / 8 - 0.5dvmin);
	height: calc(82.5dvmin / 8 - 0.5dvmin);
}

#promotion {
	position: absolute;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	display: none;
	justify-content: center;
	align-items: center;
	gap: 7dvmin;
	z-index: 3;
}

#promotion .promotion-piece:first-child {
	margin-bottom: 7dvmin;
}

#promotion .promotion-piece {
	background-color: rgba(0, 0, 0, 0.25);
	border-radius: 10%;
	width: 40dvmin;
	height: 40dvmin;
	display: flex;
	justify-content: center;
	align-items: center;
	cursor: pointer;
}

#promotion .promotion-piece img {
	width: 90%;
	height: 90%;
}

#cover {
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0px;
	left: 0px;
	z-index: 2;
	display: none;
}

.square:not(.selected-square):not(.previously-moved-square) > .check-square {
	position: absolute;
	width: calc(82.5dvmin / 8);
	height: calc(82.5dvmin / 8);
	background: radial-gradient(rgba(255, 0, 0, 0.9), transparent) !important;
	opacity: 0;
	transition: opacity 150ms ease-out;
}

.flipped {
	transform: rotate(180deg);
}

#end-game-container {
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	display: none;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	opacity: 0;
	transition: opacity 250ms ease-in-out;
	z-index: 9;
}

#end-game-top {
	margin-top: max(75px, 8dvmin);
	background-color: gainsboro;
	width: 45dvmin;
	height: 10dvmin;
	z-index: 10;
	border-radius: 10dvmin 3dvmin 0 0;
	border: 3px solid black;
	border-bottom: none;
}

#end-game-bottom {
	background-color: gainsboro;
	width: 45dvmin;
	height: 10dvmin;
	z-index: 10;
	border-radius: 0 0 10dvmin 3dvmin;
	border: 3px solid black;
	border-top: none;
}

#end-game {
	width: 45dvmin;
	height: 40dvmin;
	background-color: gainsboro;
	z-index: 10;
	border: 3px solid black;
	border-top: none;
	border-bottom: none;
	text-align: center;
}

#result-text {
	font-size: 6dvmin;
	font-weight: bold;
	text-decoration: underline;
	color: black;
}

#result-text-description {
	font-size: 4dvmin;
	margin-top: 10dvmin;
	font-weight: bold;
	color: black;
}

#end-game-buttons {
	margin-top: 10dvmin;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 3dvmin;
}

.end-game-button {
	width: 15dvmin;
	height: 5dvmin;
	color: rgb(0, 50, 0);
	background-color: rgba(0, 200, 0, 0.2);
	border: none;
	border-radius: 10px;
	cursor: pointer;
	transition: background-color 250ms ease-in-out;
	font-size: 2dvmin;
}

@media (hover: hover) {
	.end-game-button:hover {
		background-color: rgba(0, 175, 0, 0.5);
	}
}

.end-game-button:active {
	color: rgb(0, 25, 0);
	background-color: rgba(0, 150, 0, 0.5);
	transition: background-color 75ms ease-in-out;
}

@media (max-width: 1300px) {
	#header {
		overflow-x: scroll;
		height: calc(max(75px, 8dvmin) + 17px);
	}

	#header-ui {
		width: 1250px;
	}
}

@media (max-height: 425px) {
	#header {
		display: none;
	}

	#board-container {
		height: 100%;
	}
}
