:root {
  --bg-page: #0b0805;
  --window-frame: #1c1208;
  --chrome: #221610;
  --chrome-line: rgba(255, 216, 155, 0.08);
  --panel: rgba(28, 14, 9, 0.86);
  --panel-strong: rgba(20, 10, 7, 0.94);
  --text: #ffe8c8;
  --muted: #b39073;
  --gold: #ffd89b;
  --orange: #e2864a;
  --num: #ea7233;
  --red: #7d281c;
  --brown: #2a140d;
  --bubble-bg: #f7e7c8;
  --bubble-ink: #2f1a10;
  --shadow: rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg-page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 151, 65, 0.07), transparent 40%),
    var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 32px);
}

button { font: inherit; cursor: pointer; }

/* ============================================================
   Ramka okna (macOS-style)
   ============================================================ */

.window-frame {
  width: min(100%, 1400px);
  overflow: hidden; /* górna krawędź = sama ramka, jak po bokach */
  border-radius: var(--radius);
  background: var(--window-frame);
  border: 1px solid rgba(255, 216, 155, 0.05);
  box-shadow:
    0 30px 70px -10px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

/* ============================================================
   Scena
   ============================================================ */

.game-card {
  background: var(--panel);
}

.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 1672 / 941;
  overflow: hidden;
  background: #2b150d;
  isolation: isolate;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 50%, rgba(255, 216, 155, 0.10), transparent 28%),
    linear-gradient(180deg, transparent 55%, rgba(7, 3, 2, 0.30) 100%);
  z-index: 1;
  transition: opacity 2.4s ease;
}

/* Po zgaszeniu lampki znika jej poświata. */
.scene:not([data-stage="0"])::after { opacity: 0.3; }

/* ============================================================
   Przedmioty SVG — ten sam crop co tło (slice ↔ cover),
   więc trzymają się obrazka na każdej szerokości ekranu.
   ============================================================ */

.scene-items {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  transition: filter 2.4s ease;
}

/* Przedmioty ciemnieją razem z pokojem. */
.scene[data-stage="1"] .scene-items { filter: brightness(0.88) saturate(0.95); }
.scene[data-stage="2"] .scene-items { filter: brightness(0.78) saturate(0.9); }
.scene[data-stage="3"] .scene-items { filter: brightness(0.58) saturate(0.8); }
.scene[data-stage="4"] .scene-items { filter: brightness(0.34) saturate(0.68); }
.scene[data-stage="5"] .scene-items { filter: brightness(0.24) saturate(0.6); }

.item {
  cursor: pointer;
  outline: none;
}

.item .hit {
  fill: transparent;
  pointer-events: all;
  stroke: none;
  transition: fill 160ms ease, stroke 160ms ease;
}

.item:hover {
  filter: brightness(1.12) drop-shadow(0 0 7px rgba(255, 216, 155, 0.28));
}

.item:active {
  filter: brightness(0.94);
}

/* Ukłon w stronę v1: dashed obrys, ale tylko dla nawigacji klawiaturą. */
.item:focus-visible .hit {
  stroke: rgba(255, 232, 200, 0.85);
  stroke-width: 2.5;
  stroke-dasharray: 6 7;
  stroke-linecap: round;
}

.obj-shadow {
  fill: rgba(61, 30, 15, 0.22);
}

/* --- mikro-animacje: coś się dzieje, ale to nic ------------- */

.lamp-flicker { opacity: 0; }

.item.anim .lamp-flicker {
  animation: lampFlicker 0.9s ease;
}

.item.anim .book-top {
  transform-box: view-box;
  transform-origin: 480px 496px;
  animation: bookWobble 0.7s ease;
}

.item.anim .leaves {
  transform-box: view-box;
  transform-origin: 735px 512px;
  animation: leavesSway 1.1s ease;
}

.item.anim .cat-ear {
  transform-box: view-box;
  transform-origin: 994px 490px;
  animation: earFlick 0.5s ease;
}

.item.anim .cat-tail {
  transform-box: view-box;
  transform-origin: 1004px 549px;
  animation: tailSwish 1.1s ease;
}

.item.anim .scissor-blade {
  transform-box: view-box;
  transform-origin: 385px 480px;
  animation: snip 0.55s ease;
}

.item.anim .note-page {
  transform-box: view-box;
  transform-origin: 652px 557px;
  animation: pageFlip 0.8s ease;
}

/* v3.5: pieczątka na notesie — pojawia się z „łupnięciem" i zostaje do resetu */
.note-stamp {
  opacity: 0;
  pointer-events: none;
}

