/* OLIFI – Gestaltung
   Grundsätze: große Ziele (mind. ~64 px), ruhiger Hintergrund, keine Schrift im Kinderbereich,
   Bewegungen weich und kurz, reduziert bei entsprechender Systemeinstellung. */

:root {
  --grund: #fff6e5;
  --grund-dunkel: #f5e6c8;
  --braun: #5b4636;
  --tuerkis: #39c6b5;
  --ding: clamp(72px, 24vmin, 140px);
  --schatten: 0 6px 0 rgba(91, 70, 54, 0.15);
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--grund);
  color: var(--braun);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  height: 100dvh;
  width: 100vw;
  position: relative;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

button {
  font: inherit;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

.bildschirm {
  position: absolute;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background:
    radial-gradient(circle at 15% 10%, #fff 0, transparent 40%),
    radial-gradient(circle at 90% 95%, var(--grund-dunkel) 0, transparent 45%), var(--grund);
}

/* ---------- Start ---------- */
.start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5vmin;
}
.start .maskottchen {
  width: min(55vmin, 320px);
  height: min(55vmin, 320px);
}
.knopf-los {
  width: min(34vmin, 200px);
  height: min(34vmin, 200px);
  border-radius: 50%;
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.12));
  animation: atmen 2.4s ease-in-out infinite;
}
.knopf-los:active {
  transform: scale(0.94);
}

/* Menü-Knopf für Eltern: bewusst klein und unauffällig, oben rechts */
.knopf-eltern {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  padding: 12px;
  opacity: 0.8;
}

