/*# Biến thiết kế (màu, bóng), reset, khung trang, thành phần dùng chung (thẻ, nút, bàn phím, bóng nói) */
/* Biến thiết kế (màu, bóng, safe-area). Muốn đổi bảng màu: sửa ở đây. */
:root {
  --ink: #1D355E;
  --ink2: #445C79;
  --paper: #FFFBF2;
  --grid: #EFE7D6;
  --white: #fff;
  --yellow: #FFD23F;
  --orange: #FF8A3D;
  --green: #5CC98B;
  --blue: #4DA3FF;
  --pink: #FF6F91;
  --purple: #A78BFA;
  --teal: #2EC4B6;
  --y-soft: #FFF4C7;
  --o-soft: #FFE4D2;
  --g-soft: #DDF6E8;
  --b-soft: #E3EEFF;
  --p-soft: #FFE3EA;
  --pu-soft: #EFE8FF;
  --t-soft: #D3F6F1;
  --ok: #2E9E5B;
  --bad: #D6336C;
  --sat: env(safe-area-inset-top,0px);
  --sab: env(safe-area-inset-bottom,0px);
  --sky1: #C9E8FF;
  --sky2: #EAF6FF;
  --cream: #FFF8E6;
  --shadow: rgba(20,65,114,.18);
  /* chế độ giao diện: mặc định Bé Nam (xanh); Bé Nữ ghi đè ở dưới */
  --mode-accent: #1385E9;
  --mode-accent2: #FFB62A;
  --theme-border: #2B5792;
  --hero1: #FCFFFC;
  --hero2: #DCEEFF;
  --hero3: #A9DCFF;
}
html[data-theme="girl"] {
  --sky1: #FFE1F1;
  --sky2: #FFF0FA;
  --cream: #FFF3FC;
  --yellow: #FFC9E7;
  --orange: #F892BE;
  --green: #6BD7B8;
  --blue: #9B84F3;
  --pink: #F45FA8;
  --purple: #BC8BF7;
  --b-soft: #E9E5FF;
  --p-soft: #FFE3F2;
  --g-soft: #E6FFF5;
  --y-soft: #FFF1D3;
  --mode-accent: #E854A3;
  --mode-accent2: #AB84EB;
  --theme-border: #A14F9C;
  --ink: #43336E;
  --ink2: #695875;
  --shadow: rgba(111,52,126,.2);
  --hero1: #FFF5FC;
  --hero2: #FFE0F2;
  --hero3: #F2CEFF;
}
/* Reset, kiểu chữ, tiện ích nhỏ dùng chung. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: 'Nunito','Segoe UI',Roboto,'Noto Sans',sans-serif;
  font-weight: 600;
  line-height: 1.4;
  overscroll-behavior: none;
  background-size: 24px 24px;
  background-image: none;
  background: linear-gradient(180deg,var(--sky1),var(--sky2) 360px,var(--cream) 100%) fixed;
}

h1,h2,h3,.disp {
  font-family: 'Baloo 2','Nunito',sans-serif;
  font-weight: 800;
  margin: 0;
  line-height: 1.08;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,a:focus-visible,input:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

#app {
  max-width: 850px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

main {
  flex: 1;
  padding: 8px 14px calc(98px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
}

.muted {
  color: var(--ink2);
}

.tag {
  display: inline-block;
  padding: 3px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  font-size: .9rem;
  background: #fff;
  box-shadow: 0 2px 0 var(--ink);
}

.t1 {
  background: var(--green);
}

.t2 {
  background: #FFB020;
}

.t3 {
  background: #FF7A7F;
}

mark {
  background: var(--yellow);
  padding: 0 6px;
  border-radius: 6px;
  color: inherit;
}

.fr {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.05;
  font-weight: 800;
  margin: 0 3px;
  font-size: .95em;
  white-space: nowrap;
}

.fr i {
  font-style: normal;
  padding: 0 3px;
  min-width: 1ch;
  text-align: center;
}

.fr i:first-child {
  border-bottom: 2.5px solid currentColor;
}

.unit {
  font-weight: 800;
  font-size: 1.1rem;
}

.sep {
  width: 2px;
  height: 36px;
  background: var(--ink);
  opacity: .2;
  flex: none;
}


.bounce {
  animation: bounce 1.2s infinite;
}

table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

table.t td,table.t th {
  padding: 6px 4px;
  border-bottom: 2px solid var(--grid);
  text-align: left;
}

input.txt {
  width: 100%;
  min-height: 52px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 12px;
  font: inherit;
  font-size: 1.05rem;
  background: #fff;
}

.sw {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 0;
}

.sw input {
  width: 26px;
  height: 26px;
  accent-color: var(--ink);
}

svg text {
  font-family: 'Baloo 2','Nunito',sans-serif;
  font-weight: 800;
}

.sres {
  min-width: 6.5em;
}

.mascot {
  display: block;
}

.mascot-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px rgba(36,49,75,.15));
}

.fr::after {
  content: "\2060";
}

.mascot.m-cheer {
  animation: jump .7s ease-in-out infinite;
}

.mascot.m-think {
  animation: tilt 2.6s ease-in-out infinite;
  transform-origin: 50% 100%;
}

.mascot.m-happy {
  animation: bob 2.4s ease-in-out infinite;
}

.shake {
  animation: shake .35s;
}

textarea.txt {
  width: 100%;
  font-family: ui-monospace,monospace;
  resize: vertical;
}

main>* {
  animation: rise .5s cubic-bezier(.2,.9,.3,1) both;
}

main>*:nth-child(2) {
  animation-delay: .06s;
}

main>*:nth-child(3) {
  animation-delay: .12s;
}

main>*:nth-child(4) {
  animation-delay: .18s;
}

main>*:nth-child(n+5) {
  animation-delay: .22s;
}
/* Khung trang: thanh trên, thanh dưới, nút icon. */
.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--sat)) 14px 12px;
  position: sticky;
  top: 0;
  z-index: 15;
  background: linear-gradient(110deg,rgba(255,255,255,.92),rgba(255,255,255,.65));
  border-bottom: 2px solid rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
}

