* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  user-select: none;
  font-size: 0;
}

body.customCursor,
body.customCursor * {
  cursor: none;
}

html, body {
  height: 100%;
  overflow: hidden;
}

/* Pointer */

#pointer {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
}

#pointer > img {
  transition: opacity 0.4s;
  transition-delay: 0.1s;
}

#pointer > img.hidden {
  opacity: 0;
}

/* Board */

#board {
  border: 1.5vmin solid hsl(0, 0%, 25%);
  background-color: hsl(0, 0%, 90%);
  box-shadow: 0 0 2vmin hsla(0, 0%, 0%, 0.5) inset;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#row1, #row2, #row3 {
  display: flex;
  flex-direction: row;
}

@keyframes fadingIn {
  from {
    transform: scale(1.1);
    opacity: 0;
    pointer-events: none;
  }
  to {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}

.card {
  width: 20vmin;
  height: 20vmin;
  margin: 4.5vmin;
  border: 0;
  background-color: transparent;
  position: relative;
  perspective: 75vmin;
  opacity: 1;
  transition: transform 5s;
  animation-duration: 0.8s;
  animation-name: fadingIn;
  animation-timing-function: ease-out;
}

.card[data-transition=fadingOut] {
  transition: transform 0.8s, opacity 0.8s;
  transition-timing-function: ease-in;
  transform: scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.card:focus {
  outline: 0;
}

.card > .front,
.card > .back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  transition: transform 0.8s, outline-color 0.5s, box-shadow 0.5s;
  padding: 1vmin;
  outline: 1.5vmin solid transparent;
  box-shadow: 0 0 2vmin hsla(0, 0%, 0%, 0.5) inset, 0 0 2vmin transparent;
  background-color: gray;
}

.card > .back {
  transform: rotateY(360deg);
}

.card > .front,
.card[data-state=selected] > .back,
.card[data-state=found] > .back {
  transform: rotateY(180deg);
}

.card[data-state=selected] > .front,
.card[data-state=found] > .front {
  transform: rotateY(0deg);
}

.card:hover > .front,
.card:hover > .back {
  outline-color: white;
  box-shadow: 0 0 2vmin hsla(0, 0%, 0%, 0.5) inset, 0 0 2vmin black;
}

.card[data-state=found] {
  transform: translateY(100vh) rotate(calc(1.5 * 360deg)) scale(0.8);
  z-index: 1;
}

.card > .front > img,
.card > .back > img {
  width: 100%;
  height: 100%;
}

@media (max-width: 125vh) {
  .card {
    width: 17.5vmin;
    height: 17.5vmin;
    margin: 4vmin;
  }
}

@media (max-width: 105vh) {
  .card {
    width: 15vmin;
    height: 15vmin;
    margin: 3.5vmin;
  }
}

@media (max-width: 100vh) {
  #board {
    flex-direction: row;
  }

  #row1, #row2, #row3 {
    flex-direction: column;
  }
}
