/* =============================================
   Challenge Mode — Overlay on Definition Page
   Rule: font-size NEVER below 12pt, use pt
   ============================================= */

/* ===== TRIGGER BUTTON ===== */
.challenge-trigger-wrap {
    text-align: center;
    margin: 12pt 0;
}

.challenge-trigger-btn {
    background: #F97316;
    color: #fff;
    border: none;
    border-radius: 20pt;
    padding: 8pt 22pt;
    font-size: 13pt;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 2pt 8pt rgba(249, 115, 22, 0.3);
}

.challenge-trigger-btn:hover {
    background: #ea580c;
}

.challenge-trigger-btn:active {
    transform: scale(0.96);
}

/* ===== CHALLENGE OVERLAY ===== */
.challenge-overlay {
    background: #fff;
    border-radius: 12pt;
    padding: 16pt;
    margin: 12pt 0;
    box-shadow: 0 2pt 12pt rgba(0, 0, 0, 0.06);
}

/* ===== SCORE BAR (clean, no emoji) ===== */
.challenge-scorebar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14pt;
    font-size: 12pt;
    color: #78716C;
    margin-bottom: 14pt;
    flex-wrap: wrap;
    font-variant-numeric: tabular-nums;
}

.challenge-scorebar__item {
    display: flex;
    align-items: center;
    gap: 4pt;
}

.challenge-scorebar__label {
    font-size: 10pt;
    text-transform: uppercase;
    letter-spacing: 0.5pt;
    color: #A8A29E;
    font-weight: 600;
}

.challenge-scorebar__streak {
    color: #D97706;
    font-weight: 700;
}

.challenge-scorebar__timer {
    font-weight: 600;
    color: #92400E;
}

/* ===== ROUND PROGRESS ===== */
.challenge-rounds {
    display: flex;
    justify-content: center;
    gap: 8pt;
    margin-bottom: 12pt;
}
.challenge-rounds__dot {
    width: 10pt;
    height: 10pt;
    border-radius: 50%;
    background: #E7E5E4;
    transition: background 0.3s, transform 0.3s;
}
.challenge-rounds__dot--active {
    background: #F59E0B;
    transform: scale(1.3);
    box-shadow: 0 0 6pt rgba(245, 158, 11, 0.4);
}
.challenge-rounds__dot--solved {
    background: #16A34A;
}
.challenge-rounds__dot--failed {
    background: #DC2626;
}

/* ===== DEFINITION TEXT ===== */
.challenge-def-text {
    font-size: 16pt;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    margin: 0 0 14pt;
    line-height: 1.3;
}

/* ===== LETTER CELLS ===== */
.challenge-cells-wrap {
    position: relative;
    margin: 0 auto 10pt;
}

.challenge-cells {
    display: flex;
    gap: 4pt;
    justify-content: center;
    flex-wrap: wrap;
    padding-bottom: 14pt; /* room for hint letters below cells */
}

.challenge-cell {
    width: 36pt;
    height: 36pt;
    border: 1.5pt solid #D1D5DB;
    border-radius: 6pt;
    box-shadow: 0 2pt 4pt rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #1f2937;
    background: #fff;
    position: relative;
    perspective: 300pt;
    transition: border-color 0.3s, background 0.3s;
    user-select: none;
    cursor: pointer;
}

/* Blinking cursor on active cell */
.challenge-cell--cursor {
    border-color: #F97316 !important;
    box-shadow: 0 0 0 2pt rgba(249, 115, 22, 0.2);
}

.challenge-cell--cursor::after {
    content: '';
    position: absolute;
    width: 2pt;
    height: 18pt;
    background: #F97316;
    border-radius: 1pt;
    animation: challenge-blink 1s step-end infinite;
}

@keyframes challenge-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Hidden input for capturing mobile keyboard */
.challenge-hidden-input {
    position: absolute;
    opacity: 0;
    width: 1pt;
    height: 1pt;
    top: 50%;
    left: 50%;
    pointer-events: none;
}

