:root {
  --bg-color: #121212;
  --text-color: #f5f5f5;
  --accent-color: #7c4dff;
  --card-bg: #1e1e1e;
  --cell-border: #333;
  --key-bg: #1e1e1e;
  --key-text: var(--text-color);
  --key-border: #333;
  --key-hover: #2a2a2a;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.back-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
}

.back-link a {
  color: var(--accent-color);
  font-size: 1rem;
  font-weight: bold;
  text-decoration: none;
  transition: color 0.3s ease, text-decoration 0.3s ease;
}

.back-link a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.header-box {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  margin-top: 2rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.header-box h1 {
  margin: 0;
  color: var(--accent-color);
}

main {
  width: 100%;
  max-width: 500px;
  padding: 1rem;
}

.grid-container {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.grid-cell {
  border: 2px solid var(--cell-border);
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  text-transform: uppercase;
}

/* Fehler-Animation: Rotes Wackeln */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

.grid-cell.error {
  border-color: #FF0000 !important;
  background-color: rgba(255, 0, 0, 0.2);
  animation: shake 0.5s;
}

/* Gewinn-Farbgebung: Grüne Hinterlegung für die richtige Zeile */
.grid-cell.win {
  background-color: rgba(0, 255, 0, 0.2);
  border-color: green !important;
}

/* On-Screen Tastatur */
.keyboard-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.key.disabled {
  background-color: #666;
  color: #aaa;
  /* cursor: not-allowed; */
  opacity: 0.5;
}

.key {
  background-color: var(--key-bg);
  color: var(--key-text);
  border: 1px solid var(--key-border);
  border-radius: 4px;
  padding: 1.2rem 1rem;
  font-size: 1.2rem;
  text-transform: uppercase;
  flex: 1;
  cursor: pointer;
  transition: background-color 0.3s;
}

.key.special {
  flex: 1.5;
}

.key:hover {
  background-color: var(--key-hover);
}

/* Explosion Animation: Bunte, größere und länger sichtbare Partikel */
.explosion-container {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 300;
}

.explosion-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 1;
  animation: explode 5s ease-out forwards;
}

/* Ergebnis-Box, die bei Spielende (in letzter Zeile, falsche Eingabe) erscheint */
.result-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--card-bg);
  color: var(--accent-color);
  padding: 1rem 2rem;
  border: 2px solid var(--accent-color);
  border-radius: 8px;
  font-size: 1.2rem;
  z-index: 400;
  text-align: center;
}

@keyframes explode {
  0% { 
    transform: translate(0, 0) scale(1); 
    opacity: 1;
  }
  80% {
    transform: translate(var(--dx), var(--dy)) scale(1.5);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.5);
    opacity: 0;
  }
}

/* Flip Animation für einzelne Zellen */
@keyframes flip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

.grid-cell.flip-animation {
  animation: flip 0.6s ease;
}

/* Farbgebung nach der Flip-Animation */
.grid-cell.correct {
  background-color: rgba(0, 255, 0, 0.2); /* gleiche Farbe wie .grid-cell.win */
  border-color: green !important;
}

.grid-cell.present {
  background-color: rgba(255, 165, 0, 0.6); /* gelb/orange */
  border-color: orange;
}

.grid-cell.absent {
  background-color: rgba(128, 128, 128, 0.6); /* grau */
  border-color: grey;
}