/* Elements */

html {
  min-height: 100%; /* We have to fix html height */
  display: flex;
  flex-direction: column;
}

body {
  background-color: #12221d;
  font-family: "Rubik", sans-serif;
  overflow: hidden;
  display: grid;
  justify-content: center;
  align-items: center;
  /* min-height: 100vh;
  min-height: -webkit-fill-available; */
  flex-grow: 1;
}

h1 {
  display: inline-block;
  font-size: 3rem;
  margin: 8rem 0 4rem 0;
  color: #ffffff;
  background-color: #8516b5;
  width: 10rem;
  height: 10rem;
  line-height: 10rem;
  border-radius: 0.5rem;
}

h2,
h3,
p {
  margin: 0;
}

label {
  display: block;
  font-weight: 500;
  margin: 0;
  color: #593a5f;
  font-size: 1.25rem;
}

/* Utility */

.shaking {
  -webkit-animation: left-to-right 0.05s 3 alternate;
  animation: left-to-right 0.05s 3 alternate;
}

@keyframes left-to-right {
  0% {
    transform: translateX(-2.5px);
  }

  100% {
    transform: translateX(2.5px);
  }
}

.color-flash {
  -webkit-animation: color-flash 0.75s 1 forwards ease;
  animation: color-flash 0.75s 1 forwards ease;
}

@keyframes color-flash {
  0% {
    color: #d41818;
  }
  16% {
    color: #e79d12;
  }
  32% {
    color: #dddd1a;
  }
  48% {
    color: #0e7a0e;
  }
  64% {
    color: #76ca76;
  }
  80% {
    color: #1a1ac7;
  }
  90% {
    color: #800980;
  }
  100% {
    color: #000000;
  }
}

.add-transition {
  transition: background-color 0.3s ease;
}

.spawn {
  -webkit-animation: spawn 0.3s 1 ease-in-out;
  animation: spawn 0.3s 1 ease-in-out;
}

@keyframes spawn {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

.merge {
  -webkit-animation: merge 0.3s 1 ease-in-out;
  animation: merge 0.3s 1 ease-in-out;
}

@keyframes merge {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Composition */

#game-wrapper {
  position: relative;
  background-color: #f6ebd6;
  width: 26.5rem;
  margin: 5rem auto;
  border-radius: 2rem;
  overflow: hidden;
}

/* Components */

/* Start Screen */

#section-start-screen {
  text-align: center;
  width: 100%;
  height: 44.25rem;
}

input::placeholder {
  transition: color 0.25s;
}

input[type="text"] {
  width: 70%;
  height: 3rem;
  font-size: 1rem;
  border: 0;
  margin: 1.25rem 0;
  padding: 0 1rem;
  background-color: #c7b299;
  border-radius: 0.25rem;
  transition: box-shadow 0.25s;
}

input[type="text"]::placeholder {
  color: #ffffff9d;
}

input[type="text"]:hover {
  box-shadow: inset 0 0 0 0.2rem #c69c6d;
}

input:hover::placeholder {
  color: #ffffff;
}

input[type="text"]:focus {
  outline: 0.2rem solid #c69c6d;
  box-shadow: none;
}

input[type="submit"] {
  display: block;
  width: 25%;
  height: 3rem;
  margin: 2rem auto;
  font-size: 1rem;
  font-weight: 600;
  background-color: #c69c6d;
  color: #ffffffc4;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: 0.25s;
}

input[type="submit"]:hover {
  box-shadow: 0 0.75px 0 0.75px #c98c48;
  transform: translateY(-0.75px);
  color: #ffffff;
}

button {
  color: #ffffffc4;
  transition: 0.25s;
}

button:hover {
  box-shadow: 0 0.75px 0 0.75px #c98c48;
  transform: translateY(-0.75px);
  color: #ffffff;
}

/* In Game Screen */

#section-score-board {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-auto-rows: 3rem;
  row-gap: 0.5rem;
  column-gap: 1.5rem;
  align-content: center;
  align-items: center;
  justify-items: stretch;
  width: 87.5%;
  height: 14rem;
  margin: 0 auto;
}

#section-score-board h2 {
  font-weight: 600;
  font-size: 1.5rem;
}

#section-score-board > h2 {
  font-size: 2.5rem;
  font-weight: 700;
}

#section-score-board p {
  font-weight: 400;
}

#section-score-board h3 {
  font-weight: 600;
  font-size: 1.25rem;
  grid-area: 2/1/3/4;
  align-self: flex-end;
}

#section-score-board article {
  text-align: center;
  background-color: #c7b299;
  border-radius: 0.25rem;
  padding: 0.25rem;
}

#section-score-board button {
  background-color: #c69c6d;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.15rem;
  font-size: 1rem;
  cursor: pointer;
}

.newGameBtn {
  grid-area: 3/1/4/2;
  align-self: flex-end;
}

.quitBtn {
  grid-area: 3/2/4/3;
  align-self: flex-end;
}

.instructionBtn {
  grid-area: 3/3/4/4;
  align-self: flex-end;
}

#section-grid {
  height: 30rem;
  width: 100%;
  display: grid;
  align-items: center;
  border-top: 0.25rem solid #000000;
}

.grid-background {
  background-color: #6b655a;
  margin: 0 1.15rem;
  padding: 0.6rem 0;
  border-radius: 0.5rem;
}

.grid {
  width: 23rem;
  height: 23rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 0 auto;
}

.grid-number-wrapper {
  background-color: #8f8577;
  display: grid;
  justify-content: center;
  align-items: center;
  border-radius: 0.2rem;
}

.grid-number {
  width: 84.8px;
  height: 84.8px;
  text-align: center;
  line-height: 84.8px;
  border-radius: 0.2rem;
}

.grid-number p {
  font-weight: 500;
}

/* Instruction Overlay Screen */

#section-instruction-screen {
  position: absolute;
  inset: 0;
  display: grid;
  justify-content: center;
  align-items: center;
  background-color: #ffffff88;
  backdrop-filter: blur(1px);
}

.section-instruction-content {
  background-color: #f6ebd6;
  width: 80%;
  height: 50%;
  margin: 0 auto;
  border-radius: 1.25rem;
  padding: 1.5rem;
}

.section-instruction-content article {
  margin: 3rem auto 0 auto;
}

.section-instruction-content p {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.5;
}

.section-instruction-content button {
  display: block;
  margin: 4.5rem auto 0 auto;
  width: 7rem;
  height: 3rem;
  font-size: 1.25rem;
  font-weight: 500;
  border: 0;
  border-radius: 0.5rem;
  background-color: #c98c48;
  cursor: pointer;
}

/* End Game Screen */

#section-end-screen {
  text-align: center;
  width: 100%;
  height: 44.25rem;
  overflow: hidden;
}

#section-end-screen h2 {
  font-size: 3rem;
  margin: 8rem 0 4rem 0;
}

#section-end-screen .end-scores {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
  width: 20rem;
  margin: 0rem auto 4rem auto;
  border-radius: 1rem;
  background-color: #c69c6d;
}

#section-end-screen p {
  padding: 1rem 0;
}

#section-end-screen button {
  display: block;
  margin: 1.5rem auto;
  width: 10rem;
  height: 4rem;
  font-size: 1.25rem;
  font-weight: 500;
  border: 0;
  border-radius: 0.75rem;
  background-color: #c98c48;
  cursor: pointer;
}