.item.stamped .note-stamp {
  opacity: 0.85;
  transform-box: fill-box;
  transform-origin: center;
  animation: stampThunk 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes stampThunk {
  0%   { opacity: 0;    transform: scale(1.6); }
  60%  { opacity: 0.95; transform: scale(0.94); }
  100% { opacity: 0.85; transform: scale(1); }
}

.item.anim .mug-steam {
  animation: steamPuff 1.5s ease;
}

.item.anim .clock-hands {
  transform-box: view-box;
  transform-origin: 108px 150px;
  animation: spinHands 1s cubic-bezier(0.55, 0.05, 0.35, 1);
}

/* Nocą kot na chwilę otwiera świecące oczy. */
.cat-eyes {
  opacity: 0;
  filter: drop-shadow(0 0 5px rgba(255, 223, 158, 0.9));
}

.cat-eyes.glow {
  animation: eyesGlow 1.8s ease;
}

@keyframes eyesGlow {
  0%   { opacity: 0; }
  20%  { opacity: 0.95; }
  75%  { opacity: 0.95; }
  100% { opacity: 0; }
}

/* Obraz przekrzywia się kumulatywnie — JS ustawia --tilt. */
/* „Bitwa mrówek" — gwóźdź u góry ramy */
.picture-c {
  transform-box: view-box;
  transform-origin: 1576px 254px;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* „Zima w polu" przekrzywia się w drugą stronę — własny gwóźdź */
.picture-b {
  transform-box: view-box;
  transform-origin: 1120px 200px;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.picture {
  transform-box: view-box;
  transform-origin: 1355px 172px;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lampFlicker {
  0%   { opacity: 0; }
  12%  { opacity: 0.55; }
  26%  { opacity: 0.06; }
  42%  { opacity: 0.45; }
  58%  { opacity: 0.1; }
  74%  { opacity: 0.3; }
  100% { opacity: 0; }
}

@keyframes bookWobble {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(-5deg); }
  65%  { transform: rotate(2.4deg); }
  100% { transform: rotate(0deg); }
}

@keyframes leavesSway {
  0%   { transform: rotate(0deg); }
  30%  { transform: rotate(5deg); }
  60%  { transform: rotate(-3.6deg); }
  85%  { transform: rotate(1.6deg); }
  100% { transform: rotate(0deg); }
}

@keyframes earFlick {
  0%   { transform: rotate(0deg); }
  40%  { transform: rotate(-22deg); }
  70%  { transform: rotate(8deg); }
  100% { transform: rotate(0deg); }
}

@keyframes tailSwish {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(14deg); }
  70%  { transform: rotate(-6deg); }
  100% { transform: rotate(0deg); }
}

@keyframes snip {
  0%   { transform: rotate(0deg); }
  45%  { transform: rotate(-11deg); }
  100% { transform: rotate(0deg); }
}

@keyframes pageFlip {
  0%   { transform: rotate(0deg); }
  40%  { transform: rotate(-15deg); }
  75%  { transform: rotate(3deg); }
  100% { transform: rotate(0deg); }
}

@keyframes steamPuff {
  0%   { opacity: 0; transform: translateY(5px); }
  30%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-16px); }
}

@keyframes spinHands {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   Tutorial overlay
   ============================================================ */

/* ============================================================
   Koleś + dymek
   ============================================================ */

.guy-popover {
  --gx: 50%;
  --gy: 50%;
  position: absolute;
  left: var(--gx);
  top: var(--gy);
  z-index: 6;
  width: min(260px, 36vw);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -92%) scale(0.88);
}

.guy-popover.is-visible {
  animation: popIn 320ms cubic-bezier(.18, .89, .32, 1.28) forwards;
}

.guy-popover.is-hiding {
  animation: popOut 220ms ease forwards;
}

.speech-bubble {
  position: absolute;
  left: 56%;
  bottom: 78%;
  min-width: 120px;
  max-width: min(300px, 46vw);
  padding: 10px 14px 11px;
  border: 1px solid rgba(87, 44, 25, 0.36);
  border-radius: 14px 14px 14px 4px;
  background: var(--bubble-bg);
  color: var(--bubble-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 500;
  font-size: clamp(0.92rem, 1.2vw, 1.05rem);
  line-height: 1.25;
  text-align: center;
  letter-spacing: -0.005em;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.32);
  white-space: pre-wrap;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: -8px;
  border-width: 10px 10px 0 0;
  border-style: solid;
  border-color: var(--bubble-bg) transparent transparent transparent;
}

/* ============================================================
   Stopka
   ============================================================ */

