:root {
  --ink: #3a2e5c;
  --orange: #ff6b3d;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: linear-gradient(#9fdcff, #e8f7ff 55%, #fff3b0);
  font-family: "Baloo 2", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  color: var(--ink);
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120px 56px at 15% 12%, #fff 60%, transparent 62%),
    radial-gradient(160px 66px at 82% 20%, #fff 60%, transparent 62%),
    radial-gradient(140px 60px at 25% 88%, rgba(255,255,255,.8) 60%, transparent 62%);
}
button { font: inherit; color: inherit; touch-action: manipulation; }
#app { height: 100dvh; max-width: 560px; margin: 0 auto; position: relative; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; }

.screen {
  height: 100%;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  animation: in .25s ease;
  position: relative;
}
@keyframes in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ----- Gấu ----- */
.bear {
  display: inline-block; font-size: 64px; line-height: 1;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.08));
  transform-origin: 50% 90%;
}
.bear.huge { font-size: min(34vmin, 170px); }
.dance { animation: dance .6s ease-in-out 2; }
.dance-loop { animation: dance .8s ease-in-out infinite; }
@keyframes dance {
  0%, 100% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-14deg) translateY(-14px); }
  50% { transform: rotate(0) translateY(0) scale(1.08); }
  75% { transform: rotate(14deg) translateY(-14px); }
}
.coach { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.bubble {
  position: relative; flex: 1; min-height: 62px;
  display: flex; align-items: center;
  background: #fff; border-radius: 22px; padding: 10px 16px;
  font-size: clamp(18px, 5.2vw, 26px); line-height: 1.25;
  box-shadow: 0 5px 0 rgba(61,139,255,.18);
}
.bubble::before {
  content: ""; position: absolute; left: -10px; top: 50%; margin-top: -10px;
  border: 10px solid transparent; border-right-color: #fff; border-left: 0;
}

/* ----- Thanh trên ----- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.ttl { flex: 1; text-align: center; font-size: clamp(20px, 5.6vw, 28px); }
.spacer { width: 50px; flex: none; }
.btn-round {
  width: 50px; height: 50px; flex: none; border-radius: 50%; border: 0;
  background: #fff; font-size: 24px; cursor: pointer; padding: 0;
  display: grid; place-items: center; line-height: 1;
  box-shadow: 0 5px 0 rgba(0,0,0,.12);
}
.btn-round:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.btn-round.sm { width: 40px; height: 40px; font-size: 18px; }
.dots { flex: 1; display: flex; justify-content: center; gap: 8px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px #b8c4e6; }
.dot.done { background: #ffc61a; box-shadow: none; }
.dot.now { background: var(--orange); box-shadow: 0 0 0 4px rgba(255,107,61,.3); }

/* ----- Màn hình chính ----- */
.home { align-items: center; justify-content: center; gap: 10px; text-align: center; }
.home-bear { cursor: pointer; }
.title {
  margin: 0; font-size: clamp(34px, 10vw, 52px); line-height: 1.05;
  color: var(--orange); text-shadow: 0 4px 0 #fff, 0 7px 0 rgba(0,0,0,.08);
}
.menu { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; margin-top: 10px; }
.menu-btn {
  display: flex; align-items: center; gap: 14px;
  border: 0; border-radius: 28px; padding: 14px 20px;
  font-size: clamp(22px, 6.4vw, 30px); color: #fff; text-align: left; cursor: pointer;
  background: var(--bg); box-shadow: 0 8px 0 var(--sh);
}
.menu-btn .mi { font-size: 1.6em; }
.menu-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--sh); }
.c1 { --bg: #3d8bff; --sh: #2a62bd; }
.c2 { --bg: #ff6b9a; --sh: #c2436f; }
.c3 { --bg: #ffb41f; --sh: #c98400; }
.gear {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px;
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.7); font-size: 22px; opacity: .7;
}

/* ----- Danh sách cấp ----- */
.cards { display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 8px 2px 14px; flex: 1; }
.card {
  display: flex; align-items: center; gap: 14px;
  border: 0; background: #fff; border-radius: 26px; padding: 14px 16px;
  text-align: left; cursor: pointer; flex: none;
  box-shadow: 0 7px 0 rgba(61,139,255,.2);
}
.card:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(61,139,255,.2); }
.card .num {
  width: 56px; height: 56px; flex: none; border-radius: 50%;
  background: linear-gradient(#ffd23f, #ffa51f);
  display: grid; place-items: center; font-size: 28px;
}
.card .info { flex: 1; display: flex; flex-direction: column; }
.card .info b { font-size: clamp(17px, 4.8vw, 22px); }
.card .info small { font-size: 15px; opacity: .7; font-weight: 600; }
.card.locked { opacity: .55; filter: grayscale(.6); cursor: default; }
.stars { white-space: nowrap; }
.stars i { font-style: normal; font-size: 22px; color: #d7d9e6; }
.stars i.on { color: #ffc61a; text-shadow: 0 2px 0 #d99a00; }

/* ----- Khu chơi ----- */
.stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 14px; position: relative;
}
.field { display: grid; gap: 14px; justify-items: center; align-items: center; width: 100%; }
.field.grid { grid-template-columns: repeat(2, 1fr); max-width: 420px; --f: min(20vw, 92px); }
.field.grid3 { grid-template-columns: repeat(3, 1fr); max-width: 480px; --f: min(12vw, 56px); }
.field.row { grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 460px; --f: min(17vw, 76px); }
.field.col { grid-auto-flow: row; gap: 18px; max-width: 300px; --f: min(22vw, 92px); }
.field.wrap { display: flex; flex-wrap: wrap; justify-content: center; max-width: 460px; --f: min(12vw, 56px); }

.item {
  --s: 1;
  border: 0; background: #fff; border-radius: 28px; cursor: pointer;
  width: min(36vw, 170px); height: min(26vh, 160px);
  display: grid; place-items: center;
  font-size: calc(var(--s) * var(--f, 64px)); line-height: 1;
  box-shadow: 0 7px 0 rgba(0,0,0,.1);
  transition: transform .2s, opacity .25s;
}
.item:active { transform: translateY(4px); }
.field.col .item { height: min(22vh, 140px); }
.field.grid3 .item, .field.wrap .item { width: min(27vw, 130px); height: min(13vh, 110px); border-radius: 22px; }
.item.picked { background: #d8ffe6; box-shadow: 0 0 0 6px #3ccf7a, 0 7px 0 rgba(0,0,0,.1); }
.item.good, .ball.good { animation: pop .5s; }
.shake { animation: shake .45s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.3) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); } 80% { transform: translateX(7px); }
}
.popped { transform: scale(0) !important; opacity: 0; pointer-events: none; transition: transform .25s, opacity .25s; }

.balls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; justify-items: center; max-width: 440px; width: 100%; }
.ball {
  width: min(19vw, 84px); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 30% 28%, rgba(255,255,255,.8) 0 11%, transparent 12%), var(--c);
  box-shadow: inset -6px -8px 0 rgba(0,0,0,.14), 0 6px 0 rgba(0,0,0,.1);
}
.field.wrap .ball { width: min(18vw, 78px); }
.need { display: flex; gap: 8px; min-height: 40px; }
.slot { font-style: normal; font-size: 32px; color: #b8c4e6; }
.slot.on { animation: pop .4s; }
.steps { display: flex; gap: 14px; }
.steps i {
  font-style: normal; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: #b8c4e6; font-size: 22px;
  box-shadow: inset 0 0 0 3px #b8c4e6;
}
.steps i.on { background: #3ccf7a; color: #fff; box-shadow: none; }

/* ----- Kéo thả ----- */
.dragwrap {
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  width: 100%; height: 100%; padding: 8px 0 12px;
}
.dragrow { display: flex; justify-content: center; gap: 14px; width: 100%; }
.drag {
  touch-action: none; cursor: grab; position: relative; z-index: 2;
  width: min(27vw, 120px); height: min(27vw, 120px); border-radius: 50%;
  display: grid; place-items: center; font-size: min(16vw, 70px); line-height: 1;
  background: #fff; box-shadow: 0 7px 0 rgba(0,0,0,.1);
  animation: wiggle 1.6s ease-in-out infinite;
}
.drag.lift { animation: none; box-shadow: 0 18px 22px rgba(0,0,0,.2); }
@keyframes wiggle { 0%, 100% { rotate: -4deg; } 50% { rotate: 4deg; } }
.dest {
  width: min(40vw, 190px); height: min(40vw, 190px);
  border: 6px dashed var(--orange); border-radius: 32px;
  display: grid; place-items: center; font-size: min(24vw, 110px); line-height: 1;
  background: rgba(255,255,255,.55); transition: transform .15s, background .15s;
}
.dest.hot { background: #fff3b0; transform: scale(1.06); }
.dest.good { animation: pop .5s; }

/* ----- Nút lớn ----- */
.btn-big {
  border: 0; border-radius: 999px; padding: 16px 34px; cursor: pointer;
  font-size: clamp(22px, 6vw, 30px); color: #fff; background: #3ccf7a;
  box-shadow: 0 8px 0 #229a58;
}
.btn-big:active { transform: translateY(5px); box-shadow: 0 3px 0 #229a58; }
.btn-med {
  border: 0; border-radius: 999px; padding: 12px 20px; cursor: pointer;
  font-size: clamp(17px, 4.6vw, 21px); background: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.12);
}
.btn-med:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.btn-med.danger { color: #c1273d; }

/* ----- Tập nói ----- */
.speak .pic {
  flex: 1; min-height: 0; display: grid; place-items: center; text-align: center;
  font-size: min(30vw, 130px); line-height: 1.1; padding: 8px; margin: 6px 0;
  background: rgba(255,255,255,.55); border-radius: 32px;
}
.cap { min-height: 1.5em; text-align: center; font-size: clamp(22px, 6.2vw, 30px); color: #e0481f; margin: 4px 0; }
.recbox { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mic {
  width: min(38vw, 160px); height: min(38vw, 160px); border-radius: 50%; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff; font-size: clamp(16px, 4.6vw, 20px);
  background: radial-gradient(circle at 30% 25%, #ff9a8a, #ff4d6d);
  box-shadow: 0 10px 0 #c93352;
}
.mic .ico { font-size: min(15vw, 60px); line-height: 1; }
.mic:active { transform: translateY(5px); box-shadow: 0 5px 0 #c93352; }
.mic:disabled { opacity: .7; }
.mic.rec { background: radial-gradient(circle at 30% 25%, #ff6b6b, #d90429); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 0 0 18px rgba(255,77,109,.25), 0 10px 0 #c93352; } }
.recbar { width: min(60vw, 260px); height: 10px; border-radius: 99px; background: rgba(0,0,0,.08); overflow: hidden; visibility: hidden; }
.recbar.on { visibility: visible; }
.recbar i { display: block; height: 100%; width: 0; background: #ff4d6d; }
.recbar.on i { animation: fillbar 7s linear forwards; }
@keyframes fillbar { to { width: 100%; } }
.sp-actions { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; min-height: 124px; padding-top: 10px; }

/* ----- Mừng chiến thắng ----- */
.cele { align-items: center; justify-content: center; text-align: center; gap: 6px; overflow: hidden; }
.bear-wrap { position: relative; font-size: min(30vmin, 150px); line-height: 1; }
.bear-wrap .bear { font-size: 1em; }
.hat { position: absolute; left: 50%; top: -.3em; font-size: .55em; transform: translateX(-50%) rotate(10deg); z-index: 2; }
.headline { margin: 6px 0 0; font-size: clamp(24px, 7vw, 34px); color: var(--orange); text-shadow: 0 3px 0 #fff; }
.bigstars { display: flex; gap: 6px; }
.bigstars i {
  font-style: normal; font-size: min(18vw, 78px); line-height: 1; color: #d7d9e6; display: inline-block;
  animation: starin .6s calc(var(--i) * .6s + .5s) both cubic-bezier(.3, 1.8, .5, 1);
}
.bigstars i.lit { color: #ffc61a; text-shadow: 0 4px 0 #d99a00; }
@keyframes starin {
  0% { transform: scale(0) rotate(-90deg); }
  70% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.badge {
  background: #fff; border-radius: 99px; padding: 8px 20px; font-size: clamp(18px, 5vw, 24px);
  box-shadow: 0 5px 0 rgba(0,0,0,.1); animation: in .5s 1.6s both;
}
.newsticker {
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 24px; padding: 6px 18px;
  box-shadow: 0 6px 0 rgba(0,0,0,.1); animation: stickin .7s 2.2s both cubic-bezier(.3, 1.6, .5, 1);
}
.newsticker span { font-size: 46px; line-height: 1; }
.newsticker small { font-size: 18px; }
@keyframes stickin { from { transform: scale(0) rotate(20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.actions { position: relative; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 10px; }
.row2 { display: flex; gap: 10px; }
.balloons { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.balloon {
  position: absolute; bottom: -90px; font-size: clamp(44px, 12vw, 64px); line-height: 1;
  pointer-events: auto; cursor: pointer; filter: hue-rotate(var(--h, 0deg));
  animation: floatup 7s linear var(--d, 0s) infinite;
}
.balloon.popped { display: none; }
@keyframes floatup {
  0% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-60vh) translateX(18px) rotate(6deg); }
  100% { transform: translateY(-125vh) translateX(-10px) rotate(-6deg); }
}

/* ----- Hiệu ứng nhỏ ----- */
.spark { position: fixed; font-size: 26px; pointer-events: none; animation: spark .8s ease-out forwards; }
@keyframes spark {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.6); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3); }
}
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: rgba(40,30,70,.92); color: #fff; border-radius: 99px; padding: 10px 18px;
  font-size: 16px; z-index: 60; white-space: nowrap; animation: in .2s;
}

/* ----- Album ----- */
.albumhead { text-align: center; font-size: clamp(20px, 5.6vw, 26px); margin: 8px 0; }
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 4px 2px; }
.sticker {
  border: 0; border-radius: 24px; background: #fff; aspect-ratio: 1; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 6px 0 rgba(0,0,0,.1); opacity: .6; filter: grayscale(.8);
}
.sticker.own { opacity: 1; filter: none; background: linear-gradient(#fff, #fff7d6); }
.sticker .se { font-size: min(14vw, 64px); line-height: 1; display: inline-block; }
.sticker small { font-size: 14px; font-weight: 700; }
.congrats { text-align: center; font-size: 20px; margin: 14px 0; }

/* ----- Góc phụ huynh ----- */
.parent * { -webkit-user-select: text; user-select: text; }
.pbody { flex: 1; overflow: auto; padding: 8px 2px 20px; display: flex; flex-direction: column; gap: 14px; }
.pbody section { background: #fff; border-radius: 22px; padding: 14px 16px; font-weight: 600; box-shadow: 0 5px 0 rgba(0,0,0,.08); }
.pbody h3 { margin: 0 0 8px; font-size: 19px; }
.pbody p { margin: 6px 0 10px; line-height: 1.4; font-size: 16px; }
.pbody .hint { opacity: .75; font-size: 15px; }
.pbody details { margin-top: 10px; font-size: 15px; }
.pbody .btn-med { background: #eef3ff; margin: 4px 6px 4px 0; }
.tg, .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 17px; }
.tg input {
  appearance: none; -webkit-appearance: none; width: 54px; height: 30px; border-radius: 99px;
  background: #c7cbe0; position: relative; transition: .2s; flex: none; margin: 0;
}
.tg input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
.tg input:checked { background: #3ccf7a; }
.tg input:checked::after { left: 27px; }
.seg { display: flex; gap: 6px; }
.seg button { border: 0; border-radius: 99px; padding: 8px 14px; background: #eef3ff; font-size: 15px; cursor: pointer; }
.seg button.on { background: #3d8bff; color: #fff; }
.rec { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 15px; }
.rec span { flex: 1; }
.rec small { opacity: .65; }

/* ----- Màn hình thấp (xoay ngang) ----- */
@media (max-height: 560px) {
  .bear { font-size: 44px; }
  .bear.huge { font-size: 90px; }
  .stage { gap: 8px; }
  .item { height: min(24vh, 100px); }
  .menu-btn { padding: 8px 16px; }
  .bubble { min-height: 46px; }
}
