:root {
  --sky-top: #87ceeb;
  --sky-bottom: #bfefff;
  --grass: #a8d08d;
}
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: system-ui, sans-serif;
  background: var(--grass);
  color: #1c2732;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.8s, color 0.8s;
}

/* Sky gradient */
#sky {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  transition: background 0.8s;
  pointer-events: none;
}

/* Wooden sign + tally */
.sign {
  background: #8b5a2b;
  border: 6px solid #704416;
  padding: 1rem 2.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.25);
  transform: skewX(-1deg);
  display: inline-block;
  text-align: center;
  color: #faf3e0;
}
.sign h1 {
  font-family: 'Ranchers', cursive;
  font-size: clamp(2.5rem, 6vw, 4rem);
  color: #faf3e0;
  text-shadow: 0 2px 2px rgba(0,0,0,0.4);
}
.sign ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}
.sign ul li {
  color: #faf3e0;
  font-size: 1.5rem;
}

/* Farm & pens */
#farm {
  position: relative;
  display: flex;
  width: 90vw;
  max-width: 1000px;
  height: 60vh;
  background: var(--grass);
  border: 10px solid #7c9b75;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}
.pensSide {
  width: 18%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
}
#pasture {
  flex: 1;
  position: relative;
  border-inline: 5px dashed #7c9b75;
}
.pen {
  background: #cfe2b6;
  border: 3px solid #7c9b75;
  border-radius: 0.5rem;
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 0.25rem;
  font-size: 1.5rem;
}

/* Barn doors */
.door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: #8b5a2b;
  background-image: repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,0.2) 8px 12px);
  z-index: 5;
}
#doorLeft {
  left: 0;
  transition: transform 1.6s ease-in-out 1s;
}
#doorRight {
  right: 0;
  transition: transform 1.6s ease-in-out 1s;
}
.open#doorLeft { transform: translateX(-100%); }
.open#doorRight { transform: translateX(100%); }

/* Animals & farmer */
.animal {
  position: absolute;
  font-size: 1.5rem;
  transition: transform 1.8s ease-out;
}
body.closed .animal {
  opacity: 0;
}
body.night .animal.inPen::after {
  content: "💤";
  position: absolute;
  left: 50%;
  top: -12px;
  transform: translateX(-50%);
  font-size: 1rem;
  animation: floatZ 1.8s ease-in-out infinite alternate;
  opacity: 0.8;
}
@keyframes floatZ {
  from { transform: translate(-50%, -2px); }
  to   { transform: translate(-50%, -10px); }
}

#farmer {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  z-index: 3;
}

/* Tally spans fixed width */
#tally li span {
  display: inline-block;
  width: 3ch;
  text-align: right;
}

/* Seasonal Extras */
/* Night overlay */
body.night {
  color: #cdd4e2;
  background: #1a2a3e;
}
body.night #sky {
  background: linear-gradient(var(--sky-night-top), var(--sky-night-bottom));
}
body.night #farm {
  border-color: #5e6f7e;
  background: #233848;
}
body.night .pen {
  background: #30485a;
  border-color: #5e6f7e;
}

/* Snowflakes */
@keyframes snowflake {
  0%   { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0.8; }
}
.snowflake {
  position: fixed;
  top: -10vh;
  pointer-events: none;
  animation: snowflake linear infinite;
}

/* Christmas trees */
.tree {
  position: absolute;
  bottom: 0;
  font-size: 3rem;
}

/* Clouds */
@keyframes cloudMove {
  from { transform: translateX(-200vw); }
  to   { transform: translateX(200vw); }
}
.cloud {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  animation: cloudMove linear infinite;
}

/* Static sun & moon */
.static-sun, .static-moon {
  position: absolute;
  pointer-events: auto;
  font-size: 2.5rem;
  z-index: 3;
}
.static-sun { top: 1rem; left: 1rem; }
.static-moon { top: 1rem; right: 1rem; }

/* Midsummer sun */
.midsummer-sun {
  position: absolute;
  top: 3rem;
  left: 3rem;
  font-size: 4.5rem;
  z-index: 2;
  animation: sunspin 24s linear infinite;
}

