/* ============================================================
   Sortenrein — Prototyp-Stylesheet

   Designprinzipien für die Zielgruppe (Frauen 35-60):
   - Grundschrift 17px, nie kleiner als 15px
   - Touch-Ziele mindestens 48px
   - warme Farben, hoher Kontrast, keine dünnen Graustufen
   - Farbe nie als einziger Informationsträger: jede Erntesorte hat
     zusätzlich eine eigene Silhouette
   ============================================================ */

:root {
  --cream:       #FBF3E4;
  --cream-2:     #F3E6CE;
  --cream-3:     #E8D7B8;
  --green:       #6A9A5B;
  --green-dark:  #4C7440;
  --green-light: #8FBF7E;
  --terracotta:  #DD7250;
  --gold:        #EFB03C;
  --gold-dark:   #C88A1E;
  --wood:        #A9754F;
  --wood-dark:   #7A5236;
  --sky-1:       #CDE9F2;
  --sky-2:       #A9D8E8;
  --ink:         #43352A;
  --ink-soft:    #766050;
  --white:       #FFFDF8;

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;

  --shadow-s: 0 2px 0 rgba(67,53,42,.13);
  --shadow-m: 0 4px 14px rgba(67,53,42,.16);
  --shadow-l: 0 10px 34px rgba(67,53,42,.26);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #DCCFB6;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

/* Alle Grafiken sind Inline-SVG und füllen ihren Container */
svg { width: 100%; height: 100%; display: block; }

/* ---------- Rahmen: simuliertes Telefon ---------- */

.phone {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  max-height: 940px;
  margin: 0 auto;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-l);
}
@media (min-width: 500px) and (min-height: 780px) {
  body { display: grid; place-items: center; padding: 16px; }
  .phone { height: calc(100dvh - 32px); border-radius: 28px; }
}

/* ---------- Kopfleiste ---------- */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--white);
  box-shadow: var(--shadow-s);
  z-index: 5;
}

.purse {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0,0,0,.18);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 94px;
}
.purse__icon { width: 22px; height: 22px; flex: 0 0 auto; }
.purse__value { font-size: 17px; }
.purse.is-bumped { animation: bump .45s ease; }
@keyframes bump {
  0%,100% { transform: scale(1); }
  35%     { transform: scale(1.16); }
}

.brand { flex: 1 1 auto; text-align: center; line-height: 1.15; }
.brand__name { display: block; font-weight: 800; letter-spacing: .3px; font-size: 17px; }
.brand__sub  { display: block; font-size: 13px; opacity: .88; }

.iconbtn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.iconbtn svg { width: 21px; height: 21px; }
.iconbtn:active { transform: scale(.92); }
.iconbtn:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }

/* ---------- Bildschirme ---------- */

