/* -------------------------------------------------------------------------
 * CrazeFeed Word Quiz — transparent, flat container
 * ---------------------------------------------------------------------- */

.wqp-quiz-container {
    --wqp-primary:       #003e41;
    --wqp-primary-dark:  #002527;
    --wqp-primary-light: #005a5e;
    --wqp-accent:        #f0cda3;
    --wqp-accent-dark:   #d4a97a;
    --wqp-success:       #2d7a5f;
    --wqp-warn:          #b8792e;
    --wqp-danger:        #b84343;
    --wqp-ink:           #003e41;
    --wqp-muted:         #5a7a7c;

    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 32px 28px 28px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--wqp-ink);
    text-align: center;
    overflow: hidden;
}

.wqp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.wqp-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--wqp-primary);
    flex: 1 1 auto;
    text-align: left;
    position: relative;
    padding-left: 14px;
}

.wqp-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--wqp-primary), var(--wqp-accent));
}

.wqp-hud {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.wqp-timer,
.wqp-streak {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 999px;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s;
}

.wqp-timer {
    background: var(--wqp-accent);
    color: var(--wqp-primary);
}

.wqp-streak {
    background: rgba(184, 121, 46, 0.14);
    color: #8a5620;
    transform: scale(0.85);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.2s,
        background 0.2s;
}

.wqp-streak.is-active { transform: scale(1); opacity: 1; }
.wqp-streak.is-hot    { background: rgba(184, 121, 46, 0.22); }

.wqp-streak.is-hot .wqp-streak-flame {
    animation: wqp-flame 0.8s ease-in-out infinite;
}

@keyframes wqp-flame {
    0%, 100% { transform: scale(1) rotate(-3deg); }
    50%      { transform: scale(1.15) rotate(3deg); }
}

.wqp-root-tiles {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px auto 22px;
}

.wqp-letter-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    font-size: 24px;
    font-weight: 800;
    color: var(--wqp-accent);
    background: linear-gradient(135deg, var(--wqp-primary), var(--wqp-primary-light));
    border-radius: 12px;
    box-shadow:
        0 6px 14px -6px rgba(0, 62, 65, 0.55),
        inset 0 -3px 0 rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    animation: wqp-tile-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.wqp-letter-tile:hover:not(.is-used) {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px -6px rgba(0, 62, 65, 0.7), inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}

.wqp-letter-tile.is-used {
    opacity: 0.35;
    cursor: default;
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    background: var(--wqp-primary-dark);
    color: rgba(240, 205, 163, 0.5);
}

@keyframes wqp-tile-in {
    from { transform: translateY(-20px) rotate(-15deg); opacity: 0; }
    to   { transform: translateY(0)     rotate(0);     opacity: 1; }
}

.wqp-score-board { margin-bottom: 10px; }

.wqp-score-value {
    font-size: 38px;
    font-weight: 900;
    line-height: 1;
    color: var(--wqp-primary);
    display: inline-block;
    transition: transform 0.2s ease;
}

.wqp-score-value.wqp-pulse { animation: wqp-pulse 0.4s ease-out; }

@keyframes wqp-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.18); color: var(--wqp-success); }
    100% { transform: scale(1); }
}

.wqp-target-suffix {
    font-size: 22px;
    font-weight: 700;
    color: var(--wqp-muted);
    margin-left: 6px;
}

.wqp-score-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--wqp-muted);
    margin-top: 4px;
}

.wqp-progress-track {
    position: relative;
    height: 8px;
    margin: 14px auto 4px;
    max-width: 340px;
    background: rgba(0, 62, 65, 0.1);
    border-radius: 999px;
    overflow: hidden;
}

.wqp-progress-fill {
    position: relative;
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--wqp-primary), var(--wqp-success));
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.wqp-progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(240, 205, 163, 0.6), transparent);
    animation: wqp-shine 1.6s linear infinite;
    transform: translateX(-100%);
}

@keyframes wqp-shine { to { transform: translateX(100%); } }

.wqp-hint {
    margin: 10px 0 18px;
    font-size: 14px;
    color: var(--wqp-muted);
}

#wqp-word-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 14px;
}

#wqp-user-input {
    flex: 1 1 220px;
    max-width: 420px;
    padding: 14px 18px;
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    color: var(--wqp-ink);
    background: #fff;
    border: 2px solid rgba(0, 62, 65, 0.18);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

#wqp-user-input:focus {
    border-color: var(--wqp-primary);
    box-shadow: 0 0 0 4px rgba(0, 62, 65, 0.12);
}

#wqp-user-input.wqp-shake {
    animation: wqp-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
    border-color: var(--wqp-danger);
    box-shadow: 0 0 0 4px rgba(184, 67, 67, 0.14);
}

@keyframes wqp-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

#wqp-word-form button {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--wqp-accent);
    background: linear-gradient(135deg, var(--wqp-primary), var(--wqp-primary-light));
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(0, 62, 65, 0.65);
    transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
}

#wqp-word-form button:hover:not(:disabled) {
    filter: brightness(1.15);
    box-shadow: 0 10px 22px -8px rgba(0, 62, 65, 0.8);
}

