/* Tro choi tu choi o nha — nhom hanh dong: Chan Zombie, Chem hoa qua.
   San choi (.tn-zb-san / .tn-cq-san) chi ton tai khi dang choi, co nen
   phong canh rieng; man gioi thieu / ket qua van dung nen chung. */

/* ---------- chung ---------- */
.tn-zombie .tn-san, .tn-chemqua .tn-san { min-height: min(66vh, 600px); }
.tn-zombie .tn-bay, .tn-chemqua .tn-bay { color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 0 14px rgba(0, 0, 0, .45); white-space: nowrap; }
.tn-zombie .tn-bay.sai, .tn-chemqua .tn-bay.sai { color: #ffc4c4; }
.tn-zombie .tn-bay.vang, .tn-chemqua .tn-bay.vang { color: #ffe08a; }
.tn-zombie .tn-moi small, .tn-chemqua .tn-moi small { color: var(--fg-text-muted); }
/* hinh ve (sprite SVG trong /images/game/) */
.tn-zb-san img, .tn-cq-san img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
.tn-moi-anh { display: inline-block; width: 1.3em; height: 1.3em; vertical-align: middle; filter: drop-shadow(0 4px 3px rgba(43, 29, 58, .25)); }

/* ══════════════ CHAN ZOMBIE ══════════════ */
.tn-zb-nhan, .tn-cq-nhan {
  font-size: .85rem; font-weight: 800; color: var(--fg-text-muted); background: var(--color-gray-100);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.tn-zb-goi, .tn-cq-goi { font-size: 1.5rem; line-height: 1; }

.tn-zb-san {
  --zb-w: 84px;
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  /* vuon dem: anh trang goc phai, bai co lap lai */
  background:
    radial-gradient(70% 55% at 100% 0%, rgba(255, 243, 196, .22), transparent 70%),
    url(/images/game/zombie-lawn.svg) 0 0 / 160px 120px repeat,
    linear-gradient(180deg, #2f6158 0%, #2f6b45 45%, #275c3b 100%);
}
.tn-zb-lan { position: absolute; left: 0; right: 0; border-bottom: 2px dashed rgba(10, 30, 20, .28); }
.tn-zb-lan:nth-child(odd) { background: rgba(255, 255, 255, .05); }
.tn-zb-lan:nth-child(even) { background: rgba(0, 0, 0, .07); }
.tn-zb-so {
  position: absolute; right: 8px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: #fff8ec; background: rgba(43, 29, 58, .55);
}
/* cot nha: troi dem co trang sao, ngoi nha dung tren bai co */
.tn-zb-nha {
  position: absolute; left: 0; top: 0; bottom: 0; width: 15%; z-index: 2;
  display: flex; align-items: flex-end; justify-content: center;
  background:
    radial-gradient(circle at 50% 9%, #fff3c4 0 12px, rgba(255, 248, 236, .16) 13px 21px, transparent 22px),
    radial-gradient(circle at 22% 24%, #fff8ec 0 1.4px, transparent 2.4px),
    radial-gradient(circle at 80% 31%, #fff8ec 0 1.2px, transparent 2.2px),
    radial-gradient(circle at 28% 45%, rgba(255, 248, 236, .8) 0 1px, transparent 2px),
    radial-gradient(circle at 74% 56%, rgba(255, 248, 236, .7) 0 1.2px, transparent 2.2px),
    radial-gradient(150% 26% at 50% 100%, #3f8a55 0 60%, transparent 61%),
    linear-gradient(180deg, #1b244d 0%, #243a5e 45%, #2c5568 100%);
  box-shadow: inset -4px 0 0 rgba(43, 29, 58, .35), 4px 0 12px rgba(0, 0, 0, .25);
}
.tn-zb-mai {
  display: block; width: 88%; max-width: 120px; height: auto; margin-bottom: 7%;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .3));
}
.tn-zb-nha.tn-zb-rung { animation: tnZbRung .45s ease; box-shadow: inset 0 0 0 4px #e0574f, inset 0 0 40px rgba(224, 87, 79, .65), 4px 0 12px rgba(0, 0, 0, .25); }
/* hang rao: phan tu goc van rong 10px (vi tri dung cua zombie khong doi), hinh rao ve lan sang trai */
.tn-zb-rao { position: absolute; top: 0; bottom: 0; width: 10px; z-index: 2; pointer-events: none; }
.tn-zb-rao::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -14px; right: -2px;
  background: url(/images/game/zombie-fence.svg) 50% 0 / 100% auto repeat-y;
  filter: drop-shadow(3px 2px 0 rgba(0, 0, 0, .2));
}

.tn-zb-z {
  position: absolute; width: var(--zb-w); transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin: 0; padding: 4px 0; border: none; background: none; font: inherit; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.tn-zb-z:focus-visible { outline: 3px solid var(--color-gold-500); outline-offset: 2px; border-radius: 12px; }
.tn-zb-z:disabled { cursor: default; }
.tn-zb-z.tn-zb-moi { animation: tnZbHien .35s ease both; }
/* bien chu nam tren dau gay ma zombie dang om (gay nam trong hinh zombie) */
.tn-zb-bien {
  position: relative; z-index: 1;
  min-width: 70%; padding: 2px 6px; border-radius: 9px; text-align: center; white-space: nowrap;
  font-family: var(--font-hanzi); font-weight: 700; font-size: 1.3rem; line-height: 1.15;
  color: #2b1d3a; background: #fff8ec; border: 2.5px solid #2b1d3a; box-shadow: 0 3px 0 #2b1d3a;
}
.tn-zb-bien.dai { font-size: 1.05rem; }
.tn-zb-bien.rat-dai { font-size: .85rem; }
.tn-zb-em {
  display: block; width: calc(var(--zb-w) * .76); height: auto; aspect-ratio: 100 / 120;
  margin-top: calc(var(--zb-w) * -.11); transform-origin: 50% 100%;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .3)); animation: tnZbDi .7s ease-in-out infinite alternate;
}
/* dam khoi "phut" khi ha guc (an cho toi luc tn-zb-poof) */
.tn-zb-khoi {
  position: absolute; left: 50%; bottom: 2px; width: calc(var(--zb-w) * .72); height: auto; aspect-ratio: 1;
  transform: translateX(-50%); opacity: 0;
}
.tn-zb-z.tn-zb-cho .tn-zb-em { animation: tnZbLac .3s ease-in-out infinite alternate; }
.tn-zb-z.tn-zb-giat .tn-zb-bien { animation: tnLac .35s ease; background: #ffd6d6; border-color: #c62828; box-shadow: 0 3px 0 #c62828; }
.tn-zb-z.tn-zb-giat .tn-zb-em { filter: drop-shadow(0 0 6px rgba(255, 40, 40, .9)); }
.tn-zb-nghia {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%); z-index: 1; pointer-events: none;
  white-space: nowrap; font-size: .78rem; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .75);
  border-radius: 999px; padding: 2px 8px; animation: tnZbHien .2s ease both;
}
.tn-zb-z.tn-zb-poof { pointer-events: none; }
.tn-zb-z.tn-zb-poof .tn-zb-em { animation: tnZbMo .18s ease-out forwards; }
.tn-zb-z.tn-zb-poof .tn-zb-khoi { animation: tnZbPoof .5s ease-out forwards; }
.tn-zb-z.tn-zb-poof .tn-zb-bien { animation: tnZbMo .35s ease forwards; }
.tn-zb-z.tn-zb-vao { pointer-events: none; animation: tnZbMo .45s ease forwards; }
.tn-zb-bao {
  position: absolute; left: 50%; top: 45%; z-index: 15; pointer-events: none; white-space: nowrap;
  font-family: var(--font-display); font-weight: 900; font-size: clamp(1.6rem, 6vw, 2.6rem); color: #fff;
  background: rgba(60, 20, 30, .6); border-radius: 18px; padding: 8px 24px;
  transform: translate(-50%, -50%); animation: tnZbBao 1.6s ease forwards;
}

@keyframes tnZbDi { from { transform: rotate(-6deg); } to { transform: rotate(6deg) translateY(-2px); } }
@keyframes tnZbLac { from { transform: translateX(-2px) rotate(-4deg); } to { transform: translateX(2px) rotate(4deg); } }
@keyframes tnZbHien { from { opacity: 0; } to { opacity: 1; } }
@keyframes tnZbMo { to { opacity: 0; } }
@keyframes tnZbPoof {
  0% { transform: translateX(-50%) scale(.5); opacity: 1; }
  45% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-10px) scale(1.5); opacity: 0; }
}
@keyframes tnZbRung { 20% { transform: translateX(-5px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes tnZbBao {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ══════════════ CHEM HOA QUA ══════════════ */
.tn-chemqua .tn-san.tn-cq-choi { touch-action: none; }
.tn-cq-san {
  --cq-kt: 72px;
  position: absolute; inset: 0; z-index: 0; overflow: hidden; cursor: crosshair;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  /* troi chieu ta: trang tron, vai vi sao, doi tim do phia duoi */
  background:
    url(/images/game/fruit-hills.svg) 50% 100% / 100% 28% no-repeat,
    radial-gradient(circle at 82% 15%, #fff3c4 0 30px, rgba(255, 248, 236, .16) 31px 46px, rgba(255, 248, 236, .07) 47px 62px, transparent 63px),
    radial-gradient(circle at 12% 12%, rgba(255, 248, 236, .9) 0 1.6px, transparent 2.6px),
    radial-gradient(circle at 34% 24%, rgba(255, 248, 236, .7) 0 1.2px, transparent 2.2px),
    radial-gradient(circle at 58% 9%, rgba(255, 248, 236, .85) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 66% 32%, rgba(255, 248, 236, .6) 0 1.1px, transparent 2.1px),
    radial-gradient(circle at 92% 40%, rgba(255, 248, 236, .7) 0 1.3px, transparent 2.3px),
    radial-gradient(60% 45% at 15% 10%, rgba(255, 196, 120, .2), transparent 70%),
    linear-gradient(180deg, #2e1a55 0%, #5b2770 42%, #a8326f 76%, #e0606a 100%);
}
.tn-cq-vet { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.tn-cq-qua { position: absolute; left: 0; top: 0; width: var(--cq-kt); height: var(--cq-kt); z-index: 3; pointer-events: none; will-change: transform; }
.tn-cq-em {
  position: absolute; left: 2%; top: 2%; width: 96%; height: 96%; display: block;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .35));
}
.tn-cq-qua.bom .tn-cq-em { filter: drop-shadow(0 0 8px rgba(255, 80, 60, .85)); }
.tn-cq-chu {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--font-hanzi); font-weight: 700; font-size: 1.35rem; line-height: 1.15;
  color: #2b1d3a; background: #fff8ec; border: 2.5px solid #2b1d3a; border-radius: 10px; padding: 0 8px;
  box-shadow: 0 3px 0 #2b1d3a;
}
.tn-cq-chu.dai { font-size: 1.12rem; }
.tn-cq-chu.rat-dai { font-size: .9rem; }
.tn-cq-so {
  position: absolute; left: -2px; top: -2px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff8ec;
  background: #2b1d3a; box-shadow: 0 0 0 2px rgba(255, 248, 236, .7);
}
.tn-cq-manh { position: absolute; left: 0; top: 0; width: var(--cq-kt); height: var(--cq-kt); z-index: 4; pointer-events: none; }
.tn-cq-nua { position: absolute; inset: 0; }
.tn-cq-nua img { position: absolute; left: 2%; top: 2%; width: 96%; height: 96%; display: block; }
.tn-cq-nua.phai img { transform: scaleX(-1); }     /* nua phai = nua trai lat guong */
.tn-cq-nua.trai { animation: tnCqTrai .7s ease-in forwards; }
.tn-cq-nua.phai { animation: tnCqPhai .7s ease-in forwards; }
.tn-cq-manh.no .tn-cq-nua { animation: tnCqNo .6s ease-out forwards; }
/* vet nuoc qua ban ra sau nhat chem */
.tn-cq-nuoc {
  position: absolute; left: -30%; top: -30%; width: 160%; height: 160%; display: block;
  opacity: 0; animation: tnCqNuoc .72s ease-out forwards;
}
.tn-cq-goiy {
  position: absolute; z-index: 7; pointer-events: none; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
  font-weight: 800; font-size: .95rem; color: #fff; background: rgba(150, 20, 40, .9);
  border-radius: 999px; padding: 4px 12px; transform: translate(-50%, -50%); animation: tnCqGoiY 1.7s ease forwards;
}
.tn-cq-san.tn-cq-do { animation: tnCqDo .45s ease; }

@keyframes tnCqTrai { to { transform: translate(-38px, 70px) rotate(-40deg); opacity: 0; } }
@keyframes tnCqPhai { to { transform: translate(38px, 70px) rotate(40deg); opacity: 0; } }
@keyframes tnCqNo { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }
@keyframes tnCqMo { to { opacity: 0; } }
@keyframes tnCqNuoc {
  0% { transform: scale(.35) rotate(0deg); opacity: .95; }
  35% { transform: scale(1) rotate(12deg); opacity: .9; }
  100% { transform: scale(1.08) rotate(16deg); opacity: 0; }
}
@keyframes tnCqGoiY {
  0% { opacity: 0; transform: translate(-50%, -30%); }
  12% { opacity: 1; transform: translate(-50%, -50%); }
  80% { opacity: 1; transform: translate(-50%, -60%); }
  100% { opacity: 0; transform: translate(-50%, -90%); }
}
@keyframes tnCqDo {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 60, 60, 0); }
  30% { box-shadow: inset 0 0 0 8px rgba(255, 60, 60, .75), inset 0 0 60px rgba(255, 60, 60, .5); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 60, 60, 0); }
}

@media (max-width: 520px) {
  .tn-zb-bien { font-size: 1.2rem; }
  .tn-zb-bien.dai { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tn-zb-em, .tn-zb-z.tn-zb-cho .tn-zb-em, .tn-zb-z.tn-zb-giat .tn-zb-bien, .tn-zb-nha.tn-zb-rung { animation: none !important; }
  .tn-zb-z.tn-zb-poof .tn-zb-em, .tn-zb-z.tn-zb-poof .tn-zb-bien { animation: tnZbMo .35s ease forwards !important; }
  .tn-zb-z.tn-zb-poof .tn-zb-khoi { animation: none !important; opacity: 0; }
  .tn-cq-nuoc { animation: tnCqMo .4s ease forwards !important; opacity: .8; }
  .tn-zb-bao { animation: tnZbMo 1.6s steps(1, end) forwards !important; }
  .tn-cq-nua.trai, .tn-cq-nua.phai, .tn-cq-manh.no .tn-cq-nua { animation: tnCqMo .4s ease forwards !important; }
  .tn-cq-goiy { animation: tnCqMo 1.7s steps(1, end) forwards !important; }
  .tn-cq-san.tn-cq-do { animation: none !important; box-shadow: inset 0 0 0 6px rgba(255, 60, 60, .6); }
}
