:root {
  --akcent: oklch(0.80 0.15 75);
  --niebo-gora: oklch(0.20 0.06 285);
  --niebo-dol: oklch(0.42 0.10 330);
  --tekst: oklch(0.97 0.02 80);
  --powierzchnia: oklch(0.24 0.05 285 / 0.72);
  --sierść: #6b4a33;
  --sierść-ciemna: #4a3121;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Nunito", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: linear-gradient(to bottom, var(--niebo-gora) 0%, oklch(0.28 0.08 300) 55%, var(--niebo-dol) 100%);
  color: var(--tekst);
  font: 16px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* --- tło --- */
.niebo { position: fixed; inset: 0; pointer-events: none; }
.gwiazdy {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%, #fff9 50%, transparent 51%),
    radial-gradient(2px 2px at 46% 22%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 12%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 82% 28%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 6%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 42%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 38% 38%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 74% 44%, #fff6 50%, transparent 51%);
  animation: migotanie 4s ease-in-out infinite alternate;
}
.ksiezyc {
  position: absolute; top: 6vh; right: 8vw;
  width: clamp(64px, 11vw, 140px);
  filter: drop-shadow(0 0 28px oklch(0.95 0.08 90 / 0.55));
}
.chmura {
  position: absolute; height: 34px; width: 180px; border-radius: 999px;
  background: oklch(0.55 0.06 300 / 0.35);
  animation: chmura linear infinite;
}
.chmura::before, .chmura::after {
  content: ""; position: absolute; border-radius: 50%; background: inherit;
}
.chmura::before { width: 70px; height: 56px; left: 30px; top: -28px; }
.chmura::after { width: 90px; height: 70px; left: 74px; top: -40px; }
.c1 { top: 18vh; animation-duration: 90s; animation-delay: -20s; }
.c2 { top: 46vh; animation-duration: 120s; animation-delay: -70s; transform: scale(0.7); }
.c3 { top: 70vh; animation-duration: 105s; animation-delay: -45s; opacity: 0.7; }

.las {
  position: fixed; left: 0; bottom: 0; width: 100%; height: clamp(70px, 16vh, 160px);
  pointer-events: none; z-index: 3;
}

/* --- scena i dziki --- */
#scena { position: fixed; inset: 0; z-index: 2; }

.dzik {
  position: absolute; left: 0; top: 0;
  width: var(--w, 150px);
  cursor: pointer;
  will-change: transform;
  outline: none;
}
.dzik:focus-visible .dzik-svg { filter: drop-shadow(0 0 0 var(--akcent)) drop-shadow(0 0 10px var(--akcent)); }
.dzik-obrot { transition: transform 0.7s cubic-bezier(0.3, 1.4, 0.5, 1); }
.dzik-svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 10px 14px oklch(0.12 0.05 285 / 0.45)); }
.dzik.lewo .dzik-obrot { transform: scaleX(-1); }

