/* Modo Niveles: estilos compartidos del mapa (map.html.twig) y el tablero (board.html.twig).
   Cargar SIEMPRE después de game.css: las reglas de overflow y los botones dependen del orden. */

/* ── Base común de ambas páginas ── */
html, body { overflow-x: hidden !important; max-width: 100vw; }
/* Scope a las páginas de niveles: con soft-nav esta hoja se inyecta en el
   documento de la home, y una regla `body {…}` sin scope contaminaría la home /
   otras páginas (p. ej. dejaba overflow-y:auto en la home). El mapa lo sobrescribe
   a hidden más abajo; el tablero (que sí scrollea) lo mantiene. */
body.levels-board-page, body.levels-map-page { overflow-y: auto !important; }
/* Mapa: el body NO scrollea (cabecera fija); el scroll vive en .levels-wrap.
   min-height:0 anula el min-height:100vh de game.css (evita el scroll fantasma). */
body.levels-map-page { overflow: hidden !important; height: 100dvh; min-height: 0 !important; padding-bottom: 0; }
body.levels-map-page { background: radial-gradient(ellipse at top, #2a2550 0%, #16132b 55%, #0e0c1e 100%); }
/* Modo claro: el mapa usa el degradado del tema (morado) con texto claro en el
   contenido, igual que la cabecera y la barra. El header/avatar quedan fuera de
   .levels-wrap, así que no se ven afectados. */
body.theme-light.levels-map-page { background: var(--bg-gradient); }
body.theme-light.levels-map-page .levels-wrap { color: #f8fafc; --text-color: #f8fafc; }
/* Nodos bloqueados: en claro, lavanda claro (no morado casi negro). */
body.theme-light .levels-node.locked {
    --nt: #cfd2ec; --nb: #b9bcdd; --ne: #9ea1c6;
    color: rgba(30,27,46,.5);
    box-shadow: 0 4px 0 var(--ne), 0 6px 10px rgba(76,29,149,.18);
}
/* Barra del CTA "Jugar": en claro, tono claro translúcido (no casi negro). */
body.theme-light .levels-footer {
    background: rgba(118,75,162,.32);
    border-top-color: rgba(255,255,255,.22);
}
/* Tarjeta de fin de tablero: en claro va sobre el degradado morado → texto claro.
   Las fichas del tablero usan --tile-fg, así que no se ven afectadas. */
body.theme-light .levels-result-card { color: #f8fafc; --text-color: #f8fafc; }
body.theme-light .levels-result-stars .star:not(.earned) { color: rgba(255,255,255,.3); }
/* Tablero: los textos de arriba van sobre el degradado morado → claros. */
body.theme-light .levels-board-title,
body.theme-light .levels-back,
body.theme-light .levels-progress-pts,
body.theme-light .levels-words-chip,
body.theme-light .levels-goal-chip { color: #f8fafc; }

.levels-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.levels-back {
    flex-shrink: 0; font-size: .85rem; color: inherit; text-decoration: none;
    background: rgba(255,255,255,.14); padding: 7px 14px; border-radius: 999px;
    border: 1px solid rgba(255,255,255,.22);
    transition: background .15s ease, transform .1s ease;
}
.levels-back:hover { background: rgba(255,255,255,.22); }
.levels-back:active { transform: scale(.96); }

/* Banner de bienvenida / recompensa inicial en Modo Niveles. Lo muestra
   levels_map.js solo si quedan tableros premiados por superar. */
.levels-welcome-banner {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 16px; margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(5, 150, 105, 0.25));
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #f8fafc; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15);
}
.lwb-icon { font-size: 1.5rem; flex-shrink: 0; }
.lwb-text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.lwb-text strong { font-weight: 800; font-size: .92rem; color: #34d399; }
.lwb-text span { font-size: .78rem; color: rgba(248, 250, 252, 0.85); font-weight: 600; }

@keyframes levels-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes levels-shimmer { to { background-position: -200% 0; } }

/* ── Mapa: cabecera y racha ── */
.levels-wrap { max-width: 520px; margin: 0 auto; padding: 16px 16px 110px; }
.levels-title { margin: 0; font-size: 1.35rem; display: flex; align-items: center; gap: 8px; }

.levels-streak-card {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(145deg, rgba(249,115,22,.18), rgba(234,88,12,.08));
    border: 1px solid rgba(249,115,22,.3);
    border-radius: 999px; padding: 8px 18px; margin: 0 auto 22px; width: fit-content;
    font-size: 1rem; font-weight: 700;
    animation: levels-fade-in .5s ease both;
}
.levels-streak-flame { display: inline-block; }
.levels-streak-card.on-fire .levels-streak-flame { animation: levels-flame 1.1s ease-in-out infinite; }
@keyframes levels-flame {
    0%, 100% { transform: scale(1) rotate(-3deg); }
    50% { transform: scale(1.18) rotate(4deg); }
}

/* ── Mapa: capítulos ── */
.levels-chapter {
    background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 0 0 28px;
    margin-bottom: 28px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    animation: levels-fade-in .5s ease both;
}
.levels-chapter.is-locked { opacity: .75; filter: saturate(.75); }
.levels-chapter-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(120deg, rgba(var(--chue, 99,102,241), .38), rgba(217,70,239,.14));
}
.levels-chapter-badge {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(145deg, rgb(var(--chue, 99,102,241)), color-mix(in oklab, rgb(var(--chue, 99,102,241)), black 35%));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem; box-shadow: 0 3px 8px rgba(0,0,0,.4);
}
.levels-chapter.is-done .levels-chapter-badge { background: linear-gradient(145deg,#4ade80,#16a34a); box-shadow: 0 3px 8px rgba(22,163,74,.5); }
.levels-chapter-title { margin: 0; font-size: 1rem; font-weight: 700; }
.levels-chapter-sub { margin: 2px 0 0; font-size: .78rem; opacity: .65; }
.levels-chapter-progress {
    font-size: .78rem; font-weight: 700;
    background: rgba(255,255,255,.1); padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.levels-chapter-meta { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.levels-chapter-stars {
    font-size: .72rem; font-weight: 700; white-space: nowrap;
    color: #fbbf24; background: rgba(251,191,36,.12);
    border: 1px solid rgba(251,191,36,.3);
    padding: 3px 8px; border-radius: 999px;
}
.levels-chapter-chest {
    font-size: .72rem; font-weight: 700; white-space: nowrap;
    color: #c4b5fd; background: rgba(139,92,246,.14);
    border: 1px solid rgba(139,92,246,.35);
    padding: 3px 8px; border-radius: 999px;
}
.levels-chapter-chest.is-open { color: #86efac; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.levels-chapter-bar { height: 5px; background: rgba(0,0,0,.3); }
.levels-chapter-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #4ade80, #16a34a);
    border-radius: 0 999px 999px 0;
    transition: width .9s cubic-bezier(.22, 1, .36, 1);
}

/* ── Mapa: camino serpenteante ── */
.levels-path {
    position: relative; padding: 34px 8px 6px;
    background:
        radial-gradient(circle at 18% 10%, rgba(var(--chue, 99,102,241), .13), transparent 42%),
        radial-gradient(circle at 85% 45%, rgba(var(--chue, 99,102,241), .09), transparent 45%),
        radial-gradient(circle at 30% 85%, rgba(var(--chue, 99,102,241), .08), transparent 42%);
}
/* Letras gigantes de fondo, marca de agua detrás del camino */
.levels-bg-letter {
    position: absolute; z-index: 0;
    font-weight: 900; line-height: 1;
    color: rgba(255,255,255,.05);
    pointer-events: none; user-select: none;
    transform: rotate(var(--rot, 0deg));
}
.levels-path-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.levels-path-track { fill: none; stroke: rgba(255,255,255,.16); stroke-width: 5; stroke-linecap: round; stroke-dasharray: .5 14; }
.levels-path-done { fill: none; stroke-width: 7; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(251,191,36,.45)); }

/* La posición horizontal de cada nodo la fija el JS: cada nivel tiene
   su propia onda (amplitud, frecuencia y fase distintas). */
.levels-node-row { position: relative; display: flex; padding: 7px 0; }

.levels-node {
    position: relative; z-index: 1;
    width: 60px; height: 60px; border-radius: 50%;
    border: none; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 800; font-size: 1.15rem; color: #fff;
    cursor: pointer;
    background: linear-gradient(145deg, var(--nt), var(--nb));
    box-shadow: 0 5px 0 var(--ne), 0 10px 16px rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.18);
    transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
    animation: levels-node-in .45s cubic-bezier(.34, 1.56, .64, 1) both;
    animation-delay: var(--d, 0ms);
    -webkit-tap-highlight-color: transparent;
}
@keyframes levels-node-in { from { opacity: 0; transform: scale(.55); } to { opacity: 1; transform: scale(1); } }
.levels-node:not(:disabled):hover { filter: brightness(1.1); }
.levels-node:not(:disabled):active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--ne), 0 4px 8px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.18);
}
.levels-node:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.levels-node.locked {
    --nt: #3d3a55; --nb: #2a2740; --ne: #1d1b2e;
    color: rgba(255,255,255,.32); cursor: default;
    box-shadow: 0 4px 0 var(--ne), 0 6px 10px rgba(0,0,0,.25);
}
.levels-node.completed { --nt: #4ade80; --nb: #16a34a; --ne: #166534; }
.levels-node.completed .levels-node-face { font-size: 1.5rem; line-height: 1; }

/* Mini estrellas bajo los nodos completados (estilo Angry Birds) */
.levels-node-stars {
    position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: flex-start; gap: 1px;
    font-size: .72rem; line-height: 1; pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.7));
}
.levels-node-stars span { color: rgba(255,255,255,.25); }
.levels-node-stars span.earned { color: #fbbf24; }
.levels-node-stars span:nth-child(2) { font-size: .9rem; margin-top: -3px; }
.levels-node.current { --nt: #fbbf24; --nb: #f97316; --ne: #c2410c; }
.levels-node.current::before {
    content: ''; position: absolute; inset: -9px; border-radius: 50%;
    border: 3px solid rgba(251,191,36,.55);
    animation: levels-halo 1.7s ease-out infinite;
}
@keyframes levels-halo {
    0% { transform: scale(.82); opacity: 1; }
    70%, 100% { transform: scale(1.28); opacity: 0; }
}
.levels-node.current::after {
    content: '¡Juega!'; position: absolute; top: -30px; left: 50%;
    background: #fff; color: #ea580c; font-size: .68rem; font-weight: 800;
    padding: 3px 9px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.3);
    animation: levels-bob 1.4s ease-in-out infinite;
}
@keyframes levels-bob {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -4px); }
}

/* Desbloqueo al volver de un tablero superado */
.levels-node.just-stamped .levels-node-face { animation: levels-stamp .55s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes levels-stamp {
    0% { transform: scale(0) rotate(-40deg); }
    60% { transform: scale(1.45) rotate(6deg); }
    100% { transform: scale(1) rotate(0); }
}
.levels-node.just-unlocked { animation: levels-unlock-pop .65s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes levels-unlock-pop {
    0% { transform: scale(.55); filter: saturate(0) brightness(.55); }
    55% { transform: scale(1.22); filter: none; }
    100% { transform: scale(1); }
}
.levels-unlock-ring {
    position: absolute; inset: -4px; border-radius: 50%;
    border: 4px solid rgba(251,191,36,.9); pointer-events: none;
    animation: levels-ring-burst .7s ease-out forwards;
}
@keyframes levels-ring-burst {
    0% { transform: scale(.9); opacity: 1; }
    100% { transform: scale(2.1); opacity: 0; }
}

.levels-decoration { position: absolute; font-size: 1.3rem; opacity: .3; pointer-events: none; }

/* ── Mapa: skeleton de carga ── */
.levels-skel-header { display: flex; align-items: center; gap: 12px; padding: 16px 18px; }
.levels-skel-block {
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.13) 50%, rgba(255,255,255,.05) 75%);
    background-size: 200% 100%;
    animation: levels-shimmer 1.4s linear infinite;
}
.levels-skel-badge { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; }
.levels-skel-line { height: 12px; }
.levels-skel-node { width: 60px; height: 60px; border-radius: 50%; }

/* ── Mapa: estados vacío / error ── */
.levels-state {
    text-align: center; padding: 42px 20px;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    border: 1px solid rgba(255,255,255,.1); border-radius: 20px;
    animation: levels-fade-in .4s ease both;
}
.levels-state-emoji { font-size: 2.6rem; display: block; margin-bottom: 10px; }
.levels-state p { margin: 0 0 18px; opacity: .75; line-height: 1.5; }
/* !important: game.css pisa el fondo de .btn sin id vía body.theme-dark .btn:not([style*="background"]) */
.levels-state .btn { background: linear-gradient(145deg,#6366f1,#4f46e5) !important; padding: 11px 26px; text-decoration: none; display: inline-block; }

/* ── Mapa: CTA inferior ── */
.levels-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(15,13,30,.85); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.08);
}
.levels-footer[hidden] { display: none; }
#levels-play-current-btn {
    width: 100%; max-width: 520px; margin: 0 auto; display: block;
    background: linear-gradient(145deg,#fb923c,#ea580c);
    padding: 14px; font-size: 1rem;
    box-shadow: 0 6px 18px rgba(249,115,22,.4);
}
#levels-play-current-btn:disabled { opacity: .55; cursor: default; }

/* ── Tablero: cabecera y barra de progreso ── */
/* Mismo ancho que el grid (min(96vw,96vh)) para que "Nivel · Tablero" y la barra
   de progreso ocupen todo el ancho y sus bordes coincidan con el tablero. */
.levels-board-top { width: min(96vw, 96vh); max-width: none; margin: 0; padding: 0 4px 12px; box-sizing: border-box; animation: levels-fade-in .4s ease both; }
.levels-board-title {
    margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 6px;
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.levels-progress { position: relative; }
.levels-progress-head {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    font-size: .82rem; margin-bottom: 6px;
}
.levels-progress-pts { font-weight: 800; }
.levels-progress-meta { display: flex; align-items: center; gap: 6px; }
.levels-words-chip, .levels-goal-chip, .levels-stars-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12);
    padding: 3px 10px; border-radius: 999px; font-weight: 700; white-space: nowrap;
}
.levels-stars-chip { color: #fbbf24; border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.12); }
.levels-progress-track {
    height: 14px; background: rgba(255,255,255,.1); border-radius: 999px;
    overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.35);
}
.levels-progress-fill {
    position: relative; height: 100%; width: 0%; border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width .55s cubic-bezier(.22, 1, .36, 1), background .4s ease, box-shadow .4s ease;
}
.levels-progress-fill::after {
    content: ''; position: absolute; inset: 0; border-radius: 999px;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: levels-shine 2.2s linear infinite;
}
@keyframes levels-shine { from { background-position: 200% 0; } to { background-position: -100% 0; } }
.levels-progress.goal-reached .levels-progress-fill {
    background: linear-gradient(90deg, #fbbf24, #f97316);
    box-shadow: 0 0 12px rgba(251,191,36,.6);
}
.levels-progress.goal-reached .levels-goal-chip {
    background: rgba(251,191,36,.18); border-color: rgba(251,191,36,.5); color: #fbbf24;
}

/* Chip "+N pts" que vuela hacia la barra */
.levels-pts-fly {
    position: absolute; top: 12px; transform: translate(-50%, 0);
    font-weight: 800; font-size: .95rem; color: #4ade80;
    text-shadow: 0 1px 3px rgba(0,0,0,.55); pointer-events: none; z-index: 2;
    animation: levels-fly .9s ease-out forwards;
}
@keyframes levels-fly {
    0% { opacity: 0; transform: translate(-50%, 8px) scale(.7); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -24px) scale(1.15); }
}
.bump { animation: levels-bump .32s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes levels-bump { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* Esqueleto del grid mientras carga el tablero */
.letter.levels-skel-cell {
    background: linear-gradient(90deg, #2b2f3d 25%, #3a4054 50%, #2b2f3d 75%) !important;
    background-size: 200% 100% !important;
    animation: levels-shimmer 1.3s linear infinite;
    color: transparent; pointer-events: none; box-shadow: none;
}

.section-fade-out { opacity: 0; transform: translateY(10px); transition: opacity .28s ease, transform .28s ease; }

/* ── Tablero: resultado ── */
/* Overlay fijo y scrollable: en pantallas bajas la tarjeta (con estadísticas y
   2 botones) supera el alto del tablero (overflow:hidden) y "Jugar de nuevo"
   quedaba fuera de pantalla. Ahora se puede desplazar y llegar siempre. */
.levels-result {
    position: fixed; inset: 0; z-index: 60;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    display: flex; align-items: safe center; justify-content: center;
    padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
    background: var(--bg-gradient);
}
.levels-result[hidden] { display: none; }
.levels-result-card {
    width: 100%; max-width: 420px; text-align: center;
    background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
    border: 1px solid rgba(255,255,255,.14); border-radius: 24px;
    padding: 30px 22px; box-shadow: 0 18px 40px rgba(0,0,0,.45);
    animation: levels-card-in .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes levels-card-in { from { opacity: 0; transform: translateY(24px) scale(.92); } to { opacity: 1; transform: none; } }
.levels-result-emoji { font-size: 3.4rem; line-height: 1; animation: levels-emoji-in .6s cubic-bezier(.34, 1.56, .64, 1) .15s both; }
.levels-result-emoji .ic { color: #fbbf24; filter: drop-shadow(0 0 14px rgba(251,191,36,.55)); }
@keyframes levels-emoji-in { from { opacity: 0; transform: scale(0) rotate(-30deg); } 60% { transform: scale(1.25) rotate(5deg); } to { opacity: 1; transform: none; } }
.levels-result-title { margin: 10px 0 2px; font-size: 1.35rem; }
.levels-result-stars { display: flex; justify-content: center; align-items: flex-start; gap: 12px; font-size: 2.3rem; line-height: 1; margin: 8px 0 2px; }
.levels-result-stars .star { color: rgba(255,255,255,.14); transform: scale(.9); }
.levels-result-stars .star:nth-child(2) { font-size: 3rem; margin-top: -10px; }
.levels-result-stars .star.earned {
    color: #fbbf24; transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(251,191,36,.65));
    animation: levels-star-pop .55s cubic-bezier(.34, 1.56, .64, 1) both;
    animation-delay: var(--sd, 0ms);
}
@keyframes levels-star-pop {
    0% { transform: scale(0) rotate(-40deg); }
    60% { transform: scale(1.35) rotate(8deg); }
    100% { transform: scale(1) rotate(0); }
}
.levels-result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 14px; }
.levels-result-stat {
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px; padding: 10px 8px; min-width: 0;
}
.levels-result-stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin-bottom: 3px; }
.levels-result-stat-value { font-weight: 800; font-size: 1rem; overflow-wrap: break-word; }
.levels-result-score {
    font-size: 2.7rem; font-weight: 900; line-height: 1.2; margin: 6px 0 12px;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.levels-result-card.completed .levels-result-score { background: linear-gradient(135deg, #fbbf24, #f97316); -webkit-background-clip: text; background-clip: text; }
.levels-result-bar {
    height: 12px; background: rgba(255,255,255,.1); border-radius: 999px;
    overflow: hidden; margin: 0 auto 12px; max-width: 300px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.35);
}
.levels-result-bar-fill {
    height: 100%; width: 0%; border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width .9s cubic-bezier(.22, 1, .36, 1);
}
.levels-result-card.completed .levels-result-bar-fill { background: linear-gradient(90deg, #fbbf24, #f97316); box-shadow: 0 0 10px rgba(251,191,36,.55); }
.levels-result-gems {
    background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.35);
    border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; line-height: 1.4; font-weight: 700;
}
.levels-result-detail { opacity: .8; margin: 0 0 22px; line-height: 1.5; }
.levels-result-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.levels-result-actions .btn { text-decoration: none; display: block; padding: 13px; font-size: 1rem; }
/* !important: game.css pisa el fondo de .btn sin id vía body.theme-dark .btn:not([style*="background"]) */
.levels-result-btn-primary { background: linear-gradient(145deg,#fb923c,#ea580c) !important; box-shadow: 0 6px 18px rgba(249,115,22,.4); }
.levels-result-btn-secondary { background: rgba(255,255,255,.12) !important; border: 1px solid rgba(255,255,255,.2) !important; }

/* Modal «resultado de un tablero ya superado» (se abre al tocar su nodo en el
   listado de niveles). Reutiliza .levels-result-stars y los botones de arriba.

   TODO en tokens del tema (--surface, --chip-bg, --border-color, --text-color…),
   que los 25 temas definen por igual: con rgba(255,255,255,…) fijos solo cuadraba
   en los oscuros, y hubo que parchear theme-light aparte —el resto (christmas,
   candy, school…) quedaba con la tarjeta invisible o el texto sin contraste. */
/* Las etiquetas pequeñas NO usan --text-muted: en light y christmas ese token se
   queda en 4.3-4.4:1 sobre la superficie del modal, por debajo del 4.5 de WCAG AA
   para texto pequeño. El color de texto del tema al 78% mantiene el matiz y sube
   muy por encima en los 25 temas. */
.levels-bres-content { max-width: 400px; text-align: center; }
.levels-bres-sub { margin: 0; font-weight: 700; font-size: .9rem; color: var(--text-color); opacity: .78; }
.levels-bres-stars-label { margin: 6px 0 0; font-size: .8rem; font-weight: 700; color: var(--text-color); opacity: .78; }
.levels-bres-stats { display: flex; justify-content: center; margin: 16px 0 0; }
.levels-bres-stat {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: var(--chip-bg); border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 14px; padding: 10px 22px; min-width: 140px;
}
.levels-bres-stat strong { font-size: 1.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.levels-bres-stat span { font-size: .76rem; font-weight: 700; color: var(--text-color); opacity: .78; }
.levels-bres-hint { margin: 14px 0 20px; font-size: .88rem; line-height: 1.45; color: var(--text-color); opacity: .85; }
.levels-bres-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.levels-bres-actions .btn { display: block; padding: 13px; font-size: 1rem; }
/* Estrellas sin conseguir: se apagan con opacidad y escala de grises, NO solo con
   `color`. El color únicamente afecta al icono del sprite (fill: currentColor); los
   temas que traen su propia estrella (8bit, pixel-art con fill fijo) la pintarían
   amarilla igual y las tres se verían iguales. Scopeado a .levels-bres-content para
   no tocar las del resultado del tablero. */
/* Por #id, no por clase: `body.theme-light .levels-result-stars .star:not(.earned)`
   (arriba, para el resultado del tablero, que va sobre el degradado morado) lleva un
   `body` y gana a cualquier selector de clases, así que en el tema claro pintaba
   estas estrellas de blanco sobre la superficie blanca del modal y solo se veía la
   conseguida. Un id gana sin recurrir a !important. */
#boardResultModal .levels-result-stars .star:not(.earned) {
    color: var(--text-muted);
    opacity: .55;
    filter: grayscale(1);
}
/* El color necesita !important: `body.theme-<x> .btn:not(…)` (game.css) lo fija con
   más especificidad que este selector, así que cambiar solo el fondo dejaba el texto
   del tema oscuro sobre una superficie clara (en theme-light, blanco sobre blanco). */
.levels-bres-content .levels-result-btn-secondary {
    background: var(--chip-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
}

/* Confeti */
.levels-confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4000; overflow: hidden; }
.levels-confetti {
    position: absolute; top: -18px; left: var(--x);
    width: 9px; height: 14px; border-radius: 3px;
    background: var(--clr); opacity: 0;
    animation: levels-confetti-fall var(--dur) ease-in var(--delay) forwards;
}
@keyframes levels-confetti-fall {
    0% { opacity: 1; transform: translateY(0) rotate(0); }
    100% { opacity: .85; transform: translateY(105vh) rotate(var(--r)); }
}

/* ── Subida de nivel: overlay celebratorio en la lista de niveles ── */
.levels-levelup {
    position: fixed; inset: 0; z-index: 4100;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.levels-levelup-card {
    background: linear-gradient(160deg, #312e81, #6d28d9);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 24px; padding: 26px 36px; text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 40px rgba(251,191,36,.25);
    animation: levels-levelup-pop 2.6s cubic-bezier(.34, 1.56, .64, 1) both;
}
.levels-levelup-emoji { font-size: 3rem; line-height: 1; }
.levels-levelup-title { margin: 10px 0 2px; font-size: 1.4rem; font-weight: 900; color: #fff; }
.levels-levelup-sub { margin: 0; font-size: .95rem; color: #fbbf24; font-weight: 700; }
@keyframes levels-levelup-pop {
    0% { opacity: 0; transform: scale(.6) translateY(24px); }
    12% { opacity: 1; transform: scale(1.05) translateY(0); }
    18% { transform: scale(1); }
    82% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(.96) translateY(-12px); }
}

/* ── Tablero de niveles: viewport bloqueado de verdad (iOS incluido) ───────
   Clave iOS: game.css pone body{min-height:100vh} y 100vh > pantalla visible
   (100dvh) con la barra de direcciones → el documento mide más que el viewport
   y aparece scroll con hueco abajo. Anulamos ese min-height, bloqueamos html Y
   body, y quitamos el padding-bottom del bottom-nav del juego clásico (aquí no
   existe). El logo de arriba se oculta para subir el contenido. El mapa
   (.levels-map-page) conserva su scroll normal. */
html.levels-board-html { height: 100%; overflow: hidden; }
/* Con soft-nav el contenido va dentro de #app-view; para no romper la cadena flex
   del viewport bloqueado, #app-view asume el rol de columna flexible (igual que
   en .levels-map-page). Sin esto, #section-play{flex:1} estiraría respecto a
   #app-view (altura natural) y no llenaría la pantalla. */
.levels-board-page #app-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; }
body.levels-board-page {
  min-height: 0 !important;
  height: 100vh;
  height: 100dvh;
  overflow-y: hidden !important;
  padding-top: max(env(safe-area-inset-top, 0px), 10px) !important;
  padding-bottom: env(safe-area-inset-bottom, 0px) !important;
}
.levels-board-page .game-header { display: none; }
.levels-board-page #section-play { flex: 1; min-height: 0; }
.levels-board-page .found-words {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  align-content: flex-start;
  -webkit-overflow-scrolling: touch;
}
.levels-board-page #section-result { flex: 1; min-height: 0; overflow-y: auto; }

/* ── Ranking de Niveles (podio + tu posición) ── */
.levels-ranking {
    background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 14px 14px 16px;
    margin: 0 0 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    animation: levels-fade-in .5s ease both;
}
.levels-ranking[hidden] { display: none; }
.lrk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.lrk-title { display: flex; align-items: center; gap: 7px; font-weight: 800; font-size: 1.02rem; }
.lrk-title .ic { color: #fbbf24; }
.lrk-all {
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
    color: inherit; font-size: .82rem; font-weight: 700; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.lrk-all:hover { background: rgba(255,255,255,.18); }

/* Podio: 3 columnas, la del medio (1º) más alta. */
.lrk-podium { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 8px; cursor: pointer; }
.lrk-pod {
    display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.015));
    border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 12px 6px 10px; min-width: 0; width: 100%;
}
.lrk-pod-empty { visibility: hidden; }
.lrk-pod-1 { padding-top: 18px; border-color: rgba(251,191,36,.5); background: linear-gradient(180deg, rgba(251,191,36,.2), rgba(251,191,36,.03)); }
.lrk-pod-2 { border-color: rgba(203,213,225,.4); }
.lrk-pod-3 { border-color: rgba(217,119,6,.4); }
.lrk-pod-medal { font-size: 1.5rem; line-height: 1; }
.lrk-pod-1 .lrk-pod-medal { font-size: 1.9rem; }
.lrk-pod-avatar {
    width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1rem; margin-top: 2px;
    background: linear-gradient(145deg, #6366f1, #4f46e5); color: #fff;
}
.lrk-pod-1 .lrk-pod-avatar { width: 42px; height: 42px; font-size: 1.2rem; background: linear-gradient(145deg,#fbbf24,#f59e0b); color: #1f1300; }
.lrk-pod-name {
    font-weight: 700; font-size: .82rem; max-width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lrk-pod-stars { font-size: .82rem; font-weight: 800; color: #fbbf24; }
.lrk-pod-pts { font-size: .72rem; opacity: .7; }

/* Tu posición */
.lrk-me {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 12px; padding: 10px 14px; border-radius: 12px;
    background: linear-gradient(145deg, rgba(99,102,241,.22), rgba(79,70,229,.08));
    border: 1px solid rgba(99,102,241,.4);
}
.lrk-me-rank { font-weight: 800; }
.lrk-me-stats { font-size: .88rem; opacity: .9; }
.lrk-me-empty { justify-content: center; text-align: center; font-size: .88rem; opacity: .85; }

/* Modal "Ver todo" */
.lrk-overlay {
    position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); animation: levels-fade-in .2s ease both;
}
.lrk-modal {
    width: 100%; max-width: 460px; max-height: 82vh; display: flex; flex-direction: column;
    background: #14122a; border: 1px solid rgba(255,255,255,.14); border-radius: 20px;
    padding: 18px 18px 8px; box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.lrk-modal-head { display: flex; align-items: center; justify-content: space-between; }
.lrk-modal-head h3 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.lrk-modal-head .ic { color: #fbbf24; }
.lrk-close { background: none; border: none; color: inherit; font-size: 1.8rem; line-height: 1; cursor: pointer; opacity: .7; padding: 0 4px; }
.lrk-close:hover { opacity: 1; }
.lrk-modal-sub { margin: 4px 0 12px; font-size: .8rem; opacity: .6; }
.lrk-list { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lrk-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.lrk-row.is-top { background: rgba(251,191,36,.06); }
.lrk-row.is-me { background: rgba(99,102,241,.18); border: 1px solid rgba(99,102,241,.4); }
.lrk-row-rank { width: 34px; flex-shrink: 0; font-weight: 800; text-align: center; }
.lrk-row-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .82rem; background: linear-gradient(145deg,#6366f1,#4f46e5); color: #fff;
}
/* Avatar-emoji elegido por el jugador: fondo neutro (sin el círculo de color). */
.lrk-row-avatar.has-emoji { background: rgba(125,130,150,.18) !important; font-size: 1.05rem; }
.lrk-pod-avatar.has-emoji { background: rgba(125,130,150,.18) !important; font-size: 1.5rem; }
.lrk-row-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrk-tag { font-size: .68rem; font-weight: 700; background: rgba(99,102,241,.5); padding: 1px 6px; border-radius: 999px; margin-left: 4px; }
.lrk-row-stars { flex-shrink: 0; font-weight: 800; color: #fbbf24; font-size: .86rem; }
.lrk-row-pts { flex-shrink: 0; width: 62px; text-align: right; font-size: .82rem; opacity: .75; }
.lrk-row-gap { text-align: center; opacity: .4; padding: 4px 0; letter-spacing: 3px; }

/* Claro */
body.theme-light .lrk-modal { background: #fff; color: #0f172a; }
body.theme-light .lrk-me-stats { opacity: 1; }

/* ── Pestañas Camino / Mundos ── */
.levels-tabs { display: flex; gap: 6px; padding: 4px; margin: 0 0 14px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); }
.levels-tab { flex: 1; padding: 10px 8px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; opacity: .7; }
.levels-tab.is-active { background: rgba(255,255,255,.14); opacity: 1; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.levels-worlds-empty { text-align: center; opacity: .65; padding: 32px 12px; }

/* ── Mundos temáticos: tarjeta con el color del mundo ── */
.levels-world {
    position: relative; overflow: hidden;
    border-radius: 20px; margin-bottom: 22px; padding: 0 0 16px;
    background: linear-gradient(180deg, rgba(var(--wtint), .22), rgba(var(--wtint), .05));
    border: 1px solid rgba(var(--wtint), .35);
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    animation: levels-fade-in .5s ease both;
}
.levels-world.is-done { border-color: rgba(74,222,128,.5); }
.levels-world-header { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.levels-world-emoji { font-size: 2rem; line-height: 1; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.levels-world-titles { min-width: 0; flex: 1 1 auto; }
.levels-world-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 4px 18px 0; }
.levels-world-node {
    position: relative; aspect-ratio: 1; border-radius: 16px; border: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #fff; font: inherit; font-weight: 800; font-size: 1.05rem;
    background: linear-gradient(145deg, var(--waccent), color-mix(in oklab, var(--waccent), black 30%));
    box-shadow: 0 4px 10px rgba(0,0,0,.35);
    animation: levels-fade-in .4s ease both; animation-delay: var(--d, 0ms);
}
.levels-world-node:active { transform: translateY(1px) scale(.97); }
.levels-world-node.completed { background: linear-gradient(145deg, #4ade80, #16a34a); }
.levels-world-node .levels-node-stars { font-size: .6rem; line-height: 1; }
.levels-world-node .levels-node-stars span { opacity: .35; }
.levels-world-node .levels-node-stars span.earned { opacity: 1; color: #fde68a; }

/* ── Tablero de mundo: fondo suave del tema y palabras del tema ── */
body.levels-world-mode { background: linear-gradient(135deg, rgba(var(--wtint), .55) 0%, #1e1b4b 70%) !important; }
body.levels-world-mode .levels-progress-fill { background: linear-gradient(90deg, var(--waccent), color-mix(in oklab, var(--waccent), white 25%)); }
.levels-theme-words { display: flex; flex-wrap: nowrap; gap: 5px; margin: 8px 0 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.ltw-chip { flex-shrink: 0; }
.ltw-chip { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: .04em; }
.ltw-chip.is-found { background: rgba(var(--wtint, 99,102,241), .35); border: 1px solid rgba(var(--wtint, 99,102,241), .6); text-transform: capitalize; }
.ltw-chip.is-missing { background: rgba(255,255,255,.08); border: 1px dashed rgba(255,255,255,.25); opacity: .8; font-family: ui-monospace, monospace; letter-spacing: .12em; }
.levels-finish-btn { width: 100%; margin-top: 10px; background: linear-gradient(145deg, var(--waccent, #6366f1), color-mix(in oklab, var(--waccent, #6366f1), black 25%)); }

/* ── Emoji gigante al encontrar una palabra del tema con emoji ── */
.grid-container { position: relative; }
.levels-emoji-burst {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    pointer-events: none; opacity: 0; z-index: 5;
}
.levels-emoji-burst.is-on { animation: leb-pop 1.4s cubic-bezier(.2, .9, .3, 1) both; }
.leb-emoji { font-size: clamp(96px, 34vw, 160px); line-height: 1; filter: drop-shadow(0 8px 18px rgba(0,0,0,.45)); }
.leb-word { font-weight: 900; font-size: 1.3rem; letter-spacing: .04em; text-transform: capitalize; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); background: rgba(0,0,0,.35); padding: 4px 14px; border-radius: 999px; }
@keyframes leb-pop {
    0% { opacity: 0; transform: scale(.3) rotate(-8deg); }
    18% { opacity: 1; transform: scale(1.12) rotate(3deg); }
    30% { transform: scale(1) rotate(0); }
    75% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(.9) translateY(-24px); }
}
@media (prefers-reduced-motion: reduce) { .levels-emoji-burst.is-on { animation: leb-fade .6s ease both; } @keyframes leb-fade { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } } }
