/* Thu cung hoc lenh 宠物 (public/js/nong-trai-thucung.js) */

/* ---- thu cung tren ban do: anh chan o goc duoi giua, dung thang trong goc nhin 3D (JS dat transform) ---- */
.tcg { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 50% 100%; transition: transform 0ms linear; will-change: transform; }
.tcg-nut { position: absolute; left: 12%; right: 12%; top: 22%; bottom: 4%; padding: 0; border: 0; background: none; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tcg-hinh { position: absolute; left: -16%; right: -16%; top: -28%; bottom: -5%; display: block; pointer-events: none; }
.tcg-hinh img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transform-origin: 50% 88%; }
.tcg.tu-dung .p-dung, .tcg.tu-ngoi .p-ngoi, .tcg.tu-nhay .p-nhay, .tcg.tu-ngu .p-ngu { opacity: 1; }
.tcg.trai .tcg-hinh { transform: scaleX(-1); }
body.dang-dat .tcg-nut, body.keo-vat .tcg-nut { pointer-events: none; }
/* tho nhe khi dung / ngoi, buoc chan khi di */
.tcg.tu-dung .p-dung, .tcg.tu-ngoi .p-ngoi { animation: tcg-tho 2.6s ease-in-out infinite; }
.tcg.tu-ngu .p-ngu { animation: tcg-tho 3.6s ease-in-out infinite; }
.tcg.di .tcg-hinh img { animation: tcg-buoc 0.26s ease-in-out infinite alternate; }
@keyframes tcg-tho { 50% { transform: scale(1.025, 0.97); } }
@keyframes tcg-buoc { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-7%) rotate(4deg); } }
/* lam xiec */
.tcg.dien-nhay .tcg-hinh, .tcg.dien-lai.tu-nhay .tcg-hinh { animation: tcg-nhay 0.42s ease-out infinite alternate; }
.tcg.trai.dien-nhay .tcg-hinh, .tcg.trai.dien-lai.tu-nhay .tcg-hinh { animation-name: tcg-nhay-t; }
@keyframes tcg-nhay { from { transform: translateY(0); } to { transform: translateY(-30%); } }
@keyframes tcg-nhay-t { from { transform: scaleX(-1) translateY(0); } to { transform: scaleX(-1) translateY(-30%); } }
.tcg.dien-xoay .tcg-hinh { animation: tcg-xoay 0.7s ease-in-out 3; }
@keyframes tcg-xoay { 0% { transform: scaleX(1); } 50% { transform: scaleX(-1) translateY(-6%); } 100% { transform: scaleX(1); } }
.tcg.dien-keu .tcg-hinh { animation: tcg-lac 0.14s linear 8; }
@keyframes tcg-lac { 0%, 100% { transform: rotate(0); } 33% { transform: rotate(-7deg); } 66% { transform: rotate(7deg); } }
.tcg.dien-bat .tcg-hinh { animation: tcg-nghieng 0.55s ease-in-out infinite alternate; transform-origin: 50% 90%; }
@keyframes tcg-nghieng { from { transform: rotate(-9deg); } to { transform: rotate(5deg); } }
.tcg.dien-dung .tcg-hinh img { animation: none; }
/* bong noi tren dau + chu z khi ngu */
.tcg-bong {
  position: absolute; left: 50%; bottom: 112%; z-index: 2; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; white-space: nowrap;
  background: #fff; border: 2px solid var(--vien); border-radius: 12px; box-shadow: 0 2px 0 var(--vien);
  font-size: 0.85rem; font-weight: 800; color: var(--chu); line-height: 1.3; pointer-events: none;
}
.tcg-bong[hidden] { display: none; }
.tcg-bong img { width: 22px; height: 22px; }
.tcg-bong b[lang="zh"] { font-family: 'Noto Serif SC', serif; font-size: 1rem; }
.tcg-bong small { font-size: 0.68rem; color: var(--mo); }
.tcg-zz { display: none; position: absolute; right: -6%; top: -18%; pointer-events: none; font-weight: 900; color: #5c6bc0; text-shadow: 0 1px 0 #fff; }
.tcg.zz .tcg-zz { display: block; }
.tcg-zz i { position: absolute; font-style: normal; font-size: 0.8rem; opacity: 0; animation: tcg-z 3s ease-in-out infinite; }
.tcg-zz i:nth-child(2) { animation-delay: 1s; font-size: 0.95rem; }
.tcg-zz i:nth-child(3) { animation-delay: 2s; font-size: 1.1rem; }
@keyframes tcg-z { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(14px, -22px); } }
/* che do nhe + giam chuyen dong: tat hoat anh trang tri */
body.nt-nhe .tcg, body.nt-nhe .tcg *, body.nt-nhe .tcg-to img { animation: none !important; }
body.nt-nhe .tcg-zz i { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .tcg, .tcg *, .tcg-to img { animation: none !important; }
  .tcg { transition-duration: 0ms !important; }
  .tcg-zz i { opacity: 1; }
}

