/* ──────────────────────────────────────────────────────────
   Brain Training Game Animations
   ────────────────────────────────────────────────────────── */

/* ── Play area ── */
.brain-anim-area {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 280px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: #f7f8fc;
  overflow: hidden;
}

/* ── Scoreboard (top bar) ── */
.ba-scoreboard {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 6px;
}

.ba-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
}

.ba-stat--correct {
  background: rgb(34, 197, 94, 0.08);
}

.ba-stat--wrong {
  background: rgb(239, 68, 68, 0.08);
}

.ba-stat-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ba-stat-icon--correct {
  border: 2px solid #0bb980;
  color: #0bb980;
}

.ba-stat-icon--wrong {
  border: 2px solid #ef4444;
  color: #ef4444;
}

.ba-stat-val {
  font-weight: 700;
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.ba-stat--correct .ba-stat-val {
  color: #0bb980;
}

.ba-stat--wrong .ba-stat-val {
  color: #ef4444;
}

.ba-stat-val.is-bumped {
  animation: baBump 0.3s ease;
}

@keyframes baBump {
  0% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-4px) scale(1.15);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

/* ── Play field ── */
.ba-field {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ── Moving gameplay dot ── */
.ba-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -18px;
  margin-top: -18px;
  transition: background 0.25s ease;
}

.ba-dot.is-moving {
  animation: baDotMove 4s ease-in-out infinite;
}

@keyframes baDotMove {
  0% {
    left: 50%;
    top: 50%;
  }

  8% {
    left: 88%;
    top: 10%;
  }

  18% {
    left: 10%;
    top: 60%;
  }

  28% {
    left: 85%;
    top: 80%;
  }

  40% {
    left: 14%;
    top: 12%;
  }

  52% {
    left: 86%;
    top: 42%;
  }

  62% {
    left: 8%;
    top: 78%;
  }

  74% {
    left: 72%;
    top: 8%;
  }

  86% {
    left: 28%;
    top: 68%;
  }

  100% {
    left: 50%;
    top: 50%;
  }
}

/* ── Center reference dot ── */
.ba-center-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #000;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -8px;
  margin-top: -8px;
  z-index: 2;
}

/* Focus Dot with Center – dot avoids center region */
.ba-dot.is-moving-center {
  animation: baDotMoveCenter 4.5s ease-in-out infinite;
}

@keyframes baDotMoveCenter {
  0% {
    left: 85%;
    top: 45%;
  }

  10% {
    left: 90%;
    top: 12%;
  }

  22% {
    left: 12%;
    top: 18%;
  }

  34% {
    left: 10%;
    top: 78%;
  }

  46% {
    left: 88%;
    top: 82%;
  }

  58% {
    left: 85%;
    top: 20%;
  }

  70% {
    left: 14%;
    top: 40%;
  }

  82% {
    left: 80%;
    top: 70%;
  }

  94% {
    left: 18%;
    top: 85%;
  }

  100% {
    left: 85%;
    top: 45%;
  }
}

/* ── Bottom answer row ── */
.ba-answers {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 0 10px;
}

.ba-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  cursor: default;
  transition: transform 0.15s ease;
}

.ba-btn--blue {
  background: #165dfc;
}

.ba-btn--red {
  background: #ef4444;
}

.ba-btn--green {
  background: #0bb980;
}

.ba-btn--yellow {
  background: #eab308;
}

.ba-btn.is-pressed {
  animation: baBtnPress 0.3s ease;
}

@keyframes baBtnPress {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.18);
  }

  100% {
    transform: scale(1);
  }
}

.ba-btn.is-wrong {
  animation: baShake 0.35s ease;
}

@keyframes baShake {
  0% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-4px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(2px);
  }

  100% {
    transform: translateX(0);
  }
}

/* ── Recall – dot row ── */
.ba-recall-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 0;
}

.ba-recall-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

/* ── Infinity – SVG container ── */
.ba-infinity-wrap {
  position: relative;
  width: 70%;
  aspect-ratio: 1440 / 810;
  margin: auto;
}

.ba-infinity-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ba-infinity-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  position: absolute;
  margin-left: -8px;
  margin-top: -8px;
  transition: box-shadow 0.2s ease;
  z-index: 1;
}

.ba-infinity-dot.is-active {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px rgb(0, 0, 0, 0.15);
}

/* ── Layout helpers ── */
.ba-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Wider modal for brain games ── */
.game-description-dialog--brain {
  width: min(520px, calc(100vw - 32px));
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .ba-dot,
  .ba-btn,
  .ba-stat-val,
  .ba-recall-dot,
  .ba-infinity-dot {
    animation: none !important;
    transition: none !important;
  }

  .ba-dot.is-moving,
  .ba-dot.is-moving-center {
    animation: none !important;
    left: 50%;
    top: 50%;
  }
}
