/* Keeping the existing inline CSS from game.html to avoid functional changes. */

/* Navegación más fluida entre páginas (View Transitions API, nativo del navegador).
   Crossfade suave entre /, /duelos, /niveles, /reto sin tocar el JS. Donde no hay
   soporte, navega normal. Respeta prefers-reduced-motion automáticamente. */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: .2s; }

/* Logo theme switching tied to body theme classes */
.logo-light { display: block !important; }
.logo-dark { display: none !important; }
.logo-halloween { display: none !important; }
.logo-christmas { display: none !important; }
body.theme-dark .logo-dark { display: block !important; }
body.theme-dark .logo-light { display: none !important; }
body.theme-dark .logo-halloween { display: none !important; }
body.theme-dark .logo-christmas { display: none !important; }
body.theme-halloween .logo-halloween { display: block !important; }
body.theme-halloween .logo-light { display: none !important; }
body.theme-halloween .logo-dark { display: none !important; }
body.theme-halloween .logo-christmas { display: none !important; }
body.theme-christmas .logo-christmas { display: block !important; }
body.theme-christmas .logo-light { display: none !important; }
body.theme-christmas .logo-dark { display: none !important; }
body.theme-christmas .logo-halloween { display: none !important; }
/* Logos de temas temáticos (mixto: arte del usuario). Ocultos por defecto; se
   muestran bajo su tema y ocultan el logo base (que "asoma" vía theme-dark). */
.logo-space, .logo-nature, .logo-animals, .logo-reef, .logo-retro, .logo-rain, .logo-sports, .logo-night, .logo-science, .logo-body, .logo-school, .logo-food, .logo-8bit { display: none !important; }
body.theme-space .logo-space,
body.theme-nature .logo-nature,
body.theme-animals .logo-animals,
body.theme-reef .logo-reef,
body.theme-retro .logo-retro,
body.theme-rain .logo-rain,
body.theme-sports .logo-sports,
body.theme-night .logo-night,
body.theme-science .logo-science,
body.theme-body .logo-body,
body.theme-school .logo-school,
body.theme-food .logo-food,
body.theme-8bit .logo-8bit { display: block !important; }
body.theme-space .logo-dark, body.theme-space .logo-light,
body.theme-nature .logo-dark, body.theme-nature .logo-light,
body.theme-animals .logo-dark, body.theme-animals .logo-light,
body.theme-reef .logo-dark, body.theme-reef .logo-light,
body.theme-retro .logo-dark, body.theme-retro .logo-light,
body.theme-rain .logo-dark, body.theme-rain .logo-light,
body.theme-sports .logo-dark, body.theme-sports .logo-light,
body.theme-night .logo-dark, body.theme-night .logo-light,
body.theme-science .logo-dark, body.theme-science .logo-light,
body.theme-body .logo-dark, body.theme-body .logo-light,
body.theme-school .logo-dark, body.theme-school .logo-light,
body.theme-food .logo-dark, body.theme-food .logo-light,
body.theme-8bit .logo-dark, body.theme-8bit .logo-light { display: none !important; }
/* Placeholder: hasta que llegue el arte, el logo va con un brillo del tema. */
body.theme-space .home-logo   { filter: drop-shadow(0 0 10px rgba(167, 139, 250, .7)); }
body.theme-nature .home-logo  { filter: drop-shadow(0 0 10px rgba(74, 222, 128, .7)); }
body.theme-animals .home-logo { filter: drop-shadow(0 0 10px rgba(245, 158, 11, .7)); }
body.theme-reef .home-logo    { filter: drop-shadow(0 0 10px rgba(34, 211, 238, .7)); }
body.theme-retro .home-logo   { filter: drop-shadow(0 0 10px rgba(244, 114, 182, .75)); }
body.theme-rain .home-logo    { filter: drop-shadow(0 0 10px rgba(56, 189, 248, .75)); }
body.theme-sports .home-logo  { filter: drop-shadow(0 0 10px rgba(234, 88, 12, .75)); }
body.theme-night .home-logo   { filter: drop-shadow(0 0 10px rgba(245, 158, 11, .75)); }
body.theme-science .home-logo { filter: drop-shadow(0 0 10px rgba(34, 211, 238, .75)); }
body.theme-body .home-logo    { filter: drop-shadow(0 0 10px rgba(244, 63, 94, .75)); }
body.theme-school .home-logo  { filter: drop-shadow(0 0 10px rgba(250, 204, 21, .75)); }
body.theme-food .home-logo    { filter: drop-shadow(0 0 10px rgba(245, 158, 11, .75)); }
body.theme-8bit .home-logo    { filter: drop-shadow(0 0 8px rgba(0, 255, 102, .75)) drop-shadow(0 0 14px rgba(255, 0, 127, .55)); }
/* Aurora (premium): sin arte de logo propio todavía → logo oscuro con halo esmeralda. */
body.theme-aurora .logo-dark { display: block !important; }
body.theme-aurora .logo-light { display: none !important; }
body.theme-aurora .home-logo { filter: drop-shadow(0 0 10px rgba(52, 211, 153, .75)); }
/* Magia (premium): logo oscuro con halo dorado-violeta. */
body.theme-magic .logo-dark { display: block !important; }
body.theme-magic .logo-light { display: none !important; }
body.theme-magic .home-logo { filter: drop-shadow(0 0 8px rgba(251, 191, 36, .65)) drop-shadow(0 0 14px rgba(168, 85, 247, .55)); }
/* En la HOME la escena se ancla arriba: los dinos caen en el hueco libre entre
   el saludo y las tarjetas (anclada abajo, como en el resto de vistas, quedaban
   justo detrás de ellas). Gana por especificidad al shorthand de #menuModal. */
body.theme-dino #menuModal.modal-overlay {
  background-position: center top, center top, center top;
}
/* Dinosaurios (premium): logo oscuro con halo lima-ámbar. */
body.theme-dino .logo-dark { display: block !important; }
body.theme-dino .logo-light { display: none !important; }
body.theme-dino .home-logo { filter: drop-shadow(0 0 8px rgba(132, 204, 22, .65)) drop-shadow(0 0 14px rgba(245, 158, 11, .5)); }

/* Logos estacionales: un pelín más altos que el base (28-38px) para presencia,
   pero a escala de la topbar compacta (antes clamp(96px,18vw,150px) → gigante en
   desktop). max-width evita que se desborde a lo ancho. */