/* ===== VIRTUAL KEYBOARD (fixed bottom, ordgatan style) ===== */
.challenge-vkeyboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(180px + env(safe-area-inset-bottom, 0px));
    padding: 8px 4px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, #f5f0eb 0%, #e8e3de 100%);
    border-top: 1px solid #ffe0c0;
    z-index: 100;
}

.challenge-vkeyboard-container--hidden {
    display: none;
}

.challenge-vkeyboard-container .ordgata-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 500px;
    margin: 0 auto;
    height: 100%;
    padding-top: 5px;
}

.challenge-vkeyboard-container .keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex: 1;
}

.challenge-vkeyboard-container .keyboard-key {
    all: unset;
    box-sizing: border-box;
    min-width: 28px;
    flex: 1;
    max-width: 38px;
    border: none;
    border-radius: 8px;
    background: white;
    font-size: 13pt;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 1;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

.challenge-vkeyboard-container .keyboard-key:active,
.challenge-vkeyboard-container .keyboard-key.pressed {
    background: #ffe0c0;
    transform: scale(0.95);
}

.challenge-vkeyboard-container .keyboard-key-wide {
    min-width: 48px;
    max-width: 64px;
    flex: 1.5;
    font-size: 15pt;
}

.challenge-vkeyboard-container .keyboard-key-special {
    background: #fff8f2;
    border: 1px solid #ffe0c0;
}

/* (letter count removed — cells are self-evident) */

/* ===== CELL STATES ===== */
.challenge-cell--filled {
    background: #FFF7ED;
    border-color: #F97316;
}

.challenge-cell--correct {
    background: #22C55E !important;
    border-color: #16A34A !important;
    color: #fff !important;
    animation: challenge-flip 0.4s ease forwards;
}

.challenge-cell--wrong {
    background: #FEE2E2 !important;
    border-color: #EF4444 !important;
    animation: challenge-shake-cell 0.3s ease;
}

/* Locked cell (correct letter, correct position — stays permanently) */
.challenge-cell--locked {
    background: #22C55E !important;
    border-color: #16A34A !important;
    color: #fff !important;
    pointer-events: none;
    box-shadow: 0 2pt 4pt rgba(22, 163, 106, 0.3);
}

/* Misplaced flash (correct letter, wrong position) */
.challenge-cell--misplaced {
    background: #FEF3C7 !important;
    border-color: #F59E0B !important;
    color: #92400e !important;
}

/* Hint letter under cell (misplaced letter reminder) */
.challenge-cell-hint {
    position: absolute;
    bottom: -11pt;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9pt;
    color: #F59E0B;
    font-weight: 600;
    pointer-events: none;
}

.challenge-cell--hint {
    background: #FEF3C7;
    border-color: #F59E0B;
    color: #92400e;
}

/* ===== ANIMATIONS ===== */
@keyframes challenge-flip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

@keyframes challenge-shake-cell {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3pt); }
    75% { transform: translateX(3pt); }
}

/* ===== SCORE DISPLAY (lagom — warm & gentle) ===== */
.challenge-score-wrap {
    text-align: center;
    margin-bottom: 14pt;
    position: relative;
}

.challenge-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6pt;
    margin-bottom: 8pt;
}

.challenge-score__icon {
    font-size: 20pt;
}

.challenge-score__value {
    font-size: 26pt;
    font-weight: 800;
    color: #92400E;
    font-variant-numeric: tabular-nums;
    transition: color 1s ease;
}

.challenge-score-bar {
    height: 6pt;
    background: #F3E8D0;
    border-radius: 3pt;
    overflow: hidden;
    margin: 0 auto;
    max-width: 260pt;
}

.challenge-score-bar__fill {
    height: 100%;
    width: 100%;
    background: #F59E0B;
    border-radius: 3pt;
    transition: width 0.8s ease, background 1.5s ease;
}

