.balance-launch {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 52px);
  background: #fff6dc;
  padding: clamp(16px, 3vw, 32px);
  border: 1px solid #e4cf99;
  border-radius: 28px;
}
.balance-launch img { width: 100%; height: auto; border-radius: 18px; display: block; }
.balance-launch h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.5rem); }
.balance-launch p { margin: .55em 0 1em; }
.balance-game {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 10px clamp(8px, 2vw, 24px);
  box-sizing: border-box;
  background: #fff8e6;
}
.balance-game[hidden] { display: none; }
.balance-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
}
.balance-tools { display: flex; gap: 6px; }
.balance-tools button, .balance-tray button {
  font: inherit;
  font-weight: 800;
  color: #173d31;
  border: 1px solid #d1ba83;
  border-radius: 12px;
  background: #fffdf6;
  min-height: 44px;
  cursor: pointer;
}
.balance-tools button { padding: 0 10px; white-space: nowrap; }
.balance-tools button:disabled { opacity: .45; cursor: default; }
.balance-count {
  min-width: 54px;
  padding: 6px 10px;
  border-radius: 20px;
  text-align: center;
  background: #204f3a;
  color: white;
  font-variant-numeric: tabular-nums;
}
.balance-steady { text-align: center; color: #226042; }
.balance-steady[data-tone="wobble"] { color: #8b480c; }
.balance-steady[data-tone="tilt"] { color: #8c3128; }
.balance-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  container-type: size;
  overflow: hidden;
  touch-action: none;
  border: 2px solid #b2b776;
  border-radius: 24px;
  background: linear-gradient(#bddc98, #a6c46c);
  cursor: crosshair;
}
.balance-ready .balance-stage {
  background: linear-gradient(#fff3cf15, #14382324), url('/assets/animal-balance/zoo-lawn.webp') center 60% / cover;
}
.balance-retry {
  position: absolute;
  z-index: 4;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 12px;
  display: grid;
  gap: 7px;
  text-align: center;
  color: #173d31;
  background: #fff8e6;
  border: 2px solid #b19a65;
  border-radius: 18px;
  box-shadow: 0 6px 15px #23311b48;
}
.balance-retry[hidden] { display: none; }
.balance-retry h2 { margin: 0; font-size: 1.2rem; }
.balance-retry button {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid #c7af77;
  font: inherit;
  font-weight: 900;
  color: #173d31;
  background: #fffdf6;
  cursor: pointer;
  touch-action: manipulation;
}
.balance-retry [data-balance-retry] { background: #ffcf62; border-color: #b76d19; }
.balance-tumbled .balance-status { opacity: 0; }
.balance-stage:focus-visible { outline: 3px solid #a95500; outline-offset: 2px; }
.balance-animal-name {
  position: absolute;
  z-index: 1;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 1px 16px 3px;
  border: 2px solid #ffd674;
  border-radius: 20px;
  background: #fff8e6;
  color: #174c33;
  font: inherit;
  font-size: clamp(1.125rem, 4vw, 1.5rem);
  font-weight: 900;
  line-height: 1.1;
  pointer-events: none;
}
.balance-animal-name:empty { display: none; }
.balance-scene { display: block; margin-top: 38px; width: min(100cqw, calc((100cqh - 38px) * 400 / 350)); height: auto; aspect-ratio: 400 / 350; pointer-events: none; }
.balance-tower > svg { filter: drop-shadow(0 2px 1px #352b1980); }
.balance-tower { transform-origin: 200px 318px; }
.balance-tower.is-wobbly { animation: balance-wobble 320ms ease-in-out 2 alternate; }
.balance-effects {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.balance-fall-group { position: absolute; inset: 0; }
.balance-screen-sprite {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px #352b1970);
}
.balance-screen-sprite svg { display: block; }
.balance-held { transform: translate(-50%, -50%); }
.balance-page .game-reward { z-index: 4; }
.balance-guides line { stroke: white; stroke-width: 2.5; stroke-dasharray: 4 4; stroke-linecap: round; }
.balance-ghost { opacity: .55; filter: drop-shadow(0 0 3px #fff); }
.balance-ghost.off-centre { opacity: .33; }
.balance-tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.balance-tray button {
  min-width: 0;
  padding: 2px 3px 4px;
  touch-action: none;
  display: grid;
  grid-template-rows: 39px auto;
  place-items: center;
  line-height: 1.15;
  font-size: clamp(9px, 2.6vw, 15px);
}
.balance-tray button svg { width: 100%; height: 100%; max-width: 90px; }
.balance-tray button[aria-pressed=true] { background: #ffdf86; border-color: #995718; box-shadow: inset 0 0 0 2px #b36c23; }
.balance-tray button:disabled { cursor: default; opacity: .58; }
.balance-tray .is-stacked { background: #e4eed9; }
.balance-status {
  margin: 0;
  min-height: 2.35em;
  line-height: 1.17;
  text-align: center;
  font-weight: 800;
  font-size: clamp(12px, 2.8vw, 16px);
}
.balance-page .play-header button[aria-label="Age, challenge and music settings"] { display: none; }
@keyframes balance-wobble { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
@media (max-width: 650px) {
  .balance-launch { grid-template-columns: 1fr; }
  .balance-game { padding: 7px 6px; gap: 6px; }
  .balance-stage { border-radius: 14px; }
}
@media (orientation: landscape) and (max-height: 580px) {
  .balance-game { grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr) minmax(180px, 27%); }
  .balance-toolbar { grid-column: 1 / -1; }
  .balance-tray { grid-column: 2; grid-row: 2; align-self: center; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balance-status { grid-column: 1 / -1; }
  .balance-tray button { grid-template-rows: 24px auto; }
}
@media (prefers-reduced-motion: reduce) {
  .balance-tower { animation: none !important; }
}
