:root {
	--header-height: 40px;
	--footer-height: calc(40px + env(safe-area-inset-bottom));

	--nav-pull-tab-width: 50px;

	/* To access from js getComputedStyle(document.documentElement).getPropertyValue('--sat') */
	--sat: env(safe-area-inset-top);
	--sab: env(safe-area-inset-bottom);
	--sal: env(safe-area-inset-left);
	--sar: env(safe-area-inset-right);
}

/* ====================================== development ============================================= */
/* * {
	outline: 1px solid;
}

svg * {
	outline: none;
} */

/* ====================================== reset ============================================= */

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* Fix mobile Safari increase font-size on landscape mode */
html {
	-moz-text-size-adjust: none;
	-webkit-text-size-adjust: none;
	text-size-adjust: none;
}

/* For images to not be able to exceed their container */
img,
svg {
	max-inline-size: 100%;
	max-block-size: 100%;
	max-width: 100%;
	max-height: 100%;
}

/* input:not([type="checkbox"]) { */
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="file"],
input[type="month"],
input[type="number"],
input[type="password"],
input[type="range"],
input[type="tel"],
input[type="text"],
input[type="time"],
input[type="url"],
select {
	font-family: inherit;
	width: 100%;
	font-size: inherit;
	color: inherit;
	padding: 0 0.25rem;
	text-decoration: inherit;
}

input:not([type="date"]):invalid {
	border: 0.01rem solid red;
	background-color: lightpink;
}

input[type="checkbox"] {
	appearance: none;
	position: relative;
	display: inline-block;
	/* background: lightgrey; */
	background: red;
	height: 1rem;
	width: 1.5rem;
	padding: 0.1rem;
	vertical-align: middle;
	border-radius: 99999px;
	box-shadow: 0px 1px 3px #0003 inset;
	transition: 0.25s linear background;
	border-color: var(--cw-success);
	cursor: pointer;
	flex-shrink: 0; /* Just in case inside a flexbox */
}

input[type="checkbox"]::before {
	content: "";
	display: block;
	height: 100%;
	width: auto;
	aspect-ratio: 1 / 1;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0px 1px 3px #0003;
	transition: 0.25s linear transform;
	transform: translateX(0rem);
	position: initial;
}
input[type="checkbox"]:checked {
	background: green;
}
input[type="checkbox"]:checked::before {
	transform: translateX(0.5rem); /* width - height */
}
input[type="checkbox"]:focus {
	outline: 0.1rem solid black;
	outline-offset: -0.1rem;
}
input[type="checkbox"]::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 50%;
	line-height: 0;
	font-size: 0.5rem;
	transition: 0.25s linear transform;
	transform: translateX(0rem);
}
input[type="checkbox"]:not(:checked)::after {
	content: "off";
	transform: translateX(0rem);
}
input[type="checkbox"]:checked::after {
	content: "on";
	transform: translateX(0.5rem);
}

input[type="range"] {
	cursor: ew-resize;
}

body {
	font-family: Arial, Helvetica, sans-serif;
	/* background-color: black; */

	overscroll-behavior-y: none;
	overscroll-behavior-block: none;

	height: 100vh; /* Fallback */
	height: 100dvh;
	overflow: hidden;
}

/* ====================================== app ============================================= */
.app {
	height: 100vh; /* Fallback */
	height: 100dvh;
	display: grid;
	grid-template-rows: var(--header-height) 1fr var(--footer-height);
	overflow: auto;
	background-color: lightgray;

	overscroll-behavior-y: none;
	overscroll-behavior-block: none;
	touch-action: pinch-zoom;
}

/* ====================================== main ============================================= */
main {
	display: grid;
	grid-template-columns: 1fr;
	grid-template-rows: 1fr 2fr;
	overflow: hidden;
}

@media (orientation: landscape) {
	main {
		display: grid;
		grid-template-columns: 1fr 2fr;
		grid-template-rows: 1fr;
	}
}

/* ====================================== player ============================================= */
.playerArea {
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr;
}

@media (orientation: landscape) {
	.playerArea {
		display: grid;
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 1fr;
	}
}

