:root {
	--background-color-a: #0F0F10;
	--background-color-b: #18181b;
	--border-color: #2C2C2E;
	--text-color: #CED1D4;

	--red: #c76a43;
	--yellow: #A5902D;
	--green: #447D3D;
	--blue: #49a0a3;
	--purple: #675378;

	--radius: 3px;
	--header-height: 50px;
	--keyboard-height: 200px;
	--keyboard-spacing: 3px;
	--max-width: 500px;

	--transition: 200ms ease-in-out;
	--font-family: "DM Sans", sans-serif;
}

html {
	height: 100%;
	font-size: 16px;
}

body {
	color: var(--text-color);
	background-color: var(--background-color-a);
	font-family: var(--font-family);
	margin: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* #region TEXT */

h1, h2 {
	color: var(--text-color);
	font-size: 1.25rem;
	font-family: var(--font-family);
	font-weight: bold;
}

p, a {
	color: var(--text-color);
	font-size: 1rem;
	font-family: var(--font-family);
	font-weight: normal;
}

a {
	cursor: pointer;
}

/* #endregion */

/* #region HEADER */

header {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
	height: var(--header-height);
	border-bottom: var(--radius) solid var(--border-color);
}

header >h1 {
	margin: 0;
	text-transform: uppercase;
	letter-spacing: 3px;
}

header >span {
	position: fixed;
	top: 0;
	height: inherit;
}

header span.menu {
	display: flex;
	align-items: center;
}

header span.menu.left-menu {
	left: 18px;
}

header span.menu.right-menu {
	right: 18px;
	flex-direction: row-reverse;
}

header span.menu i {
	color: var(--text-color);
	font-size: 1.25rem;
	cursor: pointer;
}

/* #endregion */

/* #region MAIN */

main {
	display: flex;
    flex-direction: column;
    align-items: center;
	width: 100%;
	max-width: var(--max-width);
	height: calc(100% - calc(var(--header-height) + var(--radius)));
	margin: 0 auto;
}

main * {
	touch-action: manipulation;
}

/* #endregion */

/* #region GRID */

.grid {
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	gap: 12px;
	justify-content: center;
    align-items: center;
	width: calc(100% - 40px);
	height: calc(100% - var(--keyboard-height));
    padding: 10px;
}

.grid .row, .help .row {
	display: flex;
	flex-direction: row;
	gap: 12px;
	width: calc(100% - 40px);
    justify-content: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.grid .row.shake {
	animation: shake 600ms normal 0ms 1 forwards ease-in-out;
}

.cell {
	width: 100%;
	height: auto;

	display: flex;
    justify-content: center;
    align-items: center;

	color: var(--text-color);
	border: var(--radius) solid var(--border-color);
	border-radius: var(--radius);
	background-color: transparent;
	transition: background-color 900ms ease-in-out;

	font-size: 1rem;
	font-weight: bold;
    text-transform: uppercase;

	aspect-ratio: 1 / 1;
	box-sizing: border-box;
	user-select: none;
}

.cell:not(:empty) {
	animation: pop 200ms normal;
}

.cell.active {
	border-style: dashed;
}

.cell.green, .cell.yellow, .cell.gray {
	border-color: transparent;
	animation: flip 300ms alternate 0ms 2 forwards ease-in-out;
}

.cell.green {
	background-color: var(--green);
}

.cell.yellow {
	background-color: var(--yellow);
}

.cell.gray {
	background-color: var(--border-color);
}

@keyframes pop {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.1);
	}
	100% {
		transform: scale(1);
	}
}

@keyframes flip {
	0% {
		transform: rotateX(0deg);
	}
	100% {
		transform: rotateX(90deg);
	}
}

@keyframes shake {
	0% {
		transform: translateX(0);
	}
	20% {
		transform: translateX(-12px);
	}
	40% {
		transform: translateX(12px);
	}
	60% {
		transform: translateX(-12px);
	}
	80% {
		transform: translateX(12px);
	}
	100% {
		transform: translateX(0);
	}
}

/* #endregion */

/* #region KEYBOARD */

.keyboard {
	height: calc(var(--keyboard-height) + 6px);
	width: 100%;
	max-width: var(--max-width);
	padding: 6px;
	box-sizing: border-box;
	transform: translateY(0);
	transition: transform 300ms ease-in;
}

.keyboard.hidden {
	transform: translateY(100%);
}

.keyboard .row {
	display: flex;
	gap: var(--keyboard-spacing);
	width: 100%;
	margin-bottom: var(--keyboard-spacing);
}

.keyboard button {
	flex: 1;
    justify-content: center;
    align-items: center;
	height: 60px;
	padding: 0 3px;
	font-size: 1rem;
	font-weight: bold;
	color: var(--text-color);
	background-color: var(--border-color);
	border: none;
	border-radius: var(--radius);
	transition: background-color var(--transition);
	box-sizing: border-box;
    text-transform: uppercase;
	cursor: pointer;
}

.keyboard button.green {
	background-color: var(--green);
}

.keyboard button.yellow {
	background-color: var(--yellow);
}

.keyboard button.gray {
	background-color: var(--background-color-b);
}

.keyboard button[data-key="backspace"] {
	padding: 0 6px;
}

/* #endregion */

/* #region OVERLAY */

.overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 99;
	pointer-events: none;
}

.overlay >* {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
}

.popup {
	opacity: 0;
	margin: auto;
	margin-top: calc(var(--header-height) + 18px);
	padding: 6px 12px;
	background-color: var(--background-color-b);
	border-radius: var(--radius);
	transition: opacity var(--transition);
}

.popup.active {
	opacity: 1;
}

/* #endregion */

/* #region CONFETTI */

.canvas {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

/* #endregion */

/* #region HELP */

.help-container {
	opacity: 0;
	transform: translateY(60px);
	backdrop-filter: blur(3px);
	pointer-events: none;
	transition: 300ms ease-in-out;
}

.help-container.active {
	opacity: 1;
	transform: translateY(0);
	pointer-events: all;
}

.help {
	position: fixed;
	width: 100%;
	height: 100%;
	color: var(--text-color);
	background-color: var(--background-color-b);
	border-radius: var(--radius);
	padding: 12px;
	overflow-y: auto;
	-ms-overflow-style: none;
 	 scrollbar-width: none;
	box-sizing: border-box;
	z-index: 999;
}

.help h1 {
	margin-top: 0;
}

.help i {
	position: absolute;
	top: 12px;
	right: 12px;
	font-size: 1.75rem;
	cursor: pointer;
}

.help .row {
	width: 100%;
}

.help::-webkit-scrollbar {
	display: none;
}

/* #endregion */

/* #region UTIL */

.no-transition {
	transition: none !important;
}

/* #endregion */

/* #region RESPONSIVE */

/* Medium screens */
@media screen and (min-width: 440px) {
	.cell {
		font-size: 2rem;
	}
}

/* Narrow screens */
@media screen and (max-width: 280px) {
	.cell {
		font-size: 0.75rem;
	}
}

@media screen and (max-width: 260px) {
	.keyboard button {
		padding: 0;
	}

	header span.menu i {
		font-size: 1rem;
	}
}

/* Non-mobile screens */
@media screen and (min-width: 360px) {
	header span.menu i {
		font-size: 1.5rem;
	}

	header >h1 {
		font-size: 1.75rem;
	}
}

/* Large mobile */
@media screen and (min-width: 425px) {
	:root {
		--keyboard-spacing: 6px;
	}
}

/* Wide screens */
@media screen and (min-width: 550px) {
	.help {
		width: var(--max-width);
		height: min-content;
		margin-top: 12px;
	}
}

/* #endregion */