/* ---- bong noi khi bam thu cung ---- */
.tcg-dau { gap: 8px; }
.tcg-anh { display: inline-block; width: 52px; flex: none; }
.tcg-anh img { width: 100%; height: auto; display: block; }
.tcg-dau [lang="zh"] { font-family: 'Noto Serif SC', serif; cursor: pointer; }
.tcg-goi { margin-bottom: 4px; }
.tcg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.tcg-chip {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 64px; min-height: 48px; padding: 3px 8px;
  border: 2.5px solid var(--vien); border-radius: 12px; background: #fff4c9; box-shadow: 0 2px 0 var(--vien); font: inherit; color: var(--chu); cursor: pointer;
}
.tcg-chip:active { transform: translateY(2px); box-shadow: none; }
.tcg-chip b { font-family: 'Noto Serif SC', serif; font-size: 1.05rem; line-height: 1.2; }
.tcg-chip small { font-size: 0.68rem; font-weight: 700; color: var(--mo); }
.tcg-chip i { font-style: normal; font-size: 0.66rem; font-weight: 700; color: var(--mo); }
.tcg-chip.nho i { display: none; }

/* ---- bang thu cung ---- */
.tcg-b, .tcg-b p, .tcg-b b, .tcg-b small, .tcg-b span, .tcg-day, .tcg-day p { color: var(--chu); text-shadow: none; }
.tcg-b small, .tcg-day small { color: var(--mo); }
.tcg-b [lang="zh"], .tcg-day [lang="zh"] { font-family: 'Noto Serif SC', serif; }
.tcg-b .nt-nut, .tcg-day .nt-nut { min-height: 44px; }
.tcg-gt { margin: 0 0 10px; padding: 10px 12px; border: 2.5px solid var(--vien); border-radius: 14px; background: #fff3e0; line-height: 1.5; }
.tcg-phu { margin: 6px 0; font-size: 0.85rem; font-weight: 600; color: var(--mo); }
.tcg-h { margin: 14px 0 6px; font-size: 1rem; }
.tcg-loai { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.tcg-loai-o {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 6px; min-height: 44px;
  border: 3px solid var(--vien); border-radius: 16px; background: #fff8ec; box-shadow: 0 3px 0 var(--vien); font: inherit; color: var(--chu); cursor: pointer;
}
.tcg-loai-o img { width: 76px; height: 76px; }
.tcg-loai-o b { font-size: 1.1rem; }
.tcg-loai-o small { font-size: 0.74rem; font-weight: 700; }
.tcg-loai-o span { font-size: 0.82rem; font-weight: 700; }
.tcg-loai-o em { font-style: normal; font-size: 0.8rem; font-weight: 900; margin-top: 2px; }
.tcg-loai-o em img { width: 15px; height: 15px; vertical-align: -3px; }
.tcg-loai-o.chon { background: #c8e6c9; box-shadow: 0 0 0 3px #43a047 inset, 0 3px 0 var(--vien); }
.tcg-loai-o.khoa { opacity: 0.55; background: #eceff1; }
.tcg-nhan { display: block; margin: 14px 0 6px; font-weight: 800; }
.tcg-ten-hang { display: flex; gap: 8px; align-items: center; }
.tcg-input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 12px; border: 2.5px solid var(--vien); border-radius: 12px; font: inherit; font-size: 1rem; background: #fff; color: var(--chu); }
.tcg-goiy { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tcg-goiy button { min-height: 44px; padding: 4px 12px; border: 2px solid var(--vien); border-radius: 99px; background: #fff; font: inherit; font-weight: 700; color: var(--chu); cursor: pointer; }
/* dau bang: hinh to + ten + thanh vui */
.tcg-dauto { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 2.5px solid var(--vien); border-radius: 16px; background: linear-gradient(180deg, #bfe8fb, #c8ec9f); }
.tcg-to { flex: none; width: 96px; }
.tcg-to img { display: block; width: 100%; height: auto; transform-origin: 50% 88%; animation: tcg-tho 2.6s ease-in-out infinite; }
.tcg-dauchu { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tcg-ten { font-size: 1.3rem; }
.tcg-dauchu [data-doc] { cursor: pointer; }
.tcg-vui { display: block; height: 12px; border: 2px solid var(--vien); border-radius: 99px; background: #fff; overflow: hidden; }
.tcg-vui i { display: block; height: 100%; background: #ffb74d; border-radius: 99px; }
.tcg-vui i.du { background: #66bb6a; }
/* danh sach lenh */
.tcg-ds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-top: 6px; }
.tcg-lenh { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 2.5px solid var(--vien); border-radius: 14px; background: #fff; }
.tcg-lenh.thuoc { background: #fffde7; }
.tcg-lenh.khoa { background: #f3f0ec; opacity: 0.7; }
.tcg-lenh-chu { display: flex; flex-direction: column; align-items: flex-start; min-width: 88px; min-height: 44px; padding: 0; border: 0; background: none; font: inherit; color: var(--chu); cursor: pointer; text-align: left; }
.tcg-lenh-chu b { font-size: 1.35rem; line-height: 1.2; }
.tcg-lenh-chu small { font-size: 0.78rem; font-weight: 700; }
.tcg-lenh-chu span { font-size: 0.8rem; font-weight: 700; }
.tcg-lenh-phai { flex: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tcg-cham { display: inline-flex; gap: 4px; align-items: center; font-size: 0.9rem; }
.tcg-cham i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--vien); background: #fff; }
.tcg-cham i.co { background: #66bb6a; }
.tcg-lenh-nut { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tcg-khoa, .tcg-xong { font-size: 0.8rem; font-weight: 800; color: var(--mo); }
.tcg-xong { color: #2e7d32; }
.tcg-ich { flex-basis: 100%; margin: 0; padding: 4px 8px; border-radius: 10px; background: #e8f5e9; font-size: 0.78rem; font-weight: 600; }
/* cho an */
.tcg-an { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tcg-mon { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border: 2.5px solid var(--vien); border-radius: 14px; background: #fff8ec; text-align: center; }
.tcg-mon img { width: 52px; height: 52px; }
.tcg-mon b { font-size: 1.05rem; cursor: pointer; }
.tcg-mon small { font-size: 0.72rem; font-weight: 700; }
.tcg-mon .nt-nut img { width: 15px; height: 15px; vertical-align: -3px; }
.tcg-mon.thieu { opacity: 0.6; }
.tcg-giup { margin: 4px 0; padding-left: 20px; font-size: 0.85rem; line-height: 1.6; }
/* choi */
.tcg-choi { margin-top: 10px; padding: 10px 12px; border: 2.5px dashed #e4d6c6; border-radius: 14px; line-height: 1.5; }
.tcg-choi-dau { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; }
.tcg-choi-dau img { width: 48px; height: 48px; }
.tcg-ket { text-align: center; }
.tcg-ket .tcg-ket-hinh { width: 120px; height: 120px; }
/* buoi day lenh */
.tcg-day { text-align: center; }
.tcg-day h2 { margin: 4px 0; }
.tcg-day-hinh img { width: 120px; height: 120px; }
.tcg-day-the {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; margin: 6px auto 10px; padding: 10px 26px;
  border: 3px solid var(--vien); border-radius: 18px; background: #fff4c9; box-shadow: 0 4px 0 var(--vien); font: inherit; color: var(--chu); cursor: pointer;
}
.tcg-day-the b { font-size: 2.4rem; line-height: 1.2; }
.tcg-day-the small { font-size: 1rem; font-weight: 800; }
.tcg-day-the span { font-size: 0.9rem; font-weight: 700; }
.tcg-mic.dang { background: #e53935; color: #fff; animation: tcg-mic 1s ease-in-out infinite; }
@keyframes tcg-mic { 50% { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0.3), 0 3px 0 var(--vien); } }
.tcg-tb { min-height: 1.5em; font-weight: 700; }
.tcg-link { min-height: 44px; padding: 4px 6px; border: 0; background: none; font: inherit; font-weight: 700; color: #1565c0; text-decoration: underline; cursor: pointer; }
.tcg-mau i { font-style: normal; font-size: 1.2rem; font-weight: 900; padding: 0 1px; }
.tcg-mau i.co { color: #2e7d32; }
.tcg-mau i.thieu { color: #c62828; text-decoration: underline wavy; }
.tcg-day-cau b { font-size: 1.6rem; cursor: pointer; }
.tcg-lua { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 420px; margin: 8px auto; }
.tcg-lua button {
  display: flex; flex-direction: column; align-items: center; min-height: 64px; padding: 6px; border: 3px solid var(--vien); border-radius: 14px;
  background: #fff; box-shadow: 0 3px 0 var(--vien); font: inherit; color: var(--chu); cursor: pointer;
}
.tcg-lua button b { font-family: 'Noto Serif SC', serif; font-size: 1.4rem; }
.tcg-lua button small { font-size: 0.8rem; font-weight: 700; color: var(--mo); }
.tcg-lua button.dung { background: #c8e6c9; }
.tcg-lua button.sai { background: #ffcdd2; }
@media (max-width: 640px) {
  .tcg-ds { grid-template-columns: minmax(0, 1fr); }
  .tcg-to { width: 76px; }
  .tcg-loai { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcg-an { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
