/* ----------------------------------------------------
   Grundlegendes Layout: flexbox, 100 % Viewport-Höhe
---------------------------------------------------- */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100vw;
  overflow-x: hidden;      /* nur horizontal abschneiden */
  overflow-y: auto;        /* vertikal scrollen erlauben */
  font-family: Arial, Helvetica, sans-serif;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.5s ease-in-out;
  background-image: url('images/level1.jpg');
}

/* Hintergrundbilder pro Level */
body.level-1 { background-image: url('images/level1.jpg'); }
body.level-2 { background-image: url('images/level2.jpg'); }
body.level-3 { background-image: url('images/level3.jpg'); }
body.level-4 { background-image: url('images/level4.jpg'); }
body.level-5 { background-image: url('images/level5.jpg'); }
body.level-6 { background-image: url('images/level6.jpg'); }
body.level-7 { background-image: url('images/level7.jpg'); }
body.level-8 { background-image: url('images/level8.jpg'); }
body.level-9 { background-image: url('images/level9.jpg'); }
body.level-10 { background-image: url('images/level10.jpg'); }

/* Container mit flex-column */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  padding: 10px;
  box-sizing: border-box;
  gap: 10px;
}

/* ----------------------------------------------------
   Steuerung oben (Buttons, Info, Aufgabe)
---------------------------------------------------- */
.top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.top-bar button {
  font-size: 14px;
  padding: 6px 10px;
  border: none;
  background-color: #0077cc;
  color: white;
  border-radius: 5px;
  cursor: pointer;
}
.top-bar button:disabled {
  background-color: #999;
  cursor: default;
}

#info {
  font-size: 15px;
  text-align: center;
  color: #FFF;
}

#task-box {
  font-size: 50px;
  font-weight: bold;
  text-align: center;
  background-color: #ffdd55;
  padding: 10px 20px;
  border: 2px solid rgba(200,80,100,0.6);
  border-radius: 6px;
  width: 80%;
  max-width: 650px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ----------------------------------------------------
   Spielfeld (Canvas) nimmt restliche Höhe ein
   und wird horizontal zentriert
---------------------------------------------------- */
canvas {
  flex: 1 1 auto;
  min-height: 0;
  width: 80%;
  max-width: 650px;
  margin: 0 auto;                /* zentriert horizontal */
  border: 2px solid #ffdd55;
  background-color: rgba(200,80,100,0.6);
  border-radius: 6px;
  display: block;
  box-sizing: border-box;
}

/* Auf schmalen Geräten volle Breite */
@media (max-width: 768px) {
  canvas {
    width: 95%;
    max-width: none;
  }
}

/* ----------------------------------------------------
   Großer Pokal (Erscheinen bei Meilenstein)
---------------------------------------------------- */
#trophy {
  width: 140px;
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  transition: opacity 0.5s;
  z-index: 10;
}

/* ----------------------------------------------------
   Leiste mit kleinen Pokalen am Seitenende
   passt zum Canvas-Hintergrund
---------------------------------------------------- */
.trophy-bar {
  width: 80%;
  max-width: 650px;
  margin: 0 auto;                /* ebenfalls zentriert */
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 0;
  background-color: rgba(200,80,100,0.6);  /* gleiche Farbe wie Canvas */
  border-radius: 6px;
  box-sizing: border-box;
}

.small-trophy {
  width: 60px;
  height: auto;
  transition: transform 0.3s;
}
.small-trophy:hover {
  transform: scale(1.2);
}

/* ----------------------------------------------------
   Konfetti-Animation
---------------------------------------------------- */
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: explode 1.2s ease-out forwards;
  pointer-events: none;
  z-index: 9999;
}

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

/* ----------------------------------------------------
   Shake-Animation bei Fehler
---------------------------------------------------- */
@keyframes shake {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-5px, 0); }
  40%  { transform: translate(5px, 0); }
  60%  { transform: translate(-5px, 0); }
  80%  { transform: translate(5px, 0); }
 100%  { transform: translate(0, 0); }
}
.container.shake {
  animation: shake 0.5s ease-in-out;
}

/* Start-Text klickbar machen */
.start-click {
  cursor: pointer;
}
.start-click:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------
   Responsive Feinschliff
---------------------------------------------------- */
@media (max-width: 600px) {
  #task-box {
    font-size: 26px;
    padding: 6px 16px;
  }
  .top-bar button {
    font-size: 12px;
    padding: 5px 8px;
  }
  .small-trophy {
    width: 32px;
  }
  #trophy {
    width: 80px;
  }
}
