/* Grundlayout für das Kinder-Insekten-Spiel */
.kif-game-container {
  width: 100%;
  max-width: 1080px;        /* optimiert für 9:16 Touchscreen */
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  background: #222;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 10px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  /* Lockerere Schriftart */
  font-family: "Comic Sans MS", "Comic Sans", "Trebuchet MS", Arial, sans-serif;
}

/* Falls der Container höher als der Bildschirm ist */
@media (max-height: 800px) {
  .kif-game-container {
    aspect-ratio: auto;
    height: 100vh;
  }
}

.kif-top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  font-size: 32px;
  margin-bottom: 10px;
}

#kif-timer-display,
#kif-score-display {
  font-weight: bold;
}

.kif-control-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.kif-control-bar button {
  padding: 8px 16px;
  font-size: 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

#kif-start-btn {
  background: #c62828;
  color: #fff;
}

#kif-reset-btn {
  background: #2e7d32;
  color: #fff;
}

#kif-start-btn:disabled,
#kif-reset-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Spieler-Buttons */
.kif-player-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kif-player-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.kif-player-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.kif-player-btn {
  background: #1976d2;
  color: #fff;
  padding: 6px 10px;
  font-size: 18px;
  border-radius: 6px;
  min-width: 90px;
  border: none;
  cursor: pointer;
}

.kif-player-btn.kif-active-player {
  background: #e53935;
}

.kif-player-score {
  font-size: 16px;
  margin-top: 4px;
  min-height: 20px;
}

/* Spielfeld */
#kif-playfield {
  flex: 1;
  margin: 5px 0;
  border-radius: 16px;
  border: 3px solid #444;
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

/* Insekten */
.kif-insect {
  position: absolute;
  width: 80px;
  height: 80px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  touch-action: none;
}

/* Einstellungen */
#kif-settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 5px;
  font-size: 18px;
}

#kif-settings label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

#kif-settings select {
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #555;
  min-width: 80px;
}

/* Allgemeine Popups (Insektenauswahl dunkel lassen) */
.kif-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.kif-overlay.kif-hidden {
  display: none;
}

.kif-popup-box {
  position: relative;
  background: #333;
  color: #fff;
  padding: 30px 40px;
  border-radius: 24px;
  text-align: center;
  min-width: 420px;
  max-width: 90%;
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
}

.kif-popup-box h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 30px;
}

.kif-popup-box p {
  margin: 12px 0;
  font-size: 22px;
}

/* Spezielles Styling NUR für das Gewinner-Popup: gelbe Box mit dunkler Schrift */
#kif-winner-popup .kif-popup-box {
  background: #ffeb3b;      /* kräftiges Gelb */
  color: #222;              /* dunkle Schrift */
  border-radius: 30px;
  padding: 40px 60px;
  min-width: 520px;
  box-shadow: 0 0 40px rgba(0,0,0,0.85);
}

#kif-winner-popup #kif-winner-text {
  color: #222;
  font-size: 36px;
  font-weight: bold;
}

#kif-winner-popup #kif-winner-score-text {
  color: #333;
  font-size: 28px;
}

#kif-winner-popup #kif-winner-ok-btn {
  margin-top: 18px;
  padding: 10px 22px;
  font-size: 20px;
  border-radius: 12px;
  border: none;
  background: #1976d2;
  color: #fff;
  cursor: pointer;
}

/* Insekten-Auswahl im Popup */
#kif-insect-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.kif-insect-choice {
  width: 80px;
  height: 80px;
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
}

.kif-insect-choice:hover {
  border-color: #fff;
}

/* Gewinner-Hintergrundanimation */
.kif-winner-anim {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.kif-winner-anim .kif-fly-insect {
  position: absolute;
  width: 70px;
  height: 70px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.9;
  bottom: -80px; /* Start knapp unterhalb des sichtbaren Bereichs */
  animation-name: kif-fly-up;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* Fallback-Emoji, wenn kein Bild vorhanden ist */
.kif-winner-anim .kif-fly-insect span {
  display: inline-block;
  font-size: 42px;
}

/* Keyframes: von unten nach oben schweben */
@keyframes kif-fly-up {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-140vh);
  }
}
