/* ============================================================
   Tiny Tales — Wald-Versteck-Spiel
   Warmes Wald-Design passend zur Hauptseite:
   Salbei-/Waldgrün + Rinden-/Erdbraun, cremiges Off-White,
   Koralle als Akzent. Nur System-Fonts (keine externen Fonts).
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Hintergrund (von der Hauptseite) */
  --color-bg:           #FBF8F4;
  --color-bg-elevated:  #FFFFFF;
  --color-bg-soft:      #F1ECE3;

  /* Grün (von der Hauptseite) */
  --color-forest-50:    #EEF3EC;
  --color-forest-100:   #D6E2D5;
  --color-forest-200:   #ADC7AB;
  --color-forest-400:   #6B9968;
  --color-forest-500:   #4F8050;
  --color-forest-600:   #3E6840;
  --color-forest-700:   #2F5033;
  --color-forest-900:   #1B3020;

  /* Braun — Rinde, Erde, Holz */
  --color-bark-100:     #EADBC8;
  --color-bark-300:     #C49A6C;
  --color-bark-500:     #8B5E3C;
  --color-bark-600:     #6F4A2E;
  --color-bark-700:     #553821;
  --color-bark-900:     #33210F;

  /* Akzent */
  --color-coral-100:    #FCE3D6;
  --color-coral-500:    #E89578;
  --color-coral-600:    #D77A5C;
  --color-gold:         #F2C14E;

  --color-text:         #1F2A23;
  --color-text-soft:    #5A6258;
  --color-text-muted:   #8A8F86;
  --color-border:       #E5E0D6;
  --color-error:        #B3412A;

  /* Typografie — System-Fonts. Wenn Fraunces/Inter lokal installiert
     sind, werden sie genutzt, sonst Georgia bzw. System-UI. */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;

  --shadow-sm: 0 2px 8px rgba(31, 42, 35, 0.08);
  --shadow:    0 6px 24px rgba(31, 42, 35, 0.12);
  --shadow-md: 0 12px 36px rgba(31, 42, 35, 0.22);

  /* Größe der Helden-Gucklöcher — wird von game.js gelesen */
  --actor-size: clamp(84px, 24vw, 150px);
  --bonus-size: clamp(64px, 17vw, 110px);
}

/* ---------- Reset & Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bark-900);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

img { display: block; max-width: 100%; }

[hidden] { display: none !important; }

a { color: var(--color-forest-600); }
a:hover { color: var(--color-forest-700); }

:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -100px;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--color-forest-700);
  color: #fff;
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .6rem 1.2rem;
  font: 600 1rem/1.2 var(--font-body);
  color: var(--color-forest-700);
  text-decoration: none;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .12s ease, background-color .2s ease, box-shadow .2s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary {
  color: #fff;
  background: var(--color-forest-500);
  box-shadow: 0 4px 0 var(--color-forest-700);
}
.btn--primary:hover { background: var(--color-forest-600); color: #fff; }
.btn--primary:active { box-shadow: 0 1px 0 var(--color-forest-700); transform: translateY(3px); }

.btn--big { min-height: 54px; padding: .8rem 2rem; font-size: 1.15rem; }

.btn--ghost {
  border-color: var(--color-forest-200);
  background: var(--color-bg-elevated);
}
.btn--ghost:hover { background: var(--color-forest-50); }

.btn--icon {
  width: 44px; padding: 0;
  font-size: 1.3rem;
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .25);
}

/* ---------- Header ---------- */
.game-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem clamp(.75rem, 3vw, 1.5rem);
  padding-top: max(.5rem, env(safe-area-inset-top));
  color: var(--color-bark-100);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, var(--color-bark-600), var(--color-bark-700));
  border-bottom: 4px solid var(--color-forest-600);
  box-shadow: var(--shadow-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: #fff;
  text-decoration: none;
}
.logo:hover { color: var(--color-bark-100); }
.logo__tree { font-size: 1.5rem; }
.logo__text {
  font: 700 clamp(1.05rem, 3.5vw, 1.4rem)/1 var(--font-display);
  letter-spacing: .01em;
  white-space: nowrap;
}