#wqp-word-form button:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

#wqp-word-form button:disabled {
    opacity: 0.55;
    cursor: progress;
    box-shadow: none;
}

.wqp-msg {
    min-height: 1.6em;
    margin: 6px 0 4px;
    font-weight: 700;
    font-size: 15px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s, transform 0.2s;
}

.wqp-msg.is-visible { opacity: 1; transform: translateY(0); }

.wqp-msg.wqp-msg-success { color: var(--wqp-success); }
.wqp-msg.wqp-msg-error   { color: var(--wqp-danger); }
.wqp-msg.wqp-msg-warn    { color: var(--wqp-warn); }
.wqp-msg.wqp-msg-info    { color: var(--wqp-muted); }

.wqp-found-list-wrap {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed rgba(0, 62, 65, 0.15);
    text-align: left;
}

.wqp-found-list-wrap h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--wqp-muted);
}

.wqp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 800;
    color: var(--wqp-accent);
    background: var(--wqp-primary);
    border-radius: 999px;
}

#wqp-found-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 30px;
}

#wqp-found-list li {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--wqp-primary);
    background: var(--wqp-accent);
    border: 1px solid var(--wqp-accent-dark);
    border-radius: 999px;
    box-shadow: 0 2px 4px -2px rgba(212, 169, 122, 0.5);
    animation: wqp-pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    
    /* Clickable styling */
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

#wqp-found-list li.has-definition:hover {
    background: #fff;
    border-color: var(--wqp-primary);
}

#wqp-found-list li.is-active {
    background: var(--wqp-primary);
    color: var(--wqp-accent);
    border-color: var(--wqp-primary);
}

/* Replace checkmark with circle info icon (ⓘ) */
#wqp-found-list li::before {
    content: "ⓘ";
    font-size: inherit; /* inherits exact word size */
    font-weight: 800;   /* bold, not bigger */
    color: var(--wqp-primary);
    opacity: 0.6;
    line-height: 1;
}

#wqp-found-list li.is-active::before {
    color: var(--wqp-accent);
    opacity: 1;
}

@keyframes wqp-pop-in {
    from { transform: scale(0.6) translateY(8px); opacity: 0; }
    to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

#wqp-finish-section {
    margin-top: 26px;
    padding: 24px 20px;
    border-top: 1px solid rgba(0, 62, 65, 0.1);
    animation: wqp-fade-up 0.5s ease both;
}

#wqp-finish-section[hidden] { display: none; }

.wqp-finish-emoji {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 8px;
    animation: wqp-bounce 1s ease-in-out infinite;
}

@keyframes wqp-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

#wqp-finish-section h4 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 800;
    color: var(--wqp-success);
}

#wqp-finish-section p {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--wqp-muted);
}

.wqp-finish-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

#wqp-player-name {
    flex: 1 1 200px;
    max-width: 260px;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid rgba(0, 62, 65, 0.18);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#wqp-player-name:focus {
    border-color: var(--wqp-success);
    box-shadow: 0 0 0 4px rgba(45, 122, 95, 0.15);
}

#wqp-save-score {
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--wqp-success), #245d47);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 8px 16px -8px rgba(45, 122, 95, 0.7);
    transition: transform 0.1s, filter 0.2s;
}

#wqp-save-score:hover:not(:disabled) { filter: brightness(1.08); }
#wqp-save-score:active:not(:disabled) { transform: translateY(1px); }
#wqp-save-score:disabled { opacity: 0.55; cursor: progress; }

.wqp-early-finish-wrap { margin-top: 22px; }
.wqp-early-finish-wrap[hidden] { display: none; }

.wqp-link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--wqp-muted);
    font-size: 13px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color 0.2s;
}

.wqp-link-button:hover { color: var(--wqp-primary); }

.wqp-confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 99999;
}

.wqp-confetti-piece {
    position: absolute;
    top: -20px;
    border-radius: 2px;
    animation: wqp-confetti-fall linear forwards;
    will-change: transform, opacity;
}

@keyframes wqp-confetti-fall {
    0%   { transform: translateY(0)      rotate(0deg);   opacity: 1; }
    100% { transform: translateY(105vh)  rotate(720deg); opacity: 0; }
}

@keyframes wqp-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .wqp-letter-tile,
    .wqp-finish-emoji,
    .wqp-progress-fill::after,
    .wqp-streak.is-hot .wqp-streak-flame {
        animation: none;
    }
    #wqp-found-list li        { animation: none; }
    #wqp-user-input.wqp-shake { animation: none; }
}

/* --- Countdown timer -------------------------------------------------- */

.wqp-timer--countdown {
    background: var(--wqp-accent);
    color: var(--wqp-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.wqp-timer--countdown.is-warning {
    background: #fff3e0;
    color: #b8792e;
    animation: wqp-timer-pulse 1s ease-in-out infinite;
}

.wqp-timer--countdown.is-critical {
    background: var(--wqp-danger);
    color: #fff;
    animation: wqp-timer-pulse 0.6s ease-in-out infinite;
}

@keyframes wqp-timer-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
    .wqp-timer--countdown.is-warning,
    .wqp-timer--countdown.is-critical {
        animation: none;
    }
}

.wqp-quiz-container,
.wqp-quiz-container *,
#wqp-word-form,
#wqp-word-form * {
    view-transition-name: none;
}

