@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=VT323&display=swap");

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;

  background: #1d1d1d;
  background-image: url(../images/background/background.png);
  background-position: center;
  background-size: cover;
  user-select: none;
}

.container {
  width: 100%;
  max-width: 510px;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(8px, 2vw, 12px);

  padding: clamp(25px, 4vw, 25px) /* top/bottom */ clamp(8px, 3vw, 25px); /* left/right */
  margin: 0 auto;

  border-radius: 10px;
  background: linear-gradient(145deg, #303233, #2f2f31);

  box-sizing: border-box;
}

.visor {
  width: 100%;
  height: 13em;
  overflow: hidden;
  line-height: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  font-family: "VT323", monospace;

  text-align: center;
  text-transform: uppercase;
  color: hsl(150, 100%, 50%);

  padding: 0.3em 0.5em;
  border-radius: 10px;
  border: clamp(8px, 1.5vw, 15px) solid transparent;

  background:
    linear-gradient(hsl(150, 25%, 5%)) padding-box,
    linear-gradient(145deg, #1a1c1d, #1b1c1e) border-box;

  box-shadow:
    0 0 0 1px #000,
    inset 0 0 2px 3px #000;

  text-shadow:
    0 0 5px hsla(150, 100%, 50%, 0.8),
    0 0 10px hsla(150, 100%, 50%, 0.6),
    0 0 20px hsla(150, 100%, 50%, 0.4);
}

.visor.warning {
  color: hsl(45, 100%, 50%);
  animation: pulse 1s infinite;

  background:
    linear-gradient(hsl(45, 25%, 5%)) padding-box,
    linear-gradient(145deg, #1a1c1d, #1b1c1e) border-box;

  text-shadow:
    0 0 6px hsla(45, 100%, 50%, 0.7),
    0 0 12px hsla(45, 100%, 50%, 0.5),
    0 0 20px hsla(45, 100%, 50%, 0.3);
}

@keyframes pulse {
  0% {
    text-shadow:
      0 0 6px hsla(45, 100%, 50%, 0.6),
      0 0 12px hsla(45, 100%, 50%, 0.4),
      0 0 20px hsla(45, 100%, 50%, 0.2);
  }

  50% {
    text-shadow:
      0 0 10px hsla(45, 100%, 50%, 1),
      0 0 20px hsla(45, 100%, 50%, 0.8),
      0 0 40px hsla(45, 100%, 50%, 0.6);
  }

  100% {
    text-shadow:
      0 0 6px hsla(45, 100%, 50%, 0.6),
      0 0 12px hsla(45, 100%, 50%, 0.4),
      0 0 20px hsla(45, 100%, 50%, 0.2);
  }
}

#titulo {
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(3rem, 2.5vw, 3.7rem);
}

#timer {
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(6rem, 6vw, 6.5rem);
  display: flex;
  justify-content: center;
}

.visor.game-over {
  animation: none;
  color: hsl(345, 100%, 50%);
  background:
    linear-gradient(hsl(345, 25%, 5%)) padding-box,
    linear-gradient(145deg, #1a1c1d, #1b1c1e) border-box;
  text-shadow:
    0 0 6px hsla(345, 100%, 50%, 0.7),
    0 0 12px hsla(345, 100%, 50%, 0.5),
    0 0 20px hsla(345, 100%, 50%, 0.3);
}

.visor.game-over #titulo {
  overflow: hidden;
  white-space: nowrap;
  margin: 0 auto;
  font-size: clamp(4rem, 4vw, 4rem);
  animation: typing 2.5s steps(40, end) forwards;
}

.visor.game-over #timer {
  flex-direction: column;
  align-items: center;
  font-size: clamp(1.7rem, 3vw, 2rem);
}

.visor.game-over #timer .line1 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 1.4em;
  animation: typing 3s steps(30, end) forwards;
  animation-delay: 4s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.visor.game-over #timer .line2 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 1.2em;
  animation: typing 2.5s steps(40, end) forwards;
  animation-delay: 7s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.visor.game-over #timer .line3 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 0.6em;
  opacity: 0;
  animation: typing 3s steps(50, end) forwards;
  animation-delay: 11s;
  animation-fill-mode: forwards;
}