.player {
	display: grid;
	grid-template-rows: auto 1fr;
	container-type: size;
	text-align: center;
}

.player .areaLabel {
	color: white;
	background-color: darkgray;
	font-weight: bold;
}

.player .stat {
	display: flex;
	flex-direction: column;
	justify-content: space-around;
}

.player .stat .nickname {
	font-weight: bold;
}

.player .stat .sessionWentFirst,
.player .stat .sessionWon {
	display: inline-block;
	line-height: 0;
	vertical-align: middle;
}

.player .stat .sessionWentFirst.squishPip,
.player .stat .sessionWon.squishPip {
	letter-spacing: -0.15em;
	font-size: 0.65rem;
}

.player .profile {
	display: grid;
	grid-template-rows: 1fr;
	grid-template-columns: 1fr;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

@container (orientation: landscape) {
	.player .profile {
		grid-template-rows: 1fr;
		grid-template-columns: 1fr 1fr;
	}
}

.playerArea .player .profile .avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	/* position: relative; */
	overflow: hidden;
}

.playerArea .player .profile .avatar img {
	/* width: 100%; */
	/* height: 100%; */
	/* position: absolute; */
	object-fit: contain;

	outline: 15px solid;
	outline-offset: -15px;
	border-radius: 9999px;
	/* Color from js */
	outline-color: transparent;
}

/* ====================================== game area ============================================= */
.gameArea {
	position: relative;
	container-type: size;
	display: grid;
}

.gameBoardWrapper {
	display: grid;
	position: absolute;
	height: auto;
	width: 100%;
	/* aspect-ratio: 1/1; */
	aspect-ratio: 412/435;
	justify-self: center;
	align-self: center;
}

@container (orientation: landscape) {
	.gameBoardWrapper {
		height: 100%;
		width: auto;
	}
}

.gameBoard {
	justify-self: center;
	align-self: end;
	overflow: visible;
}

.dropBtnWrapper {
	display: flex;
	align-items: center;
	justify-content: space-evenly;
	padding: 0 2%;
	height: 50px;
}

.dropBtnWrapper .dropBtn {
	width: 10%;
	height: 60%;
	line-height: 0;
	cursor: pointer;
}

.dropBtnWrapper .dropBtn img {
	pointer-events: none;
}

svg.gameBoard .checkerWrapper .checker {
	stroke-width: 2;
}