.hud {
  display: flex;
  align-items: center;
  gap: clamp(.6rem, 3vw, 1.6rem);
  margin: 0;
}
.hud__item { text-align: center; }
.hud dt {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-bark-300);
}
.hud dd {
  margin: 0;
  font: 700 clamp(1.1rem, 4vw, 1.5rem)/1.1 var(--font-display);
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.hud__score.is-bump { animation: bump .25s ease; }
.hud__item--streak dd { color: var(--color-gold); }

.lives { display: inline-flex; gap: .25rem; vertical-align: middle; }
.life {
  width: 1.05rem; height: 1.05rem;
  background: var(--color-coral-500);
  /* kleines Herz per clip-path */
  clip-path: path('M8.4 15.2 1.6 8.6A4.2 4.2 0 0 1 8.4 3.4a4.2 4.2 0 0 1 6.8 5.2Z');
  transform: scale(1.05);
  transition: background-color .3s ease, transform .3s ease;
}
.life.is-lost {
  background: rgba(255, 255, 255, .2);
  transform: scale(.85);
}
.lives.is-shake { animation: shake .4s ease; }

/* ---------- Spielfeld ---------- */
main {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

.field {
  position: relative;
  flex: 1;
  min-height: 340px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  /* Echter Tiny-Tales-Wald als Hintergrund (statt CSS-Gradients) */
  background:
    /* Subtle Vignette damit Charaktere besser lesbar sind */
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 40%, rgba(20, 35, 15, .35) 100%),
    var(--wald-bg, url('assets/wald-hintergrund.jpg')) center 30% / cover no-repeat;
  background-color: #2F5033; /* Fallback falls Bild nicht lädt */
}
.field:focus { outline: none; }

/* Dekorativer Wald-Layer (Licht-Schatten-Effekte über dem Bild) */
.forest { position: absolute; inset: 0; pointer-events: none; }

.forest__light {
  position: absolute; inset: 0;
  background:
    linear-gradient(115deg, transparent 30%, rgba(255, 244, 200, .10) 40%, transparent 50%),
    linear-gradient(110deg, transparent 55%, rgba(255, 244, 200, .06) 62%, transparent 70%);
  animation: sway-light 9s ease-in-out infinite alternate;
}

/* CSS-Bäume entfernt — der echte Tiny Tales Wald ist jetzt im Hintergrund-Bild.
   Pseudo-Baumstämme, Büsche und Boden werden nicht mehr gebraucht.
   Dekoration kommt komplett aus dem Bild: assets/wald-hintergrund.jpg */

.actors { position: absolute; inset: 0; }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* ---------- Held (Guckloch) ---------- */
.hero {
  position: absolute;
  left: 0; top: 0;
  width: var(--actor-size);
  height: var(--actor-size);
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  /* Position via --x/--y aus game.js */
  transform: translate(var(--x), var(--y));
  z-index: 2;
}

.hero__inner {
  position: absolute; inset: 0;
  border-radius: 50%;
  animation: hero-in .35s cubic-bezier(.34, 1.56, .64, 1) both;
}

/* Zeit-Ring: läuft ab, gesteuert über --t (0..1) */
.hero__ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--color-gold)) calc((1 - var(--t, 0)) * 1turn), rgba(0,0,0,.25) 0);
}
.hero.is-late .hero__ring { --ring-color: var(--color-coral-500); }

.hero__frame {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: 50%;
  border: 5px solid var(--color-bark-500);
  box-shadow:
    inset 0 0 0 2px var(--color-bark-700),
    inset 0 6px 16px rgba(0,0,0,.35),
    var(--shadow);
  background: var(--color-bark-700);
}
/* Alle Posen liegen übereinander; nur die aktive ist sichtbar.
   Bewusst opacity .001 statt 0 / display:none: Browser zeichnen (und dekodieren)
   die Bilder dann weiter → beim Posenwechsel blitzt kein leeres Guckloch auf. */
.hero__frame img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: .001;
  pointer-events: none;
  -webkit-user-drag: none;
}
.hero__frame img.is-active { opacity: 1; }

