/* ── Task Force Ninja — global busy indicator + hover help + play ─ */
#tf-ninja {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 12000;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  transition: left 0.45s cubic-bezier(0.34, 1.2, 0.64, 1),
              top 0.45s cubic-bezier(0.34, 1.2, 0.64, 1),
              right 0.45s cubic-bezier(0.34, 1.2, 0.64, 1),
              bottom 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#tf-ninja.on { display: flex; }
#tf-ninja.dragging {
  transition: none !important;
  z-index: 13000;
}

#tf-ninja .tf-bubble,
#tf-ninja .tf-stage {
  pointer-events: auto;
}

.tf-bubble {
  position: relative;
  max-width: 260px;
  padding: 10px 48px 10px 14px;
  background: #12171e;
  border: 1px solid rgba(0, 212, 170, 0.45);
  border-radius: 14px 14px 4px 14px;
  color: #e8ecf1;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 20px rgba(0,212,170,0.12);
  animation: tfBubbleIn 0.28s cubic-bezier(0.4,0,0.2,1);
  cursor: default;
}
.tf-bubble::after {
  content: '';
  position: absolute;
  right: 18px; bottom: -7px;
  width: 12px; height: 12px;
  background: #12171e;
  border-right: 1px solid rgba(0,212,170,0.45);
  border-bottom: 1px solid rgba(0,212,170,0.45);
  transform: rotate(45deg);
}
.tf-bubble .tf-tag {
  display: block;
  font: 700 9px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #00d4aa;
  margin-bottom: 5px;
}
.tf-bubble .tf-msg { color: #c8d0da; }

.tf-gender {
  position: absolute;
  top: 4px;
  right: 26px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #00d4aa;
  font: 700 13px/1 system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tf-gender:hover {
  opacity: 1;
  color: #00ffd0;
  background: rgba(0, 212, 170, 0.12);
}

.tf-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #4e5968;
  font: 700 14px/1 system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tf-close:hover {
  opacity: 1;
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.tf-stage {
  position: relative;
  width: 88px;
  height: 88px;
  cursor: grab;
  touch-action: none;
}
#tf-ninja.dragging .tf-stage {
  cursor: grabbing;
}

.tf-ninja-svg {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.55));
  transform-origin: 50% 80%;
  animation: tfIdle 1.1s ease-in-out infinite;
  pointer-events: none;
}
#tf-ninja.running .tf-ninja-svg {
  animation: tfRun 0.45s steps(2) infinite;
}
#tf-ninja.dash .tf-ninja-svg {
  animation: tfDash 0.55s cubic-bezier(0.4,0,0.2,1);
}

#tf-ninja.jump .tf-ninja-svg {
  animation: tfJump 0.55s cubic-bezier(0.34, 1.4, 0.64, 1);
}
#tf-ninja.climb .tf-ninja-svg {
  animation: tfClimb 0.65s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#tf-ninja.roll .tf-ninja-svg {
  animation: tfRoll 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
#tf-ninja.glide .tf-ninja-svg {
  animation: none;
  transition: transform 0.4s ease;
}

.tf-ground {
  position: absolute;
  left: 12px; right: 12px; bottom: 4px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(0,212,170,0.35), transparent);
  animation: tfGround 1.1s ease-in-out infinite;
  pointer-events: none;
}

.tf-dust {
  position: absolute;
  bottom: 6px; left: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(0,212,170,0.45);
  opacity: 0;
  pointer-events: none;
}
#tf-ninja.running .tf-dust,
#tf-ninja.jump .tf-dust,
#tf-ninja.roll .tf-dust {
  animation: tfDust 0.45s ease-out infinite;
}

#tf-ninja-summon {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 11999;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 170, 0.35);
  background: #12171e;
  color: #e8ecf1;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
#tf-ninja-summon:hover {
  opacity: 1;
  border-color: rgba(0, 212, 170, 0.7);
  transform: scale(1.08);
}

/* ── Play attacks ─────────────────────────────────────────────── */

/* Flying packet shuriken */
.tf-shuriken-fly {
  position: fixed;
  z-index: 12500;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(0, 212, 170, 0.85));
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.38s ease;
  will-change: transform, opacity;
}

/* Impact burst */
.tf-impact {
  position: fixed;
  z-index: 12501;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, #00ffd0 0%, #00d4aa 40%, transparent 70%);
  pointer-events: none;
  animation: tfImpact 0.45s ease-out forwards;
}
.tf-impact-big {
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  animation: tfImpactBig 0.5s ease-out forwards;
}

