/* VARIABLES */
:root {
  --color1: #E8E8E8;
  --color2: #222831;
  --color3: #30475E;
  --color3-darker: #213243;
  --color4: #F05454;
  --color4-darker: #C13838;
  --color4-hightlight: #F0545466;
  --player-height: 400px;
  --player-width: 300px;
  --cell-size: 140px;
  --marker-size: calc(var(--cell-size)* 0.9);
}

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

body {
  display: grid;
  height: 100vh;
  grid-template-rows: auto 1fr auto;
  font-family: 'Permanent Marker', cursive;
}

header {
  width: 100vw;
  text-align: center;
  color: var(--color1);
  background-color: var(--color2);
}

main {
  background-color: var(--color1);
}

footer {
  background-color: var(--color2);
  width: 100%;
  padding: 1rem;
  text-align: center;
}

footer a {
  color: var(--color1);
  display: flex;
  align-items: center;
  width: fit-content;
  margin: 0 auto;
  gap: .5rem;
  text-decoration: none;
  transition: 0.5s;
}

footer a:hover {
  scale: 1.1;
}

header h1 {
  font-size: 3.5rem;
}

button {
  font-family: 'Permanent Marker', cursive;
}


/* CLASS SELECTOR */

.title-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 2.5vh 0;
}

.player-selection {
  background-color: var(--color1);
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.player-selection h1 {
  font-size: 2.25rem;
}


.players {
  display: flex;
  gap: 5rem;
  width: 80vw;
  justify-content: space-around;
}


.player1,
.player2 {
  display: flex;
  justify-content: center;
  flex-direction: column;
  border-radius: 20px;
  height: var(--player-height);
  width: var(--player-width);
  background-color: var(--color1);
  border: .5rem solid var(--color2);
  border-radius: 20px;
  box-shadow: 0px 0px 20px 1px var(--color2);
}


.player-top {
  width: 100%;
  color: var(--color1);
  background-color: var(--color2);
  text-align: center;
  padding-bottom: .5rem;
}

.player-avatar {
  height: 100%;
  position: relative;
}

.player-avatar ul {
  margin: 0;
  padding: 0;
  list-style-type: none;

}

.avatar-select-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  z-index: 2;
  cursor: pointer;
  border: none;
  color: var(--color1);
  background-color: var(--color4-hightlight);
  border-radius: 10px;
  padding: 0 .5rem;
  transition: all 0.5s ease;
}

.avatar-select-btn.prev {
  left: .5rem;

}

.avatar-select-btn.next {
  right: .5rem;
}

.avatar-select-btn:hover,
.avatar-select-btn:focus {
  font-size: 2.25rem;
  background-color: var(--color4);
}

.avatar-select-btn:focus {
  outline: 2.5px solid var(--color2);
  transition: 0s;
}


.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: 200ms opacity ease-in-out;
  transition-delay: 200ms;
}

.slide>img {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 7.5px solid var(--color2);
  background-color: var(--color3);
  box-shadow: 0px 0px 10px 1px var(--color2);
  transform: translateX(-50%) translateY(-50%);
}

.slide[data-active] {
  opacity: 1;
  transition-delay: 0ms;
}

.player-name {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  background-color: var(--color2);
  gap: 1rem;
}

.player-name input {
  font-size: 1.25rem;
  padding: 0.3rem 0.7rem;
  width: 150px;
  border-radius: 20px;
  background-color: var(--color1);
  border: none;
}

.player-name input:focus {
  outline: 2.5px solid var(--color4);
}


.game-page {
  display: none;
  align-items: center;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  padding: 2.5vh 0;
}

.game-container {
  background-color: var(--color1);
  width: 75vw;
  height: fit-content;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  position: relative;
}

.rounds {

  font-size: 1.25rem;
  ;
}

.gameboard {
  border: 10px solid var(--color2);
  border-radius: 20px;
  display: grid;
  width: fit-content;
  height: fit-content;
  grid-template-columns: repeat(3, auto);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background-color: var(--color3);
  border: 1px solid var(--color1);
  font-size: var(--marker-size);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--color1);
  transition: 0.3s ease;
  cursor: pointer;
}

.cell:hover {
  background-color: var(--color3-darker);
}

.cell:first-child,
.cell:nth-child(2),
.cell:nth-child(3) {
  border-top: none;
}

.cell:nth-child(3n+1) {
  border-left: none;
}

.cell:nth-child(3n+3) {
  border-right: none;
}

.cell:last-child,
.cell:nth-child(8),
.cell:nth-child(7) {
  border-bottom: none;
}

.cell:first-child {
  border-radius: 7.5px 0 0 0;
}

.cell:nth-child(3) {
  border-radius: 0 7.5px 0 0;
}

.cell:last-child {
  border-radius: 0 0 7.5px 0;
}

.cell:nth-child(7) {
  border-radius: 0 0 0 7.5px;
}


.cell.appear {
  animation: markerAppear .5s 1;
  overflow: visible;
}

.player1-left,
.player2-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3rem;
}

.avatar p {
  text-align: center;
  color: var(--color3);
}

.player1-avatar,
.player2-avatar {
  border-radius: 50%;
  border: 7.5px solid var(--color2);
  background-color: var(--color3);
  transition: 0.25s;
}

.player1-avatar.active,
.player2-avatar.active {
  border: 7.5px solid var(--color4);
}

.winner-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
  width: 300px;
  height: 250px;
  text-align: center;
  border-radius: 20px;
  color: var(--color1);
  background-color: var(--color2);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
}

