/* tac-engine.css — เวที isometric (FAA.tac) · โหลดหลัง game.css
   canvas = ภาพฉาก (aria-hidden) · ตัวละครเป็น DOM sprite · ทุกการเคลื่อนไหวปิดเมื่อ reduced-motion */
.tac {
  --tw: 32px;
  position: relative; width: 100%; overflow: hidden; isolation: isolate;
  border-radius: 12px; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  background: #172133;
  background-image: radial-gradient(120% 85% at 50% 28%, #46597a 0%, #24304a 48%, #0f1626 100%);
  contain: layout paint;
}
.tac[data-light="day"] { background-color: #8fc3e4; background-image: radial-gradient(120% 90% at 50% 18%, #e9f6fd 0%, #a9d6f1 42%, #5a98c7 100%); }
.tac[data-light="sun"] { background-color: #e7a86a; background-image: radial-gradient(120% 90% at 30% 12%, #fff0c9 0%, #f4c487 38%, #a86a6e 100%); }
.tac[data-light="water"] { background-color: #3d9cc8; background-image: radial-gradient(120% 90% at 50% 15%, #d8f6ff 0%, #7fcbe8 40%, #1f5d8e 100%); }
/* ขอบมืด (vignette) + ลายเส้นบาง ๆ ของฉากหลัง */
.tac::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: repeating-linear-gradient(60deg, rgba(255,255,255,.035) 0 1px, transparent 1px 14px),
                    repeating-linear-gradient(-60deg, rgba(255,255,255,.035) 0 1px, transparent 1px 14px);
}
.tac::after {
  content: ""; position: absolute; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(5,8,20,.38) 100%);
  border-radius: inherit;
}
.tac[data-light="day"]::after, .tac[data-light="water"]::after { background: radial-gradient(130% 100% at 50% 45%, transparent 60%, rgba(10,30,60,.22) 100%); }

.tac-world { position: absolute; inset: 0; z-index: 1; transition: opacity .17s ease, transform .2s ease; transform-origin: 50% 55%; }
.tac-world.tac-fade { opacity: 0; }
.tac-world.tac-fade-r { transform: scale(.94) rotate(-4deg); }
.tac-world.tac-fade-l { transform: scale(.94) rotate(4deg); }
.tac-world.tac-in-l { transition: none; transform: scale(.94) rotate(4deg); }
.tac-world.tac-in-r { transition: none; transform: scale(.94) rotate(-4deg); }
.tac canvas { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }
.tac-base { z-index: 1; }
.tac-pulse { z-index: 2; animation: tacPulse .9s ease-in-out infinite alternate; }
.tac-flk { z-index: 2; mix-blend-mode: screen; animation: tacFlk 1.1s steps(1) infinite; }
.tac-cur { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.tac-units { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.tac-fx { z-index: 5; }
.tac-top { position: absolute; inset: 0; z-index: 6; pointer-events: none; }

/* ตัวละคร: ห่อด้วย .tac-u ที่จุดเท้า · .tac-us ยกตัวตอนกระโดด · เงาอยู่กับพื้น */
.tac-u { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.tac-ush {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(5,5,15,.5), rgba(5,5,15,.3) 55%, rgba(5,5,15,0));
}
.tac-us { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.tac .walker { position: absolute; left: 0; top: 0; z-index: auto; filter: none; }
.tac .walker.running { animation: tacRun .52s steps(var(--rf, 6)) infinite; }
.tac .walker.idle, .tac .walker.idle.running { animation: tacIdle 2.2s steps(var(--rf, 2)) infinite; }
.tac .walker.npcspr.idle { animation-duration: 2.6s; }
.tac .walker.kneel { animation: tacKneel 1.05s steps(var(--kf, 4)) infinite; }
@keyframes tacRun { to { background-position: calc(var(--fw) * var(--rf, 6) * -1) 0; } }
@keyframes tacIdle { to { background-position: calc(var(--fw) * var(--rf, 2) * -1) 0; } }
@keyframes tacKneel { to { background-position: calc(var(--fw) * var(--kf, 4) * -1) 0; } }
.tac .tac-pat { position: absolute; left: 0; top: 0; max-width: none; transform: translate(-50%, -100%); image-rendering: auto; }
.tac .tac-pat.flip { transform: translate(-50%, -100%) scaleX(-1); }
.tac .tac-custom { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); }
.tac .tac-dot { position: absolute; width: 14px; height: 24px; transform: translate(-50%, -100%); background: #e0362d; border-radius: 7px 7px 3px 3px; }
.tac-occ { position: absolute; left: 0; top: 0; }

/* เคอร์เซอร์ช่อง + ลูกศรชี้ */
.tac-cursor { position: absolute; left: 0; top: 0; overflow: visible; }
.tac-cursor .tc-fill { fill: rgba(255, 244, 190, .26); animation: tacCurFill 1s ease-in-out infinite alternate; }
.tac-cursor .tc-line { fill: none; stroke: #fff6cf; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.tac-cursor .tc-cnr { fill: none; stroke: #ffc93a; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; animation: tacCurCnr 1s ease-in-out infinite alternate; }
.tac-mark { position: absolute; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); animation: tacBob .9s ease-in-out infinite; }
.tac-mark svg { display: block; width: 100%; height: 100%; }
@keyframes tacBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22%); } }
@keyframes tacCurFill { from { fill: rgba(255, 244, 190, .12); } to { fill: rgba(255, 244, 190, .38); } }
@keyframes tacCurCnr { from { opacity: .7; } to { opacity: 1; } }
@keyframes tacPulse { from { opacity: .35; } to { opacity: 1; } }
@keyframes tacFlk { 0% { opacity: 1; } 12% { opacity: .25; } 20% { opacity: .9; } 46% { opacity: .1; } 52% { opacity: 1; } 70% { opacity: .4; } 84% { opacity: 0; } 92% { opacity: .85; } }

/* ตัวเลข/ข้อความลอย (แบบตัวเลขความเสียหาย) */
.tac-pop {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  font-family: Kanit, "Noto Sans Thai", sans-serif; font-weight: 700; line-height: 1; letter-spacing: .02em;
  color: #fff; paint-order: stroke fill; -webkit-text-stroke: 4px #1a1020;
  text-shadow: 0 2px 0 #1a1020, 0 0 10px rgba(0,0,0,.35);
  animation: tacPop 1.45s cubic-bezier(.2,.9,.25,1) forwards;
}
.tac-pop-dmg { color: #ff5a4a; -webkit-text-stroke-color: #2a0505; }
.tac-pop-heal { color: #7dffb4; -webkit-text-stroke-color: #04301a; }
.tac-pop-info { color: #ffe27a; -webkit-text-stroke-color: #2e1f02; font-weight: 600; }
.tac-pop-miss { color: #e4e8f0; -webkit-text-stroke-color: #262a36; font-weight: 600; }
@keyframes tacPop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.5); }
  12% { opacity: 1; transform: translate(-50%, -150%) scale(1.22); }
  22% { transform: translate(-50%, -105%) scale(1); }
  30% { transform: translate(-50%, -125%) scale(1); }
  38% { transform: translate(-50%, -110%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(.96); }
}
.tac.tac-shake .tac-world { animation: tacShake .34s linear; }
@keyframes tacShake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-4px, 1px); } 40% { transform: translate(4px, -1px); } 60% { transform: translate(-3px, 0); } 80% { transform: translate(2px, 1px); } }
.tac-fxstill { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid #ffce46; }
.tac-fxstill-shock { border-color: #ff3d3d; } .tac-fxstill-heal { border-color: #4dffa0; } .tac-fxstill-spark { border-color: #fff07a; }

.tac-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .tac-world, .tac-world.tac-fade { transition: none; }
  .tac .walker, .tac .walker.running, .tac .walker.idle, .tac .walker.kneel,
  .tac-pulse, .tac-flk, .tac-mark, .tac-cursor .tc-fill, .tac-cursor .tc-cnr, .tac.tac-shake .tac-world { animation: none; }
  .tac-pop { animation: none; transform: translate(-50%, -120%); }
}
.tac.tac-rm .walker, .tac.tac-rm .tac-pulse, .tac.tac-rm .tac-flk, .tac.tac-rm .tac-mark { animation: none; }
.tac.tac-rm .tac-pop { animation: none; transform: translate(-50%, -120%); }
/* สไปรต์ 3D (รอบ 14): จุดยึด = เท้ากลางล่าง เหมือน .walker */
.tac .tacspr.tac-3d { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); }