.game-footer {
  display: block;          /* wyśrodkowanie tekstowe — odporne na flexowe niespodzianki */
  text-align: center;
  padding: 12px clamp(14px, 2.4vw, 22px);
  color: var(--muted);
  background: var(--panel-strong);
  border-top: 1px solid var(--chrome-line);
  font-size: 0.86rem;
}

.counters {
  display: flex;           /* + auto-marginesy = środek niezależnie od rodzica */
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  flex-wrap: nowrap;
  gap: 6px 14px;
  align-items: baseline;
  white-space: nowrap;
  min-width: 0;
}

.counter-label { display: inline-flex; gap: 6px; align-items: baseline; }
.counter-num   { color: var(--num); font-weight: 600; font-variant-numeric: tabular-nums; }
.counter-sep   { opacity: 0.4; }

.scene-buttons { display: contents; } /* dzieci pozycjonują się same względem sceny */

/* lewy dół: dźwięk + „ustawienia nicości"; prawy dół: „pochwal się" + reset */
.scene-tools,
.scene-actions {
  position: absolute;
  bottom: 12px;
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
}
.scene-tools   { left: 12px; }
.scene-actions { right: 12px; }

.scene .sound-button,
.scene .reset-button { opacity: 0.85; }

.scene .sound-button:hover, .scene .reset-button:hover { opacity: 1; }

.sound-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 216, 155, 0.18);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(120, 50, 28, 0.3);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.sound-button:hover,
.sound-button:focus-visible {
  background: rgba(160, 70, 36, 0.5);
  border-color: rgba(255, 216, 155, 0.42);
  color: var(--text);
  outline: none;
}

.sound-icon { width: 17px; height: 17px; }

.sound-x { display: none; }
.sound-button.muted .sound-x { display: block; }
.sound-button.muted .sound-wave { display: none; }
.sound-button.muted { opacity: 0.75; }

.reset-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(255, 216, 155, 0.18);
  border-radius: 999px;
  color: var(--text);
  background: rgba(120, 50, 28, 0.45);
  font-size: 0.86rem;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.reset-button:hover,
.reset-button:focus-visible {
  background: rgba(160, 70, 36, 0.55);
  border-color: rgba(255, 216, 155, 0.42);
  outline: none;
}

.reset-button:active { transform: translateY(1px); }

.reset-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

/* ============================================================
   Noscript
   ============================================================ */

.noscript-note {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* ============================================================
   Animacje dymka
   ============================================================ */

@keyframes popIn {
  0%   { opacity: 0; transform: translate(-50%, -82%)  scale(0.74); }
  62%  { opacity: 1; transform: translate(-50%, -101%) scale(1.05); }
  100% { opacity: 1; transform: translate(-50%, -96%)  scale(1); }
}

@keyframes popOut {
  from { opacity: 1; transform: translate(-50%, -96%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, -88%) scale(0.9); }
}

/* wariant „pod punktem" — stacja F: dymek wisi POD obrazem, ogonek do góry */
.guy-popover.below { transform: translate(-50%, 8%) scale(0.88); }
.guy-popover.below.is-visible { animation-name: popInBelow; }
.guy-popover.below.is-hiding  { animation-name: popOutBelow; }
.guy-popover.below .speech-bubble {
  bottom: auto;
  top: 22%;
  left: auto;
  right: 44%;
  border-radius: 14px 4px 14px 14px;
}

.guy-popover.below .speech-bubble::after {
  bottom: auto;
  top: -8px;
  left: auto;
  right: 16px;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent var(--bubble-bg) transparent;
}

@keyframes popInBelow {
  0%   { opacity: 0; transform: translate(-50%, -2%) scale(0.74); }
  62%  { opacity: 1; transform: translate(-50%, 13%) scale(1.05); }
  100% { opacity: 1; transform: translate(-50%, 8%)  scale(1); }
}

@keyframes popOutBelow {
  from { opacity: 1; transform: translate(-50%, 8%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, 0%) scale(0.9); }
}

/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 760px) {
  body { padding: 8px; }
  .window-frame { border-radius: 14px; }
  /* scena zostaje w proporcjach jak na komputerze (bez wyższego kadru) — w v3 przedmioty
     stoją przy brzegach (lampka, kot, obrazy) i wyższy kadr z przycięciem by je ucinał.
     Ten blok przez długi czas w ogóle nie działał (osierocony nawias wyżej w pliku). */

  .guy-popover { width: min(236px, 62vw); }
  .speech-bubble {
    left: 50%;
    bottom: 74%;
    transform: translateX(-50%);
    min-width: 140px;
    max-width: min(280px, 72vw);
    font-size: clamp(0.86rem, 3.4vw, 1rem);
  }

  
  /* stopka ZAWSZE w jednym wierszu — na wąskich tylko ciaśniej */
  .game-footer { gap: 8px; padding: 10px 10px; }
  .counters { flex-wrap: nowrap; white-space: nowrap; }
  .counters { gap: 4px 8px; font-size: 0.74rem; min-width: 0; overflow: hidden; }

  /* „pochwal się" na wąskim ekranie tylko jako ikona — reset potrzebuje miejsca */
  #shareButton { padding: 7px 9px; }
  #shareButton span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* ============================================================
   Wektorowe tło sceny
   ============================================================ */

.scene-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* zmierzch płynie: kolory i słońce interpolują się między etapami */
.scene-backdrop rect,
.scene-backdrop path,
.scene-backdrop polygon,
.scene-backdrop circle,
.scene-backdrop g {
  transition: fill 2.4s ease, opacity 2.4s ease;
}

/* v3 wizualizacja: niebo to teraz jeden gradient — stopy przechodzą razem z resztą */
.scene-backdrop stop {
  transition: stop-color 2.4s ease;
}

#sunGroup {
  transform: translateY(var(--sunY));
  opacity: var(--sunOp);
  transition: transform 2.4s ease, opacity 2.4s ease;
}

