
.mx-svg { color: var(--ink); cursor: pointer; overflow: visible; -webkit-tap-highlight-color: transparent; transform-origin: 50% 90%; }
.mx-bubble { position: absolute; top: 0; left: 50%; transform: translate(-50%, 6px); background: #fffaf0; color: #2a2119;
  border: 2px solid #2a2119; border-radius: 14px; padding: 5px 12px 6px; font: 600 15px var(--sans); white-space: nowrap;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 2; text-align: center; }
.mx-bubble.on { opacity: 1; transform: translate(-50%, 0); }
.mx-bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: inherit;
  border: 2px solid #2a2119; border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
.mx-bubble .zh { font-family: var(--cjk); font-size: 20px; }
.mx-bubble .py { font-family: var(--pinyin); margin-left: 6px; }
.mx-bubble small { display: block; font-weight: 400; font-size: 13px; color: #6e604f; }

.mx-svg .m-bob, .mx-svg .eyes-open, .mx-svg .arm-l, .mx-svg .arm-r, .mx-svg .x-spark, .mx-svg .x-zz, .mx-svg .cheek, .mx-svg .tuft { transform-box: fill-box; }
.mx-svg .cheek { transform-origin: 50% 50%; transition: transform .35s, opacity .35s; }
.mx-svg .x-blush { opacity: 0; transition: opacity .4s; }
.mx-svg .tuft { transform-origin: 50% 100%; }
.mx-svg .m-bob { transform-origin: 50% 100%; animation: mx-breathe 3.2s ease-in-out infinite; }
.mx-svg .eyes-open { transform-origin: 50% 50%; transition: transform .07s; }
.mx-svg .pupils { transform: translate(var(--lx, 0px), var(--ly, 0px)); }
.mx-svg .face { transform: translate(var(--fx, 0px), var(--fy, 0px)); }
.mx-svg .arm-l { transform-origin: 90% 50%; transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.mx-svg .arm-r { transform-origin: 10% 50%; transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.mx-svg .eyes-happy, .mx-svg .eyes-closed, .mx-svg .brows, .mx-svg .m-open, .mx-svg .m-wavy, .mx-svg .m-o, .mx-svg .m-sleep,
.mx-svg .x-sweat, .mx-svg .x-dots, .mx-svg .x-zz, .mx-svg .x-spark, .mx-svg .x-shy, .mx-svg .x-waves { display: none; }
.mx-svg .ti { stroke-dasharray: 1 2; stroke-dashoffset: 1; }

.mx-svg.blink .eyes-open { transform: scaleY(.12); }
.st-happy .eyes-open, .st-celebrate .eyes-open, .st-sleep .eyes-open { display: none; }
.st-happy .eyes-happy, .st-celebrate .eyes-happy, .st-sleep .eyes-closed { display: inline; }
.st-happy .m-idle, .st-celebrate .m-idle, .st-oops .m-idle, .st-think .m-idle, .st-sleep .m-idle { display: none; }
.st-happy .m-open, .st-celebrate .m-open { display: inline; }
.st-oops .m-wavy, .st-oops .brows, .st-oops .x-sweat { display: inline; }
.st-think .m-o, .st-think .x-dots { display: inline; }
.st-sleep .m-sleep, .st-sleep .x-zz { display: inline; }
.st-happy .x-spark, .st-celebrate .x-spark { display: inline; }
.st-think .pupils { transform: translate(calc(var(--lx, 0px) + 3px), calc(var(--ly, 0px) - 4px)); }
.st-happy .arm-l, .st-celebrate .arm-l { transform: translate(3px, -24px) rotate(-35deg); }
.st-happy .arm-r, .st-celebrate .arm-r { transform: translate(-3px, -24px) rotate(35deg); }
.st-oops .arm-l { transform: translate(14px, -16px); }
.st-oops .arm-r { transform: translate(-14px, -16px); }
/* смущение: краснеет, щурится, ручки у лица, покачивается */
.st-shy .eyes-open, .st-listen .eyes-open, .st-shy .m-idle { display: none; }
.st-shy .eyes-happy, .st-shy .x-shy, .st-shy .m-wavy, .st-listen .eyes-closed, .st-listen .x-waves { display: inline; }
.st-shy .cheek { transform: scale(1.6); opacity: 1; }
.st-shy .x-blush { opacity: .32; }
.st-shy .arm-l { transform: translate(20px, -24px); }
.st-shy .arm-r { transform: translate(-20px, -24px); }
/* слушает: глаза закрыты, ладонь у уха, звуковые волны, хохолок / ленточка колышутся */
.st-listen .arm-r { transform: translate(-16px, -46px) rotate(-30deg); }
[data-m="mo"] .st-listen .arm-r { transform: translate(2px, -38px); }
.st-listen .x-waves path { animation: mx-wave 1.2s ease-out infinite; }
.st-listen .x-waves path:nth-child(2) { animation-delay: .2s; }
.st-listen .x-waves path:nth-child(3) { animation-delay: .4s; }
.st-listen .tuft { animation: mx-wiggle .7s ease-in-out infinite; }

.st-happy .m-bob { animation: mx-hop .55s cubic-bezier(.3,.7,.4,1), mx-breathe 3.2s ease-in-out .55s infinite; }
.st-celebrate .m-bob { animation: mx-hop .55s cubic-bezier(.3,.7,.4,1) 3, mx-breathe 3.2s ease-in-out 1.65s infinite; }
.st-oops .m-bob { animation: mx-shake .5s, mx-breathe 3.2s ease-in-out .5s infinite; }
.st-sleep .m-bob { animation: mx-breathe 4.8s ease-in-out infinite; }
.st-shy .m-bob { animation: mx-sway 1.3s ease-in-out infinite; }
.st-listen .m-bob { animation: mx-tilt 1.6s ease-in-out infinite; }
.mx-svg .m-bob.hop { animation: mx-hop .5s cubic-bezier(.3,.7,.4,1); }
.mx-img { display: block; height: auto; transform-origin: 50% 88%; animation: mx-breathe 3.2s ease-in-out infinite; user-select: none; }
.mx-img.st-happy { animation: mx-hop .55s cubic-bezier(.3,.7,.4,1), mx-breathe 3.2s ease-in-out .55s infinite; }
.mx-img.st-celebrate { animation: mx-hop .55s cubic-bezier(.3,.7,.4,1) 3, mx-breathe 3.2s ease-in-out 1.65s infinite; }
.mx-img.st-oops { animation: mx-shake .5s, mx-breathe 3.2s ease-in-out .5s infinite; }
.mx-img.st-sleep { animation: mx-breathe 4.8s ease-in-out infinite; }
.mx-img.st-shy { animation: mx-sway 1.3s ease-in-out infinite; }
.mx-img.st-listen { animation: mx-tilt 1.6s ease-in-out infinite; }
.mx-img.hop { animation: mx-hop .5s cubic-bezier(.3,.7,.4,1); }
/* пируэт: присел, взлетел, приземлился с «плюхом»; обороты делает JS (лицо и ручки обходят тело или кадры 3D-оборота) */
.mx-svg.spin, .mx-turn.spin { animation: mx-spin 1.25s cubic-bezier(.45,0,.25,1); transform-origin: 50% 90%; }
.mx-turn { position: absolute; background-repeat: no-repeat; background-size: 2400% 100%; pointer-events: none; }
.mx-conf.mx-spark { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 8px 2px rgba(242, 183, 64, .7); }
.st-sleep .x-zz { transform-origin: 0 100%; animation: mx-z 2.4s ease-out infinite; }
.mx-svg .x-spark { transform-origin: 50% 50%; animation: mx-tw .9s ease-in-out infinite; }
.st-think .x-dots { animation: mx-dots 1.2s ease-in-out infinite; }

@keyframes mx-breathe { 50% { transform: scale(1.045, .955); } }
@keyframes mx-shadow { 50% { transform: scale(1.09, 1); opacity: .17; } }
@keyframes mx-hop { 0% { transform: scale(1.08, .9); } 35% { transform: translateY(-18px) scale(.95, 1.06); }
  70% { transform: translateY(0) scale(1.06, .94); } 100% { transform: none; } }
@keyframes mx-shake { 20% { transform: rotate(-5deg); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
@keyframes mx-z { 0% { transform: translate(0, 4px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(8px, -12px); opacity: 0; } }
@keyframes mx-tw { 0%, 100% { transform: scale(.6); } 50% { transform: scale(1.15) rotate(20deg); } }
@keyframes mx-dots { 50% { opacity: .35; } }
@keyframes mx-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes mx-tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(4deg); } }
@keyframes mx-wiggle { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes mx-wave { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes mx-spin {
  0% { transform: none; } 14% { transform: translateY(6px) scale(1.08, .9); } 30% { transform: translateY(-26px) scale(.96, 1.05); }
  62% { transform: translateY(-30px); } 84% { transform: translateY(0) scale(1.1, .88); } 100% { transform: none; } }

.mx-conf { position: absolute; left: 50%; top: 55%; width: 8px; height: 12px; border-radius: 2px; pointer-events: none;
  animation: mx-conf 1.3s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes mx-conf { 0% { transform: translate(0, 0); opacity: 1; } 60% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 1; }
  100% { transform: translate(var(--x), calc(var(--y) + 120px)) rotate(var(--r)); opacity: 0; } }

/* «жизнь»: тень дышит, мелкие действия в покое и реакции на интерфейс (классы act-* ставит JS) */
.mx-svg .m-shadow { transform-box: fill-box; transform-origin: 50% 50%; animation: mx-shadow 3.2s ease-in-out infinite; }
.mx-svg.act-yawn .eyes-open, .mx-svg.act-yawn .m-idle, .mx-svg.act-nod .eyes-open { display: none; }
.mx-svg.act-yawn .eyes-closed, .mx-svg.act-yawn .m-o, .mx-svg.act-nod .eyes-closed { display: inline; }
.mx-svg.act-yawn .m-o { transform-box: fill-box; transform-origin: 50% 50%; animation: mx-yawn 1.5s ease-in-out; }
.mx-svg.act-yawn .arm-l { transform: translate(8px, -28px) rotate(-30deg); }
.mx-svg.act-yawn .arm-r { transform: translate(-8px, -28px) rotate(30deg); }
.mx-svg.act-scratch .arm-r { animation: mx-scratch .22s ease-in-out 6 alternate; }
[data-m="mo"] .mx-svg.act-scratch .arm-r { animation-name: mx-scratch-mo; }
.mx-svg.act-shuffle .m-bob, .mx-img.act-shuffle { animation: mx-shuffle .5s ease-in-out 2; }
.mx-svg.act-tuft .tuft { animation: mx-wiggle .3s ease-in-out 4; }
.mx-img.act-wobble { animation: mx-sway .5s ease-in-out 3; }
.mx-img.act-yawn { animation: mx-stretch 1.5s ease-in-out; }
.mx-img.act-scratch { animation: mx-key .22s ease-in-out 6; }
.mx-svg.act-nod .m-bob, .mx-img.act-nod { animation: mx-nod 1.7s ease-in-out; }
.mx-svg.act-curious .brows { display: inline; transform: translateY(-5px); }
.mx-svg.act-type .m-bob, .mx-img.act-type { animation: mx-key .26s ease-out; }
.mx-svg.act-wait .arm-l { animation: mx-tapping .28s ease-in-out infinite alternate; }
.mx-img.act-wait { animation: mx-tilt 1.2s ease-in-out infinite; }
.mx-svg.act-fidget .m-bob, .mx-img.act-fidget { animation: mx-shake .32s 2; }
.mx-drip { position: absolute; width: 7px; height: 9px; margin-left: -3.5px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #2a2119; box-shadow: 0 0 0 1.5px rgba(245, 236, 220, .75); pointer-events: none; animation: mx-drip 1.2s ease-in forwards; }
@keyframes mx-yawn { 0%, 100% { transform: scale(1); } 40%, 70% { transform: scale(1.8, 2.2); } }
@keyframes mx-scratch { from { transform: translate(-34px, -16px); } to { transform: translate(-30px, -21px); } }
@keyframes mx-scratch-mo { from { transform: translate(2px, -12px); } to { transform: translate(4px, -18px); } }
@keyframes mx-shuffle { 0%, 100% { transform: none; } 30% { transform: translateY(-5px) rotate(-3deg); } 70% { transform: translateY(-3px) rotate(3deg); } }
@keyframes mx-stretch { 0%, 100% { transform: none; } 35%, 70% { transform: scale(.96, 1.06); } }
@keyframes mx-nod { 0%, 100% { transform: none; } 35%, 65% { transform: translateY(4px) rotate(5deg) scale(1.02, .97); } }
@keyframes mx-key { 40% { transform: translateY(2px) scale(1.03, .96); } }
@keyframes mx-tapping { from { transform: translate(6px, -6px); } to { transform: translate(6px, -14px); } }
@keyframes mx-drip { 0% { transform: scale(.3); opacity: 0; } 20% { transform: scale(1); opacity: 1; }
  85% { transform: translateY(var(--fall)) scale(.9, 1.15); opacity: 1; } 100% { transform: translateY(var(--fall)) scale(2.2, .3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .mx-svg, .mx-svg *, .mx-img { animation: none !important; transition: none !important; }
}

.mx-dock { position: fixed; left: 12px; bottom: 12px; z-index: 40; display: flex; flex-direction: column; align-items: flex-start; pointer-events: none; }
.mx-dock .mx-stage { position: relative; width: 104px; height: 104px; }
.mx-dock .mx-svg { width: 104px; height: 104px; pointer-events: auto; }
.mx-dock .mx-bubble { top: auto; bottom: 100%; left: 4px; transform: translate(0, 6px); }
.mx-dock .mx-bubble.on { transform: none; }
.mx-dock .mx-bubble::after { left: 44px; }
.mx-switch { pointer-events: auto; font: 500 12px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule);
  border-radius: 999px; padding: 3px 10px; margin-top: 2px; cursor: pointer; min-height: 28px; }
.mx-switch:hover, .mx-switch[aria-expanded="true"] { border-color: var(--seal); }
.mx-dock.is-off .mx-stage { display: none; }
.mx-menu { pointer-events: auto; position: absolute; left: 0; bottom: calc(100% + 6px); width: 230px; background: var(--paper);
  color: var(--ink); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  font: 400 14px var(--sans); }
.mx-menu[hidden] { display: none; }
.mx-menu b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; margin: 0 0 6px; }
.mx-menu label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.mx-menu input { accent-color: var(--seal); margin: 0; }
.mx-menu hr { border: 0; border-top: 1px solid var(--rule); margin: 8px 0; }
@media (max-width: 640px) {
  .mx-dock .mx-stage, .mx-dock .mx-svg { width: 72px; height: 72px; }
  .mx-dock .mx-bubble::after { left: 30px; }
  body:not(.g-playing) .mx-dock { bottom: 76px; }  /* над нижней кнопкой записи */
}
/* телефон во время игры: маскот в строке над полем (рядом с очками), облачко — влево, поверх названия уровня */
.mx-dock.mx-dock--hud { position: relative; left: auto; bottom: auto; z-index: 3; flex: none; }
.mx-dock--hud .mx-stage, .mx-dock--hud .mx-svg { width: 46px; height: 46px; }
.mx-dock--hud .mx-switch { display: none; }
.mx-dock--hud .mx-bubble { top: 50%; bottom: auto; left: auto; right: calc(100% + 8px); transform: translate(6px, -50%); font-size: 13px; padding: 4px 10px 5px; }
.mx-dock--hud .mx-bubble.on { transform: translate(0, -50%); }
.mx-dock--hud .mx-bubble .zh { font-size: 16px; }
.mx-dock--hud .mx-bubble small { font-size: 11px; }
.mx-dock--hud .mx-bubble::after { left: auto; right: -8px; top: 50%; bottom: auto; transform: translateY(-50%) rotate(-45deg); }
