/* Pooper Scooper — loaded only on /game */

.pg {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
  max-width: 1000px;
  margin: 0 auto;
}

/* ---- HUD ---- */
.pg-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: .5rem;
  align-items: stretch;
}
.pg-stat {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "ico lbl" "ico val";
  column-gap: .55rem;
  align-items: center;
  padding: .55rem .8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.pg-ico { grid-area: ico; font-size: 1.45rem; line-height: 1; }
.pg-lbl {
  grid-area: lbl;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.pg-val {
  grid-area: val;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--ink);
}
.pg-val small { font-size: .8rem; color: var(--ink-soft); font-family: 'Inter', sans-serif; font-weight: 600; }
.pg-bagbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: rgba(0,0,0,.05);
}
.pg-bagbar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #f59e0b);
  transition: width .15s ease;
}
.pg-stat-bag.is-full { border-color: #f59e0b; background: #fff7e6; }
.pg-stat-bag.is-full .pg-bagbar span { background: #ef4444; }
.pg-stat.is-nudge { animation: pgNudge .35s ease; }
.pg-stat.is-low { border-color: #fca5a5; background: #fff1f1; }
.pg-stat.is-low .pg-val { color: #dc2626; animation: pgPulse 1s ease-in-out infinite; }
.pg-mute {
  width: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  font-size: 1.3rem;
  cursor: pointer;
  transition: background .15s ease;
}
.pg-mute:hover { background: var(--accent-soft); }

.pg-timebar {
  height: 6px;
  margin: .6rem 0 .75rem;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.pg-timebar span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #84cc16);
  transition: width .1s linear;
}
.pg-timebar.is-low span { background: linear-gradient(90deg, #ef4444, #f97316); }

/* ---- field ---- */
.pg-field {
  position: relative;
  height: clamp(380px, 54vw, 520px);
  border-radius: 16px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.pg-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pg-props { position: absolute; inset: 0; pointer-events: none; }
.pg-prop { position: absolute; display: block; overflow: visible; }
.pg-sun { right: 4%; top: 1%; width: clamp(80px, 13%, 130px); }
.pg-cloud { left: 10%; top: 6%; width: clamp(80px, 14%, 140px); animation: pgCloud 38s ease-in-out infinite alternate; }
.pg-cloud-2 { left: 50%; top: 3%; width: clamp(60px, 10%, 100px); animation-duration: 52s; animation-direction: alternate-reverse; }
/* horizon props sit on the treeline at 36% */
.pg-trees, .pg-spire { top: 36.5%; transform: translate(-50%, -100%); }
.pg-trees-1 { left: 8%; width: clamp(64px, 11%, 110px); }
.pg-trees-2 { left: 33%; width: clamp(46px, 7%, 72px); }
.pg-spire { left: 46%; width: clamp(14px, 2%, 20px); }
.pg-trees-3 { left: 63%; width: clamp(60px, 10%, 100px); }
.pg-trees-4 { left: 95%; width: clamp(46px, 8%, 76px); }
.pg-pond { left: 19%; top: 47%; width: clamp(110px, 20%, 170px); transform: translate(-50%, -50%); }
.pg-bench { left: 76%; top: 43%; width: clamp(40px, 7%, 60px); transform: translate(-50%, -100%); }
.pg-sign { left: 88%; top: 44%; width: clamp(64px, 9.5%, 92px); transform: translate(-50%, -100%); }
.pg-flower { position: absolute; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1.6px #ffd54a; }
.pg-flower.is-pink { background: #f472b6; box-shadow: none; }
.pg-layer { position: absolute; inset: 0; }
.pg-field.is-shake { animation: pgShake .35s ease; }

/* dogs */
.pg-dog {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -85%);
  pointer-events: none;
  font-size: clamp(30px, 4.4vw, 42px);
  line-height: 1;
}
.pg-dog::after { /* shadow */
  content: '';
  position: absolute;
  left: 15%; right: 15%; bottom: -3px;
  height: 7px;
  border-radius: 50%;
  background: rgba(0,0,0,.16);
  z-index: -1;
}
.pg-dog-body {
  display: block;
  transform: scaleX(var(--dir, 1));
  animation: pgTrot .32s ease-in-out infinite alternate;
}
.pg-dog.is-leaving { opacity: 0; transition: opacity .35s ease; }

/* poo */
.pg-poo {
  position: absolute;
  z-index: 1;
  width: 50px;
  height: 50px;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  font-size: clamp(24px, 3.2vw, 30px);
  line-height: 1;
  animation: pgDrop .32s cubic-bezier(.3, 1.6, .5, 1) both;
}
.pg-poo:focus-visible { outline: 3px solid #fff; outline-offset: -4px; }
.pg-poo-emoji {
  display: block;
  filter: drop-shadow(0 3px 1px rgba(0,0,0,.2));
  transition: transform .1s ease;
}
.pg-poo:hover .pg-poo-emoji { transform: scale(1.14); }
/* steam off a fresh one */
.pg-poo::before {
  content: '';
  position: absolute;
  left: 50%; top: 4px;
  width: 8px; height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  filter: blur(2px);
  opacity: 0;
  animation: pgSteam 1.4s ease-out infinite;
}
.pg-poo.is-stinky::before { display: none; }
.pg-poo.is-stinky .pg-poo-emoji {
  filter: drop-shadow(0 3px 1px rgba(0,0,0,.2)) hue-rotate(55deg) saturate(.75) brightness(.95);
  animation: pgWobble .5s ease-in-out infinite;
}
.pg-poo.is-stinky::after {
  content: '🪰';
  position: absolute;
  left: 50%; top: 50%;
  font-size: 13px;
  animation: pgFly .9s linear infinite;
  pointer-events: none;
}
.pg-poo.is-gold .pg-poo-emoji {
  filter: drop-shadow(0 0 6px rgba(255, 214, 10, .95)) sepia(1) saturate(5) hue-rotate(5deg) brightness(1.2);
}
.pg-poo.is-gold::before {
  content: '✨';
  background: none;
  filter: none;
  width: auto; height: auto;
  left: 62%; top: -2px;
  font-size: 15px;
  opacity: 1;
  animation: pgTwinkle 1s ease-in-out infinite;
}
.pg-poo.is-fading { opacity: .55; transition: opacity 2s linear; }
.pg-poo.is-bagged { pointer-events: none; animation: pgBag .26s ease-in forwards; }
.pg-poo.is-fined { pointer-events: none; animation: pgFined .5s ease-out forwards; }
.pg-poo.is-gone { pointer-events: none; opacity: 0; transition: opacity .35s ease; }

/* bin */
.pg-bin {
  position: absolute;
  z-index: 3;
  right: 1.5%;
  bottom: 2%;
  width: clamp(64px, 8.5vw, 84px);
  aspect-ratio: 64 / 84;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.18));
  transition: transform .12s ease;
}
.pg-bin svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pg-bin:hover { transform: translateY(-2px); }
.pg-bin:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 10px; }
.pg-bin-lid { transform-box: fill-box; transform-origin: 0% 100%; }
.pg-bin.is-open .pg-bin-lid { animation: pgLid .45s ease; }
.pg-bin.is-open .pg-bin-body { animation: pgGulp .45s ease; transform-box: fill-box; transform-origin: 50% 100%; }
.pg-bin.is-nudge { animation: pgNudge .35s ease; }
.pg-bin.has-bag { animation: pgBeckon 1.2s ease-in-out infinite; }
.pg-bin[data-count]::after {
  content: attr(data-count);
  position: absolute;
  top: -6px;
  left: -8px;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background: #1f2937;
  color: #fff;
  border: 2px solid #fff;
  font: 700 .8rem/22px 'Inter', sans-serif;
  text-align: center;
}

/* floating text + particles */
.pg-float {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  pointer-events: none;
  font: 700 .95rem 'Inter', sans-serif;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6), 0 0 6px rgba(0,0,0,.35);
  animation: pgFloat .9s ease-out forwards;
}
.pg-float.is-score { font-size: 1.4rem; color: #fff; }
.pg-float.is-combo {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  color: #fde047;
  text-shadow: 0 2px 0 #b45309, 0 3px 8px rgba(0,0,0,.35);
  transform-origin: center;
  animation: pgCombo 1s ease-out forwards;
}
.pg-float.is-gold { color: #fde047; font-size: 1.15rem; text-shadow: 0 1px 0 #92400e, 0 2px 6px rgba(0,0,0,.35); }
.pg-float.is-bad { color: #fff; background: #dc2626; padding: .15rem .5rem; border-radius: 999px; text-shadow: none; font-size: .85rem; }
.pg-float.is-warn { color: #1f2937; background: #fde68a; padding: .15rem .55rem; border-radius: 999px; text-shadow: none; font-size: .8rem; }
.pg-spark {
  position: absolute;
  z-index: 3;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  pointer-events: none;
  animation: pgSpark .6s ease-out forwards;
}
.pg-confetti-wrap { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.pg-confetti {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  pointer-events: none;
  animation: pgConfetti 2.2s cubic-bezier(.25,.6,.45,1) forwards;
}

/* ---- overlay: intro / countdown / results ---- */
.pg-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(15, 23, 42, .35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.pg-overlay[hidden] { display: none; }
.pg-overlay.is-count { background: rgba(15, 23, 42, .15); backdrop-filter: none; -webkit-backdrop-filter: none; }
.pg-count {
  font-family: 'Fraunces', serif;
  font-weight: 800;
  font-size: clamp(4rem, 14vw, 7.5rem);
  color: #fff;
  text-shadow: 0 4px 0 rgba(30, 64, 175, .9), 0 10px 30px rgba(0,0,0,.3);
  animation: pgCount .6s cubic-bezier(.3, 1.5, .5, 1) both;
}
.pg-panel {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  margin: auto;
  padding: 1.5rem 1.4rem 1.3rem;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 50px -15px rgba(15, 23, 42, .45);
  text-align: center;
  animation: pgPanel .35s cubic-bezier(.3, 1.3, .5, 1) both;
}
.pg-kicker {
  margin: 0 0 .25rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.pg-title {
  margin: 0 0 .9rem;
  font-size: clamp(1.5rem, 3.5vw, 1.9rem);
  line-height: 1.15;
}
.pg-rules {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: grid;
  gap: .45rem;
  text-align: left;
}
.pg-rules li {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .45rem .7rem;
  background: var(--bg);
  border-radius: 12px;
  font-size: .9rem;
  color: var(--ink-soft);
  line-height: 1.35;
}
.pg-rule-ico { font-size: 1.35rem; flex-shrink: 0; width: 1.6rem; text-align: center; }
.pg-rules b { color: var(--ink); }
.pg-diff {
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--bg);
}
.pg-diff label { position: relative; cursor: pointer; }
.pg-diff input { position: absolute; opacity: 0; pointer-events: none; }
.pg-diff span {
  display: block;
  padding: .4rem 1rem;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.pg-diff label:hover span { color: var(--accent-dark); }
.pg-diff input:checked + span { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 3px rgba(16,24,40,.15); }
.pg-diff input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.pg-hint { margin: .5rem 0 1rem; font-size: .82rem; color: var(--ink-soft); }
.pg-go { width: 100%; justify-content: center; font-size: 1.05rem; padding-block: .8rem; }
.pg-rank { font-size: 3.4rem; line-height: 1; margin-bottom: .4rem; animation: pgRank .7s cubic-bezier(.3, 1.6, .5, 1) both .1s; }
.pg-final { margin: 0; color: var(--ink-soft); font-weight: 600; }
.pg-final span {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-dark);
}
.pg-badge {
  display: inline-block;
  margin: .7rem 0 0;
  padding: .3rem .8rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  font-size: .88rem;
}
.pg-overlay.is-results .pg-hint { margin: .6rem 0 0; }
.pg-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
  margin: 1rem 0 .6rem;
}
.pg-stats div { padding: .5rem .2rem; background: var(--bg); border-radius: 12px; }
.pg-stats dt { font-size: .62rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.pg-stats dd { margin: 0; font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.pg-quip { margin: 0 0 1rem; font-size: .9rem; color: var(--ink-soft); font-style: italic; }
.pg-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }
.pg-btns .btn { justify-content: center; white-space: nowrap; padding-inline: .8rem; }
.pg-help { margin: .8rem .25rem 0; opacity: .8; }
.pg-help kbd {
  font: 600 .75rem 'Inter', sans-serif;
  padding: .05rem .35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
}

@media (max-width: 640px) {
  .pg { padding: .6rem; border-radius: 16px; }
  .pg-hud { grid-template-columns: repeat(4, minmax(0, 1fr)) 40px; gap: .3rem; }
  .pg-stat { grid-template-columns: 1fr; grid-template-areas: "lbl" "val"; padding: .4rem .45rem .5rem; text-align: center; border-radius: 12px; }
  .pg-ico { display: none; }
  .pg-lbl { font-size: .64rem; }
  .pg-val { font-size: 1.15rem; }
  .pg-mute { width: 40px; font-size: 1.1rem; border-radius: 12px; }
  .pg-field { height: min(72vh, 520px); border-radius: 12px; }
  .pg-panel { padding: 1.1rem 1rem 1rem; }
  .pg-rules li { font-size: .82rem; padding: .35rem .55rem; }
  .pg-stats { gap: .3rem; margin: .8rem 0 .5rem; }
  .pg-stats dt { font-size: .54rem; letter-spacing: .03em; }
  .pg-stats dd { font-size: 1.1rem; }
  .pg-rank { font-size: 2.4rem; margin-bottom: .2rem; }
  .pg-final span { font-size: 2.5rem; }
  .pg-title { margin-bottom: .6rem; }
  .pg-overlay.is-results .pg-quip { display: none; }
  .pg-btns { margin-top: .7rem; }
  .pg-sign { top: 40%; }
  .pg-bench { left: 70%; }
}

/* ---- keyframes ---- */
@keyframes pgTrot { from { transform: scaleX(var(--dir, 1)) translateY(0) rotate(-3deg); } to { transform: scaleX(var(--dir, 1)) translateY(-4px) rotate(3deg); } }
@keyframes pgDrop { from { transform: translate(-50%, -110%) scale(.3); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes pgSteam { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.6); } 30% { opacity: .8; } 100% { opacity: 0; transform: translate(-50%, -18px) scale(1.4); } }
@keyframes pgWobble { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes pgFly { from { transform: rotate(0deg) translateX(20px) rotate(0deg); } to { transform: rotate(360deg) translateX(20px) rotate(-360deg); } }
@keyframes pgTwinkle { 0%, 100% { transform: scale(.7) rotate(0deg); opacity: .6; } 50% { transform: scale(1.15) rotate(20deg); opacity: 1; } }
@keyframes pgBag { to { transform: translate(-50%, -50%) scale(.2) translateY(-30px); opacity: 0; } }
@keyframes pgFined { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.4); filter: drop-shadow(0 0 8px #ef4444); } 100% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
@keyframes pgFloat { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(-50%, calc(-50% - 36px)); opacity: 0; } }
@keyframes pgCombo { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; } 60% { transform: translate(-50%, calc(-50% - 16px)) scale(1); opacity: 1; } 100% { transform: translate(-50%, calc(-50% - 44px)) scale(1); opacity: 0; } }
@keyframes pgSpark { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
@keyframes pgConfetti { to { transform: translate(var(--x), 560px) rotate(var(--r)); opacity: .9; } }
@keyframes pgLid { 0%, 100% { transform: rotate(0deg); } 35% { transform: rotate(-38deg); } }
@keyframes pgGulp { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.08, .92); } 70% { transform: scale(.96, 1.05); } }
@keyframes pgBeckon { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes pgNudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pgShake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }
@keyframes pgPulse { 50% { transform: scale(1.12); } }
@keyframes pgCloud { from { transform: translateX(-30px); } to { transform: translateX(60px); } }
@keyframes pgCount { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pgPanel { from { transform: translateY(14px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pgRank { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0deg); } }

@media (prefers-reduced-motion: reduce) {
  .pg-cloud, .pg-dog-body, .pg-poo::before, .pg-poo.is-stinky .pg-poo-emoji, .pg-bin.has-bag, .pg-stat.is-low .pg-val { animation: none; }
}
