body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f0f0f0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  background: #0078d7;
  color: white;
  width: 100%;
  text-align: center;
  padding: 1rem;
}

#player-input {
  margin: 1rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#player-input input {
  padding: 5px;
}

#player-input button {
  padding: 5px 10px;
  cursor: pointer;
}

.players-info {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 800px;
  margin-bottom: 1rem;
}

.player {
  background: #e0e0e0;
  padding: 10px;
  border-radius: 10px;
  width: 150px;
  text-align: center;
  transition: all 0.3s ease;
}

.player.active {
  border: 4px solid #0078d7;
  background: #cce5ff;
  transform: scale(1.05);
}

.pair-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 5px 0;
  max-height: 100px;
  overflow-y: auto;
}

.pair-stack img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 5px;
  border: 1px solid #aaa;
}

#game-board {
  display: grid;
  gap: 10px;
  padding: 1rem;
  justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  max-width: 800px;
}

.card {
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 1000px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  cursor: pointer;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
}

.card-back {
  background: #0078d7;
}

.card-front {
  transform: rotateY(180deg);
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-front img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Overlay */
#overlay {
  position: fixed;
  top:0; left:0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#overlay-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 90%;
}

#overlay-cards {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

#overlay-cards img {
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
  border-radius: 10px;
  border: 2px solid #333;
  transform: scale(0);
  opacity: 0;
  animation: popIn 0.3s forwards;
}

#overlay-result {
  font-size: 2rem;
  margin-bottom: 10px;
}

#overlay-close {
  padding: 0.5rem 1rem;
  background: #5bc0de;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#overlay-close:hover {
  background: #31b0d5;
}

/* Pop-in Animation */
@keyframes popIn {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Fade-out für Karten vom Spielfeld */
.card.fade-out {
  animation: fadeOut 0.5s forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

#restart-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 3rem;
  margin-bottom: 2rem;
}

#restart {
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 5px;
  background: #d9534f;
  color: white;
  font-weight: bold;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

#restart:hover {
  background: #c9302c;
  transform: scale(1.05);
}
