.sound-select, .sound-results { display: grid; gap: var(--space-2); }
.sound-scene, .sound-count-stage, .sound-result-scene {
  background: var(--surface-2) var(--sound-art) center top / 100% auto no-repeat;
}
.sound-scene {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  container-type: inline-size;
  border-radius: var(--r-card);
  border: 1px solid var(--mg-key-line);
  isolation: isolate;
}
.sound-round { display: grid; grid-template-rows: minmax(320px, 1fr); }
.sound-select .sound-scene {
  container-type: size;
  max-height: max(320px, calc(100dvh - 236px - var(--safe-t) - var(--safe-b)));
  background-size: 100% calc(100% * 32 / 27);
}
@media (max-height: 740px) {
  .sound-select .sound-scene {
    width: 100%;
    max-height: max(280px, calc(100dvh - 313px - var(--safe-t) - var(--safe-b)));
  }
}
@media (max-height: 640px) {
  .sound-select .sound-scene { aspect-ratio: auto; height: max(280px, calc(100dvh - 313px - var(--safe-t) - var(--safe-b))); }
}
.sound-round .sound-scene {
  aspect-ratio: auto;
  container-type: size;
  /* Keep the original crop and scale its landmarks with the play area. */
  background-size: 100% calc(100% * 32 / 27);
  --sound-stage-unit: calc(100cqh / 150);
  --sound-lower-rail: min(calc(119 * var(--sound-stage-unit)), calc(100% - 89px));
}
.sound-round .sound-scene::before {
  content: '';
  position: absolute;
  inset: 52.7% 8.3% 16.5%;
  pointer-events: none;
  clip-path: polygon(0 0, 10% 4%, 25% 7%, 40% 8%, 60% 8%, 75% 7%, 90% 4%, 100% 0, 100% 100%, 0 100%);
  clip-path: shape(from 0 0, curve to 100% 0 with 23% 11% / 77% 11%,
    line to 100% 100%, line to 0 100%, close);
  background:
    radial-gradient(ellipse 70% 28% at 50% 0%, #2d1a2be0 18%, transparent 84%),
    repeating-linear-gradient(94deg, #3e263e65 0, #bf7b752b 12px, transparent 22px, #3e263e65 36px),
    radial-gradient(ellipse at 51% 35%, #8a565a, #4c2c40 84%);
}
.sound-doki {
  position: absolute;
  z-index: 3;
  right: 2%;
  bottom: 0;
}
.sound-doki > .mg-doki { display: block; width: 130px; height: 130px; }
.sound-select > small {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.sound-total, .sound-greeting, .sound-call, .sound-counter {
  color: var(--ivory);
  background: var(--color-plum-black);
}
.sound-total, .sound-call, .sound-greeting {
  position: absolute;
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-weight: 800;
}
.sound-total { top: var(--space-2); right: var(--space-2); color: #ffe093; }
.sound-greeting { z-index: 4; bottom: var(--space-2); left: 6%; }
.sound-stages {
  position: absolute;
  inset: 53.333% 8% auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: max(44px, 9.1cqh);
  align-items: end;
  gap: 0 var(--space-1);
}
.sound-stages button {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 44px;
  background: #35212d;
  border: 1px solid #aa7577;
  border-radius: var(--r-md);
  color: #fff3dc;
  font: 800 var(--text-sm)/1.1 var(--mg-digits);
  touch-action: manipulation;
}
.sound-stages button > span { font: 700 12px/1.1 system-ui, sans-serif; }
.sound-stages button[aria-pressed="true"] { background: #ffe093; border-color: #ffe093; color: #382130; }
.sound-stages button:disabled { background: #261924; color: #e0c9bc; }
.sound-count-stage { position: absolute; inset: 0; }
.sound-count-stage .sound-doki { bottom: max(8%, calc(100% - 145cqw)); }
[data-game="sound"] .mg-count-stage::after { background: rgb(19 8 23 / .39); }

.sound-listen-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgb(25 8 27 / .23);
  opacity: 0;
  transition: opacity .12s;
}
.sound-scene[data-state="listen"] .sound-listen-shade { opacity: 1; }
.sound-scene[data-state="listen"] .sound-doki::after {
  content: '';
  position: absolute;
  inset: 21% 17% auto auto;
  width: 19px;
  height: 19px;
  border: 3px solid transparent;
  border-right-color: #ffe093;
  border-radius: 50%;
  box-shadow: 5px -3px 0 -3px #ffe093;
  transform: rotate(-28deg);
}

.sound-bulbs, .sound-prizes, .sound-rails { position: absolute; inset: 0; pointer-events: none; }
.sound-bulbs i {
  position: absolute;
  width: clamp(11px, 4cqw, 18px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #fff4c7;
  box-shadow: 0 0 5px 2px #ffb83caa;
  opacity: 0;
}
.sound-scene[data-final] .sound-bulbs i { animation: sound-bulb .56s ease-in-out infinite alternate; }
.sound-scene[data-final] .sound-bulbs i:nth-child(even) { animation-direction: alternate-reverse; }
@keyframes sound-bulb { from { opacity: .13; } to { opacity: .82; } }

.sound-prizes i {
  position: absolute;
  color: #fff1a7;
  font: 800 clamp(16px, 5.5cqw, 25px)/1 system-ui, sans-serif;
  text-shadow: 0 0 8px #ffac46;
  opacity: 0;
}
.sound-prizes i:nth-child(1) { top: calc(52 * var(--sound-stage-unit)); left: 17%; }
.sound-prizes i:nth-child(2) { top: calc(47 * var(--sound-stage-unit)); left: 40%; }
.sound-prizes i:nth-child(3) { top: calc(58 * var(--sound-stage-unit)); left: 58%; }
.sound-prizes i:nth-child(4) { top: calc(51 * var(--sound-stage-unit)); left: 80%; }
.sound-prizes i:nth-child(5) { top: calc(70 * var(--sound-stage-unit)); left: 34%; }
.sound-scene[data-state="focus"] .sound-prizes i:nth-child(odd) { animation: sound-sparkle .82s ease-in-out infinite alternate; }
.sound-scene[data-outcome="hit"] .sound-prizes i:nth-child(odd) { animation: sound-sparkle .64s ease-out 2 alternate; }
.sound-prizes i:nth-child(even) { animation-delay: .12s !important; }
@keyframes sound-sparkle { from { opacity: .28; scale: .7; } to { opacity: 1; scale: 1; } }

.sound-target {
  /* The transparent padding around the disc takes up about 30% of the artwork. */
  --target-size: clamp(108px, 32.5cqw, 120px);
  --hit-height: calc(var(--target-size) * .92);
  --rail: calc(var(--sound-lower-rail) - max(32 * var(--sound-stage-unit), var(--hit-height) + 3px));
  position: absolute;
  top: var(--rail);
  left: 29%;
  z-index: 1;
  width: var(--target-size);
  min-width: 56px;
  height: var(--hit-height);
  min-height: 56px;
  padding: 0;
  margin-top: calc(-1 * var(--hit-height));
  border: 0;
  border-radius: var(--r-md);
  background: none;
  translate: -50% 0;
  pointer-events: auto;
  touch-action: manipulation;
}
.sound-target:nth-child(2) { left: 70%; }
.sound-target:nth-child(3) { left: 43%; --rail: var(--sound-lower-rail); }
.sound-target-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: block;
  transform-origin: center 94%;
  background: var(--sound-target) center / 100% auto no-repeat;
}
.sound-target.is-gold .sound-target-art { background-image: var(--sound-gold); }
.sound-target b, .sound-target small { position: absolute; left: 50%; translate: -50% -50%; white-space: nowrap; }
.sound-target b {
  top: 42.5%;
  color: #382130;
  font: 900 clamp(28px, 8.5cqw, 36px)/1 var(--font-ui-title), var(--f-ko);
}
.sound-target b.is-long { font-size: 28px; }
.sound-target small {
  top: 94%;
  max-width: 126%;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--r-sm);
  padding: 0 3px;
  color: #fff6e4;
  background: var(--color-plum-black);
  font: 700 12px/1.25 var(--f-ja);
}
.sound-target[aria-disabled="true"] { pointer-events: none; }
.sound-target.is-answer:not(.is-hit) .sound-target-art { filter: drop-shadow(0 0 5px #ffdb79); }
.sound-target.is-miss .sound-target-art { animation: sound-target-miss .32s ease-out both; }
.sound-target.is-hit .sound-target-art { animation: sound-target-hit .45s cubic-bezier(.25,.76,.36,1) both; }
.sound-scene[data-state="fluster"]:not([data-outcome]) .sound-target:nth-child(3) .sound-target-art { animation: sound-target-wobble .33s ease-in-out infinite alternate; }
@keyframes sound-target-miss { 24%, 69% { rotate: -10deg; } 46%, 85% { rotate: 8deg; } }
@keyframes sound-target-wobble { from { rotate: -2.5deg; } to { rotate: 2.5deg; } }
@keyframes sound-target-hit {
  24% { transform: perspective(150px) rotateX(30deg) rotateY(-8deg); }
  57%, 100% { transform: perspective(150px) rotateX(79deg) rotateY(-14deg); }
  76% { transform: perspective(150px) rotateX(71deg) rotateY(-14deg); }
}
.sound-aim {
  z-index: 4;
  position: absolute;
  pointer-events: none;
  width: 32px;
  height: 32px;
  translate: -50% -50%;
  border: 2px solid #fff4b9;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #3b172c, inset 0 0 0 1px #3b172c;
  background: linear-gradient(#fff4b9, #fff4b9) center / 2px 9px no-repeat,
    linear-gradient(#fff4b9, #fff4b9) center / 9px 2px no-repeat;
}
.sound-scene[data-outcome="hit"] .sound-aim { animation: sound-aim .45s ease-out both; }
.sound-scene[data-outcome="miss"] .sound-aim { border-color: #ffadac; }
@keyframes sound-aim { 25% { scale: .72; } 100% { scale: 1.08; opacity: .55; } }
.sound-window {
  position: absolute;
  top: calc(var(--sound-lower-rail) + 3 * var(--sound-stage-unit));
  left: 9%;
  width: 42%;
  height: 5px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: #321f2a;
}
.sound-window i {
  display: block;
  height: 100%;
  background: #ffe093;
  transform-origin: left;
}
.sound-call {
  z-index: 4;
  bottom: 122px;
  right: 11px;
  max-width: 126px;
  margin: 0;
  background: #fff1d9;
  color: #492b35;
}
.sound-call::after {
  content: ''; position: absolute; top: 100%; right: 34px;
  border: 6px solid transparent; border-top-color: #fff1d9;
}
.sound-scene[data-outcome="miss"] .sound-doki { animation: sound-doki-miss .46s ease-out both; }
@keyframes sound-doki-miss {
  18%, 54%, 82% { transform: translateX(-6px) rotate(-4deg); }
  36%, 70% { transform: translateX(6px) rotate(4deg); }
}
.sound-call:empty { display: none; }
.sound-counter {
  position: absolute;
  bottom: max(6px, 1.2cqw);
  left: 4%;
  right: max(131px, 36%);
  padding: 3px 7px;
  border: 1px solid #85585c;
  border-radius: var(--r-md);
}
.sound-audio { min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sound-wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.sound-wave i { width: 3px; height: 6px; border-radius: var(--r-pill); background: #ffda93; }
.sound-wave i:nth-child(even) { height: 12px; }
.sound-wave i:nth-child(3) { height: 17px; }
[data-listening] .sound-wave i { animation: sound-wave .42s ease-in-out infinite alternate; }
[data-listening] .sound-wave i:nth-child(even) { animation-direction: alternate-reverse; }
@keyframes sound-wave { from { scale: 1 .6; } to { scale: 1 1.22; } }
.sound-fallback, .sound-combo, .sound-feedback { color: var(--ivory); font-size: 12px; font-weight: 800; }
.sound-fallback small, .sound-feedback small { font-size: inherit; }
.sound-fallback b, .sound-feedback b { color: #ffe093; font: 900 16px/1.2 var(--f-ko); }
.sound-combo { white-space: nowrap; margin-inline-start: auto; color: #ffda93; }
.sound-feedback:has(span:empty):has(b:empty):has(small:empty) { display: none; }
.sound-feedback { margin: 0; line-height: 1.35; color: #ffe093; }
.sound-feedback.is-miss span { color: #ffd0ca; }
.sound-feedback.is-miss b { white-space: nowrap; }
.sound-feedback small { color: var(--ivory); }
[data-game="sound"] .mg-combo { display: none; }

.sound-result-scene {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-card);
  background-image: linear-gradient(rgb(26 12 24 / .31), rgb(26 12 24 / .85) 81%), var(--sound-art);
  background-position: center, center 27%;
}
.sound-result-summary { display: grid; justify-items: center; align-content: center; gap: 4px; }
.sound-result-doki { position: relative; width: 126px; height: 126px; }
.sound-result-doki img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sound-gold-headband {
  position: absolute;
  inset: 0;
  filter: sepia(1) saturate(3) brightness(1.21) hue-rotate(356deg);
  clip-path: polygon(27% 33%, 37% 26%, 48% 22%, 54% 23%, 56% 18%, 61% 21%, 66% 17%, 71% 18%, 70% 22%, 74% 25%, 72% 29%, 66% 27%, 64% 30%, 60% 26%, 54% 26%, 47% 26%, 38% 29%, 29% 36%);
}
.sound-result-doki[data-pose="oops"] .sound-gold-headband {
  clip-path: polygon(27% 32%, 29% 27%, 39% 22%, 46% 19%, 59% 20%, 63% 15%, 69% 18%, 68% 22%, 73% 23%, 72% 27%, 67% 28%, 63% 25%, 58% 26%, 48% 23%, 40% 24%, 32% 29%, 29% 35%);
}
.sound-result-doki > i {
  position: absolute;
  top: 23%;
  left: 69%;
  color: #fff4af;
  font: 900 22px/1 system-ui, sans-serif;
  text-shadow: 0 0 8px #ffb83c;
  animation: sound-sparkle .72s infinite alternate;
}
.sound-results .mg-result-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sound-result-scene :is(.sound-outcome, .mg-stars, .mg-result-score) {
  background: #231624e8;
  border-radius: var(--r-pill);
  padding: 4px 12px;
}
.sound-result-scene .mg-stars { margin-block: 3px; }
.sound-outcome { margin: 0; color: #fff2cc; font: 800 var(--text-lg)/1.2 var(--font-ui-title); }
.sound-milestones {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--r-card);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.sound-milestones div { display: flex; justify-content: space-between; color: #ffe093; }
.sound-milestones progress { width: 100%; accent-color: #ffc975; }
@media (max-height: 740px) {
  .sound-result-scene { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .sound-result-doki { width: 108px; height: 108px; }
}

.mg-paused .sound-scene * { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .sound-target { transform: none !important; }
  .sound-scene *, .sound-result-doki > i { animation: none !important; transition: none !important; }
  .sound-scene[data-final] .sound-bulbs i { opacity: .62; }
  .sound-target.is-hit .sound-target-art { filter: drop-shadow(0 0 5px #9de7bf); }
  .sound-target.is-miss .sound-target-art { filter: drop-shadow(0 0 5px #f19098); }
  .sound-prizes i, .sound-result-doki > i { display: none; }
  .sound-scene:is([data-state="focus"], [data-outcome="hit"]) .sound-prizes {
    background: linear-gradient(transparent 27%, rgb(255 212 129 / .12) 40%, transparent 46%);
  }
}

.sound-scene[data-finale="win"]::after {
  content: '';
  position: absolute;
  inset: 81.7% 12% 14.4% 25%;
  pointer-events: none;
  background: radial-gradient(ellipse, #2e172baf, transparent 73%);
  opacity: 0;
}
.sound-scene[data-caught]::after { opacity: 1; }
.sound-scene[data-finale] :is(.sound-rails, .sound-counter, .sound-window, .sound-call, .sound-aim) {
  visibility: hidden;
}
.sound-finale-message {
  position: absolute;
  z-index: 4;
  inset: auto 12px 24px;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-1);
  color: var(--ivory);
  font: 800 var(--text-md)/1.25 var(--font-ui-title);
}
.sound-finale-shelf {
  position: absolute;
  inset: 29.6% 38% 56% 36%;
  pointer-events: none;
  background: linear-gradient(#2e1826, #502b39 83%, #744339);
}
.sound-finale-shelf::before, .sound-finale-shelf::after {
  content: '';
  position: absolute;
  bottom: 0;
  box-shadow: 2px 2px 3px #2c1726a6, inset -5px 0 #532a3d40, inset 0 4px #ffd3a24d;
  border: 1px solid #642d37;
  border-radius: 3px 2px 1px 1px;
}
.sound-finale-shelf::before {
  width: 52%;
  height: 76%;
  left: 36%;
  background: repeating-linear-gradient(45deg, #c2765d 0 7px, #edac7b 7px 13px);
  rotate: 4deg;
  transform-origin: bottom right;
}
.sound-finale-shelf::after {
  width: 52%;
  height: 42%;
  left: 10%;
  background: linear-gradient(90deg, transparent 39%, #f5b966 39% 58%, transparent 58%), #ac544f;
}
.sound-finale-prize {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* The bear is cut out of the same approved backdrop at its shelf coordinates. */
  clip-path: polygon(40% 30.1%, 43% 29.6%, 46% 30.3%, 52% 30%, 56% 29.5%, 59% 31%,
    58.6% 33%, 57% 34.1%, 57% 35.7%, 55.5% 37%, 59% 38%, 61.3% 40%,
    62% 42%, 60.4% 44%, 38.3% 44%, 36.2% 43%, 36% 41.1%, 37% 38.7%,
    40.5% 36.5%, 40.8% 34.1%, 39.4% 32.8%);
  --catch-x: calc(19cqw - 90px);
  --catch-y: calc(40cqh - 4px);
  z-index: 5;
  background: var(--sound-art) center top / 100% calc(100% * 32 / 27) no-repeat;
  transform-origin: 49% 37%;
  transform: translate(var(--catch-x), var(--catch-y)) scale(1.32);
}
.sound-scene[data-caught] .sound-doki { bottom: 16%; right: 14%; scale: 1.23; }
@media (prefers-reduced-motion: no-preference) {
  .sound-finale-prize { animation: sound-prize-drop 1.05s both; }
}
@keyframes sound-prize-drop {
  0%, 15% { transform: none; }
  45% { transform: translate(calc(var(--catch-x) * .55), calc(var(--catch-y) * .42)) rotate(11deg) scale(1.10); }
  69% { transform: translate(var(--catch-x), calc(var(--catch-y) + 3px)) rotate(-7deg) scale(1.38); }
  85% { transform: translate(var(--catch-x), calc(var(--catch-y) - 7px)) rotate(4deg) scale(1.32); }
  100% { transform: translate(var(--catch-x), var(--catch-y)) scale(1.15); }
}
