/* ===== Reset & Grundlayout ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #6d28d9 100%);
  color: #fff;
  padding: 20px;
  overflow-x: hidden;
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 6px;
  background: linear-gradient(90deg, #a78bfa, #f472b6, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.6;
  margin-bottom: 16px;
  transition: all 0.3s;
}

/* ===== Status-Leiste ===== */
.hud {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 0.85rem;
  min-width: 90px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2px;
  color: #c4b5fd;
}

/* ===== Spielfeld ===== */
#board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-width: 560px;
  width: 100%;
  position: relative;
}

/* ===== Vorschau-Banner ===== */
.preview-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  color: #fff;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.5);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 50;
  letter-spacing: 0.5px;
}

.preview-banner.show {
  transform: translateX(-50%) translateY(0);
}

/* Fortschrittsbalken für Vorschau */
.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 0 0 22px 22px;
  width: 0%;
  transition: width 0.1s linear;
}

/* ===== Karten ===== */
.card {
  aspect-ratio: 3 / 4;
  perspective: 800px;
  cursor: pointer;
  user-select: none;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-style: preserve-3d;
  border-radius: 12px;
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
}

/* Rückseite (verdeckt) */
.card-front {
  background: linear-gradient(145deg, #4c1d95, #7c3aed);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.6rem;
  font-weight: 900;
}

.card:hover:not(.matched) .card-inner {
  transform: translateY(-4px) rotateY(0deg);
  box-shadow: 0 10px 25px rgba(167, 139, 250, 0.4);
}

.card.flipped:hover .card-inner,
.card.matched:hover .card-inner {
  transform: rotateY(180deg);
}

/* Vorderseite (aufgedeckt) */
.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, #ffffff, #e0e7ff);
  color: #1e1b4b;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.card.matched .card-back {
  background: linear-gradient(145deg, #34d399, #10b981);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.7);
  animation: pop 0.4s ease;
}

@keyframes pop {
  0%   { transform: rotateY(180deg) scale(1); }
  50%  { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ===== Sperre während Vorschau/Auswertung ===== */
#board.locked .card {
  pointer-events: none;
}

#board.locked .card:hover .card-inner {
  transform: rotateY(180deg);
  box-shadow: none;
}

/* ===== Steuerung unten ===== */
.controls {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

button,
select {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.5);
  font-family: inherit;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(236, 72, 153, 0.6);
}

button:active {
  transform: translateY(0);
}

select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
  padding: 12px 18px;
  appearance: none;
  cursor: pointer;
}

select option {
  background: #312e81;
  color: #fff;
}

/* ===== Gewinn-Overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 40, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 100;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  background: linear-gradient(145deg, #312e81, #6d28d9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 40px 50px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.show .overlay-card {
  transform: scale(1);
}

.overlay h2 {
  font-size: 2rem;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #fbbf24, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.overlay p {
  opacity: 0.85;
  margin-bottom: 8px;
  font-size: 1rem;
}

.overlay .big {
  font-size: 1.4rem;
  font-weight: 700;
  color: #c4b5fd;
  margin: 12px 0 20px;
}

/* ===== Konfetti ===== */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -20px;
  z-index: 99;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ===== Mobile ===== */
@media (max-width: 520px) {
  #board {
    gap: 6px;
    padding: 10px;
  }
  .card-front {
    font-size: 1.1rem;
  }
  .overlay-card {
    padding: 30px 25px;
  }
}