.hero.is-late .hero__inner { animation: wobble .5s ease-in-out infinite; }

.hero.is-hit { pointer-events: none; }
.hero.is-hit .hero__inner { animation: hero-hit .35s ease-out forwards; }
.hero.is-gone { pointer-events: none; }
.hero.is-gone .hero__inner { animation: hero-out .3s ease-in forwards; }

/* ---------- Bonus-Items ---------- */
.bonus {
  position: absolute;
  left: 0; top: 0;
  width: var(--bonus-size);
  height: var(--bonus-size);
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  transform: translate(var(--x), var(--y));
  z-index: 3;
}
.bonus__inner {
  position: absolute; inset: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px var(--color-gold), var(--shadow);
  animation: bonus-in .25s ease-out both;
}
.bonus__inner img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
/* Zwei-Frame-Animation: Frame B liegt über Frame A und wird
   per steps()-Keyframe im Takt ein- und ausgeblendet. */
.bonus__frame-b { animation: frame-swap var(--frame-ms, 300ms) steps(1, end) infinite; }

.bonus--raupe         { --frame-ms: 500ms; }
.bonus--vogel         { --frame-ms: 160ms; }
.bonus--gluehwuermchen { --frame-ms: 260ms; }
.bonus--gluehwuermchen .bonus__inner {
  box-shadow: 0 0 0 3px var(--color-gold), 0 0 28px 10px rgba(255, 225, 120, .75);
  animation: bonus-in .25s ease-out both, glow 520ms ease-in-out infinite alternate;
}
/* Raupe + Vogel schauen im Bild nach links → bei Bewegung nach rechts spiegeln */
.bonus.is-flip .bonus__inner img { transform: scaleX(-1); }

.bonus__tag {
  position: absolute;
  right: -6px; top: -6px;
  padding: .1rem .4rem;
  font: 800 .8rem/1.2 var(--font-body);
  color: var(--color-bark-900);
  background: var(--color-gold);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.bonus.is-hit { pointer-events: none; }
.bonus.is-hit .bonus__inner { animation: hero-hit .35s ease-out forwards; }
.bonus.is-gone { pointer-events: none; opacity: 0; transition: opacity .2s ease; }

/* Inaktive Sprites bleiben im DOM, damit ihre Bilder dekodiert bleiben.
   Animationen ruhen und starten beim nächsten Erscheinen neu. */
.hero.is-idle,
.bonus.is-idle,
.pilz.is-idle {
  opacity: .001; /* nicht 0 — siehe .hero__frame img */
  pointer-events: none;
  transition: none;
}
.is-idle .hero__inner,
.is-idle .pilz__inner,
.is-idle .bonus__inner,
.is-idle .bonus__frame-b { animation: none; }

/* Pausiert: alle Animationen im Feld anhalten */
.field.is-paused .actors *,
.field.is-paused .fx * { animation-play-state: paused !important; }

/* ---------- Effekte ---------- */
.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 800 clamp(1.2rem, 5vw, 1.8rem)/1 var(--font-display);
  color: #fff;
  text-shadow: 0 2px 0 var(--color-bark-700), 0 0 12px rgba(0,0,0,.35);
  white-space: nowrap;
  animation: float-up .9s ease-out forwards;
}
.popup--bonus { color: var(--color-gold); }
.popup--miss  { color: var(--color-coral-100); }
.popup--combo {
  left: 50% !important;
  top: 22% !important;
  font-size: clamp(1.8rem, 8vw, 3rem);
  color: var(--color-gold);
  animation: combo 1.3s ease-out forwards;
}

.leaf {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 0 70% 0 70%;
  background: var(--color-forest-200);
  animation: leaf-burst .6s ease-out forwards;
}

