:root {
	--word-length: 6;
	--flip-time: 0.8s;
	--tile-size: 60px;
	--tile-font-size: 36px;
	--keyboard-width: 480px;
}

@media screen and (max-width: 400px), screen and (max-height: 700px) {
	:root {
		--tile-size: 50px;
		--tile-font-size: 30px;
	}
}

@media screen and (max-width: 300px), screen and (max-height: 600px) {
	:root {
		--tile-size: 40px;
		--tile-font-size: 24px;
	}
}

@media screen and (max-width: 200px), screen and (max-height: 500px) {
	:root {
		--tile-size: 30px;
		--tile-font-size: 18px;
	}
}

@keyframes shake {
	20%, 60% {
		transform: translate3d(-3px, 0, 0);
	}
	40%, 80% {
		transform: translate3d(3px, 0, 0);
	}
}

.tile {
	--tile-background-color: var(--background-color);
	--tile-border-color: var(--border-color);
	--tile-text-color: var(--text-color);
}

.tile[state=correct] {
	--tile-background-color: var(--green);
	--tile-border-color: var(--green);
	--tile-text-color: var(--white);
}

.tile[state=valid] {
	--tile-background-color: var(--yellow);
	--tile-border-color: var(--yellow);
	--tile-text-color: var(--white);
}

.tile[state=invalid] {
	--tile-background-color: var(--grey);
	--tile-border-color: var(--grey);
	--tile-text-color: var(--white);
}

.tile[state=wrong] {
	--tile-background-color: var(--red);
	--tile-border-color: var(--red);
	--tile-text-color: var(--white);
}

.letter[state=correct] {
	background-color: var(--green) !important;
	color: var(--white) !important;
}

.letter[state=valid] {
	background-color: var(--yellow) !important;
	color: var(--white) !important;
}

.letter[state=invalid] {
	background-color: var(--grey) !important;
	color: var(--white) !important;
}

.letter[state=wrong] {
	background-color: var(--red) !important;
	color: var(--white) !important;
}

#game {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	user-select: none;
}

#game .fill {
	flex: 1 1 auto;
}

#game #board {
	flex: none;
	display: flex;
	flex-direction: column;
	align-content: center;
	justify-content: center;
	font-size: var(--tile-font-size);
	font-weight: 700;
	width: 100%;
	padding: 12px;
	min-height: 0;
	gap: 6px;
	overflow-y: auto;
}

#game #board .row {
	flex: none;
	display: flex;
	flex-direction: row;
	justify-content: center;
	gap: 6px;
}

#game #board .row.shake {
	animation: shake 0.5s;
}

#game #board .tile {
	flex: none;
	width: var(--tile-size);
	height: var(--tile-size);
	box-sizing: border-box;
	text-align: center;
	text-transform: uppercase;
	transform-style: preserve-3d;
	transition: transform var(--flip-time);
}

#game #board .tile .front, #board .tile .back {
	display: flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	border-radius: 2px;
	backface-visibility: hidden;
	position: absolute;
	height: 100%;
	width: 100%;
	overflow: auto;
}

#game #board .tile .front {
	color: var(--text-color);
	border: var(--border-color) solid 1px;
	background-color: var(--background-color);
}

#game #board .tile .back {
	transform: rotateY(180deg);
	background-color: var(--tile-background-color);
	color: var(--tile-text-color);
}

#game #board .tile[flipped=true] {
	transform: rotateY(-180deg);
}

#game #day {
	color: var(--subtle-text-color);
	font-size: 18px;
	font-weight: 700;
	text-align: center;
	text-transform: uppercase;
	text-decoration: none;
}

#game #keyboard {
	flex: none;
	width: 100%;
	max-width: var(--keyboard-width);
	padding: 12px;
}

#game #keyboard .row {
	display: grid;
	justify-content: center;
	grid-template-rows: 1fr;
	height: 50px;
	font-size: 14px;
	font-weight: 700;
}

#game #keyboard .top {
	grid-template-columns: repeat(10, 2fr);
}

#game #keyboard .middle {
	grid-template-columns: 1fr repeat(9, 2fr) 1fr;
}

#game #keyboard .bottom {
	grid-template-columns: 3fr repeat(7, 2fr) 3fr;
}

#game #keyboard .letter {
	text-transform: uppercase;
}

#game #keyboard button {
	margin: 3px;
	border-radius: 4px;
	border-width: 0;
	font: inherit;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
	color: var(--keyboard-text-color);
	background-color: var(--keyboard-background-color);
}

#game #keyboard button[state=invalid] {
	color: var(--keyboard-background-color) !important;
	background-color: inherit !important;
	border: 1px solid var(--keyboard-background-color);
}

@media (hover: hover) {
	#game #keyboard button:hover {
		background-color: var(--keyboard-text-color) !important;
		color: var(--keyboard-background-color) !important;
		border: none;
	}
}