/* ==========================================================================
   Die Zeidler – Spielewelt · gemeinsames Designsystem
   Alle Klassen tragen das Präfix "zg-", alle Variablen "--zg-".
   Farben abgeleitet aus Logo (#D7B56D) und Workbook-Vorlagen (#1D411E).
   ========================================================================== */

@font-face { font-family: "ZG Fredoka"; src: url("../assets/fonts/fredoka-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "ZG Fredoka"; src: url("../assets/fonts/fredoka-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "ZG Baloo"; src: url("../assets/fonts/baloo-2-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "ZG Baloo"; src: url("../assets/fonts/baloo-2-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* Markenfarben */
  --zg-green-900: #1D411E;   /* Zeidler-Waldgrün (Vorlage) */
  --zg-green-800: #24502A;
  --zg-green-700: #2F6233;
  --zg-green-500: #6E9A45;   /* Wiese */
  --zg-green-300: #A9C97A;
  --zg-green-100: #E4EFD2;
  --zg-gold-500: #D7B56D;    /* Zeidler-Gold (Logo) */
  --zg-gold-400: #E3C88C;
  --zg-gold-200: #F2E3BF;
  --zg-gold-700: #8A6A28;    /* Gold für Text auf Hell (AA-Kontrast) */
  --zg-honey-500: #E9A630;
  --zg-honey-300: #F6CF6B;
  --zg-cream-50: #FFFCF4;
  --zg-cream-100: #FBF5E6;
  --zg-cream-200: #F3E8CF;
  --zg-bark-700: #6E3B28;    /* Baumrinde (Vorlage) */
  --zg-bark-500: #8E5A3C;
  --zg-sky-200: #D6EAF3;
  --zg-ink: #1E2A1B;
  --zg-ink-soft: #46523F;
  --zg-rose: #E88A8A;

  /* Zustände */
  --zg-success: #2F7A3A;
  --zg-success-bg: #E2F2DA;
  --zg-hint: #8A5A12;
  --zg-hint-bg: #FCEFD2;

  /* Typografie */
  --zg-font-display: "ZG Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --zg-font-body: "ZG Baloo", "Segoe UI", system-ui, sans-serif;
  --zg-fs-xs: 0.875rem;   /* 14px */
  --zg-fs-sm: 1rem;       /* 16px */
  --zg-fs-md: 1.125rem;   /* 18px */
  --zg-fs-lg: 1.375rem;   /* 22px */
  --zg-fs-xl: clamp(1.6rem, 6vw, 2.25rem);
  --zg-fs-xxl: clamp(1.9rem, 8vw, 3rem);

  /* Abstände (4er-Raster) */
  --zg-s1: 4px; --zg-s2: 8px; --zg-s3: 12px; --zg-s4: 16px; --zg-s5: 24px; --zg-s6: 32px; --zg-s7: 48px;

  /* Formen */
  --zg-radius-sm: 12px;
  --zg-radius-md: 18px;
  --zg-radius-lg: 28px;
  --zg-radius-pill: 999px;
  --zg-shadow-card: 0 2px 0 rgba(29, 65, 30, .08), 0 10px 28px -12px rgba(29, 65, 30, .35);
  --zg-shadow-press: 0 4px 0 #0E2711;
  --zg-touch: 48px;       /* Mindestgröße Touch-Fläche */

  /* Bewegung */
  --zg-ease: cubic-bezier(.2, .8, .2, 1);
  --zg-ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --zg-dur: 220ms;
}

/* ---------- Basis ---------- */
.zg-body, .zg-body * { box-sizing: border-box; }
.zg-body {
  margin: 0;
  font-family: var(--zg-font-body);
  font-size: var(--zg-fs-md);
  line-height: 1.45;
  color: var(--zg-ink);
  background: var(--zg-cream-100);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
.zg-body.zg-game-page { height: 100%; overflow: hidden; overscroll-behavior: none; }
html:has(.zg-game-page) { height: 100%; }
.zg-body h1, .zg-body h2, .zg-body h3 { font-family: var(--zg-font-display); font-weight: 600; line-height: 1.15; margin: 0; }
.zg-body p { margin: 0; }
.zg-body button { font: inherit; color: inherit; }
.zg-body img { max-width: 100%; }
.zg-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.zg-body :focus-visible { outline: 3px solid var(--zg-honey-500); outline-offset: 3px; border-radius: 10px; }

/* ---------- App-Rahmen für Spielseiten ---------- */
.zg-app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--zg-cream-100);
  isolation: isolate;
}
.zg-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}
.zg-screen[hidden] { display: none; }

