/* Chọn trò cho bé: claymorphism theo canvas đã duyệt. Fonts tự host (OFL), không gọi domain nào khác. */
@font-face { font-family: "Baloo 2"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/baloo2-800.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/nunito-700.woff2") format("woff2"); }

:root {
  /* mặc định: Mi Lá (xanh lá, kiểu Keroppi) */
  --bg: #edf6ea; --surf: #f8fcf6; --ink: #24402b; --muted: #56735b;
  --a1: #3f9f45; --a1d: #2f7f35; --a1ink: #ffffff;
  --a2: #e9a82a; --a3: #ffe08a; --a4: #8fd18a; --a5: #cdeec9;
  --sh: 50, 100, 60;
  --head: "Baloo 2", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  color-scheme: light;
}
/* Min: tím, kiểu Kuromi */
:root[data-pal="min"] { --bg: #f2eefa; --surf: #fbf9fe; --ink: #2f2540; --muted: #665b7c;
  --a1: #7d5cc6; --a1d: #5e41a3; --a2: #d9709f; --a3: #f6d98f; --a4: #b9a3e3; --a5: #e3d9f7; --sh: 70, 50, 120; }
/* Mon: hồng trắng, kiểu Hello Kitty */
:root[data-pal="mon"] { --bg: #fff1f4; --surf: #fffafb; --ink: #4a2630; --muted: #845e68;
  --a1: #d94f78; --a1d: #b53a60; --a1ink: #ffffff; --a2: #e5484d; --a3: #ffe3a3; --a4: #f7a9c0; --a5: #ffd6e0; --sh: 140, 60, 80; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink); font-family: var(--body); font-weight: 700; line-height: 1.45;
  -webkit-tap-highlight-color: transparent; transition: background-color .25s ease, color .25s ease; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid #2f6fe4; outline-offset: 2px; }
img.broken { visibility: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
#topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
#kidbar { display: flex; gap: 10px; }
#screens { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding-bottom: 6px; }
.screen.center { align-items: center; text-align: center; }
.screen:focus, .h:focus { outline: none; }

/* ---------- clay primitives ---------- */
.clay { background: var(--surf); border-radius: 26px;
  box-shadow: 8px 10px 20px rgba(var(--sh), .16), -6px -6px 14px rgba(255, 255, 255, .85), inset 2px 2px 3px rgba(255, 255, 255, .9), inset -3px -4px 6px rgba(var(--sh), .06); }
.clay-in { background: var(--bg); border-radius: 22px; box-shadow: inset 5px 6px 12px rgba(var(--sh), .14), inset -5px -5px 10px rgba(255, 255, 255, .9); }
.puffy { border: 0; cursor: pointer; font-family: var(--head); font-weight: 800; color: var(--a1ink); background: var(--a1); border-radius: 24px; min-height: 56px; padding: 0 22px; font-size: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-align: center; line-height: 1.1;
  box-shadow: 0 8px 0 var(--a1d), 6px 14px 22px rgba(var(--sh), .25), inset 3px 4px 6px rgba(255, 255, 255, .45), inset -3px -5px 8px rgba(0, 0, 0, .08);
  transition: transform .12s ease, box-shadow .12s ease, opacity .2s; margin-bottom: 8px; }
.puffy:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 2px 0 var(--a1d), 3px 6px 10px rgba(var(--sh), .2), inset 3px 4px 6px rgba(255, 255, 255, .45); }
.puffy:disabled { opacity: .55; cursor: default; }
.puffy.soft { background: var(--surf); color: var(--ink); box-shadow: 0 6px 0 rgba(var(--sh), .14), 6px 12px 20px rgba(var(--sh), .14), inset 3px 3px 5px rgba(255, 255, 255, .9); }
.puffy.big { width: 100%; min-height: 64px; font-size: 1.45rem; }
.puffy.full { width: 100%; margin-top: auto; }
.tile { width: 46px; height: 46px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #fff; background: var(--a1);
  box-shadow: inset 3px 3px 5px rgba(255, 255, 255, .55), inset -3px -4px 6px rgba(0, 0, 0, .08), 4px 6px 10px rgba(var(--sh), .16); }
.tile svg { width: 24px; height: 24px; }
svg.st { fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; width: 22px; height: 22px; flex: 0 0 auto; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--ink); background: var(--surf);
  box-shadow: 5px 6px 12px rgba(var(--sh), .18), -4px -4px 10px rgba(255, 255, 255, .9), inset 2px 2px 3px rgba(255, 255, 255, .9); flex: 0 0 auto; }
.round.ghost { visibility: hidden; }
#music-btn[aria-pressed="true"] { background: var(--a2); color: #fff; }
.h { font-family: var(--head); font-weight: 800; line-height: 1.05; margin: 0; overflow-wrap: anywhere; }
.t-xl { font-size: 2rem; margin-top: 4px; }
.t-l { font-size: 1.6rem; }
.sub { margin: 0; color: var(--muted); }
.sub.tight { font-size: .85rem; }
.foot { margin: auto 0 0; font-size: .78rem; color: var(--muted); text-align: center; }
.foot.left { text-align: left; margin-top: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.full { width: 100%; }
.grow { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: .8rem; background: var(--surf); color: var(--ink);
  box-shadow: 3px 4px 8px rgba(var(--sh), .12), inset 2px 2px 3px rgba(255, 255, 255, .9); }
.chip svg.st { width: 15px; height: 15px; }
.chip.hot { background: var(--a2); color: #fff; }
.link { background: none; border: 0; padding: 4px 2px; margin: -4px 0; font-weight: 800; color: var(--a1d); text-decoration: underline; cursor: pointer; min-height: 32px; }

/* ---------- kid avatars ---------- */
.avatar { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--a5); flex: 0 0 auto; }
.avatar img, .av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
#kidbar button { width: 48px; height: 48px; padding: 0; border: 3px solid transparent; border-radius: 50%; overflow: hidden; cursor: pointer; background: var(--surf);
  box-shadow: 4px 5px 10px rgba(var(--sh), .18), -3px -3px 8px rgba(255, 255, 255, .9); }
#kidbar button img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
#kidbar button[aria-pressed="true"] { border-color: var(--a1); }

/* ---------- chọn bé ---------- */
.who { display: flex; flex-direction: column; gap: 12px; }
.who .card { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border: 0; cursor: pointer; text-align: left; width: 100%; }
.who .av { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; background: var(--k-a5);
  box-shadow: inset 3px 3px 5px rgba(255, 255, 255, .6), inset -3px -4px 6px rgba(0, 0, 0, .08); }
.who .txt { flex: 1; min-width: 0; }
.who .nm { display: block; font-size: 1.35rem; color: var(--k-ink); }
.who .ln { display: block; font-size: .85rem; color: var(--k-muted); }
.who .tile { width: 34px; height: 34px; border-radius: 12px; background: var(--k-a1); }
.who .tile svg { width: 18px; height: 18px; }
.who .card[data-kid="min"] { --k-a5: #e3d9f7; --k-ink: #2f2540; --k-muted: #665b7c; --k-a1: #7d5cc6; }
.who .card[data-kid="mon"] { --k-a5: #ffd6e0; --k-ink: #4a2630; --k-muted: #845e68; --k-a1: #d94f78; }
.who .card[data-kid="mila"] { --k-a5: #cdeec9; --k-ink: #24402b; --k-muted: #56735b; --k-a1: #5fb865; background: #eef5ec; }
.who .card.young .av { opacity: .85; }

/* ---------- trang chủ ---------- */
.hero { background: var(--a1); color: #fff; padding: 18px; position: relative; min-height: 190px; overflow: hidden; }
.t-hero { font-size: 1.6rem; max-width: 58%; color: #fff; }
.hero-sub { margin: 6px 0 0; max-width: 55%; font-size: .88rem; opacity: .95; }
.kimg { filter: drop-shadow(0 10px 12px rgba(var(--sh), .18)); }
.hero .kimg { position: absolute; right: 4px; bottom: -14px; height: 118%; width: auto; max-width: 52%; object-fit: contain; object-position: right bottom; }
.hero .note { position: absolute; left: 18px; bottom: 16px; width: 24px; height: 24px; color: #fff; opacity: .85; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.stat .tile { width: 38px; height: 38px; border-radius: 13px; }
.stat .tile svg { width: 20px; height: 20px; }
.stat .t2 { background: var(--a2); }
.stat .t3 { background: var(--a4); }
.stat .num { font-size: 1.5rem; }
.stat .lbl { font-size: .72rem; color: var(--muted); }

/* ---------- quay trò ---------- */
.reel-wrap { width: 100%; padding: 16px; margin-top: 8px; background: var(--a3); }
.reel-box { height: 150px; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 0 10px; }
.reel { font-size: 1.7rem; text-align: center; }
#spin-img { height: 190px; width: auto; margin-top: 6px; object-fit: contain; }

/* ---------- thẻ trò ---------- */
.stage-card { padding: 10px; background: var(--a4); }
.stage { position: relative; overflow: hidden; background: #fdf8f2; aspect-ratio: 4 / 3; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage .count { position: absolute; left: 10px; top: 10px; font-size: .78rem; }
.step-btn { position: absolute; top: 50%; width: 44px; height: 44px; transform: translateY(-50%); opacity: .94; }
.step-btn.left { left: 8px; }
.step-btn.right { right: 8px; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.dots i { height: 8px; width: 8px; border-radius: 99px; background: var(--a5); transition: width .2s, background-color .2s; }
.dots i.on { width: 22px; background: var(--a1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips .chip { min-width: 0; }
.chips .chip span { overflow-wrap: anywhere; }
.stepbox { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 1.05rem; min-height: 64px; }
.stepbox .num { width: 34px; height: 34px; border-radius: 11px; font-family: var(--head); font-weight: 800; font-size: 1.1rem; }
.step-text { flex: 1; min-width: 0; overflow-wrap: break-word; white-space: normal; text-overflow: clip; }
.safety { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: .85rem; color: var(--muted); }
.safety svg.st { width: 18px; height: 18px; margin-top: 1px; color: var(--a1d); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: auto; }
.actions .puffy { flex: 1 1 auto; font-size: 1.05rem; padding: 0 14px; }
.actions #done-btn { flex: 1 1 200px; }
.actions .icon-only { flex: 0 0 64px; padding: 0; }
.actions .icon-only svg.st { width: 24px; height: 24px; }

/* ---------- kỷ niệm ---------- */
.streakbox { padding: 14px 16px; }
.streakbox p { margin: 0; }
.best { color: var(--a1d); }
.empty { padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.empty img { height: 190px; width: auto; object-fit: contain; }
.empty p { margin: 0; font-size: 1.05rem; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.grid figure { position: relative; margin: 0; padding: 8px 8px 10px; content-visibility: auto; contain-intrinsic-size: auto 210px; background: var(--surf); border-radius: 26px;
  box-shadow: 8px 10px 20px rgba(var(--sh), .16), -6px -6px 14px rgba(255, 255, 255, .85), inset 2px 2px 3px rgba(255, 255, 255, .9); }
.grid figure:nth-child(odd) { transform: rotate(-1.6deg); }
.grid figure:nth-child(even) { transform: rotate(1.6deg); }
.grid .ph { aspect-ratio: 1; background: var(--a5); border-radius: 22px; overflow: hidden; box-shadow: inset 5px 6px 12px rgba(var(--sh), .14); }
.grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.grid figcaption { font-size: .78rem; margin-top: 6px; overflow-wrap: anywhere; }
.grid figcaption span { display: block; color: var(--muted); }
.grid .del { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .88); color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 2px 3px 6px rgba(var(--sh), .25); }
.grid .del svg.st { width: 16px; height: 16px; }
.grid .del.ask { width: auto; border-radius: 17px; padding: 0 10px; background: #d33; color: #fff; font-size: .72rem; }

/* ---------- hồ sơ ---------- */
.plist { display: flex; flex-direction: column; gap: 12px; }
.prow { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.prow .top { display: flex; align-items: center; gap: 12px; }
.prow .av { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--a5); flex: 0 0 auto; }
.prow .nm { font-size: 1.25rem; }
.prow .age { margin: 0; font-size: .85rem; color: var(--muted); }
.prow .form { display: flex; gap: 10px; align-items: stretch; }
.prow input { flex: 1; min-width: 0; min-height: 48px; border: 0; border-radius: 16px; padding: 0 14px; background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem;
  box-shadow: inset 4px 5px 10px rgba(var(--sh), .14), inset -4px -4px 8px rgba(255, 255, 255, .9); }
.prow .puffy { min-height: 48px; font-size: 1.05rem; padding: 0 18px; margin-bottom: 6px; border-radius: 18px; box-shadow: 0 5px 0 var(--a1d), 4px 8px 14px rgba(var(--sh), .22), inset 2px 3px 5px rgba(255, 255, 255, .45); }
.prow .msg { margin: 0; font-size: .85rem; min-height: 1.2em; color: var(--muted); }
.prow .msg.bad { color: #b3261e; }

/* ---------- nav ---------- */
.nav { display: flex; justify-content: space-around; padding: 10px 8px; margin-top: auto; position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 5; }
.nav button { border: 0; background: transparent; color: var(--muted); font-weight: 800; font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 76px; min-height: 48px; cursor: pointer; border-radius: 16px; padding: 6px; }
.nav button[aria-current="page"] { color: var(--ink); background: var(--bg); box-shadow: inset 3px 3px 6px rgba(var(--sh), .12), inset -3px -3px 6px rgba(255, 255, 255, .9); }

/* ---------- sau "Chơi xong" ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(36, 30, 50, .42); padding: 16px; overflow-y: auto; }
.sheet-card { width: 100%; max-width: 480px; margin: auto; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.sheet-kid { height: 130px; width: auto; object-fit: contain; }
.sheet-thumb { width: 160px; height: 160px; object-fit: cover; border-radius: 22px; box-shadow: 6px 8px 16px rgba(var(--sh), .25); }
.sheet-msg { margin: 0; min-height: 1.4em; color: var(--muted); }
.sheet-btns { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.sheet-btns .puffy { width: 100%; }
#toast { position: fixed; left: 50%; bottom: max(84px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: min(92vw, 440px); padding: 12px 18px; border-radius: 18px; background: var(--ink); color: #fff; font-size: .95rem; text-align: center; }

/* ---------- chuyển động nhẹ ---------- */
@media (prefers-reduced-motion: no-preference) {
  .bob { animation: bob 2.4s ease-in-out infinite; }
  .hop { animation: hop 1.1s ease-in-out infinite; }
  .note { animation: note 1.8s ease-in-out infinite; }
  .reel.tick { animation: tick .09s ease-out; }
  @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
  @keyframes hop { 0%, 100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-16px) rotate(-3deg); } }
  @keyframes note { 0%, 100% { transform: translateY(0) rotate(-8deg); opacity: .9; } 50% { transform: translateY(-8px) rotate(6deg); opacity: 1; } }
  @keyframes tick { from { transform: translateY(-14px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
}

@media (min-width: 700px) {
  #app { padding-top: 28px; }
  .t-xl { font-size: 2.3rem; }
}