/* Katana slash trail */
.tf-slash {
  position: fixed;
  z-index: 12490;
  height: 3px;
  margin-top: -1.5px;
  transform-origin: 0 50%;
  background: linear-gradient(90deg,
    transparent 0%,
    #00ffd0 8%,
    #00d4aa 50%,
    #00ffd0 92%,
    transparent 100%);
  box-shadow: 0 0 12px 2px rgba(0, 212, 170, 0.7),
              0 0 28px 4px rgba(0, 255, 208, 0.35);
  pointer-events: none;
  animation: tfSlashFade 0.5s ease-out forwards;
}
.tf-slash-preview {
  opacity: 0.55;
  animation: none;
  box-shadow: 0 0 8px 1px rgba(0, 212, 170, 0.5);
}

/* Staff shockwave ring */
.tf-shockwave {
  position: fixed;
  z-index: 12490;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  border-radius: 50%;
  border: 2px solid rgba(0, 212, 170, 0.85);
  box-shadow: 0 0 16px rgba(0, 255, 208, 0.5);
  pointer-events: none;
  animation: tfShockwave 0.55s ease-out forwards;
}

/* Temporary scars on dashboard elements (purely visual) */
.tf-hit-flash {
  outline: 2px solid rgba(0, 212, 170, 0.7) !important;
  outline-offset: 2px;
  transition: outline-color 0.4s ease;
  animation: tfHitPulse 0.45s ease-out;
}
.tf-cut-scar {
  position: relative;
  outline: 1px solid rgba(0, 255, 208, 0.45) !important;
  outline-offset: 1px;
  filter: brightness(1.08) saturate(1.15);
  transition: filter 0.6s ease, outline-color 1.5s ease;
}
.tf-cut-scar::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(0, 255, 208, 0.35) 49%,
    rgba(0, 212, 170, 0.55) 50%,
    rgba(0, 255, 208, 0.35) 51%,
    transparent 58%
  );
  animation: tfCutScar 2.1s ease-out forwards;
  border-radius: inherit;
  z-index: 5;
}

@keyframes tfBubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes tfIdle {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@keyframes tfRun {
  0%   { transform: translateY(0) rotate(-2deg); }
  50%  { transform: translateY(-4px) rotate(2deg); }
  100% { transform: translateY(0) rotate(-2deg); }
}
@keyframes tfDash {
  0%   { transform: translateX(0) scaleX(1); }
  40%  { transform: translateX(-18px) scaleX(1.05); }
  100% { transform: translateX(0) scaleX(1); }
}
@keyframes tfJump {
  0%   { transform: translateY(0) scale(1); }
  25%  { transform: translateY(-28px) scale(0.95, 1.08); }
  55%  { transform: translateY(-8px) scale(1.05, 0.95); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes tfClimb {
  0%   { transform: translateY(12px) rotate(-4deg); }
  40%  { transform: translateY(-18px) rotate(3deg); }
  70%  { transform: translateY(-6px) rotate(-2deg); }
  100% { transform: translateY(0) rotate(0); }
}
@keyframes tfRoll {
  0%   { transform: translateX(0) rotate(0deg); }
  40%  { transform: translateX(-22px) rotate(-160deg); }
  100% { transform: translateX(0) rotate(-360deg); }
}
@keyframes tfGround {
  0%, 100% { opacity: 0.4; transform: scaleX(0.85); }
  50%      { opacity: 0.9; transform: scaleX(1.05); }
}
@keyframes tfDust {
  0%   { opacity: 0.7; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(-14px, -10px) scale(0.3); }
}
@keyframes tfImpact {
  0%   { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(3.2); opacity: 0; }
}
@keyframes tfImpactBig {
  0%   { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(4.5); opacity: 0; }
}
@keyframes tfSlashFade {
  0%   { opacity: 1; filter: brightness(1.4); }
  70%  { opacity: 0.85; }
  100% { opacity: 0; }
}
@keyframes tfShockwave {
  0%   { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(6); opacity: 0; }
}
@keyframes tfHitPulse {
  0%   { outline-color: rgba(0, 255, 208, 0.95); }
  100% { outline-color: rgba(0, 212, 170, 0); }
}
@keyframes tfCutScar {
  0%   { opacity: 0.9; }
  40%  { opacity: 0.7; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-ninja-svg, .tf-ground, .tf-dust, .tf-bubble,
  .tf-shuriken-fly, .tf-impact, .tf-slash, .tf-shockwave {
    animation: none !important;
    transition: none !important;
  }
  #tf-ninja {
    transition: left 0.25s ease, top 0.25s ease, right 0.25s ease, bottom 0.25s ease;
  }
}