svg.gameBoard .checkerWrapper .checker[data-playerNum="1"] {
	/* stroke: black; */
	fill: url(#checkerAvatarP1);
}

svg.gameBoard .checkerWrapper .checker[data-playerNum="2"] {
	/* stroke: red; */
	fill: url(#checkerAvatarP2);
}

/* ====================================== header/footer ============================================= */

header {
	height: var(--header-height);
	color: white;
	fill: white;
	background-color: black;
	padding: 0 var(--nav-pull-tab-width);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
}

header .headerIcon {
	width: 32px;
	margin-right: 10px;
}

footer {
	height: var(--footer-height);
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	color: white;
	background-color: black;
	padding: 0 0.25rem;
	white-space: nowrap;

	& .right {
		justify-self: end;
	}
}

/* ====================================== msg ============================================= */
/* Inserted dynamically by msg.js */
.msgFullParent.backdrop {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.msgFullParent.backdrop .content {
	padding: 1rem;
	border-radius: 0.5rem;
	border: 0.25rem solid;
}

/* ====================================== nav Menu ============================================= */

nav {
	position: fixed;
	top: 0;
	font-size: 1.25rem;
	background-color: #fdfdfd;
	transition: translate 300ms ease-in-out;
	z-index: 2;

	&.left {
		left: 0;
		translate: -100%;
		border-right: 0.1rem solid black;
		border-bottom: 0.1rem solid black;
		border-bottom-right-radius: 5px;
	}

	&.right {
		right: 0;
		translate: 100%;
		transition: translate 300ms ease-in-out;
		border-left: 0.1rem solid black;
		border-bottom: 0.1rem solid black;
		border-bottom-left-radius: 0.5rem;
	}

	&.open {
		translate: 0;
	}

	&.right.open {
		box-shadow: -4px 6px 6px rgba(0, 0, 0, 0.6);
	}

	&.left.open {
		box-shadow: 4px 6px 6px rgba(0, 0, 0, 0.6);
	}

	& .menuBody {
		overflow: auto;
		max-height: 100dvh;
		background-color: inherit;
	}

	&.left .menuBody {
		border-bottom-right-radius: 5px;
	}

	&.right .menuBody {
		border-bottom-left-radius: 5px;
	}

	& .pullTab {
		position: absolute;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		line-height: 0;
		width: var(--nav-pull-tab-width);
		height: var(--header-height);
		cursor: pointer;
		color: white;
		background-color: black;
		transition: all 300ms ease-in-out;
		border-bottom: 0.1rem solid black;
	}

	&.left .pullTab {
		right: 0;
		translate: 100%;
		border-right: 0.1rem solid black;
		border-bottom-right-radius: 0.5rem;
	}

	&.right .pullTab {
		left: 0;
		translate: -100%;
		border-left: 0.1rem solid black;
		border-bottom-left-radius: 0.5rem;
	}

	&.open .pullTab {
		color: black;
		background-color: inherit;
	}

	&.left.open .pullTab {
		box-shadow: 4px 6px 6px rgba(0, 0, 0, 0.2);
	}

	&.right.open .pullTab {
		box-shadow: -4px 6px 6px rgba(0, 0, 0, 0.2);
	}

	& .pullTab .hamburger {
		width: 32px;
		height: 32px;
		pointer-events: none;
	}

	& .pullTab .hamburger path {
		transition:
			rotate 500ms ease-in-out 300ms,
			translate 500ms ease-in-out 300ms,
			scale 500ms ease-in-out 300ms;
		transform-box: fill-box;
		transform-origin: center;
	}

	&.open .pullTab .hamburger .top {
		rotate: 45deg;
		translate: 0px 5px;
	}

	&.open .pullTab .hamburger .middle {
		scale: 0;
	}

	&.open .pullTab .hamburger .bottom {
		rotate: -45deg;
		translate: 0px -5px;
	}

	& .pullTab .avatar {
		color: black;
		width: calc(var(--header-height) * 0.85);
		border-radius: 9999px;
		display: grid;
		align-items: center;
		justify-content: center;
	}

	& .pullTab .avatar img,
	& .pullTab .avatar svg {
		width: 100%;
	}

	& summary {
		color: #363636;
		background-color: #beddf4;
		padding: 0.25rem 0.5rem;
		text-align: center;
		font-weight: bold;
	}

	& summary .subTitle {
		font-size: 0.75rem;
		font-weight: normal;
	}

	& ul li {
		list-style-type: none;
	}

	& ul li label {
		cursor: inherit;
	}

	& .navImgBox .opacity label {
		display: block;
		text-align: center;
		font-size: 1rem;
	}

	& .navImgBox .opacity [type="range"] {
		width: 100%;
	}

	& [type="checkbox"] {
		vertical-align: middle;
		margin: 0 auto;
		cursor: inherit;
	}

	& [type="radio"] {
		height: 1rem;
		width: 1rem;
		cursor: inherit;
	}

	& .infoCell {
		position: relative;
		text-align: end;
		border-top: 0.15rem solid;
		padding: 0.7rem 0.25rem 0;
	}

	& .infoCell label {
		position: absolute;
		top: 0;
		left: 0;
		font-size: 0.7rem;
		padding: 0.05rem 0.25rem;
		color: darkgreen;
		white-space: nowrap;
	}

	& .navBtnGroup {
		display: grid;
		/* grid-template-columns: 1fr 1fr; */
		grid-template-columns: repeat(6, 1fr);
		gap: 0.25rem;
		padding: 0.25rem;
	}

	& .navBtnGroup .col-2 {
		grid-column: span 2;
	}

	& .navBtnGroup .col-3 {
		grid-column: span 3;
	}

	& .navBtnGroup .col-4 {
		grid-column: span 4;
	}

	& .navBtnGroup .col-5 {
		grid-column: span 5;
	}

	& .navBtnGroup .col-6 {
		grid-column: span 6;
	}

	& .navBtn {
		display: grid;
		align-items: center;
		border: 0.1rem solid;
		border-radius: 0.25rem;
		padding: 0.1rem 0.25rem;
		background-color: inherit;
		min-width: 10ch;
	}

	& .navBtn:focus {
		outline: 0.1rem solid;
	}

	& .navBtn:hover {
		background-color: #f2f2f2;
	}

	& .navBtn .icon {
		line-height: 0;
		pointer-events: none;
	}

	& .navBtn .icon svg,
	& .navBtn .icon img {
		height: 2rem;
		width: auto;
	}

	& .navBtn .text {
		pointer-events: none;
	}

	&.btnOptText .navBtn .icon {
		display: none;
	}

	&.btnOptText .navBtn .text {
		min-height: 1.5rem;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	&.btnOptIcon .navBtn .text {
		display: none;
	}

	& .navBtn .text .subTitle {
		font-size: 0.5rem;
	}

	& .navBtn .text .title {
		font-size: 0.65rem;
	}

	& .boardConfig {
		display: flex;
		align-items: center;
		flex-direction: column;
		padding: 0 0.25rem 0.5rem;
	}

	& .boardConfig #cellCntSelect {
		font-size: 1.25rem;
		padding: 1.25rem 0 1.25rem 1.25rem;
		cursor: pointer;
	}

	& .cardZoomWrapper {
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 0.25rem;
	}

	& .cardZoomWrapper .title {
		text-align: center;
	}

	& .admin {
		display: none;
	}

	.app.admin & .admin {
		display: revert;
	}
}

/* ====================================== MsgBox ============================================= */
.msgBox #joinGameNum {
	width: 8ch;
	text-align: right;
}

.msgBox .whatsNew ul > li {
	font-weight: bold;
	margin-top: 0.5rem;
}

.msgBox .whatsNew ol {
	list-style: auto;
	margin-left: 2rem;
}

.msgBox .helpInstructions ul li {
	list-style: disc;
	margin-left: 2rem;
}

.msgBox .helpInstructions p {
	margin: revert;
}

.msgBox table {
	border-collapse: collapse;
	margin: 0 auto;
}

.msgBox table .tableTitle {
	color: white;
	background-color: black;
}

.msgBox td,
.msgBox th {
	border: 1px solid;
	text-align: center;
	padding: 0.1rem.25rem;
}

.msgBox .leaderboardTable thead tr:last-child th {
	color: white;
	background-color: black;
	border: none;
}

.msgBox.leaderboard .nickname .nameWrapper {
	display: flex;
	align-items: center;
	justify-content: center;
}

.msgBox.leaderboard .nickname .imgWrapper {
	display: inline-block;
	width: 20px;
	height: 20px;
	margin-left: 3px;
}

.msgBox.leaderboard [selected] .nickname .imgWrapper {
	width: 40px;
	height: 40px;
}

.msgBox.leaderboard .nickname img {
	width: 100%;
	vertical-align: bottom;
}

.msgBox.leaderboard fieldset {
	font-size: 0.75rem;
}

.msgBox.leaderboard fieldset legend {
	font-weight: bold;
	text-align: left;
	margin-left: 0.25rem;
	padding: 0 0.25rem;
}

.msgBox .rematchMsg .enemyNameBubble .avatar {
	display: inline-block;
	line-height: 0;
	vertical-align: middle;
	width: 3rem;
}

.msgBox .rematchMsg .enemyMsg {
	border-radius: 9999px;
	background-color: rgba(173, 216, 230, 0.75);
	padding: 0.25rem 0.75rem;
	margin-left: 1rem;
}

.msgBox .scoreBreakdown details {
	border: 2px solid;
	border-radius: 0.25rem;
	cursor: pointer;
	padding: 0 0.25rem;
	font-size: 0.9rem;
	width: fit-content;
}

.msgBox .scoreBreakdown details .label {
	margin-right: 0.25rem;
	font-weight: bold;
}

/* ====================================== utility ============================================= */
.v-hidden {
	visibility: hidden;
}
