/* Silly Monster (reading): the monster on the left (on top on a tall screen), the speech bubble and
   three big picture cards on the right (underneath). Everything he taps is at least 60px. */
.game.monstermaker { background: linear-gradient(160deg, #fbe9ff, #fff3dc 60%, #e2f4ff); }
.monstermaker .game-top { padding-top: 5px; padding-bottom: 5px; }
.monstermaker .mm-back { min-height: 60px; min-width: 60px; white-space: nowrap; touch-action: manipulation; }
.monstermaker .mm-body {
  flex: 1; min-height: 0; position: relative; display: grid; align-items: center; gap: 14px 22px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px));
}

/* the monster: a square as big as fits, or taller than wide (more sky) when there's room up there */
.monstermaker .mm-stage { container-type: size; align-self: stretch; min-width: 0; min-height: 0; display: grid; place-items: center; }
.monstermaker .mm-frame { position: relative; width: min(100cqw, 100cqh); height: min(100cqh, 135cqw); }
.monstermaker .mm-frame > .mm-scene {
  display: block; width: 100%; height: 100%; box-sizing: border-box; overflow: hidden;
  border: 4px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow); background: #fbf4ff;
}
.monstermaker .mm-dots { position: absolute; left: 12px; top: 12px; z-index: 2; display: flex; gap: 5px; padding: 6px 9px; background: rgba(255, 255, 255, .88); border: 3px solid var(--ink); border-radius: 999px; pointer-events: none; }
.monstermaker .mm-dots i { width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; }
.monstermaker .mm-dots i.on { background: var(--grape); }
.monstermaker .mm-dots i.now { background: var(--sun); animation: mm-pulse .9s ease-in-out infinite; }

