* { box-sizing: border-box }
:root {
  color-scheme: dark;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: #fff4e8;
  background: #17132f;
}
[hidden] { display: none !important }
body { margin: 0; min-height: 100svh }
button { font: inherit; cursor: pointer; border: 0; border-radius: 15px; font-weight: 800; padding: .65rem 1rem; color: #231633; background: #ffd84f }
button:focus-visible, input:focus-visible { outline: 3px solid #62f3ff; outline-offset: 3px }
.small { background: #34234d; color: #fff4e8; border: 1px solid #9b6db1 }
.stall {
  position: relative;
  max-width: 520px;
  min-height: 100svh;
  margin: auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
  background: linear-gradient(180deg, #10234300 65%, #14223e75), url("festival-alley.webp") center top / 100% 100%, #123054;
}
header { position: relative; z-index: 1; display: flex; gap: 8px; justify-content: space-between; align-items: center }
header strong { font-size: .85rem; background: #2a2147; padding: 7px 9px; border-radius: 12px; white-space: nowrap }
h1 { margin: 0; font-size: clamp(23px, 6vw, 36px); color: #ff75c9; letter-spacing: -.06em; paint-order: stroke fill; -webkit-text-stroke: 4px #fff4e8; text-shadow: 0 4px 0 #822061, 0 0 24px #ff4faa }
h1 span { color: #9ef7ff }
#settings { padding: 7px 11px }
#options { z-index: 3; position: absolute; right: 16px; top: 60px; display: grid; gap: 10px; padding: 16px; border-radius: 13px; background: #2a2147 }
.order { display: flex; gap: 13px; align-items: center; width: min(92%, 380px); margin: clamp(34px, 9vh, 82px) auto 0; padding: 10px 14px; border: 2px solid #fbb5ea; border-radius: 21px; background: #2a2147; box-shadow: 0 4px 0 #7a3e73, 0 0 15px #ffafcf73; }
#customer { font-size: 38px; line-height: 1.3 }
#customer[data-mio] {
  flex: 0 0 48px;
  height: 48px;
  background: #4cacc4 url("fireworks-ink.webp") 71% 47% / 420% no-repeat;
  border-radius: 50%;
  border: 2px solid #ffd2ee;
}
#request { margin: 0 0 3px; font-size: .82rem }
#size { margin-left: .5em; background: #fff4e8; color: #2a2147; padding: 0 .45em; border-radius: .4em }
.play { width: min(100%, 440px, 53svh); position: relative; margin: auto }
canvas { position: relative; display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
#cue { position: absolute; text-align: center; margin: 0; top: 4%; width: 100%; pointer-events: none; font-size: 1.6rem; font-weight: 900; color: #b9fbff; text-shadow: 0 2px 4px #17132f, 0 0 15px #21a2d4 }
#controls { text-align: center }
#hint { display: inline-block; margin: 0 0 4px; padding: 5px 13px; border-radius: 999px; background: #251835; font-weight: 800; font-size: .95rem }
progress { display: block; width: min(210px, 70%); margin: 5px auto 10px; height: 8px; accent-color: #ff75c9 }
#assist { font-size: .78rem; padding: 6px 10px }
#assist-buttons { margin: 8px }
#results { text-align: center; margin: clamp(70px, 23vh, 210px) auto 0; max-width: 380px; padding: 20px 10px; border-radius: 25px; border: 2px solid #fbb5ea; background: radial-gradient(circle at 20% 15%, #724579, transparent 36%), #2a2147ee }
#results h2, #total { margin: 0 0 9px }
#total { color: #ffd84f; font-size: 2rem; font-weight: 900 }
#best { margin: 0 0 16px }
#candies { display: flex; justify-content: center; align-items: end; gap: 15px; height: 90px; margin-bottom: 35px }
.candy { position: relative; display: block; border: 4px solid #fff4e8; border-radius: 45% 58% 47% 51%; background: radial-gradient(circle at 37% 26%, #fff5, transparent 70%), var(--flavor); box-shadow: 0 0 15px var(--flavor) }
.candy::after { content: ""; position: absolute; top: 100%; left: calc(50% - 2px); width: 4px; height: 20px; border-radius: 2px; background: #ffe3b3 }
#retry { width: min(240px, 90%); font-size: 1.1rem }
.ending { margin: 0 0 12px; overflow: hidden; border-radius: 15px; background: #211832 }
.ending img { display: block; width: 100%; height: auto }
.ending figcaption { padding: 9px 12px; font-size: .85rem; line-height: 1.55 }
#results { margin-top: clamp(26px, 7vh, 74px) }
#celebration { position: absolute; inset: 0; pointer-events: none }
.halo, .prism { position: absolute; left: 50%; top: 37%; border-radius: 50%; aspect-ratio: 1 }
.halo {
  width: 84%;
  background: repeating-conic-gradient(from 0deg, transparent 0 14deg, #fff0a884 23deg, transparent 32deg);
  mask-image: radial-gradient(circle, transparent 19%, #000 39%, transparent 71%);
  animation: halo 1.15s ease-out both;
}
.prism {
  width: 64%;
  background: conic-gradient(#ff79cb, #fff59a, #82ffd9, #71d7ff, #b590ff, #ff79cb);
  mask-image: radial-gradient(circle, transparent 42%, #000 51%, transparent 71%);
  animation: prism 1.15s ease-out both;
}
.finale .halo { width: 100% }
.finale .prism { width: 82% }
#sparkles { position: absolute; z-index: 2; inset: 0; overflow: hidden }
.sparkle {
  position: absolute;
  top: -12%;
  left: var(--x);
  color: var(--tint);
  font-size: var(--size);
  text-shadow: 0 0 9px currentColor;
  animation: fall var(--duration) var(--delay) ease-in both;
}
#cue { z-index: 3 }
.play:has(#celebration:not([hidden])) #cue { color: #fff1a6; font-size: clamp(1.35rem, 5vw, 1.9rem); }
@keyframes halo {
  from { transform: translate(-50%, -50%) scale(.58) rotate(-32deg); opacity: .25 }
  28% { opacity: .9 }
  to { transform: translate(-50%, -50%) scale(1.16) rotate(72deg); opacity: .28 }
}
@keyframes prism {
  from { transform: translate(-50%, -50%) scale(.65); opacity: .35 }
  30% { opacity: .9 }
  to { transform: translate(-50%, -50%) scale(1.36); opacity: .23 }
}
@keyframes fall {
  from { transform: translate(0, 0) rotate(0); opacity: 0 }
  25% { opacity: 1 }
  to { transform: translate(var(--drift), 48svh) rotate(120deg); opacity: 0 }
}
@media (prefers-reduced-motion: reduce) {
  .halo, .prism { animation: none; transform: translate(-50%, -50%); opacity: .65 }
  #sparkles { display: none }
}