/* Palety etapów wieczoru — generowane z warsztat/wektor/backdrop_gen.py */

.scene[data-stage="0"] {
  --moonOp: 0;
  --skyMid: #f28a45;
  --wallLitOp: 0.6;
  --skyTop: #e8683a;
  --skyLow: #ffb054;
  --sun: #ffe49a;
  --sunGlow: #ffcf7a;
  --cloud: #d95f36;
  --cloudHi: #f08a4e;
  --cityFar: #a05a48;
  --cityNear: #7c4638;
  --cityLight: #adc6de;
  --lightOp: 0.4;
  --wall: #e3aca0;
  --wallLit: #f5cbbc;
  --frame: #8a5a3a;
  --frameDark: #6e452c;
  --sill: #a06b45;
  --blinds: #8a5a3a;
  --floor: #5a381f;
  --floorLine: #744427;
  --rug: #d99e6b;
  --rugEdge: #c08a58;
  --sunY: 0px;
  --sunOp: 1;
}

.scene[data-stage="1"] {
  --moonOp: 0.4;
  --skyMid: #e37a3f;
  --wallLitOp: 0.5;
  --skyTop: #d95c34;
  --skyLow: #f5a04c;
  --sun: #ffd98a;
  --sunGlow: #f2b862;
  --cloud: #c65432;
  --cloudHi: #e07a45;
  --cityFar: #92503f;
  --cityNear: #6e3d31;
  --cityLight: #e59a55;
  --lightOp: 0.55;
  --wall: #cf948c;
  --wallLit: #e2ab9e;
  --frame: #7a4e32;
  --frameDark: #5f3a25;
  --sill: #8e5c3b;
  --blinds: #7a4e32;
  --floor: #4e2f1a;
  --floorLine: #653b23;
  --rug: #c08a58;
  --rugEdge: #a87648;
  --sunY: 34px;
  --sunOp: 1;
}

.scene[data-stage="2"] {
  --moonOp: 0.7;
  --skyMid: #d06a38;
  --wallLitOp: 0.42;
  --skyTop: #c14f31;
  --skyLow: #e08a42;
  --sun: #f8c26e;
  --sunGlow: #d99a50;
  --cloud: #a8452c;
  --cloudHi: #c96a3e;
  --cityFar: #7e4436;
  --cityNear: #5e342a;
  --cityLight: #f2ae5e;
  --lightOp: 0.75;
  --wall: #b27d76;
  --wallLit: #c69086;
  --frame: #68412a;
  --frameDark: #4e2f1e;
  --sill: #775033;
  --blinds: #68412a;
  --floor: #422717;
  --floorLine: #54321e;
  --rug: #a87648;
  --rugEdge: #8f6238;
  --sunY: 72px;
  --sunOp: 0.9;
}