/* Floating score change animation */
.challenge-score-float {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    font-size: 16pt;
    font-weight: 700;
    pointer-events: none;
    opacity: 1;
    animation: scoreFloatUp 1s ease-out forwards;
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.challenge-score-float--penalty {
    color: #DC2626;
}
.challenge-score-float--bonus {
    color: #16A34A;
}
@keyframes scoreFloatUp {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30pt); }
}

/* ===== BUTTONS ===== */
.challenge-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8pt;
}

.challenge-btn-guess {
    background: #F97316;
    color: #fff;
    border: none;
    border-radius: 10pt;
    padding: 10pt 32pt;
    font-size: 14pt;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    min-width: 160pt;
    box-shadow: 0 2pt 8pt rgba(249, 115, 22, 0.3);
}

.challenge-btn-guess:hover { background: #ea580c; }
.challenge-btn-guess:active { transform: scale(0.96); }
.challenge-btn-guess:disabled { opacity: 0.5; cursor: not-allowed; }

.challenge-btn-reveal {
    background: transparent;
    border: none;
    color: #777;
    font-size: 12pt;
    cursor: pointer;
    padding: 4pt 8pt;
    text-decoration: underline;
}

.challenge-btn-reveal:hover { color: #555; }

/* ===== RESULT PANEL ===== */
.challenge-result {
    text-align: center;
    padding: 20pt 16pt;
}

/* Score in result panel */
.challenge-result__score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6pt;
    margin: 10pt 0;
}

.challenge-result__score-icon {
    font-size: 22pt;
}

.challenge-result__score-value {
    font-size: 34pt;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.challenge-result__score-label {
    font-size: 13pt;
    color: #92400E;
}

.challenge-result__score--high .challenge-result__score-value { color: #059669; }
.challenge-result__score--mid  .challenge-result__score-value { color: #D97706; }
.challenge-result__score--low  .challenge-result__score-value { color: #EA580C; }

.challenge-result__message {
    font-size: 15pt;
    font-weight: 600;
    margin-bottom: 8pt;
    color: #92400E;
}

.challenge-result__personal {
    display: flex;
    justify-content: center;
    gap: 16pt;
    font-size: 11pt;
    color: #9CA3AF;
    margin-bottom: 14pt;
}

.challenge-result__word {
    font-size: 20pt;
    font-weight: 800;
    color: #1f2937;
    letter-spacing: 2pt;
    margin-bottom: 10pt;
}

.challenge-result__stats {
    display: flex;
    justify-content: center;
    gap: 12pt;
    font-size: 12pt;
    color: #6b7280;
    margin-bottom: 14pt;
    flex-wrap: wrap;
}

.challenge-result__streak {
    color: #F59E0B;
    font-weight: 700;
}

/* Progress bar */
.challenge-progress {
    margin: 14pt 0;
}

.challenge-progress__label {
    font-size: 12pt;
    color: #6b7280;
    margin-bottom: 6pt;
}

.challenge-progress__bar {
    height: 8pt;
    background: #E5E7EB;
    border-radius: 4pt;
    overflow: hidden;
}

.challenge-progress__fill {
    height: 100%;
    background: #F97316;
    border-radius: 4pt;
    transition: width 0.5s ease;
}

/* Next button */
.challenge-btn-next {
    display: block;
    width: 100%;
    background: #F97316;
    color: #fff;
    border: none;
    border-radius: 10pt;
    padding: 12pt 24pt;
    font-size: 14pt;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10pt;
    box-shadow: 0 2pt 8pt rgba(249, 115, 22, 0.3);
    transition: background 0.2s;
}

.challenge-btn-next:hover { background: #ea580c; }

.ch-countdown {
    font-weight: 400;
    opacity: 0.8;
}

/* ===== AUTO-REVEALED CELL (gentle fade-in) ===== */
.challenge-cell--auto-revealed {
    background: #D1FAE5 !important;
    border-color: #6EE7B7 !important;
    color: #065F46 !important;
    pointer-events: none;
    animation: challenge-cell-fadein 0.6s ease;
}

@keyframes challenge-cell-fadein {
    from { opacity: 0.3; transform: scale(0.9); }
    to   { opacity: 1;   transform: scale(1); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .challenge-cell {
        width: 30pt;
        height: 30pt;
        font-size: 12pt;
    }
    .challenge-overlay {
        padding: 12pt 10pt;
    }
}

/* Long words (>10 letters) */
.challenge-cells--long .challenge-cell {
    width: 26pt;
    height: 26pt;
    font-size: 12pt;
    border-radius: 4pt;
}

@media (max-width: 400px) {
    .challenge-cells--long .challenge-cell {
        width: 22pt;
        height: 22pt;
        font-size: 12pt;
    }
}

/* ===== LOADING ===== */
.challenge-loading {
    text-align: center;
    padding: 24pt;
    color: #9ca3af;
    font-size: 12pt;
}

.challenge-loading i {
    display: block;
    font-size: 16pt;
    margin-bottom: 8pt;
    animation: challenge-spin 1s linear infinite;
}

@keyframes challenge-spin {
    to { transform: rotate(360deg); }
}

/* ===== MISPLACED CHIPS BAR ===== */
.challenge-misplaced-bar {
    text-align: center;
    margin: 8pt 0;
}

.challenge-misplaced-label {
    font-size: 12pt;
    color: #92400e;
    display: block;
    margin-bottom: 4pt;
}

.challenge-misplaced-chips {
    display: flex;
    gap: 6pt;
    justify-content: center;
    flex-wrap: wrap;
}

.challenge-misplaced-chip {
    background: #FEF3C7;
    border: 1pt solid #F59E0B;
    border-radius: 4pt;
    padding: 2pt 8pt;
    font-size: 12pt;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
}

/* ===== ONBOARDING OVERLAY ===== */
.challenge-onboarding {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.challenge-onboarding__card {
    background: #fff;
    border-radius: 14pt;
    padding: 20pt;
    max-width: 280pt;
    text-align: center;
    box-shadow: 0 4pt 24pt rgba(0, 0, 0, 0.15);
}

.challenge-onboarding__title {
    font-size: 16pt;
    font-weight: 700;
    margin-bottom: 12pt;
    color: #1f2937;
}

.challenge-onboarding__rules {
    text-align: left;
    font-size: 12pt;
    line-height: 2.4;
    margin-bottom: 12pt;
    color: #374151;
}

.challenge-onboarding__rules div {
    display: flex;
    align-items: center;
    gap: 8pt;
}

/* Onboarding colored dots (replace emoji) */
.ob-dot {
    display: inline-block;
    width: 10pt;
    height: 10pt;
    border-radius: 3pt;
    flex-shrink: 0;
}
.ob-dot--score  { background: #F59E0B; }
.ob-dot--green  { background: #22C55E; }
.ob-dot--yellow { background: #FCD34D; }
.ob-dot--gray   { background: #D1D5DB; }
.ob-dot--reveal { background: #93C5FD; }

.challenge-onboarding__footer {
    font-size: 12pt;
    color: #6b7280;
    margin-bottom: 14pt;
}

/* Close button (X) in challenge overlay */
.challenge-close-btn {
    position: absolute;
    top: 8pt;
    left: 8pt;
    width: 24pt;
    height: 24pt;
    border-radius: 50%;
    border: 1.5pt solid #D1D5DB;
    background: #fff;
    color: #9ca3af;
    font-size: 14pt;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.challenge-close-btn:hover {
    border-color: #EF4444;
    color: #EF4444;
}

/* Help button (?) in challenge overlay */
.challenge-help-btn {
    position: absolute;
    top: 8pt;
    right: 8pt;
    width: 24pt;
    height: 24pt;
    border-radius: 50%;
    border: 1.5pt solid #D1D5DB;
    background: #fff;
    color: #9ca3af;
    font-size: 12pt;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.challenge-help-btn:hover {
    border-color: #F97316;
    color: #F97316;
}

/* Make overlay position relative for help btn */
.challenge-overlay {
    position: relative;
}

/* ===== FINAL SPLASH (after 5 rounds) ===== */
.challenge-final {
    text-align: center;
    padding: 16pt 12pt;
}

.challenge-final__title {
    font-size: 18pt;
    font-weight: 700;
    margin-bottom: 14pt;
    color: #1f2937;
}

.challenge-final__summary {
    display: flex;
    justify-content: center;
    gap: 24pt;
    margin-bottom: 14pt;
}

.challenge-final__stat {
    text-align: center;
}

.challenge-final__stat-value {
    display: block;
    font-size: 22pt;
    font-weight: 800;
    color: #92400E;
    font-variant-numeric: tabular-nums;
}

.challenge-final__stat-label {
    font-size: 11pt;
    color: #6b7280;
}

.challenge-final__personal {
    font-size: 11pt;
    color: #9CA3AF;
    margin-bottom: 14pt;
}

/* ===== SHARE BUTTONS (ordgatan style) ===== */
.challenge-final__share {
    margin-bottom: 14pt;
}

.challenge-final__share-label {
    font-size: 13pt;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8pt;
}

.challenge-final__share-buttons {
    display: flex;
    gap: 8pt;
}

.challenge-share-btn {
    flex: 1;
    height: 36pt;
    border-radius: 8pt;
    border: 1.5pt solid;
    background: #fff;
    font-size: 12pt;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6pt;
    transition: background 0.2s, color 0.2s;
}

.challenge-share-btn--whatsapp {
    border-color: #25d366;
    color: #25d366;
}

.challenge-share-btn--whatsapp:hover {
    background: #25d366;
    color: #fff;
}

.challenge-share-btn--facebook {
    border-color: #1877f2;
    color: #1877f2;
}

.challenge-share-btn--facebook:hover {
    background: #1877f2;
    color: #fff;
}

/* ===== AUTH CTA (anonymous users) ===== */
.challenge-final__auth-text {
    font-size: 12pt;
    color: #92400E;
    margin: 0 0 8pt;
    text-align: center;
}

.challenge-final__google-btn {
    display: inline-flex;
    align-items: center;
    gap: 8pt;
    background: #fff;
    border: 1pt solid #D1D5DB;
    border-radius: 8pt;
    padding: 8pt 16pt;
    font-size: 12pt;
    font-weight: 600;
    color: #374151;
    text-decoration: none;
    transition: box-shadow 0.2s;
}

.challenge-final__google-btn:hover {
    box-shadow: 0 2pt 8pt rgba(0, 0, 0, 0.1);
}

.challenge-final__google-btn img {
    width: 16pt;
    height: 16pt;
}

.challenge-final__or-register {
    text-align: center;
    font-size: 11pt;
    color: #78716C;
    margin: 8pt 0 14pt;
}
.challenge-final__or-register a {
    color: #EA580C;
    text-decoration: underline;
    font-weight: 600;
}
.challenge-final__or-register a:hover {
    color: #C2410C;
}

/* ===== PLAY MORE CTA (single mode) ===== */
.challenge-final__playmore {
    text-align: center;
    padding: 16pt;
}

.challenge-final__playmore p {
    font-size: 14pt;
    color: #374151;
    margin-bottom: 12pt;
}

/* ===== MODAL ===== */
.challenge-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16pt;
    animation: ch-modal-fadein 0.3s ease;
}

.challenge-modal {
    position: relative;
    background: #fff;
    border-radius: 16pt;
    padding: 24pt 20pt;
    max-width: 400pt;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8pt 32pt rgba(0, 0, 0, 0.2);
    animation: ch-modal-slidein 0.3s ease;
}

.challenge-modal-close {
    position: absolute;
    top: 10pt;
    right: 12pt;
    background: none;
    border: none;
    font-size: 22pt;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4pt;
}

.challenge-modal-close:hover {
    color: #333;
}

@keyframes ch-modal-fadein {
    from { opacity: 0; } to { opacity: 1; }
}

@keyframes ch-modal-slidein {
    from { opacity: 0; transform: translateY(20pt); }
    to { opacity: 1; transform: translateY(0); }
}
