/* Поляна: пиксельная картина (static/meadow/day.webp, night.webp) с днём/ночью и анимацией.
   Мир = чёткая картина 1595x986 в режиме cover; все эффекты лежат внутри мира в процентах. */
#meadowScene { display: none; }
html[data-theme="meadow"]:not([data-halloween="on"]) #meadowScene { display: block; position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: #3fa0f0; }
html[data-theme="meadow"][data-sky="night"]:not([data-halloween="on"]) #meadowScene { background: #0b1030; }
html[data-theme="meadow"]:not([data-halloween="on"]) .bg-wide #villageScene { display: none !important; }
.ms-world {
  --ms-w: max(100vw, calc(100dvh * 1.6168));
  position: absolute; left: var(--ms-rest-x, 0px); top: var(--ms-top, 0px);
  width: var(--ms-w); height: var(--ms-h,100%); font-size: calc(var(--ms-w) / 100);
  /* Keep fine foreground details still; only independent ambient particles move. */
  transform: none; animation: none; will-change: auto;
}
.ms-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering:pixelated; transition: opacity 2.6s ease-in-out; }
.ms-dusk { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; image-rendering:pixelated; }
/* день и ночь: прогресс ведёт скрипт (--ms-n 0..1, --ms-d - вечерний слой), поэтому смену можно развернуть с любого места */
.ms-img.night, .ms-fg.night { opacity: var(--ms-n, 0); transition: none; }
.ms-dusk { opacity: var(--ms-d, 0); }
.ms-dayfx, .ms-nightfx { position: absolute; inset: 0; }
.ms-dayfx { opacity: var(--ms-day, 1); }
.ms-nightfx { opacity: var(--ms-n, 0); }
/* A skewed duplicate of the entire flower field made the foreground double
   and smear. Wind is represented by the separate ambient particles instead. */
.ms-fg { display:none!important; }
.ms-fx { position: absolute; inset: 0; }
/* облака */
.ms-cloud { position: absolute; width: 9em; height: 3.5em; left: -12em; animation: msCloud linear infinite; }
.ms-cloud svg { width: 100%; height: 100%; display: block; }
@keyframes msCloud { to { transform: translateX(118em); } }
/* дым из труб */
.ms-smoke { position: absolute; width: .7em; height: .7em; background: #eee8da; opacity: 0; animation: msSmoke 5s linear infinite; }
html[data-sky="night"] .ms-smoke { background: #9fa8c8; }
@keyframes msSmoke { 0% { transform: translate(0, 0) scale(.7); opacity: 0; } 15% { opacity: .65; } 100% { transform: translate(1.8em, -4.4em) scale(1.8); opacity: 0; } }
/* блики на озере */
.ms-glint { position: absolute; width: .55em; height: .16em; background: #fff; opacity: 0; animation: msGlint 3.2s steps(2) infinite; }
@keyframes msGlint { 0%, 55%, 100% { opacity: 0; } 62%, 78% { opacity: .95; } }
/* бабочки и пыльца (день) */
.ms-bfly { position: absolute; width: 1.5em; height: 1.1em; animation: msFly 22s ease-in-out infinite; }
.ms-bfly i { position: absolute; top: 0; width: .72em; height: .9em; background: var(--c, #ff8fc0); box-shadow: inset 0 0 0 .12em rgba(60,20,50,.35); animation: msFlap .32s steps(2) infinite alternate; }
.ms-bfly i:first-child { left: 0; transform-origin: 100% 50%; border-radius: 70% 20% 55% 20%; }
.ms-bfly i:last-child { right: 0; transform-origin: 0 50%; border-radius: 20% 70% 20% 55%; }
@keyframes msFlap { to { transform: scaleX(.25); } }
@keyframes msFly { 0% { transform: translate(0, 0); } 25% { transform: translate(8em, -3em); } 50% { transform: translate(15em, 1em); } 75% { transform: translate(6em, 3.5em); } 100% { transform: translate(0, 0); } }
.ms-pollen { position: absolute; width: .22em; height: .22em; background: #fff6b0; opacity: 0; animation: msPollen 14s linear infinite; }
@keyframes msPollen { 0% { transform: translate(0, 0); opacity: 0; } 10%, 85% { opacity: .85; } 100% { transform: translate(14em, -5em); opacity: 0; } }
/* ночь: светлячки, звёзды, огни окон */
.ms-firefly { position: absolute; width: .3em; height: .3em; background: #e9ff8a; box-shadow: 0 0 .7em .25em rgba(210,255,110,.6); opacity: 0; animation: msFirefly 6s ease-in-out infinite; }
@keyframes msFirefly { 0%, 100% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 55% { opacity: .35; transform: translate(2.2em, -1.6em); } 75% { opacity: 1; } }
.ms-star { position: absolute; width: .22em; height: .22em; background: #fff; opacity: 0; animation: msStar 3s ease-in-out infinite alternate; }
@keyframes msStar { to { opacity: .15; } }
.ms-lamp { position: absolute; width: 7em; height: 7em; margin: -3.5em 0 0 -3.5em; border-radius: 50%; background: radial-gradient(circle, rgba(255,200,110,.55), rgba(255,170,60,.18) 45%, transparent 70%); animation: msFlicker 2.4s steps(1) infinite; }
.ms-win { position: absolute; width: 2.6em; height: 2.6em; margin: -1.3em 0 0 -1.3em; border-radius: 50%; background: radial-gradient(circle, rgba(255,205,120,.5), transparent 70%); animation: msFlicker 3.1s steps(1) infinite; }
@keyframes msFlicker { 0%, 100% { opacity: 1; } 18% { opacity: .78; } 36% { opacity: .95; } 61% { opacity: .7; } 80% { opacity: .92; } }
@media (prefers-reduced-motion: reduce) { .ms-world, .ms-world * { animation: none !important; } }
#meadowScene.scene-paused * { animation-play-state: paused !important; }

/* Light is already painted into the aligned night image; avoid broad duplicate glow patches. */
.ms-lamp, .ms-win { display:none; }