.scene[data-stage="3"] {
  --moonOp: 0.9;
  --skyMid: #a84534;
  --wallLitOp: 0.3;
  --skyTop: #8f3130;
  --skyLow: #c25538;
  --sun: #f8c26e;
  --sunGlow: #b06a3c;
  --cloud: #732c26;
  --cloudHi: #984034;
  --cityFar: #5c3230;
  --cityNear: #422522;
  --cityLight: #ffc668;
  --lightOp: 0.9;
  --wall: #90605c;
  --wallLit: #a16d68;
  --frame: #523322;
  --frameDark: #3c2417;
  --sill: #5e3f2a;
  --blinds: #523322;
  --floor: #331d10;
  --floorLine: #40261a;
  --rug: #8a6040;
  --rugEdge: #745032;
  --sunY: 118px;
  --sunOp: 0;
}

.scene[data-stage="4"] {
  --moonOp: 1;
  --skyMid: #5e3038;
  --wallLitOp: 0.18;
  --skyTop: #4a2637;
  --skyLow: #7c3a3a;
  --sun: #f8c26e;
  --sunGlow: #8a5a3c;
  --cloud: #3a1e2c;
  --cloudHi: #54303c;
  --cityFar: #37222c;
  --cityNear: #241722;
  --cityLight: #ffd97e;
  --lightOp: 1;
  --wall: #654240;
  --wallLit: #6f4a45;
  --frame: #38231a;
  --frameDark: #281812;
  --sill: #40291d;
  --blinds: #38231a;
  --floor: #241409;
  --floorLine: #2a1a12;
  --rug: #5e422e;
  --rugEdge: #4e3624;
  --sunY: 150px;
  --sunOp: 0;
}

.scene[data-stage="5"] {
  --moonOp: 1;
  --skyMid: #2a2942;
  --wallLitOp: 0.1;
  --skyTop: #1c2138;
  --skyLow: #3a2f4a;
  --sun: #f8c26e;
  --sunGlow: #4a3a50;
  --cloud: #161a2e;
  --cloudHi: #252a42;
  --cityFar: #1c1826;
  --cityNear: #120f1c;
  --cityLight: #ffe59a;
  --lightOp: 1;
  --wall: #452e2d;
  --wallLit: #4b322f;
  --frame: #271811;
  --frameDark: #1b110c;
  --sill: #2d1d14;
  --blinds: #271811;
  --floor: #1a0e07;
  --floorLine: #1d130c;
  --rug: #423022;
  --rugEdge: #362718;
  --sunY: 170px;
  --sunOp: 0;
}

/* ============================================================
   Lampa wektorowa: zapalona tylko w etapie 0
   ============================================================ */

/* Lampa przełącza się przez sam wariant OFF: LIT leży zawsze pod spodem w pełnym
   kryciu, a wierzchni OFF tylko blaknie/kryje. Cross-fade OBU wariantów naraz dawał
   w połowie animacji ~75% łącznego krycia i biurko prześwitywało przez lampkę. */
#lampOff { transition: opacity 1.4s ease; }

/* okna miasta: łagodne migotanie po zmroku; w finale zostaje jedno */
.city-win { transition: opacity 1.4s ease; }
.scene.city-final .city-win { opacity: 0 !important; transition: opacity 5s ease; }
.scene.city-final #cityOne { opacity: 1 !important; }

.scene-light {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none; /* światło nie łapie kliknięć */
}

#lampLight { transition: opacity 0.35s ease; }
.scene.lamp-out #lampLight { opacity: 0; }

/* lampka należy do skrzata: gaśnie jego pstrykiem przy wyjściu, nie etapem */
.scene:not(.lamp-out) #lampOff { opacity: 0; }

/* Okno nie ma własnego rysunku w warstwie przedmiotów — poświata na hover */
#item-okno:hover .hit {
  fill: rgba(255, 232, 200, 0.10);
  stroke: rgba(255, 232, 200, 0.20);
  stroke-width: 2;
}

/* Mikro-animacje nowych przedmiotów */
.item.anim #blindsSlats { animation: blindsJiggle 0.7s ease; }
@keyframes blindsJiggle {
  0% { transform: translateY(0); } 30% { transform: translateY(4px); }
  60% { transform: translateY(-2px); } 100% { transform: translateY(0); }
}

/* ============================================================
   Skrzat 2.0: wychyla się zza mebli
   ============================================================ */

/* --- pogoda: prawdziwe zachmurzenie i opady (Open-Meteo, patrz applyWeather) --- */
#cloudDrift path { transition: opacity 2.4s ease; }
.scene[data-clouds="0"] #cloudDrift path { opacity: 0; }
.scene[data-clouds="1"] #cloudDrift .cl-2,
.scene[data-clouds="1"] #cloudDrift .cl-4,
.scene[data-clouds="1"] #cloudDrift .cl-a2 { opacity: 0; }
#overcastVeil { opacity: 0; transition: opacity 2.4s ease; }
.scene[data-clouds="3"] #overcastVeil { opacity: 0.18; }
/* świat za szybą szarzeje przy kiepskiej pogodzie (filtr na całości: niebo, słońce,
   księżyc z zasłoną, chmury, miasto, sowa — bez szwów) */
