@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap");

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

:root {
  --RESULT-DIALOG-WIDTH: min(85vw, 500px);
  --NAMES-DIALOG-WIDTH: min(85vw, 700px);
  --HEADER-WIDTH: min(90vw, 550px);
  --GAMEBOARD-SIDE: min(90vw, 470px);

  --TITLE-FS: clamp(3rem, 13vw, 4.5rem);
  --TURN-MSG-FS: clamp(1.5rem, 10vw, 2.5rem);
  --PLAYER-SYMBOL-FS: clamp(2rem, 15vw, 5rem);
  --FOOTER-FS: clamp(1rem, 5vw, 1.2rem);
  --RESULT-DIALOG-FS: clamp(1.2rem, 8vw, 2.3rem);

  --LIGHT-COLOR: #d9d6f5; /* soft lavender */
  --EXTRA-LIGHT-COLOR: #edeafd; /* lighter lavender */
}

html {
  position: relative;
  min-height: 100vh;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: #b9ccf3; /* pastel blue */
  margin-bottom: 100px;
  user-select: none;
}

/* HEADER */

header {
  padding-top: 30px;
  margin-bottom: 40px;
}

header h1 {
  margin: 0 auto;
  padding: 20px 0;
  width: var(--HEADER-WIDTH);
  text-align: center;
  font-size: var(--TITLE-FS);
  background-color: var(--LIGHT-COLOR);
  color: #222;
  border-radius: 20px;
}

header h1:hover {
  background-color: var(--EXTRA-LIGHT-COLOR);
}

/* MAIN */

main p {
  margin-bottom: 20px;
  text-align: center;
  font-size: var(--TURN-MSG-FS);
  color: #1d1b2c;
}

main .gameboard {
  width: var(--GAMEBOARD-SIDE);
  height: var(--GAMEBOARD-SIDE);
  margin: 0 auto;
  margin-bottom: 30px;
  padding: 20px;
  border-radius: 20px;
  background-color: var(--LIGHT-COLOR);

  display: grid;
  gap: 3px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.gameboard .gamecell {
  border: 2px solid #111;
  font-size: var(--PLAYER-SYMBOL-FS);
  cursor: pointer;
  color: #3a354d;

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

.gameboard .gamecell:hover {
  background-color: var(--EXTRA-LIGHT-COLOR);
}

main button {
  display: block;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 auto;
  padding: 20px 70px;
  border: none;
  border-radius: 10px;
  background-color: var(--LIGHT-COLOR);
  cursor: pointer;
  color: #2e2b3e;
}

main button:hover {
  background-color: var(--EXTRA-LIGHT-COLOR);
}

/* DIALOG */

dialog {
  position: fixed;
  border: none;
  border-radius: 20px;
  user-select: none;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

/* --- RESULT DIALOG */

.result-dialog {
  top: 300px;
  left: calc(50% - (var(--RESULT-DIALOG-WIDTH) / 2));
}

.result-dialog h1 {
  padding: 70px 10px;
  width: var(--RESULT-DIALOG-WIDTH);
  text-align: center;
  font-size: var(--RESULT-DIALOG-FS);
  font-weight: 700;
  color: #262138;
}

/* --- NAMES DIALOG */

.names-dialog {
  top: 200px;
  left: calc(50% - (var(--NAMES-DIALOG-WIDTH) / 2));
}

.names-dialog form {
  padding: 50px 0 70px 0;
  width: var(--NAMES-DIALOG-WIDTH);

  display: grid;
  row-gap: 50px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
}

.names-dialog p.title {
  grid-column: 1 / -1;
  font-size: 2.5rem;
  font-weight: 700;
  color: #2c2541;
}

.names-dialog p.player-name {
  display: flex;
  flex-direction: column;
  gap: 10px;

  font-size: 1.3rem;
  font-weight: 500;
  color: #333;
}

.names-dialog input {
  width: 230px;
  padding: 5px;
  border: 2px solid #333;
  border-radius: 5px;
  font-size: 1rem;
  background-color: #f5f4fb;
  color: #111;
}

.names-dialog button {
  grid-column: 1 / -1;

  margin-top: 25px;
  padding: 25px 70px;
  background-color: #8ee4af; /* soft green */
  border: 0.5px solid black;
  border-radius: 10px;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 500;
  cursor: pointer;
  color: #1e2e2e;
}

.names-dialog button:hover {
  background-color: #b3f0c0;
}

@media screen and (max-width: 600px) {
  .names-dialog {
    top: 100px;
  }
  .names-dialog form {
    row-gap: 40px;
    grid-template-columns: 1fr;
  }
  .names-dialog p.title {
    font-size: clamp(1.5rem, 8vw, 2.2rem);
  }
  .names-dialog button {
    padding-inline: 60px;
    font-size: 1.2rem;
  }
}

/* FOOTER */

footer {
  position: absolute;
  bottom: 15px;
  width: 100%;
  text-align: center;
  color: #111;
  font-size: var(--FOOTER-FS);
  user-select: text;
}