/* ---------- Kopfband (wie Workbook: Waldgrün mit geschwungener Kante) ---------- */
.zg-band {
  position: relative;
  background: var(--zg-green-900);
  color: var(--zg-cream-50);
  padding: calc(var(--zg-s5) + env(safe-area-inset-top)) var(--zg-s5) var(--zg-s7);
  text-align: center;
}
.zg-band::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 34px;
  background: no-repeat center bottom / 100% 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 34' preserveAspectRatio='none'%3E%3Cpath d='M0 34 L0 4 Q 520 52 1000 14 L1000 34 Z' fill='%23FBF5E6'/%3E%3C/svg%3E");
}
.zg-band__kicker { font-family: var(--zg-font-display); color: var(--zg-gold-500); font-size: var(--zg-fs-md); letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.zg-band__title { font-size: var(--zg-fs-xxl); color: var(--zg-cream-50); margin-top: var(--zg-s1); }
.zg-band__title em { font-style: normal; color: var(--zg-gold-500); }

/* ---------- Startbildschirm ---------- */
.zg-start { align-items: stretch; }
.zg-start__body {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: var(--zg-s4) var(--zg-s5) var(--zg-s6);
  display: flex; flex-direction: column; gap: var(--zg-s5);
}
.zg-start__art {
  margin: calc(-1 * var(--zg-s6)) auto 0; width: min(78%, 300px); aspect-ratio: 4 / 3;
  position: relative; z-index: 1;
  filter: drop-shadow(0 12px 18px rgba(29, 65, 30, .18));
}
.zg-start__art > svg, .zg-end__art > svg, .zg-dialog__art > svg { width: 100%; height: 100%; display: block; }
.zg-start__desc { font-size: var(--zg-fs-md); text-align: center; color: var(--zg-ink-soft); }
.zg-start__label { font-family: var(--zg-font-display); font-weight: 600; font-size: var(--zg-fs-sm); color: var(--zg-green-900); text-align: center; letter-spacing: .04em; }

/* Schwierigkeitswahl */
.zg-diff { margin-top: var(--zg-s2); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--zg-s2); }
.zg-diff__opt {
  appearance: none; border: 2px solid var(--zg-cream-200); background: var(--zg-cream-50);
  border-radius: var(--zg-radius-md); padding: var(--zg-s3) var(--zg-s1) var(--zg-s2);
  min-height: 96px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform var(--zg-dur) var(--zg-ease), border-color var(--zg-dur), background var(--zg-dur), box-shadow var(--zg-dur);
  touch-action: manipulation;
}
.zg-diff__opt:hover { border-color: var(--zg-gold-400); }
.zg-diff__opt[aria-checked="true"] {
  border-color: var(--zg-green-900); background: var(--zg-gold-200);
  box-shadow: 0 0 0 3px rgba(215, 181, 109, .45);
  transform: translateY(-2px);
}
.zg-diff__bees { display: flex; gap: 1px; height: 26px; align-items: center; }
.zg-diff__bees svg { width: 24px; height: 24px; }
.zg-diff__bees .zg-dim { opacity: .22; filter: grayscale(1); }
.zg-diff__name { font-family: var(--zg-font-display); font-weight: 600; font-size: var(--zg-fs-md); color: var(--zg-green-900); }
.zg-diff__note { font-size: 13px; line-height: 1.2; color: var(--zg-ink-soft); text-align: center; padding: 0 2px; }

