.mathgame {
  border: 1px solid #d7dce0;
  border-radius: 12px;
  padding: 16px;
  background: #f8fbff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  max-width: 640px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 16px;
}

.mathgame__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.mathgame__level {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e6f0ff;
  color: #1a4fb0;
  font-weight: 600;
  font-size: 0.9rem;
}

.mathgame__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0d2a5c;
}

.mathgame__topics {
  margin: 0 0 12px;
  padding-left: 20px;
  color: #243349;
}

.mathgame__actions {
  margin-bottom: 12px;
}

.mathgame__start,
.mathgame__check {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #4da3ff, #1c7cf3);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 16px rgba(28, 124, 243, 0.2);
}

.mathgame__start:hover,
.mathgame__check:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(28, 124, 243, 0.28);
}

.mathgame__start:active,
.mathgame__check:active {
  transform: translateY(0);
  box-shadow: 0 6px 12px rgba(28, 124, 243, 0.2);
}

.mathgame__play {
  border-top: 1px solid #e0e6ed;
  padding-top: 12px;
}

.mathgame__question {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0e1f3c;
  margin-bottom: 0;
}

.mathgame__question-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.mathgame__assist {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0;
    position: relative;
    z-index: 10;
  }

  .mathgame__assist .course-gpt-launcher {
    position: static;
    right: auto;
    bottom: auto;
    pointer-events: auto;
    --course-gpt-launcher-gap: 8px;
    --course-gpt-launcher-size: 42px;
    --course-gpt-flyout-height: 440px;
  }

  .mathgame__assist .course-gpt-launcher__inner {
    justify-content: flex-end;
  }

  .mathgame__assist .course-gpt-popup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, 92vw);
    max-height: min(var(--course-gpt-flyout-height, 520px), calc(100vh - 2rem));
    z-index: 4500;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
  }

  .mathgame__assist .course-gpt-popup.course-gpt-popup--fullscreen {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    transform: none;
    border-radius: 0;
  }
  
  .mathgame__assist .course-gpt-launcher__button {
    background: #0ea5e9;
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
    border: 1px solid #cbe8fb;
    color: #ffffff;
  }

.mathgame__assist .course-gpt-launcher__button:hover,
.mathgame__assist .course-gpt-launcher__button:focus {
  background: #0d8ad2;
}

.mathgame__input {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.mathgame__input input {
  flex: 1;
  border: 1px solid #cdd6e4;
  border-radius: 8px;
  padding: 10px;
  font-size: 1rem;
}

.mathgame__status {
  min-height: 24px;
  color: #0d6b34;
  font-weight: 600;
}

.mathgame__status--error {
  color: #b00020;
}

.mathgame__score {
  font-size: 0.95rem;
  color: #243349;
  font-weight: 600;
}

.mathgame__popup {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: min(380px, 95vw);
  z-index: 1150;
}

@media (max-width: 640px) {
  .mathgame {
    padding: 14px;
  }

  .mathgame__input {
    flex-direction: column;
    align-items: stretch;
  }

  .mathgame__start,
  .mathgame__check {
    width: 100%;
    justify-content: center;
  }

  .mathgame__header {
    gap: 6px;
  }

  .mathgame__popup {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 1rem;
  }
}
