:root {
  --con: #2f6fed;   /* Konsonant blau */
  --vow: #e23b46;   /* Vokal rot */
  --gold: #f4c430;
  --ink: #2a1550;
  --card: rgba(255, 255, 255, 0.92);
  --tap: 0 4px 0 rgba(0,0,0,0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- Bühne / Himmel ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #3a1c6e 0%, #7b3f9d 42%, #d16aa0 72%, #f6a96b 100%);
}
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 10%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 45% 22%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 85% 26%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 12% 32%, #fff, transparent);
  opacity: .8;
}
.castle {
  position: absolute; left: 0; right: 0; bottom: 0;
  width: 100%; height: 34vh; max-height: 240px;
  filter: drop-shadow(0 -2px 6px rgba(0,0,0,.15));
}

/* ---------- Layout ---------- */
.app {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2vh;
  padding: max(12px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
}
.title {
  margin: 2px 0 0;
  font-size: clamp(20px, 6vw, 30px);
  color: #fff;
  text-shadow: 0 2px 0 #00000055, 0 0 14px #ffd98a88;
  letter-spacing: .5px;
}

/* ---------- Konsonanten-Türme ---------- */
.towers { width: 100%; max-width: 420px; }
.towers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tower {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, #fff, #eef1ff);
  color: var(--con);
  font-weight: 800;
  font-size: clamp(22px, 7.5vw, 34px);
  box-shadow: var(--tap);
  cursor: pointer;
  transition: transform .08s ease, background .15s, box-shadow .08s;
}
.tower::before { /* Zinnen-Dach */
  content: "";
  position: absolute; top: -7px; left: 4px; right: 4px; height: 8px;
  background:
    repeating-linear-gradient(90deg, #fff 0 6px, transparent 6px 10px);
}
.tower:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.tower.selected {
  background: linear-gradient(180deg, var(--con), #1c50c0);
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 6px 14px rgba(47,111,237,.5);
  transform: translateY(-2px);
}

/* ---------- Silben-Bühne ---------- */
.stage {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 10px 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.syllable {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(64px, 15vh, 120px);
  font-weight: 900;
  line-height: 1;
}
.letter {
  font-size: clamp(56px, 20vw, 104px);
  transition: transform .5s cubic-bezier(.34,1.56,.64,1);
}
.consonant { color: var(--con); transform: translateX(0); }
.vowel     { color: var(--vow);  transform: translateX(0); }
.gap { display: inline-block; width: clamp(20px, 8vw, 44px); transition: width .5s ease; }

/* getrennt -> Lücke; verbunden -> zusammen */
.syllable[data-joined="false"] .gap { width: clamp(20px, 8vw, 44px); }
.syllable[data-joined="true"]  .gap { width: 0; }
.syllable[data-joined="true"] .consonant { transform: translateX(6%); }
.syllable[data-joined="true"] .vowel     { transform: translateX(-6%); }

.arc {
  position: absolute;
  bottom: -2px; left: 50%; transform: translateX(-50%) scaleX(.4);
  width: 62%; height: 34px;
  opacity: 0;
  transition: opacity .35s ease .25s, transform .45s ease .25s;
}
.syllable[data-joined="true"] .arc {
  opacity: 1; transform: translateX(-50%) scaleX(1);
}

/* ---------- Vokal-Hebel ---------- */
.vowel-lever {
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px;
}
.lever-btn {
  width: 52px; height: 52px;
  border: none; border-radius: 50%;
  background: var(--vow); color: #fff;
  font-size: 30px; font-weight: 900;
  box-shadow: var(--tap); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 0;
}
.lever-btn:active { transform: translateY(3px); }
.vowel-window {
  min-width: 64px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: #fff5f5; border: 3px solid var(--vow); border-radius: 12px;
  color: var(--vow); font-size: 34px; font-weight: 900;
}

/* ---------- Aktionen ---------- */
.actions {
  width: 100%; max-width: 420px;
  display: flex; gap: 10px;
}
.btn {
  flex: 1;
  border: none; border-radius: 14px;
  padding: 14px 8px;
  font-size: clamp(15px, 4.6vw, 19px);
  font-weight: 800; color: #fff;
  box-shadow: var(--tap); cursor: pointer;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.bridge { background: linear-gradient(180deg, #33b06b, #1f8a4f); }
.speak  { background: linear-gradient(180deg, #9b5cff, #6a2ecc); }
.btn:disabled { filter: grayscale(.6) opacity(.6); }

/* ---------- Uhu ---------- */
.uhu-area {
  width: 100%; max-width: 420px;
  display: flex; align-items: flex-end; gap: 8px;
  margin-top: auto;
}
.bubble {
  flex: 1;
  background: #fff; color: var(--ink);
  border-radius: 16px; padding: 10px 14px;
  font-size: clamp(14px, 4.2vw, 17px); font-weight: 600;
  line-height: 1.25;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  position: relative;
  min-height: 44px;
  display: flex; align-items: center;
}
.bubble::after {
  content: ""; position: absolute; right: -8px; bottom: 16px;
  border: 9px solid transparent; border-left-color: #fff;
}
.uhu { width: 78px; height: 78px; flex: none; }
.uhu svg { width: 100%; height: 100%; display: block; }
.uhu.cheer { animation: hop .5s ease; }
@keyframes hop {
  0%,100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-14px) rotate(-6deg); }
  60% { transform: translateY(-4px) rotate(4deg); }
}
.uhu.cheer .pupil { animation: blink .5s ease; }
@keyframes blink { 40% { transform: scaleY(.2); } }
.pupil { transform-box: fill-box; transform-origin: center; }

/* Uhu spricht: Schnabel bewegt sich + leichtes Wippen */
.beak { transform-box: fill-box; transform-origin: 50% 0%; }
.uhu.talking { animation: talkbob .5s ease-in-out infinite; }
@keyframes talkbob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.uhu.talking .beak { animation: talk .2s ease-in-out infinite; }
@keyframes talk { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(2); } }

/* ---------- Sammel-Leiste ---------- */
.collection {
  display: flex; gap: 6px; justify-content: center; align-items: center;
  min-height: 26px; margin-top: 2px;
}
.slot {
  font-size: 20px; line-height: 1;
  filter: grayscale(1) opacity(.35);
  transform: scale(.85);
  transition: filter .3s ease, transform .3s ease;
}
.slot.got { filter: none; transform: scale(1); }
.slot.pulse { animation: slotpulse .6s ease; }
@keyframes slotpulse { 40% { transform: scale(1.5); } }

/* ---------- Belohnungs-Popup ---------- */
.reward-pop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; pointer-events: none; opacity: 0;
}
.reward-pop.show { animation: rewardShow 2.6s ease forwards; }
@keyframes rewardShow { 0%{opacity:0} 12%{opacity:1} 85%{opacity:1} 100%{opacity:0} }
.reward-pop.show::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(255,220,120,.4), transparent 60%);
}
.reward-emoji { font-size: 36vw; filter: drop-shadow(0 8px 20px rgba(0,0,0,.4)); }
.reward-pop.show .reward-emoji { animation: rewardPop .7s cubic-bezier(.34,1.8,.5,1); }
@keyframes rewardPop {
  0% { transform: scale(0) rotate(-25deg); }
  70% { transform: scale(1.15) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.reward-name {
  position: relative;
  font-size: clamp(20px, 6.5vw, 32px); font-weight: 800; color: #fff;
  background: rgba(58,28,110,.8); padding: 6px 20px; border-radius: 999px;
  text-shadow: 0 1px 2px #0008;
}

/* sehr kleine Höhen (SE) nicht überlaufen lassen */
@media (max-height: 640px) {
  .app { gap: .6vh; }
  .letter { font-size: clamp(46px, 16vw, 80px); }
}
