/* -- Challenge sentence ------------------------------- */
.challenge-box {
    position: relative;
    background: linear-gradient(135deg, #fffdf8 0%, #f7f8ff 100%);
    border: 2px solid #e6dfd6;
    border-radius: 18px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    text-align: center;
    box-shadow: 0 3px 16px rgba(96,72,46,0.08);
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
    min-height: clamp(280px, 40dvh, 420px);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    touch-action: pan-y;
}
.challenge-box:hover {
    border-color: #cfc8f6;
    box-shadow: 0 6px 22px rgba(96,72,46,0.12);
    transform: translateY(-2px);
}
.challenge-box.has-result {
    border-color: #d7d2ec;
    min-height: clamp(360px, 52dvh, 500px);
}
.challenge-box.pop .challenge-text {
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.challenge-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #6c5ce7;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}
.speak-btn {
    position: absolute; top: 0.5rem; right: 0.5rem;
    background: rgba(255,255,255,0.85); border: none; cursor: pointer;
    color: #00b894; padding: 4px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; z-index: 2;
    width: 30px; height: 30px;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.speak-btn svg { width: 18px; height: 18px; }
.speak-btn:hover { color: #00a381; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.speak-btn:active { transform: scale(0.9); }
.speak-btn.speaking { color: #e17055; animation: pulse 1s ease-in-out infinite; }
.challenge-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 10.5rem;
    flex: 1 1 auto;
}
.challenge-text {
    width: 100%;
    font-size: 1.55rem;
    font-weight: 700;
    color: #263238;
    line-height: 1.5;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.22rem;
    min-height: 10.5rem;
    max-height: 15rem;
    overflow-y: auto;
    overflow-wrap: anywhere;
    padding: 0.1rem 0.25rem;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
}
.challenge-text-original {
    display: block;
    font-size: 1.08rem;
    font-weight: 650;
    color: #94a3b8;
    text-align: center;
    line-height: 1.42;
}
.challenge-text-inner {
    display: block;
    text-align: center;
}
.challenge-text-browser {
    color: #263238;
}
.challenge-translation {
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    text-align: center;
    margin-top: 0.3rem;
    font-style: italic;
}
.challenge-loading {
    position: absolute;
    inset: 0;
    z-index: 1;
    color: #8b7e74;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease-in;
}
.challenge-loading.htmx-request {
    opacity: 1;
}
.challenge-box.is-loading .challenge-loading {
    opacity: 1;
}
.loading-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    min-height: 2rem;
}
.challenge-loading .loading-dots {
    gap: 7px;
    min-height: 32px;
}
.loading-dots span {
    width: 0.62rem;
    height: 0.62rem;
    border-radius: 50%;
    background: #9aa4b2;
    box-shadow: 0 4px 10px rgba(71,85,105,0.16);
    animation: loadingBounce 900ms ease-in-out infinite;
}
.challenge-loading .loading-dots span {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
}
.loading-dots span:nth-child(2) {
    animation-delay: 120ms;
}
.loading-dots span:nth-child(3) {
    animation-delay: 240ms;
}
@keyframes loadingBounce {
    0%, 80%, 100% { transform: translateY(0) scale(0.96); opacity: 0.62; }
    40% { transform: translateY(-4px) scale(1.02); opacity: 1; }
}

/* Remove sentence text from the stage while the loading overlay is active. */
.challenge-box.is-loading .challenge-text,
#challenge-loading.htmx-request ~ .challenge-text {
    display: none;
}