/* Fireworks behind farm & sign */
@keyframes firework {
  0%   { opacity: 0; transform: scale(0.5) translateY(10px); }
  50%  { opacity: 1; transform: scale(1.2) translateY(0);    }
  100% { opacity: 0; transform: scale(0.5) translateY(-10px); }
}
.firework {
  position: absolute;
  font-size: 2.5rem;
  pointer-events: none;
  animation: firework 1.5s ease-in-out forwards;
  z-index: -2;
}

/* Rotate midsummer sun */
@keyframes sunspin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ─── April Fool’s ─────────────────────────────────────────── */
@keyframes foolBlink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.animal { /* reuse .animal */ }

/* ─── Valentine’s hearts ───────────────────────────────────── */
@keyframes heartFloat {
  0%   { transform: translateX(0) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(30vw) translateY(-100vh) scale(1.5); opacity: 0; }
}
.valentine-heart {
  position: absolute;
  bottom: 0;
  font-size: 1.5rem;
  animation-name: heartFloat;
  animation-duration: var(--heart-dur, 8s);  /* if you were using inline durations, you can fall back here */
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* ─── Falling leaves ───────────────────────────────────────── */
@keyframes leafFall {
  to {
    transform: translateY(100vh) rotate(360deg);
    /* opacity stays at whatever it was, so leaves never fade out */
  }
}
.falling-leaf {
  position: absolute;
  font-size: 1.5rem;
  animation: leafFall 8s linear forwards;
}

/* ─── Pet heart on click ──────────────────────────────────── */
@keyframes petPop {
  0%   { transform: translate(-50%,-150%) scale(0.5); opacity:1; }
  100% { transform: translate(-50%,-200%) scale(1.2); opacity:0; }
}
.pet-heart {
  position:absolute; pointer-events:none; font-size:1.5rem;
  animation: petPop 1s ease-out forwards;
}

/* ─── Starry night ────────────────────────────────────────── */
@keyframes starTwinkle {
  0%,100%{opacity:0; transform: scale(0.5);}
  50%     {opacity:1; transform: scale(1);}
}
.night-star {
  position: absolute;
  font-size: 1rem;
  color: #fff;
  animation: starTwinkle 2s ease-in-out forwards;
  z-index: -2;   /* under farm (#farm z=0) and signs */
}

/* ─── Pollinator sine-wave ───────────────────────────────── */
@keyframes sineFly {
  0%   { transform: translate(0,0) rotate(0deg); }
  25%  { transform: translate(25vw, -10vh) rotate(15deg); }
  50%  { transform: translate(50vw,   0vh) rotate(0deg);  }
  75%  { transform: translate(75vw,  10vh) rotate(-15deg);}
  100% { transform: translate(100vw,  0vh) rotate(0deg); }
}
.pollinator {
  position: absolute;
  left: 0;
  pointer-events: none;
  font-size: 1.5rem;
  animation-name: sineFly;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  /* duration & direction set inline */
  z-index: 2;    /* flight above sky but below clouds/signs */
}

/* ─── Halloween lightning & ghosts ───────────────────────── */
@keyframes flash {
  0%   { background: white; opacity:1; }
  20%  { opacity:0; }
  100% { opacity:0; }
}
.lightning-flash {
  position:fixed; inset:0; background:white; pointer-events:none;
  animation: flash 0.5s ease-out forwards;
  z-index: 10;
}
@keyframes ghostCreep {
  0%   { opacity:0; transform: translateX(-10vw); }
  10%  { opacity:1; }
  100% { transform: translateX(110vw); opacity:0; }
}
.ghost {
  position:absolute; top: calc(20% + 60vh * Math.random()); font-size:2rem;
  animation: ghostCreep 6s linear forwards;
  z-index:5;
}

/* ─── raindrops ───────────────────────────────────────────── */
@keyframes dropFall {
  to { transform: translateY(100vh); opacity: 0; }
}
.rain-drop {
  position: absolute;
  top: 0;
  font-size: 1rem;
  animation: dropFall 2s linear forwards;
  pointer-events: none;
  z-index: 2;
}

#ninjaTally {
  display: inline-block;
  width: 3ch;
  filter: blur(4px);
  transition: filter 0.3s ease; /* optional smoothing if you remove blur on hover */
}
