.tutorial-replay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.tutorial-replay-button .ui-icon {
  width: 20px;
  height: 20px;
}

.kf-coach[hidden],
.kf-coach-speech[hidden],
.kf-coach-lock-message[hidden] {
  display: none !important;
}

.kf-coach {
  --coach-cyan: #66e8ff;
  --coach-gold: #ffd84d;
  --coach-lime: #b9ff62;
  --coach-ink: #f7fbff;
  --coach-panel: rgba(7, 13, 31, 0.98);
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  direction: rtl;
  color: var(--coach-ink);
  font-family: "Assistant", "Rubik", Arial, sans-serif;
  pointer-events: none;
  isolation: isolate;
}

.kf-coach-dim-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.kf-coach-target-ring {
  position: fixed;
  z-index: 2;
  border: 3px solid var(--coach-gold);
  border-radius: 18px;
  background: rgba(255, 216, 77, 0.08);
  box-shadow:
    0 0 0 3px rgba(255, 216, 77, 0.18),
    0 0 16px rgba(255, 216, 77, 0.54),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  opacity: 0;
  pointer-events: none;
}

.kf-coach.is-ready .kf-coach-target-ring {
  opacity: 1;
  /* Animated blurred shadows re-rasterize a large WebView tile every frame. */
  animation: none;
}

.kf-coach.is-feedback .kf-coach-target-ring,
.kf-coach.is-locating .kf-coach-target-ring,
.kf-coach.is-transitioning .kf-coach-target-ring {
  opacity: 0;
  animation: none;
}

.kf-coach-active-target {
  /*
   * The cutout already exposes the real control. Promoting a control from a
   * nested scrolling sheet to its own filtered layer makes Android WebView
   * composite it behind the sheet, leaving an empty highlighted rectangle.
   */
  filter: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/*
 * Android WebView can reorder nested backdrop-filter layers above a fixed
 * tutorial overlay. Blur is decorative, so suspend it only while the coach is
 * open; the original backgrounds, borders, icons and copy stay intact.
 */
html.kf-tutorial-open #start-screen,
html.kf-tutorial-open #start-screen .menu-sheet-inner,
html.kf-tutorial-open #start-screen .settings-sheet,
html.kf-tutorial-open #start-screen .hero-gallery {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* Keep Android WebView's compositor focused on the coach layer. */
html.kf-tutorial-open #start-screen :is(
  .menu-enemy,
  .menu-particle,
  .hero-enemy,
  .hero-gallery-enemy,
  .menu-character img,
  .menu-character .character-card::before,
  .hero-animation-image,
  .hero-animation-layer,
  .hero-animation-rig
) {
  animation-play-state: paused !important;
}

html.kf-tutorial-open #start-screen :is(
  .menu-character,
  .menu-character .character-card,
  .menu-character img,
  .menu-character .character-card::before
) {
  transition-duration: 1ms !important;
}

html.kf-tutorial-open #start-screen .hero-gallery {
  animation: none !important;
}

.kf-coach-hand-wrap {
  position: fixed;
  z-index: 5;
  width: 46px;
  height: 54px;
  opacity: 0;
  transform-origin: center;
  filter:
    drop-shadow(0 4px 0 rgba(2, 5, 17, 0.54))
    drop-shadow(0 0 10px rgba(102, 232, 255, 0.72));
  pointer-events: none;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.kf-coach.is-ready .kf-coach-hand-wrap {
  opacity: 1;
  animation: kf-coach-hand-point 1.65s ease-in-out infinite alternate;
}

.kf-coach.is-feedback .kf-coach-hand-wrap,
.kf-coach.is-locating .kf-coach-hand-wrap,
.kf-coach.is-transitioning .kf-coach-hand-wrap {
  opacity: 0;
  animation: none;
}

.kf-coach-hand {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: center;
}

.kf-coach-hand path {
  fill: #fff7d6;
  stroke: #071126;
  stroke-width: 18px;
  paint-order: stroke fill;
}

.kf-coach-hand-wrap[data-side="above"] .kf-coach-hand {
  transform: rotate(180deg);
}

.kf-coach-hand-wrap[data-side="right"] .kf-coach-hand {
  transform: rotate(-90deg);
}

.kf-coach-hand-wrap[data-side="left"] .kf-coach-hand {
  transform: rotate(90deg);
}

.kf-coach-tap-ripple {
  display: none;
}

.kf-coach-hand-wrap[data-side="above"] .kf-coach-tap-ripple {
  top: auto;
  bottom: -7px;
}

.kf-coach-hand-wrap[data-side="right"] .kf-coach-tap-ripple {
  top: 50%;
  right: -7px;
  left: auto;
  transform: translateY(-50%);
}

.kf-coach-hand-wrap[data-side="left"] .kf-coach-tap-ripple {
  top: 50%;
  right: auto;
  left: -7px;
  transform: translateY(-50%);
}

.kf-coach-card {
  position: fixed;
  z-index: 7;
  width: min(304px, calc(100vw - 20px));
  height: 118px;
  overflow: visible;
  border: 1px solid rgba(102, 232, 255, 0.54);
  border-radius: 20px;
  background:
    radial-gradient(circle at 12% 10%, rgba(102, 232, 255, 0.12), transparent 34%),
    linear-gradient(155deg, rgba(13, 24, 55, 0.99), var(--coach-panel));
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.62),
    0 0 25px rgba(102, 232, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: none;
  transition: none;
  pointer-events: none;
}

.kf-coach-card::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-right: 1px solid rgba(102, 232, 255, 0.54);
  border-bottom: 1px solid rgba(102, 232, 255, 0.54);
  background: #09132d;
  transform: translateX(-50%) rotate(45deg);
}