.top .ttl {
  flex: 1;
  min-width: 0;
}

.top .ttl small {
  display: block;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #3D5A80;
}

.top .ttl b {
  display: block;
  font-family: 'Baloo 2';
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 rgba(255,255,255,.7);
  font-size: 1.1rem;
  white-space: normal;
  line-height: 1.02;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  font-size: 1rem;
  background: linear-gradient(180deg,#FFF3B8,#FFD23F);
  box-shadow: 0 3px 0 var(--ink);
}

.ibtn {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: linear-gradient(180deg,#fff,#EAF2FF);
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s,box-shadow .08s;
}

.ibtn svg {
  width: 26px;
  height: 26px;
}

.ibtn.on {
  background: linear-gradient(180deg,#FFF3B8,#FFD23F);
}

nav.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  border-top: 2.5px solid var(--ink);
  display: flex;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0 12px calc(10px + var(--sab));
  pointer-events: none;
}

nav.bar .in {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 6px;
  pointer-events: auto;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 5px 0 var(--ink),0 12px 24px var(--shadow);
  padding: 6px;
  max-width: 520px;
}

nav.bar button {
  border: 2px solid transparent;
  background: transparent;
  font-weight: 800;
  font-size: .85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  border-radius: 20px;
  color: #5B6478;
  transition: transform .15s;
}

nav.bar button svg {
  width: 26px;
  height: 26px;
}

nav.bar button.on {
  border-color: var(--ink);
  background: linear-gradient(180deg,#FFF3B8,#FFD23F);
  color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(31,42,68,.15);
}

.logo {
  width: 44px;
  flex: none;
  filter: drop-shadow(0 3px 0 rgba(31,42,68,.2));
}

.logo .mascot {
  width: 44px;
  height: auto;
}

.pill+.pill {
  background: linear-gradient(180deg,#FFE0C2,#FF9B54);
}

.ibtn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--ink);
}

nav.bar button .ni {
  display: flex;
  transition: transform .2s;
}

nav.bar button.on .ni {
  transform: translateY(-2px) scale(1.18);
}

.logo,.logo .mascot {
  width: 44px;
}
/* Thành phần tái sử dụng: thẻ, nút, ô nhập, bàn phím, bóng nói, hình minh hoạ, sheet. */
.card {
  background: #fff;
  border: 2.5px solid var(--theme-border);
  padding: 16px;
  box-shadow: 0 5px 0 var(--theme-border),0 14px 24px var(--shadow);
  border-radius: 25px;
}

.card.flat {
  box-shadow: 0 4px 0 var(--theme-border),0 10px 20px var(--shadow);
}

.card h2 {
  font-size: 1.5rem;
}

.btn {
  min-height: 58px;
  padding: 8px 20px;
  border: 2.5px solid var(--ink);
  font-family: 'Baloo 2';
  font-weight: 800;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .08s,box-shadow .08s;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg,#fff,#E9EEF8);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink),0 10px 16px var(--shadow);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn.pri {
  background: linear-gradient(180deg,#FFE680,#FFB82E);
}

.btn.grn {
  background: linear-gradient(180deg,#8FE6B3,#35B56B);
}

.btn.blu {
  background: linear-gradient(180deg,#9FD0FF,#3D8FF0);
}

.btn.pnk {
  background: linear-gradient(180deg,#FFB0C4,#FF5C84);
}

.btn.sm {
  min-height: 48px;
  font-size: 1rem;
  padding: 6px 8px;
  gap: 6px;
  white-space: nowrap;
  border-radius: 14px;
}

.btn[disabled] {
  opacity: .45;
  pointer-events: none;
}

.btn.block {
  width: 100%;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .1s;
}

.fig {
  border: 2.5px solid var(--ink);
  overflow: hidden;
  position: relative;
  border-radius: 24px;
  background: linear-gradient(180deg,#fff,#F7FBFF);
  box-shadow: 0 5px 0 var(--ink),0 12px 22px var(--shadow);
}

.fig svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.fig svg * {
  transition: opacity .45s,transform .6s cubic-bezier(.3,.8,.3,1),fill .45s,stroke .45s,x .6s,y .6s,width .6s,height .6s,cx .6s,cy .6s,r .6s;
  transform-box: fill-box;
  transform-origin: center;
}

.fig.noanim svg * {
  transition: none;
}

.fig .cap {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  font-size: .95rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.say {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.say .mascot {
  width: 70px;
  flex: none;
  filter: drop-shadow(0 4px 0 rgba(31,42,68,.18));
}

.bub {
  flex: 1;
  border: 2.5px solid var(--ink);
  border-radius: 20px 20px 20px 6px;
  padding: 12px 14px;
  font-size: 1.15rem;
  line-height: 1.4;
  font-weight: 700;
  background: linear-gradient(180deg,#E6FAF6,#CDF3EC);
  box-shadow: 0 4px 0 var(--ink);
  position: relative;
}

.bub b,.q b {
  font-weight: 900;
}

.sol {
  background: #fff;
  border: 2.5px dashed var(--ink);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 1.1rem;
  line-height: 1.55;
}

.sol .ln {
  padding: 2px 0;
}

.sol .ln.new {
  animation: pop .5s;
}

.sol .ans {
  font-weight: 900;
}

.rule {
  border: 2.5px solid var(--ink);
  padding: 12px 14px;
  font-size: 1.1rem;
  background: linear-gradient(180deg,#FFF8D6,#FFF1B0);
  border-radius: 22px;
  box-shadow: 0 4px 0 var(--ink);
  position: relative;
  padding-top: 20px;
  margin-top: 6px;
}

.rule h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.rule ul {
  margin: 4px 0 0;
  padding-left: 1.1em;
}

.q {
  border: 2.5px solid var(--ink);
  padding: 14px 16px;
  font-size: 1.3rem;
  line-height: 1.5;
  font-weight: 700;
  border-radius: 24px;
  box-shadow: 0 5px 0 var(--ink),0 12px 22px var(--shadow);
  background: linear-gradient(180deg,#fff,#FBFDFF);
  position: relative;
}

.dots {
  display: flex;
  gap: 6px;
  flex: 1;
}

.dots i {
  flex: 1;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: #fff;
  height: 14px;
  transition: background .3s,transform .3s;
}

.dots i.ok {
  background: linear-gradient(180deg,#8FE6B3,#35B56B);
}

.dots i.no {
  background: #FF9EA2;
}

.dots i.cur {
  animation: pulse 1.2s infinite;
  background: linear-gradient(180deg,#FFE680,#FFB82E);
}

.parts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.part {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.part .lab {
  font-weight: 800;
  font-size: 1.15rem;
  min-width: 3.2rem;
}

.field {
  min-width: 120px;
  min-height: 58px;
  padding: 6px 14px;
  border: 3px solid var(--ink);
  background: #fff;
  font-family: 'Baloo 2';
  font-weight: 800;
  font-size: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 240px;
  border-radius: 18px;
  box-shadow: inset 0 3px 0 rgba(31,42,68,.08);
}

.field.act {
  background: var(--y-soft);
  box-shadow: 0 0 0 4px var(--yellow);
  animation: fglow 1.4s ease-in-out infinite;
}

.field.ok {
  background: var(--g-soft);
  border-color: var(--ok);
  animation: pop .4s;
}

.field.no {
  background: #FFE0E0;
  border-color: var(--bad);
}

.field .ph {
  opacity: .35;
}

.field.fr2 {
  flex-direction: column;
  min-height: 110px;
  gap: 4px;
  max-width: 120px;
  min-width: 90px;
}

.field.fr2 .sub {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.field.fr2 .sub.act {
  background: var(--y-soft);
  box-shadow: 0 0 0 3px var(--yellow);
}

.field.fr2 .bar {
  height: 3px;
  width: 100%;
  background: var(--ink);
}

.opts {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
  width: 100%;
}

.opt {
  min-height: 62px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 0 var(--ink);
  background: linear-gradient(180deg,#fff,#EDF3FF);
  border-radius: 18px;
  transition: transform .08s,box-shadow .08s;
}

.opt.sel {
  background: linear-gradient(180deg,#FFE680,#FFB82E);
}

.opt.ok {
  background: var(--g-soft);
  border-color: var(--ok);
}

.opt.no {
  background: #FFE0E0;
  border-color: var(--bad);
}

.pad {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 9px;
}

.pad button {
  min-height: 62px;
  border: 2.5px solid var(--ink);
  font-family: 'Baloo 2';
  font-weight: 800;
  font-size: 1.7rem;
  background: linear-gradient(180deg,#fff,#E7EEFB);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .06s;
}

.pad button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.pad .del {
  background: linear-gradient(180deg,#FFD0DA,#FF8FAA);
}

.pad .go {
  grid-column: span 2;
  font-size: 1.35rem;
  background: linear-gradient(180deg,#8FE6B3,#35B56B);
  color: #fff;
  text-shadow: 0 2px 0 rgba(31,42,68,.35);
}

.pad .w2 {
  grid-column: span 2;
}

.fb {
  border: 2.5px solid var(--ink);
  padding: 12px 14px;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.4;
  animation: pop .35s;
  border-radius: 22px;
  box-shadow: 0 4px 0 var(--ink);
}

.fb.ok {
  background: linear-gradient(180deg,#E6FBEE,#C8F2D9);
}

.fb.no {
  background: linear-gradient(180deg,#FFEDED,#FFD3D3);
}

.fb.info {
  background: linear-gradient(180deg,#E6FAF6,#CDF3EC);
}

.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(31,42,68,.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 92dvh;
  overflow: auto;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 16px 14px calc(16px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: up .25s;
  background: linear-gradient(180deg,#fff,#FFF8E6);
}

.bub.pop {
  animation: pop .35s;
}

.sheet .mascot {
  width: 110px;
  margin: 0 auto;
}

.fbm {
  display: flex;
  gap: 10px;
  align-items: center;
}

.fbm .mascot {
  flex: none;
  width: 64px;
  filter: drop-shadow(0 3px 0 rgba(31,42,68,.18));
}

.chip.on {
  background: var(--yellow);
}

.btn:before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg,rgba(255,255,255,.75),rgba(255,255,255,0));
  pointer-events: none;
}

.btn.pri.block,.mission .btn.sm {
  animation: glow 2.2s ease-in-out infinite;
}

.chip:active {
  transform: translateY(2px);
}

.rule h3:before {
  content: "📌 ";
}

.rule:before {
  content: "GHI NHỚ";
  position: absolute;
  left: 14px;
  top: -12px;
  background: var(--pink);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0 12px;
  font: 800 .8rem/22px 'Baloo 2';
  letter-spacing: .08em;
  box-shadow: 0 2px 0 var(--ink);
}

html[lang=en] .rule:before {
  content: "REMEMBER";
}

.bub:before {
  content: "";
  position: absolute;
  left: -12px;
  bottom: 10px;
  border: 10px solid transparent;
  border-right-color: var(--ink);
  border-left: 0;
}

.bub:after {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 12px;
  border: 8px solid transparent;
  border-right-color: #D9F6F0;
  border-left: 0;
}

.q:before {
  content: "❓";
  position: absolute;
  right: 10px;
  top: -14px;
  font-size: 1.1rem;
  background: var(--yellow);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.opt:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