#outdoors { transition: filter 2.4s ease; }
.scene[data-clouds="3"] #outdoors,
.scene.weather-rain #outdoors,
.scene.weather-snow #outdoors { filter: saturate(0.45) brightness(0.93); }
.scene.weather-fog #outdoors { filter: saturate(0.3) brightness(0.98); }
/* mgła: mleko nad miastem */
#fogLayer { opacity: 0; transition: opacity 3s ease; }
.scene.weather-fog #fogLayer { opacity: 1; }
#fogDrift { animation: cloud-drift 420s linear infinite; }
@media (prefers-reduced-motion: reduce) { #fogDrift { animation: none; } }
#rainLayer, #snowLayer { opacity: 0; transition: opacity 2.4s ease; }
.scene.weather-rain #rainLayer { opacity: 0.55; }
.scene.weather-snow #snowLayer { opacity: 0.85; }
#rainDrift { animation: precip-fall 1.3s linear infinite; }
#snowDrift { animation: precip-fall 9s linear infinite; }
@keyframes precip-fall { to { transform: translateY(462px); } }
@media (prefers-reduced-motion: reduce) { #rainDrift, #snowDrift { animation: none; } }

/* --- chmury: dryf przez całe okno, pętla bez szwu ---------------------------- */
#cloudDrift { animation: cloud-drift 300s linear infinite; }
@keyframes cloud-drift { to { transform: translateX(-668px); } }
@media (prefers-reduced-motion: reduce) { #cloudDrift { animation: none; } }

/* --- księżyc: nad horyzontem decyduje etap (--moonOp), pod — inline z silnika - */
#moonGroup { opacity: var(--moonOp, 0); transition: opacity 2.4s ease; }
#moonCover { transition: opacity 2.4s ease; } /* zasłona fazy: pełnokryjąca (jest "niebem"), silnik chowa ją inline razem z tarczą */

/* --- sowa: nocna zmiana za szybą (pokazywana przez silnik czasu) ------------ */
#sowa { opacity: 0; transition: opacity 2.4s ease, filter 2.4s ease; }
.scene.owl-out #sowa { opacity: 1; }
/* za dnia jej hit nie może podkradać kliknięć oknu */
#item-sowa .hit { pointer-events: none; }
.scene.owl-out #item-sowa .hit { pointer-events: all; }
/* przyciemnianie łagodniejsze niż przedmiotów — nocny ptak ma być widoczny po ciemku */
.scene[data-stage="1"] #sowaDim { filter: brightness(0.88) saturate(0.95); }
.scene[data-stage="2"] #sowaDim { filter: brightness(0.8)  saturate(0.9); }
.scene[data-stage="3"] #sowaDim { filter: brightness(0.7)  saturate(0.85); }
.scene[data-stage="4"] #sowaDim { filter: brightness(0.6)  saturate(0.8); }
.scene[data-stage="5"] #sowaDim { filter: brightness(0.55) saturate(0.75); }
/* hover/focus: sowa podświetla się jak inne przedmioty. Hit żyje w scene-items,
   rysunek w tle — sprzęga je :has(); specyficzność (2,2,0) bije filtry etapów,
   a stare przeglądarki bez :has po prostu nie podświetlą (jak dziś). */
.scene:has(#item-sowa:hover) #sowa,
.scene:has(#item-sowa:focus-visible) #sowa {
  /* dokładnie ta sama siła co .item:hover — mnoży się z przyciemnieniem #sowaDim */
  filter: brightness(1.12) drop-shadow(0 0 7px rgba(255, 216, 155, 0.28));
}


/* --- nietoperz (v3.1): dzienna zmiana na gałązce za szybą ------------------- */
/* Dopełnienie sowy: w dzień śpi głową w dół, po zachodzie wylatuje na łowy —
   chowa go ta sama klasa .owl-out, która pokazuje sowę. Gałązka zostaje. */
#nietoperz {
  transition: opacity 2.4s ease;
  transform-box: fill-box;
  transform-origin: 50% 0%; /* punkt zaczepu = paluszki na gałązce */
  animation: batSway 7s ease-in-out infinite alternate;
}
.scene.owl-out #nietoperz { opacity: 0; }
@keyframes batSway {
  from { transform: rotate(-1.6deg); }
  to   { transform: rotate(1.6deg); }
}
@media (prefers-reduced-motion: reduce) { #nietoperz { animation: none; } }
/* przyciemnianie etapowe jak sowa (stałe hexy nie znają palet etapów);
   dotyczy też gałązki — ona wisi za oknem również nocą */
.scene[data-stage="1"] #nietoperzDim { filter: brightness(0.88) saturate(0.95); }
.scene[data-stage="2"] #nietoperzDim { filter: brightness(0.8)  saturate(0.9); }
.scene[data-stage="3"] #nietoperzDim { filter: brightness(0.7)  saturate(0.85); }
.scene[data-stage="4"] #nietoperzDim { filter: brightness(0.6)  saturate(0.8); }
.scene[data-stage="5"] #nietoperzDim { filter: brightness(0.55) saturate(0.75); }

#gnome { cursor: pointer; outline: none; }
/* a11y: widoczny fokus z klawiatury (outline na <g> w SVG się nie rysuje — poświata na obrazku) */
#gnome.shown:focus-visible #gnomeImg {
  filter: drop-shadow(0 0 2px #1f6feb) drop-shadow(0 0 4px #1f6feb);
}
#gnome:not(.shown) { pointer-events: none; } /* zaparkowany (niewidoczny) nie może łapać klików w obrazki, między którymi stoi */

#gnomeSlide {
  transform: translateY(80px); /* schowany za meblem; krótki zjazd — nie prześwituje pod blatem */
  opacity: 0; /* bezpiecznik: nigdy nie widać go poza meblem (start, prześwit pod biurkiem) */
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15),
              opacity 0.15s ease 0.05s; /* chowanie: gaśnie tuż po starcie zjazdu */
}

/* stacje E/F/G (zza obrazków): krótki skok — ramy niskie */
#gnome[data-station="E"] #gnomeSlide { transform: translateY(125px); }
#gnome[data-station="F"] #gnomeSlide { transform: translateY(76px); }
#gnome[data-station="G"] #gnomeSlide { transform: translateY(125px); }

#gnome.shown #gnomeSlide,
#gnome.shown[data-station] #gnomeSlide { /* specyficzność > offsetów stacji — kolejność reguł przestaje grać rolę */
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15),
              opacity 0.12s ease; /* pokazanie: szybkie pojawienie jeszcze za meblem */
}