/* ---------- Buttons ---------- */
.zg-btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--zg-s2);
  min-height: 56px; padding: 0 var(--zg-s6);
  border-radius: var(--zg-radius-pill);
  font-family: var(--zg-font-display) !important; font-weight: 600; font-size: var(--zg-fs-lg); letter-spacing: .02em;
  text-decoration: none; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 120ms var(--zg-ease), box-shadow 120ms var(--zg-ease), background var(--zg-dur);
}
.zg-btn--primary { background: var(--zg-green-900); color: var(--zg-cream-50) !important; box-shadow: var(--zg-shadow-press); }
.zg-btn--primary:hover { background: var(--zg-green-800); }
.zg-btn--primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #0E2711; }
.zg-btn--gold { background: var(--zg-gold-500); color: var(--zg-green-900) !important; box-shadow: 0 4px 0 #A98A45; }
.zg-btn--gold:active { transform: translateY(3px); box-shadow: 0 1px 0 #A98A45; }
.zg-btn--ghost { background: transparent; color: var(--zg-green-900) !important; border: 2px solid var(--zg-green-900); min-height: 52px; font-size: var(--zg-fs-md); }
.zg-btn--ghost:active { transform: translateY(2px); }
.zg-btn--block { width: 100%; }
.zg-btn svg { width: 26px; height: 26px; flex: none; }

.zg-icon-btn {
  appearance: none; border: 0; cursor: pointer; flex: none;
  width: var(--zg-touch); height: var(--zg-touch); border-radius: 50%;
  display: inline-grid; place-items: center;
  background: rgba(255, 252, 244, .94); color: var(--zg-green-900);
  box-shadow: 0 2px 0 rgba(29, 65, 30, .18), 0 4px 12px -4px rgba(29, 65, 30, .3);
  touch-action: manipulation;
  transition: transform 120ms var(--zg-ease);
}
.zg-icon-btn:active { transform: scale(.92); }
.zg-icon-btn svg { width: 24px; height: 24px; }
.zg-icon-btn[aria-pressed="true"] .zg-ico-off, .zg-icon-btn[aria-pressed="false"] .zg-ico-on { display: none; }

/* ---------- HUD (während des Spiels) ---------- */
.zg-play { overflow: hidden; }
.zg-hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--zg-s2);
  padding: calc(var(--zg-s2) + env(safe-area-inset-top)) calc(var(--zg-s2) + env(safe-area-inset-right)) var(--zg-s2) calc(var(--zg-s2) + env(safe-area-inset-left));
  pointer-events: none;
}
.zg-hud > * { pointer-events: auto; }
.zg-hud__progress {
  flex: 1; min-width: 0; min-height: var(--zg-touch);
  display: flex; align-items: center; gap: var(--zg-s2);
  background: rgba(255, 252, 244, .94); border-radius: var(--zg-radius-pill);
  padding: 4px var(--zg-s3) 4px var(--zg-s2);
  box-shadow: 0 2px 0 rgba(29, 65, 30, .18), 0 4px 12px -4px rgba(29, 65, 30, .3);
  font-family: var(--zg-font-display); font-weight: 600; color: var(--zg-green-900); font-size: var(--zg-fs-sm);
}
.zg-hud__progress-icon { width: 34px; height: 34px; flex: none; }
.zg-bar { flex: 1; height: 14px; border-radius: 99px; background: var(--zg-cream-200); overflow: hidden; min-width: 40px; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.zg-bar__fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--zg-honey-300), var(--zg-honey-500)); transition: width 400ms var(--zg-ease); }
.zg-hud__count { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 400px) { .zg-hud__word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .zg-hud__progress { gap: 6px; } }
.zg-hud--solid { background: linear-gradient(var(--zg-hud-bg, var(--zg-cream-100)) 72%, transparent); }

.zg-stage { position: absolute; inset: 0; }

/* ---------- Overlays (Pause / Hilfe) ---------- */
.zg-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: var(--zg-s4);
  background: rgba(20, 42, 21, .55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: zg-fade 200ms var(--zg-ease);
}
.zg-overlay[hidden] { display: none; }
.zg-dialog {
  width: min(100%, 440px); max-height: calc(100% - 16px); overflow: auto;
  background: var(--zg-cream-50); border-radius: var(--zg-radius-lg);
  padding: var(--zg-s5); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column; gap: var(--zg-s4); text-align: center;
  animation: zg-pop 320ms var(--zg-ease-bounce);
}
.zg-dialog h2 { font-size: var(--zg-fs-xl); color: var(--zg-green-900); }
.zg-dialog__art { width: 110px; height: 90px; margin: 0 auto; }
.zg-dialog__actions { display: flex; flex-direction: column; gap: var(--zg-s3); }
.zg-help-list { text-align: left; display: flex; flex-direction: column; gap: var(--zg-s3); margin: 0; padding: 0; list-style: none; }
.zg-help-list li { display: flex; gap: var(--zg-s3); align-items: flex-start; }
.zg-help-list .zg-help-ico { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--zg-gold-200); display: grid; place-items: center; font-family: var(--zg-font-display); font-weight: 600; color: var(--zg-green-900); }

/* ---------- Toast (Wissens-Einblendung) ---------- */
.zg-toast {
  position: absolute; z-index: 30; left: 50%; top: calc(68px + env(safe-area-inset-top));
  transform: translate(-50%, -16px); opacity: 0;
  width: min(calc(100% - 24px), 460px);
  display: flex; gap: var(--zg-s3); align-items: center;
  background: var(--zg-cream-50); border: 2px solid var(--zg-gold-500);
  border-radius: var(--zg-radius-md); padding: var(--zg-s3) var(--zg-s4);
  box-shadow: 0 12px 30px -12px rgba(29, 65, 30, .55);
  font-size: var(--zg-fs-sm); line-height: 1.35; color: var(--zg-ink);
  pointer-events: none;
  transition: transform 350ms var(--zg-ease-bounce), opacity 250ms;
}
.zg-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.zg-toast__ico { width: 44px; height: 40px; flex: none; }
.zg-toast strong { font-family: var(--zg-font-display); color: var(--zg-green-900); font-weight: 600; }

