.balance-page {
  color-scheme: light;
  color: #2f261e;
  background: #f3e4cc;
}
.balance-page::before { background: radial-gradient(ellipse at 48% 45%, #fff5e1, #e8d2b2 85%); }
.balance-header, .balance-game { width: min(calc(100% - 2rem), 45rem); margin-inline: auto; }
.balance-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .65rem 0; border-bottom: 1px solid #8a6d5255;
}
.balance-header .wordmark span, .balance-game h1 span { color: #974a2d; }
.balance-game { text-align: center; padding-block: 1.25rem 2rem; }
.balance-game h1 { padding: 0; font: 700 clamp(2.1rem, 6.4vw, 4.25rem)/1 Georgia, serif; letter-spacing: -.065em; }
.instructions { margin: .6rem auto .65rem; max-width: 44ch; color: #594332; }
.scale { --tilt: 0deg; position: relative; height: clamp(10.4rem, 29vw, 14rem); }
.scale-post {
  position: absolute; top: 5%; bottom: 13%; left: 50%; width: min(24%, 10rem); transform: translateX(-50%);
  background: url("art/scale-base.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 .28rem .2rem #57391f55);
}
.scale-beam {
  position: absolute; top: 19%; left: 13%; width: 74%; height: clamp(1rem, 2.8vw, 1.9rem);
  background: url("art/scale-beam.png") center / 100% 100% no-repeat;
  transform: rotate(var(--tilt)); transition: transform .93s cubic-bezier(.12,1.85,.44,1);
}
.hanger {
  position: absolute; top: 50%; width: clamp(4.25rem, 18vw, 7.5rem); height: clamp(4.7rem, 16vw, 6.6rem);
  transform: translateX(-50%) rotate(calc(-1 * var(--tilt))); transform-origin: top center;
  transition: transform .93s cubic-bezier(.12,1.85,.44,1);
}
.hanger-left { left: 4%; }
.hanger-right { left: 96%; }
.hanger::before, .hanger::after {
  content: ""; position: absolute; top: 0; left: 50%; width: 1px; height: 85%;
  background: #8a5b35; transform-origin: top; transform: rotate(26deg);
}
.hanger::after { transform: rotate(-26deg); }
.slot, .balance-footer button {
  font: 700 .875rem system-ui, sans-serif; cursor: pointer; color: #3b2c21;
}
.slot {
  position: relative; display: grid; place-items: center; min-width: 0;
  border: 1px dashed #ac8867; border-radius: .65rem; background: #fff4df;
  padding: .28rem; touch-action: none;
}
.slot.occupied { border-style: solid; }
.slot.selected { outline: 3px solid #9a4b2c; outline-offset: 2px; }
.slot:focus-visible, .balance-footer button:focus-visible { outline-color: #974a2d; }
.animal-figure {
  display: block; position: absolute; inset: .24rem; pointer-events: none; user-select: none;
  container-type: size;
}
.animal-figure[hidden] { display: none; }
.animal-rig {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  transform-origin: 50% 82%;
}
.animal-figure img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transform-origin: 50% 74%; pointer-events: none; user-select: none;
}
.animal-figure[data-animal="cat"] { --mouth-mask: radial-gradient(ellipse 11% 12% at 31% 40%, #000 66%, transparent 95%); }
.animal-figure[data-animal="duck"] { --mouth-mask: radial-gradient(ellipse 18% 15% at 25% 36%, #000 72%, transparent 98%); }
.animal-figure[data-animal="sheep"] { --mouth-mask: radial-gradient(ellipse 12% 12% at 25% 40%, #000 65%, transparent 95%); }
.animal-figure[data-animal="cow"] { --mouth-mask: radial-gradient(ellipse 15% 13% at 23% 44%, #000 68%, transparent 96%); }
.animal-figure .animal-mouth {
  opacity: 0;
  mask-image: var(--mouth-mask);
}
.animal-figure.calling .animal-rig {
  transform: rotate(var(--nod)) scaleY(calc(1 + var(--mouth) * .025));
}
.animal-figure.calling .animal-mouth { opacity: min(1, calc(var(--mouth) * 1.35)); }
.animal-figure:not([hidden]) + .slot-caption { display: none; }
.pan {
  position: absolute; bottom: 0; width: 100%; height: 78%; z-index: 1;
  border: 0; border-radius: .3rem .3rem 22% 22%;
  background: url("art/scale-pan.png") center bottom / 100% 43% no-repeat;
}
.pan .animal-figure { inset: -.38rem .22rem .4rem; }
.pan .slot-caption { align-self: end; margin-bottom: .35rem; font-size: .75rem; color: #472f1d; }
#scale-status {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.animal-shelf, .order-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(.35rem, 1.8vw, .8rem); }
.animal-shelf { margin-top: .5rem; }
.animal-shelf .slot, .order-slots .slot { aspect-ratio: 1.25; }
.animal-shelf .slot { background: #fff0d8; }
.answer-tray { margin-top: 1rem; padding: .55rem; border: 1px solid #b69a78; border-radius: .65rem; background: #dec4a1; }
.answer-tray p { display: flex; justify-content: space-between; margin: 0 0 .45rem; font-size: .8rem; font-weight: 750; }
.balance-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; margin-top: .85rem; }
.balance-footer button {
  min-height: 44px; padding: .5rem .85rem; border-radius: .35rem;
  border: 1px solid #ab8866; background: #fff1d9;
}
#check-order { color: #fff4df; background: #864329; border-color: #864329; }
.balance-footer p { flex-basis: 100%; min-height: 1.4em; margin: .35rem 0 0; color: #684632; }
.drag-animal {
  inset: auto; width: 82px; height: 82px; position: fixed; z-index: 9;
  pointer-events: none; transform: translate(-50%, -56%) rotate(-9deg);
  filter: drop-shadow(0 .3rem .38rem #2a1b1460);
}
.drag-source .animal-figure { opacity: .23; }
.slot.animating { z-index: 4; }
.slot.selected .animal-figure { transform: translateY(-5px) rotate(-3deg); }
.slot.selected .animal-figure:not(.calling) .animal-rig,
.drag-animal:not(.calling) .animal-rig {
  animation: figurine-breathe 1.45s ease-in-out infinite alternate;
}
@keyframes figurine-breathe {
  from { transform: rotate(-3deg) scaleY(.98); }
  to { transform: rotate(3deg) scaleY(1.045); }
}
@media (prefers-reduced-motion: reduce) {
  .scale-beam, .hanger { transition: none; }
  .slot.selected .animal-figure:not(.calling) .animal-rig,
  .drag-animal:not(.calling) .animal-rig { animation: none; }
}
