.village-scene {
  --swirl-y: 83.8%;
  --swirl-h: 10%;
  /* On narrow scenes, give the lower doors clearance while keeping the gumdrop in frame. */
  --gumdrop-y: clamp(82.1%, calc(73% + 23px), calc(100% - 24px));
  --gumdrop-h: 11%;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 240 / 139;
  border-radius: clamp(0.625rem, 2vw, 1.125rem);
  background: #342840;
  overflow: hidden;
  box-shadow:
    0 0 0 1px #ae858277,
    0 0 0 5px #1e1729,
    0 0 0 6px #ae858233,
    0 18px 35px -13px #130d1fcf;
}

.village-art {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.village-art .cookie-outline {
  stroke: #67404a;
  stroke-width: 2.3;
  stroke-linejoin: round;
}

.village-art .roof-hatching {
  fill: none;
  stroke: #edaf94;
  stroke-linecap: round;
  stroke-width: 1.4;
  opacity: 0.45;
}

.village-art .icing-line,
.village-art .house-snow {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.village-art .icing-line {
  stroke: #f9d8bd;
  stroke-width: 2;
}

.village-art .house-snow {
  stroke: #f5dfdf;
  stroke-width: 4;
}

.village-art .window-core,
.village-art .piece-glow,
.village-art .candy-sparkles {
  transition: opacity 240ms ease, fill 240ms ease;
}

.village-art .piece-glow {
  opacity: 0.29;
}

.village-art .ground-glow,
.village-art .candy-sparkles {
  opacity: 0.48;
}

.village-art [data-piece].is-collected {
  --pane-fill: #ffe5a6;
  --pane-opacity: 1;
}

.village-art .window-core {
  fill: var(--pane-fill, url(#window-light));
  opacity: var(--pane-opacity, 0.82);
}

.village-art [data-piece].is-collected .piece-glow,
.village-art [data-piece].is-collected .candy-sparkles {
  opacity: 1;
}

.village-scene > .collectible {
  appearance: none;
  display: block;
  position: absolute;
  z-index: 3;
  left: var(--x);
  top: var(--y);
  width: var(--hit-w);
  height: var(--hit-h);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 8%;
  background: transparent;
  box-shadow: none;
  color: #fff1cc;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.village-scene > .collectible--sweet {
  border-radius: 31%;
}

.village-scene > .collectible--swirl {
  --y: var(--swirl-y);
  --hit-h: var(--swirl-h);
}

.village-scene > .collectible--gumdrop {
  --y: var(--gumdrop-y);
  --hit-h: var(--gumdrop-h);
}

.village-scene > .collectible--above-swirl {
  --sweet-y: var(--swirl-y);
  --sweet-h: var(--swirl-h);
}

.village-scene > .collectible--above-gumdrop {
  --sweet-y: var(--gumdrop-y);
  --sweet-h: var(--gumdrop-h);
}

/* Keep the roof clickable first; trim the bottom where a sweet's 44px target comes close. */
.village-scene > :is(.collectible--above-swirl, .collectible--above-gumdrop) {
  --sweet-top: calc(var(--sweet-y) - max(22px, var(--sweet-h) / 2));
  --roof-top: calc(var(--y) - var(--hit-h) / 2);
  top: min(var(--roof-top), calc(var(--sweet-top) - 45px));
  height: min(var(--hit-h), calc(var(--sweet-top) - var(--roof-top) - 1px));
  transform: translateX(-50%);
}

.village-scene > .collectible:focus-visible {
  outline: 2px solid #fff5d7;
  outline-offset: 1px;
  box-shadow: 0 0 0 5px #301c35;
}

.village-scene .piece-marker {
  display: grid;
  place-items: center;
  position: absolute;
  left: var(--marker-x);
  top: var(--marker-y);
  width: clamp(0.875rem, 2vw, 1.5rem);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #ffe5b9;
  border-radius: 50%;
  background: #38233c;
  box-shadow: 0 1px 5px #25192989;
  pointer-events: none;
}

.village-scene .piece-marker::before {
  content: "";
  width: 45%;
  height: 53%;
  background: currentColor;
  clip-path: polygon(50% 0%, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0% 50%, 37% 37%);
}

.village-scene > .collectible.is-collected .piece-marker {
  border-color: #fff2c7;
  background: #ffe6ad;
  color: #402d43;
}

.village-scene > .collectible.is-collected .piece-marker::before {
  width: 41%;
  height: 24%;
  border: solid currentColor;
  border-width: 0 0 1.5px 1.5px;
  background: transparent;
  clip-path: none;
  transform: translateY(-15%) rotate(-45deg);
}

@media (max-width: 426px) {
  .village-scene > .collectible--gumdrop:focus-visible {
    outline-offset: 0;
  }
}

@media (hover: hover) {
  .village-scene > .collectible:hover .piece-marker {
    color: #402d43;
    background: #ffe6ad;
    box-shadow: 0 0 0 2px #4b2d46, 0 0 12px 3px #ffd07899;
  }
}

@media (prefers-reduced-motion: reduce) {
  .village-art .window-core,
  .village-art .piece-glow,
  .village-art .candy-sparkles {
    transition: none;
  }
}

@media (forced-colors: active) {
  .village-scene .piece-marker {
    forced-color-adjust: none;
  }

  .village-scene > .collectible:focus-visible {
    outline-color: Highlight;
  }
}
