:root { --ink: #2b2340; --pink: #ffd6e7; --accent: #ff6b9d; --cream: #fff8ef; --sa: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom); --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7fcbff; font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; position: fixed; width: 100%; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; user-select: none; -webkit-user-select: none; }
#stage text { user-select: none; -webkit-user-select: none; pointer-events: none; }
#stage.flash { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .2; } to { opacity: 1; } }
#ghost { position: fixed; left: 0; top: 0; font-size: 60px; line-height: 1; pointer-events: none; z-index: 30; filter: drop-shadow(0 6px 4px rgba(43,35,64,.3)); transform-origin: center; }

/* ---------- SVG animation classes ---------- */
.fx { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .15s ease-out; }
.fx.held { transform: scale(1.12) rotate(-4deg); }
.fx.held.mine { transition: none; }
.fx.hop { animation: hop .5s ease-out; }
.fx.land { animation: land .4s cubic-bezier(.3,1.6,.6,1); }
.fx.bounce { animation: bounce .65s cubic-bezier(.3,1.4,.6,1); }
.fx.spin { animation: spin .7s ease-in-out; }
.fx.wob { animation: wob .6s ease-in-out infinite; }
.fx.walk { animation: walk .3s ease-in-out infinite; }
.fx.fall { animation: fall .65s cubic-bezier(.4,0,.7,1); }
.fx.float { animation: floaty 3s ease-in-out infinite; }
.fx.breathe { animation: breathe 2.6s ease-in-out infinite; }
.fx.tapfx { animation: tapfx .3s ease-out; }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-34px) scale(1.02); } 100% { transform: translateY(0); } }
@keyframes land { 0% { transform: scale(1.1, .82); } 100% { transform: scale(1, 1); } }
@keyframes bounce { 0% { transform: translateY(0) scale(1.1,.8); } 35% { transform: translateY(-50px) scale(.95,1.08); } 70% { transform: translateY(0) scale(1.08,.9); } 100% { transform: translateY(0) scale(1); } }
@keyframes spin { 0% { transform: scaleX(1); } 50% { transform: scaleX(-1) translateY(-10px); } 100% { transform: scaleX(1); } }
@keyframes wob { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes walk { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
@keyframes fall { 0% { transform: translateY(-240px); } 100% { transform: translateY(0); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-16px) rotate(3deg); } }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.015); } }
@keyframes tapfx { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

.eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: blink 4.2s infinite; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.swinging { transform-box: fill-box; transform-origin: 50% 0%; animation: swing 2.4s ease-in-out infinite alternate; }
@keyframes swing { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
.swingidle { transform-box: fill-box; transform-origin: 50% 0%; animation: swing 3.5s ease-in-out infinite alternate; }
.zzz { animation: zzz 2s ease-in-out infinite; transform-box: fill-box; transform-origin: 0 100%; }
@keyframes zzz { 0% { transform: translateY(0); opacity: .3; } 50% { opacity: 1; } 100% { transform: translateY(-16px); opacity: .3; } }
.steam { animation: steam 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes steam { 0% { transform: translateY(0); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(-22px); opacity: 0; } }
.flame { animation: flame .35s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes flame { from { transform: scale(.9); } to { transform: scale(1.1); } }
.munch { animation: munch .35s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes munch { from { transform: scaleY(.6); } to { transform: scaleY(1.1); } }
.munchfood { animation: munchfood 2.2s ease-in forwards; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes munchfood { 0% { transform: scale(1) rotate(0); } 50% { transform: scale(.7) rotate(-10deg); } 100% { transform: scale(0) rotate(20deg); } }
.notes { animation: notes 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes notes { 0% { transform: translateY(0) rotate(-8deg); opacity: .4; } 50% { opacity: 1; } 100% { transform: translateY(-22px) rotate(8deg); opacity: .4; } }
.music { animation: music .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes music { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }
.tail { transform-box: fill-box; transform-origin: 0% 100%; animation: tail 1.4s ease-in-out infinite alternate; }
@keyframes tail { from { transform: rotate(-12deg); } to { transform: rotate(14deg); } }
.leaf { transform-box: fill-box; transform-origin: 50% 100%; animation: leaf 5s ease-in-out infinite alternate; }
@keyframes leaf { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
.cloud { animation: cloud 60s linear infinite; }
@keyframes cloud { from { transform: translateX(-200px); } to { transform: translateX(600px); } }
.tvshow { transform-box: fill-box; transform-origin: 50% 50%; animation: tvshow 1.6s ease-in-out infinite alternate; }
@keyframes tvshow { from { transform: scale(.96); } to { transform: scale(1.04); } }
.water { stroke-dasharray: 10 8; animation: water .6s linear infinite; }
@keyframes water { to { stroke-dashoffset: -18; } }
.ripple { transform-box: fill-box; transform-origin: 50% 50%; animation: ripple 1.2s ease-out infinite; }
@keyframes ripple { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.dooropen { transform-box: fill-box; transform-origin: 0% 50%; animation: dooropen .7s ease-in-out; }
@keyframes dooropen { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.2); } }
.busride { animation: busride 2.6s ease-in-out forwards; }
@keyframes busride { 0% { transform: translateX(1200px); } 40% { transform: translateX(170px); } 65% { transform: translateX(170px); } 100% { transform: translateX(-1400px); } }
.bubbles circle { transform-box: fill-box; transform-origin: 50% 50%; animation: bub 2s ease-in-out infinite alternate; }
@keyframes bub { from { transform: translateY(0) scale(.9); } to { transform: translateY(-14px) scale(1.1); } }
.pop { animation: popfx .9s ease-out forwards; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes popfx { 0% { transform: scale(0); } 40% { transform: scale(1.3); } 100% { transform: scale(1) translateY(-10px); opacity: 0; } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#tabs { position: absolute; top: calc(8px + var(--sa)); left: calc(8px + var(--sl)); display: flex; gap: 6px; }
#tabs button { position: relative; border: 3px solid var(--ink); background: #fff; border-radius: 999px; padding: 5px 10px 5px 8px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; display: flex; align-items: center; gap: 5px; color: var(--ink); }
#tabs button span { font-size: 18px; line-height: 1; }
#tabs button.cur { background: var(--pink); }
#tabs button i { display: flex; gap: 2px; position: absolute; top: -8px; right: -4px; }
#tabs button em { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); display: block; }
@media (max-width: 520px) { #tabs button b { display: none; } #tabs button { padding: 5px 8px; } }
#side { position: absolute; right: calc(8px + var(--sr)); top: calc(8px + var(--sa)); display: flex; flex-direction: column; gap: 8px; }
.ib { width: 46px; height: 46px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; font-size: 22px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.ib:active, .wb:active, #tabs button:active, .stk:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip { position: absolute; left: calc(8px + var(--sl)); bottom: calc(10px + var(--sb)); background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 5px 12px 5px 8px; font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 6px; box-shadow: 0 3px 0 var(--ink); color: var(--ink); cursor: pointer; }
.chip.off { opacity: .6; }
.chip i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid var(--ink); }
.pop { position: absolute; right: calc(62px + var(--sr)); top: calc(8px + var(--sa)); background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px; box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; gap: 6px; }
#reacts { flex-direction: row; flex-wrap: wrap; width: 236px; top: calc(62px + var(--sa)); }
#reacts button { font-size: 26px; width: 42px; height: 42px; border: 0; background: #f6f1ff; border-radius: 12px; cursor: pointer; }
#menu button { border: 0; background: #f6f1ff; border-radius: 10px; padding: 10px 12px; font-weight: 700; text-align: left; font-size: 14px; cursor: pointer; color: var(--ink); }
#menu { top: calc(224px + var(--sa)); }
#chat { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--sb)); width: min(540px, 94vw); display: flex; flex-direction: column; gap: 6px; }
#quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
#quick button { flex: 0 0 auto; border: 3px solid var(--ink); background: #fff; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 13px; }
#chatf { display: flex; gap: 6px; }
#chatf input { flex: 1; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 16px; background: #fff; outline: none; }
#chatf button { border: 3px solid var(--ink); background: var(--pink); border-radius: 14px; width: 50px; font-size: 18px; }
#tray { position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; width: min(760px, 100vw); background: var(--cream); border: 3px solid var(--ink); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 0 0 var(--sb); box-shadow: 0 -4px 0 rgba(43,35,64,.08); animation: trayin .25s cubic-bezier(.3,1.4,.6,1); }
@keyframes trayin { from { transform: translate(-50%, 60px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.tray-h { display: flex; align-items: center; gap: 10px; padding: 8px 12px 4px 16px; font-weight: 900; font-size: 15px; }
.tray-h small { flex: 1; font-weight: 600; opacity: .55; font-size: 11px; }
.tray-h button { border: 3px solid var(--ink); background: #fff; border-radius: 10px; width: 32px; height: 32px; font-weight: 800; }
#tray-b { display: flex; gap: 6px; overflow-x: auto; padding: 4px 12px 10px; scrollbar-width: none; touch-action: pan-x; }
.stk { flex: 0 0 auto; width: 68px; height: 68px; border: 3px solid var(--ink); background: #fff; border-radius: 18px; font-size: 38px; line-height: 1; box-shadow: 0 3px 0 var(--ink); cursor: grab; touch-action: none; padding: 0; }
#toast { position: absolute; left: 50%; top: calc(64px + var(--sa)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap; }
#hint { position: absolute; left: 50%; bottom: calc(60px + var(--sb)); transform: translateX(-50%); background: #fff; border: 3px solid var(--ink); padding: 6px 12px; border-radius: 16px; font-weight: 700; font-size: 13px; box-shadow: 0 3px 0 var(--ink); max-width: 90vw; text-align: center; }
.hidden { display: none !important; }

.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100vw); max-height: 86dvh; background: var(--cream); border: 3px solid var(--ink); border-bottom: 0; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; z-index: 5; padding-bottom: var(--sb); }
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 800; font-size: 16px; border-bottom: 3px solid var(--ink); }
.sheet-h button { background: #fff; border: 3px solid var(--ink); border-radius: 10px; width: 34px; height: 34px; font-weight: 800; }
.sheet-prev { height: 200px; background: linear-gradient(#bfe6ff, #fde2e4); border-bottom: 3px solid var(--ink); display: flex; justify-content: center; }
.sheet-prev svg { height: 100%; }
.sheet-b { overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.row label { display: block; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; opacity: .7; }
.opts { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; }
.sw.cur, .op.cur { outline: 3px solid var(--accent); outline-offset: 2px; }
.op { border: 3px solid var(--ink); background: #fff; border-radius: 10px; padding: 6px 10px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink); }
.row input { border: 3px solid var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 16px; width: 100%; }

#login { position: fixed; inset: 0; background: linear-gradient(#7fcbff, #ffd6e7); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 20px; }
.card { background: #fff; border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 var(--ink); padding: 22px 26px; width: min(360px, 92vw); text-align: center; }
.card .big { font-size: 56px; line-height: 1; }
.card h1 { margin: 6px 0 0; font-size: 30px; letter-spacing: -.02em; }
.card p { margin: 2px 0 16px; opacity: .7; font-weight: 600; }
.who { display: flex; gap: 10px; justify-content: center; }
.wb { flex: 1; border: 3px solid var(--ink); border-radius: 16px; padding: 14px; font-size: 18px; font-weight: 800; background: #fff; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.wb[data-who="P"].cur { background: #ffd4b8; } .wb[data-who="E"].cur { background: #e9d5ff; }
#loginf { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
#loginf input { border: 3px solid var(--ink); border-radius: 12px; padding: 12px; font-size: 18px; text-align: center; }
#loginf button { border: 3px solid var(--ink); border-radius: 12px; padding: 12px; font-size: 16px; font-weight: 800; background: var(--pink); box-shadow: 0 3px 0 var(--ink); }
#lerr { color: #d6336c; font-weight: 700; min-height: 18px; font-size: 13px; }
@media (max-height: 420px) { .ib { width: 40px; height: 40px; font-size: 19px; border-radius: 13px; } #side { gap: 5px; } }
