.kz-trace {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  font-family: var(--kz-game-font, system-ui, sans-serif);
  color: var(--kz-game-ink, #0f172a);
}

.kz-trace__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, #fda4af 0%, #fde68a 48%, #bbf7d0 100%);
  overflow: hidden;
}

.kz-trace__prompt {
  margin: 0;
  font-weight: 800;
  font-size: 0.88rem;
  text-align: center;
  flex: 0 0 auto;
}

.kz-trace__canvas-wrap {
  position: relative;
  width: min(100%, clamp(8rem, 42vh, 16rem));
  aspect-ratio: 1;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.5);
  flex: 0 1 auto;
}

.kz-trace__canvas-wrap.is-done {
  opacity: 0.55;
}

.kz-trace__canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.kz-trace__pops {
  position: absolute;
  inset: 2.5rem 0.5rem 0.5rem;
  pointer-events: none;
}

.kz-trace__pops:not([hidden]) {
  pointer-events: auto;
}

.kz-trace__bubble {
  position: absolute;
  width: clamp(2.4rem, 7vh, 3.1rem);
  height: clamp(2.4rem, 7vh, 3.1rem);
  border: 3px solid rgba(15, 23, 42, 0.1);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff 0%, #fb7185 40%, #e11d48 100%);
  color: #fff;
  font-size: clamp(1rem, 3vh, 1.25rem);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
  animation: kz-trace-bob 1.4s ease-in-out infinite;
  touch-action: manipulation;
}

.kz-trace__bubble.is-popped {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  animation: none;
}

@keyframes kz-trace-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.kz-letter-hub__play .kz-trace-mount,
.kz-letter-hub__play .kz-trace {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.kz-letter-hub__stage-inner:has(.kz-trace-mount),
.kz-letter-hub__stage-inner:has(.kz-trace) {
  align-items: stretch;
  justify-content: stretch;
}

.kz-letter-hub__play:has(.kz-trace) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
  .kz-trace__bubble {
    animation: none;
  }
}
