
  :root {
    --frog-green: #4caf50;
    --frog-dark: #2e7d32;
    --frog-belly: #a5d6a7;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    cursor: url("/assets/fly-32.775a0247fc510f7d.png") 16 16, url("/assets/fly-64.468e975e568adf5b.png") 32 32, auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;   /* przy przewijaniu srodek nie ucina gory */
    background: linear-gradient(#87ceeb 0%, #b3e5fc 55%, #66bb6a 55%, #43a047 100%);
    font-family: system-ui, sans-serif;
    overflow-x: hidden;
    /* niskie okno: wolisze przewijac niz obciac glos zaby; muchy nie wychodza
       poza scene, wiec w poziomie nic nie ucieka */
    overflow-y: auto;
    padding: 10px 0 18px;
  }

  .stage {
    /* --ox: gdzie stoi żaba, --hop: jak wysoko leci w kolejnym susie.
       Definiowane tutaj, żeby i żaba, i dymka je odziedziczyły. */
    --ox: 0px;
    --hop: 110px;
    position: relative;
    width: 320px;
    height: 260px;
  }

  /* ===== ŻABKA =====
     Pozycja (skok w stronę kursora) idzie przez właściwość `translate`,
     a przysiad i rozciągnięcie (squash & stretch) idą przez `transform` — dzięki temu
     animacja skoku nie nadpisuje przesunięcia. */
  .frog {
    position: absolute;
    bottom: 20px;       /* linia ziemi — odpoczynek zawsze tu, w gore tylko w przelocie */
    left: 50%;
    translate: calc(-50% + var(--ox)) 0;
    transition: translate .45s cubic-bezier(.18, .62, .3, 1);
    width: 200px;
    height: 160px;
    animation: idle 2.4s ease-in-out infinite;
    transform-origin: bottom center;
  }
  .frog.jump { animation: jump 0.45s cubic-bezier(.3, .05, .55, .95); }
  .frog.blink-none { animation: none; }

  @keyframes idle {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(0.96) translateY(2px); }
  }
  /* start i meta są na ziemi (translateY(0)) — w powietrzu żaba tylko przelatuje */
  @keyframes jump {
    0%   { transform: translateY(0) scaleY(1) scaleX(1); }
    18%  { transform: translateY(0) scaleY(0.68) scaleX(1.18); }         /* odpychanie się */
    50%  { transform: translateY(calc(-1 * var(--hop))) scaleY(1.14) scaleX(0.92); }
    82%  { transform: translateY(0) scaleY(0.78) scaleX(1.12); }         /* lądowanie */
    100% { transform: translateY(0) scaleY(1) scaleX(1); }
  }

  .body {
    position: absolute;
    bottom: 0;
    width: 200px;
    height: 120px;
    background: var(--frog-green);
    border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
    box-shadow: inset -12px -10px 0 rgba(0,0,0,0.08);
  }
  .belly {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 70px;
    background: var(--frog-belly);
    border-radius: 50% 50% 45% 45% / 70% 70% 40% 40%;
  }

  /* oczy */
  .eye {
    position: absolute;
    top: -18px;
    width: 58px;
    height: 58px;
    background: var(--frog-green);
    border-radius: 50%;
    box-shadow: inset -6px -6px 0 rgba(0,0,0,0.08);
  }
  .eye.left  { left: 12px; }
  .eye.right { right: 12px; }
  .eye { transition: transform .12s ease-out; transform: translate(var(--ex, 0px), var(--ey, 0px)); }
  .eye .ball {
    position: absolute;
    top: 8px;
    left: 9px;
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    overflow: hidden;
  }
  .pupil {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    background: #1b1b1b;
    border-radius: 50%;
    animation: look 5s ease-in-out infinite;
  }
  /* gdy kursor jest aktywny, patrzeniem steruje JS, nie animacja */
  .frog.tracking .pupil { animation: none; }

  @keyframes look {
    0%, 40%  { transform: translate(0, 0); }
    45%, 55% { transform: translate(9px, -2px); }
    60%, 75% { transform: translate(-9px, 0); }
    80%,100% { transform: translate(0, 0); }
  }
  .lid {
    position: absolute;
    inset: 0;
    background: var(--frog-green);
    border-radius: 50%;
    transform: translateY(-100%);
    animation: blink 4s infinite;
  }
  @keyframes blink {
    0%, 92%, 100% { transform: translateY(-100%); }
    95%, 97%      { transform: translateY(0); }
  }

  /* buzia */
  .mouth {
    position: absolute;
    transform-origin: 50% 0%;   /* otwiera się w dół, jak u żaby */
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 24px;
    border-bottom: 4px solid var(--frog-dark);
    border-radius: 0 0 80px 80px;
  }
  .frog.jump .mouth,
  .frog.chrup .mouth {
    height: 34px;
    width: 60px;
    border: 4px solid var(--frog-dark);
    border-radius: 0 0 60px 60px;
    background: #6d4c41;
  }

  /* jezyk: zakotwiczony w srodku pyska, wysuwa sie w strone muchy
     (skala X = dlugosc, kat ustawia JS) */
  .tongue {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 42px;
    width: var(--dl, 0px);
    height: 11px;
    background: linear-gradient(#ff97a6, #e04a61);
    border-radius: 2px 9px 9px 2px;
    transform-origin: 0 50%;
    transform: rotate(0deg) scaleX(0);
    opacity: 0;
    pointer-events: none;
  }

  /* policzki */
  .cheek {
    position: absolute;
    bottom: 52px;
    width: 26px;
    height: 14px;
    background: rgba(244, 143, 177, 0.55);
    border-radius: 50%;
  }
  .cheek.l { left: 24px; }
  .cheek.r { right: 24px; }

  /* łapki */
  .leg {
    position: absolute;
    bottom: -6px;
    width: 46px;
    height: 26px;
    background: var(--frog-dark);
    border-radius: 50% 50% 40% 40%;
  }
  .leg.l { left: -8px;  transform: rotate(12deg); }
  .leg.r { right: -8px; transform: rotate(-12deg); }

  /* ===== muchy ===== */
  .fly {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #333;
    border-radius: 50%;
    animation: buzz 6s linear infinite;
  }
  .fly::before, .fly::after {
    content: "";
    position: absolute;
    top: -3px;
    width: 8px;
    height: 6px;
    background: rgba(255,255,255,0.7);
    border-radius: 50%;
    animation: wings 0.12s linear infinite;
  }
  .fly::before { left: -5px; }
  .fly::after  { right: -5px; }
  @keyframes wings {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(0.3); }
  }
  @keyframes buzz {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(60px, -40px); }
    50%  { transform: translate(-30px, -70px); }
    75%  { transform: translate(-70px, -20px); }
    100% { transform: translate(0, 0); }
  }
  /* Pozycje i czasy każdej z 20 much nadaje JS — inaczej wszystkie lecialyby
     ta sama trasaca, w tym samym momencie. */
  .swarm { position: absolute; inset: 0; pointer-events: none; }

  /* bąbelki "rybryb" po kliknięciu */
  .bubble {
    position: absolute;
    bottom: 160px;
    left: calc(50% + var(--ox, 0px));   /* dymka leci nad żabą, nie nad środkiem sceny */
    font-weight: bold;
    color: var(--frog-dark);
    background: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    animation: bubble 1s ease-out forwards;
    pointer-events: none;
  }
  @keyframes bubble {
    from { opacity: 1; transform: translate(-50%, 0) scale(0.6); }
    to   { opacity: 0; transform: translate(-50%, -60px) scale(1.2); }
  }

  /* ===== konfetti na czesc zjedzonego roju ===== */
  .confetti {
    position: absolute;
    z-index: 4;
    left: calc(50% + var(--ox, 0px));
    bottom: 130px;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    opacity: 0;
    pointer-events: none;
  }
  @keyframes fajerwerki {
    0%   { opacity: 1; transform: translate(0, 0) scale(.4) rotate(0deg); }
    55%  { opacity: 1; transform: translate(calc(var(--fx) * .75), var(--fy)) scale(1) rotate(calc(var(--fr) * .5)); }
    100% { opacity: 0; transform: translate(var(--fx), calc(var(--fy) + 120px)) scale(.9) rotate(var(--fr)); }
  }

  .hint { margin-top: 24px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }

  #soundBtn {
    position: fixed;
    top: 16px;
    right: 16px;
    font-size: 22px;
    padding: 8px 12px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.85);
    cursor: url("/assets/fly-32.775a0247fc510f7d.png") 16 16, pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  }
  #soundBtn:hover { background: #fff; }

  /* ===== QUIZ ZABA ===== */
  .quiz {
    position: relative;
    z-index: 3;
    width: min(560px, 92vw);
    margin-bottom: 8px;
    padding: 14px 18px 16px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
    text-align: center;
  }
  .question {
    margin: 0 0 12px;
    font-size: clamp(26px, 5vw, 40px);
    font-weight: 700;
    color: #14532d;
    letter-spacing: 1px;
    min-height: 1.2em;
  }
  .question .ask { color: #166534; font-weight: 500; font-size: 0.5em; display: block; margin-bottom: 2px; }

  .answers {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .answer {
    min-width: 84px;
    padding: 10px 18px;
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 700;
    color: #14532d;
    background: radial-gradient(circle at 30% 25%, #86efac, #4ade80 70%);
    border: 3px solid #16a34a;
    border-radius: 999px;
    cursor: url("/assets/fly-32.775a0247fc510f7d.png") 16 16, pointer;
    transition: transform .12s ease-out, box-shadow .12s ease-out, background .2s;
    box-shadow: 0 4px 0 #15803d;
  }
  .answer:hover:not([disabled]) { transform: translateY(-3px); box-shadow: 0 7px 0 #15803d; }
  .answer:active:not([disabled]) { transform: translateY(2px); box-shadow: 0 1px 0 #15803d; }
  .answer:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 3px; }
  .answer[disabled] { opacity: .75; cursor: default; }
  .answer.ok { background: radial-gradient(circle at 30% 25%, #bbf7d0, #22c55e 70%); border-color: #15803d; }
  .answer.bad { background: radial-gradient(circle at 30% 25%, #fecaca, #ef4444 70%); border-color: #b91c1c; color: #7f1d1d; animation: shake .4s; }
  .answer.reveal { outline: 3px dashed #15803d; outline-offset: 3px; }

  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
  }

  .verdict { min-height: 1.5em; margin: 10px 0 0; font-size: 20px; font-weight: 700; }
  .verdict.ok { color: #15803d; }
  .verdict.bad { color: #b91c1c; }
  .score { margin: 4px 0 0; font-size: 14px; color: #3f6212; }
  .score b { font-weight: 700; }

  /* ===== pasek pozostałych much ===== */
  .flyRow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 0;
    font-size: 13px;
    color: #3f6212;
  }
  .flyRow span:first-child { white-space: nowrap; }
  .flybar {
    position: relative;
    flex: 1 1 auto;
    height: 12px;
    min-width: 56px;
    background: #e6efe0;
    border: 1px solid #b9d1b1;
    border-radius: 999px;
    overflow: hidden;
  }
  .flybar-fill {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: 100%;
    background: linear-gradient(90deg, #86efac, #16a34a);
    transition: width .4s ease;
  }
  .flybar.pusto { border-color: #cfd8ca; background: #f2f4f0; }
  .flybar.pusto .flybar-fill { background: #dfe6da; }

  .voiceRow {
    margin: 10px 0 0;
    padding-top: 9px;
    border-top: 1px solid rgba(21, 128, 61, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #3f6212;
  }
  .voiceRow label { font-weight: 700; }
  #voiceSelect {
    font: inherit;
    font-size: 14px;
    max-width: 320px;
    padding: 6px 8px;
    border: 2px solid #16a34a;
    border-radius: 10px;
    background: #f0fdf4;
    color: #14532d;
    cursor: url("/assets/fly-32.775a0247fc510f7d.png") 16 16, pointer;
  }
  #voiceSelect:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
  #voiceTest {
    font-size: 15px;
    padding: 5px 9px;
    border: 2px solid #16a34a;
    border-radius: 10px;
    background: #dcfce7;
    cursor: url("/assets/fly-32.775a0247fc510f7d.png") 16 16, pointer;
  }
  #voiceTest:hover { background: #bbf7d0; }

  /* klik = plaska mucha, jakby zaba ja zdazyla */
  body:active, .stage:active {
    cursor: url("/assets/fly-splat-32.6cfb95aff02bc215.png") 16 16, url("/assets/fly-splat-64.8007163bc90a8bbb.png") 32 32, auto;
  }
  /* waski ekran: quiz + zaba musza sie miescic bez przewijania */
  @media (max-width: 620px) {
    /* very low screens (landscape phone): lepiej pozwol przewijac niz obciac zabe */
    body { justify-content: flex-start; padding: 4px 0 4px; overflow-y: auto; }
    .quiz { margin-bottom: 0; padding: 10px 12px 12px; }
    .answers { gap: 8px; }
    .answer { min-width: 72px; padding: 12px 16px; }      /* obszar dotyku >= 44 px */
    #voiceSelect, #voiceTest { min-height: 44px; }         /* tez na palec */
    #voiceSelect { max-width: 182px; font-size: 13px; }
    .voiceRow label { font-size: 12px; }
    .verdict { font-size: 17px; margin-top: 6px; }
    .flyRow { margin-top: 5px; font-size: 12px; gap: 8px; }
    .stage { transform: scale(.82); transform-origin: top center; height: 213px; }
    .hint { margin-top: 4px; font-size: 12px; line-height: 1.3; }
    .voiceRow { margin-top: 7px; padding-top: 7px; gap: 6px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .frog, .fly, .fly::before, .fly::after, .pupil, .lid, .answer.bad,
    .confetti { animation: none !important; }
    .tongue { display: none; }           /* bez strzelania jezykiem: mucha znika od razu */
    /* bez animowanego skoku: zaba tylko "przeskakuje" w nowe miejsce od razu */
    .frog { transition: none; }
    .flybar-fill { transition: none; }   /* pasek zmienia się od razu */
    .eye { transition: none; }
  }