.kf-coach-card[data-placement="above"]::after {
  left: var(--coach-tail-x, 50%);
  bottom: -10px;
}

.kf-coach-card[data-placement="below"]::after {
  left: var(--coach-tail-x, 50%);
  top: -10px;
  transform: translateX(-50%) rotate(225deg);
}

.kf-coach-card[data-placement="left"]::after {
  top: var(--coach-tail-y, 50%);
  right: -10px;
  transform: translateY(-50%) rotate(-45deg);
}

.kf-coach-card[data-placement="right"]::after {
  top: var(--coach-tail-y, 50%);
  left: -10px;
  transform: translateY(-50%) rotate(135deg);
}

.kf-coach.is-ready .kf-coach-card,
.kf-coach.is-transitioning .kf-coach-card,
.kf-coach.is-feedback .kf-coach-card {
  opacity: 1;
  transform: none;
}

.kf-coach.is-feedback .kf-coach-card {
  border-color: rgba(185, 255, 98, 0.76);
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.62),
    0 0 26px rgba(185, 255, 98, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.kf-coach.is-feedback .kf-coach-card::after {
  border-color: rgba(185, 255, 98, 0.76);
}

.kf-coach-status {
  position: relative;
  height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(123, 153, 203, 0.18);
  pointer-events: none;
}

.kf-coach-status-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kf-coach-status-copy strong {
  flex: 0 0 auto;
  color: var(--coach-gold);
  font-size: 13px;
  font-weight: 900;
}

.kf-coach-status-copy span {
  min-width: 0;
  overflow: hidden;
  color: #dbe9ff;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kf-coach-progress {
  position: absolute;
  right: 10px;
  bottom: 5px;
  left: 64px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(123, 153, 203, 0.22);
}

.kf-coach-progress span {
  width: 10%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #8f69ff, var(--coach-cyan), var(--coach-lime));
  box-shadow: 0 0 10px rgba(102, 232, 255, 0.55);
  transition: width 240ms ease;
}

.kf-coach-skip {
  min-width: 48px;
  min-height: 29px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #e7effd;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

.kf-coach-skip:hover,
.kf-coach-skip:focus-visible {
  border-color: var(--coach-cyan);
  outline: 3px solid rgba(102, 232, 255, 0.2);
  color: #fff;
}

.kf-coach-action-pill {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px 13px;
  color: #fff;
  pointer-events: none;
}

.kf-coach.is-feedback .kf-coach-action-pill {
  display: none;
}

.kf-coach-action-pill strong {
  font-size: clamp(15px, 4.1vw, 17px);
  font-weight: 900;
  line-height: 1.25;
  text-wrap: balance;
}

.kf-coach-action-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: var(--coach-gold);
  box-shadow: 0 0 14px var(--coach-gold);
  animation: none;
}

.kf-coach-speech {
  height: 72px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px 13px;
  color: #fff;
  pointer-events: none;
}

.kf-coach-check {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--coach-lime), #58df9e);
  color: #082016;
  box-shadow: 0 0 16px rgba(185, 255, 98, 0.48);
}

.kf-coach-check .ui-icon {
  width: 19px;
  height: 19px;
}

.kf-coach-speech p {
  margin: 0;
  font-size: clamp(14px, 3.9vw, 16px);
  font-weight: 850;
  line-height: 1.35;
  text-wrap: pretty;
}

.kf-coach-lock-message {
  position: fixed;
  z-index: 10;
  right: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 24px);
  padding: 10px 15px;
  border: 1px solid rgba(255, 216, 77, 0.66);
  border-radius: 999px;
  background: rgba(31, 11, 18, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.54);
  color: #ffeaa0;
  font-size: 14px;
  font-weight: 900;
  transform: translateX(50%);
  animation: none;
  pointer-events: none;
}

html[data-language="en"] .kf-coach,
html[lang="en"] .kf-coach {
  direction: ltr;
}

@keyframes kf-coach-hand-point {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

@keyframes kf-coach-lock-shake {
  0%, 100% { transform: translateX(50%); }
  30% { transform: translateX(calc(50% - 7px)); }
  65% { transform: translateX(calc(50% + 7px)); }
}

@media (max-width: 600px) {
  .kf-coach-card {
    width: min(304px, calc(100vw - 20px));
    border-radius: 18px;
  }

  .kf-coach-hand-wrap {
    width: 42px;
    height: 50px;
  }

  .kf-coach-status-copy span {
    font-size: 12px;
  }
}

@media (max-height: 680px) {
  .kf-coach-status {
    height: 44px;
    padding-top: 6px;
  }

  .kf-coach-action-pill,
  .kf-coach-speech {
    height: 68px;
    padding-top: 8px;
    padding-bottom: 9px;
  }

  .kf-coach-card {
    height: 114px;
  }

  .kf-coach-speech p,
  .kf-coach-action-pill strong {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kf-coach-target-ring,
  .kf-coach-hand-wrap,
  .kf-coach-tap-ripple,
  .kf-coach-action-dot,
  .kf-coach-speech,
  .kf-coach-card,
  .kf-coach-progress span,
  .kf-coach-lock-message {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}