@media (prefers-reduced-motion: reduce) {
  /* UWAGA: żadnych transformów tutaj! Duplikaty offsetów E/F/G wklejone za .shown
     przygważdżały skrzata przy obrazkach u osób z redukcją animacji (fix 05.07.2026). */
  #gnomeSlide,
  #gnome.shown #gnomeSlide { transition-duration: 1ms; }
}

/* potwierdzenie resetu — dymek nad przyciskiem w prawym dolnym rogu */
.reset-confirm {
  position: absolute;
  right: 14px;
  bottom: 58px;
  z-index: 6;
  max-width: 240px;
  padding: 10px 12px;
  background: var(--bubble-bg);
  border: 1px solid rgba(87, 44, 25, 0.36);
  border-radius: 14px 14px 4px 14px;
  color: #3a2a1e;
  font-size: 0.85rem;
}

.reset-confirm .rc-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.reset-confirm button {
  padding: 3px 16px;
  border: 1px solid rgba(87, 44, 25, 0.5);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.reset-confirm #resetYes:hover { background: rgba(87, 44, 25, 0.15); }
.reset-confirm #resetNo { font-weight: 600; }
.reset-confirm #resetNo:hover { background: rgba(87, 44, 25, 0.15); }

/* ============================================================
   Satyra: „korporacyjny internet" wciska się w przytulny pokój.
   Celowo inny styl niż scena — białe karty, niebieski przycisk,
   maleńkie „odrzuć". Zgrzyt jest częścią żartu.
   ============================================================ */

:root {
  --ui-bg: #ffffff;
  --ui-ink: #1f2328;
  --ui-muted: #5f6671;
  --ui-line: #e2e5e9;
  --ui-accent: #1f6feb;
  --ui-accent-ink: #ffffff;
  --ui-real: #fff6dc;
  --ui-hot: #d9480f;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.consent-wall,
.ui-modal-wall {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 3, 2, 0.55);
  backdrop-filter: blur(2px);
}
.consent-wall  { align-items: flex-end; }
.ui-modal-wall { align-items: center; z-index: 95; }
.consent-wall[hidden],
.ui-modal-wall[hidden] { display: none; }

.consent-banner,
.ui-modal,
.toast {
  color: var(--ui-ink);
  background: var(--ui-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.consent-banner {
  width: min(100%, 640px);
  padding: 20px 22px;
  border-radius: 14px;
  animation: uiRise 380ms cubic-bezier(.2, .8, .3, 1) both;
}

.ui-modal {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px 24px;
  border-radius: 16px;
  animation: uiRise 300ms cubic-bezier(.2, .8, .3, 1) both;
}

.consent-title,
.ui-modal-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  line-height: 1.3;
}

.consent-text,
.ui-modal-intro {
  margin: 0 0 14px;
  color: var(--ui-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.ui-btn {
  padding: 9px 18px;
  border: 1px solid #c9ced6;
  border-radius: 999px;
  color: var(--ui-ink);
  background: var(--ui-bg);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 140ms ease, transform 140ms ease;
}
.ui-btn:hover { background: #f1f3f5; }
.ui-btn:active { transform: translateY(1px); }

/* „Akceptuj" duży i niebieski, „odrzuć" malutki i szary — klasyka gatunku */
.ui-btn-primary {
  padding: 12px 28px;
  border-color: var(--ui-accent);
  color: var(--ui-accent-ink);
  background: var(--ui-accent);
  font-size: 1rem;
}
.ui-btn-primary:hover { background: #1a5fd0; }

.ui-link {
  margin-left: auto;
  padding: 4px;
  border: 0;
  color: #9aa1aa;
  background: none;
  font-size: 0.74rem;
  text-decoration: underline;
}

.ui-btn:focus-visible,
.ui-link:focus-visible,
.ui-close:focus-visible,
.ui-switch input:focus-visible + span,
.ui-field input:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.ui-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  color: var(--ui-muted);
  background: none;
  font-size: 1.5rem;
  line-height: 1;
}
.ui-close:hover { background: #f1f3f5; }

.consent-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.consent-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--ui-line);
}
.consent-row strong { display: block; font-size: 0.9rem; }
.consent-row span   { display: block; color: var(--ui-muted); font-size: 0.8rem; line-height: 1.4; }

.consent-row-real {
  margin-bottom: 4px;
  padding: 12px;
  border: 1px solid #f0d58a;
  border-radius: 12px;
  background: var(--ui-real);
}

.ui-switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.ui-switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.ui-switch span {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 999px;
  background: #c3c8cf;
  transition: background 160ms ease;
}
.ui-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease;
}
.ui-switch input:checked + span { background: var(--ui-accent); }
.ui-switch input:checked + span::after { transform: translateX(18px); }
.ui-switch input:disabled + span { opacity: 0.55; }
.ui-switch:has(input:disabled) { cursor: not-allowed; }

.ui-fineprint {
  margin: 10px 0 0;
  color: #8a9099;
  font-size: 0.74rem;
}

.ui-sep {
  margin: 18px 0 14px;
  border: 0;
  border-top: 1px solid var(--ui-line);
}

.ui-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--ui-muted);
  font-size: 0.82rem;
}
.ui-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9ced6;
  border-radius: 10px;
  color: var(--ui-ink);
  background: #fff;
  font: inherit;
}

