/* Bé Làm Nghề — tranh "viền mực": màu phẳng, nét nâu đậm. Nền êm, nút to cỡ ngón tay bé. */
:root { --ink: #4A2C20; --wall: #FCEBC0; --cream: #FFF8EA; --slot: #FFF3DC; --coral: #E8705A; --must: #F2BE4A; --tray: #9A643F; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--wall); color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; border: 0; padding: 0; cursor: pointer; color: inherit; background: none; touch-action: manipulation; }
.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: block; }

/* Sân khấu: kéo thả bằng ngón tay → tắt cuộn/thu phóng của trình duyệt trên vùng chơi */
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#play { touch-action: none; }
.world { position: absolute; left: 0; top: 0; width: 1600px; height: 1000px; transform-origin: 0 0; }
.world > .bg { position: absolute; left: -200px; top: -400px; width: 2000px; height: 1800px; }
.actor { position: absolute; transform-origin: 50% 100%; will-change: transform; }
.actor > svg { width: 100%; height: 100%; overflow: visible; display: block; }
.actor svg g[class^="L-"] { transition: none; }
[data-id^="door-"], [data-id="friend"] { cursor: pointer; }

/* Lửa nhỏ lay nhẹ (chậm, không nhấp nháy) */
.flick { transform-box: fill-box; transform-origin: 50% 100%; animation: flick 1.1s ease-in-out infinite alternate; }
.flick.b { animation-duration: 1.4s; } .flick.c { animation-duration: .95s; animation-delay: -.4s; }
@keyframes flick { from { transform: scale(1, 1) rotate(-2deg); } to { transform: scale(.94, 1.08) rotate(2deg); } }

/* ---------- Khay đồ nghề ---------- */
#tray { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 4; transition: opacity .8s; }
#tray > svg.bar { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#tray.rest { opacity: .2; pointer-events: none; }
.slot { position: absolute; width: 248px; height: 152px; border-radius: 30px; }
.slot > svg { width: 100%; height: 100%; overflow: visible; display: block; }
.slot.out > svg { opacity: .3; }
.slot.invite::after {
  content: ''; position: absolute; inset: -12px; border-radius: 40px; z-index: -1;
  background: rgba(255, 236, 170, .9); animation: invite 2.6s ease-in-out infinite;
}
@keyframes invite { 0%, 100% { opacity: .15; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.02); } }
.ghost { position: absolute; left: 0; top: 0; z-index: 20; pointer-events: none; transform-origin: 50% 50%; will-change: transform; }
.ghost > svg { width: 100%; height: 100%; overflow: visible; display: block; }

/* ---------- Nút ---------- */
.round {
  position: absolute; z-index: 6; width: 72px; height: 72px; border-radius: 50%; background: var(--cream);
  box-shadow: 0 0 0 4px var(--ink); display: grid; place-items: center; transition: transform .15s;
}
.round:active, .big:active { transform: scale(.92); }
.round svg, .big svg { width: 100%; height: 100%; overflow: visible; }
#homeBtn { top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
.amb { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
.amb.off svg { opacity: .35; }
.amb.off::after { content: ''; position: absolute; width: 46px; height: 5px; background: var(--coral); border-radius: 3px; transform: rotate(-45deg); box-shadow: 0 0 0 2px var(--ink); }

/* Phụ đề nhỏ cho ba mẹ (bé không cần đọc; chạm để nghe lại) */
#caption {
  position: absolute; z-index: 5; left: 50%; top: max(20px, env(safe-area-inset-top)); transform: translateX(-50%);
  margin: 0; max-width: min(70vw, 720px); padding: 8px 18px; border-radius: 22px; background: rgba(255, 248, 234, .88);
  font-size: clamp(14px, 1.7vw, 19px); font-weight: 600; line-height: 1.35; text-align: center; color: #6B4B3A; cursor: pointer;
  transition: opacity .4s;
}
#caption:empty { opacity: 0; pointer-events: none; }

/* ---------- Sau khi bạn về: màn hình lắng xuống ---------- */
#after { position: absolute; z-index: 8; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; gap: 36px; justify-content: center; align-items: center; animation: fade 1s ease-out; }
#after[hidden] { display: none; }
.big { position: relative; width: 112px; height: 112px; border-radius: 50%; background: var(--cream); box-shadow: 0 0 0 5px var(--ink); display: grid; place-items: center; transition: transform .15s; }
.big.bell { width: 168px; height: 168px; background: var(--must); }
.big.bell::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 6px var(--must); animation: ready 2.8s ease-out infinite; }
@keyframes ready { from { opacity: .7; transform: scale(1); } to { opacity: 0; transform: scale(1.35); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .flick, .slot.invite::after, .big.bell::after, #after { animation: none !important; }
}