/* what the monster wants (nothing yet behind the start card) */
.monstermaker .mm-body.waiting .mm-side { visibility: hidden; }
.monstermaker .mm-side { min-width: 0; width: 100%; max-width: 640px; justify-self: center; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.monstermaker .mm-bubble {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 104px; padding: 12px 14px 12px 24px;
  background: #fff; border: 4px solid var(--ink); border-radius: 30px; box-shadow: var(--shadow);
}
/* the bubble's tail, pointing at the monster */
.monstermaker .mm-bubble::before, .monstermaker .mm-bubble::after { content: ''; position: absolute; top: 50%; width: 0; height: 0; border-style: solid; }
.monstermaker .mm-bubble::before { left: -27px; margin-top: -18px; border-width: 18px 27px 18px 0; border-color: transparent var(--ink) transparent transparent; }
.monstermaker .mm-bubble::after { left: -19px; margin-top: -13px; border-width: 13px 20px 13px 0; border-color: transparent #fff transparent transparent; }
.monstermaker .mm-bubble.nudge { animation: mm-wiggle .5s ease-in-out 2; }
.monstermaker .mm-ask { flex: 1; min-width: 0; margin: 0; font-size: clamp(30px, 3.4vw, 50px); font-weight: 700; line-height: 1.22; color: var(--ink); word-spacing: .14em; overflow-wrap: anywhere; }
.monstermaker .mm-ask.say { font-family: var(--font); font-size: clamp(22px, 2.3vw, 32px); font-weight: 800; color: var(--grape); word-spacing: normal; }
.monstermaker .mm-ask.pop { animation: mm-askpop .35s cubic-bezier(.2, 1.5, .4, 1); }
.monstermaker .mm-hear {
  flex: none; width: 66px; height: 66px; padding: 0; border-radius: 50%; border: 4px solid var(--ink); background: #fff8d6;
  font-size: 32px; line-height: 1; box-shadow: 0 4px 0 rgba(58, 42, 74, .25); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.monstermaker .mm-hear.wait { animation: mm-wake 2.5s linear both; }
.monstermaker .mm-hear.no { animation: mm-wake 0s both, mm-wiggle .35s ease-in-out; }
.monstermaker .mm-hear:active:not(:disabled) { transform: scale(.92); }
.monstermaker .mm-hear:disabled { visibility: hidden; }

/* the three pictures (no words: the pictures are the answers) */
.monstermaker .mm-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.6vw, 18px); }
.monstermaker .mm-card {
  position: relative; aspect-ratio: 1; min-height: 60px; min-width: 0; padding: 0; container-type: inline-size; display: grid; place-items: center;
  background: #fff; border: 4px solid var(--ink); border-radius: 26px; box-shadow: var(--shadow); color: var(--ink);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  opacity: 0; transform: scale(.7); transition: opacity .18s, transform .25s cubic-bezier(.2, 1.5, .4, 1), background .2s;
}
.monstermaker .mm-card.show { opacity: 1; transform: none; }
.monstermaker .mm-card.show:active:not(:disabled) { transform: scale(.94); }
.monstermaker .mm-card:disabled { cursor: default; }
@media (hover: hover) { .monstermaker .mm-card.show:hover:not(:disabled) { background: #fff8d6; } }
.monstermaker .mm-cpic { display: grid; place-items: center; font-size: 66cqw; line-height: 1; transition: font-size .2s, transform .2s; pointer-events: none; }
.monstermaker .mm-cpic > svg { display: block; }
.monstermaker .mm-emo { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; line-height: 1; }
.monstermaker .mm-lbl { display: none; position: absolute; left: 5%; right: 5%; bottom: 5%; font-size: 19cqw; font-weight: 700; line-height: 1.15; text-align: center; color: #a33; background: #fff; border-radius: 12px; pointer-events: none; }
.monstermaker .mm-lbl u { text-decoration: none; background: #ffe27a; border-radius: 5px; padding: 0 1px; }
.monstermaker .mm-card.bad { background: #ffe8ea; animation: mm-shake .35s; }
.monstermaker .mm-card.bad .mm-cpic { font-size: 46cqw; transform: translateY(-15%); opacity: .7; }
.monstermaker .mm-card.bad .mm-lbl { display: block; }
.monstermaker .mm-card.ok { background: #dcf8e3; box-shadow: 0 0 0 6px var(--good), var(--shadow); }
.monstermaker .mm-card.pulse { animation: mm-pulse .9s ease-in-out infinite; }
.monstermaker .mm-card.gone { opacity: 0; transform: scale(.7); }

/* ---------- inside the monster picture ---------- */
.mm-scene .mm-mon { transition: transform .5s cubic-bezier(.3, 1.45, .5, 1); transform-origin: 300px 556px; }
.mm-scene .mm-mon.riding { transform: translate(0, -112px) scale(.84); }
.mm-scene .mm-wob, .mm-scene .mm-breathe { transform-origin: 300px 556px; }
.mm-scene .mm-breathe { animation: mm-breathe 3.2s ease-in-out infinite; }
.mm-scene .mm-wob.hop { animation: mm-hop .6s ease-out; }
.mm-scene .mm-wob.laugh { animation: mm-laugh .9s ease-in-out; }
.mm-scene.party .mm-wob { animation: mm-party 1s ease-in-out infinite; }
.mm-scene .mm-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: mm-blink 4.4s infinite; }
.mm-scene .mm-joy, .mm-scene .mm-mouth-ha { display: none; }
.mm-scene.joy .mm-joy, .mm-scene.party .mm-joy, .mm-scene.ha .mm-mouth-ha, .mm-scene.party .mm-mouth-ha { display: inline; }
.mm-scene.joy .mm-eyes, .mm-scene.party .mm-eyes, .mm-scene.ha .mm-mouth, .mm-scene.party .mm-mouth { display: none; }
.mm-scene .mm-emo { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.mm-scene .mm-it { transform-box: fill-box; transform-origin: 50% 50%; animation: mm-pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.mm-scene .mm-it.out { animation: mm-out .35s ease-in forwards; }
.mm-scene [data-slot="sky"] > .mm-it:not(.out) { animation: mm-pop .45s cubic-bezier(.2, 1.6, .4, 1) both, mm-bob 2.8s .5s ease-in-out infinite; }
.mm-scene .mm-mark { transform-box: fill-box; transform-origin: 50% 50%; animation: mm-mark 1.1s ease-in-out infinite; }
.mm-scene .mm-sp { animation: mm-sp .8s cubic-bezier(.2, .8, .4, 1) forwards; }
.mm-scene .mm-rays { opacity: 0; transition: opacity .6s; transform-origin: 300px 330px; }
.mm-scene.party .mm-rays { opacity: .8; animation: mm-spin 9s linear infinite; }
.mm-scene.mm-still *, .mm-scene.mm-still { animation: none !important; transition: none !important; }

/* ---------- before the first monster ---------- */
.monstermaker .mm-start { position: absolute; inset: 0; z-index: 12; display: none; place-items: center; padding: 14px; overflow: auto; background: rgba(40, 20, 70, .35); }
.monstermaker .mm-start.show { display: grid; }
.monstermaker .mm-start-card {
  width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 20px 16px; text-align: center;
  background: #fff; border: 4px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow);
}
.monstermaker .mm-hero { width: min(230px, 30vh); aspect-ratio: 1; }
.monstermaker .mm-hero svg, .monstermaker .mm-gal svg { display: block; width: 100%; height: 100%; }
.monstermaker .mm-go { font-size: 30px; min-height: 72px; padding: 10px 46px; touch-action: manipulation; }
.monstermaker .mm-gallery { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.monstermaker .mm-gal { width: 74px; height: 74px; padding: 2px; background: #f6f0ff; border: 2px solid #e6dcf5; border-radius: 16px; }
.monstermaker .mm-now { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.monstermaker .mm-now .rd-word { font-size: 19px; color: var(--ink); }
.monstermaker .mm-off { margin: 0; font-weight: 700; color: var(--coral-dark); }
.monstermaker .mm-off .btn { min-height: 48px; }

/* new sounds learned */
.monstermaker .mm-banner {
  position: absolute; left: 50%; top: 18px; z-index: 11; transform: translateX(-50%) scale(0); opacity: 0; pointer-events: none; white-space: nowrap;
  background: var(--sun); color: var(--ink); border: 4px solid var(--ink); border-radius: 22px; box-shadow: var(--shadow); padding: 6px 22px; font-size: 30px; font-weight: 800;
}
.monstermaker .mm-banner .rd-word { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 0 10px; }
.monstermaker .mm-banner.show { animation: mm-banner 2.8s ease-out forwards; }

/* the finished monster on the results card */
.results .mm-res { display: block; width: 150px; height: 150px; margin: -4px auto 0; }
.results .mm-res svg { display: block; width: 100%; height: 100%; }

/* ---------- a tall screen (an iPad held up, a phone): monster on top ---------- */
@media (max-aspect-ratio: 1/1) {
  .monstermaker .mm-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 14px; align-items: stretch; }
  .monstermaker .mm-side { max-width: 760px; gap: 14px; }
  .monstermaker .mm-bubble::before { left: 50%; top: -27px; margin: 0 0 0 -18px; border-width: 0 18px 27px 18px; border-color: transparent transparent var(--ink) transparent; }
  .monstermaker .mm-bubble::after { left: 50%; top: -19px; margin: 0 0 0 -13px; border-width: 0 13px 20px 13px; border-color: transparent transparent #fff transparent; }
  .monstermaker .mm-ask { font-size: clamp(27px, 5.6vw, 48px); }
  .monstermaker .mm-ask.say { font-size: clamp(21px, 4vw, 32px); }
}
@media (max-width: 560px) {
  .monstermaker .game-top h2 { font-size: 20px; }
  .monstermaker .mm-body { padding-top: 8px; padding-bottom: 10px; gap: 10px; }
  .monstermaker .mm-side { gap: 12px; }
  .monstermaker .mm-bubble { min-height: 84px; padding: 8px 8px 8px 16px; border-radius: 24px; }
  .monstermaker .mm-hear { width: 60px; height: 60px; font-size: 28px; }
  .monstermaker .mm-card { border-width: 3px; border-radius: 20px; }
  .monstermaker .mm-frame > .mm-scene { border-radius: 22px; border-width: 3px; }
  .monstermaker .mm-dots { left: 8px; top: 8px; gap: 4px; padding: 4px 7px; border-width: 2px; }
  .monstermaker .mm-dots i { width: 10px; height: 10px; border-width: 2px; }
  .monstermaker .mm-gal { width: 58px; height: 58px; }
  .monstermaker .mm-go { font-size: 26px; padding: 8px 34px; }
  .monstermaker .mm-banner { font-size: 22px; }
}
/* short screens: a smaller bubble so the cards keep their size */
@media (max-height: 640px) and (min-aspect-ratio: 1/1) {
  .monstermaker .mm-bubble { min-height: 84px; }
  .monstermaker .mm-ask { font-size: clamp(26px, 3vw, 40px); }
}

@keyframes mm-pulse { 50% { transform: scale(1.08); } }
@keyframes mm-wiggle { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes mm-shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes mm-askpop { from { transform: scale(.85); opacity: .3; } }
@keyframes mm-wake { from { opacity: .35; filter: grayscale(1); } 99% { opacity: .35; filter: grayscale(1); } to { opacity: 1; filter: none; } }
@keyframes mm-breathe { 50% { transform: scale(1.012, .99); } }
@keyframes mm-hop { 25% { transform: scale(1.06, .92); } 55% { transform: translateY(-26px) scale(.96, 1.05); } 80% { transform: scale(1.03, .97); } }
@keyframes mm-laugh { 15% { transform: rotate(-4deg); } 35% { transform: rotate(4deg); } 55% { transform: rotate(-3deg); } 75% { transform: rotate(2deg); } }
@keyframes mm-party { 0%, 100% { transform: rotate(-6deg); } 25% { transform: translateY(-30px) rotate(0deg) scale(1.03, .97); } 50% { transform: rotate(6deg); } 75% { transform: translateY(-30px) rotate(0deg) scale(1.03, .97); } }
@keyframes mm-blink { 0%, 93%, 100% { transform: none; } 95% { transform: scaleY(.1); } }
@keyframes mm-pop { from { transform: scale(0) rotate(-20deg); opacity: 0; } 60% { opacity: 1; } }
@keyframes mm-out { to { transform: scale(0) rotate(40deg); opacity: 0; } }
@keyframes mm-bob { 50% { transform: translateY(-10px); } }
@keyframes mm-mark { 50% { transform: scale(1.08); opacity: .7; } }
@keyframes mm-sp { from { transform: scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1) rotate(90deg); opacity: 0; } }
@keyframes mm-spin { to { transform: rotate(360deg); } }
@keyframes mm-banner { 0% { transform: translateX(-50%) scale(0); opacity: 0; } 12% { transform: translateX(-50%) scale(1.1); opacity: 1; } 20%, 85% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { transform: translateX(-50%) scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .mm-scene .mm-breathe, .mm-scene.party .mm-wob, .mm-scene.party .mm-rays, .mm-scene [data-slot="sky"] > .mm-it { animation: none; }
}
