/* Style dùng chung - màu tươi, nút to, thân thiện bé 6-7 tuổi.
   (Đồng bộ biến màu khi tạo bản wireframe ở GĐ sau.)
   ĐƠN VỊ: dùng px cho mọi kích thước (KHÔNG dùng rem/em) - xem docs/CongNghe.md. */
/* ===== THEME KHU BÉ =====
   Mỗi theme = 1 bộ biến ĐẦY ĐỦ. Theme mặc định (Kẹo ngọt) ở :root.
   2 theme khác ghi đè khi <body> có class .theme-ocean / .theme-garden
   (JS gắn class theo lựa chọn lưu trong localStorage - xem kidtheme.js).
   THÊM THEME MỚI: copy đủ 10 biến dưới đây sang một khối .theme-<tên> - thiếu biến
   nào sẽ rơi về :root, dễ lệch tông. Nút chọn theme thêm ô màu ở navbar (base_kid). */
:root {
    /* Theme mặc định: "Kẹo ngọt" - tím-xanh vui + hồng kẹo + vàng điểm nhấn.
       Giữ tên biến cũ để template/khu quản lý không phải sửa. */
    --brand: #7b6cff;          /* tím-xanh: nút chính, navbar bé */
    --brand-dark: #5b4de0;
    --brand-soft: #f4f0ff;     /* nền pastel rất nhạt (mặc định mọi trang) */
    --brand-border: #ffd6ec;   /* viền hồng kẹo */
    --accent: #ffd93b;         /* vàng kẹo: điểm nhấn */
    --candy-pink: #ff7eb3;
    --candy-blue: #4f8cff;
    --candy-green: #33d685;
    --candy-orange: #ff924c;
    --ink: #3a2e5c;            /* chữ: tím than, đọc rõ trên nền sáng */
    /* Nền gradient khu bé (đưa vào biến để đổi theo theme) */
    --kid-bg:
        radial-gradient(1200px 500px at 15% -5%, #ffe3f3 0%, transparent 60%),
        radial-gradient(1000px 500px at 90% 0%, #e2ecff 0%, transparent 55%),
        linear-gradient(180deg, #fef1f9 0%, #eef4ff 100%);
}

/* Theme "Biển & trời" - xanh dương → xanh ngọc, điểm vàng nắng */
body.theme-ocean {
    --brand: #1e9fd8;
    --brand-dark: #157aa8;
    --brand-soft: #eaf7ff;
    --brand-border: #bce6f5;
    --accent: #ffd93b;
    --candy-pink: #24c4c4;     /* xanh ngọc thay hồng */
    --candy-blue: #2a8fe0;
    --candy-green: #33d6a8;
    --candy-orange: #ffb703;
    --ink: #133b52;
    --kid-bg:
        radial-gradient(1200px 500px at 15% -5%, #d6f0ff 0%, transparent 60%),
        radial-gradient(1000px 500px at 90% 0%, #d3f7ef 0%, transparent 55%),
        linear-gradient(180deg, #eaf7ff 0%, #e2fbf4 100%);
}

/* Theme "Vườn cổ tích" - xanh lá + vàng + cam ấm (hợp linh vật cây lớn dần) */
body.theme-garden {
    --brand: #46b649;
    --brand-dark: #2f8f32;
    --brand-soft: #f2fbee;
    --brand-border: #d6efc7;
    --accent: #ffcf33;
    --candy-pink: #ff9f68;     /* cam ấm thay hồng */
    --candy-blue: #56b657;
    --candy-green: #7bc043;
    --candy-orange: #fb8500;
    --ink: #2e4a24;
    --kid-bg:
        radial-gradient(1200px 500px at 15% -5%, #eafbdf 0%, transparent 60%),
        radial-gradient(1000px 500px at 90% 0%, #fff3d1 0%, transparent 55%),
        linear-gradient(180deg, #f3fbef 0%, #fdf6e3 100%);
}

body {
    background: var(--brand-soft);
    font-size: 17px;
}

/* ===== KHU CỦA BÉ: nền theo theme + chữ TO cho dễ nhìn (chỉ .body-kid) ===== */
body.body-kid {
    background: var(--kid-bg);
    background-attachment: fixed;
    font-size: 19px;              /* chữ nền to hơn cho bé dễ đọc */
    color: var(--ink);
}
body.body-kid h1 { font-size: 30px; }
body.body-kid .fs-5 { font-size: 22px !important; }   /* nhãn nút hoạt động */
body.body-kid .btn { font-size: 19px; }               /* nút to hơn toàn khu bé */
body.body-kid .small { font-size: 15px; }
/* Nút chọn đáp án trong game (Bootstrap btn-outline-primary) - bo tròn to, viền kẹo,
   hover tô nền tím-xanh. Chỉ trong khu bé để không đụng khu quản lý. */
body.body-kid .btn-outline-primary {
    border-width: 2px;
    border-color: var(--brand-border);
    border-radius: 18px;
    color: var(--ink);
    background: #fff;
}
body.body-kid .btn-outline-primary:hover,
body.body-kid .btn-outline-primary:focus {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* ===== Nút chọn theme trên navbar khu bé (kidtheme.js) ===== */
.theme-picker { position: relative; }
.theme-toggle {
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .5);
    color: #fff;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .32); }
/* Bảng chọn: các ô màu tròn để bé chưa biết chữ tự bấm */
.theme-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    display: none;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
    z-index: 1090;
}
.theme-menu.open { display: flex; }
.theme-swatch {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 3px solid #fff;
    outline: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch.active { outline-color: #333; }
/* Mỗi ô màu = ảnh thu nhỏ tông của theme tương ứng */
.theme-swatch.sw-candy  { background: linear-gradient(135deg, #7b6cff, #ff7eb3); }
.theme-swatch.sw-ocean  { background: linear-gradient(135deg, #2a8fe0, #24c4c4); }
.theme-swatch.sw-garden { background: linear-gradient(135deg, #46b649, #fb8500); }

.navbar-brand-bar {
    background: linear-gradient(90deg, var(--candy-blue), var(--brand) 55%, var(--candy-pink));
}
.navbar-brand-bar .navbar-brand {
    color: #fff;
    font-size: 22px;
}
/* Liên kết trên navbar màu trắng để nổi trên nền xanh */
.navbar-brand-bar .nav-link {
    color: rgba(255, 255, 255, .9);
    font-weight: 500;
}
.navbar-brand-bar .nav-link:hover,
.navbar-brand-bar .nav-link:focus { color: #fff; }
.navbar-brand-bar .navbar-toggler {
    border-color: rgba(255, 255, 255, .5);
}
.navbar-brand-bar .navbar-toggler-icon {
    filter: invert(1) grayscale(1) brightness(2);
}
.navbar-username { color: rgba(255, 255, 255, .85); }

/* Navbar KHU QUẢN LÝ: tông xám trung tính, tách biệt hẳn nav xanh của bé */
.navbar-manage-bar { background: #343a40; }
.navbar-manage-bar .navbar-brand { color: #fff; font-size: 20px; }
.navbar-manage-bar .nav-link { color: rgba(255, 255, 255, .85); font-weight: 500; }
.navbar-manage-bar .nav-link:hover,
.navbar-manage-bar .nav-link:focus { color: #fff; }
.navbar-manage-bar .navbar-toggler { border-color: rgba(255, 255, 255, .5); }
.navbar-manage-bar .navbar-toggler-icon { filter: invert(1) grayscale(1) brightness(2); }
/* Nền khu quản lý hơi xám để phụ huynh thấy rõ đang ở khu khác với khu của bé */
body.body-manage { background: #eef1f4; }

/* Ô nhập passcode: to, dễ bấm, ẩn ký tự */
.passcode-input { letter-spacing: 8px; text-align: center; font-size: 26px; }

/* Nút to dễ bấm cho bé - gradient vui + bóng màu "kẹo dẻo", nảy nhẹ khi hover */
.btn-kid {
    background: linear-gradient(135deg, var(--candy-blue), var(--brand));
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 12px 22px;
    font-weight: 700;
    box-shadow: 0 6px 0 rgba(91, 77, 224, .35), 0 8px 16px rgba(123, 108, 255, .28);
    transition: transform .1s ease, box-shadow .1s ease, filter .1s ease;
}
.btn-kid:hover { color: #fff; filter: brightness(1.05); transform: translateY(-2px); }
.btn-kid:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(91, 77, 224, .35); }

/* Thẻ hồ sơ bé / chủ đề - bo tròn, bóng hồng mềm, nảy nhẹ khi hover */
.child-card {
    border: 2px solid var(--brand-border);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(255, 126, 179, .12);
    transition: transform .1s ease, box-shadow .1s ease;
}
.child-card:hover { transform: translateY(-4px); box-shadow: 0 12px 22px rgba(255, 126, 179, .22); }
.child-avatar { font-size: 52px; line-height: 1; }

/* ===== Bảng điều khiển: thẻ khu (zone), số liệu (stat), khu quản lý ===== */
.zone-card {
    border: 2px solid var(--brand-border);
    border-radius: 20px;
    background: #fff;
    transition: transform .1s ease, box-shadow .1s ease;
}
.zone-card:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0, 0, 0, .08); }
/* Khu của bé: to, nhiều màu, icon lớn nảy khi hover */
.zone-kid .zone-icon { font-size: 52px; line-height: 1.2; transition: transform .15s ease; }
.zone-kid .zone-icon img { filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .22)); }
.zone-kid:hover .zone-icon { transform: scale(1.15) rotate(-4deg); }
.zone-kid .zone-title { font-size: 24px; font-weight: 900; text-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
/* 3 nút hoạt động: mỗi nút một gradient "kẹo" + bóng màu cùng tông, chữ trắng nổi */
.zone-kid.zone-a, .zone-kid.zone-b, .zone-kid.zone-c {
    color: #fff; border: none; border-radius: 24px;
}
.zone-kid.zone-a { background: linear-gradient(135deg, var(--candy-blue), var(--brand)); box-shadow: 0 10px 22px rgba(79, 140, 255, .35); }
.zone-kid.zone-b { background: linear-gradient(135deg, #ff9ec7, var(--candy-pink)); box-shadow: 0 10px 22px rgba(255, 126, 179, .38); }
.zone-kid.zone-c { background: linear-gradient(135deg, #ffcf5c, var(--candy-orange)); box-shadow: 0 10px 22px rgba(255, 146, 76, .38); }
.zone-kid.zone-a:hover, .zone-kid.zone-b:hover, .zone-kid.zone-c:hover {
    transform: translateY(-5px); filter: brightness(1.04);
}
/* Chữ con (mô tả) trên nền màu: trắng dịu để vẫn đọc rõ */
.zone-kid.zone-a .small, .zone-kid.zone-b .small, .zone-kid.zone-c .small { color: rgba(255, 255, 255, .92); }
/* Khu quản lý: gọn hơn, tông trung tính để phân biệt với khu của bé */
.zone-manage { border-color: #e2e6ea; }
.zone-manage .manage-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    background: var(--brand-soft); color: var(--brand-dark);
    font-size: 22px; flex: 0 0 auto;
}

/* Thẻ số liệu tổng quan */
.stat-card {
    border: 2px solid var(--brand-border);
    border-radius: 16px;
    background: #fff;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--brand-dark); }

/* ===== Tiến độ của bé (trang chủ khu bé) - sinh động, dễ thương ===== */
/* Thẻ tiến độ nền gradient tươi */
.progress-card {
    border: none;
    border-radius: 24px;
    background: linear-gradient(135deg, #fff6d5 0%, #ffe0ec 100%);
    box-shadow: 0 8px 20px rgba(255, 150, 100, .18);
}
/* ---- Sân khấu linh vật: tia sáng xoay + lấp lánh + linh vật nảy + bóng dưới chân ---- */
.pet-stage {
    position: relative; width: 260px; height: 240px; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
}
.pet-rays {
    position: absolute; inset: -10px; border-radius: 50%;
    background:
        radial-gradient(circle, rgba(255, 255, 255, .95) 0, rgba(255, 236, 150, .55) 38%, transparent 66%),
        repeating-conic-gradient(rgba(255, 210, 80, .32) 0 10deg, transparent 10deg 24deg);
    -webkit-mask: radial-gradient(circle, #000 45%, transparent 70%);
    mask: radial-gradient(circle, #000 45%, transparent 70%);
    animation: hero-spin 24s linear infinite;
}
.pet-emoji {
    position: relative; z-index: 2; line-height: 1; display: inline-block;
    animation: pet-bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 10px rgba(120, 70, 0, .18));
}
@keyframes pet-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.pet-floor {
    position: absolute; z-index: 1; bottom: 12px; left: 50%; width: 150px; height: 18px;
    transform: translateX(-50%); border-radius: 50%;
    background: radial-gradient(ellipse, rgba(140, 90, 20, .28), transparent 70%);
}
.pet-spark { position: absolute; z-index: 3; width: 34px; height: 34px; animation: hero-twinkle 2.4s ease-in-out infinite; }
.pet-spark-1 { top: 18px; right: 22px; }
.pet-spark-2 { top: 96px; left: 4px; width: 26px; height: 26px; animation-delay: -.8s; }
.pet-spark-3 { bottom: 40px; right: 0; width: 22px; height: 22px; animation-delay: -1.6s; }
@keyframes hero-twinkle {
    0%, 100% { transform: scale(.6) rotate(0); opacity: .3; }
    50% { transform: scale(1.1) rotate(20deg); opacity: 1; }
}
@keyframes hero-spin { to { transform: rotate(360deg); } }
/* Huy chương cấp: tròn vàng-cam viền trắng, gắn góc trên trái linh vật */
.pet-medal {
    position: absolute; z-index: 4; top: 14px; left: 6px; width: 66px; height: 66px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 50%; color: #fff; line-height: 1;
    background: radial-gradient(circle at 35% 30%, #ffd166, #ff8a00 70%, #e05e00);
    border: 4px solid #fff; box-shadow: 0 6px 14px rgba(224, 94, 0, .4);
    transform: rotate(-10deg);
}
.pet-medal span { font-size: 11px; font-weight: 800; letter-spacing: 1px; opacity: .9; }
.pet-medal b { font-size: 28px; font-weight: 900; text-shadow: 0 2px 0 rgba(150, 60, 0, .35); }
.pet-name {
    font-weight: 900; font-size: 32px; line-height: 1.15; color: #e86a00;
    text-shadow: 0 3px 0 #fff, 0 4px 8px rgba(232, 106, 0, .25);
}
.pet-description { font-size: 16px; color: #8a6d3b; font-style: italic; margin-top: 2px; }
/* Hành trình tới bạn kế tiếp: thanh to có chữ + trứng bí ẩn cuối thanh */
.pet-journey {
    display: flex; align-items: center; gap: 8px; max-width: 460px; margin: 14px auto 0;
}
.pet-journey .pet-progress { flex: 1; }
.pet-journey .pet-mystery { animation: pet-egg-hatch 1.6s ease-in-out infinite; filter: drop-shadow(0 0 10px rgba(255, 217, 59, .9)); }
.pet-next-teaser { font-size: 17px; color: var(--ink); margin-top: 4px; }
.pet-next-teaser b { color: #e86a00; }
/* Nút Bộ sưu tập: to, tím kẹo, icon sách 3D, nhấn xuống như nút thật */
.btn-collection {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 19px; font-weight: 800; color: #fff; border: none; border-radius: 22px;
    padding: 8px 22px 8px 14px;
    background: linear-gradient(135deg, #8f7bff, var(--brand-dark));
    box-shadow: 0 6px 0 #4436b8, 0 10px 20px rgba(91, 77, 224, .35);
    transition: transform .1s, box-shadow .1s;
}
.btn-collection:hover { color: #fff; transform: translateY(-2px); }
.btn-collection:active { transform: translateY(4px); box-shadow: 0 2px 0 #4436b8, 0 4px 10px rgba(91, 77, 224, .3); }
.btn-collection b { color: var(--accent); }

/* ---- Kho sao: ngôi sao 3D xoay tia sáng + số TO ---- */
.star-burst { position: relative; width: 170px; height: 150px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.star-burst-rays {
    position: absolute; inset: -6px; border-radius: 50%;
    background: repeating-conic-gradient(rgba(255, 196, 0, .35) 0 8deg, transparent 8deg 22deg);
    -webkit-mask: radial-gradient(circle, #000 30%, transparent 68%);
    mask: radial-gradient(circle, #000 30%, transparent 68%);
    animation: hero-spin 16s linear infinite;
}
.star-burst-img { position: relative; animation: star-pulse 2.2s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(240, 160, 0, .45)); }
@keyframes star-pulse {
    0%, 100% { transform: scale(1) rotate(-6deg); }
    50% { transform: scale(1.08) rotate(6deg); }
}
/* Số sao TO, vàng, có bóng cho nổi bật (bé nhìn rõ thành quả) - dùng cả ở màn luyện nói */
.stars-big {
    font-size: 64px;
    font-weight: 800;
    color: #f59e0b;
    text-shadow: 0 2px 0 #fff, 0 3px 4px rgba(0, 0, 0, .1);
    line-height: 1.1;
}
.stars-count {
    font-size: 76px; font-weight: 900; color: #ffb000; line-height: 1;
    text-shadow: 0 4px 0 #e07b00, 0 8px 14px rgba(224, 123, 0, .3);
    font-variant-numeric: tabular-nums;
}
.stars-label { font-size: 16px; font-weight: 700; color: #8a6d3b; margin-top: 6px; }
.stat-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 20px; font-weight: 800; border-radius: 20px; padding: 4px 14px 4px 8px;
    background: #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
}
.stat-pill-game { color: var(--brand-dark); }
.stat-pill-speech { color: #e0457b; }

/* Thanh tiến tới mốc linh vật kế tiếp */
.pet-progress {
    height: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .6);
    overflow: hidden;
}
.pet-progress-bar {
    height: 100%;
    border-radius: 16px;
    background: linear-gradient(90deg, #ffb703, #fb8500);
    transition: width .6s ease;
}
/* Bản to (trang chủ): viền trắng, vạch sọc chạy, chữ số sao nằm giữa thanh */
.pet-progress-lg {
    position: relative; height: 30px; border-radius: 16px;
    background: rgba(255, 255, 255, .85); border: 3px solid #fff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, .08), 0 3px 8px rgba(255, 150, 0, .2);
}
.pet-progress-lg .pet-progress-bar {
    background:
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, .28) 0 10px, transparent 10px 20px),
        linear-gradient(90deg, #ffcf3a, #ff8a00);
    background-size: 28px 28px, 100% 100%;
    animation: bar-stripes 1s linear infinite;
}
@keyframes bar-stripes { to { background-position: 28px 0, 0 0; } }
.pet-progress-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 900; color: #7a4b00; text-shadow: 0 1px 0 #fff;
}

/* Tủ huy hiệu: nền trắng mờ, tiêu đề có huy chương 3D */
.badge-shelf { background: rgba(255, 255, 255, .55); border-radius: 22px; padding: 14px 10px 18px; }
.badge-shelf-title { text-align: center; font-size: 20px; font-weight: 800; color: var(--ink); margin-bottom: 12px; }
.badge-shelf-title b { color: #e86a00; }
/* Lưới huy hiệu: các ô tròn trải thành KHỐI nhiều cột (tự xuống hàng), căn giữa */
.badge-grid { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.badge-chip {
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    border-radius: 50%;
    background: #fff;
    border: 3px dashed #e3dcf5;
    position: relative;
    cursor: default;
    transition: transform .12s ease;
}
.badge-chip:hover, .badge-chip:focus { transform: scale(1.15) rotate(-5deg); outline: none; z-index: 5; }
/* Đã đạt: viền gradient màu kẹo (luân phiên 5 màu) trên nền sáng */
.badge-chip.earned {
    --ring: linear-gradient(135deg, #ffd166, #ff9f1c);
    border: 4px solid transparent;
    background: radial-gradient(circle at 35% 30%, #fff, #fff6dc) padding-box, var(--ring) border-box;
    box-shadow: 0 5px 12px rgba(255, 160, 40, .35);
}
.badge-chip.earned:nth-child(5n+2) { --ring: linear-gradient(135deg, #ff9ec7, #ff5c9a); box-shadow: 0 5px 12px rgba(255, 92, 154, .3); }
.badge-chip.earned:nth-child(5n+3) { --ring: linear-gradient(135deg, #7fd3ff, #4f8cff); box-shadow: 0 5px 12px rgba(79, 140, 255, .3); }
.badge-chip.earned:nth-child(5n+4) { --ring: linear-gradient(135deg, #8ff0b5, #22c473); box-shadow: 0 5px 12px rgba(34, 196, 115, .3); }
.badge-chip.earned:nth-child(5n)   { --ring: linear-gradient(135deg, #c3b5ff, #7b6cff); box-shadow: 0 5px 12px rgba(123, 108, 255, .3); }
.badge-chip.earned .badge-icon { filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .15)); }
/* Icon render bằng <img> SVG offline (tag icon_img) - không phụ thuộc font hệ thống.
   Kích thước do tag đặt inline (width/height px); rule này chỉ chuẩn hoá cách hiển thị. */
.emoji-svg { display: inline-block; vertical-align: middle; }

/* Chưa đạt → làm mờ CHỈ phần icon (không grayscale cả chip → tooltip vẫn rõ) + ổ khoá góc */
.badge-icon { line-height: 1; }
.badge-chip.locked { background: rgba(255, 255, 255, .6); }
.badge-chip.locked .badge-icon { filter: grayscale(1) brightness(1.15); opacity: .35; }
/* Ổ khoá là phần tử riêng (.badge-lock) - KHÔNG dùng ::after vì ::after dành cho mũi nhọn tooltip */
.badge-lock {
    position: absolute; bottom: -4px; right: -4px;
    font-size: 14px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .2));
}

/* Tooltip ghi chú: hiện khi hover/focus vào chip (đẹp hơn title mặc định) */
.badge-chip[data-tip]::before {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    /* Cho phép XUỐNG DÒNG để bao trọn câu khen dài (không cắt chữ) */
    white-space: normal;
    width: max-content;
    max-width: 256px;
    text-align: center;
    line-height: 1.35;
    background: #2b2b2b;
    color: #ffd93b;             /* vàng nổi bật trên nền đậm cho bé dễ đọc */
    font-size: 16px;
    font-weight: 700;
    padding: 8px 13px;
    border-radius: 10px;
    box-shadow: 0 5px 13px rgba(0, 0, 0, .3);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease;
    z-index: 20;
    pointer-events: none;
    filter: none;               /* không bị xám theo chip locked */
}
/* Mũi nhọn nhỏ dưới tooltip (tam giác trỏ về chip) */
.badge-chip[data-tip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2b2b2b;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease;
    z-index: 20;
    pointer-events: none;
    filter: none;
}
.badge-chip[data-tip]:hover::before, .badge-chip[data-tip]:focus::before,
.badge-chip[data-tip]:hover::after,  .badge-chip[data-tip]:focus::after {
    opacity: 1; visibility: visible;
}

/* Chip chuỗi ngày (streak) */
.streak-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 20px; font-weight: 800; color: #e5484d;
    background: #fff; border-radius: 20px; padding: 4px 14px 4px 8px;
    box-shadow: 0 4px 10px rgba(229, 72, 77, .18);
}

/* ===== Hiệu ứng khích lệ cho bé (kidfx.js) - offline, thuần CSS ===== */
/* Lớp phủ toàn màn, không chặn thao tác (pointer-events:none) */
.kidfx-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1080; /* trên modal Bootstrap (1055) để bé luôn thấy */
}

/* Mảnh confetti rơi từ trên xuống, vừa rơi vừa xoay */
.kidfx-confetti {
    position: absolute;
    top: -12px;
    width: 10px;
    height: 14px;
    border-radius: 2px;
    opacity: .9;
    animation: kidfx-fall linear forwards;
}
@keyframes kidfx-fall {
    0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* Emoji to nảy giữa màn + câu động viên */
.kidfx-pop {
    position: absolute;
    left: 50%;
    top: 38%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    animation: kidfx-pop-in .35s cubic-bezier(.2, 1.4, .4, 1) both,
               kidfx-pop-out .3s ease-in 1.1s forwards;
}
.kidfx-pop-emoji { font-size: 80px; line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.kidfx-pop-text {
    font-size: 26px;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}
.kidfx-good .kidfx-pop-text { color: #2f8f2f; }   /* đúng: xanh lá vui */
.kidfx-soft .kidfx-pop-text { color: var(--brand-dark); } /* sai: xanh dịu, không đỏ gắt */

@keyframes kidfx-pop-in {
    0%   { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);  opacity: 1; }
}
@keyframes kidfx-pop-out {
    0%   { opacity: 1; }
    100% { transform: translate(-50%, -80%) scale(.9); opacity: 0; }
}

/* Banner "Huy hiệu mới!" giữa màn khi bé vừa mở khoá */
.kidfx-badge {
    position: absolute;
    left: 50%; top: 40%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: #fff;
    border: 3px solid #ffca3a;
    border-radius: 20px;
    padding: 16px 24px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
    animation: kidfx-pop-in .4s cubic-bezier(.2, 1.4, .4, 1) both,
               kidfx-pop-out .3s ease-in 1.8s forwards;
}
.kidfx-badge-title { font-weight: 800; color: #d96a00; }
.kidfx-badge-icon { font-size: 64px; line-height: 1.2; }
.kidfx-badge-name { font-weight: 800; font-size: 20px; color: #333; }
.kidfx-badge-desc { color: #666; }

/* ===== Tiến hoá linh vật (kidFx.evolve): màn phủ toàn trang ===== */
.kidfx-evolve {
    position: fixed; inset: 0; z-index: 1070; /* dưới lớp confetti (1080) để pháo giấy rơi phía trên */
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 16px; text-align: center;
    background: radial-gradient(circle at 50% 45%, #4b3a8f 0%, #241a4d 60%, #120c2a 100%);
    animation: kidfx-fade-in .35s ease-out both;
}
.kidfx-evolve.is-closing { animation: kidfx-fade-out .3s ease-in forwards; }
.kidfx-evolve-title {
    color: #ffe680; font-weight: 800; font-size: 26px; text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
    margin-bottom: 8px;
}
.kidfx-evolve-stage { position: relative; width: 300px; height: 300px; }
.kidfx-evolve-stage img, .kidfx-evolve-stage span {
    position: absolute; left: 30px; top: 30px; width: 240px; height: 240px;
    object-fit: contain; font-size: 180px; line-height: 240px;
}
/* Linh vật cũ: phát sáng + rung mạnh dần */
.kidfx-evolve-old {
    animation: kidfx-evolve-charge 2.6s ease-in forwards;
    filter: drop-shadow(0 0 12px #fff6b0);
}
/* Bóng trắng linh vật mới nhấp nháy xen kẽ (nhá hàng) */
.kidfx-evolve-shadow {
    opacity: 0; filter: brightness(0) invert(1) drop-shadow(0 0 16px #fff);
    animation: kidfx-evolve-blink 2.6s steps(1) forwards;
}
.kidfx-evolve-new { opacity: 0; transform: scale(.2); }
.kidfx-evolve-rays {
    position: absolute; inset: -60px; opacity: 0; border-radius: 50%;
    background: repeating-conic-gradient(rgba(255, 236, 140, .55) 0deg 10deg, transparent 10deg 24deg);
    -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%);
            mask: radial-gradient(circle, #000 25%, transparent 70%);
}
.kidfx-evolve-flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.kidfx-evolve-info { opacity: 0; transform: translateY(16px); }
.kidfx-evolve-name { color: #fff; font-weight: 800; font-size: 34px; text-shadow: 0 3px 10px rgba(0, 0, 0, .5); }
.kidfx-evolve-desc { color: #ffe680; font-size: 20px; font-weight: 700; }
.kidfx-evolve-count { color: #cfc6ff; font-size: 16px; margin-top: 4px; }

/* Sau khi loé sáng: linh vật cũ biến mất, linh vật mới bật ra giữa vòng tia sáng xoay */
.kidfx-evolve.is-revealed .kidfx-evolve-old,
.kidfx-evolve.is-revealed .kidfx-evolve-shadow { display: none; }
.kidfx-evolve.is-revealed .kidfx-evolve-new {
    animation: kidfx-evolve-pop .8s cubic-bezier(.2, 1.5, .4, 1) forwards,
               pet-bounce 2s ease-in-out .8s infinite;
    filter: drop-shadow(0 0 18px rgba(255, 230, 128, .9));
}
.kidfx-evolve.is-revealed .kidfx-evolve-rays { animation: kidfx-evolve-rays 8s linear infinite, kidfx-fade-in .6s both; }
.kidfx-evolve.is-revealed .kidfx-evolve-flash { animation: kidfx-evolve-flash .7s ease-out; }
.kidfx-evolve.is-revealed .kidfx-evolve-info { animation: kidfx-evolve-info .5s ease-out .5s forwards; }

@keyframes kidfx-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes kidfx-fade-out { to { opacity: 0; } }
@keyframes kidfx-evolve-charge {
    0%   { transform: scale(1) rotate(0); }
    20%  { transform: scale(1.03) rotate(-3deg); }
    30%  { transform: scale(1.03) rotate(3deg); }
    45%  { transform: scale(1.06) rotate(-5deg); filter: brightness(1.3) drop-shadow(0 0 20px #fff6b0); }
    55%  { transform: scale(1.06) rotate(5deg); }
    65%  { transform: scale(1.1) rotate(-7deg); }
    72%  { transform: scale(1.1) rotate(7deg); }
    79%  { transform: scale(1.12) rotate(-8deg); filter: brightness(2) drop-shadow(0 0 30px #fff); }
    86%  { transform: scale(1.12) rotate(8deg); }
    93%  { transform: scale(1.15) rotate(-8deg); filter: brightness(3) drop-shadow(0 0 40px #fff); }
    100% { transform: scale(1.2) rotate(0); filter: brightness(5) drop-shadow(0 0 50px #fff); }
}
@keyframes kidfx-evolve-blink {
    0%, 60% { opacity: 0; }
    64% { opacity: 1; } 70% { opacity: 0; }
    76% { opacity: 1; } 81% { opacity: 0; }
    86% { opacity: 1; } 90% { opacity: 0; }
    94% { opacity: 1; } 100% { opacity: 1; }
}
@keyframes kidfx-evolve-pop {
    0%   { opacity: 0; transform: scale(.2); }
    60%  { opacity: 1; transform: scale(1.25); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes kidfx-evolve-rays { to { transform: rotate(360deg); } }
@keyframes kidfx-evolve-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes kidfx-evolve-info { to { opacity: 1; transform: translateY(0); } }

/* ===== Bộ sưu tập linh vật ===== */
.pet-count { color: var(--brand); font-size: 24px; }
.pet-slot {
    position: relative; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 28px 8px 12px; border: 3px solid transparent; border-radius: 20px;
    background: #fff; box-shadow: 0 6px 16px rgba(91, 77, 224, .12);
    transition: transform .15s;
}
.pet-slot:hover { transform: translateY(-3px); }
.pet-slot:active { transform: scale(.97); }
.pet-slot-level {
    position: absolute; top: 8px; left: 10px; font-size: 13px; font-weight: 800;
    color: #fff; background: var(--brand); border-radius: 10px; padding: 1px 8px;
}
.pet-slot-name { font-weight: 800; color: var(--ink); font-size: 17px; line-height: 1.2; }
.pet-slot-hint { font-size: 14px; color: #8a7fb8; font-weight: 700; }
.pet-slot-current {
    border-color: #ffca3a; background: linear-gradient(180deg, #fff9e0, #fff);
    box-shadow: 0 0 0 4px rgba(255, 202, 58, .35), 0 8px 20px rgba(255, 170, 0, .3);
}
.pet-slot-current .pet-slot-img { animation: pet-bounce 2s ease-in-out infinite; }
.pet-slot-ribbon {
    position: absolute; top: -12px; right: 10px; font-size: 13px; font-weight: 800;
    color: #7a4b00; background: #ffd93b; border-radius: 12px; padding: 2px 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
/* Bạn kế tiếp: trứng "sắp nở" trên nền sáng, viền đứt phát sáng, trứng nảy + rung */
.pet-slot-next {
    background: radial-gradient(circle at 50% 45%, #fffbe0 0, #f1ecff 60%, #e6deff 100%);
    border-color: #9d8cff; border-style: dashed;
    animation: pet-slot-glow 1.8s ease-in-out infinite;
}
.pet-slot-next .pet-slot-img {
    animation: pet-egg-hatch 1.6s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(255, 217, 59, .9));
}
.pet-slot-next .pet-slot-name { color: var(--brand); }
.pet-slot-next .pet-slot-hint { color: #d96a00; font-size: 16px; }
@keyframes pet-slot-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(123, 108, 255, 0), 0 6px 16px rgba(91, 77, 224, .15); }
    50% { box-shadow: 0 0 0 8px rgba(123, 108, 255, .28), 0 6px 16px rgba(91, 77, 224, .15); }
}
/* Trứng sắp nở: nảy lên rồi rung nhanh như sắp vỡ */
@keyframes pet-egg-hatch {
    0%, 100% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-10px) rotate(0); }
    50% { transform: translateY(0) rotate(0); }
    58% { transform: rotate(-9deg); }
    66% { transform: rotate(9deg); }
    74% { transform: rotate(-6deg); }
    82% { transform: rotate(4deg); }
}
/* Bạn còn khoá: thẻ "bầu trời đêm" lấp lánh + trứng bí ẩn lắc lư (server KHÔNG gửi hình thật) */
.pet-slot-locked {
    background:
        radial-gradient(2px 2px at 20% 30%, #fff, transparent),
        radial-gradient(2px 2px at 75% 20%, #ffe680, transparent),
        radial-gradient(1.5px 1.5px at 60% 75%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 30% 80%, #b9e6ff, transparent),
        radial-gradient(2px 2px at 88% 62%, #fff, transparent),
        linear-gradient(160deg, #3b2a8f, #1f1550);
    box-shadow: 0 6px 16px rgba(31, 21, 80, .35);
}
.pet-slot-locked .pet-slot-img { animation: pet-egg-wobble 3s ease-in-out infinite; }
.pet-slot-locked:nth-child(odd) .pet-slot-img { animation-delay: -1.2s; }
.pet-slot-locked .pet-slot-name { color: #fff; }
.pet-slot-locked .pet-slot-hint { color: #ffd93b; }
.pet-slot-locked .pet-slot-level { background: rgba(255, 255, 255, .2); }
@keyframes pet-egg-wobble {
    0%, 70%, 100% { transform: rotate(0); }
    76% { transform: rotate(-8deg); }
    82% { transform: rotate(7deg); }
    88% { transform: rotate(-4deg); }
    94% { transform: rotate(2deg); }
}
.pet-zoom {
    position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(30, 20, 70, .65);
}
.pet-zoom-card {
    position: relative; width: 100%; max-width: 380px; padding: 36px 20px 20px; text-align: center;
    background: #fff; border-radius: 28px; box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
    animation: kidfx-evolve-pop .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
.pet-zoom-level {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    font-weight: 800; color: #fff; background: var(--brand); border-radius: 12px; padding: 2px 12px;
}
.pet-zoom-img img { width: 260px; height: 260px; object-fit: contain; animation: pet-bounce 2s ease-in-out infinite; }
.pet-zoom-card.pet-slot-next .pet-zoom-img img {
    animation: pet-egg-hatch 1.6s ease-in-out infinite; filter: drop-shadow(0 0 16px rgba(255, 217, 59, .9));
}
.pet-zoom-card.pet-slot-locked .pet-zoom-img img { animation: pet-egg-wobble 2s ease-in-out infinite; }
.pet-zoom-card.pet-slot-locked .pet-zoom-name { color: #ffd93b; }
.pet-zoom-card.pet-slot-locked .pet-zoom-desc { color: #fff; }
.pet-zoom-name { font-weight: 800; font-size: 28px; color: #d96a00; }
.pet-zoom-desc { font-size: 18px; color: var(--ink); }

/* Nghe lại giọng bé (khu quản lý): mỗi bản 1 ô có nhãn + trình phát */
.rec-card { border-radius: 16px; border-color: #ece7fb; }
.rec-item {
    width: 290px; padding: 8px 10px; border-radius: 12px;
    background: #f7f5ff; border: 1px solid #e6e0fb;
}
.rec-item.is-pinned { background: #fff8dc; border-color: #ffd93b; }
.rec-item audio { width: 100%; height: 36px; }
.rec-label { background: var(--brand); font-weight: 600; }
.rec-item.is-pinned .rec-label:first-child { background: #e0a800; }

/* Đồng hồ ghi âm (luyện phát âm): số không nhảy độ rộng */
.rec-clock { font-variant-numeric: tabular-nums; font-size: 15px; opacity: .9; }

/* Rung nhẹ khi chọn sai (gắn tạm class này vào phần tử muốn rung) */
.kidfx-shake { animation: kidfx-shake .4s; }
@keyframes kidfx-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Tôn trọng người dùng tắt hiệu ứng chuyển động */
@media (prefers-reduced-motion: reduce) {
    .kidfx-confetti { display: none; }
    .kidfx-evolve-old, .kidfx-evolve.is-revealed .kidfx-evolve-rays { animation: none; }
    .kidfx-pop { animation: kidfx-pop-in .2s both; }
    .pet-rays, .star-burst-rays, .pet-spark, .pet-progress-lg .pet-progress-bar { animation: none; }
}

/* ===== Mục chủ đề (cho bé / cho bố mẹ) - templates/_topic_sections.html ===== */
.topic-section { margin-bottom: 20px; }
.topic-section-title {
  font-weight: 700; font-size: 18px; color: var(--ink);
  cursor: pointer; padding: 8px 4px; margin-bottom: 8px;
}
.topic-section-count { font-weight: 400; font-size: 14px; color: #6c757d; margin-left: 6px; }
/* Mục cho bố mẹ: nền nhạt, tách khỏi phần của bé */
.topic-section-adult { background: #f6f4ff; border-radius: 18px; padding: 8px 12px 12px; }
/* Thẻ chủ đề người lớn: thiên về chữ - icon nhỏ hơn */
.topic-card-adult .child-avatar img { width: 40px; height: 40px; }
/* Game cần hình mà chủ đề không đủ hình → làm mờ, không bấm được */
.topic-card-disabled { opacity: .45; cursor: not-allowed; }