.screen {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.screen.is-active { display: flex; }

/* ---------- Hof ---------- */

.farm {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.farm__sky {
  position: absolute; inset: 0 0 58% 0;
  background: linear-gradient(180deg, var(--sky-2) 0%, var(--sky-1) 62%, #DFF0E2 100%);
}
.farm__sun {
  position: absolute; top: 12%; right: 13%;
  width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #FFE9A8, #F7C948);
  box-shadow: 0 0 34px rgba(247,201,72,.6);
}
.cloud {
  position: absolute;
  height: 20px;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  box-shadow: 15px -7px 0 -2px rgba(255,255,255,.9), 32px 2px 0 -4px rgba(255,255,255,.9);
}
.cloud--1 { top: 16%; left: -60px; width: 50px; animation: drift 46s linear infinite; }
.cloud--2 { top: 40%; left: -60px; width: 38px; animation: drift 68s linear infinite 12s; }
@keyframes drift { to { transform: translateX(560px); } }

/* Hügelkette an der Horizontlinie — gibt dem Hof Tiefe */
.farm__hills {
  position: absolute; left: -8%; right: -8%; bottom: -2px; height: 54px;
  background:
    radial-gradient(ellipse 34% 118% at 18% 100%, #8FBF7E 0 99.5%, transparent 100%),
    radial-gradient(ellipse 30% 96%  at 53% 100%, #A3CE8C 0 99.5%, transparent 100%),
    radial-gradient(ellipse 38% 126% at 86% 100%, #86B674 0 99.5%, transparent 100%);
}

.farm__ground {
  position: absolute; inset: 42% 0 0 0;
  background:
    radial-gradient(ellipse 130% 74% at 50% 4%, #A7CE8C 0%, #8CBB72 46%, #77A55E 100%);
  box-shadow: inset 0 4px 7px rgba(72,112,62,.2);
}
.farm__ground::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.22) 1.4px, transparent 1.6px);
  background-size: 26px 26px;
  opacity: .5;
}

.farm__stage { position: absolute; inset: 0; }

/* Der Fußpunkt des Objekts sitzt exakt auf seiner y-Position.
   Das Namensschild hängt darunter, damit das Tier auf dem Boden steht
   und nicht darüber schwebt. */
.plot {
  --size: 1;
  position: absolute;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  animation: pop .5s cubic-bezier(.2,1.5,.4,1) both;
  /* Nur Grafik und Namensschild sind anklickbar, nicht der leere
     Kasten drumherum — sonst fangen sich überlappende Objekte
     gegenseitig die Klicks ab. */
  pointer-events: none;
}
.plot__icon, .plot__label { pointer-events: auto; }
@keyframes pop {
  from { transform: translate(-50%, -100%) scale(0); }
  to   { transform: translate(-50%, -100%) scale(1); }
}
.plot__shadow {
  position: absolute;
  bottom: -3px; left: 50%;
  width: 72%; height: 10px;
  transform: translateX(-50%);
  background: rgba(58,43,30,.24);
  border-radius: 50%;
  filter: blur(2.5px);
}
.plot__icon {
  position: relative;
  width:  calc(62px * var(--size));
  height: calc(62px * var(--size));
  filter: drop-shadow(0 2px 1px rgba(60,45,30,.22));
}
.plot__label {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  margin-top: 3px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
  box-shadow: var(--shadow-s);
  cursor: pointer;
}
.plot__label:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }

.plot--animal .plot__icon { cursor: pointer; animation: idle 3.4s ease-in-out infinite; }
.plot--animal .plot__icon:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; border-radius: 8px; }
.plot--animal .plot__icon:active { transform: scale(1.16) rotate(-6deg); }
@keyframes idle {
  0%,100% { transform: translateY(0)    rotate(0deg); }
  25%     { transform: translateY(-4px) rotate(-4deg); }
  75%     { transform: translateY(-2px) rotate(4deg); }
}

.bubble {
  position: absolute;
  max-width: 76%;
  background: var(--white);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--r-m);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-m);
  transform: translate(-50%, -100%);
  animation: pop .32s cubic-bezier(.2,1.5,.4,1) both;
  z-index: 4;
  pointer-events: none;
}
.bubble::after {
  content: "";
  position: absolute; bottom: -8px; left: 50%;
  margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: var(--white);
  border-bottom: 0;
}

.heart {
  position: absolute;
  width: 22px; height: 22px;
  pointer-events: none;
  animation: floatUp 1.15s ease-out forwards;
  z-index: 4;
}
@keyframes floatUp {
  from { transform: translate(-50%,0) scale(.5); opacity: 1; }
  to   { transform: translate(-50%,-74px) scale(1.2); opacity: 0; }
}