/* podgląd posta — ogólna „sieć zawodowa", bez cudzych logo */
.post-card {
  padding: 14px 16px 10px;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
}
.post-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.post-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ui-ink);
  background: #e8ecf1;
  font-size: 0.85rem;
  font-weight: 700;
}
.post-head strong { display: block; font-size: 0.92rem; }
.post-head small  { display: block; color: var(--ui-muted); font-size: 0.76rem; }
.post-text {
  max-height: 260px;
  overflow: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.post-stats {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--ui-line);
  color: var(--ui-muted);
  font-size: 0.78rem;
}

/* dymki „fałszywej presji" — lewy dół ekranu, nigdy nie łapią kliknięć */
.toast-stack {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(330px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 10px 14px 10px 12px;
  border-left: 4px solid var(--ui-hot);
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.35;
  animation: toastIn 420ms cubic-bezier(.2, .8, .3, 1) both;
}
.toast small {
  display: block;
  margin-top: 3px;
  color: #8a9099;
  font-size: 0.72rem;
}
.toast.is-leaving { animation: toastOut 360ms ease both; }

@keyframes uiRise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(-24px); }
}

@media (max-width: 760px) {
  .consent-wall, .ui-modal-wall { padding: 10px; }
  .consent-banner, .ui-modal { padding: 18px 16px; }
  .ui-btn-primary { flex: 1 1 100%; }
  .ui-link { margin-left: 0; }
  .toast-stack { left: 10px; bottom: 10px; width: calc(100vw - 20px); }
}