.wqp-finish-status {
    min-height: 24px;
    margin-top: 12px;
    font-size: 15px;
    text-align: center;
}

.wqp-found-list-wrap ul li.wqp-word-item {
    display: inline-flex;
    align-items: center;
}

/* Hide the old separate info button */
.wqp-info-btn {
    display: none !important;
}

/* Definition Popover */
.wqp-def-toast {
    position: fixed;
    background: #003e41;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    max-width: 220px;
    white-space: normal;
    z-index: 99999;
    font-size: 13px;
    line-height: 1.45;
    cursor: pointer;
    transform: translateX(-50%);
    animation: wqp-def-in 0.16s ease-out;
}

.wqp-def-toast::after {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #003e41;
    pointer-events: none;
}

.wqp-def-toast.is-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #003e41;
}

.wqp-def-toast strong {
    font-weight: 800;
    margin-right: 2px;
}

.wqp-def-toast .wqp-pos {
    font-style: italic;
    opacity: 0.7;
    font-size: 0.92em;
}

@keyframes wqp-def-in {
    from { opacity: 0; transform: translateX(-50%) translateY(4px) scale(0.97); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* -------------------------------------------------------------------------
 * MOBILE LAYOUT (OPTIMIZED AUTO-FIT GRID)
 * ---------------------------------------------------------------------- */

@media (max-width: 768px) {
    .wqp-quiz-container {
        display: flex;
        flex-direction: column;
        padding: 20px 2px;
    }

    .wqp-header {
        order: 1;
        flex-shrink: 0;
    }

    .wqp-root-tiles {
        order: 2;
        flex-shrink: 0;
        margin-bottom: 12px;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
        width: 100%;
        padding: 0;
    }

    .wqp-score-board {
        order: 3;
        flex-shrink: 0;
        margin-bottom: 8px;
    }

    .wqp-hint {
        order: 4;
        display: none;
    }

    .wqp-found-list-wrap {
        order: 5;
        flex-shrink: 1;
        min-height: 60px;
        max-height: 95px;
        overflow-y: auto;
        margin-top: 0;
        margin-bottom: 12px;
        padding-top: 10px;
        border-top: 1px dashed rgba(0, 62, 65, 0.15);
        border-bottom: 1px dashed rgba(0, 62, 65, 0.15);
        padding-bottom: 10px;
        padding-left: 5px;
        padding-right: 5px;
    }

    .wqp-found-list-wrap h4 {
        margin-top: 0;
        font-size: 12px;
        margin-bottom: 8px;
    }

    /* --- OPTIMIZED AUTO-FIT GRID --- */
    #wqp-found-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
        gap: 5px;
        width: 100%;
    }

    #wqp-found-list li {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        box-sizing: border-box;
        font-size: 11px; 
        padding: 6px 4px;
        margin: 0;
        gap: 4px; /* space between icon and word */
        
        /* Safe text containment */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Keep the circle info icon perfectly sized on mobile */
    #wqp-found-list li::before {
        font-size: inherit;
        font-weight: 800;
    }

    /* Click state for mobile */
    #wqp-found-list li.has-definition:active,
    #wqp-found-list li.is-active {
        transform: scale(0.96);
        background: var(--wqp-primary);
        color: var(--wqp-accent);
        border-color: var(--wqp-primary);
    }

    /* ----------------------------- */

    #wqp-word-form {
        order: 6;
        flex-shrink: 0;
        margin-bottom: 8px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #wqp-user-input {
        flex: none;
        max-width: 100%;
        padding: 12px 14px;
        font-size: 16px;
    }

    #wqp-word-form button {
        width: 100%;
        padding: 12px 20px;
    }

    #wqp-message {
        order: 7;
        flex-shrink: 0;
    }

    #wqp-finish-section {
        order: 8;
        flex-shrink: 0;
    }

    .wqp-early-finish-wrap {
        order: 9;
        flex-shrink: 0;
    }

    /* Dynamic Tiles */
    .wqp-letter-tile {
        width: calc(100vw / 13);
        height: calc(100vw / 13);
        max-width: 45px;
        max-height: 45px;
        min-width: 24px;
        min-height: 24px;
        font-size: calc(100vw / 22);
        border-radius: 8px;
        flex-grow: 0;
    }

    .wqp-letter-tile:active:not(.is-used) {
        transform: scale(0.92);
        background: var(--wqp-primary-dark);
    }

    .wqp-score-value { font-size: 32px; }

    .wqp-def-toast {
        max-width: 90vw;
    }

    #wqp-player-name { max-width: 100%; }
    #wqp-save-score { width: 100%; }

    .wqp-header,
    #wqp-word-form,
    .wqp-score-board {
        padding-left: 5px;
        padding-right: 5px;
    }
}