/* V31 fixes: stable mobile layout and readable answer controls. */
#emoji-library-app .question-card,
#emoji-library-app .answer-grid,
#emoji-library-app .card-actions {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#emoji-library-app .answer-card,
#emoji-library-app .answer-title {
  min-width: 0;
  max-width: 100%;
}

#emoji-library-app .answer-title {
  overflow-wrap: anywhere;
  word-break: normal;
}

@media (max-width: 720px) {
  #emoji-library-app .card-actions {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.25fr);
    gap: 8px;
    width: 100%;
  }

  #emoji-library-app .card-actions .primary-button,
  #emoji-library-app .card-actions .secondary-button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-inline: 8px;
    gap: 8px;
    white-space: normal;
  }

  #emoji-library-app .result-screen {
    width: 100%;
    box-sizing: border-box;
  }
}

/* V33: reusable hub metadata and explicit completion state. */
#emoji-library-app .test-card-template {
  display: none;
}

#emoji-library-app .test-meta span {
  white-space: normal;
}

#emoji-library-app .test-save-pill.completed-pill {
  color: #123d31;
  border-color: rgba(37, 145, 108, .24);
  background: #dff8ed;
}

#emoji-library-app .test-save-pill.date-pill {
  color: #4d4666;
  background: #f6f3ff;
}

#emoji-library-app button[aria-busy="true"] {
  cursor: wait;
  opacity: .72;
}

#emoji-library-app img.cover-fallback {
  object-fit: contain !important;
  background: #eee9ff;
}

/* The original desktop result grid has fixed minimum columns and clips at tablet/200% widths. */
@media (min-width: 721px) and (max-width: 1180px) {
  #emoji-library-app.vibrant-v30 .result-screen {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 30px;
    width: 100%;
    padding: 42px clamp(26px, 5vw, 54px) 54px;
    box-sizing: border-box;
  }

  #emoji-library-app.vibrant-v30 .result-intro,
  #emoji-library-app.vibrant-v30 .result-card {
    width: min(820px, 100%);
    min-width: 0;
    margin-inline: auto;
    box-sizing: border-box;
  }

  #emoji-library-app.vibrant-v30 .result-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
    column-gap: clamp(24px, 5vw, 52px);
    align-items: center;
    padding-top: 0;
  }

  #emoji-library-app.vibrant-v30 .result-sticker,
  #emoji-library-app.vibrant-v30 .v8-result-note,
  #emoji-library-app.vibrant-v30 .result-label,
  #emoji-library-app.vibrant-v30 .result-intro h1 {
    grid-column: 1;
  }

  #emoji-library-app.vibrant-v30 .cover-stage {
    grid-column: 2;
    grid-row: 1 / 6;
    min-height: 320px;
  }

  #emoji-library-app.vibrant-v30 .result-card {
    min-height: 0;
  }
}

.app-loading,
.no-js-message {
  width: min(720px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: 28px;
  color: #211b38;
  text-align: center;
  font: 700 18px/1.5 Arial, sans-serif;
  border: 1px solid rgba(118, 87, 255, .22);
  border-radius: 20px;
  background: #f7f4ff;
  box-sizing: border-box;
}

.no-js-message h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 6vw, 44px);
}

.no-js-message p {
  margin: 0;
  font-weight: 400;
}

/* V33: data-driven hub, loading/error states, and optional per-question hints. */
#emoji-library-app .test-card + .test-card {
  margin-top: 16px;
}

#emoji-library-app .data-state-screen {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: calc(100vh - 88px);
  padding: 48px 24px;
  text-align: center;
  box-sizing: border-box;
}

#emoji-library-app .data-state-screen h1 {
  max-width: 760px;
  margin: 8px 0 16px;
  font-size: clamp(38px, 7vw, 72px);
  line-height: .95;
}

#emoji-library-app .data-state-screen > p:last-of-type {
  max-width: 680px;
  margin: 0;
  color: #56525e;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.55;
}

#emoji-library-app .data-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

#emoji-library-app .question-hint-area {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: -2px auto 18px;
}

#emoji-library-app .question-hint-button {
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid rgba(118, 87, 255, .28);
  border-radius: 999px;
  color: #44358f;
  background: #f4f0ff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

#emoji-library-app .question-hint-button:hover,
#emoji-library-app .question-hint-button:focus-visible {
  border-color: #7657ff;
  background: #ece6ff;
}

#emoji-library-app .question-hint {
  max-width: 720px;
  margin: 0;
  padding: 12px 16px;
  border-left: 4px solid #7657ff;
  border-radius: 10px;
  color: #332c4d;
  background: #f7f4ff;
  font-size: 15px;
  line-height: 1.45;
}

@media (max-width: 520px) {
  #emoji-library-app .data-state-actions {
    display: grid;
    width: 100%;
  }

  #emoji-library-app .data-state-actions > * {
    width: 100%;
  }

  #emoji-library-app .question-hint {
    text-align: left;
  }
}
