* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: monospace; 
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #0a3c2f;
}

.container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 30px;
  background: #962C16;
  padding: 40px 60px;
}

h2 {
  font-size: 3em;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.reset {
  padding: 15px 20px;
  color: #C05038;
  background: #fff;
  border: none;
  font-size: 1.5em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 600;
}

.reset:focus {
  color: #fff;
  background: #C05038;
}

.game {
  display: flex; 
  flex-wrap: wrap; 
  justify-content: center; /* New: Center cards horizontally */
  align-items: center; /* New: Center cards vertically */
  gap: 10px; 
  max-width: calc(100px * 4 + 30px); /* New: Sets the max width of the game dynamically */
  margin: auto; /* New: Centers the .game container itself */
}

.item {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3em;
  background: #fff;
  transform: rotateX(180deg);
  transition: 0.25s;
}

.item.boxOpen {
  transform: rotateY(0deg);
}

.item:after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  transition: 0.15s;
  transform: rotateY(0deg);
  backface-visibility: hidden;
}

.boxOpen:after,
.boxMatch:after {
  transform: rotateY(180deg);
}

