/* Load after fonts.css, tokens.css and widgets.css. */

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100%; overflow: hidden; position: fixed; inset: 0;
  font-family: var(--font); color: var(--ink); background: var(--butter);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
img { -webkit-user-drag: none; display: block; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
h1, h2, p { margin: 0; text-wrap: pretty; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 3px #fff; }
/* These only take focus from a script, so they need no ring. */
h1:focus, h1:focus-visible, .screen:focus, .screen:focus-visible { outline: 0; box-shadow: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.screen { position: absolute; inset: 0; overflow: hidden; animation: screen-in .28s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Bubbles, pops, flying pictures ---------- */
.bubble-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.burst-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.burst-dot { position: absolute; left: 0; top: 0; border-radius: 50%; }
.flyer { position: fixed; z-index: 30; pointer-events: none; object-fit: contain; }

/* ---------- Keys ---------- */
.key {
  display: grid; place-items: center; position: relative; border-radius: 18px; background: var(--cream);
  font-weight: 700; line-height: 1; box-shadow: 0 7px 0 var(--earth-edge); transition: transform .08s, box-shadow .08s;
}
.key:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--earth-edge); }
.key.glow { background: var(--gold); box-shadow: 0 7px 0 var(--gold-edge), 0 0 0 8px rgb(255 226 138 / .75); animation: key-breathe 1.4s ease-in-out infinite; z-index: 1; }
.key.hit { animation: key-hit .18s ease-out; }
.key.nope { animation: key-nope .3s ease-in-out; }
@keyframes key-breathe { 50% { transform: scale(1.06); } }
@keyframes key-hit { 40% { transform: translateY(5px) scale(.96); } }
@keyframes key-nope { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }

/* ---------- Choose what to play ---------- */
.choose { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; padding: max(20px, env(safe-area-inset-top)) 20px max(14px, env(safe-area-inset-bottom)); }
.choose h1 { position: relative; font-size: clamp(34px, 6vw, 60px); line-height: 1.1; min-height: 64px; display: flex; align-items: center; text-align: center; }
.choices { position: relative; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: clamp(14px, 3vw, 40px); }
.choice { position: relative; width: min(27vw, 38vh, 360px); aspect-ratio: 1; display: grid; place-content: center; justify-items: center; gap: 2%; border-radius: 50%; transition: transform .18s; }
.choice { background: #ffe28a; }
.choice:nth-child(2) { translate: 0 -14px; background: #a5ebdd; }
.choice:nth-child(3) { background: #ffc4cf; }
.choice > :not(.bubble-svg) { position: relative; }
.choice:active { transform: scale(.94); }
.choice .label { font-size: clamp(18px, 2.4vw, 28px); font-weight: 700; line-height: 1.15; }
.choose .age-chip { position: absolute; left: max(20px, env(safe-area-inset-left)); bottom: max(20px, env(safe-area-inset-bottom)); }
.choose-pip { position: relative; width: min(22vh, 34vw, 200px); }
@media (hover: hover) { .choice:hover { transform: scale(1.05); } }
@media (max-aspect-ratio: 1/1) {
  .choice { width: min(44vw, 27vh, 300px); }
  .choice:nth-child(2) { translate: none; }
}
@media (max-width: 480px) {
  .choose h1 { font-size: 28px; padding: 0 60px; }
  .choice { width: min(42vw, 24vh); }
}

/* ---------- End of a round ---------- */
.finish { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2vh; min-height: 0; background: #d65a72; padding: 12px 16px max(4vh, env(safe-area-inset-bottom)); }
.finish > * { position: relative; }
.finish-sky { position: absolute; inset: 0; background: #7a2f5c url("/games/_shared/night.svg") center / cover no-repeat; }
.finish-star { width: min(15vh, 24vw); margin-bottom: -5vh; animation: star-bob 4s ease-in-out infinite; }
@keyframes star-bob { 50% { transform: translateY(-8px) rotate(5deg); } }
.finish-isle { position: relative; width: min(94vw, 64vh, 660px); aspect-ratio: 1; flex: none; }
.isle-art { position: absolute; left: 0; bottom: 0; width: 100%; }
.finish-pip { position: absolute; z-index: 1; left: 50%; top: 9%; width: 41%; translate: -50% 0; }
.crowd { position: absolute; z-index: 2; bottom: 45%; width: 27%; display: flex; flex-wrap: wrap-reverse; justify-content: center; }
.crowd-l { left: 7%; }
.crowd-r { right: 7%; }
.crowd img { position: relative; z-index: 1; width: 47%; margin: 0; }
.crowd img:nth-child(3) { z-index: 0; margin-bottom: -16%; }
.finish-title { margin-top: calc(min(94vw, 64vh, 660px) * -.4); font-size: clamp(28px, 5vw, 44px); color: var(--cream); text-align: center; }
.finish-picks { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 44px); min-height: min(24vh, 170px); }
.sticker-pick { width: min(27vw, 21vh, 164px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--cream); box-shadow: 0 8px 0 #5b1f45; transition: transform .15s; animation: pop-in .4s backwards; }
.sticker-pick:nth-child(2) { animation-delay: .12s; }
.sticker-pick:nth-child(3) { animation-delay: .24s; }
.sticker-pick:active { transform: scale(.93); }
.sticker-pick.chosen { box-shadow: 0 8px 0 #5b1f45, 0 0 0 10px var(--gold); }
.sticker-pick img { width: 70%; }
@keyframes pop-in { from { transform: scale(0); } 70% { transform: scale(1.12); } }
@media (max-width: 620px) {
  .finish-picks:has(.chosen) { flex-direction: column; gap: 14px; }
  .finish-picks .chosen { order: -1; width: 110px; margin-bottom: 8px; }
  .finish-picks .big-btn { min-height: 60px; width: 240px; }
}
