html, body { margin: 0; height: 100%; background: #1d2a14; overflow: hidden; touch-action: manipulation; }
body { position: relative; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; }

/* Внутренние координаты всегда 1080×1920; масштаб ставит main.js (transform: scale). */
#game { position: absolute; left: 50%; top: 50%; width: 1080px; height: 1920px; transform-origin: 0 0; overflow: hidden; }
#bg { position: absolute; inset: 0; width: 1080px; height: 1920px; image-rendering: auto; pointer-events: none; }
#plots { position: absolute; inset: 0; }
#ambient { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#sprites { position: absolute; inset: 0; pointer-events: none; }

.plant { position: absolute; pointer-events: none; transform-origin: 50% 100%; will-change: transform; }
.shadow { position: absolute; border-radius: 50%; background: rgba(60, 90, 40, 0.22); filter: blur(6px); pointer-events: none; }
.tap { position: absolute; -webkit-tap-highlight-color: transparent; }

/* Целина: пока участок не освоен — на его месте трава, а не серая плашка. */
.turf { position: absolute; pointer-events: none; will-change: opacity, transform;
  transition: opacity .6s ease, transform .6s ease;
  filter: drop-shadow(0 0 3px rgba(40, 55, 25, 0.55)); }
.turf.gone { opacity: 0; transform: scale(1.10); }

#hud { position: absolute; left: 0; top: 0; width: 1080px; height: 200px; display: flex; gap: 20px; padding: 40px 30px 0; box-sizing: border-box; pointer-events: none; }
.hud-item { flex: 1; height: 120px; background: rgba(40, 30, 20, 0.72); border-radius: 24px; color: #fff; padding: 14px 22px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; }
.hud-item .lbl { font-size: 26px; opacity: 0.8; }
.hud-item .val { font-size: 44px; font-weight: 700; }
.xpbar { height: 18px; background: rgba(255, 255, 255, 0.25); border-radius: 9px; overflow: hidden; margin: 8px 0 4px; }
.xpfill { height: 100%; width: 0; background: #8fd14f; transition: width .35s ease; }
.xptxt { font-size: 22px; opacity: 0.85; }

#toast { position: absolute; left: 50%; top: 260px; transform: translateX(-50%); background: rgba(30, 20, 10, 0.85); color: #fff; font-size: 38px;
  padding: 16px 36px; border-radius: 30px; opacity: 0; transition: opacity 0.25s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

#actions { position: absolute; left: 30px; top: 172px; display: flex; gap: 20px; }
.btn { font: inherit; font-size: 34px; font-weight: 700; color: #fff; background: #4f8f2a; border: 0; border-radius: 24px;
  min-width: 120px; height: 76px; padding: 0 28px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); -webkit-tap-highlight-color: transparent;
  transition: transform .08s ease, background .2s ease; }
.btn:active { transform: translateY(2px) scale(.98); }
.btn.off { background: #7a7a7a; color: #ddd; }
.coin-float { position: absolute; color: #ffd84a; font-size: 56px; font-weight: 800; text-shadow: 0 3px 0 rgba(60, 30, 0, 0.7);
  pointer-events: none; animation: coin-up 1.1s ease-out forwards; }
@keyframes coin-up { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-140px); } }

#shop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; }
#shop[hidden] { display: none; }
#shop .card { width: 760px; background: #f1e3bd; color: #3a2a14; border-radius: 36px; padding: 40px; box-sizing: border-box; }
#shop h2 { margin: 0 0 24px; font-size: 52px; }
#shop .row { display: flex; justify-content: space-between; align-items: center; font-size: 40px; margin: 18px 0; }
#shop .row.buy { gap: 20px; justify-content: stretch; }
#shop .row.buy .btn { flex: 1; }
#shop .close { width: 100%; margin-top: 16px; background: #8a5a2b; }

/* --- Блок 4: живность как спрайты с анимацией --- */
.pen { position: absolute; pointer-events: none; }
.animal { position: absolute; pointer-events: auto; touch-action: manipulation; min-width: 88px; min-height: 88px; -webkit-tap-highlight-color: transparent; border-radius: 50%; }
.animal:active { transform: scale(.94); }

/* Спрайт животного: точные пиксели кадра, вырезанные по inpaint-маске. */
.spr { position: absolute; pointer-events: none; transform-origin: 50% 92%; will-change: transform;
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, 1.3, .4, 1); }
.spr.gone { opacity: 0; transform: translateY(16px) scale(.88); }
.spr.pop { animation: spr-pop .6s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes spr-pop {
  0% { transform: translateY(18px) scale(.82); opacity: 0; }
  60% { transform: translateY(-4px) scale(1.04); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Анимация животных — спрайтовые полосы, см. css/anim.css (генерируется tools/build_anim_css.py). */
.spr { transition: translate .6s ease-out; touch-action: manipulation; }
.tab-hidden .spr-anim { animation-play-state: paused !important; }
.spr-anim.look { animation: none; }
.fx-float { position: absolute; transform: translateX(-50%); font: 700 30px/1 sans-serif; color: #fff6c8;
  text-shadow: 0 2px 4px rgba(0,0,0,.6); pointer-events: none; animation: coin-up 1.2s ease-out forwards; }
.fx-float.heart { color: #ff5a7a; font-size: 44px; }

/* Готовый продукт: мягкое сияние + подпрыгивание, чтобы игрок заметил. */
.spr.ready { animation: ready-hop 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(255, 244, 170, .95)) drop-shadow(0 0 34px rgba(255, 226, 120, .55)); }
@keyframes ready-hop {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-6px); }
}

/* Растения: живые, покачиваются на ветру; готовые подпрыгивают. */
.plant.sway { animation: plant-sway 4.2s ease-in-out infinite; }
@keyframes plant-sway {
  0%, 100% { transform: rotate(-1.4deg); }
  50% { transform: rotate(1.4deg); }
}
.plant.ready { animation: plant-ready 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255, 246, 180, .9)); }
@keyframes plant-ready {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-7px) scale(1.02); }
}