.logo-halloween,
.logo-christmas {
  height: clamp(32px, 6.5vw, 44px) !important;
  max-width: 46vw;
}
* { margin:0; padding:0; box-sizing:border-box; }
html, body { overscroll-behavior-x: none; }
body { font-family: 'Arial', sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; color: var(--text-color); overflow: hidden; padding: 10px max(calc(env(safe-area-inset-left, 0) + 14px), 14px) calc(env(safe-area-inset-bottom, 0) + 60px) max(calc(env(safe-area-inset-right, 0) + 14px), 14px); touch-action: manipulation; }
/* Edge guards to reduce accidental system back-swipe on mobile */
.edge-guard{ position: fixed; top: 0; bottom: 0; width: max(12px, env(safe-area-inset-left, 0)); z-index: 100; pointer-events: auto; touch-action: none; }
.edge-guard.left{ left: 0; }
.edge-guard.right{ right: 0; width: max(12px, env(safe-area-inset-right, 0)); }
        .game-header { text-align: center; margin-bottom: 8px; width: 100%; }
        .score-board { display:flex; flex-wrap:nowrap; justify-content:space-between; gap:6px; width:100%; max-width:600px; margin:0 auto 8px auto; font-size: clamp(0.8rem, 3vw, 1rem); }
        .score-item { display:flex; align-items:center; gap:6px; background: rgba(255,255,255,0.22); padding: 6px 12px; border-radius: 999px; backdrop-filter: blur(10px); box-shadow: 0 2px 6px rgba(0,0,0,0.18); color:#111827; }
        body.theme-dark .score-item { color:#ffffff; }
        body.theme-halloween .score-item { color:#ffd89b; background: rgba(77, 45, 0, 0.5); border: 1px solid rgba(212, 131, 79, 0.3); }
        body.theme-christmas .score-item { color:#ffffff; background: rgba(30, 90, 61, 0.5); border: 1px solid rgba(122, 90, 110, 0.25); }
        .score-item > span[aria-hidden="true"]{ font-size:1.1em; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
        .sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
        .timer-warning { display:inline-block; animation: pulseGlow 0.9s infinite; color:#fff !important; background: linear-gradient(135deg, #ef4444, #dc2626); padding:2px 10px; border-radius:999px; text-shadow:0 1px 2px rgba(0,0,0,0.5); box-shadow:0 0 0 3px rgba(239,68,68,0.25), 0 6px 14px rgba(0,0,0,0.25); }
        .timer-urgent { animation: flash 0.6s infinite alternate; background: linear-gradient(135deg, #b91c1c, #991b1b) !important; box-shadow: 0 0 0 4px rgba(153,27,27,0.35), 0 10px 18px rgba(0,0,0,0.35) !important; transform: scale(1.06); }
        @keyframes pulseGlow { 0%{ transform: scale(1); box-shadow: 0 0 0 3px rgba(239,68,68,0.25), 0 6px 14px rgba(0,0,0,0.25);} 50%{ transform: scale(1.08); box-shadow: 0 0 0 6px rgba(239,68,68,0.32), 0 10px 20px rgba(0,0,0,0.35);} 100%{ transform: scale(1); box-shadow: 0 0 0 3px rgba(239,68,68,0.25), 0 6px 14px rgba(0,0,0,0.25);} }
        @keyframes flash { 0%{ filter:brightness(1);} 100%{ filter:brightness(1.35);} }
        .game-container { display:flex; flex-direction:column; align-items:center; gap:8px; flex:1; width:100%; max-width:100vw; }
        .grid-container { background: rgba(255,255,255,0.1); padding: 10px; border-radius: 15px; backdrop-filter: blur(10px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); display:flex; justify-content:center; align-items:center; }
        .grid { display:grid; grid-template-columns: repeat(6,1fr); grid-template-rows: repeat(6,1fr); gap:1px; background: rgba(0,0,0,0.2); padding:8px; border-radius:12px; width: min(85vw, 85vh, 400px); height: min(85vw, 85vh, 400px); }
        @media (max-width: 600px) { .grid { width: min(96vw, 96vh); height: min(96vw,96vh);} .grid-container{ padding:6px;} .letter{ font-size: clamp(1.1rem, 6vw, 1.8rem);} .current-word{ width:98vw; max-width:98vw; } }
        @media (max-width: 600px) and (min-height: 740px) { .word-list{ max-height:200px; } .found-word{ font-size: clamp(0.8rem, 3vw, 1rem); } }
        .letter { width:100%; height:100%; background: linear-gradient(145deg,#fff,#e0e0e0); border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:clamp(1rem,4vw,1.4rem); font-weight:bold; color:#333; cursor:pointer; transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.2); user-select:none; touch-action:none; position:relative; }
        .letter::before { content:''; position:absolute; left:50%; top:50%; width:70%; height:70%; transform: translate(-50%,-50%); border-radius:50%; background:transparent; pointer-events:auto; box-sizing:border-box; }
        @media (hover: hover) { .letter:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.3); } }
        .letter.selected { background: linear-gradient(145deg,#4CAF50,#45a049); color:white; transform: scale(1.05); }
        .letter:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; z-index: 1; }
        .submit-word-btn { background: rgba(255,255,255,0.2); color: var(--text-color); border: 1px solid rgba(255,255,255,0.3); border-radius: 20px; padding: 8px 20px; font-weight: bold; cursor: pointer; backdrop-filter: blur(10px); }
        @media (hover: hover) { .submit-word-btn:hover { background: rgba(255,255,255,0.3); } }
        .submit-word-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
        .current-word { background: rgba(255,255,255,0.2); padding: 8px 15px; border-radius: 20px; font-size:clamp(0.9rem,4vw,1.2rem); font-weight:bold; height:50px; text-align:center; backdrop-filter: blur(10px); width:min(95vw, 640px); display:flex; align-items:center; justify-content:center; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:var(--text-color); }
        body.theme-dark .current-word { color:var(--text-color); }
        body.theme-light .current-word { color:#ffffff; }
        body.theme-halloween .current-word { color:#ffd89b; background: rgba(77, 45, 0, 0.4); border: 1px solid rgba(212, 131, 79, 0.3); }
        body.theme-christmas .current-word { color:#ffffff; background: rgba(30, 90, 61, 0.4); border: 1px solid rgba(122, 90, 110, 0.2); }
        .word-list { background: rgba(255,255,255,0.2); padding:8px 15px; border-radius:20px; width:min(95vw, 640px); max-width:640px; max-height:120px; overflow-y:auto; color:var(--text-color); }
        body.theme-dark .word-list { color:var(--text-color); }
        body.theme-light .word-list { color:#ffffff; }
        body.theme-halloween .word-list { color:#ffd89b; background: rgba(77, 45, 0, 0.4); border: 1px solid rgba(212, 131, 79, 0.3); }
        body.theme-christmas .word-list { color:#ffffff; background: rgba(30, 90, 61, 0.4); border: 1px solid rgba(122, 90, 110, 0.2); }
        .word-list h3 { margin-bottom:5px; text-align:center; font-size:clamp(0.8rem,3vw,1rem); color: inherit; }
        .found-words { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
        .found-word { background: rgba(255,255,255,0.2); padding:6px 14px; border-radius:14px; font-size:clamp(0.95rem,3.5vw,1.15rem); font-weight:700; text-decoration:none; box-shadow: 0 2px 6px rgba(0,0,0,0.2); transition: transform 0.2s ease; }
        @media (hover: hover) { .found-word:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.25); } }
        .found-word.score-low { background: rgba(76, 175, 80, 0.85); color: #fff; }
        .found-word.score-med { background: rgba(33, 150, 243, 0.9); color: #fff; }
        .found-word.score-high { background: rgba(255, 152, 0, 0.95); color: #fff; }
        .found-word.score-elite { background: rgba(244, 67, 54, 0.95); color: #fff; }
        .found-word.score-legend { background: linear-gradient(135deg, #7b1fa2, #e91e63); color: #fff; box-shadow: 0 4px 8px rgba(123, 31, 162, 0.5); }
        .modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.7); display:none; align-items:center; justify-content:center; z-index:2000; padding:15px; cursor:pointer; }
        .modal-content { background:#fff; color:#333; border-radius:10px; max-width:760px; width:100%; max-height:80vh; position:relative; box-shadow:0 5px 15px rgba(0,0,0,0.3); cursor:default; display:flex; flex-direction:column; overflow:hidden; }
        .modal-header { position:sticky; top:0; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:16px 20px 10px 20px; background:inherit; z-index:2; border-bottom:1px solid rgba(0,0,0,0.06); border-top-left-radius:10px; border-top-right-radius:10px; }
        .modal-body { padding:12px 20px 16px 20px; overflow-y:auto; }
        /* min 44px de área táctil; el margen negativo evita agrandar la cabecera */
        .modal-close-btn { position:static; background:transparent; border:none; font-size:1.8rem; line-height:1; cursor:pointer; color:#aaa; min-width:44px; min-height:44px; display:flex; align-items:center; justify-content:center; padding:0; margin:-8px -12px -8px 0; border-radius:10px; }
        .modal-close-btn:hover { color:#333; }
        .release-notes-modal { max-width:520px; }
        .release-notes-version { font-weight:700; color:var(--text-muted, #6b7280); }
        .release-notes-intro { margin:0 0 12px 0; font-size:1rem; line-height:1.5; color:var(--text-muted, #6b7280); }
        .release-notes-content { font-size:0.98rem; line-height:1.6; color:var(--text-color); }
        .release-notes-content p { margin:0 0 10px 0; }
        .release-notes-content ul { margin:0 0 12px 20px; padding:0; list-style:disc; }
        .release-notes-content li { margin-bottom:6px; }
        .release-notes-skipped { margin:18px 0 8px; padding-top:14px; border-top:1px solid var(--border-color, rgba(148,163,184,.25)); font-size:.85rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted, #6b7280); }
        .release-notes-older { margin:0 0 6px; border-radius:12px; background:var(--surface-muted, rgba(148,163,184,.10)); }
        .release-notes-older-title { margin:0; padding:10px 12px; font-size:.95rem; font-weight:700; display:flex; align-items:center; gap:10px; cursor:pointer; list-style:none; }
        .release-notes-older-title::-webkit-details-marker { display:none; }
        .release-notes-older-title::after { content:"›"; margin-left:auto; font-size:1.2rem; opacity:.6; transition:transform .2s ease; }
        .release-notes-older[open] .release-notes-older-title::after { transform:rotate(90deg); }
        .release-notes-older-version { flex-shrink:0; font-size:.72rem; font-weight:800; padding:2px 7px; border-radius:6px; background:rgba(148,163,184,.18); color:var(--text-muted, #6b7280); }
        .release-notes-older-body { padding:0 12px 10px; font-size:.92rem; }
        .release-notes-older h3, .release-notes-older h4, .release-notes-older h5 { font-size:.92rem; margin:8px 0 4px; }
        .release-notes-older ul { margin-bottom:6px; }
        .release-notes-footer { margin-top:12px; display:flex; flex-direction:column; gap:12px; }
        .release-notes-tip { font-size:0.95rem; color:var(--text-muted, #6b7280); display:flex; align-items:center; gap:6px; }
.release-notes-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.release-notes-action { flex:0 0 auto; }
.release-notes-action[data-action="releaseNotesEnablePush"] {
    background: #f44336 !important;
    color: #ffffff !important;
    box-shadow: none;
    border: 1px solid #d32f2f !important;
}
.release-notes-action[data-action="releaseNotesEnablePush"]:hover {
    background: #d32f2f !important;
}
.release-notes-loading { color:var(--text-muted, #6b7280); font-style:italic; }

        .ranking-groups { display:grid; gap:14px; }
        .ranking-card { background: linear-gradient(145deg, rgba(255,255,255,0.95), #f4f7ff); border:2px solid #e6edff; border-radius:14px; padding:12px; }
        .ranking-title { display:flex; align-items:center; gap:8px; color:#1e3a8a; margin:0 0 8px 0; font-size:1.1rem; }
        .ranking-list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px; width:100%; }
        .ranking-item { display:flex; align-items:center; justify-content:space-between; background:#ffffff; border:1px solid #edf2ff; border-radius:12px; padding:8px 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
        .rk-left { display:flex; align-items:center; gap:10px; }
        .rk-medal { font-size:1.2rem; width:24px; text-align:center; }
        .rk-name { font-weight:700; color: var(--text-color); }
        .rk-mini-grid { display:grid; grid-template-columns:repeat(6,4px); grid-template-rows:repeat(6,4px); gap:1px; flex:0 0 auto; }
        .rk-mini-cell { width:4px; height:4px; border-radius:1px; background:#e5e7eb; }
        .rk-mini-cell--on { background:#3b82f6; }
        .rk-meta { color:#6b7280; font-size:0.85rem; }
        .rk-right { display:flex; align-items:center; gap:8px; }
        .rk-score { font-weight:800; color:#0f766e; font-size:1.2rem; }
        .rk-chip { background:#eef2ff; color:#3730a3; padding:2px 8px; border-radius:999px; font-size:0.78rem; margin-left:8px; }
        .rk-date { color:#94a3b8; font-size:0.78rem; }
        .ranking-item.me { border:2px solid #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
        /* Rankings: con nombres largos, truncar el nombre para que la columna
           derecha (puntos + "Retar") no se salga ni se corte. Acotado a las
           listas de ranking para no afectar a stats/logros (que llevan palabras
           y chips dentro de .rk-name). */
        #rankingScoreModal .rk-left, #rankingLongestModal .rk-left, #rankingHighestModal .rk-left { min-width:0; flex:1 1 auto; }
        #rankingScoreModal .rk-left > div, #rankingLongestModal .rk-left > div, #rankingHighestModal .rk-left > div { min-width:0; }
        #rankingScoreModal .rk-name, #rankingLongestModal .rk-name, #rankingHighestModal .rk-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
        #rankingScoreModal .rk-right, #rankingLongestModal .rk-right, #rankingHighestModal .rk-right { flex-shrink:0; }
        .tabs { display:flex; gap:6px; margin-bottom:10px; flex-wrap:wrap; }
        .tab-btn { padding:6px 10px; border-radius:999px; border:1px solid #c7d2fe; background:#eef2ff; color:#1e3a8a; cursor:pointer; font-weight:700; }
        .tab-btn.active { background:#3b82f6; color:#fff; border-color:#2563eb; }
        .tab-panel { display:none; }
        .tab-panel.active { display:block; }
        #definitionModal { z-index:3000; }
        #historyModal .found-word { font-size: clamp(0.95rem, 3.4vw, 1.1rem); padding: 4px 10px; }
        #historyModal .rk-chip { font-size: 0.9rem; }
        #historyModal .rk-score { font-size: 1rem; }
        #historyModal .ranking-card table.ranking-list th a { color: inherit; text-decoration: none; }
        #historyModal .ranking-card table.ranking-list th a.sort-active { font-weight: bold; }
        #historyModal .ranking-card table.ranking-list th a .sort-arrow { display: inline-block; margin-left: 4px; }
        #historyModal .ranking-card table.ranking-list th a .sort-arrow.sort-asc::after { content: ' ▲'; }
        #historyModal .ranking-card table.ranking-list th a .sort-arrow.sort-desc::after { content: ' ▼'; }

        /* History table responsive fixes */
        #historyModal table.ranking-list thead tr,
        #historyModal table.ranking-list tbody tr {
          min-width: 0;
        }
        #historyModal table.ranking-list td,
        #historyModal table.ranking-list th { min-width:0; }
        #historyModal table.ranking-list td:first-child,
        #historyModal table.ranking-list th:first-child { }
        #historyModal table.ranking-list td:first-child a { }

        /* Default grid columns for games history table (desktop) */
        #historyModal #historyGamesTable thead tr,
        #historyModal #historyGamesTable tbody tr {
          grid-template-columns: minmax(120px, 1fr) minmax(80px, 100px) minmax(60px, 80px) minmax(100px, 120px);
        }

        /* Default grid columns for words history table (desktop) */
        #historyModal #historyWordsTable thead tr,
        #historyModal #historyWordsTable tbody tr {
          grid-template-columns: minmax(100px, 1fr) minmax(40px, 60px) minmax(60px, 80px) minmax(80px, 100px);
        }

        /* En pantallas estrechas las filas pasan a tarjetas de dos líneas:
           principal + puntos arriba, metadatos + fecha debajo. La cabecera
           se convierte en una barra compacta de ordenación. */
        @media (max-width: 420px){
          #historyModal table.ranking-list thead tr { display:flex !important; justify-content:flex-end; gap:4px; }
          #historyModal table.ranking-list th { padding:4px 8px !important; }

          #historyModal #historyWordsTable tbody tr,
          #historyModal #historyGamesTable tbody tr {
            grid-template-columns: 1fr auto;
            grid-template-areas: "main score" "meta date";
            row-gap: 2px;
          }
          #historyModal #historyWordsTable tbody tr > td,
          #historyModal #historyGamesTable tbody tr > td { padding:2px 8px !important; }

          /* Palabras: palabra + puntos / letras + fecha */
          #historyModal #historyWordsTable tbody tr > td:nth-child(1) { grid-area: main; }
          #historyModal #historyWordsTable tbody tr > td:nth-child(2) { grid-area: meta; text-align:left !important; color:#6b7280; font-size:.82rem; }
          #historyModal #historyWordsTable tbody tr > td:nth-child(2)::after { content: " letras"; }
          #historyModal #historyWordsTable tbody tr > td:nth-child(3) { grid-area: score; text-align:right !important; font-weight:800; }
          #historyModal #historyWordsTable tbody tr > td:nth-child(3)::after { content: " pts"; font-weight:400; font-size:.82rem; color:#6b7280; }
          #historyModal #historyWordsTable tbody tr > td:nth-child(4) { grid-area: date; text-align:right !important; }

          /* Partidas: puntos + botón IA / nº de palabras + fecha */
          #historyModal #historyGamesTable tbody tr > td:nth-child(1) { grid-area: main; font-weight:800; }
          #historyModal #historyGamesTable tbody tr > td:nth-child(1)::after { content: " pts"; font-weight:400; font-size:.82rem; color:#6b7280; }
          #historyModal #historyGamesTable tbody tr > td:nth-child(2) { grid-area: meta; text-align:left !important; color:#6b7280; font-size:.82rem; }
          #historyModal #historyGamesTable tbody tr > td:nth-child(2)::after { content: " palabras"; }
          #historyModal #historyGamesTable tbody tr > td:nth-child(3) { grid-area: score; text-align:right !important; }
          #historyModal #historyGamesTable tbody tr > td:nth-child(4) { grid-area: date; text-align:right !important; }

          #historyModal .found-word { max-width: 100%; display: inline-block; }
        }
#historyModal table.ranking-list th:last-child,
#historyModal table.ranking-list td:last-child {
  word-break: break-all;
}

        /* Restore rounded, pill-shaped buttons style */
        .btn { border:none; color:#fff; font-weight:800; letter-spacing:0.2px; border-radius:999px; padding:10px 14px; box-shadow:0 4px 10px rgba(0,0,0,0.15); cursor:pointer; transition:transform .08s ease, box-shadow .12s ease; }
        .btn:active { transform: translateY(1px); box-shadow:0 2px 6px rgba(0,0,0,0.2); }
        /* Ensure btn has good contrast in light theme when no inline background is set */
        body.theme-light .btn:not([style*="background"]):not(.btn-primary):not(.btn-success):not(.btn-ghost) { background: linear-gradient(145deg,#3b82f6,#1d4ed8); color:#fff; }
        /* Ensure btn has good contrast in dark theme when no inline background is set */
        body.theme-dark .btn:not([style*="background"]):not(.btn-primary):not(.btn-success):not(.btn-ghost) { background: linear-gradient(145deg,#334155,#0f172a); color:#e5e7eb; border:1px solid var(--border-color); }
        /* Dark mode: soften vivid menu button gradients only in the Menu modal */
        body.theme-dark #menuModal .btn { filter: saturate(0.8) brightness(0.9); }
        body.theme-dark #menuModal .btn:hover { filter: saturate(0.85) brightness(1.0); }

        /* Compact icon bar inside menu modal */
        #menuModal .mini-icon-bar{ display:flex; gap:8px; justify-content:flex-end; align-items:center; margin-top:12px; }
        #menuModal .mini-icon{ width:44px; height:44px; border-radius:999px; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:18px; box-shadow:0 4px 10px rgba(0,0,0,0.15); background:linear-gradient(145deg,#eef2ff,#e0e7ff); color:#1f2937; }
        #menuModal .mini-icon:active{ transform: translateY(1px); box-shadow:0 2px 6px rgba(0,0,0,0.2); }
        body.theme-dark #menuModal .mini-icon{ background: linear-gradient(145deg,#0f172a,#111827); color:#e5e7eb; border:1px solid #1f2937; }
        body.theme-christmas #menuModal .mini-icon{ background: linear-gradient(145deg,#3a5a7a,#2a4a6a); color:#e5e7eb; border:1px solid #4a6a8a; }

        /* New bottom icon bar flanking footer */
        #menuModal .bottom-icon-bar{ margin-top:16px; display:flex; align-items:center; justify-content:space-between; gap:10px; }
        #menuModal .bottom-icon-bar .mini-icon-group{ display:flex; gap:8px; align-items:center; }
        #menuModal .bottom-icon-bar .footer-text{ color:#6b7280; font-size:0.9rem; flex:1; text-align:center; }
        body.theme-dark #menuModal .bottom-icon-bar .footer-text{ color:#9ca3af; }
        body.theme-christmas #menuModal .bottom-icon-bar .footer-text{ color:#a0b4c4; }

        /* Success/feedback popup message styles (restored from original game.html) */
        .message { position:fixed; bottom:50px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.8); color:#fff; padding: clamp(18px, 3.5vw, 28px) clamp(28px, 6vw, 52px); border-radius:16px; font-size: clamp(1.4rem, 4.8vw, 2rem); font-weight:bold; z-index:3000; opacity:0; transition: all .3s ease; pointer-events:none; text-align:center; max-width:94vw; }
        .message.show { opacity:1; }
        .achievement-share-btn { pointer-events:auto; margin-left:10px; font-size:0.9rem; font-weight:bold; padding:6px 14px; border-radius:999px; border:none; background:#fff; color:#000; cursor:pointer; vertical-align:middle; }
        .message.tier-low { background: rgba(46, 204, 113, 0.95); }
        .message.tier-med { background: rgba(33, 150, 243, 0.95); }
        .message.tier-high { background: rgba(255, 152, 0, 0.95); }
        .message.tier-elite { background: rgba(244, 67, 54, 0.95); }
        .message.tier-legend { background: linear-gradient(135deg, #7b1fa2, #e91e63); }
        .message.pop { animation: msgPopIn 350ms ease-out; }
        @keyframes msgPopIn { 0% { transform: translateX(-50%) scale(0.7); opacity:0; } 60% { transform: translateX(-50%) scale(1.06); opacity:1; } 100% { transform: translateX(-50%) scale(1); opacity:1; } }
        .message .big-emoji { font-size:2.6rem; display:block; margin-bottom:6px; }

        /* Grid celebration + floating emoji particles */
        .celebrate .grid { animation: glow 800ms ease-out; }
        @keyframes glow { 0% { box-shadow:0 0 0 rgba(255,255,255,0); } 50% { box-shadow:0 0 24px rgba(255,255,255,0.75);} 100% { box-shadow:0 0 0 rgba(255,255,255,0);} }
        .floating-emoji { position:fixed; pointer-events:none; z-index:3001; animation: floatUp 1000ms ease-out forwards; font-size:1.4rem; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3)); }
        @keyframes floatUp { 0% { transform: translateY(0) scale(0.8); opacity:0; } 20% { opacity:1; } 100% { transform: translateY(-60px) scale(1.1); opacity:0; } }
            /* Explode and fall animations for grid updates */
            .letter.explode { animation: explode 220ms ease-out forwards; }
            @keyframes explode { 0%{ transform: scale(1); opacity:1; } 60%{ transform: scale(1.2); opacity:0.7;} 100%{ transform: scale(0.6); opacity:0; } }
            @keyframes fall { 0%{ transform: translateY(-20%); } 100%{ transform: translateY(0); } }
            @keyframes spawn { 0%{ transform: scale(0.6); opacity:0; } 100%{ transform: scale(1); opacity:1; } }

/* Accessibility and theming additions (0–2 semanas): dark theme + reduced motion */
:root {
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --text-color: #ffffff;
  --tile-fg: #333333;
  --tile-bg-from: #ffffff;
  --tile-bg-to: #e0e0e0;
  /* UI surfaces */
  --surface: #ffffff;
  --surface-muted: rgba(255,255,255,0.95);
  --overlay-bg: rgba(0,0,0,0.7);
  --border-color: #e6edff;
  --border-color-soft: #edf2ff;
  --heading: #1e3a8a;
  --text-muted: #6b7280;
  --chip-bg: #eef2ff;
  --chip-fg: #3730a3;
  --success: #10b981;
  --accent: #3b82f6;
}
body.theme-dark {
  --bg-gradient: linear-gradient(135deg, #0b1020 0%, #111827 100%);
  --text-color: #e5e7eb;
  --tile-fg: #e5e7eb;
  --tile-bg-from: #303745;
  --tile-bg-to: #1a2130;
  --surface: #0b1020;
  --surface-muted: #0f172a;
  --overlay-bg: rgba(0,0,0,0.8);
  --border-color: #1c2432;
  --border-color-soft: #131a26;
  --heading: #bfdbfe; /* softer heading in dark */
  --text-muted: #9ca3af;
  --chip-bg: #111827;
  --chip-fg: #c7d2fe;
  --success: #22c55e; /* slightly toned down from neon */
  --accent: #3b82f6; /* less saturated accent */
}
body.theme-halloween {
  --bg-gradient: linear-gradient(135deg, #1a0d00 0%, #2d1b0e 50%, #0f0a0a 100%);
  --text-color: #ffd89b;
  --tile-fg: #f4f1e8;
  --tile-bg-from: #8b5a3c;
  --tile-bg-to: #5d3a22;
  --surface: #2d1b0e;
  --surface-muted: #3d2b1e;
  --overlay-bg: rgba(0,0,0,0.9);
  --border-color: #d4834f;
  --border-color-soft: #a66a3b;
  --heading: #ffcc80;
  --text-muted: #d4a574;
  --chip-bg: #4d2d00;
  --chip-fg: #ffd89b;
  --success: #ff9933;
  --accent: #ff9933;
}

body.theme-christmas {
  --bg-gradient: linear-gradient(135deg, #0d1a2d 0%, #1a3a4d 50%, #0a1f2e 100%);
  --text-color: #ffffff;
  --tile-fg: #f0f8ff;
  --tile-bg-from: #1e5a3d;
  --tile-bg-to: #0f3a22;
  --surface: #1a3a4d;
  --surface-muted: #2a4a5d;
  --overlay-bg: rgba(0,0,0,0.7);
  --border-color: #7a5a6e;
  --border-color-soft: #5a3a4e;
  --heading: #e8d494;
  --text-muted: #a0b4c4;
  --chip-bg: #2a4a5d;
  --chip-fg: #ffffff;
  --success: #5abe90;
  --accent: #d97d6a;
}

/* ── Temas de la tienda (se canjean con gemas) ─────────────────────────── */
body.theme-neon {
  --bg-gradient: linear-gradient(135deg, #05060f 0%, #0d0a1f 55%, #050510 100%);
  --text-color: #eafff2; --tile-fg: #eafff2; --tile-bg-from: #1b2440; --tile-bg-to: #0e1428;
  --surface: #0a0b18; --surface-muted: #12132a; --overlay-bg: rgba(2,2,10,0.88);
  --border-color: #2de2e6; --border-color-soft: #1b8a8c; --heading: #a3e635; --text-muted: #8ea0b5;
  --chip-bg: #14213a; --chip-fg: #2de2e6; --success: #a3e635; --accent: #2de2e6;
}
body.theme-ocean {
  --bg-gradient: linear-gradient(135deg, #041e2e 0%, #0a3a4d 55%, #05202e 100%);
  --text-color: #d6f0ff; --tile-fg: #eaf7ff; --tile-bg-from: #114b63; --tile-bg-to: #0a2f40;
  --surface: #072634; --surface-muted: #0d3446; --overlay-bg: rgba(0,10,20,0.82);
  --border-color: #38bdf8; --border-color-soft: #1f6e8c; --heading: #7dd3fc; --text-muted: #93b4c4;
  --chip-bg: #0d3446; --chip-fg: #7dd3fc; --success: #2dd4bf; --accent: #38bdf8;
}
body.theme-sunset {
  --bg-gradient: linear-gradient(135deg, #2a0f30 0%, #4a1e3a 50%, #5a2418 100%);
  --text-color: #ffe4e6; --tile-fg: #fff1f2; --tile-bg-from: #6d2b4a; --tile-bg-to: #45203a;
  --surface: #2e1230; --surface-muted: #431f3a; --overlay-bg: rgba(20,5,20,0.85);
  --border-color: #fb7185; --border-color-soft: #b04a63; --heading: #fda4af; --text-muted: #d1a0b0;
  --chip-bg: #431f3a; --chip-fg: #fda4af; --success: #fbbf24; --accent: #fb7185;
}
body.theme-forest {
  --bg-gradient: linear-gradient(135deg, #08170f 0%, #123020 55%, #0a1f14 100%);
  --text-color: #e3f7e8; --tile-fg: #f0fff4; --tile-bg-from: #1d4633; --tile-bg-to: #0f2e1f;
  --surface: #0c2016; --surface-muted: #143021; --overlay-bg: rgba(2,12,6,0.85);
  --border-color: #34d399; --border-color-soft: #1f7a55; --heading: #86efac; --text-muted: #9cb8a6;
  --chip-bg: #143021; --chip-fg: #86efac; --success: #a3e635; --accent: #34d399;
}
body.theme-candy {
  --bg-gradient: linear-gradient(135deg, #2a1030 0%, #431a4a 55%, #2a1030 100%);
  --text-color: #ffe4f0; --tile-fg: #fff0f8; --tile-bg-from: #6b2b63; --tile-bg-to: #431a4a;
  --surface: #2e1230; --surface-muted: #431a4a; --overlay-bg: rgba(20,5,20,0.85);
  --border-color: #f472b6; --border-color-soft: #a84a86; --heading: #f9a8d4; --text-muted: #d1a0c0;
  --chip-bg: #431a4a; --chip-fg: #f9a8d4; --success: #c084fc; --accent: #f472b6;
}

/* ── Temas temáticos gratuitos ─────────────────────────────────────────── */
/* Espacio: nebulosa violeta/índigo sobre negro + campo de estrellas (todo dentro
   de --bg-gradient, como el resto de temas; SIN background-attachment:fixed, que
   rompe el render de overlays/modales en WebView móvil). */
body.theme-space {
  --bg-gradient:
    radial-gradient(1.5px 1.5px at 15% 20%, rgba(255,255,255,.95), transparent 60%),
    radial-gradient(1px 1px at 80% 14%, rgba(255,255,255,.75), transparent 60%),
    radial-gradient(1px 1px at 62% 68%, rgba(196,181,253,.85), transparent 60%),
    radial-gradient(2px 2px at 34% 82%, rgba(255,255,255,.85), transparent 60%),
    radial-gradient(1px 1px at 90% 58%, rgba(34,211,238,.8), transparent 60%),
    radial-gradient(1px 1px at 24% 52%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 50% 28%, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(1px 1px at 6% 74%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 72% 40%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 8%, rgba(167,139,250,.8), transparent 60%),
    radial-gradient(120% 90% at 80% -10%, #2a1a5e 0%, transparent 55%),
    radial-gradient(120% 90% at 0% 110%, #14204d 0%, transparent 55%),
    linear-gradient(160deg, #070316 0%, #0c0730 50%, #06021a 100%);
  --text-color: #e9e7ff; --tile-fg: #f2f0ff; --tile-bg-from: #241a4d; --tile-bg-to: #140e30;
  --surface: #0f0a26; --surface-muted: #191140; --overlay-bg: rgba(6,2,20,0.9);
  --border-color: #a78bfa; --border-color-soft: #5b4a9c; --heading: #c4b5fd; --text-muted: #9a92c8;
  --chip-bg: #191140; --chip-fg: #c4b5fd; --success: #22d3ee; --accent: #a78bfa;
}

/* Naturaleza: verdes/tierra con luz cálida y motas de hoja/polen. */
body.theme-nature {
  --bg-gradient:
    radial-gradient(1.5px 1.5px at 18% 24%, rgba(163,230,53,.5), transparent 60%),
    radial-gradient(2px 2px at 76% 30%, rgba(134,239,172,.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 40% 78%, rgba(250,204,21,.4), transparent 60%),
    radial-gradient(1px 1px at 88% 66%, rgba(255,255,255,.3), transparent 60%),
    radial-gradient(120% 80% at 50% -10%, #2f5a2e 0%, transparent 55%),
    linear-gradient(165deg, #0c2216 0%, #123522 55%, #0a1f14 100%);
  --text-color: #e6f7e6; --tile-fg: #f0fff0; --tile-bg-from: #1f4a30; --tile-bg-to: #123020;
  --surface: #0e2417; --surface-muted: #163524; --overlay-bg: rgba(4,16,8,0.9);
  --border-color: #4ade80; --border-color-soft: #2f7a4d; --heading: #bbf7d0; --text-muted: #9cbfa4;
  --chip-bg: #163524; --chip-fg: #bbf7d0; --success: #a3e635; --accent: #4ade80;
}

/* Animales: savana cálida (ámbar/tierra) con motas de sol. */
body.theme-animals {
  --bg-gradient:
    radial-gradient(2px 2px at 22% 30%, rgba(253,224,71,.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 70% 24%, rgba(251,191,36,.4), transparent 60%),
    radial-gradient(120% 80% at 80% -10%, #5a3a1a 0%, transparent 55%),
    radial-gradient(120% 80% at 0% 110%, #3a2410 0%, transparent 55%),
    linear-gradient(165deg, #241505 0%, #3a2410 55%, #1c1206 100%);
  --text-color: #fdeede; --tile-fg: #fff6ea; --tile-bg-from: #4d3418; --tile-bg-to: #33220e;
  --surface: #241505; --surface-muted: #382512; --overlay-bg: rgba(16,9,2,0.9);
  --border-color: #f59e0b; --border-color-soft: #a86a1a; --heading: #fcd9a8; --text-muted: #c4a986;
  --chip-bg: #382512; --chip-fg: #fcd9a8; --success: #a3e635; --accent: #f59e0b;
}

/* Arrecife: aguas turquesa/profundas con burbujas y rayos de luz. */
body.theme-reef {
  --bg-gradient:
    radial-gradient(2px 2px at 25% 80%, rgba(125,211,252,.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 60% 70%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(2.5px 2.5px at 80% 86%, rgba(45,212,191,.45), transparent 60%),
    radial-gradient(1px 1px at 40% 58%, rgba(255,255,255,.3), transparent 60%),
    radial-gradient(120% 90% at 50% -20%, #0a4a63 0%, transparent 55%),
    linear-gradient(180deg, #073649 0%, #04202e 60%, #021620 100%);
  --text-color: #dcf5ff; --tile-fg: #eafaff; --tile-bg-from: #0e4b5f; --tile-bg-to: #082f3e;
  --surface: #072634; --surface-muted: #0d3849; --overlay-bg: rgba(0,10,18,0.9);
  --border-color: #22d3ee; --border-color-soft: #1a7f96; --heading: #7dd3fc; --text-muted: #8fb4c2;
  --chip-bg: #0d3849; --chip-fg: #7dd3fc; --success: #2dd4bf; --accent: #22d3ee;
}

/* AMOLED: Negro puro #000000 para ahorro de batería en pantallas OLED y máximo contraste. */
body.theme-amoled {
  --bg-gradient: #000000;
  --text-color: #ffffff; --tile-fg: #ffffff; --tile-bg-from: #18181b; --tile-bg-to: #09090b;
  --surface: #121212; --surface-muted: #1e1e1e; --overlay-bg: rgba(0,0,0,0.96);
  --border-color: #3b82f6; --border-color-soft: #1d4ed8; --heading: #60a5fa; --text-muted: #a1a1aa;
  --chip-bg: #1e1e1e; --chip-fg: #60a5fa; --success: #22c55e; --accent: #3b82f6;
}

#themeAmoledBtn {
  border: 1px solid #3b82f6 !important;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.55);
  background: linear-gradient(135deg, #09090b, #1f2937);
  font-weight: 700;
}

/* Retro: synthwave: rejilla de neón sobre morado, magenta/cian. */
body.theme-retro {
  --bg-gradient:
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(244,114,182,.10) 38px 39px),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(34,211,238,.08) 38px 39px),
    radial-gradient(120% 80% at 50% 120%, #ff2d95 0%, transparent 45%),
    linear-gradient(180deg, #1a0a2e 0%, #2a0f45 55%, #14082a 100%);
  --text-color: #ffe3fb; --tile-fg: #fff0fc; --tile-bg-from: #3d1a54; --tile-bg-to: #26103a;
  --surface: #1c0d30; --surface-muted: #2c1348; --overlay-bg: rgba(10,4,20,0.9);
  --border-color: #f472b6; --border-color-soft: #a8478a; --heading: #f9a8d4; --text-muted: #c79bc4;
  --chip-bg: #2c1348; --chip-fg: #67e8f9; --success: #22d3ee; --accent: #f472b6;
}

/* Lluvia: gotas de agua procedurales y escena lluviosa de fondo. */
body.theme-rain {
  --bg-gradient:
    linear-gradient(180deg, rgba(3, 18, 28, .50) 0%, rgba(3, 18, 28, .20) 30%, rgba(3, 18, 28, .55) 65%, rgba(3, 18, 28, .85) 100%),
    url('/img/rain/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #071e2c 0%, #092d42 55%, #03141f 100%);
  --text-color: #e0f2fe; --tile-fg: #f0f9ff; --tile-bg-from: #0c4a6e; --tile-bg-to: #073654;
  --surface: #072538; --surface-muted: #0c3650; --overlay-bg: rgba(3,18,28,0.92);
  --border-color: #38bdf8; --border-color-soft: #0284c7; --heading: #7dd3fc; --text-muted: #94a3b8;
  --chip-bg: #0c3650; --chip-fg: #7dd3fc; --success: #38bdf8; --accent: #0284c7;
}

/* Deportes: verde césped deportivo y escena de estadio de noche. */
body.theme-sports {
  --bg-gradient:
    linear-gradient(180deg, rgba(5, 23, 13, .50) 0%, rgba(5, 23, 13, .20) 30%, rgba(5, 23, 13, .55) 65%, rgba(5, 23, 13, .85) 100%),
    url('/img/sports/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #092415 0%, #0f381e 60%, #05170d 100%);
  --text-color: #f0fdf4; --tile-fg: #ffffff; --tile-bg-from: #166534; --tile-bg-to: #0e4423;
  --surface: #0d2d18; --surface-muted: #154526; --overlay-bg: rgba(4,18,10,0.92);
  --border-color: #ea580c; --border-color-soft: #9a3412; --heading: #fdba74; --text-muted: #86efac;
  --chip-bg: #154526; --chip-fg: #fdba74; --success: #22c55e; --accent: #ea580c;
}

/* Noche: escena de noche estrellada con luna brillante. */
body.theme-night {
  --bg-gradient:
    linear-gradient(180deg, rgba(2, 5, 14, .45) 0%, rgba(2, 5, 14, .15) 30%, rgba(2, 5, 14, .50) 65%, rgba(2, 5, 14, .85) 100%),
    url('/img/night/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #050a16 0%, #091224 55%, #02050c 100%);
  --text-color: #e0e7ff; --tile-fg: #ffffff; --tile-bg-from: #1e293b; --tile-bg-to: #0f172a;
  --surface: #0d1527; --surface-muted: #142038; --overlay-bg: rgba(2,5,14,0.94);
  --border-color: #f59e0b; --border-color-soft: #b45309; --heading: #fde047; --text-muted: #94a3b8;
  --chip-bg: #142038; --chip-fg: #fde047; --success: #38bdf8; --accent: #f59e0b;
}

/* Ciencia: laboratorio de ciencia con órbita atómica y luz de neón. */
body.theme-science {
  --bg-gradient:
    linear-gradient(180deg, rgba(12, 4, 25, .50) 0%, rgba(12, 4, 25, .20) 30%, rgba(12, 4, 25, .55) 65%, rgba(12, 4, 25, .85) 100%),
    url('/img/science/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #16092b 0%, #1e0d3b 55%, #0c0419 100%);
  --text-color: #f3e8ff; --tile-fg: #ffffff; --tile-bg-from: #4c1d95; --tile-bg-to: #321367;
  --surface: #190a33; --surface-muted: #27124d; --overlay-bg: rgba(10,3,22,0.92);
  --border-color: #22d3ee; --border-color-soft: #0891b2; --heading: #c084fc; --text-muted: #a78bfa;
  --chip-bg: #27124d; --chip-fg: #22d3ee; --success: #a855f7; --accent: #22d3ee;
}

/* Cuerpo humano: gráficos médicos de salud con pulsos de pulso carmesí. */
body.theme-body {
  --bg-gradient:
    linear-gradient(180deg, rgba(24, 5, 11, .50) 0%, rgba(24, 5, 11, .20) 30%, rgba(24, 5, 11, .55) 65%, rgba(24, 5, 11, .85) 100%),
    url('/img/body/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #290a14 0%, #3b0f1d 55%, #18050b 100%);
  --text-color: #ffe4e6; --tile-fg: #ffffff; --tile-bg-from: #881337; --tile-bg-to: #5c0d25;
  --surface: #300c18; --surface-muted: #4a1325; --overlay-bg: rgba(20,4,10,0.92);
  --border-color: #f43f5e; --border-color-soft: #be123c; --heading: #fecdd3; --text-muted: #fda4af;
  --chip-bg: #4a1325; --chip-fg: #fecdd3; --success: #22c55e; --accent: #f43f5e;
}

/* Colegio: aula escolar con pizarra de tiza. */
body.theme-school {
  --bg-gradient:
    linear-gradient(180deg, rgba(5, 16, 9, .50) 0%, rgba(5, 16, 9, .20) 30%, rgba(5, 16, 9, .55) 65%, rgba(5, 16, 9, .85) 100%),
    url('/img/school/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #0a1d12 0%, #0e2919 55%, #051009 100%);
  --text-color: #fef9c3; --tile-fg: #ffffff; --tile-bg-from: #14532d; --tile-bg-to: #0b331b;
  --surface: #0c2316; --surface-muted: #133621; --overlay-bg: rgba(5,14,9,0.92);
  --border-color: #facc15; --border-color-soft: #ca8a04; --heading: #fef08a; --text-muted: #86efac;
  --chip-bg: #133621; --chip-fg: #fef08a; --success: #22c55e; --accent: #facc15;
}

/* Comida: cocina gourmet cálida con horno y platos deliciosos. */
body.theme-food {
  --bg-gradient:
    linear-gradient(180deg, rgba(25, 6, 4, .50) 0%, rgba(25, 6, 4, .20) 30%, rgba(25, 6, 4, .55) 65%, rgba(25, 6, 4, .85) 100%),
    url('/img/food/scene.webp') center center / cover no-repeat,
    linear-gradient(180deg, #290b07 0%, #3d110b 55%, #190604 100%);
  --text-color: #ffedd5; --tile-fg: #ffffff; --tile-bg-from: #7f1d1d; --tile-bg-to: #541313;
  --surface: #330f0a; --surface-muted: #4d170f; --overlay-bg: rgba(20,5,3,0.92);
  --border-color: #f59e0b; --border-color-soft: #b45309; --heading: #fed7aa; --text-muted: #fdba74;
  --chip-bg: #4d170f; --chip-fg: #fed7aa; --success: #22c55e; --accent: #f59e0b;
}

/* --- Animaciones procedurales de los temas --- */
/* Lluvia */
body.theme-rain::before,
body.theme-rain #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; left: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(56, 189, 248, .35), rgba(14, 165, 233, .15) 45%, transparent 70%);
  will-change: transform; animation: aurora-orb-a 38s ease-in-out infinite alternate;
}
body.theme-rain::after,
body.theme-rain #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -70vmax; right: -40vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(2, 132, 199, .30), rgba(125, 211, 252, .12) 50%, transparent 72%);
  will-change: transform; animation: aurora-orb-b 48s ease-in-out infinite alternate;
}

/* Deportes */
body.theme-sports::before,
body.theme-sports #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 130vmax; height: 130vmax; top: -75vmax; right: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(234, 88, 12, .32), rgba(251, 146, 60, .14) 48%, transparent 72%);
  will-change: transform; animation: aurora-orb-b 42s ease-in-out infinite alternate;
}
body.theme-sports::after,
body.theme-sports #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 130vmax; height: 130vmax; bottom: -75vmax; left: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 197, 94, .28), rgba(22, 163, 74, .12) 50%, transparent 70%);
  will-change: transform; animation: aurora-orb-a 52s ease-in-out infinite alternate;
}

/* Noche */
body.theme-night::before,
body.theme-night #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -85vmax; left: -55vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(253, 224, 71, .28), rgba(245, 158, 11, .12) 45%, transparent 70%);
  will-change: transform; animation: aurora-orb-a 45s ease-in-out infinite alternate;
}
body.theme-night::after,
body.theme-night #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -65vmax; right: -45vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(99, 102, 241, .32), rgba(168, 85, 247, .15) 50%, transparent 72%);
  will-change: transform; animation: aurora-orb-b 55s ease-in-out infinite alternate;
}

/* Ciencia */
body.theme-science::before,
body.theme-science #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 135vmax; height: 135vmax; top: -75vmax; left: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 211, 238, .36), rgba(167, 139, 250, .18) 46%, transparent 72%);
  will-change: transform; animation: aurora-orb-a 34s ease-in-out infinite alternate;
}
body.theme-science::after,
body.theme-science #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 125vmax; height: 125vmax; bottom: -70vmax; right: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(192, 132, 252, .32), rgba(168, 85, 247, .14) 48%, transparent 70%);
  will-change: transform; animation: aurora-orb-b 46s ease-in-out infinite alternate;
}

/* Cuerpo humano */
body.theme-body::before,
body.theme-body #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; right: -55vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(244, 63, 94, .38), rgba(225, 29, 72, .16) 46%, transparent 72%);
  will-change: transform; animation: heartbeat-bg-pulse 4s ease-in-out infinite;
}
body.theme-body::after,
body.theme-body #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -65vmax; left: -45vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(251, 113, 133, .28), rgba(190, 18, 60, .12) 50%, transparent 70%);
  will-change: transform; animation: aurora-orb-b 50s ease-in-out infinite alternate;
}
@keyframes heartbeat-bg-pulse {
  0%, 100% { transform: scale(1); opacity: .8; }
  14%      { transform: scale(1.06); opacity: 1; }
  28%      { transform: scale(1.02); opacity: .9; }
  42%      { transform: scale(1.08); opacity: 1; }
  70%      { transform: scale(1); opacity: .8; }
}

/* Colegio */
body.theme-school::before,
body.theme-school #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 135vmax; height: 135vmax; top: -80vmax; left: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(250, 204, 21, .28), rgba(234, 179, 8, .12) 48%, transparent 72%);
  will-change: transform; animation: aurora-orb-a 44s ease-in-out infinite alternate;
}
body.theme-school::after,
body.theme-school #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 125vmax; height: 125vmax; bottom: -70vmax; right: -45vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 197, 94, .32), rgba(22, 163, 74, .14) 46%, transparent 70%);
  will-change: transform; animation: aurora-orb-b 56s ease-in-out infinite alternate;
}

/* Comida */
body.theme-food::before,
body.theme-food #menuModal.modal-overlay::before {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; right: -50vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(245, 158, 11, .35), rgba(217, 119, 6, .15) 46%, transparent 72%);
  will-change: transform; animation: aurora-orb-a 40s ease-in-out infinite alternate;
}
body.theme-food::after,
body.theme-food #menuModal.modal-overlay::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -65vmax; left: -45vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(239, 68, 68, .30), rgba(185, 28, 28, .12) 48%, transparent 70%);
  will-change: transform; animation: aurora-orb-b 52s ease-in-out infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
  body.theme-rain::before, body.theme-rain::after, body.theme-rain #menuModal.modal-overlay::before, body.theme-rain #menuModal.modal-overlay::after,
  body.theme-sports::before, body.theme-sports::after, body.theme-sports #menuModal.modal-overlay::before, body.theme-sports #menuModal.modal-overlay::after,
  body.theme-night::before, body.theme-night::after, body.theme-night #menuModal.modal-overlay::before, body.theme-night #menuModal.modal-overlay::after,
  body.theme-science::before, body.theme-science::after, body.theme-science #menuModal.modal-overlay::before, body.theme-science #menuModal.modal-overlay::after,
  body.theme-body::before, body.theme-body::after, body.theme-body #menuModal.modal-overlay::before, body.theme-body #menuModal.modal-overlay::after,
  body.theme-school::before, body.theme-school::after, body.theme-school #menuModal.modal-overlay::before, body.theme-school #menuModal.modal-overlay::after,
  body.theme-food::before, body.theme-food::after, body.theme-food #menuModal.modal-overlay::before, body.theme-food #menuModal.modal-overlay::after {
    animation: none;
  }
}

/* ── Temas premium (nivel superior: fondo procedural ANIMADO) ──────────── */
/* Aurora boreal: noche polar con estrellas (estáticas, en --bg-gradient) y
   cortinas de aurora animadas en body::before. El fondo del body se propaga al
   canvas (html no tiene background), así que un hijo posicionado con z-index:-1
   pinta por encima de él y por debajo de todo el contenido. La animación es solo
   transform+opacity (compositor; el blur se rasteriza una vez en su capa GPU). */
body.theme-aurora {
  --bg-gradient:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(1px 1px at 78% 12%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 58% 34%, rgba(190,242,230,.8), transparent 60%),
    radial-gradient(2px 2px at 30% 44%, rgba(255,255,255,.75), transparent 60%),
    radial-gradient(1px 1px at 90% 40%, rgba(153,246,228,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 10%, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(1px 1px at 8% 62%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 68% 58%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(120% 70% at 50% 115%, #0d2b3f 0%, transparent 60%),
    linear-gradient(175deg, #020a14 0%, #04121f 55%, #041a26 100%);
  --text-color: #e4f6f0; --tile-fg: #eefaf5; --tile-bg-from: #0f3a40; --tile-bg-to: #082430;
  --surface: #06202c; --surface-muted: #0b3140; --overlay-bg: rgba(1,8,14,0.9);
  --border-color: #34d399; --border-color-soft: #1c6e5c; --heading: #99f6e4; --text-muted: #8fbcb2;
  --chip-bg: #0b3140; --chip-fg: #99f6e4; --success: #a3e635; --accent: #34d399;
}
/* Dos capas gemelas: body::before cubre las vistas que van directas sobre el body
   (partida, duelos, reto…); la del menú hace falta porque #menuModal (la home)
   pinta su propio --bg-gradient OPACO encima del body — al ser un stacking
   context (z-index:2000), su ::before con z-index:-1 queda entre su fondo y su
   contenido, que es justo donde queremos la aurora. */
/* Dos ORBES de luz independientes (estilo mesh-gradient de las webs de IA): cada
   uno es un círculo con degradado radial muy suave que deriva en su propia órbita
   lenta, a ritmos distintos — al cruzarse, los colores se funden y "fluyen".
   Solo transform (compositor puro): ni filter:blur (la GPU de móvil/WebView
   descarta capas fijas gigantes con blur) ni bordes que puedan asomar (son
   círculos con caída a transparente mucho antes de su borde). */
body.theme-aurora::before,
body.theme-aurora #menuModal.modal-overlay::before {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; left: -60vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(52, 211, 153, .42), rgba(34, 211, 238, .20) 46%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-a 36s ease-in-out infinite alternate;
}
body.theme-aurora::after,
body.theme-aurora #menuModal.modal-overlay::after {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; top: -68vmax; right: -55vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(167, 139, 250, .36), rgba(236, 72, 153, .15) 48%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-b 52s ease-in-out infinite alternate;
}
@keyframes aurora-orb-a {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  33%  { transform: translate3d(10vmax, 6vmax, 0) scale(1.12); }
  66%  { transform: translate3d(4vmax, 12vmax, 0) scale(.95); }
  100% { transform: translate3d(14vmax, 3vmax, 0) scale(1.08); }
}
@keyframes aurora-orb-b {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  40%  { transform: translate3d(-12vmax, 9vmax, 0) scale(1.15); }
  70%  { transform: translate3d(-5vmax, 15vmax, 0) scale(.92); }
  100% { transform: translate3d(-16vmax, 5vmax, 0) scale(1.05); }
}

/* Toque premium del tema: aro de luz multicolor girando tras el CTA principal.
   El fondo opaco del botón tapa el centro del conic-gradient, así que solo se ve
   el halo asomando por los bordes. El giro anima --hg-angle vía @property
   (Chromium/WebView y Firefox modernos); sin soporte queda un halo estático. */
@property --hg-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
body.theme-aurora .home-hero { position: relative; z-index: 0; }
body.theme-aurora .home-hero::before {
  content: '';
  position: absolute; inset: -4px; z-index: -2;
  border-radius: 24px;
  background: conic-gradient(from var(--hg-angle), #34d399, #22d3ee, #a78bfa, #ec4899, #34d399);
  filter: blur(10px); /* elemento pequeño: este blur sí es seguro en móvil */
  opacity: .85;
  animation: hero-glow-spin 6s linear infinite;
}
/* Tapa el centro del conic (los hijos con z-index negativo pintan ENCIMA del
   background del botón): replica el verde del CTA y deja solo el halo del borde. */
body.theme-aurora .home-hero::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: 20px;
  background: linear-gradient(145deg, #22c55e, #15803d);
}
@keyframes hero-glow-spin { to { --hg-angle: 360deg; } }

@media (prefers-reduced-motion: reduce) {
  body.theme-aurora::before, body.theme-aurora::after,
  body.theme-aurora #menuModal.modal-overlay::before,
  body.theme-aurora #menuModal.modal-overlay::after,
  body.theme-aurora .home-hero::before { animation: none; }
}

/* Magia: noche de hechicero — púrpura profundo con destellos dorados y lilas
   (estáticos, en --bg-gradient); la "magia" en movimiento la ponen los orbes
   de abajo, mismo patrón compositor-puro que aurora. */
body.theme-magic {
  --bg-gradient:
    radial-gradient(1.5px 1.5px at 14% 16%, rgba(251, 191, 36, .9), transparent 60%),
    radial-gradient(1px 1px at 76% 12%, rgba(255, 255, 255, .7), transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 30%, rgba(233, 213, 255, .85), transparent 60%),
    radial-gradient(2px 2px at 30% 46%, rgba(251, 191, 36, .7), transparent 60%),
    radial-gradient(1px 1px at 88% 42%, rgba(216, 180, 254, .75), transparent 60%),
    radial-gradient(1.5px 1.5px at 44% 8%, rgba(255, 255, 255, .8), transparent 60%),
    radial-gradient(1px 1px at 8% 64%, rgba(251, 191, 36, .55), transparent 60%),
    radial-gradient(1px 1px at 66% 58%, rgba(255, 255, 255, .45), transparent 60%),
    radial-gradient(120% 80% at 78% -10%, #3b1470 0%, transparent 55%),
    linear-gradient(165deg, #16062e 0%, #2b0f52 55%, #120426 100%);
  --text-color: #f3e8ff; --tile-fg: #faf5ff; --tile-bg-from: #3b1d63; --tile-bg-to: #241040;
  --surface: #1d0b38; --surface-muted: #2e1554; --overlay-bg: rgba(10, 2, 24, 0.9);
  --border-color: #a855f7; --border-color-soft: #6b3fa0; --heading: #e9d5ff; --text-muted: #b79fd8;
  --chip-bg: #2e1554; --chip-fg: #e9d5ff; --success: #fbbf24; --accent: #c084fc;
}
/* Orbes: uno violeta (hechizo) y uno DORADO (polvo de hadas), órbitas lentas a
   ritmos distintos — al cruzarse los colores fluyen. Solo transform. */
body.theme-magic::before,
body.theme-magic #menuModal.modal-overlay::before {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; left: -60vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(168, 85, 247, .40), rgba(192, 132, 252, .18) 46%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-a 40s ease-in-out infinite alternate;
}
body.theme-magic::after,
body.theme-magic #menuModal.modal-overlay::after {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; top: -68vmax; right: -55vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(251, 191, 36, .26), rgba(236, 72, 153, .12) 48%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-b 56s ease-in-out infinite alternate;
}
/* Aro de luz mágico (violeta→dorado) girando tras el CTA, como en aurora. */
body.theme-magic .home-hero { position: relative; z-index: 0; }
body.theme-magic .home-hero::before {
  content: '';
  position: absolute; inset: -4px; z-index: -2;
  border-radius: 24px;
  background: conic-gradient(from var(--hg-angle), #a855f7, #fbbf24, #ec4899, #7c3aed, #a855f7);
  filter: blur(10px);
  opacity: .85;
  animation: hero-glow-spin 6s linear infinite;
}
body.theme-magic .home-hero::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: 20px;
  background: linear-gradient(145deg, #22c55e, #15803d);
}
@media (prefers-reduced-motion: reduce) {
  body.theme-magic::before, body.theme-magic::after,
  body.theme-magic #menuModal.modal-overlay::before,
  body.theme-magic #menuModal.modal-overlay::after,
  body.theme-magic .home-hero::before { animation: none; }
}

/* Dinosaurios: selva jurásica al anochecer — verdes pantanosos con resplandor
   volcánico en el horizonte y luciérnagas/pavesas fijas en --bg-gradient; el
   movimiento lo ponen los orbes (jungla + volcán) y las brasas de themeDecor. */
body.theme-dino {
  /* Escena jurásica (ilustración propia, 51 KB en WebP) como primera capa del
     stack: al ir dentro de --bg-gradient llega sola a body Y a #menuModal (la
     home). El velo oscuro que va justo encima mantiene legible el texto blanco
     sobre la parte más clara del cielo. */
  /* La escena va a TODO EL ANCHO sin recortar (100% auto), no en cover: así los
     dinos caen en hueco libre en vez de quedar detrás de las tarjetas. Anclada
     ABAJO por defecto (partida, duelos, reto: el contenido vive arriba y la
     selva llena el vacío inferior); la home la reposiciona arriba más abajo. */
  --bg-gradient:
    linear-gradient(180deg, rgba(6, 14, 8, .50) 0%, rgba(6, 14, 8, .18) 26%, rgba(6, 14, 8, .38) 52%, rgba(6, 14, 8, .70) 100%),
    url('/img/dino/scene.webp') center bottom / 100% auto no-repeat,
    linear-gradient(170deg, #0c1a0f 0%, #16260f 40%, #0a1408 100%);
  --text-color: #eef7e9; --tile-fg: #f4fbef; --tile-bg-from: #2f4526; --tile-bg-to: #1c2b16;
  --surface: #14200f; --surface-muted: #1f3018; --overlay-bg: rgba(6, 14, 5, 0.9);
  --border-color: #84cc16; --border-color-soft: #4d7c0f; --heading: #d9f99d; --text-muted: #a9c294;
  --chip-bg: #1f3018; --chip-fg: #d9f99d; --success: #f59e0b; --accent: #84cc16;
}
/* Orbes: verde jungla y ámbar volcánico (este sube desde ABAJO, donde arde el
   horizonte), mismas órbitas compositor-puro que aurora/magia. */
body.theme-dino::before,
body.theme-dino #menuModal.modal-overlay::before {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -80vmax; left: -60vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(132, 204, 22, .30), rgba(74, 222, 128, .14) 46%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-a 44s ease-in-out infinite alternate;
}
body.theme-dino::after,
body.theme-dino #menuModal.modal-overlay::after {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -78vmax; right: -50vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(245, 158, 11, .30), rgba(239, 68, 68, .14) 48%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-b 58s ease-in-out infinite alternate;
}
/* Aro de luz jurásico (lima→ámbar→rojo volcánico) girando tras el CTA. */
body.theme-dino .home-hero { position: relative; z-index: 0; }
body.theme-dino .home-hero::before {
  content: '';
  position: absolute; inset: -4px; z-index: -2;
  border-radius: 24px;
  background: conic-gradient(from var(--hg-angle), #84cc16, #f59e0b, #ef4444, #16a34a, #84cc16);
  filter: blur(10px);
  opacity: .85;
  animation: hero-glow-spin 6s linear infinite;
}
body.theme-dino .home-hero::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: 20px;
  background: linear-gradient(145deg, #22c55e, #15803d);
}
@media (prefers-reduced-motion: reduce) {
  body.theme-dino::before, body.theme-dino::after,
  body.theme-dino #menuModal.modal-overlay::before,
  body.theme-dino #menuModal.modal-overlay::after,
  body.theme-dino .home-hero::before { animation: none; }
}

/* ==========================================
   TEMA 8-BIT RETRO (ARCADE PIXEL ART)
   ========================================== */
body.theme-8bit {
  --bg-gradient:
    linear-gradient(rgba(18, 16, 38, 0) 50%, rgba(0, 0, 0, 0.4) 50%),
    linear-gradient(90deg, rgba(255, 0, 127, 0.04), rgba(0, 255, 102, 0.04), rgba(0, 240, 255, 0.04)),
    linear-gradient(170deg, #090911 0%, #120b24 50%, #060919 100%);
  --text-color: #00ff66;
  --tile-fg: #ffffff;
  --tile-bg-from: #1f0b38;
  --tile-bg-to: #0c051a;
  --surface: #0e071c;
  --surface-muted: #180d2e;
  --overlay-bg: rgba(7, 4, 15, 0.94);
  --border-color: #00ff66;
  --border-color-soft: #00f0ff;
  --heading: #ffe600;
  --text-muted: #00f0ff;
  --chip-bg: #180d2e;
  --chip-fg: #00ff66;
  --success: #00ff66;
  --accent: #ff007f;
}

body.theme-8bit::before,
body.theme-8bit #menuModal.modal-overlay::before {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 140vmax; height: 140vmax; top: -70vmax; left: -50vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 255, 102, .25), rgba(0, 240, 255, .12) 46%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-a 38s ease-in-out infinite alternate;
}

body.theme-8bit::after,
body.theme-8bit #menuModal.modal-overlay::after {
  content: '';
  position: fixed; z-index: -1; pointer-events: none;
  width: 120vmax; height: 120vmax; bottom: -70vmax; right: -40vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 0, 127, .25), rgba(255, 230, 0, .12) 48%, transparent 72%);
  will-change: transform;
  animation: aurora-orb-b 50s ease-in-out infinite alternate;
}

body.theme-8bit .home-hero { position: relative; z-index: 0; }
body.theme-8bit .home-hero::before {
  content: '';
  position: absolute; inset: -4px; z-index: -2;
  border-radius: 24px;
  background: conic-gradient(from var(--hg-angle), #00ff66, #00f0ff, #ff007f, #ffe600, #00ff66);
  filter: blur(8px);
  opacity: .9;
  animation: hero-glow-spin 5s linear infinite;
}
body.theme-8bit .home-hero::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: 20px;
  background: linear-gradient(145deg, #ff007f, #b30059);
}

body.theme-8bit .home-tile,
body.theme-8bit .ranking-item,
body.theme-8bit .modal-content {
  border: 2px solid #00ff66 !important;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.3), inset 0 0 12px rgba(0, 240, 255, 0.15) !important;
}

body.theme-8bit .ticon-svg {
  filter: drop-shadow(0 0 4px rgba(0, 255, 102, 0.8));
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  body.theme-8bit::before, body.theme-8bit::after,
  body.theme-8bit #menuModal.modal-overlay::before,
  body.theme-8bit #menuModal.modal-overlay::after,
  body.theme-8bit .home-hero::before { animation: none; }
}

/* Apply variables */
body { background: var(--bg-gradient); color: var(--text-color); }
body.theme-light { --text-color: #111827; }
.letter { color: var(--tile-fg); background: linear-gradient(145deg, var(--tile-bg-from), var(--tile-bg-to)); }
.letter.selected { color: #fff; }

/* Menu/header and scoreboard surfaces */
.score-item {
  background: color-mix(in oklab, var(--surface-muted), transparent 20%);
  border: 1px solid var(--border-color, rgba(148,163,184,.3));
}
.score-item .ic { width: 16px; height: 16px; flex-shrink: 0; }

/* Modals and overlays */
.modal-overlay { background: var(--overlay-bg); }
.modal-content { background: var(--surface); color: var(--text-color); }
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-title { color: var(--heading); }
.modal-close-btn { color: var(--text-muted); }
.modal-close-btn:hover { color: var(--text-color); }

/* Ranking cards and lists */
.ranking-card { background: linear-gradient(145deg, var(--surface-muted), var(--surface)); border: 2px solid var(--border-color); }
.ranking-title { color: var(--heading); }
.ranking-item { background: var(--surface); border: 1px solid var(--border-color-soft); }
.rk-name { color: var(--text-color); }
.rk-meta, .rk-date { color: var(--text-muted); }
.rk-score { color: var(--success); }
.rk-chip { background: var(--chip-bg); color: var(--chip-fg); }
/* Force override inline light backgrounds inside modals when dark theme is active */
body.theme-dark .ranking-card { background: linear-gradient(145deg, var(--surface-muted), var(--surface)) !important; border-color: var(--border-color) !important; }
body.theme-dark .ranking-item { background: var(--surface) !important; border-color: var(--border-color-soft) !important; }
body.theme-dark .ranking-card, body.theme-dark .ranking-card * { color: var(--text-color) !important; }
/* Dark theme override for notification prompt banner created inline via JS */
body.theme-dark #notifPromptBanner { background: linear-gradient(145deg, var(--surface-muted), var(--surface)) !important; border-color: var(--border-color) !important; color: var(--text-color) !important; }

/* Forms and preview boxes inside modals */
.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content textarea {
  background: var(--surface);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}
.modal-content input::placeholder,
.modal-content textarea::placeholder { color: var(--text-muted); }
#sharePreview {
  background: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
}

/* Tabs */
.tab-btn { background: var(--chip-bg); color: var(--heading); border-color: var(--border-color); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* High contrast helper (optional via body.classList) */
body.high-contrast .score-item,
body.high-contrast .current-word,
body.high-contrast .word-list { background: rgba(255,255,0,0.28); }

/* Reduced motion: respect user preference and optional local toggle */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
body.reduce-motion * { animation: none !important; transition: none !important; }

/* Light theme readability fixes for ranking text and modal content */
body.theme-light .rk-name { color: #1f2937; }

/* Light theme readability fixes for modal content and form fields */
body.theme-light .modal-content { color: #111827; }
body.theme-light .modal-content input[type="text"],
body.theme-light .modal-content input[type="email"],
body.theme-light .modal-content input[type="password"],
body.theme-light .modal-content textarea {
  color: #111827;
}
body.theme-light .modal-content input::placeholder,
body.theme-light .modal-content textarea::placeholder { color: #6b7280; }
body.theme-light #sharePreview { color: #111827; }

/* Temporary mobile tooltip bubble for date long format */
.mobile-tooltip-bubble {
  position: absolute;
  transform: translateX(-50%);
  background: rgba(17,24,39,0.95);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.1;
  z-index: 4000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-width: 80vw;
  pointer-events: none;
}
.mobile-tooltip-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(17,24,39,0.95) transparent transparent transparent;
}

/* Achievements progress bars */
.achievement-item .ach-progress { width: 160px; height: 10px; background: var(--border-color-soft); border-radius: 999px; overflow: hidden; border:1px solid var(--border-color); }
.achievement-item .ach-progress-bar { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); width: 0%; transition: width 0.4s ease; }
body.theme-dark .achievement-item .ach-progress { background: var(--surface-muted); border-color: var(--border-color-soft); }
.achievement-item.unlocked .ach-progress-bar { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.achievement-item .ach-progress-label { text-align: right; margin-top: 4px; }

/* Missing letters display for alphabet achievement */
.achievement-item .missing-letters {
  color: #e67e22;
  font-style: italic;
}
.achievement-item .missing-letters strong {
  font-weight: 600;
  color: #d35400;
}
body.theme-dark .achievement-item .missing-letters {
  color: #f39c12;
}
body.theme-dark .achievement-item .missing-letters strong {
  color: #e67e22;
}

/* Achievement words button */
.achievement-words-btn {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-left: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}
.achievement-words-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}
.achievement-words-btn:active {
  transform: translateY(0);
}

/* Word badges in achievement words modal */
.word-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  color: #0c4a6e;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid #bae6fd;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
body.theme-dark .word-badge {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #93c5fd;
  border-color: #475569;
}

/* Alphabet letter groups */
.alphabet-letter-group {
  padding: 12px;
  background: linear-gradient(135deg, #fefce8, #fef3c7);
  border-radius: 8px;
  border: 1px solid #fde047;
}
body.theme-dark .alphabet-letter-group {
  background: linear-gradient(135deg, #18181b, #27272a);
  border-color: #3f3f46;
}

/* Today progress badge */
.today-progress-badge {
  display: inline-block;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  animation: pulseOnce 0.6s ease-out;
}

@keyframes pulseOnce {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* Mobile layout for achievements: title above description */
@media (max-width: 600px) {
  /* Stack the left block vertically so name is above description */
  .achievement-item .rk-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .achievement-item .rk-name {
    line-height: 1.2;
  }
  .achievement-item .rk-meta {
    line-height: 1.2;
  }
  /* Allow right panel to wrap under if space is tight */
  .achievement-item { flex-wrap: wrap; }
  .achievement-item .rk-right { margin-top: 6px; width: 100%; }
  .achievement-item .ach-progress { width: 100%; }
}

/* Pagination styles */
.pagination-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 8px; /* Space between buttons */
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.pagination-btn {
  background: var(--chip-bg); /* Reusing existing variable for consistency */
  color: var(--heading); /* Reusing existing variable for consistency */
  border: 1px solid var(--border-color); /* Reusing existing variable for consistency */
  padding: 8px 14px;
  border-radius: 999px; /* Pill shape */
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
  min-width: 40px; /* Ensure a minimum width for numbers */
  text-align: center;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent); /* Reusing existing variable for consistency */
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.pagination-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pagination-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface-muted); /* Softer background for disabled */
  color: var(--text-muted);
  border-color: var(--border-color-soft);
}

/* Custom styles for word ranking display */
.rk-word-display .found-word {
  font-size: clamp(1rem, 3.5vw, 1.2rem); /* Slightly smaller font */
  font-weight: 700; /* Keep it bold */
  padding: 1px 6px; /* Less vertical, less horizontal padding */
}

.rk-user-display {
  font-size: 0.8rem; /* Make username smaller */
  color: var(--text-muted); /* Use muted color for username */
  font-weight: 400; /* Normal weight */
}

/* Adjust .rk-name if it's still used elsewhere and needs to be smaller */
.rk-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  flex-shrink: 0;
}

.rk-avatar-initial {
  font-size: 1.3rem;
  line-height: 1;
}
/* Avatar-emoji (el que el jugador ha elegido) en ranking y perfil: sin el
   degradado de color por inicial, emoji centrado sobre un fondo neutro. */
.rk-avatar.rk-avatar-emoji { background: rgba(125, 130, 150, .16); }
.rk-avatar-emoji-char { font-size: 1.3rem; line-height: 1; }
/* Avatar SVG del sprite (avatarSvg.js): dimensiona como un glifo un pelín mayor
   que el emoji al que sustituye, heredando el font-size de cada contexto. */
.av-svg { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.25em; }
.profile-avatar.avatar-has-emoji { background: rgba(125, 130, 150, .16); }
.profile-avatar.avatar-has-emoji .profile-avatar-initial { font-size: 2.4rem; line-height: 1; }

.rk-medal-top {
  font-size: 1.6rem;
}

.rk-name {
  font-weight: 700; /* Keep original rk-name bold */
  color: var(--text-color); /* Keep original rk-name color */
}

/* Fullscreen Menu */
#menuModal.modal-overlay {
    padding: 0;
    cursor: default;
    background: var(--bg-gradient); /* Use gradient background */
}

/* Halloween menu background images */
body.theme-halloween #menuModal.modal-overlay {
    background-image: url('/img/halloween/desktop_background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Mobile Halloween background */
@media (max-width: 768px) {
    body.theme-halloween #menuModal.modal-overlay {
        background-image: url('/img/halloween/mobile_background.webp');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: fixed;
    }
}

/* Halloween full-screen background images during gameplay */
body.theme-halloween {
    background-image: url('/img/halloween/desktop_background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: rgba(45, 27, 14, 0.3); /* Fallback color matching Halloween theme */
}


/* Halloween profile modal icon */
body.theme-halloween #profileModalTitle .profile-icon {
    font-size: 0;
}
body.theme-halloween #profileModalTitle .profile-icon::before {
    content: '🎃';
    font-size: 1.35rem;
    display: inline-block;
}

/* Christmas menu background images */
body.theme-christmas #menuModal.modal-overlay {
    background-image: url('/img/christmas/desktop_background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Mobile Christmas background */
@media (max-width: 768px) {
    body.theme-christmas #menuModal.modal-overlay {
        background-image: url('/img/christmas/mobile_background.webp');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: fixed;
    }
}

/* Christmas full-screen background images during gameplay */
body.theme-christmas {
    background-image: url('/img/christmas/desktop_background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: rgba(26, 58, 77, 0.3); /* Fallback color matching Christmas theme */
}

/* Christmas menu button - Nueva Partida gets different color (orange) since icon is green */
body.theme-christmas .menu-buttons .btn:first-of-type {
    background: linear-gradient(145deg, #f97316, #ea580c) !important;
}

body.theme-christmas .menu-buttons .btn:first-of-type:hover {
    background: linear-gradient(145deg, #fb923c, #f97316) !important;
}

/* Christmas profile modal icon */
body.theme-christmas #profileModalTitle .profile-icon {
    font-size: 0;
}
body.theme-christmas #profileModalTitle .profile-icon::before {
    content: '🎅';
    font-size: 1.35rem;
    display: inline-block;
}

/* Mobile Halloween background during gameplay */
@media (max-width: 768px) {
    body.theme-halloween {
        background-image: url('/img/halloween/mobile_background.webp');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: fixed;
    }
}

#menuModal .menu-content {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Use vh for full height */
    width: 100vw; /* Use vw for full width */
    padding: 20px;
    padding-top: 40px; /* Less padding at the top */
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
}

#menuModal .menu-header {
    text-align: center;
    flex-shrink: 0;
}

#menuModal .menu-center {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#menuModal .menu-footer {
    flex-shrink: 0;
}

body.theme-light #menuModal .bottom-icon-bar .footer-text {
    color: #FFFFFF;
}

.update-message {
    background: linear-gradient(145deg, #10b981, #059669);
    padding: 15px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    border-radius: 15px;
    margin: 0 20px 20px 20px; /* 0 top, 20 right, 20 bottom, 20 left */
    opacity: 0.7; /* More transparency */
}

.menu-buttons {
    width: 80%;
    max-width: 400px;
}

body.theme-light .update-message {
    background: linear-gradient(145deg, #f59e0b, #d97706); /* Orange gradient for light mode */
}

.update-message a {
    color: #FFFFFF;
    text-decoration: none;
}

/* Profile modal */
.profile-modal {
  max-width: min(760px, 94vw);
  border-radius: 24px;
  background: var(--surface);
}

.profile-modal-body {
  display: grid;
  gap: 20px;
  padding: 24px;
}

@media (max-width: 600px) {
  .profile-modal-body {
    padding: 18px;
    gap: 16px;
  }
}

.profile-loading {
  text-align: center;
  padding: 36px 0;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-overview {
  display: flex;
  gap: 16px;
  align-items: center;
}

@media (max-width: 520px) {
  .profile-overview {
    flex-direction: column;
    align-items: flex-start;
  }
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  background-color: #ccc; /* Default background */
}







.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: none;
  position: relative;
  z-index: 2;
}

.profile-avatar.has-image img {
  display: block;
}

.profile-avatar.has-image .profile-avatar-initial {
  display: none;
}

.profile-avatar-initial {
  font-size: 3.5rem; /* Increased from 2.5rem */
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}







/* Color variants based on username hash */
.avatar-color-0 { background-color: #06b6d4; }
.avatar-color-1 { background-color: #10b981; }
.avatar-color-2 { background-color: #f59e0b; }
.avatar-color-3 { background-color: #ec4899; }
.avatar-color-4 { background-color: #8b5cf6; }

.profile-overview-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.profile-display-name {
  font-size: 1.4rem;
  margin: 0;
  color: var(--heading);
  word-break: break-word;
}

.profile-username {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.profile-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-chip {
  background: var(--chip-bg);
  color: var(--chip-fg);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.profile-actions .btn {
  font-size: 0.95rem;
  padding: 10px 14px;
}

.profile-section {
  display: grid;
  gap: 12px;
}

.profile-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-section-title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--heading);
}

.profile-section-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.profile-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.profile-stat-card {
  background: var(--surface);
  border: 1px solid var(--border-color-soft);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.profile-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--heading);
}

.profile-badge-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.profile-badge-card {
  background: var(--surface);
  border: 1px solid var(--border-color-soft);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  min-height: 80px;
}

.profile-badge-card::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.profile-badge-card--unlocked::after {
  opacity: 0.18;
  background: linear-gradient(140deg, rgba(250, 204, 21, 0.35), transparent 65%);
}

.profile-badge-card--in_progress::after {
  opacity: 0.14;
  background: linear-gradient(140deg, rgba(56, 189, 248, 0.3), transparent 65%);
}

.profile-badge-card--locked {
  opacity: 0.65;
}

.profile-badge-card__icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-badge-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-badge-card__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.profile-badge-card__name {
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.95rem;
  margin: 0;
}

.profile-badge-card__desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin: 0;
}

.profile-badge-progress {
  width: 100%;
  height: 6px;
  background: var(--border-color-soft);
  border-radius: 999px;
  overflow: hidden;
}

.profile-badge-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  width: 0%;
}

.profile-badge-card__footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-empty {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 12px 0;
}

.profile-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.profile-activity-item {
  background: var(--surface);
  border: 1px solid var(--border-color-soft);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.profile-activity-item .label {
  font-size: 0.85rem;
  color: var(--text-color);
  flex: 1;
}

.profile-activity-item .time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.profile-modal-footer {
  display: flex;
  justify-content: flex-end;
}

.profile-modal-footer .btn-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.profile-badge-card--locked .profile-badge-card__icon,
.profile-badge-card--in_progress .profile-badge-card__icon {
  filter: grayscale(100%);
  opacity: 0.6;
}

.profile-badge-card--locked .profile-badge-card__name,
.profile-badge-card--in_progress .profile-badge-card__name {
  color: var(--text-muted);
}


/** Override: keep avatar left and info right inside profile modal, even on small widths */
.profile-modal .profile-overview {
  flex-direction: row;
  align-items: center;
}

/* Completion multiplier badge for repeatable achievements */
.completion-multiplier {
  display: inline-block;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
  vertical-align: middle;
}

/* Google Sign-In Button - Dark theme support */
#googleSignInButton {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
}

#googleSignInButton iframe {
  border-radius: 8px !important;
}

/* Contenedor personalizado para mejor control */
#googleNotLinked {
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

body.theme-dark #googleNotLinked {
  background: rgba(255, 255, 255, 0.08);
}

/* Streak Motivation Section Styles */
.profile-streak-section {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(249, 115, 22, 0.08));
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 8px;
}

.profile-streak-content {
  display: grid;
  gap: 16px;
}

.profile-streak-display {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(239, 68, 68, 0.15);
}

.profile-streak-number {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ef4444, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  min-width: 80px;
  text-align: center;
}

.profile-streak-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-color);
}

.profile-streak-label small {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.profile-streak-progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.profile-streak-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f97316);
  width: 0%;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 999px;
}

.profile-streak-cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.profile-streak-card {
  background: var(--surface);
  border: 1px solid var(--border-color-soft);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.profile-streak-card:hover {
  border-color: rgba(239, 68, 68, 0.4);
  background: var(--surface-muted);
  transform: translateY(-2px);
}

.profile-streak-card-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-streak-card-value {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ef4444, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-streak-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.profile-streak-card-today {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.05);
}

.profile-streak-card-today .profile-streak-card-value {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-streak-card-tomorrow {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.profile-streak-card-tomorrow .profile-streak-card-value {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-streak-card-call-to-action {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.05);
  border-width: 2px;
}

.profile-streak-card-call-to-action .profile-streak-card-value {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-streak-card-future {
  border-color: rgba(249, 115, 22, 0.3);
  background: rgba(249, 115, 22, 0.05);
}

.profile-streak-card-future .profile-streak-card-value {
  background: linear-gradient(135deg, #f97316, #ea580c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-streak-message {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text-color);
  font-weight: 500;
  text-align: center;
}

/* ===================================================================
   YEAR HIGHLIGHTS MODAL STYLES
   =================================================================== */

.year-highlights-overlay {
    z-index: 9999;
}

.year-highlights-overlay.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.year-highlights-modal {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 90vh;
    max-height: 800px;
    background: linear-gradient(145deg, #6366f1, #8b5cf6);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.year-highlights-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 100%);
    z-index: 10;
}

.year-highlights-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    transition: background 0.3s ease;
}

.progress-segment.completed {
    background: rgba(255, 255, 255, 0.9);
}

.progress-segment.active {
    background: linear-gradient(90deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.3) 100%);
    animation: progress-fill 3s ease-out;
}

@keyframes progress-fill {
    0% { background: rgba(255, 255, 255, 0.3); }
    100% { background: rgba(255, 255, 255, 0.9); }
}

.year-highlights-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.year-highlights-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.year-highlights-slides {
    position: relative;
    width: 100%;
    height: 100%;
}

.year-highlight-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    opacity: 0;
    transform: translateX(100%);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.year-highlight-slide.active {
    opacity: 1;
    transform: translateX(0);
}

.year-highlight-slide.prev {
    transform: translateX(-100%);
}

.slide-content {
    width: 100%;
}

.slide-icon {
    font-size: 4rem;
    margin-bottom: 24px;
    animation: bounce-in 0.6s ease;
}

.slide-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: fade-in 0.5s ease 0.2s both;
}

.slide-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    animation: fade-in 0.5s ease 0.3s both;
}

.slide-number {
    font-size: 4rem;
    font-weight: 800;
    color: white;
    margin: 20px 0;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: scale-in 0.6s ease 0.1s both;
}

.slide-message {
    font-size: 1.2rem;
    color: white;
    line-height: 1.6;
    font-weight: 500;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: fade-in 0.5s ease 0.3s both;
}

.words-list {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    animation: slide-up 0.5s ease both;
}

.word-item:nth-child(1) { animation-delay: 0.2s; }
.word-item:nth-child(2) { animation-delay: 0.3s; }
.word-item:nth-child(3) { animation-delay: 0.4s; }

.word-rank {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.word-text {
    flex: 1;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.word-meta {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.year-highlights-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.year-highlights-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 28px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.year-highlights-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Year Highlights Banner */
.year-highlights-banner {
    margin: 20px auto;
    max-width: 800px;
    background: linear-gradient(145deg, #6366f1, #8b5cf6);
    border: none !important;
    color: white !important;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
}

.year-highlights-banner .alert-heading {
    color: white !important;
}

.year-highlights-banner p {
    color: rgba(255, 255, 255, 0.95) !important;
}

.year-highlights-banner .btn-primary {
    background: white;
    color: #6366f1;
    border: none;
    font-weight: 600;
    padding: 10px 24px;
    white-space: nowrap;
}

.year-highlights-banner .btn-primary:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}

.year-highlights-banner .btn-close {
    filter: brightness(0) invert(1);
}

/* Animations */
@keyframes bounce-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scale-in {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .year-highlights-modal {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .year-highlight-slide {
        padding: 60px 24px;
    }

    .slide-title {
        font-size: 1.6rem;
    }

    .slide-number {
        font-size: 3rem;
    }

    .slide-subtitle,
    .slide-message {
        font-size: 1rem;
    }

    .word-text {
        font-size: 1.1rem;
    }
}

/* ── Game effects ─────────────────────────────────────────────────────────── */

/* Grid entrance stagger */
@keyframes grid-enter {
    from { opacity: 0; transform: scale(0.45) translateY(-6px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.letter.grid-enter {
    animation: grid-enter 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Letter selection ripple */
@keyframes select-pop {
    0%   { box-shadow: 0 0 0 0   rgba(76,175,80,0.65), 0 2px 4px rgba(0,0,0,.2); }
    55%  { box-shadow: 0 0 0 9px rgba(76,175,80,0),    0 2px 4px rgba(0,0,0,.2); }
    100% { box-shadow: 0 0 0 0   rgba(76,175,80,0),    0 2px 4px rgba(0,0,0,.2); }
}
.letter.select-pop { animation: select-pop 0.32s ease-out; }

/* Score-item bounce */
@keyframes score-pop {
    0%   { transform: scale(1);    filter: brightness(1); }
    35%  { transform: scale(1.22); filter: brightness(1.35); }
    65%  { transform: scale(0.96); filter: brightness(1.08); }
    100% { transform: scale(1);    filter: brightness(1); }
}
.score-item.score-pop { animation: score-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Found word entrance */
@keyframes word-enter {
    from { opacity: 0; transform: translateX(16px) scale(0.82); }
    to   { opacity: 1; transform: translateX(0)    scale(1); }
}
.found-word.word-enter { animation: word-enter 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Current word letter pop */
@keyframes cw-letter-in {
    from { opacity: 0; transform: translateY(6px) scale(0.7); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.cw-letter     { display: inline-block; }
.cw-letter-new { display: inline-block; animation: cw-letter-in 0.14s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Legend screen flash */
@keyframes screen-flash {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

/* Invalid word shake */
@keyframes shake {
    0%,100% { transform: translateX(0); }
    15%  { transform: translateX(-12px); }
    30%  { transform: translateX(10px); }
    45%  { transform: translateX(-8px); }
    60%  { transform: translateX(6px); }
    75%  { transform: translateX(-4px); }
    90%  { transform: translateX(2px); }
}
.shake { animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* Invalid letter flash */
@keyframes letter-flash-invalid {
    0%,100% { background: var(--tile-bg, #fff); }
    35%  { background: rgba(220,50,50,0.5); box-shadow: 0 0 0 2px rgba(220,50,50,0.4); }
}
.letter-invalid { animation: letter-flash-invalid 0.42s ease-in-out; }

/* ── Pista del novato: camino de una palabra que sí está en el tablero ──
   Se encienden en orden, con retardo escalonado, para que se lea la dirección
   del arrastre. Ámbar y no verde: el verde es «palabra acertada» y esto todavía
   no lo ha hecho nadie — la palabra la tiene que arrastrar el jugador. */
.letter-hint {
  animation: letter-hint-pulse 1.5s ease-in-out infinite;
  animation-delay: var(--hint-delay, 0ms);
  position: relative;
  z-index: 2;
}
@keyframes letter-hint-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); transform: scale(1); }
  35%      { box-shadow: 0 0 0 4px rgba(251,191,36,.55), 0 0 16px rgba(251,191,36,.5); transform: scale(1.07); }
  70%      { box-shadow: 0 0 0 0 rgba(251,191,36,0); transform: scale(1); }
}
/* Sin animación, la pista se marca igual: fija y visible. */
@media (prefers-reduced-motion: reduce) {
  .letter-hint {
    animation: none;
    box-shadow: 0 0 0 3px rgba(251,191,36,.75);
  }
}

/* Aviso que acompaña a la pista */
.hint-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  z-index: 1400; max-width: 90vw;
  background: rgba(15,23,42,.94); color: #fff; font-weight: 700; font-size: .95rem;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.3);
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.hint-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Daily challenge chip entrance */
.rk-chip.word-enter { animation: word-enter 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ─────────────────────────────────────────────────────────────────────────── */

@keyframes profile-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,.3); }
    50% { box-shadow: 0 0 0 5px rgba(34,197,94,.15); }
}

/* Feedback tooltip callout */
.feedback-tooltip {
    position: fixed;
    z-index: 2000;
    width: 220px;
    background: var(--surface, #fff);
    color: var(--tile-fg, #1f2937);
    border-radius: 14px;
    padding: 14px 16px 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
    font-size: 0.85rem;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    border: 1.5px solid var(--border-color, #e6edff);
}
.feedback-tooltip.show {
    opacity: 1;
    pointer-events: auto;
}
.feedback-tooltip::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: var(--surface, #fff);
    border-bottom: 0;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,0.08));
}
.feedback-tooltip-emoji {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 6px;
}
.feedback-tooltip p { margin: 0; }
body.theme-dark .feedback-tooltip {
    background: #1e293b;
    color: #e5e7eb;
    border-color: #334155;
    box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
body.theme-dark .feedback-tooltip::after { border-top-color: #1e293b; }

/* Feedback modal */
.feedback-type-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: 999px;
    border: 2px solid var(--border-color);
    background: var(--chip-bg);
    color: var(--chip-fg);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.feedback-type-btn.active {
    background: linear-gradient(145deg, #6366f1, #4f46e5);
    border-color: #6366f1;
    color: #fff;
}
body.theme-dark .feedback-type-btn {
    background: #1e293b;
    border-color: #334155;
    color: #e5e7eb;
}
body.theme-dark .feedback-type-btn.active {
    background: linear-gradient(145deg, #6366f1, #4f46e5);
    border-color: #6366f1;
    color: #fff;
}
.feedback-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: var(--surface);
    color: var(--tile-fg);
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s;
    outline: none;
}
.feedback-input:focus {
    border-color: #6366f1;
}
body.theme-dark .feedback-input {
    background: #1e293b;
    border-color: #334155;
    color: #e5e7eb;
}
body.theme-dark .feedback-input::placeholder { color: #6b7280; }
.feedback-input::placeholder { color: #9ca3af; }

/* ── Power-ups ──────────────────────────────────────────────────────────────── */

/* Targeting mode overlay on grid */
#grid.powerup-targeting .letter { cursor: crosshair; transition: transform .15s, box-shadow .15s; }
@media (hover: hover) { #grid.powerup-targeting .letter:hover { transform: scale(1.05); } }

/* Highlight on hover during targeting */
.letter.pu-highlight {
  background: rgba(249,115,22,.35) !important;
  box-shadow: 0 0 12px rgba(249,115,22,.6);
  transition: background .1s, box-shadow .1s;
}
.letter.pu-highlight-center {
  background: rgba(239,68,68,.6) !important;
  box-shadow: 0 0 20px rgba(239,68,68,.8), 0 0 40px rgba(239,68,68,.4);
  transform: scale(1.08);
}

/* Bomb prime (brief pulse before explosion) */
@keyframes bomb-prime {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,.8); }
  50%  { transform: scale(1.15); box-shadow: 0 0 0 12px rgba(239,68,68,0); }
  100% { transform: scale(1.1); }
}
.letter.bomb-prime {
  animation: bomb-prime .3s ease-out forwards;
  background: rgba(239,68,68,.7) !important;
}

/* Cell explosion */
@keyframes cell-explode {
  0%   { transform: scale(1); opacity: 1; }
  30%  { transform: scale(1.3) rotate(var(--spin, 15deg)); opacity: 1; }
  100% { transform: scale(0) rotate(var(--spin, 180deg)); opacity: 0; }
}
.letter.cell-explode {
  animation: cell-explode .35s cubic-bezier(.55,.06,.68,.19) forwards;
  pointer-events: none;
}
.letter:nth-child(odd).cell-explode  { --spin: -25deg; }
.letter:nth-child(even).cell-explode { --spin: 20deg; }

/* Cell dissolve (row/column) */
@keyframes cell-dissolve {
  0%   { transform: scaleY(1); opacity: 1; filter: brightness(1); }
  40%  { filter: brightness(2); }
  100% { transform: scaleY(0); opacity: 0; }
}
.letter.cell-dissolve {
  animation: cell-dissolve .3s ease-in forwards;
  transform-origin: center;
  pointer-events: none;
}

/* New letters falling in from top */
@keyframes cell-fall-in {
  0%   { transform: translateY(-120%); opacity: 0; }
  60%  { transform: translateY(8%); opacity: 1; }
  80%  { transform: translateY(-4%); }
  100% { transform: translateY(0); opacity: 1; }
}
.letter.cell-fall-in {
  animation: cell-fall-in .45s cubic-bezier(.34,1.56,.64,1) both;
  animation-delay: var(--fall-delay, 0ms);
}

/* Surviving letters sliding down */
@keyframes cell-slide-down {
  0%   { transform: translateY(-30%); opacity: .6; }
  100% { transform: translateY(0); opacity: 1; }
}
.letter.cell-slide-down {
  animation: cell-slide-down .3s ease-out both;
  animation-delay: var(--fall-delay, 0ms);
}

/* Grid shake */
@keyframes grid-shake {
  0%,100% { transform: translateX(0) rotate(0); }
  15%  { transform: translateX(-6px) rotate(-1deg); }
  30%  { transform: translateX(6px) rotate(1deg); }
  45%  { transform: translateX(-4px) rotate(-.5deg); }
  60%  { transform: translateX(4px) rotate(.5deg); }
  75%  { transform: translateX(-2px); }
}
.grid-shake { animation: grid-shake .45s ease-out; }

/* Screen flash */
@keyframes pu-flash-anim {
  0%   { opacity: .7; }
  100% { opacity: 0; }
}
.pu-flash-anim { animation: pu-flash-anim .35s ease-out forwards; }

/* Particles */
@keyframes pu-particle {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx),var(--dy)) scale(0); opacity: 0; }
}
.pu-particle { animation: pu-particle .5s ease-out forwards; }

/* Laser sweep - row */
@keyframes laser-row {
  0%   { transform: scaleX(0); opacity: 1; transform-origin: left; }
  60%  { transform: scaleX(1); opacity: 1; }
  100% { opacity: 0; }
}
.pu-laser-row {
  background: linear-gradient(90deg, transparent, #f97316, #fbbf24, #f97316, transparent);
  box-shadow: 0 0 12px #f97316, 0 0 30px #fbbf24;
  border-radius: 4px;
  animation: laser-row .35s ease-out forwards;
}

/* Laser sweep - column */
@keyframes laser-col {
  0%   { transform: scaleY(0); opacity: 1; transform-origin: top; }
  60%  { transform: scaleY(1); opacity: 1; }
  100% { opacity: 0; }
}
.pu-laser-col {
  background: linear-gradient(180deg, transparent, #8b5cf6, #a78bfa, #8b5cf6, transparent);
  box-shadow: 0 0 12px #8b5cf6, 0 0 30px #a78bfa;
  border-radius: 4px;
  animation: laser-col .35s ease-out forwards;
}

/* Power-up buttons in game */
.pu-btn {
  border: none; border-radius: 10px; padding: 8px 14px;
  font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: transform .15s, opacity .15s, box-shadow .15s;
  display: flex; align-items: center; gap: 6px;
}
@media (hover: hover) { .pu-btn:not(:disabled):hover { transform: scale(1.06); } }
.pu-btn:not(:disabled):active { transform: scale(.97); }
.pu-btn-disabled { opacity: .45; cursor: not-allowed; }
.pu-btn-bomb    { background: linear-gradient(145deg,#ef4444,#b91c1c); color:#fff; box-shadow:0 2px 8px rgba(239,68,68,.4); }
.pu-btn-row     { background: linear-gradient(145deg,#f97316,#c2410c); color:#fff; box-shadow:0 2px 8px rgba(249,115,22,.4); }
.pu-btn-column  { background: linear-gradient(145deg,#8b5cf6,#6d28d9); color:#fff; box-shadow:0 2px 8px rgba(139,92,246,.4); }

/* Gem counter chip */
.gem-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(145deg,#1e293b,#0f172a);
  border: 1.5px solid rgba(139,92,246,.4);
  border-radius: 20px; padding: 4px 10px;
  font-size: .85rem; font-weight: 700; color: #e2d9f3;
}

/* Inline toolbar inside score-board */
.pu-toolbar-inline { gap: 3px !important; padding: 4px 8px !important; }
/* El HUD NUNCA puede desbordar el ancho: con la fiebre y el reloj en rojo (que
   crecía con padding y scale) la fila llegaba a 435 px en un móvil de 360 y el
   juego se salía de la pantalla. Los tamaños escalan con el viewport y el reloj
   tiene ancho fijo para no saltar. */
.score-board { max-width: 100%; box-sizing: border-box; }
.score-board .score-item { flex: 0 1 auto; min-width: 0; padding: 6px clamp(5px, 2.2vw, 12px); gap: clamp(3px, 1.2vw, 6px); white-space: nowrap; }
#hud-timer #timer { display: inline-block; min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }
#hud-timer .timer-warning, #hud-timer .timer-urgent { padding: 2px 6px; margin: -2px -2px; }
#hud-timer .timer-urgent { transform: none; }
@media (max-width: 400px) {
  .score-board { gap: 4px; font-size: .78rem; }
  .score-board .score-item { padding: 5px 7px; }
  .score-board .hud-tools { padding: 3px 6px !important; gap: 3px !important; }
  .hud-tools .pu-inline-btn { min-width: 28px; min-height: 28px; }
  .hud-tools .pu-inline-btn .ic { width: 16px; height: 16px; }
  .hud-tools .pu-toolbar-inline { gap: 3px; }
  .hud-exit { width: 30px; height: 30px; font-size: 1.1rem; }
  .hud-label { font-size: .66rem; }
}
@media (max-width: 340px) {
  .score-board { gap: 3px; font-size: .72rem; }
  .score-board .score-item { padding: 4px 5px; }
  .score-board .hud-tools { padding: 2px 4px !important; gap: 2px !important; }
  .score-item .ic { width: 13px; height: 13px; }
  .hud-tools .pu-inline-btn { min-width: 25px; min-height: 25px; }
  .hud-tools .pu-inline-btn .ic { width: 14px; height: 14px; }
  .hud-exit { width: 28px; height: 28px; }
}
/* Una sola píldora de herramientas: Barajar + power-ups */
.hud-tools { gap: 4px !important; padding: 4px 8px !important; }
.hud-tools .pu-toolbar-inline { display: inline-flex; align-items: center; gap: 4px; padding: 0 !important; margin: 0; background: none; box-shadow: none; border-radius: 0; }
.hud-points, .hud-words { display: inline-flex; align-items: center; gap: 4px; }
.hud-sep { opacity: .45; margin: 0 1px; }
.hud-exit { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-color, rgba(148,163,184,.3)); background: color-mix(in oklab, var(--surface-muted), transparent 20%); color: var(--text-color, #f8fafc); font-size: 1.25rem; line-height: 1; display: none; align-items: center; justify-content: center; cursor: pointer; opacity: .75; align-self: center; }
.hud-exit:hover { opacity: 1; }
/* Durante la partida la cabecera (avatar · racha · logo · gemas) sobra: todo
   eso vive en la home y aquí solo quitaba sitio al tablero. */
body.in-game .home-topbar { display: none; }
body.in-game .score-board { padding-top: var(--safe-top); }
body.in-game .hud-exit { display: inline-flex; }

.pu-inline-btn {
  border: none; border-radius: 6px; padding: 2px 4px;
  font-size: 1rem; cursor: pointer; line-height: 1;
  transition: transform .15s, opacity .15s;
  background: rgba(255,255,255,.15);
  min-width: 32px; min-height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
/* extiende el área táctil hasta ~44px sin cambiar el tamaño visual */
.pu-inline-btn::after { content: ''; position: absolute; inset: -6px; }
@media (hover: hover) { .pu-inline-btn:hover { transform: scale(1.15); } }
.pu-inline-btn:active { transform: scale(.93); }
.pu-inline-btn.pu-btn-disabled { opacity: .35; cursor: not-allowed; }
.pu-inline-btn.pu-btn-bomb   { color: #ef4444; }
.pu-inline-btn.pu-btn-row    { color: #f97316; }
.pu-inline-btn.pu-btn-column { color: #8b5cf6; }
.pu-inline-btn .ic { width: 18px; height: 18px; filter: drop-shadow(0 0 4px currentColor); }
.pu-inline-btn.pu-btn-shuffle { color: #22d3ee; }
/* Combo y fiebre final (multiplier.js): estados de las píldoras del HUD, sin línea propia */
.score-item { position: relative; }
.mult-x2, .mult-fire { position: absolute; top: -8px; right: -4px; display: none; line-height: 1; pointer-events: none; }
.mult-x2 { font-size: .62rem; font-weight: 900; padding: 2px 5px; border-radius: 999px; background: #22d3ee; color: #083344; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.mult-fire { font-size: .8rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.mult-bar { position: absolute; left: 12px; right: 12px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(34,211,238,.25); overflow: hidden; display: none; pointer-events: none; }
.mult-fill { display: block; height: 100%; width: 0; background: #22d3ee; transition: width .2s linear; }
.score-item.combo-on { background: linear-gradient(135deg, rgba(34,211,238,.28), rgba(59,130,246,.28)) !important; border-color: rgba(34,211,238,.65) !important; box-shadow: 0 0 0 1px rgba(34,211,238,.25), 0 0 14px rgba(34,211,238,.35); }
.score-item.combo-on .mult-x2, .score-item.combo-on .mult-bar { display: block; }
.score-item.fever-on { background: linear-gradient(135deg, rgba(249,115,22,.32), rgba(239,68,68,.32)) !important; border-color: rgba(251,146,60,.75) !important; box-shadow: 0 0 0 1px rgba(251,146,60,.3), 0 0 14px rgba(249,115,22,.4); }
.score-item.fever-on .mult-fire { display: block; }
body.fever-on .letter { box-shadow: 0 0 0 1px rgba(251,146,60,.55), 0 2px 6px rgba(249,115,22,.35); }
body.fever-on #grid { animation: feverGlow 1.2s ease-in-out infinite; border-radius: 12px; }
@keyframes feverGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(249,115,22,0); } 50% { box-shadow: 0 0 22px 4px rgba(249,115,22,.35); } }
@media (prefers-reduced-motion: reduce) { body.fever-on #grid { animation: none; box-shadow: 0 0 18px 3px rgba(249,115,22,.3); } .mult-fill { transition: none; } }
/* Sin zoom: touch-action ya está en body; el tablero y sus celdas no dejan pasar ningún gesto. */
#grid, #grid * { touch-action: none; }
/* Objetivos de la primera partida (firstGame.js): píldoras que se rellenan */
.fg-goals { display: flex; justify-content: center; flex-wrap: nowrap; gap: 8px; margin: 2px auto 8px; max-width: 520px; font-size: .78rem; font-weight: 700; }
.fg-goal { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; min-width: 96px; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16); opacity: .9; transition: border-color .3s, opacity .3s; white-space: nowrap; }
.fg-fill { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, rgba(34,197,94,.28), rgba(34,197,94,.42)); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.fg-text { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.fg-goal.done { border-color: rgba(34,197,94,.7); opacity: 1; }
.fg-goal.done .fg-fill { background: rgba(34,197,94,.3); }
.fg-check { font-size: .85rem; line-height: 1; color: #86efac; }
@media (prefers-reduced-motion: reduce) { .fg-fill { transition: none; } }
body.theme-light .fg-goal { background: rgba(15,23,42,.05); border-color: rgba(15,23,42,.14); }
body.theme-light .fg-fill { background: linear-gradient(90deg, rgba(34,197,94,.22), rgba(34,197,94,.36)); }
body.theme-light .fg-goal.done { border-color: rgba(21,128,61,.55); }
body.theme-light .fg-check { color: #15803d; }
/* Primera partida: el HUD se explica con palabras y no enseña herramientas
   (ni power-ups ni Barajar): sin gemas no sirven, con las etiquetas no cabían
   en 412 px y son conceptos que sobran en el primer contacto. */
.hud-label { display: none; font-size: .72rem; font-weight: 600; opacity: .8; margin-left: 3px; }
body.first-game .hud-label { display: inline; }
body.first-game .hud-tools { display: none !important; }
body.first-game .score-item { padding-left: 10px; padding-right: 10px; }
.pu-inline-btn.pu-btn-shuffle.shuffle-ready { animation: shuffleReady 1.4s ease-in-out infinite; }
/* Solo brillo (sin transform): un botón que cambia de tamaño en bucle no se puede pulsar con fiabilidad, ni en tests ni con dedos grandes. */
@keyframes shuffleReady { 0%,100% { box-shadow: 0 0 0 0 rgba(34,211,238,.55); filter: brightness(1); } 50% { box-shadow: 0 0 0 7px rgba(34,211,238,0); filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { .pu-inline-btn.pu-btn-shuffle.shuffle-ready { animation: none; box-shadow: 0 0 0 3px rgba(34,211,238,.45); } }

.gem-counter-mini { display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; font-weight: 700; opacity: .85; white-space: nowrap; }
.gem-counter-mini .ic { width: 13px; height: 13px; color: #e879f9; }

/* Floating cancel button during targeting mode */
.pu-cancel-float {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 9998; border: none; border-radius: 999px;
  padding: 8px 20px; font-size: .9rem; font-weight: 700;
  background: rgba(239,68,68,.9); color: #fff; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  transition: opacity .2s, transform .2s;
}
.pu-cancel-float:active { transform: translateX(-50%) scale(.95); }

/* Bomb sparks */
@keyframes pu-spark {
  0%   { transform: rotate(var(--sa)) translateY(0)         scaleY(1.2); opacity: 1; }
  100% { transform: rotate(var(--sa)) translateY(var(--sd)) scaleY(0);   opacity: 0; }
}
.pu-spark { animation: pu-spark 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }


/* Daily challenge like button */
.dc-like-btn {
  background: none; border: 1px solid rgba(255,255,255,.2); border-radius: 6px;
  color: inherit; cursor: pointer; font-size: 1rem; padding: 4px 10px;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
@media (hover: hover) { .dc-like-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); transform: scale(1.05); } }
.dc-like-btn:active:not(:disabled) { transform: scale(.95); }
.dc-like-btn.liked, .dc-like-btn:disabled { opacity: .7; cursor: default; }
.dc-like-btn.liked { border-color: rgba(251,191,36,.5); background: rgba(251,191,36,.08); }
.dc-like-passive { font-size: .8rem; opacity: .6; }

/* "NUEVO" en el botón de Modo Niveles hasta la primera visita (ver initLevelsNewBadge) */
.levels-new-badge {
  background: linear-gradient(145deg, #fbbf24, #f97316);
  color: #fff; font-size: .62rem; font-weight: 800; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(249,115,22,.5);
  animation: levels-new-bounce 1.6s ease-in-out infinite;
}
@keyframes levels-new-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.levels-menu-attention {
  animation: levels-menu-glow 1.8s ease-in-out infinite;
}
@keyframes levels-menu-glow {
  0%, 100% { box-shadow: 0 4px 10px rgba(0,0,0,.15); }
  50% { box-shadow: 0 0 18px rgba(251,191,36,.75), 0 4px 10px rgba(0,0,0,.15); }
}

/* ── Bottom-nav fija para páginas secundarias (lobby de duelos) ── */
.app-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1200;
  display: flex; justify-content: space-around; align-items: center; gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: rgba(15,23,42,.92); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.08);
}
.app-bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; min-height: 44px; padding: 4px 10px; border-radius: 10px;
  text-decoration: none; color: #cbd5e1; font-size: .72rem; font-weight: 700;
}
.app-bottom-nav a .nav-emoji { font-size: 1.25rem; line-height: 1; }
.app-bottom-nav a .ic.nav-emoji { width: 22px; height: 22px; }
.app-bottom-nav a.active { color: #fff; background: rgba(99,102,241,.28); }
/* Páginas con barra inferior (duelos/reto/duelo) scrollean el body. Va aquí (y no
   en un <style> inline de cada plantilla) para que aplique también por soft-nav:
   el router añade has-bottom-nav al <body>, pero NO intercambia el <head>. */
body.has-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); overflow-y: auto; }

/* ── Modal de instrucciones: índice navegable + tarjetas ── */
.instr-body { scroll-behavior: smooth; }
/* Índice fijo bajo la cabecera del modal: referencia siempre a mano */
.instr-index {
  margin: -12px -20px 16px; padding: 14px 20px 12px;
  background: #fff; box-shadow: 0 2px 6px rgba(15,23,42,0.06);
  border-bottom: 1px solid #eef2f7;
  display: flex; flex-direction: column; gap: 10px;
}
.instr-index-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.instr-index-label {
  flex: 0 0 100%; font-size: .72rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: #94a3b8; margin-bottom: 2px;
}
.instr-chip {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 6px 12px; min-height: 34px; border-radius: 999px;
  background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff;
  font-size: .82rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.instr-chip:active { transform: translateY(1px); }
@media (hover: hover) { .instr-chip:hover { background: #e0e7ff; } }

.instr-cards { display: flex; flex-direction: column; gap: 14px; }
.instr-card {
  background: #fff; border: 1px solid #eef2f7; border-left: 4px solid var(--accent, #6366f1);
  border-radius: 14px; padding: 16px 18px; scroll-margin-top: 132px;
}
.instr-card > h4 {
  margin: 0 0 10px; font-size: 1.06rem; font-weight: 800; color: #1f2937;
  display: flex; align-items: center; gap: 8px;
}
.instr-card h4 .instr-emoji { font-size: 1.2rem; }
.instr-card p { margin: 0 0 8px; color: #374151; line-height: 1.55; }
.instr-card p:last-child { margin-bottom: 0; }
.instr-card .instr-note { font-size: .88rem; color: #6b7280; }
.instr-card .instr-example { font-size: .9rem; color: #4b5563; }
.instr-list { margin: 4px 0 8px; padding-left: 18px; }
.instr-list li { color: #374151; line-height: 1.5; margin-bottom: 4px; }
/* Definiciones clave→valor: alineadas, escaneables */
.instr-defs { margin: 4px 0 0; display: flex; flex-direction: column; gap: 8px; }
.instr-defs > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
}
.instr-defs dt { font-weight: 700; color: #111827; flex: 0 0 auto; }
.instr-defs dd { margin: 0; color: #6b7280; font-size: .9rem; text-align: right; }
@media (max-width: 520px) {
  .instr-defs > div { flex-direction: column; gap: 1px; }
  .instr-defs dd { text-align: left; }
  .instr-card { scroll-margin-top: 148px; }
}

/* ── Guía de instalación en iOS (banner inferior) ── */
.ios-install-hint {
  position: fixed; left: 12px; right: 12px; z-index: 3400;
  bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 14px 16px 16px; border-radius: 16px;
  background: linear-gradient(145deg, #4f46e5, #7c3aed); color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transform: translateY(140%); transition: transform .28s ease;
  max-width: 460px; margin: 0 auto;
}
.ios-install-hint.show { transform: translateY(0); }
.ios-install-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; }
.ios-install-text { margin: 0 0 8px; font-size: .9rem; opacity: .92; line-height: 1.45; }
.ios-install-steps { margin: 0; font-size: .9rem; line-height: 1.5; }
.ios-install-steps span { font-size: 1.05em; }
.ios-install-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: none; color: #fff; opacity: .8;
  font-size: 1.6rem; line-height: 1; cursor: pointer;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
@media (hover: hover) { .ios-install-close:hover { opacity: 1; } }

/* ── Onboarding: bienvenida con demo animado + pista de primera partida ── */
.welcome-content { max-width: 420px; }
/* Colores según tema: el modal usa var(--surface) (oscuro en tema dark), así que
   hardcodear gris oscuro dejaba texto oscuro sobre fondo oscuro (fallo de contraste). */
.welcome-lead { margin: 4px 0 6px; font-size: 1.05rem; color: var(--text-color); line-height: 1.5; }
.welcome-sub { margin: 0 0 4px; font-size: .92rem; color: var(--text-color); opacity: .72; line-height: 1.5; }
.welcome-more { margin: 12px 0 0; }
.welcome-more-link {
  background: none; border: 0; padding: 4px 8px;
  /* Medía 23px de alto: demasiado poco para el dedo en el primer modal que ve
     un jugador nuevo. Se centra en una caja de 44px sin mover el texto. */
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-color); opacity: .7;
  font: inherit; font-size: .85rem; text-decoration: underline;
  cursor: pointer;
}
.welcome-more-link:hover, .welcome-more-link:focus-visible { opacity: 1; }
.welcome-cta { width: 100%; max-width: 260px; }
/* Acceso a la cuenta desde la bienvenida. Discreto a propósito: compite con
   "Jugar", que es lo que necesita el 95% de quien ve esta pantalla. */
.welcome-account { margin: 10px 0 0; font-size: .85rem; opacity: .75; }
.welcome-account-link {
  background: none; border: 0; padding: 6px 4px;
  min-height: 44px; display: inline-flex; align-items: center;
  color: var(--text-color); font: inherit; font-weight: 700;
  text-decoration: underline; cursor: pointer;
}
.welcome-account-link:hover, .welcome-account-link:focus-visible { opacity: 1; }

/* Demo: UN tablero continuo con el centro (S→O→L) enfocado; las mismas fichas
   siguen hacia fuera, difuminándose y desvaneciéndose en los bordes (máscara
   radial), como si hiciéramos foco en esa parte de un tablero más grande. */
.welcome-demo {
  position: relative; margin: 4px auto 18px; width: 262px; height: 190px;
}
.wd-grid {
  display: grid; grid-template-columns: repeat(5, 46px); grid-template-rows: repeat(4, 40px);
  gap: 5px; justify-content: center;
  /* Funde el tablero hacia los bordes: es un primer plano, no un panel */
  -webkit-mask-image: radial-gradient(ellipse 58% 62% at 50% 50%, #000 40%, transparent 86%);
  mask-image: radial-gradient(ellipse 58% 62% at 50% 50%, #000 40%, transparent 86%);
}
.wd-cell {
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px; font-weight: 800; font-size: 1.35rem; color: #333;
  background: linear-gradient(145deg,#fff,#e0e0e0); box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
/* Fichas fuera del foco: mismas fichas, pero borrosas y atenuadas */
.wd-cell.wd-out {
  filter: blur(2px); opacity: .55; font-size: 1.15rem; color: #6b7280;
  background: linear-gradient(145deg,#f3f4f6,#d1d5db); box-shadow: none;
}
/* Cada letra del camino S→A→L→T→O se enciende en secuencia y se mantiene
   (verde) hasta que la palabra se completa; luego se reinicia el ciclo. */
.wd-cell[data-i] { animation-duration: 3.6s; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }
.wd-cell[data-i="0"] { animation-name: wd-p0; }
.wd-cell[data-i="1"] { animation-name: wd-p1; }
.wd-cell[data-i="2"] { animation-name: wd-p2; }
.wd-cell[data-i="3"] { animation-name: wd-p3; }
.wd-cell[data-i="4"] { animation-name: wd-p4; }
@keyframes wd-p0 { 0%,7% { } 9%,78% { background: linear-gradient(145deg,#4CAF50,#45a049); color:#fff; transform: scale(1.05); } 84%,100% { } }
@keyframes wd-p1 { 0%,18% { } 20%,78% { background: linear-gradient(145deg,#4CAF50,#45a049); color:#fff; transform: scale(1.05); } 84%,100% { } }
@keyframes wd-p2 { 0%,31% { } 33%,78% { background: linear-gradient(145deg,#4CAF50,#45a049); color:#fff; transform: scale(1.05); } 84%,100% { } }
@keyframes wd-p3 { 0%,44% { } 46%,78% { background: linear-gradient(145deg,#4CAF50,#45a049); color:#fff; transform: scale(1.05); } 84%,100% { } }
@keyframes wd-p4 { 0%,57% { } 59%,78% { background: linear-gradient(145deg,#4CAF50,#45a049); color:#fff; transform: scale(1.05); } 84%,100% { } }

/* El dedo traza el camino con giros: derecha → diagonal ↘ → abajo → izquierda */
.wd-finger {
  position: absolute; top: 74px; left: 68px; font-size: 1.5rem;
  animation: wd-drag 3.6s ease-in-out infinite; will-change: transform; pointer-events: none;
}
@keyframes wd-drag {
  0%, 6% { transform: translate(0, 0); opacity: 0; }
  9% { transform: translate(0, 0); opacity: 1; }        /* S */
  20% { transform: translate(51px, 0); }                /* A: derecha */
  33% { transform: translate(102px, 45px); }            /* L: diagonal ↘ */
  46% { transform: translate(102px, 90px); }            /* T: abajo */
  59% { transform: translate(51px, 90px); opacity: 1; } /* O: izquierda */
  72% { transform: translate(51px, 90px); opacity: 0; }
  100% { transform: translate(0, 0); opacity: 0; }
}
.wd-word {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center;
  font-weight: 800; font-size: 1.1rem; color: #16a34a;
  animation: wd-pop 3.6s ease-in-out infinite;
}
@keyframes wd-pop {
  0%, 60% { opacity: 0; transform: scale(.7); }
  68% { opacity: 1; transform: scale(1.12); }
  78%, 84% { opacity: 1; transform: scale(1); }
  92%, 100% { opacity: 0; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .wd-cell[data-i], .wd-finger, .wd-word { animation: none; }
  .wd-cell[data-i] { background: linear-gradient(145deg,#4CAF50,#45a049); color: #fff; }
  .wd-finger { opacity: 0; }
  .wd-word { opacity: 1; }
}

/* Pista sobre la cuadrícula en la primera partida */
.first-game-hint {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  z-index: 1400; max-width: 90vw;
  background: rgba(15,23,42,.94); color: #fff; font-weight: 700; font-size: .95rem;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.3);
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
  animation: fgh-pulse 1.6s ease-in-out infinite;
}
.first-game-hint.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes fgh-pulse { 0%,100% { box-shadow: 0 6px 18px rgba(0,0,0,.3); } 50% { box-shadow: 0 6px 24px rgba(34,197,94,.6); } }
@media (prefers-reduced-motion: reduce) { .first-game-hint { animation: none; } }

/* ── Toast del bonus diario: centrado y dorado (a juego con las gemas) ── */
.bonus-toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.7);
  z-index: 3010; pointer-events: none; text-align: center;
  padding: 22px 34px; border-radius: 20px;
  background: linear-gradient(145deg, #fbbf24, #f59e0b);
  color: #3f2d00; box-shadow: 0 12px 40px rgba(245,158,11,.5), 0 0 0 4px rgba(255,255,255,.25) inset;
  opacity: 0; transition: opacity .28s ease, transform .28s cubic-bezier(.2,1.3,.4,1);
}
.bonus-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.bonus-toast-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 4px; }
.bonus-toast-amount { font-size: 2rem; font-weight: 900; letter-spacing: .5px; }
.bonus-toast-label { font-size: 1rem; font-weight: 700; opacity: .8; margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .bonus-toast { transition: opacity .2s ease; transform: translate(-50%,-50%) scale(1); } }

/* ── Auth: modal de nombre (proteger opcional) y login ── */
.auth-body { display: flex; flex-direction: column; gap: 12px; }
.auth-intro { color: var(--text-muted); }
.auth-field label { display: block; font-size: .82rem; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.auth-body input[type="text"],
.auth-body input[type="email"],
.auth-body input[type="password"] {
  width: 100%; padding: 11px 13px; border-radius: 11px; outline: none; font-size: .98rem;
}
.auth-body input:focus { border-color: var(--indigo, #6366f1); box-shadow: 0 0 0 3px rgba(99,102,241,.25); }
.auth-protect {
  border: 1px dashed var(--border-color); border-radius: 13px; padding: 12px 13px;
  display: flex; flex-direction: column; gap: 10px; background: rgba(99,102,241,.06);
}
.auth-protect-head { display: flex; align-items: center; justify-content: space-between; }
.auth-protect-head .lab { font-size: .9rem; font-weight: 800; color: var(--text-color); }
.auth-protect-head .opt {
  font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #6366f1; background: rgba(99,102,241,.16); padding: 3px 8px; border-radius: 999px;
}
.auth-hint { margin: 0; font-size: .8rem; color: var(--text-muted); line-height: 1.45; }
.auth-error { font-size: .84rem; color: #f87171; font-weight: 600; }
.auth-cta { width: 100%; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .78rem; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--border-color); flex: 1; }
.auth-google { display: flex; justify-content: center; min-height: 40px; }
.auth-login-link { text-align: center; font-size: .88rem; color: var(--text-muted); margin: 2px 0 0; }
.auth-login-link a { color: #6366f1; font-weight: 700; text-decoration: none; }

/* ── Barra de estado compacta de la home (racha · gemas · regalo) ─────── */
.home-status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 auto 4px;
  padding: 6px 10px;
  color: var(--text-color, #f8fafc);
  font-size: .95rem;
  opacity: .92;
}
.home-status-bar .hsb-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.home-status-bar .hsb-item strong { font-weight: 800; }
.home-status-bar .hsb-streak.hsb-at-risk { color: #f59e0b; }
/* Las gemas abren power-ups: pill sutil que se lee como tocable. */
.home-status-bar .hsb-gems {
  border: 1px solid rgba(217,70,239,.45);
  background: rgba(217,70,239,.12);
  color: inherit;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.home-status-bar .hsb-gems:active { transform: scale(.96); }

/* ── Tarjeta "próximo logro" en el fin de partida (meta concreta) ─────── */
.next-achievement-card {
  background: linear-gradient(145deg, rgba(99,102,241,.12), rgba(67,56,202,.12));
  border-color: rgba(99,102,241,.4);
}
.next-achievement-card .ach-progress {
  height: 8px; border-radius: 999px; background: rgba(148,163,184,.25); overflow: hidden; margin: 4px 0;
}
.next-achievement-card .ach-progress-bar {
  height: 100%; border-radius: 999px; background: linear-gradient(90deg,#6366f1,#a855f7); transition: width .5s ease;
}

/* ── Tienda de temas (dentro del modal de gemas) ──────────────────────── */
.theme-swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #888; flex-shrink: 0; display: inline-block; box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.theme-inuse { display: inline-block; min-width: 84px; text-align: center; font-weight: 700; color: var(--success); font-size: .85rem; }
.theme-buy-btn { background: linear-gradient(145deg,#8b5cf6,#6d28d9); }
.theme-use-btn { background: linear-gradient(145deg,#22c55e,#16a34a); }

/* ══ Home: dashboard + navegación inferior (refresco chess-like) ═══════════ */
#menuModal .menu-content { padding: 0; height: 100dvh; }
#menuModal .home-shell {
  display: flex; flex-direction: column;
  width: 100%; max-width: 560px; height: 100%; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 56px) 14px 0;
  box-sizing: border-box;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
}

/* Topbar: racha · logo · gemas.
   El safe-area superior (barra de estado / notch) se aplica AQUÍ, en la cabecera
   misma, que TODA página lleva (home y secundarias con .page-topbar). Así una
   página nueva no tiene que acordarse de envolverla para respetar la barra
   (era la causa del bug del header de duelos bajo la barra de Android). */
/* Safe-area superior como variable: por defecto env(safe-area-inset-top) (idéntico
   en dispositivo), pero al ser una var los tests e2e pueden sobrescribirla para
   simular el notch/barra de estado y cazar regresiones del header sin un móvil. */
:root { --safe-top: env(safe-area-inset-top, 0px); }
.home-topbar {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
  padding-top: var(--safe-top);
}
.home-topbar .home-logo-wrap { flex: 1 1 auto; text-align: center; min-width: 0; }
.home-logo {
  height: clamp(28px, 6vw, 38px); max-width: 42vw; width: auto; object-fit: contain;
  display: inline-block; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}
.hsb-chip {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  font-weight: 700; font-size: .95rem; white-space: nowrap;
  padding: 7px 13px; border-radius: 999px;
  color: var(--text-color, #f8fafc);
  border: 1px solid var(--border-color, rgba(148,163,184,.3));
  background: var(--surface-muted, rgba(148,163,184,.12));
}
.hsb-chip strong { font-weight: 800; }
/* Los chips que son botones medían 33px de alto: se les extiende el área táctil
   hasta los 44px con un pseudo-elemento, para no engordar la cabecera solo por
   ganar zona de dedo. */
button.hsb-chip { position: relative; }
button.hsb-chip::after {
  content: ''; position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 44px; min-width: 44px;
}
.hsb-chip.hsb-streak { border-color: rgba(249,115,22,.45); background: rgba(249,115,22,.14); }
.hsb-chip.hsb-gems, .hsb-chip.hsb-gems-static { border-color: rgba(217,70,239,.5); background: rgba(217,70,239,.14); }
.hsb-chip.hsb-gems { cursor: pointer; transition: transform .08s ease; }
.hsb-chip.hsb-gems:active { transform: scale(.95); }
/* En tema claro la cabecera va sobre el degradado morado → texto claro en los chips */
body.theme-light .home-topbar .hsb-chip { color: #f8fafc; }
/* El magenta tenue del chip de gemas se lavaba sobre el morado: lo hacemos más visible. */
body.theme-light .home-topbar .hsb-gems,
body.theme-light .home-topbar .hsb-gems-static {
  background: rgba(232,121,249,.28); border-color: rgba(232,121,249,.75);
}
body.theme-light .home-topbar .hsb-streak {
  background: rgba(249,115,22,.28); border-color: rgba(249,115,22,.75);
}
/* Duelos: el contenido va sobre el degradado morado → texto claro en modo claro. */
body.theme-light .duels-content { color: #f8fafc; }
/* Página de duelo (/duelo/id): contenido claro sobre el degradado; la cabecera
   conserva su color (el avatar va oscuro sobre su círculo claro; racha/gemas ya
   tienen su color propio). Los chips de marcador/timer usan color propio. */
body.theme-light#duel-page { --text-color: #f8fafc; }
body.theme-light#duel-page .page-topbar { --text-color: #111827; }

/* Avatar de perfil (arriba a la izquierda) */
.home-topbar-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.home-avatar {
  position: relative; flex-shrink: 0;
  /* 44px es el mínimo táctil recomendado; estaba en 42 y se quedaba justo. */
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 1.35rem;
  color: var(--text-color, #f8fafc);
  background: var(--surface-muted, rgba(148,163,184,.16));
  border: 1px solid var(--border-color, rgba(148,163,184,.35));
  transition: transform .08s ease;
}
.home-avatar:active { transform: scale(.94); }
.home-avatar-ic { line-height: 1; }
.home-avatar-dot {
  position: absolute; top: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 2px var(--overlay-bg, #0b1220);
}
.home-avatar-level {
  position: absolute; bottom: -5px; right: -5px;
  min-width: 22px; height: 22px; padding: 0 3px; box-sizing: border-box;
  display: none; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  font: 900 11px/1 system-ui, -apple-system, sans-serif;
  border: 2px solid #111827; border-radius: 11px;
  box-shadow: 0 2px 6px rgba(0,0,0,.6);
  pointer-events: none; z-index: 10;
}

/* Iconos reicon (SVG monocromo, se tiñen con currentColor) */
.ic { width: 1em; height: 1em; display: inline-block; vertical-align: middle; fill: currentColor; flex-shrink: 0; }
/* Colores canónicos de iconos: iguales a los del HUD durante la partida
   (.pu-inline-btn.* y .gem-counter-mini) para que el modal de gemas no confunda.
   OJO: hay que colorear también el <use> hijo. El path del sprite pinta con
   fill="currentColor" y hereda el color del <use> (su host), NO del <svg>. La
   regla ancha `body.theme-dark .ranking-card *` (!important) alcanza ese <use>
   y lo forzaba a var(--text-color) (blanco) → icono blanco pese al color del
   <svg>. Scopeado a #powerupsModal (id) para ganar en specificity + !important. */
#powerupsModal .ic-c-gem,    #powerupsModal .ic-c-gem use    { color: #e879f9 !important; }
#powerupsModal .ic-c-bomb,   #powerupsModal .ic-c-bomb use   { color: #ef4444 !important; }
#powerupsModal .ic-c-row,    #powerupsModal .ic-c-row use    { color: #f97316 !important; }
#powerupsModal .ic-c-column, #powerupsModal .ic-c-column use { color: #8b5cf6 !important; }
#powerupsModal .ic-c-flame,  #powerupsModal .ic-c-flame use  { color: #f97316 !important; }
#powerupsModal .ic-c-trophy, #powerupsModal .ic-c-trophy use { color: #f59e0b !important; }
.home-avatar .ic { width: 22px; height: 22px; }
/* Iconos en cabeceras de modal (heredan el color del título) */
.modal-title .ic { width: 22px; height: 22px; vertical-align: -3px; }
.ranking-title .ic { width: 18px; height: 18px; vertical-align: -3px; }
.tab-btn .ic { width: 16px; height: 16px; vertical-align: -3px; }
/* Fila de pestañas que reparte el ancho en columnas iguales, en una sola línea. */
.tabs--fit { flex-wrap: nowrap; gap: 6px; }
.tabs--fit .tab-btn {
  flex: 1 1 0; min-width: 0; justify-content: center;
  padding: 8px 4px; font-size: clamp(.72rem, 3vw, .84rem); white-space: nowrap;
}
.tabs--fit .tab-btn .ic { width: 14px; height: 14px; }
.levels-streak-flame .ic { color: #f97316; }
.home-hero-icon { color: #fff; }
.home-hero-icon .ic { width: 26px; height: 26px; }
.home-tile-icon .ic, .home-card-icon .ic { width: 24px; height: 24px; }
.home-nav-ic .ic { width: 24px; height: 24px; }

/* Iconos temáticos (emoji que sustituyen al SVG según el tema, ver themeIcons.js).
   Se dimensionan por font-size para casar aprox. con el tamaño del SVG en cada sitio. */
.ticon { display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-style: normal; vertical-align: middle; pointer-events: none; }
.home-tile-icon .ticon { font-size: 1.05rem; }
.ht-head .home-tile-icon .ticon { font-size: 1rem; }
.home-hero-icon .ticon { font-size: 1.5rem; }
.home-nav-ic .ticon { font-size: 1.3rem; }
.home-avatar .ticon { font-size: 1.3rem; }
.hsb-chip .ticon { font-size: .95rem; }
.modal-title .ticon { font-size: 1.2rem; }
/* Banner informativo (oculto por defecto; se activa con showHomeBanner) */
.home-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 16px;
  background: linear-gradient(145deg, rgba(59,130,246,.16), rgba(139,92,246,.16));
  border: 1px solid rgba(99,102,241,.45);
  color: var(--text-color, #f8fafc);
}
.home-banner-ic { font-size: 1.4rem; flex-shrink: 0; }
.home-banner-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: inherit; }
.home-banner-title { font-weight: 800; font-size: .98rem; color: var(--heading, #f1f5f9); }
.home-banner-title:empty { display: none; }
.home-banner-text { font-size: .84rem; color: var(--text-muted, #cbd5e1); font-weight: 600; }
.home-banner-close {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 999px;
  border: none; background: transparent; color: var(--text-muted, #94a3b8);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.home-banner-close:active { transform: scale(.9); }

.home-tile--rankings .home-tile-icon { color: #3b82f6; }
.home-tile--stats .home-tile-icon { color: #a855f7; }
.home-tile--history .home-tile-icon { color: #14b8a6; }
.home-tile--achievements .home-tile-icon { color: #f59e0b; }

/* Iconos en los chips de arriba (relleno + color) */
.hsb-chip .ic { width: 17px; height: 17px; }
.hsb-chip.hsb-streak .ic { color: #f97316; }
.hsb-chip.hsb-gems .ic, .hsb-chip.hsb-gems-static .ic { color: #e879f9; }

/* Iconos de las filas del menú "Más" */
.more-row .ic { width: 22px; height: 22px; }
.more-row-ic { display: inline-flex; align-items: center; justify-content: center; }
.more-row-ic--help .ic { color: #3b82f6; }
.more-row-ic--msg .ic { color: #14b8a6; }
.more-row-ic--heart .ic { color: #ef4444; }
.more-row-ic--set .ic { color: #94a3b8; }

/* Duelos: escudo relleno + color naranja cuando hay pendientes */
.home-nav-item.nav-alert { color: #f97316; }
.home-nav-item.nav-alert .home-nav-ic { opacity: 1; }


/* Zona superior: saludo y avisos. */
/* Crece para empujar la acción a la zona del pulgar cuando sobra alto, pero NO se
   comprime (flex-shrink: 0): con el scroll ya en .home-shell, dejarla encogible
   la achataba por debajo del alto del saludo y —al ir centrado y desbordado— el
   texto se colaba bajo la cabecera flotante y bajo la tarjeta del regalo. */
.home-top {
  flex: 1 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 12px 2px; text-align: center;
}
.home-greet { display: flex; flex-direction: column; gap: 4px; }
.home-greet-hi { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; color: var(--heading, #f1f5f9); }
.home-greet-sub { font-size: .95rem; font-weight: 600; color: var(--text-muted, #94a3b8); }
/* En claro el saludo va directamente sobre el degradado morado: el --heading navy
   y el --text-muted gris del tema se pierden ahí → texto claro, como en .reto-title. */
body.theme-light .home-greet-hi { color: #f8fafc; }
body.theme-light .home-greet-sub { color: rgba(248, 250, 252, .85); }

/* Zona baja: tarjetas informativas arriba, botón de jugar al fondo. No crece
   (queda anclada abajo); si el conjunto no cupiera, encoge la zona superior. */
.home-dash {
  flex: 0 0 auto;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
  padding: 8px 2px 4px;
}

/* Hero: nueva partida */
.home-hero {
  display: flex; align-items: center; gap: 14px; text-align: left;
  width: 100%; border: none; cursor: pointer;
  padding: 20px 18px; border-radius: 20px; color: #fff;
  background: linear-gradient(145deg, #22c55e, #15803d);
  box-shadow: 0 10px 24px rgba(21,128,61,.35);
  transition: transform .1s ease, box-shadow .12s ease;
}
.home-hero:active { transform: translateY(1px) scale(.995); box-shadow: 0 6px 16px rgba(21,128,61,.3); }
.home-hero-icon {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; font-size: 1.5rem; background: rgba(255,255,255,.2);
}
.home-hero-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home-hero-title { font-size: 1.35rem; font-weight: 800; letter-spacing: .2px; }
.home-hero-sub { font-size: .85rem; opacity: .9; font-weight: 600; }
.home-hero-go { flex-shrink: 0; font-size: 1.9rem; font-weight: 700; opacity: .75; line-height: 1; }

/* Tarjeta ancha (reto, instalar) */
.home-card {
  display: flex; align-items: center; gap: 13px; text-align: left;
  width: 100%; cursor: pointer; padding: 15px; border-radius: 18px;
  color: var(--text-color, #f8fafc);
  background: var(--surface, #1e293b);
  border: 1px solid var(--border-color, rgba(148,163,184,.22));
  transition: transform .1s ease;
}
.home-card:active { transform: translateY(1px) scale(.995); }
.home-card-icon {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.4rem;
}
.home-card--reto .home-card-icon { background: rgba(239,68,68,.16); }
.home-card--install .home-card-icon { background: rgba(14,165,233,.16); }
.home-card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home-card-title { font-size: 1.08rem; font-weight: 800; color: var(--heading, #f1f5f9); }
.home-card-sub { font-size: .82rem; color: var(--text-muted, #94a3b8); font-weight: 600; }
.home-card-cta {
  flex-shrink: 0; font-weight: 800; font-size: .9rem; color: #fff;
  padding: 8px 16px; border-radius: 999px;
  background: linear-gradient(145deg, #ef4444, #b91c1c);
}
.home-card--install .home-card-cta { background: linear-gradient(145deg, #0ea5e9, #0284c7); }
.home-card--rankings .home-card-icon { background: rgba(59,130,246,.18); }
.home-card-cta--rank { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.home-card--stats .home-card-icon { background: rgba(168,85,247,.18); }
.home-card-cta--stats { background: linear-gradient(145deg, #a855f7, #7c3aed); }

/* Card de Regalo Diario */
.home-card--bonus {
  background: linear-gradient(145deg, rgba(251,191,36,.2), rgba(245,158,11,.16));
  border: 1.5px solid rgba(251,191,36,.55);
  box-shadow: 0 4px 16px rgba(251,191,36,.18);
  cursor: pointer;
  display: flex; align-items: center; gap: 14px; text-align: left;
  width: 100%; border-radius: 20px; padding: 14px 16px;
}
.home-card--bonus .home-card-icon {
  background: rgba(251,191,36,.25);
  color: #fbbf24;
}
.home-card--bonus .home-card-icon .ic {
  width: 22px; height: 22px; color: #fbbf24;
}
.home-card-cta--bonus {
  background: linear-gradient(145deg, #fbbf24, #d97706);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(245,158,11,.4);
  font-weight: 800; font-size: .88rem;
  padding: 8px 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.home-card-cta--bonus .ic {
  width: 15px; height: 15px; color: #0f172a;
}
#dailyBonusBtn.bonus-attention {
  animation: bonus-card-pulse 1.8s ease-in-out infinite;
}
@keyframes bonus-card-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(251,191,36,.25); transform: scale(1); }
  50% { box-shadow: 0 4px 22px rgba(251,191,36,.5); transform: scale(1.015); }
}
/* Debe ir DESPUÉS de la regla animada: misma especificidad, así que si se
   declarase antes (como cuando el pulso vivía en la barra superior) el
   `animation` la pisaría y el pulso seguiría corriendo con movimiento reducido. */
@media (prefers-reduced-motion: reduce) {
  #dailyBonusBtn.bonus-attention { animation: none; box-shadow: 0 0 0 3px rgba(251,191,36,.45); }
}

/* Grid 2 columnas (duelos, niveles) */
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-tile {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  text-align: left; text-decoration: none; cursor: pointer;
  padding: 16px 15px; border-radius: 18px;
  color: var(--text-color, #f8fafc);
  background: var(--surface, #1e293b);
  border: 1px solid var(--border-color, rgba(148,163,184,.22));
  transition: transform .1s ease;
}
.home-tile:active { transform: translateY(1px) scale(.99); }
.home-tile-icon {
  width: 42px; height: 42px; border-radius: 13px; margin-bottom: 4px;
  display: grid; place-items: center; font-size: 1.3rem;
}
.home-tile--duelos .home-tile-icon { background: rgba(249,115,22,.18); }
.home-tile--niveles .home-tile-icon { background: rgba(99,102,241,.18); }
.home-tile--rankings .home-tile-icon { background: rgba(59,130,246,.18); }
.home-tile--stats .home-tile-icon { background: rgba(168,85,247,.18); }
.home-tile--history .home-tile-icon { background: rgba(20,184,166,.18); }
.home-tile--achievements .home-tile-icon { background: rgba(245,158,11,.18); }
.home-tile-title { font-size: 1.05rem; font-weight: 800; color: var(--heading, #f1f5f9); }
.home-tile-sub { font-size: .78rem; color: var(--text-muted, #94a3b8); font-weight: 600; }
.home-tile-badge {
  position: absolute; top: 12px; right: 12px; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f97316; color: #fff; font-size: .72rem; font-weight: 800;
  box-shadow: 0 0 0 2px var(--surface, #1e293b);
}
.home-tile-new { position: absolute; top: 10px; right: 10px; }

/* Tarjetas informativas de la home: cabecera (icono+título) + dato grande, con
   rotación de facetas en Estadísticas (×3) y Logros (×2). */
.home-tile--rankings, .home-tile--stats, .home-tile--progress,
.home-tile--history, .home-tile--achievements { gap: 8px; overflow: hidden; }
/* Franja de acento superior por tarjeta (más vistoso, mismo color que el icono) */
.home-tile--rankings::before, .home-tile--stats::before, .home-tile--progress::before,
.home-tile--history::before, .home-tile--achievements::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; opacity: .95;
}
.home-tile--rankings::before { background: linear-gradient(90deg, #60a5fa, #2563eb); }
.home-tile--stats::before    { background: linear-gradient(90deg, #c084fc, #7c3aed); }
.home-tile--history::before  { background: linear-gradient(90deg, #2dd4bf, #0d9488); }
.home-tile--achievements::before { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.ht-head { display: flex; align-items: center; gap: 8px; }
/* En estas tarjetas el icono es más compacto e inline (no el bloque de 42px) */
.ht-head .home-tile-icon { width: 30px; height: 30px; border-radius: 9px; margin-bottom: 0; font-size: 1rem; }
.ht-head .home-tile-icon .ic { width: 18px; height: 18px; }
.ht-head .home-tile-title { font-size: .98rem; }
.ht-dots { margin-left: auto; display: flex; gap: 4px; }
.ht-dots.is-hidden { display: none; }
.ht-dot { width: 5px; height: 5px; border-radius: 50%; background: rgba(148,163,184,.4); transition: background .3s ease; }
.ht-dot.is-on { background: var(--heading, #f1f5f9); }
.ht-stack { position: relative; min-height: 52px; }
.ht-facet { display: flex; flex-direction: column; gap: 5px; transition: opacity .42s ease, transform .42s ease; }
.ht-facet:not(.is-on) { position: absolute; inset: 0; opacity: 0; transform: translateY(7px); pointer-events: none; }
.ht-facet.is-on { opacity: 1; transform: none; }
.ht-facet.is-hidden { display: none; }
.ht-big { font-size: 1.5rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: var(--heading, #f1f5f9); font-variant-numeric: tabular-nums; }
.ht-sub { font-size: .76rem; color: var(--text-muted, #94a3b8); font-weight: 600; }
.ht-xpbar { height: 6px; border-radius: 999px; background: rgba(148,163,184,.22); overflow: hidden; }
.ht-xpbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #c084fc, #7c3aed); transition: width .5s ease; }
@media (prefers-reduced-motion: reduce) { .ht-facet { transition: none; } }

/* Almacén de avatares: rejilla de emoji canjeables. */
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.avatar-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  background: rgba(125, 130, 150, .12);
  border: 1px solid rgba(125, 130, 150, .28);
  transition: transform .08s ease, border-color .15s ease;
}
.avatar-cell:active { transform: scale(.94); }
.avatar-cell-emoji { font-size: 1.7rem; line-height: 1; }
.avatar-cell.is-selected { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99, 102, 241, .8); background: rgba(99, 102, 241, .14); }
.avatar-cell.is-locked .avatar-cell-emoji { opacity: .55; filter: grayscale(.4); }
.avatar-cell-check { position: absolute; top: 1px; right: 4px; color: #6366f1; font-weight: 800; font-size: .8rem; }
.avatar-cell-price { position: absolute; bottom: 1px; left: 0; right: 0; text-align: center; font-size: .58rem; font-weight: 700; color: #c084fc; }
/* Emoji del avatar elegido en la cabecera. */
.home-avatar-emoji { font-size: 1.35rem; line-height: 1; }

/* Navegación inferior persistente */
/* sticky bottom: .home-shell scrollea, y sin esto la barra —último hijo del
   contenedor— se iba fuera del viewport en cuanto el contenido desbordaba
   (263px de desborde en 360x640), obligando a bajar hasta el final para verla. */
.home-nav {
  flex-shrink: 0; display: flex; align-items: stretch; gap: 2px;
  position: sticky; bottom: 0; z-index: 2;
  margin: 10px -14px 0; padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: var(--surface, #0f172a);
  border-top: 1px solid var(--border-color, rgba(148,163,184,.2));
}
.home-nav-item {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  padding: 6px 2px; border-radius: 12px;
  color: var(--text-muted, #94a3b8);
  transition: color .12s ease, background .12s ease;
}
.home-nav-ic { display: inline-flex; line-height: 1; opacity: .72; }
.home-nav-lb { font-size: .72rem; font-weight: 700; }
.home-nav-item.is-active { color: var(--heading, #f8fafc); }
.home-nav-item.is-active .home-nav-ic { opacity: 1; }
.home-nav-item:active { background: var(--surface-muted, rgba(148,163,184,.12)); }
.home-nav-dot {
  position: absolute; top: 4px; right: calc(50% - 19px);
  width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 2px var(--surface, #0b1220);
}
.home-nav-item { text-decoration: none; }
.home-nav-badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f97316; color: #fff; font-size: .68rem; font-weight: 800;
  box-shadow: 0 0 0 2px var(--overlay-bg, #0b1220);
}
.home-nav-new {
  position: absolute; top: -2px; right: calc(50% - 30px);
  transform: scale(.82); transform-origin: right top;
}
/* Aviso de novedad en Niveles: solo una bolita de color (sin "NUEVO" ni glow) */
.home-nav-newdot {
  position: absolute; top: 5px; right: calc(50% - 17px);
  width: 9px; height: 9px; border-radius: 50%;
  background: #f59e0b; box-shadow: 0 0 0 2px var(--surface, #0f172a);
}
.home-nav-item.levels-menu-attention { animation: none; box-shadow: none; }

/* Barra de navegación fija reutilizada en páginas secundarias (Duelos, Niveles) */
.home-nav--fixed {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1200;
  margin: 0 auto; max-width: 560px;
  padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: var(--surface, #0f172a);
  border-top: 1px solid var(--border-color, rgba(148,163,184,.2));
}
/* Niveles (mapa): cabecera fija (solo scrollea la lista) y CTA pegado a la barra. */
/* Con soft-nav el contenido va dentro de #app-view; para no romper la cadena flex
   del layout de niveles, #app-view asume el rol de columna flexible. */
.levels-map-page #app-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; }
.levels-map-page .page-topbar { flex-shrink: 0; }
.levels-map-page .levels-wrap {
  flex: 1 1 auto; min-height: 0; width: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}
.levels-map-page .levels-footer { bottom: calc(66px + env(safe-area-inset-bottom)); padding: 10px 16px 10px; }

/* Cabecera compartida en páginas secundarias */
/* El <body> ya aporta 14px laterales y 10px arriba (regla global de game.css);
   la cabecera compartida no añade padding propio para que quede igual que la home. */
.page-topbar {
  width: 100%; max-width: 560px; margin: 0 auto 10px; box-sizing: border-box;
  /* NO poner padding aquí: el safe-area superior lo aporta .home-topbar (que esta
     cabecera también lleva). Un `padding` shorthand aquí pisaría ese padding-top
     y dejaría el header bajo la barra de estado en niveles/reto/duelo. */
}
.page-topbar .home-avatar { text-decoration: none; }
.page-topbar .hsb-gems { text-decoration: none; }

/* Botón flotante "crear duelo" (sustituye al + de la cabecera) */
.duel-fab {
  position: fixed; right: 16px; z-index: 1210;
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(145deg, #f97316, #ea580c); color: #fff; border: none;
  font-size: 1.7rem; font-weight: 800; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px rgba(249,115,22,.45);
  display: flex; align-items: center; justify-content: center;
}
.duel-fab:active { transform: scale(.94); }

/* Página Reto (/reto) */
.reto-page { display: flex; flex-direction: column; min-height: 100dvh; }
/* Con soft-nav el contenido va dentro de #app-view; sin esto, el body (flex column
   con align-items:center) encoge #app-view al ancho de su contenido y la cabecera
   sale más estrecha que en niveles/home. #app-view asume la columna flexible y
   ocupa el ancho completo (mismo arreglo que .levels-map-page #app-view). */
.reto-page #app-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; }
.reto-wrap {
  flex: 1 1 auto; width: 100%; max-width: 560px; margin: 0 auto; box-sizing: border-box;
  padding: 8px 18px calc(80px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.reto-hero { display: flex; flex-direction: column; align-items: center; width: 100%; }
.reto-hero-icon {
  width: 84px; height: 84px; border-radius: 26px; margin-bottom: 14px;
  display: grid; place-items: center; color: #ef4444;
  background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.35);
}
.reto-hero-icon .ic { width: 44px; height: 44px; }
.reto-title { margin: 0 0 6px; font-size: 1.7rem; font-weight: 800; color: var(--heading, #f1f5f9); }
.reto-sub { margin: 0 0 22px; color: var(--text-muted, #94a3b8); font-weight: 600; font-size: .95rem; }
.reto-prize { display: inline-flex; align-items: center; gap: 6px; margin: -14px 0 22px; font-weight: 700; color: #e879f9; font-size: .9rem; }
.reto-prize .ic { width: 16px; height: 16px; }
.reto-state { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.reto-play-btn {
  display: inline-block; width: 100%; max-width: 340px; padding: 16px; border-radius: 16px;
  text-decoration: none; font-size: 1.15rem; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, #22c55e, #15803d); box-shadow: 0 8px 22px rgba(21,128,61,.35);
}
.reto-play-btn:active { transform: translateY(1px); }
.reto-play-btn[hidden] { display: none; }
.reto-streak { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #f97316; font-size: .95rem; }
.reto-streak .ic { width: 18px; height: 18px; }
.reto-result {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface, #1e293b); border: 1px solid var(--border-color, rgba(148,163,184,.22));
  border-radius: 16px; padding: 16px 28px; min-width: 200px;
}
.reto-result-word { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; color: var(--heading, #f1f5f9); text-transform: uppercase; }
.reto-result-pts { font-size: 1.1rem; font-weight: 800; color: var(--accent, #a855f7); }
.reto-msg { color: var(--text-muted, #94a3b8); font-weight: 600; max-width: 320px; }
.reto-msg-sm { color: var(--text-muted, #94a3b8); font-size: .85rem; font-weight: 600; margin-top: 4px; }
.reto-ghost-btn {
  margin-top: 26px; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  background: var(--surface-muted, rgba(148,163,184,.12));
  border: 1px solid var(--border-color, rgba(148,163,184,.25));
  color: var(--text-color, #e5e7eb); font-weight: 700; font-size: .9rem;
  text-decoration: none;
}
.reto-ghost-btn .ic { width: 18px; height: 18px; }
.reto-ghost-btn[hidden] { display: none; }
.reto-yesterday-card {
  margin-top: 14px; width: 100%; max-width: 340px;
  background: var(--surface, #1e293b); border: 1px solid var(--border-color, rgba(148,163,184,.22));
  border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.reto-yesterday-card[hidden] { display: none; }
.reto-yh-title { font-weight: 800; color: var(--heading, #f1f5f9); font-size: .95rem; }
/* Modo claro: los textos que van sobre el degradado morado, en claro (las
   tarjetas de resultado/ayer son claras y conservan su texto oscuro). */
body.theme-light.reto-page .reto-title { color: #f8fafc; }
body.theme-light.reto-page .reto-sub,
body.theme-light.reto-page .reto-msg,
body.theme-light.reto-page #reto-state > .reto-msg-sm { color: rgba(248,250,252,.85); }

/* Modal "Más" */
.more-list { display: flex; flex-direction: column; gap: 8px; }
.more-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; cursor: pointer; padding: 14px; text-decoration: none;
  border-radius: 14px; font-size: 1rem; font-weight: 700;
  color: var(--text-color, #f8fafc);
  background: var(--surface-muted, rgba(148,163,184,.1));
  border: 1px solid var(--border-color, rgba(148,163,184,.18));
  transition: transform .08s ease;
}
.more-row:active { transform: scale(.99); }
.more-row-ic { font-size: 1.25rem; width: 28px; text-align: center; flex-shrink: 0; }
.more-row-lb { flex: 1 1 auto; }
.more-row-go { color: var(--text-muted, #94a3b8); font-size: 1.3rem; }
.more-footer { text-align: center; color: var(--text-muted, #94a3b8); font-size: .82rem; margin-top: 14px; }
.more-footer-heart { width: 15px; height: 15px; color: #ef4444; vertical-align: -2px; }

@media (prefers-reduced-motion: reduce) {
  .home-hero, .home-card, .home-tile, .home-nav-item, .more-row { transition: none; }
}

/* Variantes de .btn reutilizables (evitan backgrounds/paddings inline sueltos). */
.btn-primary { background: linear-gradient(145deg,#4f46e5,#7c3aed); color: #fff; }
.btn-success { background: linear-gradient(145deg,#22c55e,#16a34a); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.15); color: inherit; border: 1px solid rgba(255,255,255,.25); }
.btn-secondary, #confirmModalCancel {
  background: var(--surface-muted, rgba(255, 255, 255, 0.12));
  color: var(--text-color, #ffffff);
  border: 1px solid var(--border-color-soft, rgba(255, 255, 255, 0.2));
}
body.theme-light .btn-secondary,
body.theme-light #confirmModalCancel {
  background: #f1f5f9 !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1 !important;
}
body.theme-light .btn-secondary:hover,
body.theme-light #confirmModalCancel:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

.profile-quick-btn {
  background: var(--surface-muted, rgba(255, 255, 255, 0.08));
  color: var(--text-color, #ffffff);
  border: 1px solid var(--border-color-soft, rgba(255, 255, 255, 0.15));
  font-size: .85rem; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; border-radius: 10px;
}
body.theme-light .profile-quick-btn {
  background: #f1f5f9 !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1 !important;
}
body.theme-light .profile-quick-btn:hover {
  background: #e2e8f0 !important;
}
.btn-primary .ic, .btn-success .ic, .btn-ghost .ic { width: 18px; height: 18px; margin-right: 4px; vertical-align: -3px; }

/* Cabecera + HUD persistentes (fuera de #menuModal y #section-game, visibles
   tanto en el dashboard como durante la partida). */
.home-shell-persistent {
  /* Sticky: la cabecera se queda fija arriba al hacer scroll (antes se iba con el
     contenido en /duelos). Fondo esmerilado para no transparentar lo que pasa por
     detrás; el safe-area superior lo sigue aportando .home-topbar (dentro). */
  position: sticky; top: 0; z-index: 1550;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  /* SIN fondo en reposo: cualquier color aquí se veía como un rectángulo flotante
     sobre el fondo del tema. El esmerilado (abajo, .shell-frosted) solo aparece
     mientras hay contenido desplazado por debajo (lo activa shellFrost.js con el
     scroll de página, p. ej. la lista de /duelos), y se tiñe de la --surface del
     TEMA ACTIVO para fundirse con él. */
  background: transparent;
  transition: background .25s ease;
}
.home-shell-persistent.shell-frosted {
  background: rgba(11, 16, 32, .72); /* fallback sin color-mix */
  background: color-mix(in srgb, var(--surface, #0b1020) 74%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
/* En claro el fondo de página es el degradado morado (#667eea→#764ba2) y los chips
   de la cabecera usan texto claro: el esmerilado se tiñe del mismo morado (la
   --surface del tema claro es blanca, que aquí sería un rectángulo blanco). */
body.theme-light .home-shell-persistent.shell-frosted { background: rgba(96, 112, 226, .68); }

/* ─────────────────────────────────────────────────────────────────────────
   Force-update de la app nativa (nativeUpdateGate.js). Pantalla bloqueante
   (.nug-gate) y aviso descartable (.nug-banner). Solo aparecen dentro de la app.
   ───────────────────────────────────────────────────────────────────────── */
html.nug-locked, html.nug-locked body { overflow: hidden; }
.nug-gate {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  padding-top: calc(24px + env(safe-area-inset-top));
  background: rgba(7, 11, 23, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nug-card {
  width: 100%; max-width: 400px; text-align: center;
  background: linear-gradient(160deg, #131a2e, #0d1424);
  border: 1px solid rgba(148,163,184,.18); border-radius: 22px;
  padding: 30px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.nug-icon { font-size: 2.6rem; line-height: 1; margin-bottom: 12px; }
.nug-title { margin: 0 0 8px; font-size: 1.4rem; font-weight: 800; color: #f8fafc; }
.nug-text { margin: 0 0 22px; color: rgba(226,232,240,.82); font-size: 1rem; line-height: 1.45; }
.nug-btn {
  width: 100%; border: none; cursor: pointer;
  padding: 14px 18px; border-radius: 14px;
  font-size: 1.05rem; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, #f97316, #ea580c);
  box-shadow: 0 8px 22px rgba(249,115,22,.4);
}
.nug-btn:active { transform: scale(.97); }

.nug-banner {
  position: fixed; z-index: 1560; left: 12px; right: 12px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(19, 26, 46, .96);
  border: 1px solid rgba(148,163,184,.22);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  color: #f8fafc;
}
.nug-banner-text { flex: 1 1 auto; font-size: .92rem; font-weight: 600; }
.nug-banner-update {
  flex-shrink: 0; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, #f97316, #ea580c);
}
.nug-banner-update:active { transform: scale(.96); }
.nug-banner-close {
  flex-shrink: 0; border: none; background: transparent; cursor: pointer;
  color: rgba(226,232,240,.7); font-size: 1rem; padding: 6px 8px; line-height: 1;
}

/* ─────────────────────────────────────────────────────────────────────────
   Pantalla de resultado premium (compartida por duelo y reto). Eleva el patrón
   de la tarjeta de niveles (.levels-result-*) a un componente reutilizable.
   Firma del duelo: el marcador grande TÚ–RIVAL (.result-scoreboard).
   ───────────────────────────────────────────────────────────────────────── */
.result-screen {
  display: flex; align-items: safe center; justify-content: center;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  width: 100%;
}
.result-card {
  width: 100%; max-width: 440px; 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: 26px 20px; box-shadow: 0 18px 40px rgba(0,0,0,.45);
  animation: result-card-in .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes result-card-in { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
.result-verdict-icon { line-height: 1; animation: result-icon-in .6s cubic-bezier(.34, 1.56, .64, 1) .12s both; }
.result-verdict-icon .ic { width: 3rem; height: 3rem; color: rgba(255,255,255,.5); }
.result-card.win .result-verdict-icon .ic { color: #fbbf24; filter: drop-shadow(0 0 14px rgba(251,191,36,.55)); }
@keyframes result-icon-in { from { opacity: 0; transform: scale(0) rotate(-25deg); } 60% { transform: scale(1.2) rotate(6deg); } to { opacity: 1; transform: none; } }
.result-verdict { margin: 8px 0 0; font-size: 1.4rem; font-weight: 800; }
.result-subtitle { margin: 4px 0 0; opacity: .7; font-size: .92rem; line-height: 1.4; }

/* Marcador TÚ–RIVAL (firma del duelo) */
.result-scoreboard { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 16px 0 4px; }
.rsb-side { display: flex; flex-direction: column; gap: 3px; min-width: 92px; max-width: 120px; }
.rsb-name { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsb-score { font-size: 3rem; font-weight: 900; line-height: 1; color: rgba(255,255,255,.85); }
.result-card.win .rsb-you .rsb-score { color: #4ade80; text-shadow: 0 0 18px rgba(74,222,128,.5); }
.result-card.lose .rsb-them .rsb-score { color: #f87171; }
.rsb-vs { font-size: 1.5rem; font-weight: 800; opacity: .35; }

/* Insignia de XP ganada */
.result-xp { display: inline-flex; align-items: center; gap: 6px; margin: 12px auto 2px; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: .95rem; background: rgba(251,191,36,.14); border: 1px solid rgba(251,191,36,.3); color: #fbbf24; }
.result-xp .ic { width: 1.05rem; height: 1.05rem; }

/* Ronda a ronda */
.result-rounds { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 20px; }
.rr { display: grid; grid-template-columns: 2.4em 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06); font-size: .86rem; }
.rr.won { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.25); }
.rr.lost { background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.22); }
.rr-n { font-weight: 800; opacity: .55; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
.rr-you, .rr-them { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-you { text-align: right; font-weight: 700; }
.rr-them { text-align: left; opacity: .75; }
.rr-pts { opacity: .55; font-weight: 600; }
.rr-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.25); box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.rr.won .rr-dot { background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,.6); }
.rr.lost .rr-dot { background: #f87171; }

/* Acciones (CTAs claros, siempre presentes: nadie sin salida) */
.result-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.result-actions .btn { text-decoration: none; display: block; padding: 13px; font-size: 1rem; }
.result-btn-primary { background: linear-gradient(145deg,#fb923c,#ea580c) !important; box-shadow: 0 6px 18px rgba(249,115,22,.4); color: #fff !important; }
.result-btn-secondary { background: rgba(255,255,255,.12) !important; border: 1px solid rgba(255,255,255,.2) !important; }

@media (prefers-reduced-motion: reduce) {
  .result-card, .result-verdict-icon { animation: none !important; }
}

/* Métricas grandes para el resultado del reto (una sola palabra/puntuación) */
.result-word { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-top: 16px; overflow-wrap: anywhere; }
.result-score { font-size: 2.6rem; font-weight: 900; line-height: 1.1; margin-top: 12px; background: linear-gradient(135deg, #fbbf24, #f97316); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.result-metric-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; opacity: .55; margin-top: 2px; }

/* ─────────────────────────────────────────────────────────────────────────
   Modal de fin de partida (juego clásico) — look premium coherente con las
   pantallas de resultado, y theme-aware (antes tenía fondos claros hardcodeados
   que desentonaban en tema oscuro). Conserva todos los ids que rellena el JS.
   ───────────────────────────────────────────────────────────────────────── */
#endGameModal .modal-content { max-width: 440px; }
#endGameModal .modal-title .ic { width: 1.3rem; height: 1.3rem; color: #fbbf24; filter: drop-shadow(0 0 8px rgba(251,191,36,.45)); }
.eg-score-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin: 0; }
.eg-score { font-size: 2.9rem; font-weight: 900; line-height: 1.1; margin: 2px 0 16px; background: linear-gradient(135deg,#fbbf24,#f97316); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.eg-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.eg-stat { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 10px 8px; min-width: 0; text-align: center; }
.eg-stat-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; opacity: .6; margin-bottom: 3px; }
.eg-stat-value { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.eg-stat-meta { font-size: .64rem; opacity: .55; margin-top: 2px; min-height: .8em; }
.eg-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 12px 14px; margin: 12px 0; text-align: left; }
.eg-card-title { display: flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 800; margin: 0 0 8px; }
.eg-card-title .ic { width: 1.05rem; height: 1.05rem; }
.eg-xp-total { font-size: 1.7rem; font-weight: 900; margin-bottom: 6px; background: linear-gradient(135deg,#fbbf24,#f97316); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.eg-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.eg-actions .btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; font-size: 1rem; }
.eg-actions-row { display: flex; gap: 10px; }
.eg-actions-row .btn { flex: 1; }
.eg-btn-primary { background: linear-gradient(145deg,#fb923c,#ea580c) !important; box-shadow: 0 6px 18px rgba(249,115,22,.4); color: #fff !important; }
.eg-btn-secondary { background: rgba(255,255,255,.12) !important; border: 1px solid rgba(255,255,255,.2) !important; }
.eg-actions-top { margin: 0 0 14px; }
.eg-compare { margin: -8px 0 14px; font-size: .9rem; font-weight: 700; opacity: .85; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; }
.eg-compare .up { color: #4ade80; }
.eg-compare .down { color: #fb923c; }
.eg-compare .record { color: #fbbf24; }
.eg-autonext { margin: -4px 0 0; font-size: .78rem; opacity: .7; }
.eg-autonext b { font-variant-numeric: tabular-nums; }
/* Cierre de una partida floja: en vez de la rejilla de ceros, un mensaje y un
   consejo. Se usa el azul de "información" y no el naranja del marcador, para
   que no compita con la puntuación ni se lea como un premio. */
.eg-encouragement { background: rgba(59,130,246,.10); border: 1px solid rgba(59,130,246,.28); border-radius: 16px; padding: 14px 16px; margin: 0 0 14px; text-align: left; }
.eg-encouragement-lead { margin: 0 0 6px; font-weight: 800; font-size: .98rem; line-height: 1.35; }
.eg-encouragement-tip { margin: 0; font-size: .88rem; line-height: 1.5; opacity: .82; }

/* Tema claro: fondos translúcidos oscuros para que tarjetas y botones se lean. */
body.theme-light .eg-stat, body.theme-light .eg-card { background: rgba(15,23,42,.05); border-color: rgba(15,23,42,.12); }
body.theme-light .eg-encouragement { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.22); }
body.theme-light .eg-btn-secondary { background: rgba(15,23,42,.06) !important; border-color: rgba(15,23,42,.15) !important; }
body.theme-light .eg-compare .up { color: #15803d; }
body.theme-light .eg-compare .down { color: #c2410c; }
body.theme-light .eg-compare .record { color: #b45309; }

/* ─────────────────────────────────────────────────────────────────────────
   Tooltips de iconos no clicables (tooltip.js). data-tip="texto".
   ───────────────────────────────────────────────────────────────────────── */
.app-tooltip {
  position: fixed; z-index: 2500; top: 0; left: 0;
  max-width: 240px; padding: 8px 11px; border-radius: 10px;
  background: #0f172a; color: #f1f5f9; border: 1px solid rgba(148,163,184,.28);
  font-size: .82rem; line-height: 1.35; font-weight: 600; text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  pointer-events: none; opacity: 0; visibility: hidden;
  transform: translateY(3px); transition: opacity .12s ease, transform .12s ease;
}
.app-tooltip.visible { opacity: 1; visibility: visible; transform: translateY(0); }
/* Cursor de "ayuda" en desktop para que se note que hay info. */
@media (hover: hover) { [data-tip] { cursor: help; } }

/* ---- Pantalla de celebración (logro / subida de nivel de cuenta) ---- */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #fff; padding: 24px; cursor: pointer;
  animation: cel-fade-in .25s ease-out;
}
@keyframes cel-fade-in { from { opacity: 0; } to { opacity: 1; } }
.celebration-overlay.theme-levelup {
  background: radial-gradient(circle at 50% 30%, #3b2a12 0%, #1a1206 55%, #0b1020 100%);
}
.celebration-overlay.theme-ach {
  background: radial-gradient(circle at 50% 30%, #4a1f3d 0%, #1f1030 55%, #0b1020 100%);
}
.celebration-overlay .cel-ring {
  position: absolute; width: 190px; height: 190px; border-radius: 50%;
  animation: cel-ring-pulse 2.2s ease-out infinite;
}
.celebration-overlay.theme-levelup .cel-ring { border: 2px solid rgba(251,146,60,.6); }
.celebration-overlay.theme-ach .cel-ring { border: 2px solid rgba(217,70,239,.5); }
.celebration-overlay .cel-ring.r2 { animation-delay: .7s; }
.celebration-overlay .cel-ring.r3 { animation-delay: 1.4s; }
@keyframes cel-ring-pulse { 0% { transform: scale(.6); opacity: 0; } 35% { opacity: .75; } 100% { transform: scale(1.7); opacity: 0; } }
.celebration-overlay .cel-badge {
  width: 100px; height: 100px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 48px; position: relative; z-index: 2; animation: cel-pop .6s cubic-bezier(.34,1.56,.64,1);
}
.celebration-overlay.theme-levelup .cel-badge { background: linear-gradient(135deg, #fb923c, #eab308); box-shadow: 0 0 34px rgba(251,146,60,.6); }
.celebration-overlay.theme-ach .cel-badge { background: linear-gradient(135deg, #f59e0b, #d946ef); box-shadow: 0 0 34px rgba(217,70,239,.55); }
@keyframes cel-pop { 0% { transform: scale(0) rotate(-25deg); } 70% { transform: scale(1.15) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
.celebration-overlay .cel-title { font-size: 23px; font-weight: 800; margin-top: 22px; z-index: 2; padding: 0 14px; }
.celebration-overlay .cel-sub { font-size: 13px; opacity: .85; margin-top: 4px; z-index: 2; padding: 0 18px; }
.celebration-overlay .cel-chip {
  margin-top: 16px; z-index: 2; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
  padding: 8px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.celebration-overlay .cel-cta {
  margin-top: 18px; z-index: 2; background: #fff; color: #17153b; font-weight: 800;
  padding: 11px 30px; border-radius: 999px; font-size: 14px; border: none; cursor: pointer;
}
.celebration-overlay .cel-share {
  margin-top: 10px; z-index: 2; background: transparent; color: #fff; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; border: 1px solid rgba(255,255,255,.35); cursor: pointer;
}
.celebration-overlay .cel-spark { position: absolute; font-size: 16px; opacity: 0; animation: cel-rise 1.8s ease-in infinite; }
@keyframes cel-rise { 0% { opacity: 0; transform: translateY(0) scale(.5); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-36px) scale(1); } }
.celebration-overlay .cel-dots { position: absolute; bottom: 24px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; z-index: 2; }
.celebration-overlay .cel-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.3); }
.celebration-overlay .cel-dots span.active { background: #fff; }

/* prefers-reduced-motion: sin anillos, chispas ni pop — icono y textos estáticos */
.celebration-overlay.static { animation: none; }
.celebration-overlay.static .cel-ring,
.celebration-overlay.static .cel-spark { display: none; }
.celebration-overlay.static .cel-badge { animation: none; }

/* ---- Coach-marks de modos (Duelos/Niveles/Reto), primera vuelta al home ---- */
.coachmark-overlay { position: fixed; inset: 0; z-index: 9500; }
.coachmark-ring {
  position: fixed; width: 46px; height: 46px; margin-left: -23px; margin-top: -23px;
  border-radius: 50%; border: 2px solid #a78bfa; animation: cm-ring-pulse 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes cm-ring-pulse { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.coachmark-bubble {
  position: fixed; transform: translateX(-50%); width: 220px; max-width: 80vw;
  background: #1e1b3a; border: 1px solid rgba(139,92,246,.5); border-radius: 12px; padding: 12px 14px;
  color: #e5e7eb; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 22px rgba(0,0,0,.45);
  animation: cm-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cm-pop { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.coachmark-bubble .cm-title { font-weight: 800; margin-bottom: 3px; }
.coachmark-bubble .cm-dots { display: flex; gap: 5px; margin-top: 9px; }
.coachmark-bubble .cm-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.25); }
.coachmark-bubble .cm-dots span.on { background: #a78bfa; }

/* ---- Guardar partida anónima (modal de fin de partida) ---- */
.eg-save-anon { margin: 4px 0 16px; text-align: left; }
.eg-save-lead { font-weight: 700; margin: 0 0 4px; text-align: center; }
.eg-save-sub { margin: 0 0 10px; text-align: center; font-size: .82rem; opacity: .75; line-height: 1.35; }
.eg-save-done { font-weight: 700; text-align: center; color: var(--success, #22c55e); margin: 4px 0 16px; }

/* ---- Modos de Juego destacados en el Home ---- */
.home-modes-section {
  display: flex; flex-direction: column; gap: 10px; margin-top: 4px;
}
.home-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px; margin-top: 6px;
}
.hsh-title {
  font-size: .84rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted, #94a3b8); display: flex; align-items: center; gap: 6px;
}
.home-modes-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.home-mode-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  text-decoration: none; width: 100%; cursor: pointer; padding: 14px 16px; border-radius: 18px;
  color: #fff; background: var(--surface, #1e293b);
  border: 1px solid var(--border-color, rgba(148,163,184,.22));
  transition: transform .1s ease, box-shadow .15s ease;
  position: relative; overflow: hidden;
}
.home-mode-card:active { transform: translateY(1px) scale(.995); }
.home-mode-card--reto {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(239, 68, 68, 0.22));
  border-color: rgba(245, 158, 11, 0.4);
}
.home-mode-card--reto .hmc-icon {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}
.hmc-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.35rem; color: #fff;
}
.hmc-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hmc-title { font-size: 1.08rem; font-weight: 800; color: #fff; display: flex; align-items: center; gap: 8px; }
.hmc-badge {
  font-size: .65rem; font-weight: 800; padding: 2px 7px; border-radius: 6px;
  background: #ef4444; color: #fff; text-transform: uppercase; letter-spacing: .04em;
}
.hmc-sub { font-size: .8rem; color: rgba(255, 255, 255, 0.82); font-weight: 600; }
.hmc-go { flex-shrink: 0; font-size: 1.6rem; font-weight: 800; color: rgba(255, 255, 255, 0.7); }

.home-modes-subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-mode-tile {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  text-decoration: none; cursor: pointer; padding: 14px 14px; border-radius: 18px;
  color: #fff; background: var(--surface, #1e293b);
  border: 1px solid var(--border-color, rgba(148,163,184,.22));
  transition: transform .1s ease, border-color .15s ease;
  position: relative;
}
.home-mode-tile:active { transform: translateY(1px) scale(.99); }
.home-mode-tile--duelos {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(124, 58, 237, 0.22));
  border-color: rgba(99, 102, 241, 0.35);
}
.home-mode-tile--duelos .hmt-icon {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.home-mode-tile--niveles {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.14), rgba(2, 132, 199, 0.22));
  border-color: rgba(14, 165, 233, 0.35);
}
.home-mode-tile--niveles .hmt-icon {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
}
.hmt-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.hmt-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; color: #fff; }
.hmt-title { font-size: 1.02rem; font-weight: 800; color: #fff; }
.hmt-sub { font-size: .76rem; color: rgba(255, 255, 255, 0.78); font-weight: 600; }


/* --- Historial de gemas y premio del reto ---------------------------------
   Los importes se distinguen por color Y por signo: solo por color no se
   leerían con daltonismo, que es justo la distinción ganado/gastado. */
.gem-history-totals { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:12px; }
.ght-item { display:flex; flex-direction:column; align-items:center; gap:2px; padding:8px 4px; border-radius:10px; background:rgba(127,127,127,0.10); }
.ght-label { font-size:0.75rem; color:var(--text-muted, #6b7280); }
.ght-item strong { font-size:1.05rem; color:var(--text-color); }
.ght-earned { color:var(--success, #10b981) !important; }
.ght-spent { color:#ef4444 !important; }

.gem-tx { align-items:flex-start; }
.gem-tx .rk-left { align-items:flex-start; gap:10px; }
.gem-tx-icon { font-size:1.25rem; line-height:1.3; flex:0 0 auto; }
.gem-tx-detail { margin-top:1px; }
.gem-tx-date { margin-top:2px; opacity:0.75; font-size:0.78rem; }
.gem-tx-amount { font-weight:800; font-size:1.02rem; white-space:nowrap; margin-left:10px; }
.gem-tx-amount.is-earned { color:var(--success, #10b981); }
.gem-tx-amount.is-spent { color:#ef4444; }

.gem-award-trophy { font-size:3.4rem; line-height:1; margin-bottom:8px; animation:gem-award-pop 0.5s cubic-bezier(.34,1.56,.64,1) both; }
.gem-award-title { margin:0 0 6px; font-size:1.3rem; color:var(--text-color); }
.gem-award-detail { margin:0; }
.gem-award-amount { margin-top:14px; display:inline-flex; align-items:center; gap:8px; font-size:1.6rem; color:var(--text-color); }
@keyframes gem-award-pop { from { transform:scale(.4) rotate(-12deg); opacity:0; } to { transform:none; opacity:1; } }
@media (prefers-reduced-motion: reduce) { .gem-award-trophy { animation:none; } }

/* ── Popover de racha (streakPopover.js) ─────────────────────────────────── */
.hsb-streak { cursor: pointer; }
.hsb-streak .hsb-shield { font-size: .8rem; margin-left: 2px; }
.streak-pop .modal-body { text-align: center; }
.sp-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 4px 0 8px; }
.sp-num { font-size: 3rem; font-weight: 900; line-height: 1; background: linear-gradient(135deg,#fbbf24,#f97316); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.sp-unit { font-size: .85rem; opacity: .75; font-weight: 600; }
.sp-best { font-size: .75rem; opacity: .6; }
.sp-status { margin: 0 0 12px; font-size: .92rem; line-height: 1.4; }
.sp-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 0 auto 12px; max-width: 320px; }
.sp-day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); font-size: .7rem; }
.sp-day-letter { opacity: .6; font-weight: 700; }
.sp-day-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: .85rem; background: rgba(255,255,255,.08); }
.sp-day-num { opacity: .55; font-variant-numeric: tabular-nums; }
.sp-played .sp-day-dot { background: linear-gradient(135deg,#f97316,#fbbf24); color: #1c1917; }
.sp-protected .sp-day-dot { background: rgba(59,130,246,.35); }
.sp-missed .sp-day-dot { color: rgba(255,255,255,.35); }
.sp-today { border-color: rgba(251,191,36,.7); }
.sp-today .sp-day-dot { border: 2px dashed rgba(251,191,36,.8); color: #fbbf24; }
.sp-future { opacity: .45; }
.sp-note { font-size: .8rem; opacity: .7; margin: 0 0 12px; line-height: 1.4; }
.sp-shield { text-align: left; background: rgba(59,130,246,.10); border: 1px solid rgba(59,130,246,.3); border-radius: 14px; padding: 12px 14px; }
.sp-shield-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.sp-shield-ic { font-size: 1.6rem; line-height: 1; }
.sp-shield-sub { font-size: .8rem; opacity: .75; line-height: 1.4; margin-top: 2px; }
.sp-shield-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp-shield-count { font-size: 1rem; }
.sp-shield-empty { opacity: .25; filter: grayscale(1); }
.sp-buy { padding: 8px 14px !important; font-size: .9rem !important; background: linear-gradient(145deg,#3b82f6,#2563eb) !important; color: #fff !important; }
.sp-buy:disabled { opacity: .5; cursor: default; }
body.theme-light .sp-day { background: rgba(15,23,42,.05); border-color: rgba(15,23,42,.12); }
body.theme-light .sp-day-dot { background: rgba(15,23,42,.08); }
body.theme-light .sp-missed .sp-day-dot { color: rgba(15,23,42,.35); }
body.theme-light .sp-shield { background: rgba(59,130,246,.08); }

/* ── Misiones de hoy (missions.js) ─────────────────────────────────────────── */
.home-missions { background: var(--surface-muted, rgba(148,163,184,.10)); border: 1px solid var(--border-color, rgba(148,163,184,.25)); border-radius: 16px; padding: 12px 12px 8px; margin: 0 0 12px; }
.home-missions-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.home-missions-title { font-weight: 800; font-size: .95rem; }
.home-missions-week { font-size: .74rem; opacity: .75; text-align: right; }
.hm-week-count { font-weight: 800; font-variant-numeric: tabular-nums; }
.home-missions-list { display: flex; flex-direction: column; gap: 6px; }
.hm-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: inherit; text-decoration: none; min-height: 52px; }
.hm-item:hover { border-color: rgba(255,255,255,.2); }
.hm-item.done { opacity: .7; }
.hm-icon { font-size: 1.35rem; width: 1.6rem; text-align: center; flex-shrink: 0; }
.hm-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hm-title { font-weight: 700; font-size: .88rem; line-height: 1.2; }
.hm-desc { font-size: .74rem; opacity: .7; line-height: 1.25; }
.hm-bar { display: block; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 3px; }
.hm-fill { display: block; height: 100%; background: linear-gradient(90deg,#22c55e,#4ade80); transition: width .4s ease; }
.hm-item.done .hm-fill { background: #22c55e; }
.hm-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.hm-progress { font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .85; }
.hm-done { color: #4ade80; font-weight: 900; font-size: 1rem; }
.hm-reward { font-size: .76rem; font-weight: 800; display: inline-flex; align-items: center; gap: 2px; color: #c4b5fd; }
.hm-reward .ic { width: 12px; height: 12px; }
body.theme-light .hm-item { background: rgba(15,23,42,.04); border-color: rgba(15,23,42,.10); }
body.theme-light .hm-bar { background: rgba(15,23,42,.12); }
body.theme-light .hm-done { color: #15803d; }
body.theme-light .hm-reward { color: #6d28d9; }

/* ── Home compacta (ago-2026): jugar arriba, modos en fila, misiones plegadas ── */
.home-greet-sub { display: none; }
/* Antes el saludo crecía para anclar el botón de jugar al fondo; ahora jugar va
   arriba y el bloque se reparte el espacio libre por igual arriba y abajo. */
.home-top { flex: 0 0 auto; padding: 10px 2px 2px; margin-top: auto; }
.home-dash { flex: 0 0 auto; justify-content: flex-start; margin-bottom: auto; }
.home-card--install .home-card-title { font-size: .95rem; }
.home-hero { padding: 18px 18px; }
.home-modes-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.home-mode-chip {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center; text-decoration: none; cursor: pointer; padding: 10px 6px 9px; border-radius: 14px;
  color: #fff; background: var(--surface, #1e293b);
  border: 1px solid var(--border-color, rgba(148,163,184,.22));
  transition: transform .1s ease;
}
.home-mode-chip:active { transform: translateY(1px) scale(.98); }
.hmch-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; margin-bottom: 2px; }
.hmch-icon .ic { width: 18px; height: 18px; }
.hmch-title { font-size: .82rem; font-weight: 800; line-height: 1.1; }
.hmch-sub { font-size: .68rem; font-weight: 600; color: rgba(255,255,255,.72); line-height: 1.1; }
.hmch-badge { position: absolute; top: 6px; right: 6px; }
.home-mode-chip--reto { background: linear-gradient(135deg, rgba(245,158,11,.16), rgba(239,68,68,.22)); border-color: rgba(245,158,11,.4); }
.home-mode-chip--reto .hmch-icon { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.home-mode-chip--duelos { background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(124,58,237,.22)); border-color: rgba(99,102,241,.35); }
.home-mode-chip--duelos .hmch-icon { background: linear-gradient(135deg, #6366f1, #7c3aed); }
.home-mode-chip--niveles { background: linear-gradient(135deg, rgba(14,165,233,.14), rgba(2,132,199,.22)); border-color: rgba(14,165,233,.35); }
.home-mode-chip--niveles .hmch-icon { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
body.theme-light .home-mode-chip { color: #0f172a; }
body.theme-light .hmch-sub { color: rgba(15,23,42,.65); }

.home-missions { padding: 0; margin: 0; overflow: hidden; }
.home-missions-head {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 12px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.home-missions-title { flex-shrink: 0; }
.home-missions-summary { flex: 1 1 auto; min-width: 0; font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 3px; }
.home-missions-summary .ic { width: 12px; height: 12px; }
.home-missions-chev { flex-shrink: 0; font-size: 1.3rem; font-weight: 700; opacity: .6; line-height: 1; transition: transform .2s ease; }
.home-missions.is-open .home-missions-chev { transform: rotate(90deg); }
.home-missions-list { padding: 0 10px 8px; }
.home-missions-week { padding: 0 12px 10px; text-align: left; }
.home-missions:not(.is-open) .home-missions-list,
.home-missions:not(.is-open) .home-missions-week { display: none; }

.home-tile--progress .home-tile-icon { color: #a855f7; background: rgba(168,85,247,.18); }
.home-tile--progress { gap: 8px; overflow: hidden; }
.home-tile--progress::before { background: linear-gradient(90deg, #c084fc, #7c3aed); }

.home-card--install { position: relative; padding: 0; display: flex; }
.home-card-main { flex: 1 1 auto; display: flex; align-items: center; gap: 12px; text-align: left; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 12px 40px 12px 14px; width: 100%; }
.home-card-close { position: absolute; top: 4px; right: 6px; width: 32px; height: 32px; border: 0; background: none; color: inherit; opacity: .6; font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.home-card-close:hover { opacity: 1; }
/* Héroe del reto (horas pico, reto no jugado): mismo bloque, paleta del reto. */
.home-hero--reto { background: linear-gradient(145deg, #f59e0b, #dc2626); box-shadow: 0 10px 24px rgba(220,38,38,.35); }
.home-hero--reto:active { box-shadow: 0 6px 16px rgba(220,38,38,.3); }
