.quiz-test-balance {
  position: relative;
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: 9px;
  min-height: 38px;
  color: var(--app-muted, #696965);
  font-size: 12px;
  font-weight: 720;
}

.quiz-launch-main:has(.quiz-test-balance) {
  position: relative;
  z-index: 3;
}

.quiz-launch-main > .quiz-test-balance {
  position: absolute;
  top: 24px;
  right: 34px;
  z-index: 1;
}

.quiz-test-balance > strong {
  min-width: 22px;
  color: var(--app-ink, #171715);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.test-balance-add {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  padding: 0 0 2px;
  border: 1px solid #050505;
  border-radius: 10px;
  background: #050505;
  color: #fff;
  font-size: 24px;
  font-weight: 450;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--app-motion-spring) var(--app-spring), background 160ms var(--app-ease);
}

.test-balance-add:hover { background: #2a2a28; transform: translateY(-1px); }
.test-balance-add:focus-visible { outline: 3px solid rgba(49, 87, 232, 0.22); outline-offset: 2px; }

.test-purchase-backdrop {
  position: fixed;
  z-index: 1190;
  inset: 0;
  background: rgba(240, 240, 238, 0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Fixed positioning keeps every purchase step above browser chrome and page footers. */
.test-balance-menu {
  position: fixed;
  z-index: 1200;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: min(410px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px;
  border: 1px solid var(--app-line-strong, rgba(5, 5, 5, 0.2));
  border-radius: 15px;
  background: #fff;
  color: var(--app-ink, #171715);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  animation: testBalanceMenuIn 180ms cubic-bezier(.22, 1, .36, 1) both;
}

.test-balance-menu-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid var(--app-line, rgba(5, 5, 5, 0.12));
  border-radius: 9px;
  background: var(--app-paper-soft, #f3f3f1);
  color: var(--app-ink, #171715);
  box-shadow: none;
  cursor: pointer;
}
.test-balance-menu-close::before,
.test-balance-menu-close::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
}
.test-balance-menu-close::before { transform: rotate(45deg); }
.test-balance-menu-close::after { transform: rotate(-45deg); }
.test-balance-menu-close:hover { background: #e8e8e5; box-shadow: none; transform: none; }
.test-balance-menu-close:focus-visible { outline: 3px solid rgba(49, 87, 232, 0.22); outline-offset: 2px; }

.test-balance-card .test-balance-menu {
  position: fixed;
}

@keyframes testBalanceMenuIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 6px)) scale(.985); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.test-balance-menu .section-kicker {
  margin: 0;
  color: var(--app-muted, #696965);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.test-balance-menu h3 {
  margin: 5px 0 16px;
  color: var(--app-ink, #171715);
  font-size: 21px;
  letter-spacing: -0.035em;
}

.test-balance-menu-actions { display: grid; gap: 9px; }
.test-balance-premium-action,
.test-balance-pack-action {
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid var(--app-line, rgba(5, 5, 5, 0.12));
  border-radius: 11px;
  font: inherit;
  box-shadow: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms var(--app-ease), transform var(--app-motion-spring) var(--app-spring), background 160ms var(--app-ease);
}
.test-balance-premium-action { border-color: #050505; background: #050505; color: #fff; }
.test-balance-pack-action { background: var(--app-paper-soft, #f3f3f1); color: var(--app-ink, #171715); }
.test-balance-premium-action:hover,
.test-balance-pack-action:hover { transform: translateY(-1px); }
.test-balance-pack-action:hover { border-color: var(--app-line-strong, rgba(5, 5, 5, 0.22)); }
.test-balance-menu-actions strong,
.test-balance-menu-actions small { display: block; }
.test-balance-menu-actions strong { font-size: 14px; }
.test-balance-menu-actions small { margin-top: 4px; color: inherit; font-size: 11px; font-weight: 550; opacity: .65; }
.test-balance-menu-actions > :is(a, button) > span:last-child { flex: 0 0 auto; font-size: 20px; }

.test-pack-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: -4px 0 15px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--app-muted, #696965);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  box-shadow: none;
  cursor: pointer;
}
.test-pack-back:hover { background: transparent; box-shadow: none; transform: none; }
.test-pack-back > span {
  font-size: 21px;
  font-weight: 500;
  line-height: .8;
}

.test-pack-options { display: grid; gap: 8px; }
.test-pack-option {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--app-line, rgba(5, 5, 5, 0.12));
  border-radius: 11px;
  background: #fff;
  color: var(--app-ink, #171715);
  font: inherit;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}
.test-pack-option.is-selected { border-color: #050505; background: #f3f3f1; box-shadow: inset 3px 0 0 #050505; }
.test-pack-option span,
.test-pack-option strong,
.test-pack-option small { display: block; }
.test-pack-option strong { font-size: 15px; }
.test-pack-option small { margin-top: 3px; color: var(--app-muted, #696965); font-size: 11px; }
.test-pack-option em { flex: 0 0 auto; font-size: 13px; font-style: normal; font-weight: 800; }

.test-pack-consents { display: grid; gap: 10px; margin-top: 16px; }
.test-pack-consents label {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin: 0;
  padding: 10px 11px;
  border: 1px solid var(--app-line, rgba(5, 5, 5, 0.12));
  border-radius: 9px;
  background: var(--app-paper-soft, #f3f3f1);
  color: var(--app-muted, #696965);
  font-size: 11px;
  line-height: 1.45;
  cursor: pointer;
}
.test-pack-consents input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 1px 0 0;
  padding: 0;
  border-radius: 3px;
  box-shadow: none;
  accent-color: #050505;
}
.test-pack-consents a { color: inherit; text-underline-offset: 2px; }

.buy-test-pack-btn {
  width: 100%;
  min-height: 46px;
  margin: 17px 0 0;
  padding: 0 16px;
  border: 1px solid #050505;
  border-radius: 10px;
  background: #050505;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
  cursor: pointer;
}
.buy-test-pack-btn:hover { box-shadow: none; }
.buy-test-pack-btn:disabled { opacity: .42; cursor: not-allowed; }
.test-pack-panel .inline-message { margin-top: 11px; }

@media (max-width: 620px) {
  .quiz-launch-main > .quiz-test-balance { top: 17px; right: 22px; }
  .quiz-test-balance { gap: 7px; }
  .quiz-test-balance > span { font-size: 11px; }
  .quiz-test-balance > strong { min-width: 18px; font-size: 18px; }
  .test-balance-add { width: 36px; height: 36px; flex-basis: 36px; }
  .test-balance-menu {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: calc(100vw - 30px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: calc(100dvh - 30px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 17px;
  }
  .test-balance-card .test-balance-menu {
    position: fixed;
  }
}

@media (prefers-reduced-motion: reduce) {
  .test-balance-menu { animation: none; }
}

/* In a narrow card the corner no longer has room beside the kicker, so the balance
   becomes the card's first row instead of overlapping the heading. */
.quiz-launch-main { container-type: inline-size; }
@container (max-width: 520px) {
  .quiz-launch-main > .quiz-test-balance {
    position: relative;
    top: auto;
    right: auto;
    align-self: flex-start;
    margin-bottom: -4px;
  }
}