/* ---------- Übersicht ---------- */
.uebersicht {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vmin;
}
.uebersicht .maskottchen.klein {
  width: min(28vmin, 160px);
  height: min(28vmin, 160px);
}
.kacheln {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5vmin;
  padding: 0 4vmin;
}
.kachel {
  width: min(70vmin, 340px);
  aspect-ratio: 200 / 130;
  background: var(--kachel, #ffe3a3);
  border-radius: 28px;
  padding: 3vmin;
  box-shadow: var(--schatten);
  transition: transform 0.12s;
}
.kachel:active {
  transform: scale(0.96) translateY(3px);
}

/* ---------- Spiel-Rahmen ---------- */
.knopf-haus {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: calc(env(safe-area-inset-left) + 12px);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  padding: 10px;
  box-shadow: var(--schatten);
  z-index: 5;
}
.buehne {
  position: absolute;
  inset: 0;
  touch-action: none;
}

/* ---------- Farbkörbe ---------- */
.fk {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 88px 3vw 3vh;
  gap: 2vh;
}
.fk-koerbe {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1vh 2vw;
}
.fk-korb {
  position: relative;
  /* Hochformat: bei 4 Farben zwei Reihen, damit die Körbe groß genug bleiben */
  width: min(calc((94vw - 6vw * (var(--spalten) - 1)) / var(--spalten)), 22vh, 220px);
  aspect-ratio: 120 / 100;
  transform-origin: 50% 100%;
}
.fk-korb > svg {
  position: relative;
  z-index: 1;
}
/* Eingeräumte Dinge schauen oben aus dem Korb heraus */
.fk-inhalt {
  position: absolute;
  left: 12%;
  right: 12%;
  top: -14%;
  height: 46%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 0;
}
.mini {
  width: 34%;
  max-width: 54px;
  margin: 0 -6%;
  animation: reinplumpsen 0.35s ease-out;
}
.fk-feld {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 3vmin 4vmin;
  padding: 2vmin;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 32px;
}
.ding {
  width: var(--ding);
  height: var(--ding);
  position: relative;
  z-index: 2;
  touch-action: none;
  cursor: grab;
}
.ding > svg {
  transform: rotate(var(--dreh));
  animation: auftauchen 0.4s backwards cubic-bezier(0.3, 1.6, 0.5, 1);
  animation-delay: var(--verz);
  transition: transform 0.15s;
  filter: drop-shadow(0 5px 0 rgba(91, 70, 54, 0.18));
}
.ding.gefasst {
  z-index: 10;
}
.ding.gefasst > svg,
.ding.gewaehlt > svg {
  transform: rotate(0deg) scale(1.15);
}
.ding.gewaehlt > svg {
  filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 4px var(--tuerkis));
  animation: hupfen 0.9s ease-in-out infinite;
}
.ding.zieht {
  cursor: grabbing;
}
.ding.gleitet {
  transition: transform 0.35s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.ding.weg {
  pointer-events: none;
  z-index: 10;
}
.ding.wackelt > svg {
  animation: wackeln 0.4s ease-in-out 3;
}

.fk-korb.pulsiert {
  animation: pulsieren 0.9s ease-in-out infinite;
}
.fk-korb.pulsiert > svg {
  filter: drop-shadow(0 0 12px #fff) drop-shadow(0 0 6px #ffd84d);
}
.fk-korb.freut {
  animation: freuen 0.5s ease-out;
}

/* Querformat: Körbe links, Dinge rechts */
@media (orientation: landscape) {
  .fk {
    flex-direction: row;
    padding: 3vh 3vw 3vh 96px;
  }
  .fk-koerbe {
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
  }
  .fk-korb {
    width: min(calc((88vh - 2vh * (var(--anzahl) - 1)) / var(--anzahl) * 1.2), 30vw, 200px);
  }
}

/* ---------- Ende ---------- */
.ende {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8vmin;
  background: rgba(255, 246, 229, 0.82);
  animation: einblenden 0.4s ease-out;
}
.ende button {
  width: min(32vmin, 180px);
  height: min(32vmin, 180px);
  border-radius: 50%;
  padding: 5vmin;
  box-shadow: var(--schatten);
  animation: auftauchen 0.45s backwards cubic-bezier(0.3, 1.6, 0.5, 1);
}
.knopf-nochmal {
  background: var(--tuerkis);
}
.knopf-zurueck {
  background: #fff;
  animation-delay: 0.12s !important;
}
.ende button:active {
  transform: scale(0.94);
}

/* ---------- Eltern-Bereich (für Erwachsene: hier ist Schrift erlaubt) ---------- */
.eltern-ebene {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(46, 42, 38, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  user-select: text;
  -webkit-user-select: text;
}
.eltern-karte {
  background: #fff;
  border-radius: 20px;
  padding: 20px 22px;
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  font-size: 16px;
  line-height: 1.45;
  color: #2e2a26;
}
.eltern-karte h2 { margin: 0 0 8px; font-size: 21px; }
.eltern-karte h3 { margin: 18px 0 4px; font-size: 16px; }
.eltern-karte p { margin: 6px 0; }
.eltern-karte ul { padding-left: 18px; margin: 8px 0; }
.eltern-karte li { margin: 6px 0; }
.eltern-karte summary { cursor: pointer; color: #1c7f73; margin-top: 6px; }
.eltern-klein { color: #7a6f66; font-size: 13px; }
.eltern-anzeige {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 6px;
  min-height: 40px;
  margin: 6px 0;
  border-bottom: 2px solid #eee3d2;
}
.eltern-zahlen {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.eltern-zahlen button {
  height: 48px;
  border-radius: 12px;
  background: #f4ede2;
  font-size: 20px;
  font-weight: 600;
  color: #2e2a26;
}
.eltern-zeile {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.eltern-knopf {
  background: #1c7f73;
  color: #fff;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 16px;
  font-weight: 600;
}
.eltern-knopf.leise { background: #f4ede2; color: #2e2a26; }
.eltern-knopf.gross { width: 100%; padding: 14px; margin: 6px 0; }

/* ---------- Konfetti ---------- */
.konfetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}
.konfetti i {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  animation: fallen linear forwards;
}

/* ---------- Bewegungen ---------- */
.hupft {
  animation: hupfen 2.4s ease-in-out infinite;
}
@keyframes atmen {
  50% { transform: scale(1.06); }
}
@keyframes hupfen {
  50% { transform: translateY(-6px); }
}
@keyframes auftauchen {
  from { transform: scale(0); opacity: 0; }
}
@keyframes reinplumpsen {
  from { transform: translateY(-30px) scale(1.3); opacity: 0; }
}
@keyframes wackeln {
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
@keyframes pulsieren {
  50% { transform: scale(1.1); }
}
@keyframes freuen {
  40% { transform: scaleY(0.9) scaleX(1.08); }
  70% { transform: scaleY(1.06) scaleX(0.97); }
}
@keyframes einblenden {
  from { opacity: 0; }
}
@keyframes fallen {
  to { transform: translate(var(--drift), 110vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