/* --- Окружение: ферма дышит --- */
/* Пыльца/мошки, плавно плывущие по кадру. */
.mote { position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 200, .95), rgba(255, 240, 150, 0) 70%);
  animation: mote-float linear infinite; }
@keyframes mote-float {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: .85; }
  50% { transform: translate(38px, -46px); opacity: .7; }
  85% { opacity: .5; }
  100% { transform: translate(-18px, -104px); opacity: 0; }
}

/* Бабочки: два крыла, взмах и полёт по петле. */
.butterfly { position: absolute; width: 34px; height: 26px; animation: fly-path 22s ease-in-out infinite; }
.butterfly i { position: absolute; top: 0; width: 16px; height: 22px; border-radius: 60% 40% 55% 45%;
  background: linear-gradient(160deg, #ffe9a8, #f0b53c); transform-origin: 100% 50%;
  animation: wing-l 0.28s ease-in-out infinite alternate; }
.butterfly i:nth-child(2) { left: 16px; transform-origin: 0 50%; animation-name: wing-r; }
@keyframes wing-l { from { transform: rotateY(0deg) rotate(-12deg); } to { transform: rotateY(64deg) rotate(6deg); } }
@keyframes wing-r { from { transform: rotateY(0deg) rotate(12deg); } to { transform: rotateY(-64deg) rotate(-6deg); } }
@keyframes fly-path {
  0% { transform: translate(120px, 980px); }
  20% { transform: translate(520px, 760px); }
  40% { transform: translate(760px, 1180px); }
  60% { transform: translate(300px, 1320px); }
  80% { transform: translate(880px, 900px); }
  100% { transform: translate(120px, 980px); }
}

/* Дым из трубы дома. */
.smoke { position: absolute; border-radius: 50%; background: rgba(245, 245, 240, .55);
  filter: blur(3px); animation: smoke-rise 6s ease-out infinite; }
@keyframes smoke-rise {
  0% { transform: translate(0, 0) scale(.5); opacity: 0; }
  18% { opacity: .55; }
  100% { transform: translate(-34px, -150px) scale(2.1); opacity: 0; }
}

.btn.feed { position: absolute; width: 360px; height: 52px; font-size: 28px; padding: 0; }
.btn.feed.locked { background: #7a7a7a; color: #ddd; }
.btn.feed.boost { background: #c9822b; }
.hud-item .sub { font-size: 20px; opacity: 0.85; }

/* Укачивает — отключаем движение окружения и растений, если система просит. */
@media (prefers-reduced-motion: reduce) {
  #ambient { display: none; }
  .plant, .spr, .turf { animation: none !important; }
}