.farm__panel {
  flex: 0 0 auto;
  padding: 14px 18px 18px;
  background: var(--cream);
  border-top: 3px solid var(--cream-3);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.hint {
  margin: 0 0 2px;
  text-align: center;
  font-size: 15px;
  color: var(--ink-soft);
  min-height: 22px;
}

/* ---------- Schaltflächen ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--r-m);
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  transition: transform .08s ease;
  text-align: center;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }

.btn--primary {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #3A2B16;
  box-shadow: 0 4px 0 #A87317;
}
.btn--primary:active:not(:disabled) { box-shadow: 0 2px 0 #A87317; }

.btn--big { min-height: 58px; font-size: 19px; }

.btn--ghost {
  background: var(--cream-2);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--cream-3);
}
.btn--ghost:active:not(:disabled) { box-shadow: 0 1px 0 var(--cream-3); }

.btn--tool {
  flex: 1 1 0;
  flex-direction: column;
  gap: 1px;
  min-height: 64px;
  padding: 8px 6px;
  font-size: 14px;
  background: var(--cream-2);
  box-shadow: 0 3px 0 var(--cream-3);
}
.btn--tool small { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.btn--tool .ticon { width: 22px; height: 22px; }

.ticon { width: 24px; height: 24px; flex: 0 0 auto; }

/* ---------- Puzzle ---------- */

.puzzlebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--cream-2);
  border-bottom: 3px solid var(--cream-3);
}
.puzzlebar .iconbtn { background: rgba(67,53,42,.1); }
.puzzlebar__info { flex: 1 1 auto; text-align: center; line-height: 1.2; min-width: 0; }
/* Gegengewicht zum Zurück-Knopf, damit die Überschrift mittig sitzt */
.bar-spacer { flex: 0 0 auto; width: 44px; }
.puzzlebar__info strong { display: block; font-size: 17px; }
.puzzlebar__info span  { display: block; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.starrow { display: flex; gap: 3px; width: 66px; justify-content: flex-end; flex: 0 0 auto; }
.starrow span { width: 18px; height: 18px; filter: grayscale(1); opacity: .3; }
.starrow span.is-on { filter: none; opacity: 1; }
.starrow--big { width: auto; justify-content: center; gap: 8px; margin: 4px 0 2px; }
.starrow--big span { width: 42px; height: 42px; }
.starrow--big span.is-on { animation: starPop .45s cubic-bezier(.2,1.6,.4,1) both; }
.starrow--big span.is-on:nth-child(2) { animation-delay: .13s; }
.starrow--big span.is-on:nth-child(3) { animation-delay: .26s; }
@keyframes starPop {
  from { transform: scale(0) rotate(-40deg); }
  to   { transform: scale(1) rotate(0); }
}

/* Spaltenzahl und Korbgröße setzt das Skript je nach Korbanzahl,
   damit die Körbe immer den verfügbaren Platz ausnutzen. */
.tubes {
  --cols: 5;
  --unit: 56px;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), auto);
  align-content: center;
  justify-content: center;
  gap: 22px 10px;
  padding: 14px 12px;
  overflow-y: auto;
}

.tube {
  position: relative;
  width: calc(var(--unit) + 14px);
  padding: 7px 7px 11px;
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  background: linear-gradient(180deg, #C99A6E 0%, var(--wood) 55%, var(--wood-dark) 100%);
  border: 3px solid var(--wood-dark);
  border-top: none;
  border-radius: 6px 6px 20px 20px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: var(--shadow-s);
}
/* Holzmaserung im Korbinneren. Muss hinter den Einheiten liegen —
   ohne z-index würde das absolut positionierte Pseudo-Element über
   den statisch positionierten Einheiten stapeln und die Steine
   durchscheinend wirken lassen. */
.tube::before {
  content: "";
  position: absolute; inset: 7px 7px 11px;
  z-index: 0;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.1) 0 4px, transparent 4px 11px);
  border-radius: 4px 4px 16px 16px;
  pointer-events: none;
}
.tube:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }
.tube.is-source { transform: translateY(-8px); box-shadow: 0 10px 0 -3px rgba(67,53,42,.22); }
.tube.is-target { box-shadow: 0 0 0 3px var(--gold), var(--shadow-m); }
.tube.is-done   { border-color: var(--gold-dark); box-shadow: 0 0 0 3px var(--gold); cursor: default; }
.tube.is-hinted { animation: hintPulse 1s ease-in-out 3; }
@keyframes hintPulse {
  0%,100% { box-shadow: 0 0 0 3px var(--terracotta), var(--shadow-s); }
  50%     { box-shadow: 0 0 0 7px rgba(221,114,80,.42), var(--shadow-m); }
}

.tube__slot { height: var(--unit); flex: 0 0 auto; }

.unit {
  height: var(--unit);
  flex: 0 0 auto;
  position: relative;
  z-index: 1;              /* über der Holzmaserung des Korbs */
  border-radius: 9px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.14), inset 0 2px 0 rgba(255,255,255,.5);
  animation: drop .22s ease-out both;
}
.unit svg { width: 84%; height: 84%; }
@keyframes drop {
  from { transform: translateY(-14px); opacity: .4; }
  to   { transform: translateY(0); opacity: 1; }
}
.unit.is-lifted {
  transform: translateY(-16px) scale(1.06);
  box-shadow: 0 6px 10px rgba(0,0,0,.28);
  z-index: 2;
  position: relative;
}
.tube__seal {
  position: absolute;
  top: -14px; left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  background: var(--gold);
  border-radius: 999px;
  width: 25px; height: 25px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-s);
  animation: pop2 .3s cubic-bezier(.2,1.6,.4,1) both;
}
.tube__seal svg { width: 15px; height: 15px; }
@keyframes pop2 {
  from { transform: translateX(-50%) scale(0); }
  to   { transform: translateX(-50%) scale(1); }
}

.toolbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px 14px;
  background: var(--cream);
  border-top: 3px solid var(--cream-3);
}

/* ---------- Ausbau ---------- */

.shoplist {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shopitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--white);
  border: 2px solid var(--cream-3);
  border-radius: var(--r-m);
  box-shadow: var(--shadow-s);
}
.shopitem.is-owned  { opacity: .66; background: var(--cream-2); }
.shopitem.is-locked { opacity: .74; }
.shopitem__icon {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--cream-2);
  border-radius: var(--r-s);
  padding: 5px;
}
.shopitem__body { flex: 1 1 auto; min-width: 0; }
.shopitem__name { font-weight: 800; font-size: 16px; }
.shopitem__desc { font-size: 14px; color: var(--ink-soft); }
.shopitem__price {
  display: flex; align-items: center; gap: 5px;
  font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 3px;
}
.shopitem__price .coin { width: 18px; height: 18px; flex: 0 0 auto; }
.shopitem__price.is-short { color: var(--terracotta); }
.shopitem__buy {
  flex: 0 0 auto;
  min-height: 48px;
  min-width: 86px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--r-s);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #3A2B16;
  box-shadow: 0 3px 0 #A87317;
}
.shopitem__buy:disabled { background: var(--cream-3); color: var(--ink-soft); box-shadow: none; cursor: not-allowed; }
.shopitem__buy:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }
.shoplist__head {
  margin: 8px 2px 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Fußnavigation ---------- */

.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: var(--cream-2);
  border-top: 3px solid var(--cream-3);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1 1 0;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 4px;
}
.tab .ticon { width: 27px; height: 27px; opacity: .6; }
.tab.is-active { color: var(--green-dark); background: var(--cream); }
.tab.is-active .ticon { opacity: 1; }
.tab:focus-visible { outline: 3px solid var(--terracotta); outline-offset: -3px; }

/* ---------- Overlays ---------- */

.overlay {
  position: absolute; inset: 0;
  background: rgba(45,34,25,.55);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 20;
  animation: fade .2s ease both;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.card {
  width: 100%;
  max-width: 340px;
  background: var(--cream);
  border-radius: var(--r-l);
  padding: 20px 20px 18px;
  text-align: center;
  box-shadow: var(--shadow-l);
  animation: rise .28s cubic-bezier(.2,1.3,.4,1) both;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
@keyframes rise { from { transform: translateY(26px) scale(.94); opacity: 0; } }
.card h2 { margin: 0; font-size: 23px; }
.card__text { margin: 0; color: var(--ink-soft); font-size: 15px; }
.card__crest { width: 58px; height: 58px; margin: 0 auto; }
.card__reward {
  margin: 0; font-size: 21px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.card__coin { width: 24px; height: 24px; flex: 0 0 auto; }
.card__breakdown {
  list-style: none;
  margin: 0 0 4px;
  padding: 10px 12px;
  background: var(--cream-2);
  border-radius: var(--r-s);
  font-size: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card__breakdown li { display: flex; justify-content: space-between; gap: 10px; }
.card__breakdown li span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 18px;
  border: 2px solid var(--cream-3);
  border-radius: var(--r-s);
  background: var(--white);
  color: var(--ink);
}
.input:focus { outline: 3px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

/* Kleine Geräte (iPhone SE & Co.): Leisten kompakter, damit auch das
   größte Level mit 10 Körben ohne Scrollen auf den Schirm passt.
   Touch-Ziele bleiben dabei über 48px. */
@media (max-height: 720px) {
  .topbar { padding: 8px 14px; }
  .puzzlebar { padding: 7px 12px; }
  .puzzlebar__info strong { font-size: 16px; }
  .puzzlebar__info span   { font-size: 13px; }

  .toolbar { padding: 7px 12px 9px; }
  .btn--tool { min-height: 52px; font-size: 13px; }
  .btn--tool small { display: none; }
  .btn--tool .ticon { width: 19px; height: 19px; }

  .tubes { gap: 14px 8px; padding: 8px 10px; }
  .tab { min-height: 52px; }
  .tab .ticon { width: 23px; height: 23px; }
}

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