/* ---------- Overlays (Start / Pause) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(27, 48, 32, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }

.overlay__card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
  background: var(--color-bg);
  border: 4px solid var(--color-bark-300);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.overlay__title {
  margin: 0 0 .5rem;
  font: 700 clamp(1.8rem, 7vw, 2.4rem)/1.1 var(--font-display);
  color: var(--color-forest-700);
}
.overlay__text { margin: 0 0 1rem; color: var(--color-text-soft); }
.overlay__rules {
  margin: 0 0 1.25rem;
  padding: .75rem 1rem;
  list-style: none;
  font-size: .95rem;
  text-align: left;
  background: var(--color-forest-50);
  border-radius: var(--radius);
}
.overlay__rules li + li { margin-top: .3rem; }
.overlay__player { margin: 0 0 1rem; font-weight: 600; color: var(--color-bark-600); }

.mode-badge {
  display: inline-block;
  margin: 1rem 0 0;
  padding: .25rem .75rem;
  font-size: .8rem;
  color: var(--color-bark-600);
  background: var(--color-bark-100);
  border-radius: 999px;
}

/* ---------- Footer ---------- */
.game-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .5rem clamp(.75rem, 3vw, 1.5rem);
  padding-bottom: max(.5rem, env(safe-area-inset-bottom));
  font-size: .9rem;
  color: var(--color-bark-100);
  background: var(--color-bark-900);
}
.game-footer__player { margin: 0; font-weight: 600; }
.game-footer__actions { display: flex; gap: .5rem; }
.game-footer .btn--ghost {
  color: var(--color-bark-100);
  background: transparent;
  border-color: var(--color-bark-500);
  min-height: 44px;
}
.game-footer .btn--ghost:hover:not(:disabled) { background: var(--color-bark-700); }
.game-footer__legal { display: flex; gap: 1rem; width: 100%; justify-content: center; font-size: .8rem; }
.game-footer__legal a { color: var(--color-bark-300); }

/* ---------- Wald-Auswahl (forest picker) ---------- */
.forest-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin: 1rem 0;
}

.forest-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 3px solid transparent;
  border-radius: var(--radius);
  background: var(--color-bg-elevated);
  cursor: pointer;
  overflow: hidden;
  transition: transform .12s ease, border-color .2s ease, box-shadow .2s ease;
  touch-action: manipulation;
}

.forest-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.forest-card:active { transform: translateY(0); }

.forest-card.is-active {
  border-color: var(--color-coral-500);
  box-shadow: 0 0 0 3px rgba(217, 92, 76, .25), var(--shadow);
}

.forest-card__img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
}

.forest-card__body {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.forest-card__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
}

.forest-card__desc {
  font-size: 0.78rem;
  color: var(--color-text-soft);
  line-height: 1.3;
}

@media (max-width: 480px) {
  .forest-picker { grid-template-columns: 1fr; }
}

/* ---------- Modals ---------- */

