/* Joh Comeau CSS Reset*/

/* Use a more-intuitive box-sizing model */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Remove default margin */
*:not(dialog) {
  margin: 0;
}

/* Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  /* Increase line-height */
  line-height: 1.5;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
}

/* Improve media defaults */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

/* Inherit fonts for form controls */
input, button, textarea, select {
  font: inherit;
}

/* Avoid text overflows */
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* Improve line wrapping */
p {
  text-wrap: pretty;
}
h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}


/* Fonts */

@font-face {
	font-family: "Roboto";
	src: url("../fonts/Roboto-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Roboto";
	src: url("../fonts/Roboto-Bold.ttf") format("truetype");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}


/* Container */

body {
	background-color: #54494B;
	font-family: "Roboto";
	display: flex;
	justify-content: center;
}

.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 60vw;
	gap: 2rem;
}


/* Title */

.title {
	font-size: 3rem;
	font-weight: bold;
	text-align: center;
	color: #E3D081;
	padding-top: 2rem;
}


/* Reset Game button */

#resetGame {
	display: flex;
	justify-content: center;
	background-color: #91C7B1;
	border: 5px solid #91C7B1;
	color: #B33951;
	font-size: 1.5rem;
	font-weight: bold;
	border-radius: 15px;
	width: 17rem;
	height: 3rem;
}


/* Gameboard */

.gameboard {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	gap: 1rem;
	width: 17rem;
	height: 17rem;
}

.cell {
	background-color: #F1F7ED;
	border: 1px solid #F1F7ED;
	border-radius: 15px;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 3rem;
	font-weight: bold;
}

#cell1 {
	grid-column: 1 / 2;
	grid-row: 1 / 2;
}


/* Next Player and Round Result */

.nextPlayerAndResult {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	width: 17rem;
	gap: 1rem;
}

.nextPlayerAndResult div {
	display: flex;
	flex-direction: column;
	text-align: center;
	background-color: #E3D081;
	border: 5px solid #E3D081;
	border-radius: 15px;
	line-height: 1;
}

.nextPlayerAndResultTitle {
	font-weight: bold;
}


/* Score */

.scoreBoard {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.scoreTitleContainer {
	display: flex;
	flex-direction: column;
	justify-content: center;
	background-color: #B33951;
	border: 5px solid #B33951;
	color: white;
	border-radius: 15px;
	width: 17rem;
	height: 3rem;
	text-align: center;
}

.scoreTitle {
	font-weight: bold;
	font-size: 1.2rem;
}

.player {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	background-color: #B33951;
	border: 5px solid #B33951;
	color: white;
	border-radius: 15px;
	width: 8rem;
	height: 8rem;
}

.playersPoints {
	display: flex;
	gap: 1rem;
}

#player1Name,
#player2Name {
	font-weight: bold;
}

#player1Score,
#player2Score {
	font-size: 2rem;
}

.changeName {
	background-color: #82142a;
	border: 1px solid #82142a;
	border-radius: 15px;
	font-size: 1rem;
	padding: 0 1rem;
	color: white;
}


/* Dialog to change name */

.changeNameForm {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

#closeButton {
	background-color: #590e1d;
	border: 1px solid #590e1d;
	border-radius: 5px;
	height: 1.5rem;
	width: 1.5rem;
	text-align: center;
}

#changeNameDialog {
	padding: 1.5rem;
	background-color: #82142a;
	border: 1px solid #82142a;
	border-radius: 15px;
}

#changeNameDialog[open] {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.closeButtonContainer {
	display: flex;
	justify-content: right;
}

#changeNameForm fieldset {
	display: flex;
	flex-direction: column;
	border: none;
	color: white;
}

#changeNameForm input {
	border: 1px solid white;
	border-radius: 10px;
	padding-left: 1rem;
}

#changeNameForm button {
	background-color: #590e1d;
	border: 1px solid #590e1d;
	border-radius: 10px;
	color: white;
}

/* Blur background while dialog is open */

dialog::backdrop {
        backdrop-filter: blur(1px);
}


/* Hover highlight */

@media (hover: hover) {
	.cell:hover {
		background-color: #c9c3c5;
		border: 1px solid #c9c3c5;
		cursor: pointer;
	}

	#resetGame:hover {
		background-color: #aee6cf;
		border: 5px solid #aee6cf;
		color: #dd4765;
		cursor: pointer;
	}

	.changeName:hover {
		cursor: pointer;
		background-color: #E3D081;
		border: 1px solid #E3D081;
		color: black;
	}

	#closeButton:hover,
	#submitButton:hover {
		cursor: pointer;
		background-color: #E3D081;
		border: 1px solid #E3D081;
		color: black;
	}
}