.visor.victory {
  animation: none;
  color: hsl(150, 100%, 50%);
  background:
    linear-gradient(hsl(150, 23%, 5%)) padding-box,
    linear-gradient(145deg, #1a1c1d, #1b1c1e) border-box;
  text-shadow:
    0 0 6px hsla(150, 100%, 50%, 0.7),
    0 0 12px hsla(150, 100%, 50%, 0.5),
    0 0 20px hsla(150, 100%, 50%, 0.3);
}

.visor.victory #titulo {
  overflow: hidden;
  white-space: nowrap;
  margin: 0 auto;
  font-size: clamp(4rem, 4vw, 4rem);
  animation: typing 2.5s steps(40, end) forwards;
}

.visor.victory #timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(2rem, 3vw, 2rem);
}

.visor.victory .line1 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 1.5em;
  animation: typing 2.5s steps(30, end) forwards;
  animation-delay: 3s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.visor.victory .line2 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  line-break: auto;
  font-size: 1em;
  animation: typing 2.5s steps(40, end) forwards;
  animation-delay: 6s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.visor.victory .line3 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 1em;
  opacity: 0;
  animation: typing 2.5s steps(50, end) forwards;
  animation-delay: 8s;
  animation-fill-mode: forwards;
}

.visor.victory .line4 {
  overflow: hidden;
  white-space: nowrap;
  font-family: inherit;
  font-size: 0.6em;
  opacity: 0;
  animation: typing 3s steps(50, end) forwards;
  animation-delay: 13s;
  animation-fill-mode: forwards;
}

@keyframes typing {
  0% {
    width: 0;
    opacity: 1;
  }
  1% {
    opacity: 1;
  }
  100% {
    width: 100%;
    opacity: 1;
  }
}

.led {
  align-self: center;
  width: clamp(12px, 2.4vw, 16px);
  height: clamp(12px, 2.4vw, 16px);
  border: 1px solid;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #424242, #111111 75%);
}

.led.wrong {
  background: radial-gradient(
    circle at 30% 30%,
    hsl(0, 100%, 85%),
    rgb(255, 0, 0) 75%
  );
  box-shadow:
    0 0 6px hsla(0, 100%, 50%, 0.8),
    0 0 12px hsla(0, 100%, 50%, 0.6),
    0 0 20px hsla(0, 100%, 50%, 0.4);
}

.led.right {
  background: radial-gradient(
    circle at 30% 30%,
    hsl(120, 100%, 85%),
    hsl(120, 100%, 50%) 75%
  );
  box-shadow:
    0 0 5px hsla(120, 100%, 50%, 0.8),
    0 0 10px hsla(120, 100%, 50%, 0.6),
    0 0 20px hsla(120, 100%, 50%, 0.4);
}

.game {
  width: 100%;
  max-width: 100%;
  background: linear-gradient(145deg, #202325, #202122);
  border: 1px solid;
  border-radius: 10px;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: clamp(10px, 2vw, 16px);
  gap: 12px;
  perspective: 500px;
}

.board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 2vw, 10px);
}

.item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  font-size: clamp(3em, 6vw, 4em);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  transform: rotateY(180deg);
  transition: 0.2s;
  border-radius: 2px;
  border: 1px solid;
}

.item.boxOpen {
  transform: rotateY(0deg);
  box-shadow: 0px 0px 2px 3px #ffffff;
}

.item.boxMatch {
  transition: 0.15s;
  box-shadow: 0px 0px 2px 3px hsl(150, 100%, 50%);
}

.item.boxOpen.game-over {
  transition: 0.15s;
  box-shadow: 0px 0px 2px 3px hsl(345, 100%, 50%);
}

.item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(195deg, #d1c8ba, #c2b8a9);
  border: 1px solid hsla(255, 255, 255, 0.06);
  transition: 0.25s;
  transform: rotateY(0deg);
  backface-visibility: visible;
  border-radius: 2px;
  box-shadow: 0px 0px 2px 3px #111111;
}

.boxOpen::after,
.boxMatch::after {
  transform: rotateY(180deg);
  backface-visibility: hidden;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.reset {
  height: clamp(2em, 6vw, 2em);
  grid-column: 2 / 4;
  color: #ffffff;
  background: linear-gradient(145deg, #cc0f12, #c41717);

  border: 1px solid #000;
  border-radius: 2px;
  box-shadow: 0px 0px 2px 2px #111111;

  font-family: "Roboto Mono", monospace;
  font-size: clamp(1.2em, 2.5vw, 1.2em);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.01s ease-in-out;
}

.reset:active {
  transform: scale(0.99);

  box-shadow: 0px 0px 2px 1.2px #111111;
}

@media (max-width: 480px) {
  .visor {
    height: 4.5em;
    font-size: clamp(3.2rem, 8vw, 5.5rem);
    border-width: clamp(6px, 1vw, 10px);
  }
}