.modal {
  width: min(520px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  color: var(--color-text);
  background: var(--color-bg);
  border: 4px solid var(--color-bark-300);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.modal::backdrop {
  background: rgba(27, 48, 32, .7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal[open] { animation: modal-in .3s cubic-bezier(.34, 1.4, .64, 1); }

.modal__body { padding: clamp(1.25rem, 5vw, 2rem); }
.modal__title {
  margin: 0 0 .25rem;
  font: 700 clamp(1.6rem, 6vw, 2.1rem)/1.15 var(--font-display);
  color: var(--color-forest-700);
}
.modal__lead { margin: 0 0 1.25rem; color: var(--color-text-soft); }
.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
  margin-top: 1.25rem;
}

/* Formular */
.field-group { margin-bottom: .9rem; }
.field-group label { display: block; margin-bottom: .3rem; font-weight: 600; }

/* Vor-/Nachname nebeneinander */
.field-group--name {
  display: inline-block;
  width: calc(50% - .35rem);
  vertical-align: top;
  margin-right: .7rem;
}
.field-group--name:last-of-type {
  margin-right: 0;
}
@media (max-width: 380px) {
  .field-group--name {
    display: block;
    width: 100%;
    margin-right: 0;
  }
}
.field-group input {
  width: 100%;
  min-height: 48px;
  padding: .6rem .9rem;
  font: inherit;
  font-size: 1rem; /* ≥16px verhindert Zoom auf iOS */
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color .2s ease;
}
.field-group input:focus { border-color: var(--color-forest-400); outline: none; box-shadow: 0 0 0 3px var(--color-forest-100); }
.field-group input[aria-invalid="true"] { border-color: var(--color-error); }
.field-group--short input { max-width: 8rem; }

.hint { margin: .2rem 0 0; font-size: .85rem; font-weight: 400; color: var(--color-text-muted); }
.required { font-size: .85rem; color: var(--color-coral-600); }
.field-error { margin: .25rem 0 0; min-height: 0; font-size: .875rem; font-weight: 600; color: var(--color-error); }
.field-error:empty { display: none; }

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .6rem;
  align-items: start;
  margin: .75rem 0 0;
  font-size: .95rem;
}
.check input {
  width: 22px; height: 22px;
  margin: .1rem 0 0;
  accent-color: var(--color-forest-500);
}

.gdpr {
  margin-top: 1rem;
  padding: .8rem 1rem;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--color-text-soft);
  background: var(--color-bg-soft);
  border-left: 4px solid var(--color-bark-300);
  border-radius: var(--radius-sm);
}
.gdpr p { margin: 0; }
.gdpr p + p { margin-top: .5rem; }
.gdpr p:empty { display: none; }

.form-status { margin: 1rem 0 0; font-weight: 600; color: var(--color-forest-600); }
.form-status:empty { display: none; }
.form-status.is-error { color: var(--color-error); }

/* ---------- Anmelden vs. Registrieren ---------- */
.modal__switch { margin: -.25rem 0 1rem; }
.btn-link {
  padding: .25rem 0;
  font: inherit;
  font-weight: 600;
  color: var(--color-forest-600);
  text-decoration: underline;
  text-underline-offset: .2em;
  background: none;
  border: 0;
  cursor: pointer;
}
.btn-link:hover { color: var(--color-forest-700); }
.btn-link:focus-visible { outline: 3px solid var(--color-forest-600); outline-offset: 2px; border-radius: 4px; }
#register-form [data-login-only] { display: none; }
#register-form.is-login [data-login-only] { display: revert; }
#register-form.is-login [data-register-only] { display: none; }
.device-hint { margin: 1rem 0 0; }

/* Game Over */
.modal--gameover .modal__body { text-align: center; }
.final-score { margin: .5rem 0 0; }
.final-score__label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.final-score__value {
  display: block;
  font: 800 clamp(3rem, 14vw, 4.5rem)/1 var(--font-display);
  color: var(--color-bark-600);
  font-variant-numeric: tabular-nums;
}
.final-rank { margin: .5rem 0 0; font-weight: 600; color: var(--color-forest-600); }
.final-rank:empty, .final-note:empty { display: none; }
.final-note { margin: .25rem 0 0; font-size: .9rem; color: var(--color-text-soft); }

.scoreboard {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--color-forest-50);
  border-radius: var(--radius);
}
.scoreboard h3 {
  margin: 0 0 .5rem;
  font: 700 1.2rem/1.2 var(--font-display);
  color: var(--color-forest-700);
}
.scoreboard__mode { font: 500 .75rem var(--font-body); color: var(--color-text-muted); }
.scoreboard__tabs { display: flex; gap: .5rem; margin: 0 0 .75rem; }
.scoreboard__tabs[hidden] { display: none; }
.scoreboard__tabs button {
  flex: 1;
  min-height: 44px; /* Touch-Target */
  padding: .5rem;
  border: 1px solid var(--color-forest-200);
  border-radius: var(--radius-sm);
  background: var(--color-bg-elevated);
  color: var(--color-forest-700);
  font: 600 .9rem var(--font-body);
  cursor: pointer;
}
.scoreboard__tabs button:hover { background: var(--color-forest-100); }
.scoreboard__tabs button[aria-selected="true"] {
  background: var(--color-forest-500);
  border-color: var(--color-forest-500);
  color: #fff;
}
.scoreboard__myrank { margin: 0 0 .5rem; font-weight: 600; font-size: .9rem; color: var(--color-forest-600); }
.scoreboard__myrank:empty { display: none; }
.scoreboard__table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.scoreboard__table th {
  padding: .3rem .4rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-forest-100);
}
.scoreboard__table td { padding: .4rem; border-bottom: 1px solid var(--color-forest-100); }
.scoreboard__table th:nth-child(2), .scoreboard__table td:nth-child(2) { text-align: left; }
.scoreboard__table td:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.scoreboard__table tr:nth-child(1) td:first-child::before { content: '🥇 '; }
.scoreboard__table tr:nth-child(2) td:first-child::before { content: '🥈 '; }
.scoreboard__table tr:nth-child(3) td:first-child::before { content: '🥉 '; }
.scoreboard__table tr.is-me td { background: var(--color-coral-100); }
.scoreboard__table tr.is-me td:first-child { border-radius: 8px 0 0 8px; }
.scoreboard__table tr.is-me td:last-child { border-radius: 0 8px 8px 0; }

