/* AI generate embeds (hub + category pages) */
/* Embedded AI card on category pages (hub grid uses .create-game-v3 rules only) */
.ppg-ai-embed article.ppg-ai-card.cg-game-card {
  background: #fff;
  border: 1px solid #e8eaf0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 100%;
  margin-bottom: 16px;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-game-thumb {
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-game-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-game-name {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-game-desc {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  flex: 1;
  margin: 0 0 2px;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-game-btns {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-btn-create {
  flex: 1;
  min-width: 0;
  background: #1870d5;
  color: #fff;
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-btn-create svg {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-btn-create:hover {
  background: #145ea8;
  color: #fff;
  text-decoration: none;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-btn-play {
  background: #fff;
  color: #374151;
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px;
  border: 1.5px solid #e8eaf0;
  border-radius: 100px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
}
.ppg-ai-embed article.ppg-ai-card.cg-game-card .cg-btn-play:hover {
  border-color: #1870d5;
  color: #1870d5;
  text-decoration: none;
}

.ppg-ai-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.ppg-ai-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
.ppg-ai-topic {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}
.ppg-ai-gen-btn {
  margin-top: 4px;
  align-self: flex-start;
}
.ppg-ai-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.35;
}

/* Modal */
#ppg-ai-modal[hidden] {
  display: none !important;
}
#ppg-ai-modal {
  position: fixed;
  inset: 0;
  z-index: 100050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.ppg-ai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}
.ppg-ai-modal-dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14), 0 8px 24px rgba(15, 23, 42, 0.08);
  max-width: 520px;
  width: 100%;
  padding: 2rem;
  box-sizing: border-box;
  animation: ppg-ai-popIn 0.28s ease-out forwards;
  overflow: visible;
}

/* Corner-close: circle centered on modal top-right vertex (half outside) */
.ppg-ai-modal-close-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  transform: translate(50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: opacity 0.2s, transform 0.15s;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.2));
}

.ppg-ai-modal-close-btn svg {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.ppg-ai-modal-close-btn:hover {
  opacity: 0.92;
}

.ppg-ai-modal-close-btn:active {
  transform: translate(50%, -50%) scale(0.96);
}

.ppg-ai-modal-close-btn:focus-visible {
  outline: 2px solid #1870d5;
  outline-offset: 3px;
}

@keyframes ppg-ai-popIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Progress UI (aligned with Bateaux course popup pattern) */
.ppg-ai-modal-progress {
  text-align: center;
}
.ppg-ai-modal-heading {
  margin-bottom: 0.35rem;
}
.ppg-ai-modal-title-row {
  margin: 0;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 500;
}
.ppg-ai-modal-sparkle {
  display: inline-flex;
  align-items: center;
  color: #2563eb;
  flex-shrink: 0;
}
.ppg-ai-modal-brand {
  color: #1870d5;
  font-weight: 700;
}

.ppg-ai-smily-loader {
  width: 64px;
  height: 64px;
  margin: 10px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ppg-ai-smily-loader img {
  display: block;
  width: 60px;
  height: auto;
  max-height: 60px;
  object-fit: contain;
}

.ppg-ai-progress-steps {
  width: 100%;
  margin: 18px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.ppg-ai-step-item {
  display: flex;
  align-items: flex-start;
  background-color: #f0f9f0;
  border-radius: 8px;
  padding: 14px 16px;
  transition: background-color 0.25s ease, opacity 0.25s ease;
}

.ppg-ai-step-item.ppg-ai-step-active {
  background-color: #e7f5ff;
}

.ppg-ai-step-item.ppg-ai-step-completed {
  background-color: #f0f9f0;
}

.ppg-ai-step-item.ppg-ai-step-pending {
  background-color: rgba(167, 167, 168, 0.12);
  opacity: 0.55;
}

.ppg-ai-step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 14px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.ppg-ai-step-icon-completed {
  background-color: #e0f5e6;
  color: #10b981;
}

.ppg-ai-step-icon-active {
  background-color: #e0f1ff;
  color: #2563eb;
}

.ppg-ai-step-icon-pending {
  background-color: #ececec;
  color: #9ca3af;
}

.ppg-ai-step-item.ppg-ai-step-active .ppg-ai-step-title,
.ppg-ai-step-item.ppg-ai-step-active .ppg-ai-step-description {
  color: #1870d5;
}

.ppg-ai-step-content {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.ppg-ai-step-title {
  font-weight: 600;
  color: #374151;
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.ppg-ai-step-description {
  color: #6b7280;
  font-size: 0.8125rem;
}

.ppg-ai-check-icon {
  width: 18px;
  height: 18px;
}

.ppg-ai-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: ppg-ai-spin 0.9s linear infinite;
}

@keyframes ppg-ai-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.ppg-ai-gear-icon {
  width: 18px;
  height: 18px;
}

.ppg-ai-modal-relax {
  margin: 0;
  color: #707070;
  font-size: 14px;
  line-height: 1.4;
}

/* Success panel (quiz-style reference) */
.ppg-ai-modal-success-wrap {
  text-align: center;
  padding: 0.35rem 0.25rem 0.15rem;
}

.ppg-ai-success-heading {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  color: #4d4d4d;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.ppg-ai-success-emoji {
  display: inline;
}

.ppg-ai-success-quoted {
  font-weight: 500;
  color: #4d4d4d;
}

.ppg-ai-success-sub {
  margin: 14px 0 26px;
  font-size: 1rem;
  font-weight: 400;
  color: #6b7280;
  line-height: 1.5;
}

.ppg-ai-play-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 148px;
  padding: 14px 32px;
  background: #1d72d3;
  color: #fff !important;
  border-radius: 9999px;
  font-weight: 700;
  text-decoration: none !important;
  font-size: 1rem;
  transition: background-color 0.2s, transform 0.15s;
}

.ppg-ai-play-pill:hover {
  background: #1560b5;
  color: #fff !important;
}

.ppg-ai-play-pill:active {
  transform: scale(0.98);
}

.ppg-ai-modal-error-wrap {
  text-align: center;
  color: #b91c1c;
  font-size: 1rem;
  line-height: 1.45;
  padding: 1.25rem 0.5rem 0.25rem;
}

#ppg-ai-modal-error {
  display: none;
  margin-top: 0;
}

/* Section index wrapper */
.ppg-ai-embed {
  max-width: 520px;
  margin: 8px 0 16px;
  box-sizing: border-box;
}
