* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #1b0f08; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
/* iPhone als Web-App: die Seite reicht bis unter Statusleiste und Home-Balken
   (black-translucent). Ohne diesen Abstand läge die Kopfleiste unter der Uhr. */
body {
  display: flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#spiel {
  position: relative;
  /* Seitenverhältnis der Spielwelt: 180 x 340 Einheiten */
  --frei-h: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  --frei-b: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
  height: min(var(--frei-h), calc(var(--frei-b) * 340 / 180));
  aspect-ratio: 180 / 340;
}
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#kopf {
  position: absolute; left: 0; right: 0; top: 0;
  height: calc(100% * 22 / 340);
  padding: 0 2%;
  display: flex; align-items: center; gap: 2%;
  color: #fff3d6; font-weight: 700;
  font-size: min(4.2vw, 2.2dvh);
  text-shadow: 0 1px 2px #000;
}
#stufe { white-space: nowrap; }
#balken {
  flex: 1; height: 55%; position: relative;
  background: #3a2112; border: 2px solid #f0c060; border-radius: 99px; overflow: hidden;
}
#fuellung {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(#bfc4c8, #7d858c); transition: width .2s;
}
#prozent { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 85%; }
#kopf button {
  height: 70%; aspect-ratio: 1; border: 2px solid #f0c060; border-radius: 30%;
  background: #8a3d12; color: #fff; font-size: 100%; padding: 0; cursor: pointer;
}
#schicht {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 8, 2, .55); backdrop-filter: blur(2px);
}
#schicht.weg { display: none; }
.karte {
  width: 84%; padding: 7% 6%; text-align: center; color: #4a2a10;
  background: linear-gradient(#fff6e0, #f2d9a6); border: 4px solid #c8862a; border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  font-size: min(4.2vw, 2.2dvh);
}
#s-symbol { font-size: 300%; line-height: 1.2; }
.karte h1 { margin: .3em 0; font-size: 170%; color: #a3261a; }
.karte p { margin: .6em 0 1.2em; line-height: 1.4; }
#s-knopf {
  font: inherit; font-weight: 800; font-size: 130%; color: #fff;
  padding: .6em 1.8em; border: 0; border-radius: 99px; cursor: pointer;
  background: linear-gradient(#5ccf3a, #2f8f1a); box-shadow: 0 4px 0 #1f6010;
}
#s-knopf:active { transform: translateY(3px); box-shadow: 0 1px 0 #1f6010; }
#hammer { position: relative; }
#hammer-zahl {
  position: absolute; right: -25%; bottom: -25%; min-width: 55%; height: 55%;
  border-radius: 99px; background: #c0392b; font-size: 65%; line-height: 1;
  display: flex; align-items: center; justify-content: center; border: 1px solid #fff3d6;
}
#hammer.aktiv { background: #f0c060; box-shadow: 0 0 0 3px #fff3d6, 0 0 14px #ffd36b; }
#hammer:disabled { opacity: .4; }
#hammer.winkt { animation: winken .6s ease-in-out infinite alternate; }
@keyframes winken { from { transform: scale(1); } to { transform: scale(1.18) rotate(-12deg); } }
#heim {
  height: 70%; aspect-ratio: 1; border: 2px solid #f0c060; border-radius: 30%;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  background: #8a3d12; font-size: 100%;
}

/* 1x1-Aufgabe für den Zeitbonus: liegt über der Schotterkammer, das Spiel läuft weiter */
#rechnen { background: #2a6fb0; }
#rechnen.winkt { animation: winken .6s ease-in-out infinite alternate; }
#rechnen:disabled { opacity: .4; }
/* Eigene Ebene über dem ganzen Spiel, gebaut wie #schicht (die erscheint
   nachweislich auf dem iPhone). Halbdurchsichtig: man sieht die Wand weiterlaufen. */
#aufgabe {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18%; background: rgba(20, 8, 2, .25);
}
#aufgabe.weg { display: none; }
#aufgabe .karte-a {
  width: 88%; padding: 5% 5% 6%; border-radius: 18px; text-align: center;
  background: linear-gradient(#fff6e0, #f2d9a6); border: 3px solid #c8862a;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); color: #4a2a10;
  font-size: min(5vw, 2.6dvh); font-weight: 800;
}
#aufgabe .frage { font-size: 170%; margin-bottom: 4%; }
#aufgabe .antworten { display: grid; grid-template-columns: 1fr 1fr; gap: 4%; }
#aufgabe .antworten button {
  font: inherit; font-size: 140%; padding: 4% 0; border-radius: 14px; border: 0; color: #fff;
  background: linear-gradient(#4f9be8, #2a6fb0); box-shadow: 0 3px 0 #1d4f80; cursor: pointer;
}
#aufgabe .antworten button.richtig { background: linear-gradient(#5ccf3a, #2f8f1a); }
#aufgabe .antworten button.falsch { background: linear-gradient(#e85a4f, #b0322a); }
#aufgabe.wackeln .karte-a { animation: wackeln .35s; }
@keyframes wackeln { 25% { transform: translateX(-4%); } 75% { transform: translateX(4%); } }
#bonus {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none;
  font-size: min(9vw, 4.6dvh); font-weight: 900; color: #fff; text-shadow: 0 2px 6px #000;
  animation: bonus 1.2s forwards;
}
@keyframes bonus { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-60%) scale(1.3); } }
