/* Học Vui – câu hỏi, bài học, trò chơi, màn hình kết thúc. */

/* Câu hỏi */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.timebar-fill { height: 100%; width: 100%; background: #ff7a59; transition: width .1s linear; }
.timebar { margin-bottom: 14px; }
.progress { margin-bottom: 14px; }
.q-prompt { display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; font-size: 1.35rem; font-weight: 900; margin-bottom: 10px; }
.q-prompt.long { font-size: 1.1rem; text-align: left; justify-content: flex-start; line-height: 1.5; }
.icon-btn { flex: none; width: 46px; height: 46px; font-size: 1.3rem; background: #e6e6ff; border: 2px solid var(--ink); border-radius: 50%; cursor: pointer; }
.q-visual { text-align: center; margin: 4px 0 14px; }
.big-emoji { font-size: 4.2rem; line-height: 1.1; margin-bottom: 6px; }
.big-expr { font-size: 2.3rem; font-weight: 900; letter-spacing: 1px; line-height: 1.3; }
.big-expr input { width: 4.2ch; margin-left: 6px; font-size: 1.6rem; text-align: center; border: var(--line); border-radius: 12px; }
.blank { display: inline-block; min-width: 1.6em; padding: 0 .25em; color: var(--accent); background: #fff3cf; border-bottom: 4px solid var(--accent); border-radius: 10px 10px 4px 4px; }
.clock { width: min(220px, 62vw); height: auto; }
.clock-face { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.clock-num { font: 800 10px var(--font); fill: var(--ink); }
.clock-hour, .clock-min { stroke: var(--ink); }
.clock-min { stroke: var(--accent); }
.clock-pin { fill: var(--ink); }

.q-options { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.q-options.n3 { grid-template-columns: repeat(3, 1fr); }
.opt {
  min-height: 64px; padding: 10px 12px; font-size: 1.5rem; font-weight: 900; background: #fff; border: var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.opt.opt-long { font-size: 1.1rem; }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt:disabled { cursor: default; }
.opt.right { background: var(--good-bg); border-color: var(--good); box-shadow: 0 4px 0 var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); box-shadow: 0 4px 0 var(--bad); animation: shake .35s; }
.feedback { margin-top: 16px; padding: 12px 14px; border-radius: 16px; border: 2px solid; }
.feedback.ok { background: var(--good-bg); border-color: var(--good); color: #0f6b30; }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); color: #9e2327; }
.explain { font-weight: 700; margin-top: 2px; }
.q > .btn { margin-top: 14px; width: 100%; }
.stage { min-height: 280px; }

/* Danh sách chọn chủ đề cho trò chơi */
.chip-group { margin: 12px 0; }
.chip-group-title { font-weight: 900; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select { min-height: 44px; padding: 6px 14px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; font-weight: 800; font-size: .95rem; cursor: pointer; }
.chip-select.sel { background: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--ink); }
.panel > .chip-select { margin-bottom: 4px; }

/* Săn bóng bay */
.balloon-q { min-height: 120px; margin-bottom: 10px; }
.balloon-q .big-expr { font-size: 1.9rem; }
.balloon-q .clock { width: 110px; }
.sky {
  --w: min(96px, 22vw); position: relative; height: min(50vh, 420px); min-height: 280px; overflow: hidden;
  background: linear-gradient(#a9dcff, #effaff); border: var(--line); border-radius: 18px;
}
.balloon {
  position: absolute; bottom: -150px; width: var(--w); height: calc(var(--w) * 1.2); margin-left: calc(var(--w) / -2); padding: 4px; border: 0; cursor: pointer;
  border-radius: 50% 50% 46% 46%; color: #fff; font-weight: 900; font-size: 1.15rem; line-height: 1.1; text-shadow: 0 2px 0 #0004;
  background: radial-gradient(circle at 30% 26%, #ffffff99 0 11%, transparent 12%), var(--c);
  box-shadow: inset -8px -10px 0 #0002;
  animation: rise linear forwards; will-change: transform;
}
.balloon::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 50px; background: #2a275088; }
.balloon.pop { animation-play-state: paused; scale: 1.4; opacity: 0; pointer-events: none; transition: scale .25s, opacity .25s; }
@keyframes rise { from { transform: translateY(0); } to { transform: translateY(calc(-1 * var(--rise, 500px))); } }

/* Lật thẻ */
.cards { display: grid; gap: 10px; }
.cards.cols3 { grid-template-columns: repeat(3, 1fr); }
.cards.cols4 { grid-template-columns: repeat(4, 1fr); }
.card { aspect-ratio: 3 / 4; padding: 0; background: none; border: 0; perspective: 700px; cursor: pointer; }
.card-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .35s; }
.card.open .card-inner, .card.done .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 4px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); font-size: 2.2rem; font-weight: 900; text-align: center; line-height: 1.1; word-break: break-word;
}
.card-face.front { background: repeating-linear-gradient(45deg, #7a7aea, #7a7aea 10px, #6b6be0 10px, #6b6be0 20px); color: #fff; }
.card-face.back { background: #fff; transform: rotateY(180deg); }
.card.small .card-face.back { font-size: 1.15rem; }
.card.done .card-face.back { background: var(--good-bg); border-color: var(--good); box-shadow: 0 4px 0 var(--good); }

/* Xếp số */
.slots { display: flex; gap: 8px; justify-content: center; margin: 12px 0 18px; }
.slot { flex: 1; max-width: 72px; aspect-ratio: 1; display: grid; place-items: center; font-size: 1.5rem; font-weight: 900; background: #f3f0ff; border: 3px dashed #a9a3d6; border-radius: 14px; }
.slot.filled { background: var(--good-bg); border: 3px solid var(--good); }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.tile { min-width: 76px; min-height: 76px; font-size: 1.9rem; font-weight: 900; background: #ffe08a; border: var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.tile.used { visibility: hidden; }
.tile.shake { animation: shake .35s; background: var(--bad-bg); }

/* Màn hình kết thúc, pháo giấy */
.end .big-emoji { font-size: 5rem; }
.end-line { font-size: 1.2rem; }
.record { color: #c46a00; font-weight: 900; font-size: 1.2rem; }
.stars-earned { display: inline-block; margin: 6px 0 10px; padding: 6px 22px; font-size: 1.8rem; font-weight: 900; background: #fff3cf; border: var(--line); border-radius: 999px; animation: bump .6s; }
.new-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0; }
.badge-pop { padding: 6px 14px; background: #ffe3f0; border: 2px solid var(--ink); border-radius: 999px; font-weight: 900; animation: bump .6s .2s backwards; }
.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -40px; animation: fall linear forwards; }

@keyframes fall { to { transform: translateY(110vh) rotate(420deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes bump { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

@media (max-width: 420px) {
  body { font-size: 17px; }
  .big-expr { font-size: 2rem; }
  .opt { font-size: 1.35rem; }
  .card-face { font-size: 1.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .opt.wrong, .tile.shake, .stars-earned, .badge-pop { animation: none; }
  .card-inner { transition: none; }
}
