/* Wonder Word – theme-aware Brain-Train aesthetic */

.wonder-word-content {
    background: var(--surface-color, #161B22);
    color: var(--text-primary, #F8FAFC);
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.wonder-word-content h3 {
    margin: 16px 0 12px 0;
    font-size: 1.1rem;
    color: var(--accent, #ffae00);
}

/* Level grid */
.wonder-word-level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 10px;
    max-width: 520px;
    max-height: 55vh;
    overflow-y: auto;
}

.wonder-word-level-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
    border: 2px solid var(--border-color, #475569);
    background: var(--button-bg, #282828);
    color: var(--text-primary, #f8fafc);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wonder-word-level-btn:hover {
    border-color: var(--accent, #ffae00);
}

.wonder-word-level-btn.completed {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

body.light-theme .wonder-word-level-btn.completed {
    color: #15803d;
}

.wonder-word-level-btn.completed:hover {
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

/* Stats bar */
.wonder-word-stats {
    margin-bottom: 16px;
    font-size: 1rem;
    color: var(--accent, #ffae00);
    font-weight: 600;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.wonder-word-found {
    color: var(--accent, #ffae00);
}

.wonder-word-stats button {
    padding: 8px 16px;
    font-size: 0.95rem;
    border-radius: 8px;
    border: 2px solid var(--border-color, #475569);
    background: var(--button-bg, #282828);
    color: var(--accent, #ffae00);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.wonder-word-stats button:hover {
    border-color: var(--accent, #ffae00);
    box-shadow: 0 0 10px rgba(255, 174, 0, 0.4);
}

.wonder-word-stats #btn-hint {
    background: var(--button-bg, #282828);
    border-color: var(--border-color, #475569);
    color: var(--accent, #ffae00);
}

.wonder-word-stats #btn-hint:hover {
    border-color: var(--accent, #ffae00);
    box-shadow: 0 0 10px rgba(255, 174, 0, 0.4);
}

/* Crossword grid area */
.wonder-word-grid-wrap {
    width: 100%;
    max-width: 420px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--button-bg, #282828);
    border-radius: 16px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

body.light-theme .wonder-word-grid-wrap {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.wonder-word-crossword {
    display: inline-grid;
    gap: 2px;
    padding: 8px;
    margin: 0 auto;
    justify-content: center;
}

.wonder-word-cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 8px;
    background: var(--button-bg, #282828);
    color: var(--text-primary, #f8fafc);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    transition: all 0.3s ease;
}

body.light-theme .wonder-word-cell {
    background: #FFFFFF;
    color: #0F172A;
    border: 1px solid #94A3B8;
}

.wonder-word-cell.empty {
    background: var(--button-bg, #282828);
    color: transparent;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

body.light-theme .wonder-word-cell.empty {
    background: #CBD5E1;
    border: 1px solid #94A3B8;
}

.wonder-word-cell.revealed {
    background: rgba(34, 197, 94, 0.3);
    color: #22c55e;
    border-color: #22c55e;
}

body.light-theme .wonder-word-cell.revealed {
    background: rgba(34, 197, 94, 0.2);
    color: #15803d;
}

.wonder-word-cell.hinted {
    background: #ffae00;
    color: #0F172A;
    border-color: #ffae00;
}

/* Preview area */
.wonder-word-preview-wrap {
    margin-bottom: 20px;
    min-height: 48px;
}

.wonder-word-preview {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent, #ffae00);
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Word wheel container */
.wonder-word-wheel-wrap {
    width: 100%;
    max-width: 380px;
    margin: 0 auto 20px;
}

.wonder-word-wheel-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 320px;
    margin: 0 auto;
    touch-action: none;
}

.wonder-word-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 50%;
}

.wonder-word-wheel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 174, 0, 0.15);
    border: 3px solid #ffae00;
    box-shadow: 0 8px 32px rgba(255, 174, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

.wonder-word-letter {
    position: absolute;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50%;
    background: #ffae00;
    color: #0F172A;
    box-shadow: 0 4px 12px rgba(255, 174, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    transform: translate(-50%, -50%);
}

.wonder-word-letter:hover {
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow: 0 6px 18px rgba(255, 174, 0, 0.5);
}

.wonder-word-letter.active {
    background: #e69500;
    box-shadow: 0 0 20px rgba(255, 174, 0, 0.7);
    transform: translate(-50%, -50%) scale(1.1);
}

.wonder-word-xp {
    color: var(--accent, #ffae00);
    font-weight: 600;
}

.wonder-word-xp-popup {
    position: fixed;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent, #ffae00);
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 12px;
    border-radius: 8px;
    transform: translate(-50%, -50%);
    z-index: 9998;
    animation: wonder-word-xp-pop 1.2s ease-out forwards;
    pointer-events: none;
}

@keyframes wonder-word-xp-pop {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    70% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

.wonder-word-hint {
    color: var(--text-secondary, #94a3b8);
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: center;
    max-width: 360px;
}

/* Flying word animation */
@keyframes wonder-word-fly {
    0% {
        opacity: 1;
        transform: scale(1) translate(0, 0);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translate(var(--fly-x), var(--fly-y));
    }
}

.wonder-word-flying {
    position: fixed;
    font-size: 1.5rem;
    font-weight: 700;
    color: #34d399;
    pointer-events: none;
    z-index: 9999;
    animation: wonder-word-fly 0.6s ease-out forwards;
}

/* Responsive */
@media (max-width: 640px) {
    .wonder-word-level-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 8px;
    }

    .wonder-word-level-btn {
        width: 42px;
        height: 42px;
        font-size: 0.85rem;
    }

    .wonder-word-cell {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }

    .wonder-word-letter {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .wonder-word-preview {
        font-size: 1.25rem;
    }
}
