/* Tilda & Bruno – Zahlenmauer-Spiel. Farben und Schrift wie seite.css, für Tablet und Handy gebaut. */
@font-face {
  font-family: "Baloo 2";
  src: url("fonts/Baloo2.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
:root {
  --creme: #FFF3E6; --papier: #FFFDF9; --weiss: #FFFFFF; --tinte: #2B1A0E; --text: #4A3423;
  --rost: #9C4A12; --petrol: #1F7A8C; --petrol-dunkel: #155A68; --orange: #E8731B; --gelb: #F7C948;
  --sand: #EAD7B7; --sand-dunkel: #C9AE86; --gruen: #3E8E41; --gruen-hell: #DDF1D5; --rot: #C0392B;
  --wasser: #6EC3E0; --schatten: rgba(43,26,14,.18);
  --kopf: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  --stein: clamp(64px, 21vw, 104px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--kopf); color: var(--tinte); background: var(--wasser) url("bilder/damm.webp") center bottom / cover no-repeat fixed;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--petrol); outline-offset: 3px; }
[hidden] { display: none !important; }

.buehne { min-height: 100%; display: flex; flex-direction: column; background: linear-gradient(rgba(255,253,249,.55), rgba(255,253,249,.25)); }

/* Kopfleiste mit Damm-Fortschritt */
.leiste { display: flex; align-items: center; gap: 12px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(255,243,230,.92); box-shadow: 0 2px 8px var(--schatten); }
.zurueck img { display: block; border-radius: 999px; }
.damm { flex: 1; display: flex; gap: 4px; justify-content: center; }
.loch { flex: 1; max-width: 44px; height: 22px; border-radius: 6px; background: var(--wasser); border: 2px dashed #3F9CBF; }
.loch.fertig { background: var(--sand); border: 2px solid var(--sand-dunkel); box-shadow: inset 0 -3px 0 var(--sand-dunkel); }
.loch.jetzt { border-color: var(--orange); border-style: solid; animation: puls 1.4s ease-in-out infinite; }
.ton { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ton .stumm { display: none; }
.ton.aus .stumm { display: inline; }
.ton.aus .welle { display: none; }

/* Start und Ende */
.bild { flex: 1; display: flex; }
.start, .ende { align-items: center; justify-content: center; padding: 20px 16px; }
.start-karte { width: 100%; max-width: 520px; background: var(--papier); border-radius: 28px; padding: 24px 22px 26px; text-align: center; box-shadow: 0 12px 32px var(--schatten); }
.start-karte h1 { font-size: clamp(30px, 7vw, 42px); line-height: 1.1; color: var(--rost); margin: 4px 0 10px; }
.start-karte p { font-family: "Segoe UI", system-ui, sans-serif; font-size: 18px; line-height: 1.5; color: var(--text); margin: 0 0 16px; }
.start-bruno { width: 140px; height: auto; margin: -70px auto 0; display: block; filter: drop-shadow(0 6px 10px var(--schatten)); }
.start { padding-top: 90px; }
.ende-bild { width: 100%; height: auto; border-radius: 18px; display: block; margin-bottom: 8px; }
.beispiel { display: inline-flex; flex-direction: column; gap: 4px; margin: 0 0 18px; }
.wahl-titel { font-weight: 700; margin: 14px 0 0 !important; }
.wahl { display: flex; gap: 10px; }
.wahl-knopf { flex: 1; flex-direction: column; line-height: 1.1; padding: 10px 12px; min-height: 78px; border-radius: 22px; }
#weiter { line-height: 1.2; }
.wahl-knopf small { font-size: 14px; font-weight: 600; opacity: .9; margin-top: 4px; }
#los100 { background: var(--gruen); box-shadow: 0 4px 0 #2B6A2E; }
.gesamt { font-weight: 700; margin: 0 0 6px !important; }
.mehr { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; font-family: "Segoe UI", system-ui, sans-serif; font-size: 16px; }
.mehr a { color: var(--petrol); font-weight: 700; }

.knopf { display: flex; width: 100%; align-items: center; justify-content: center; min-height: 60px; margin-top: 10px; padding: 8px 24px; border: 0; border-radius: 999px; background: var(--petrol); color: var(--weiss); font-size: 22px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 var(--petrol-dunkel); }
.knopf:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--petrol-dunkel); }
.knopf.leise { background: var(--weiss); color: var(--petrol); border: 2px solid var(--petrol); box-shadow: none; font-size: 19px; }

/* Spielfeld: oben Bruno, Mitte Mauer mit steigendem Wasser, unten der Fluss */
.spiel { flex-direction: column; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0 0; overflow: hidden; }
.sprecher { width: 100%; max-width: 760px; padding: 0 12px; display: flex; align-items: flex-end; gap: 8px; }
.bruno { width: 84px; height: auto; flex-shrink: 0; filter: drop-shadow(0 4px 6px var(--schatten)); transform-origin: 50% 100%; }
.bruno.hopsen { animation: hopsen .5s ease-out; }
.bruno.wackeln { animation: wackel .45s ease-in-out; }
.bruno.nass { animation: nass 1.6s ease-in-out; }
.blase { position: relative; flex: 1; margin: 0 0 18px; min-height: 64px; padding: 10px 14px; background: var(--weiss); border-radius: 18px; font-size: clamp(17px, 4.2vw, 21px); font-weight: 600; line-height: 1.25; box-shadow: 0 4px 12px var(--schatten); display: flex; align-items: center; }
.blase::before { content: ""; position: absolute; left: -10px; bottom: 16px; border: 10px solid transparent; border-right-color: var(--weiss); border-left: 0; }
.blase.neu { animation: rein .25s ease-out; }

.mauer-rahmen { position: relative; width: calc(100% - 24px); max-width: 760px; flex: 1; min-height: 0; max-height: 500px; display: flex; flex-direction: column; justify-content: center; overflow: hidden;
  background: rgba(255,253,249,.94); border-radius: 24px; padding: 8px 10px 16px; box-shadow: 0 8px 24px var(--schatten); border: 4px solid transparent; }
.mauer-rahmen.alarm { animation: alarm 1s ease-in-out infinite; }
.mauer-rahmen.schwapp { animation: schwapp .6s ease-out; }
.mauer-titel { position: relative; z-index: 2; margin: 0 0 6px; text-align: center; font-size: 17px; font-weight: 700; color: var(--rost); }
.pegel { position: absolute; left: 0; right: 0; bottom: 0; height: 10%; z-index: 1; background: linear-gradient(rgba(70,170,215,.55), rgba(31,122,140,.75)); transition: height .5s ease-out; }
.welle { position: absolute; left: -50%; right: -50%; top: -10px; height: 12px;
  background: radial-gradient(circle at 10px -2px, transparent 11px, rgba(70,170,215,.55) 12px) 0 0 / 20px 12px repeat-x; animation: welle 2.4s linear infinite; }
.mauer { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mauer.vier { --stein: clamp(58px, 19vw, 96px); }
.reihe { display: flex; gap: 6px; justify-content: center; }

.stein {
  width: var(--stein); height: calc(var(--stein) * .62); border-radius: 10px; border: 0; padding: 0;
  font-size: calc(var(--stein) * .34); font-weight: 800; line-height: 1; cursor: pointer;
  background: var(--sand); box-shadow: inset 0 -5px 0 var(--sand-dunkel), 0 2px 3px var(--schatten);
}
.stein.klein { --stein: 72px; display: inline-flex; align-items: center; justify-content: center; }
.stein.klein.voll, .stein.geloest { background: var(--gruen-hell); box-shadow: inset 0 -5px 0 #A9D69A, 0 2px 3px var(--schatten); color: #1F5C22; }
.stein.vorgegeben { cursor: default; color: var(--tinte); }
.stein:disabled { opacity: 1; }
.stein.leer { background: rgba(255,253,249,.7); box-shadow: inset 0 0 0 3px var(--sand-dunkel); color: var(--petrol); }
.stein.bereit { box-shadow: inset 0 0 0 3px var(--orange); }
.stein.ziel { background: var(--weiss); box-shadow: inset 0 0 0 4px var(--orange), 0 0 0 6px rgba(247,201,72,.6); color: var(--orange); animation: puls 1.1s ease-in-out infinite; }
.stein.tipp { outline: 4px solid var(--gelb); outline-offset: 2px; }
.stein.wackel { animation: wackel .4s ease-in-out; }
.stein.plopp { animation: plopp .35s ease-out; }
.ruf { position: absolute; z-index: 3; left: 0; right: 0; top: 40%; margin: 0; text-align: center; font-size: clamp(30px, 8vw, 48px); font-weight: 800; color: var(--orange); text-shadow: 0 3px 0 var(--weiss), 0 0 12px var(--weiss); opacity: 0; pointer-events: none; }
.ruf.zeig { animation: ruf 1.4s ease-out; }

/* Fluss */
.fluss { position: relative; width: 100%; height: clamp(150px, 26vh, 210px); flex-shrink: 0; overflow: hidden;
  background: repeating-linear-gradient(100deg, rgba(255,255,255,0) 0 38px, rgba(255,255,255,.18) 38px 44px, rgba(255,255,255,0) 44px 90px) 0 0 / 180px 100%,
              linear-gradient(#5BB8DC, #2C8DB5);
  animation: stroemung 3s linear infinite; box-shadow: inset 0 8px 10px -6px rgba(0,0,0,.25); }
.treib { position: absolute; left: 0; width: 92px; height: 58px; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; will-change: transform; }
.treib span { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; border-radius: 12px; background: var(--sand);
  box-shadow: inset 0 -6px 0 var(--sand-dunkel), 0 6px 0 rgba(20,70,95,.35); font-size: 28px; font-weight: 800; animation: schaukeln 1.8s ease-in-out infinite; }
.treib:nth-child(odd) span { animation-delay: -.9s; }
.treib.geklaut { transition: opacity .5s, top .5s; opacity: 0; top: -20% !important; }
.flug { position: fixed; z-index: 30; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--sand);
  box-shadow: inset 0 -6px 0 var(--sand-dunkel); font-family: var(--kopf); font-size: 28px; font-weight: 800; pointer-events: none; }
.tropfen { position: fixed; z-index: 31; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #8ED3EE; box-shadow: inset -2px -2px 0 #4AA7CF; pointer-events: none; }
/* Ente: schwimmt im Wasser (unten an der Wasserlinie abgeschnitten), Bugwelle vorn, Kielwasser hinten */
.ente { position: absolute; left: 0; top: 0; z-index: 4; width: 88px; height: 92px; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; will-change: transform; }
.ente-wasser { position: absolute; left: -30px; right: -10px; top: -200px; bottom: 8px; overflow: hidden; pointer-events: none; }
.ente-flug { position: fixed; z-index: 34; pointer-events: none; }
.ente-flug img { display: block; width: 100%; height: auto; }
.ente-figur { position: absolute; left: 13px; bottom: -44px; width: 120px; animation: duempeln 1.6s ease-in-out infinite; transform-origin: 50% 80%; }
.ente.eilig .ente-figur { animation: paddeln .45s ease-in-out infinite; }
.ente-figur img { display: block; width: 100%; height: auto; }
/* Zahl auf der Vorderseite des Holzklotzes im Schnabel (spiel_ente_stein.webp) */
.ente-beute { position: absolute; left: 2%; top: 37.5%; width: 23%; height: 17%; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; color: var(--tinte); letter-spacing: -.5px; }
.ente-welle { position: absolute; left: -8px; right: -4px; bottom: 2px; height: 14px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse at 20% 50%, rgba(255,255,255,.9), rgba(255,255,255,.35) 45%, transparent 70%);
  animation: bugwelle 1s ease-in-out infinite; }
.ente-kiel { position: absolute; left: 70px; bottom: 4px; width: 110px; height: 30px; pointer-events: none; opacity: .75;
  background: linear-gradient(to right, rgba(255,255,255,.7), transparent) top left / 100% 3px no-repeat,
              linear-gradient(to right, rgba(255,255,255,.7), transparent) bottom left / 100% 3px no-repeat;
  clip-path: polygon(0 45%, 100% 0, 100% 100%, 0 55%); animation: kiel 1.2s ease-in-out infinite; }
.ente.eilig .ente-kiel { width: 160px; }
.feder { position: fixed; z-index: 33; width: 10px; height: 18px; margin: -9px 0 0 -5px; border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  background: linear-gradient(#FFF6C9, #F4D55A); box-shadow: 0 1px 2px rgba(0,0,0,.15); pointer-events: none; }

/* Zwischenstand */
.schicht { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(43,26,14,.45); }
.karte { width: 100%; max-width: 380px; background: var(--papier); border-radius: 28px; padding: 22px; text-align: center; box-shadow: 0 16px 40px var(--schatten); animation: plopp .35s ease-out; }
.karte h2 { margin: 0; font-size: 32px; color: var(--gruen); }
.karte p { margin: 6px 0 4px; font-size: 19px; }
.sterne, .karte .sterne, .start-karte .sterne { font-size: 56px; line-height: 1.1; margin: 0 0 4px; min-height: 62px; display: flex; justify-content: center; gap: 6px; }
.stern { display: inline-block; color: var(--sand); transform: scale(0); }
.stern.an { color: var(--gelb); text-shadow: 0 3px 0 #C99A1A; animation: sternrein .5s cubic-bezier(.3,1.7,.5,1) forwards; }
.stern.aus { animation: sternblass .4s ease-out forwards; }

/* Jubel nach einer Mauer */
.stein.jubel { animation: steinjubel .55s ease-out; }
.bruno.jubel { animation: jubel 1.1s ease-out; }
.ende-bild.jubel { animation: bildjubel 1s ease-out; }
.loch.neu { animation: plopp .45s ease-out; }
.flug-loch { position: fixed; z-index: 32; width: 44px; height: 22px; border-radius: 6px; pointer-events: none;
  background: var(--sand); border: 2px solid var(--sand-dunkel); box-shadow: inset 0 -3px 0 var(--sand-dunkel), 0 4px 10px var(--schatten); }
.konfetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 40; pointer-events: none; }
.tilda { position: fixed; right: 8px; bottom: 0; z-index: 35; width: clamp(110px, 26vw, 170px); pointer-events: none; transform: translateY(115%); }
.tilda img { display: block; width: 100%; height: auto; filter: drop-shadow(0 -4px 10px var(--schatten)); }
.tilda-ruf { position: absolute; z-index: 1; right: 76%; top: 2%; padding: 6px 12px; border-radius: 16px; background: var(--weiss); color: var(--orange);
  font-size: clamp(20px, 5vw, 26px); font-weight: 800; white-space: nowrap; box-shadow: 0 4px 12px var(--schatten); }
.tilda.zeig { animation: tilda 2.6s ease-in-out; }

/* Finale beim letzten Stein */
body::after { content: ""; position: fixed; inset: 0; z-index: 29; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(20,12,5,.6) 100%); }
body.finale::after { opacity: 1; }
.flug.gold { z-index: 31; background: #FFE58A; box-shadow: inset 0 -6px 0 #E0B53A, 0 0 0 4px rgba(255,255,255,.7), 0 0 30px 10px rgba(247,201,72,.85); }
.blitz { position: fixed; inset: 0; z-index: 38; background: #FFFBEA; opacity: 0; pointer-events: none; }
.blitz.an { animation: blitz .45s ease-out; }
.buehne.ruetteln { animation: ruetteln .45s ease-out; }
.bruno-gross { position: fixed; left: 2%; bottom: 0; z-index: 36; width: clamp(170px, 40vw, 300px); pointer-events: none; transform: translateY(110%); transform-origin: 50% 100%; }
.bruno-gross img { display: block; width: 100%; height: auto; filter: drop-shadow(0 -4px 12px var(--schatten)); }
.bruno-gross.zeig { animation: brunogross 2.6s ease-in-out; }

/* Sternzähler oben */
.sternzahl { display: flex; align-items: center; gap: 2px; padding: 4px 12px; border-radius: 999px; background: var(--weiss); box-shadow: 0 2px 6px var(--schatten);
  font-size: 20px; font-weight: 800; color: var(--rost); white-space: nowrap; }
.sternzahl > span:first-child { color: var(--gelb); text-shadow: 0 2px 0 #C99A1A; font-size: 22px; }
.sternzahl.huepf { animation: plopp .35s ease-out; }
.flug-stern { position: fixed; z-index: 42; font-size: 52px; line-height: 1; color: var(--gelb); text-shadow: 0 3px 0 #C99A1A; pointer-events: none; }

@media (min-width: 900px) {
  :root { --stein: 104px; }
  .mauer.vier { --stein: 96px; }
  .bruno { width: 110px; }
}
@media (max-height: 700px) {
  :root { --stein: clamp(52px, 16vw, 80px); }
  .mauer.vier { --stein: clamp(50px, 15vw, 72px); }
  .bruno { width: 64px; }
  .fluss { height: 140px; }
}

@keyframes puls { 50% { transform: scale(1.04); } }
@keyframes wackel { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes plopp { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes rein { from { transform: translateY(6px); opacity: .4; } }
@keyframes hopsen { 30% { transform: translateY(-22px) scaleY(1.05); } 60% { transform: translateY(0) scaleY(.94); } }
@keyframes nass { 10%, 70% { filter: drop-shadow(0 4px 6px var(--schatten)) saturate(.5) brightness(1.15); transform: rotate(-4deg); } 40% { transform: rotate(4deg); } }
@keyframes alarm { 50% { border-color: var(--rot); } }
@keyframes schwapp { 30% { transform: translateY(6px) rotate(-1deg); } 60% { transform: translateY(-4px) rotate(1deg); } }
@keyframes welle { to { transform: translateX(20px); } }
@keyframes stroemung { to { background-position: 180px 0, 0 0; } }
@keyframes schaukeln { 50% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes ruf { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.1); } 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: translateY(-30px); } }
@keyframes duempeln { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-3px) rotate(-2deg); } 65% { transform: translateY(2px) rotate(2deg); } }
@keyframes paddeln { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-4px) rotate(3deg); } }
@keyframes bugwelle { 50% { transform: scaleX(1.12); opacity: .7; } }
@keyframes kiel { 50% { transform: scaleY(1.25); opacity: .5; } }
@keyframes sternrein { 0% { transform: scale(0) rotate(-120deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes sternblass { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(.85); opacity: .55; } }
@keyframes steinjubel { 0% { transform: scale(1); } 40% { transform: scale(1.16) translateY(-4px); background: #FFE58A; box-shadow: 0 0 0 5px rgba(247,201,72,.7), 0 0 18px rgba(247,201,72,.9); } 100% { transform: scale(1); } }
@keyframes jubel { 15% { transform: translateY(-28px) rotate(-8deg); } 30% { transform: translateY(0) scaleY(.92); } 50% { transform: translateY(-22px) rotate(8deg); } 65% { transform: translateY(0) scaleY(.94); } 80% { transform: translateY(-8px); } }
@keyframes bildjubel { 0% { transform: scale(.9); } 40% { transform: scale(1.04) rotate(-1deg); } 70% { transform: scale(.99) rotate(1deg); } 100% { transform: scale(1); } }
@keyframes tilda { 0% { transform: translateY(115%); } 16% { transform: translateY(-8%) rotate(-4deg); } 26% { transform: translateY(6%) scaleY(.96); } 38% { transform: translateY(-6%) rotate(4deg); } 48% { transform: translateY(6%) scaleY(.97); }
  58% { transform: translateY(4%); } 80% { transform: translateY(6%); } 100% { transform: translateY(115%); } }
@keyframes blitz { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes ruetteln { 10% { transform: translate(-9px, 4px); } 25% { transform: translate(8px, -5px); } 40% { transform: translate(-6px, 3px); } 60% { transform: translate(4px, -2px); } 80% { transform: translate(-2px, 1px); } }
/* Bruno springt hoch, landet (20 %), springt noch mal (42 %), landet, bleibt kurz und taucht ab */
@keyframes brunogross { 0% { transform: translateY(110%); } 11% { transform: translateY(-14%) rotate(-4deg); } 20% { transform: translateY(4%) scale(1.04, .94); }
  24% { transform: translateY(3%); } 32% { transform: translateY(-12%) rotate(4deg); } 42% { transform: translateY(4%) scale(1.04, .94); } 47% { transform: translateY(3%); }
  56% { transform: translateY(-4%) rotate(-2deg); } 62% { transform: translateY(3%); } 82% { transform: translateY(3%); } 100% { transform: translateY(110%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; }
  .stern { transform: none; }
  .stern.aus { opacity: .55; }
}