.draw-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
  width: 300px;
  height: 250px;
  text-align: center;
  border-radius: 20px;
  color: var(--color1);
  background-color: var(--color2);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4rem;
  padding: 2rem;
}

.draw-modal.active,
.winner-modal.active {
  animation: zoomIn 1s 1;
}

.draw-modal,
.winner-modal {
  animation: zoomOut 1s 1;
}

.winner-avatar {
  width: 100px;
}


/* ID SELECTORS */
#start-btn {
  padding: .1rem 1.5rem .2rem 1.5rem;
  font-size: 2rem;
  border: none;
  background-color: var(--color4);
  color: var(--color1);
  border-radius: 50px;
  cursor: pointer;
  transition: .5s;
  position: absolute;
  bottom: 10%;
  left: 50%;
  -webkit-transform: translate(-50%, -10%);
  transform: translateX(-50%, -10%)
}

.start {
  position: relative;
}

#winner-btn,
#draw-btn {
  border: none;
  background-color: var(--color4);
  color: var(--color1);
  font-size: 1.25rem;
  padding: .5rem;
  border-radius: 20px;
  transition: .5s;
  cursor: pointer;
}

#start-btn:hover,
#winner-btn:hover,
#draw-btn:hover {
  background-color: var(--color4-darker);
}

#start-btn:active,
#winner-btn:active,
#draw-btn:active {
  scale: 0.95;
  transition: .05s;
}

#player1-name,
#player2-name {
  width: fit-content;
  padding: .5rem 1rem;
  text-align: center;
  color: var(--color1);
  background-color: var(--color2);
  border-radius: 50px;
  transition: 0.25s;

}

#player1-name.active,
#player2-name.active {
  background-color: var(--color4);
  animation: scaleIncrease 2s infinite;
}

#player1-score,
#player2-score {
  color: var(--color4);
}

#home-btn,
#reset-btn {
  border: none;
  color: var(--color1);
  font-size: 1.25rem;
  width: fit-content;
  padding: .5rem .75rem;
  border-radius: 9999px;
  background-color: var(--color2);
  cursor: pointer;
  transition: 0.4s;
  position: absolute;
  bottom: -50px;
  left: 0;
  right: 0;
  margin: auto
}

#home-btn {
  left: 150px;
}

#reset-btn {
  right: 150px;

}


#home-btn:hover,
#reset-btn:hover {
  scale: 1.1;
}

#home-btn:active,
#reset-btn:active {
  outline: 1px solid var(--color1);
  scale: 1;
  transition: 0.025s;
}

/* ANIMATIONS */
@keyframes scaleIncrease {
  0% {
    scale: 1
  }

  50% {
    scale: 1.1
  }
}

@keyframes zoomIn {
  0% {
    scale: 0.1
  }

  50% {
    scale: 1
  }
}

@keyframes zoomOut {
  0% {
    scale: 1
  }

  20% {
    scale: 1.1
  }

  100% {
    scale: 0
  }

}

@keyframes markerAppear {
  0% {
    color: rgba(255, 255, 255, 0);
    font-size: 300px;
  }

  50% {
    opacity: rgba(255, 255, 255, 1);
    font-size: var(--marker-size);
  }
}


/* MEDIA QUERIES */
@media only screen and (max-width: 1600px) {
  :root {
    --cell-size: 120px;
  }
}

@media only screen and (max-width: 1100px) {
  :root {
    --cell-size: 120px;
  }
}


@media only screen and (max-width: 1111px) {
  :root {
    --cell-size: 100px;

  }

  body {
    font-size: .8rem;
  }

  .players {
    padding-top: 0;
  }

  .slide img,
  .player-name input {
    width: 70%;
    transition: .5s;
  }

  .avatar-select-btn.next,
  .avatar-select-btn.prev {
    top: auto;
    bottom: -2rem;
  }

  .game-container {
    grid-template-columns: repeat(2, 150px);
    gap: 1rem;
    transition: .5s;
    align-items: center;
    justify-content: center;
  }

  .gameboard {
    grid-column: 1 / 3;
    grid-row: 2 / 2;
    margin: 0 auto;
  }

  .player1-avatar,
  .player2-avatar {
    width: 100px;
  }

  .player1.avatar {
    margin-right: auto;
  }

  .player2.avatar {
    margin-right: auto;
  }

  .player1-left,
  .player2-right {
    gap: 1rem;
    margin: 0 auto;
  }

  #start-btn {
    bottom: 90%;
    left: 50%;
    -webkit-transform: translate(-50%, 90%);
    transform: translateX(-50%, 90%)
  }



  #reset-btn {
    font-size: .9rem;
    bottom: 0;
    left: -220px;
  }

  #home-btn {
    font-size: .9rem;
    bottom: 0;
    right: -220px;
  }

}


@media only screen and (max-width: 670px) {
  .title-page {
    margin-top: 5vh;
    align-items: baseline;
  }


  .player1,
  .player2 {
    border: none;
    box-shadow: none;
    height: 300px;
    gap: 2rem;

  }

  .player-top {
    background-color: transparent;
    color: var(--color2);
    font-size: 1rem;

  }

  .player-name {
    background-color: transparent;
  }

  .player-name input {
    background-color: var(--color2);
    color: var(--color1)
  }

  .players {
    gap: 2rem;
  }

  .avatar-select-btn {
    top: 5%;
    transform: translateY(5%);
    scale: 0.8;
  }

}