/* ---------- Keyframes ---------- */
@keyframes hero-in {
  from { transform: translateY(35%) scale(.2); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes hero-out {
  to { transform: translateY(25%) scale(.1); opacity: 0; }
}
@keyframes hero-hit {
  40%  { transform: scale(1.18); }
  100% { transform: scale(.6); opacity: 0; }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(4deg); }
}
@keyframes bonus-in {
  from { transform: scale(.3); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes frame-swap {
  0%   { opacity: .001; }
  50%  { opacity: 1; }
}
@keyframes glow {
  from { filter: brightness(.9); }
  to   { filter: brightness(1.25); }
}
@keyframes float-up {
  0%   { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  20%  { transform: translate(-50%, -80%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}
@keyframes combo {
  0%   { transform: translate(-50%, -50%) scale(.3) rotate(-8deg); opacity: 0; }
  25%  { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  75%  { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(.9); opacity: 0; }
}
@keyframes leaf-burst {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) rotate(220deg); opacity: 0; }
}
@keyframes bump {
  50% { transform: scale(1.25); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
@keyframes sway-light {
  from { transform: translateX(-3%); }
  to   { transform: translateX(3%); }
}
@keyframes modal-in {
  from { transform: translateY(20px) scale(.95); opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .logo__text { display: none; }
  .hud dt { font-size: .62rem; }
  .game-footer { font-size: .82rem; }
  .game-footer__player { width: 100%; text-align: center; }
  .game-footer__actions { width: 100%; justify-content: center; }
}

/* Handy quer: wenig Höhe → kleinere Gucklöcher */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --actor-size: clamp(70px, 22vh, 110px);
    --bonus-size: clamp(56px, 17vh, 90px);
  }
  .game-header { padding-block: .25rem; }
  .game-footer__legal { display: none; }
  .field { min-height: 220px; }
}

@media (min-width: 1100px) {
  :root { --actor-size: 160px; --bonus-size: 116px; }
}

/* Bewegungsreduktion: dekorative Animationen aus, Spiel bleibt spielbar */
@media (prefers-reduced-motion: reduce) {
  .forest__light,
  .hero.is-late .hero__inner,
  .pilz.is-late .pilz__inner,
  .modal[open],
  .hud__score.is-bump,
  .lives.is-shake { animation: none !important; }
  .leaf { display: none; }
}


/* ---------- Schwierigkeits-Auswahl ---------- */
.diff-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 0.7rem 0 1.2rem;
}
@media (max-width: 600px) {
  .diff-cards { grid-template-columns: 1fr; }
}
.diff-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.9rem 0.95rem;
  border: 3px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: transform .12s ease, border-color .18s ease, background .18s ease;
}
.diff-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.85);
}
.diff-card.is-active {
  border-color: #4F8050;
  background: rgba(255, 255, 255, 0.95);
}
.diff-card__icon { font-size: 1.7rem; }
.diff-card__name { font-weight: 700; font-size: 1.05rem; color: #2a1d12; }
.diff-card__desc { font-size: 0.85rem; color: #6B4F3A; line-height: 1.35; }

/* ---------- Scoreboard im Start-Overlay ---------- */
.start-stats {
  display: flex;
  gap: 0.7rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}
.start-stat {
  flex: 1 1 140px;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.3);
  text-align: center;
}
.start-stat__num {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2a1d12;
}
.start-stat__label {
  font-size: 0.78rem;
  color: #6B4F3A;
  margin-top: 0.1rem;
}

/* ---------- Fliegenpilz: gleiches Abzeichen wie die Helden (PROTOTYP) ---------- */
.pilz {
  position: absolute;
  left: 0; top: 0;
  width: var(--actor-size);
  height: var(--actor-size);
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  transform: translate(var(--x), var(--y));
  z-index: 2;
}
.pilz__inner {
  position: absolute; inset: 0;
  border-radius: 50%;
  animation: hero-in .35s cubic-bezier(.34, 1.56, .64, 1) both;
}
.pilz__ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--color-gold)) calc((1 - var(--t, 0)) * 1turn), rgba(0,0,0,.25) 0);
}
.pilz.is-late .pilz__ring { --ring-color: var(--color-coral-500); }
.pilz__frame {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: 50%;
  border: 5px solid var(--color-bark-500);
  box-shadow:
    inset 0 0 0 2px var(--color-bark-700),
    inset 0 6px 16px rgba(0,0,0,.35),
    var(--shadow);
  background: var(--color-bark-700);
}
.pilz__frame img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.pilz.is-late .pilz__inner { animation: wobble .5s ease-in-out infinite; }
.pilz.is-hit { pointer-events: none; }
.pilz.is-hit .pilz__inner { animation: hero-hit .35s ease-out forwards; }
.pilz.is-gone { pointer-events: none; }
.pilz.is-gone .pilz__inner { animation: hero-out .3s ease-in forwards; }

