/* =====================================================
   SOPA DE LLETRES — 5 NIVELLS
   ===================================================== */

.sopa-section {
    padding-top: calc(var(--header-h) + 1rem);
    padding-bottom: 2rem;
    min-height: calc(100vh - 80px);
}

.sopa-panel {
    max-width: 650px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
    position: relative;
}

/* ==================== INICI ==================== */
.sopa-char-preview {
    width: 70px;
    height: 70px;
    object-fit: contain;
    margin: 0 auto .75rem;
}

.sopa-title {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .4rem;
}

.sopa-intro {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: .3rem;
}

.sopa-hint {
    font-size: .9rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* Selector de nivells */
.sopa-level-select {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.sopa-level-btn {
    padding: .6rem 1rem;
    border-radius: var(--r-full);
    background: var(--bg);
    border: 2px solid transparent;
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 800;
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
    line-height: 1.3;
}

.sopa-level-btn:hover {
    border-color: var(--verde);
    transform: translateY(-2px);
}

.sopa-level-btn small {
    font-size: .7rem;
    font-weight: 600;
    color: var(--muted);
}

/* ==================== JOC ==================== */
.sopa-exit {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    font-size: .9rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.sopa-exit:hover {
    background: var(--verde);
    color: var(--white);
}

.sopa-game-char {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.sopa-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0 .25rem;
    font-weight: 800;
    gap: .5rem;
}

.sopa-level-label {
    font-size: .9rem;
    color: var(--verde);
}

.sopa-timer {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text);
    background: var(--bg);
    padding: .2rem .6rem;
    border-radius: var(--r-full);
}

.sopa-sound-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
    flex-shrink: 0;
}

.sopa-sound-btn.muted { opacity: .4; }

.sopa-found {
    font-size: .9rem;
    font-weight: 800;
    color: var(--muted);
    margin-bottom: .5rem;
}

/* ==================== GRID ==================== */
.sopa-grid {
    display: inline-grid;
    gap: 2px;
    margin: 0 auto .75rem;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.sopa-cell {
    width: var(--sopa-cell, 36px);
    height: var(--sopa-cell, 36px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--sopa-cell, 36px) * 0.48);
    font-weight: 900;
    color: var(--text);
    background: var(--white);
    border-radius: 5px;
    border: 2px solid var(--bg);
    cursor: pointer;
    transition: background .1s, border-color .1s, color .1s;
    text-transform: uppercase;
}

.sopa-cell:hover {
    border-color: var(--verde);
}

.sopa-cell.selecting {
    background: #d4edda;
    border-color: var(--verde);
    color: #2e7d32;
}

.sopa-cell.found {
    background: var(--verde);
    border-color: var(--verde);
    color: var(--white);
}

/* ==================== LLISTA PARAULES ==================== */
.sopa-words {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    justify-content: center;
}

.sopa-word {
    font-size: .85rem;
    font-weight: 800;
    padding: .25rem .65rem;
    border-radius: var(--r-full);
    background: var(--bg);
    color: var(--text);
    transition: background .2s, color .2s;
}

.sopa-word.done {
    background: var(--verde);
    color: var(--white);
    text-decoration: line-through;
}

/* ==================== VICTÒRIA NIVELL ==================== */
.sopa-lvl-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .4rem;
}

.sopa-lvl-score {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* ==================== FINAL ==================== */
.sopa-win-title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .4rem;
}

.sopa-win-msg {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.sopa-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .sopa-panel { padding: 1.25rem .75rem; }
    .sopa-grid { gap: 1px; }
    .sopa-words { gap: .3rem; }
    .sopa-word { font-size: .75rem; padding: .2rem .5rem; }
    .sopa-actions { flex-direction: column; align-items: stretch; }
    .sopa-level-select { gap: .35rem; }
    .sopa-level-btn { font-size: .75rem; padding: .4rem .7rem; }
}
