body {
  background-color: #DDD;
  color: #222;
  font-family: sans-serif;
  overflow: hidden;
  user-select: none;
}

#score {
  position: absolute;
  right: 10px;
}

#score p {
  text-align: right;
  font-size: 15pt;
  font-weight: bold;
  margin: 0;
}

@property --score {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

#counter {
  counter-reset: score var(--score);
}

#counter::after {
  content: counter(score);
}

@property --addend {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

#addend {
  counter-reset: addend var(--addend);
  visibility: hidden;
}

#addend.positive::after {
  content: "+" counter(addend);
  color: #292;
}

#addend.negative::after {
  content: counter(addend);
  color: #C22;
}

.header {
  margin: auto;
  flex-direction: column;
  align-items: center;
}

td:has(.header) {
  column-span: all;
}

h1 {
  font-size: 30pt;
}

h2 {
  font-size: 18pt;
  text-align: center;
}

table {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 650px;
}

tr {
  width: 100%;
  display: flex;
  justify-content: center;
}

td {
  perspective: 500px;
  min-width: 0px;
  display: flex;
}

td > div {
  justify-content: center;
}

.card {
  width: 140px;
  height: auto;
  aspect-ratio: 0.7;
  margin: 10px;
  background-color: #822;
  border-radius: 10px;
  display: flex;
  align-items: center;
}

img {
  flex-grow: 1;
  width: 0;
  scale: 1.3;
}

.composite {
  flex-grow: 1;
  width: 0;
}

.composite tr {
  padding: 5px;
}

.comp-ico {
  width: 60px;
  display: flex;
  align-items: center;
}

.card:hover:not(.flipped) {
  animation: hover-lift 0.1s both ease;
}

@keyframes hover-lift {
  50% {
    transform: rotateX(10deg) translateZ(20px);
  }
  100% {
    transform: rotateX(0deg) translateZ(40px);
  }
}

.flipped {
  background-color: #EEE;
  box-shadow: 0 0 5px 2px #822;
}

.matched {
  box-shadow: 0 0 5px 2px gold;
  transition: box-shadow 0.1s;
}

.card:not(.flipped) * {
  display: none;
}

@media (max-width: 780px) {
  #score {
    position: initial;
  }
  .card {
    margin: 5px;
  }
}