/* ---------- Feedback-Zustände ---------- */
.zg-feedback { border-radius: var(--zg-radius-md); padding: var(--zg-s3) var(--zg-s4); font-size: var(--zg-fs-sm); line-height: 1.35; display: flex; gap: var(--zg-s3); align-items: center; text-align: left; }
.zg-feedback--success { background: var(--zg-success-bg); color: #1F5326; border: 2px solid #9CCB8C; }
.zg-feedback--hint { background: var(--zg-hint-bg); color: #6B430A; border: 2px solid #EBC57A; }
.zg-feedback__ico { flex: none; width: 34px; height: 34px; }

/* ---------- Endbildschirm ---------- */
.zg-end__body { width: 100%; max-width: 520px; margin: 0 auto; padding: 0 var(--zg-s5) var(--zg-s6); display: flex; flex-direction: column; gap: var(--zg-s4); align-items: stretch; text-align: center; }
.zg-end__art { width: 180px; height: 150px; margin: calc(-1 * var(--zg-s6)) auto 0; position: relative; z-index: 1; }
.zg-end__stats { display: flex; justify-content: center; gap: var(--zg-s3); flex-wrap: wrap; }
.zg-stat { background: var(--zg-cream-50); border-radius: var(--zg-radius-md); padding: var(--zg-s3) var(--zg-s4); min-width: 110px; box-shadow: var(--zg-shadow-card); }
.zg-stat__value { font-family: var(--zg-font-display); font-weight: 600; font-size: 1.75rem; color: var(--zg-green-900); line-height: 1.1; }
.zg-stat__label { font-size: var(--zg-fs-xs); color: var(--zg-ink-soft); }
.zg-fact { background: var(--zg-green-900); color: var(--zg-cream-50); border-radius: var(--zg-radius-lg); padding: var(--zg-s4) var(--zg-s5); text-align: left; display: flex; gap: var(--zg-s3); align-items: flex-start; }
.zg-fact__label { font-family: var(--zg-font-display); color: var(--zg-gold-500); font-weight: 600; font-size: var(--zg-fs-sm); letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.zg-fact__ico { flex: none; width: 46px; height: 40px; margin-top: 2px; }
.zg-end__actions { display: flex; flex-direction: column; gap: var(--zg-s3); margin-top: var(--zg-s2); }
.zg-stars { display: flex; justify-content: center; gap: var(--zg-s2); }
.zg-stars svg { width: 40px; height: 40px; }
.zg-stars .zg-star { animation: zg-pop 500ms var(--zg-ease-bounce) both; }
.zg-stars .zg-star:nth-child(2) { animation-delay: 120ms; }
.zg-stars .zg-star:nth-child(3) { animation-delay: 240ms; }

/* Konfetti aus Blütenblättern */
.zg-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.zg-confetti span { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 60% 60% 60% 0; animation: zg-fall linear forwards; opacity: .9; }

/* ---------- Footer-Hinweis in Spielseiten ---------- */
.zg-credit { display: flex; align-items: center; justify-content: center; gap: var(--zg-s2); margin-top: var(--zg-s2); }
.zg-credit img { height: 34px; width: auto; }

/* ---------- Animationen ---------- */
@keyframes zg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes zg-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes zg-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes zg-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes zg-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes zg-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(233, 166, 48, .7); } 50% { box-shadow: 0 0 0 10px rgba(233, 166, 48, 0); } }
@keyframes zg-fall { to { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(540deg); } }
@keyframes zg-wing { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
.zg-float { animation: zg-float 3s ease-in-out infinite; }
.zg-shake { animation: zg-shake 420ms var(--zg-ease); }
.zg-bee-wing { transform-box: fill-box; transform-origin: 50% 100%; animation: zg-wing 140ms linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .zg-body *, .zg-body *::before, .zg-body *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .zg-bee-wing { animation: none !important; }
  .zg-confetti { display: none; }
}
.zg-reduced-motion *, .zg-reduced-motion *::before, .zg-reduced-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }

/* ---------- Responsive ---------- */
@media (max-width: 360px) {
  .zg-start__body, .zg-end__body { padding-left: var(--zg-s4); padding-right: var(--zg-s4); }
  .zg-diff__note { display: none; }
  .zg-diff__opt { min-height: 76px; }
  .zg-btn { font-size: var(--zg-fs-md); padding: 0 var(--zg-s5); }
}
@media (min-width: 720px) {
  .zg-end__actions { flex-direction: row; justify-content: center; }
  .zg-end__actions .zg-btn { flex: 1; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .zg-band { padding-bottom: var(--zg-s6); padding-top: calc(var(--zg-s3) + env(safe-area-inset-top)); }
  .zg-start__art { width: 160px; }
}