/* ---------- Warnhinweis Fliegenpilz (PROTOTYP) ---------- */
.modal--pilz .modal__body { text-align: center; }
.modal--pilz .modal__title { color: #C0392B; font-size: clamp(1.6rem, 6vw, 2.2rem); margin-bottom: .75rem; }
.pilz-warnung__zeichen { margin: 0; font-size: 2.2rem; line-height: 1; animation: pilz-blink 1.2s ease-in-out infinite; }
.pilz-warnung__bild {
  width: min(62vw, 260px); aspect-ratio: 1;
  margin: 0 auto 1rem;
  border-radius: 50%;
  overflow: hidden;
  border: 7px solid #D9493A;
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px #D9493A, 0 10px 24px rgba(0,0,0,.35);
}
.pilz-warnung__bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pilz-warnung__text { font-size: 1.1rem; line-height: 1.45; margin: 0 0 .5rem; }
.pilz-warnung__klein { font-size: .9rem; color: var(--color-text-soft); margin: 0 0 1rem; }
.modal--pilz .modal__actions { justify-content: center; }
@keyframes pilz-blink { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .pilz-warnung__zeichen { animation: none; } }


/* Rückweg zu den anderen Seiten */
.seitenweg { display:flex; flex-wrap:wrap; gap:6px 14px; justify-content:center; font-size:.95rem; padding:6px 8px 0; position:relative; z-index:5; }
.seitenweg a { color:#3E6840; text-decoration:underline; text-underline-offset:3px; padding:6px 2px; }
.seitenweg a[aria-current] { color:#1B3020; font-weight:700; text-decoration:none; }

/* Ausgang: Knöpfe im Endfenster bleiben immer sichtbar, der Weg zur Startseite ist gut zu erkennen */
.modal--gameover .modal__actions { position: sticky; bottom: 0; background: var(--color-bg); padding: .75rem 0 .25rem; margin-top: 1rem; box-shadow: 0 -8px 8px -6px rgba(0,0,0,.12); }
.modal--gameover .modal__actions .btn { flex: 1 1 200px; min-height: 50px; text-align: center; justify-content: center; text-decoration: none; }
#btn-home { border: 3px solid var(--color-forest-600); font-weight: 700; color: var(--color-forest-700); }
.start-home { margin: .9rem 0 0; font-size: 1rem; }
.start-home a { color: var(--color-forest-700, #3E6840); text-decoration: underline; text-underline-offset: 3px; padding: 8px 4px; display: inline-block; }