.cialo, .glowa { fill: var(--sierść); }
.nogi rect, .ucho, .grzywa { fill: var(--sierść-ciemna); }
.ogon { stroke: var(--sierść-ciemna); }
.kopyta rect { fill: #2a1a10; }
.brzuch { fill: #8a6448; }
.ucho-srodek { fill: #b07a6a; }
.ryj { fill: #c58f7e; }
.dziurka { fill: #5a2e26; }
.szczeka ellipse { fill: #9c6b55; }
.kiel { fill: #fffaf0; }
.oko { fill: #1a0f0a; }
.rumieniec { fill: #e58b8b; opacity: 0; transition: opacity 0.3s; }
.skrzydlo path:first-child { fill: #f6f1e4; stroke: #d9cdb2; stroke-width: 2; }
.skrzydlo.tyl path { fill: #cfc4ad; stroke: none; }
.pioro { stroke: #d9cdb2; }

.skrzydlo {
  transform-box: fill-box;
  transform-origin: 86% 100%;
  animation: machanie var(--mach, 380ms) ease-in-out infinite alternate;
}
.skrzydlo.tyl { animation-delay: -60ms; }

.szczeka { transform-box: fill-box; transform-origin: 80% 0%; }
.dzik.je .szczeka { animation: zucie 120ms ease-in-out 6 alternate; }
.dzik.je .rumieniec { opacity: 0.7; }
.dzik.je .oko-g { transform-box: fill-box; transform-origin: center; transform: scaleY(0.2); }
.dzik.je .dzik-svg { animation: podskok 360ms ease-out; }

/* --- efekty --- */
.zoladz {
  position: fixed; left: 0; top: 0; width: 34px; z-index: 4;
  pointer-events: none;
  transition: transform 260ms cubic-bezier(0.4, 0, 0.8, 0.6), opacity 260ms ease-in;
}
.zoladz.spada { transition: transform 1.1s cubic-bezier(0.5, 0, 1, 1), opacity 0.4s 0.8s; }
.zoladz-svg { display: block; width: 100%; }

.chrum {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none;
  font-weight: 800; font-size: clamp(18px, 2.6vw, 26px); letter-spacing: 0.01em;
  color: #2a1a10; background: var(--tekst);
  padding: 4px 12px; border-radius: 999px;
  box-shadow: 0 2px 0 oklch(0.6 0.1 75), 0 8px 20px oklch(0.12 0.05 285 / 0.4);
  animation: dymek 1s ease-out forwards;
  white-space: nowrap;
}
.okruch {
  position: fixed; left: 0; top: 0; width: 7px; height: 7px; border-radius: 2px;
  background: #c98a3a; z-index: 4; pointer-events: none;
  animation: okruch 700ms ease-in forwards;
}
.serce {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; width: 22px;
  animation: serce 1.1s ease-out forwards;
}

/* --- interfejs --- */
.licznik, .dzwiek {
  position: fixed; z-index: 6;
  top: max(14px, env(safe-area-inset-top));
  background: var(--powierzchnia);
  backdrop-filter: blur(6px);
  border-radius: 999px;
}
.licznik {
  left: max(14px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px 6px 8px;
  font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums;
  color: var(--akcent);
}
.licznik-ikona {
  width: 30px; height: 36px;
  background: url("zoladz.svg") center / contain no-repeat;
}
.licznik.bum { animation: bum 260ms ease-out; }
.dzwiek {
  right: max(14px, env(safe-area-inset-right));
  width: 48px; height: 48px; border: 0; padding: 0; cursor: pointer;
  color: var(--tekst); font: inherit;
  display: grid; place-items: center;
}
.dzwiek span {
  width: 24px; height: 24px; background: currentColor;
  -webkit-mask: url("glos.svg") center / contain no-repeat;
  mask: url("glos.svg") center / contain no-repeat;
}
.dzwiek[aria-pressed="false"] span {
  -webkit-mask-image: url("cisza.svg");
  mask-image: url("cisza.svg");
}
.dzwiek:hover { background: oklch(0.32 0.06 285 / 0.85); }
.dzwiek:focus-visible { outline: 3px solid var(--akcent); outline-offset: 2px; }

/* --- klatki --- */
@keyframes machanie {
  from { transform: rotate(-22deg) scaleY(1); }
  to { transform: rotate(34deg) scaleY(0.55); }
}
@keyframes zucie { to { transform: translateY(3px) scaleY(1.4); } }
@keyframes podskok { 40% { transform: scale(1.12, 0.92); } 70% { transform: scale(0.96, 1.05); } }
@keyframes dymek {
  0% { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.5) rotate(-6deg); }
  20% { opacity: 1; transform: translate(var(--x), calc(var(--y) - 14px)) scale(1.08) rotate(3deg); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) - 60px)) scale(1) rotate(0); }
}
@keyframes okruch {
  from { transform: translate(var(--x), var(--y)) rotate(0); opacity: 1; }
  to { transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(220deg); opacity: 0; }
}
@keyframes serce {
  from { transform: translate(var(--x), var(--y)) scale(0.4); opacity: 0; }
  25% { opacity: 1; transform: translate(var(--x), calc(var(--y) - 20px)) scale(1.1); }
  to { transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) - 90px)) scale(0.9); opacity: 0; }
}
@keyframes bum { 50% { transform: scale(1.12); } }
@keyframes migotanie { to { opacity: 0.55; } }
@keyframes chmura { from { translate: -260px 0; } to { translate: 110vw 0; } }

@media (prefers-reduced-motion: reduce) {
  .skrzydlo, .gwiazdy, .chmura { animation: none; }
  .dzik.je .dzik-svg, .dzik.je .szczeka { animation: none; }
  .dzik-obrot { transition: none; }
}
