/* FONT & COLOR VARIABLES */
@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
	--board-color: #1e3a8a;
	--tile-border: #0a1f44;
	--tile-empty: #ffffff;
	--bg-color: #f1f5f9;
	--red:  #e75454;;
	--yellow: #fde047;;
}

/* GLOBAL STYLES */
* {
	box-sizing: border-box;
	padding: 0;
	margin: 0;
}

body {
	min-height: 100vh;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background-color: var(--bg-color);
	font-family: "Press Start 2P", monospace;
	color: #111;
	text-align: center;
	padding: 1rem 0.5rem;
	overflow-x: hidden;
}

button, .tile {
	-webkit-tap-highlight-color: transparent;
}

/* HEADER & LABEL */
.label {
	margin: 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: clamp(0.6rem, 4vw, 1.5rem);
	margin-bottom: 1rem;
	white-space: nowrap;
}

.circles {
	font-size: clamp(1.5rem, 5vw, 2.2rem);
	animation: dance 1.2s ease-in-out infinite;
}

h1 {
	font-size: clamp(1rem, 5vw, 2rem);
	color: var(--board-color);
	animation: bounceInText 1s ease-in-out;
}

/* Reset BUTTON */
button {
	font-size: clamp(1rem, 3vw, 1.5rem);
	background-color: var(--red);
	color: white;
	border: none;
	padding: 5px 10px;
	border-radius: 50%;
	font-weight: bold;
	cursor: pointer;
	text-align: center;
	transition: background-color 0.3s ease, transform 0.2s ease;
}

button:active {
	background-color: var(--board-color);
	transform: rotate(-180deg);
}

/* GAME BOARD */
#board {
	padding: 1rem;
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	grid-template-rows: repeat(6, 1fr);
	gap: 6px;
	width: min(100%, 500px);
	aspect-ratio: 7/6;
	background: linear-gradient(to bottom, var(--board-color), #0f172a);
	border: 5px solid var(--tile-border);
	border-radius: 16px;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
	position: relative;
	margin: 0 auto;
}

/* WINNER MESSAGE AND FEEDBACK */
#winner-msg {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: rgba(0, 0, 0, 0.9);
	border: 4px solid var(--board-color);
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.9);
	padding: 0.9rem;
	border-radius: 8px;
	font-size: clamp(1rem, 1rem + 0.5vw, 2rem);
	text-transform: uppercase;
	letter-spacing: 0.2rem;
	animation: bounceInModal 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
	display: none;
	white-space: nowrap;
	z-index: 10;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.tile.winning {
	box-shadow: 0 0 10px rgb(255, 255, 255);
}

/* TILES */
.tile {
	aspect-ratio: 1/1;
	border-radius: 50%;
	border: 4px solid var(--tile-border);
	background-color: var(--tile-empty);
	box-shadow: inset 5px 5px 15px rgba(0, 0, 0, 0.3),
							inset -5px -5px 15px rgba(255, 255, 255, 0.1);

	transition: background-color 0.3s ease, transform 0.2s ease;
	cursor: pointer;
}

.tile:hover {
	transform: scale(1.05);
}

/* WINNER COLORS */
.yellow-wins {
	color: var(--yellow);
}

.red-wins {
	color: var(--red);
}
.draw {
	color: rgb(51, 87, 184);
}

/* ANIMATIONS */
@keyframes bounceInText {
	0% {
		transform: scale(0);
		opacity: 0;
	}
	60% {
		transform: scale(1.1);
		opacity: 1;
	}
	80% {
		transform: scale(0.95);
	}
	100% {
		transform: scale(1);
	}
}
@keyframes bounceInModal {
	0% {
		transform: translate(-50%, -50%) scale(0);
		opacity: 0;
	}
	60% {
		transform: translate(-50%, -50%) scale(1.1);
		opacity: 1;
	}
	80% {
		transform: translate(-50%, -50%) scale(0.95);
	}
	100% {
		transform: translate(-50%, -50%) scale(1);
	}
}

@keyframes dance {
	0% {
		transform: rotate(0deg) translateY(0);
	}
	20% {
		transform: rotate(-8deg) translateY(-5px);
	}
	40% {
		transform: rotate(8deg) translateY(5px);
	}
	60% {
		transform: rotate(-8deg) translateY(-5px);
	}
	80% {
		transform: rotate(8deg) translateY(5px);
	}
	100% {
		transform: rotate(0deg) translateY(0);
	}
}

/* MEDIA QUERIES */

@media (hover: hover) and (pointer: fine) {
	button:hover {
		background-color: var(--board-color);
		transform: rotate(-360deg);
	}
}

@media (max-width: 400px) {
	button {
		padding: 3px 6px;
	}
	#board {
		padding: 0.5rem;
		border-width: 3px;
		height: min-content;
		width: min(95vw, 500px);
	}
	#winner-msg {
		font-size: 0.8rem;
	}
}

@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
	.label {
		margin: 0.3rem;
	}
	h1,
	button {
		font-size: max(0.7rem, 4vh);
	}

	button {
		padding: 3px 6px;
	}
	.circles {
		font-size: max(1.1rem, 4vh);
	}
	body {
		padding: 0.3rem;
		overflow: hidden;
		justify-content: flex-start;
	}
	#board {
		max-height: 70vh;
		max-width: 95vw;
		width: min(95vw, 70vh * (7/6));
		margin: 0 auto;
		padding: 0.5rem;
	}

}
