@import url('https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

*, *::after, *::before {
  box-sizing: border-box;
}

/* The Modal (background) */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  font-size: clamp(.8rem, 2.5vmin, 1rem);
}

/* Modal Content/Box */
.modal-content {
  background-color: #fafafa;
  color: black;
  margin: 10% auto;
  padding: 20px;
  width: 80%; /* Could be more or less, depending on screen size */
  border-radius: 1em;
}

.modal-content p {
  color: #737373;
}

/* The Close Button */
.closeModal {
  color: #d94547;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.closeModal:hover,
.closeModal:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

.helpButton {
  position: absolute;
  left: 1em;
  top: 1em;
  z-index: 2;
  font-size: inherit;
  border: none;
  padding: 0;
  width: fit-content;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
  color: white;
  fill: white;
  text-transform: uppercase;
  border-radius: .25em;
  cursor: pointer;
  user-select: none;
  font-size: 2.0em;
}

.helpButton.right {
  left: auto;
  right: 1em;
}

/* Main Game */
body {
  background:none transparent;
  font-family: Barlow;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  margin: 0;
  font-size: clamp(.5rem, 2.5vmin, 1.5rem);
  touch-action: manipulation;
}

html {
  height: -webkit-fill-available;
}

hr {
  border: 0.5px solid #d1d1d1;
}

.keyboard {
  padding: 1em;
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  grid-template-rows: repeat(3, 56px);
  gap: min(.5em, 6px);
  justify-content: center;
  margin: 0 auto;
  width: min(500px, 100vw);
}

@supports (-webkit-touch-callout: none) {
  .keyboard {
    padding: 1em;
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(3, 56px);
    gap: 2px;
    justify-content: center;
    margin: 0 auto;
    width: min(500px, 100vw);
  }
}

.key {
  font-family: Barlow;
  font-weight: bold;
  font-size: clamp(.75rem, 2.5vmin, 1.5rem);
  grid-column: span 2;
  border: none;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #d6d6d6;
  color: black;
  fill: black;
  text-transform: uppercase;
  border-radius: .25em;
  cursor: pointer;
  user-select: none;
}

.key.large {
  grid-column: span 3;
}

.key.large.positive {
  background-color: hsl(115, 29%, 43%);
}

.key > svg {
  width: 1.75em;
  height: 1.75em;
  pointer-events: none;
}

.key:hover, .key:focus {
  border: .05em solid hsl(240, 2%, 23%);
}

.key.wrong {
  background-color: #878787;
}

.key.wrong-location {
  background-color: hsl(49, 51%, 47%);
}

.key.correct {
  background-color: hsl(115, 29%, 43%);
}

.example-grid {
  display: grid;
  flex-grow: 1;
  grid-template-columns: repeat(5, 4em);
  grid-template-rows: repeat(1, 4em);
  gap: .25em;
  margin-bottom: 1em;
}

.guess-grid {
  max-width: 320px;
  display: grid;
  justify-content: center;
  align-content: center;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: min(.5em, 6px);
  width: min(320px, 100vw);
  margin: auto;
}

.tile {
  aspect-ratio: 1;
  font-size: 3em;
  color: black;
  border: .05em solid hsl(240, 2%, 23%);
  text-transform: uppercase;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: transform 250ms linear;
}

@media only screen and (min-width: 295px) {
  .tile {
    font-size: 2rem;
  }
}

.tile.example {
  font-size: 2em;
}

.tile[data-state="active"] {
  border-color: hsl(200, 1%, 34%);
}

.tile[data-state="wrong"] {
  border: none;
  background-color: #d6d6d6;
}

.tile[data-state="wrong-location"] {
  border: none;
  background-color: hsl(49, 51%, 47%);
}

.tile[data-state="correct"] {
  border: none;
  background-color: hsl(115, 29%, 43%);
}

.tile.shake {
  animation: shake 250ms ease-in-out;
}

.tile.dance {
  animation: dance 500ms ease-in-out;
}

.tile.flip {
  transform: rotateX(90deg);
}

@keyframes shake {
  10% {
    transform: translateX(-5%);
  }

  30% {
    transform: translateX(5%);
  }

  50% {
    transform: translateX(-7.5%);
  }

  70% {
    transform: translateX(7.5%);
  }

  90% {
    transform: translateX(-5%);
  }

  100% {
    transform: translateX(0);
  }
}

@keyframes dance {
  20% {
    transform: translateY(-50%);
  }  

  40% {
    transform: translateY(5%);
  }  

  60% {
    transform: translateY(-25%);
  }  

  80% {
    transform: translateY(2.5%);
  }  

  90% {
    transform: translateY(-5%);
  }  

  100% {
    transform: translateY(0);
  }
}

.alert-container {
  position: fixed;
  top: 10vh;
  left: 50vw;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.alert {
  pointer-events: none;
  background-color: hsl(204, 7%, 85%);
  padding: .75em;
  border-radius: .25em;
  opacity: 1;
  transition: opacity 500ms ease-in-out;
  margin-bottom: .5em;
}

.alert:last-child {
  margin-bottom: 0;
}

.alert.hide {
  opacity: 0;
}

.copyButton {
  font-weight: bold;
  font-size: 17px;
  border: none;
  padding: 0.5em 1em;
  justify-content: center;
  align-items: center;
  background-color: hsl(115, 29%, 43%);
  color: white;
  fill: white;
  border-radius: .25em;
  cursor: pointer;
  user-select: none;
}

ol {
  color: #737373;
  padding-inline-start: 20px;
  margin: 0 auto;
}

.share-content {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: min(100%, 340px);
}

.stats-grid {
  display: grid;
  flex-grow: 1;
  grid-template-columns: repeat(4, fit-content(100px));
  grid-template-rows: 50px, 20px;
  column-gap: 1em;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
  text-align: center;
}

.big-stat {
  font-size: 3em;
}

.stats-grid > p {
  margin: 0;
}