/* La gamificación en todas las páginas (F7-62, bloque B, t101): el indicador
 * del menú, los toasts de +XP, los bloques que vuelan hasta él y la llama de
 * la racha. Lo grande (tarjetas de nivel, rango, logro e hito, el resumen
 * desplegable y la página «Progress») está en `gam-fx.css`, que sólo se pide
 * cuando hace falta. Sólo tokens; todo lo que se mueve, dentro de
 * `prefers-reduced-motion: no-preference`. */

/* --- El hueco: alto fijo, así nada salta al llenarlo ----------------------- */
.side-top { flex-wrap: wrap; }
.gam-slot { flex: 1 0 100%; min-height: 44px; display: flex; }
.gam-slot[hidden] { display: none; }
.gam-ph { flex: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-sunken); opacity: .5; }

/* --- El indicador --------------------------------------------------------- */
.gam-chip { --rk: var(--rk-1); flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; text-align: left;
  color: var(--text); font: inherit; position: relative; box-shadow: var(--sheen); min-height: 44px; }
.gam-chip:hover { background: var(--surface-hover); }
.gam-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gam-chip[aria-expanded="true"] { border-color: color-mix(in srgb, var(--rk) 55%, var(--line)); }
.gam-orb { position: relative; width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; }
.gam-orb .gam-ring { position: absolute; inset: 0; width: 34px; height: 34px; transform: rotate(-90deg); overflow: visible; }
.gam-ring circle { fill: none; stroke-width: 2.6; }
.gam-ring .bg { stroke: var(--line-strong); }
.gam-ring .pr { stroke: var(--rk); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.gam-orb .em { width: 24px; height: 24px; }
.gam-lv { position: absolute; right: -5px; bottom: -4px; font-size: 9.5px; font-weight: 750; line-height: 13px; padding: 0 3px;
  background: var(--bg-elevated); border: 1px solid var(--line-strong); border-radius: 6px; font-variant-numeric: tabular-nums; color: var(--text); }
.gam-meta { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.gam-meta b { font-size: var(--size-xs); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gam-meta span { font-size: var(--size-2xs); color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.gam-meta .cta { color: var(--accent); }
.gam-fl { display: inline-flex; align-items: center; gap: 2px; font-size: var(--size-xs); font-weight: 750; color: var(--flame);
  font-variant-numeric: tabular-nums; flex: 0 0 auto; position: relative; }
.gam-fl[hidden] { display: none; }
.gam-fl svg { width: 15px; height: 15px; overflow: visible; }
.gam-fl.cold { color: var(--text-faint); }
.gam-fl.blue { color: var(--freeze); }
.gam-fl.gold { color: var(--rk-8); }
.gam-fl.risk::after { content: ""; position: absolute; top: -2px; right: -4px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.gam-badge { position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 750; display: none; place-items: center; }
.gam-chip.has-badge .gam-badge { display: grid; }
.gam-n { display: inline-block; }

/* Menú recogido: sólo el emblema con su anillo. */
.shell.side-closed .gam-chip { padding: 4px; justify-content: center; border-color: transparent; background: none; box-shadow: none; }
.shell.side-closed .gam-meta, .shell.side-closed .gam-fl { display: none; }

/* Móvil: el lateral es la barra de arriba; el indicador se queda a la vista
   (pegado a la izquierda mientras el menú se desliza) y compacto. */
@media (max-width: 860px) {
  .side-top { flex-wrap: nowrap; position: sticky; left: 0; z-index: 3; background: var(--bg-elevated); padding-right: 6px; }
  .gam-slot { flex: 0 0 auto; min-height: 38px; }
  .gam-ph { width: 74px; }
  .gam-chip { padding: 3px 7px 3px 3px; min-height: 38px; gap: 6px; }
  .gam-meta { display: none; }
  .gam-anon .gam-meta { display: flex; }
  .gam-anon .gam-meta > span { display: none; }
  .gam-orb, .gam-orb .gam-ring { width: 30px; height: 30px; }
  .gam-orb .em { width: 21px; height: 21px; }
}

/* La copia del indicador cuando el de verdad no se ve (móvil, página bajada). */
.gam-dock { --rk: var(--rk-1); position: fixed; top: 10px; right: 12px; z-index: 94; display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px;
  background: var(--bg-elevated); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow); font-size: var(--size-xs);
  opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.gam-dock.on { opacity: 1; transform: none; }
.gam-dock .gam-orb, .gam-dock .gam-orb .gam-ring { width: 30px; height: 30px; }
.gam-dock .gam-orb .em { width: 20px; height: 20px; }
.gam-dock .gam-lv { display: none; }
@media (prefers-reduced-motion: no-preference) { .gam-dock.hit .gam-orb { animation: gam-hit .22s ease; } }

/* --- Bloques que vuelan --------------------------------------------------- */
.gam-layer { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; contain: strict; }
.gam-blk { position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; color: var(--rk); will-change: transform, opacity;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rk) 70%, transparent)); }
.gam-blk svg { display: block; width: 100%; height: 100%; overflow: visible; }
.gam-pop { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 2px solid var(--rk); opacity: 0; }
.gam-plus { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); font-weight: 800; font-size: var(--size-md);
  color: var(--rk); text-shadow: 0 0 12px color-mix(in srgb, var(--rk) 60%, transparent), 0 1px 0 var(--bg); white-space: nowrap;
  font-variant-numeric: tabular-nums; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .gam-chip.bump { animation: gam-bump .42s cubic-bezier(.2,.9,.3,1.4); }
  .gam-chip.glow .gam-ring .pr { animation: gam-ringglow 1.1s ease; }
  .gam-chip.glow .gam-orb { animation: gam-orbflash 1.1s ease; }
  .gam-chip.hit .gam-orb { animation: gam-hit .22s ease; }
  .gam-fl.lit svg { animation: gam-ignite 1.4s cubic-bezier(.2,.9,.3,1.2); }
  .gam-fl.lit::before { content: ""; position: absolute; left: 1px; bottom: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--flame-hot) 70%, transparent), transparent); animation: gam-halo 1.4s ease forwards; }
  .gam-fl:not(.cold) svg .core { animation: gam-flicker 1.6s ease-in-out infinite; transform-origin: 50% 90%; transform-box: fill-box; }
  .gam-chip.wait .gam-badge { animation: gam-badge 1.6s ease-in-out infinite; }
}
@keyframes gam-bump { 35% { transform: scale(1.045); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rk) 30%, transparent); } }
@keyframes gam-hit { 50% { transform: scale(1.18); } }
@keyframes gam-ringglow { 30% { stroke-width: 4.2; filter: drop-shadow(0 0 5px var(--rk)); } }
@keyframes gam-orbflash { 30% { filter: brightness(1.5) drop-shadow(0 0 8px var(--rk)); } }
@keyframes gam-ignite { 0% { transform: scale(.4); filter: grayscale(1); } 45% { transform: scale(1.7); filter: drop-shadow(0 0 8px var(--flame-hot)); } 100% { transform: scale(1); } }
@keyframes gam-halo { 0% { transform: scale(.5); opacity: 0; } 40% { transform: scale(2.6); opacity: 1; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes gam-flicker { 0%, 100% { transform: scaleY(1); } 40% { transform: scaleY(1.12) scaleX(.94); } 70% { transform: scaleY(.95); } }
@keyframes gam-badge { 50% { transform: scale(1.15); } }

/* --- Toasts (abajo a la izquierda, sin tapar la «i») ----------------------- */
.gam-toasts { position: fixed; left: 232px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  pointer-events: none; max-width: calc(100vw - 32px); }
.shell.side-closed ~ .gam-toasts { left: 72px; }
@media (max-width: 860px) { .gam-toasts { left: 16px; bottom: 16px; } }
.gam-toast { --rk: var(--accent); pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--bg-elevated); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow); font-size: var(--size-sm); color: var(--text); }
.gam-toast .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: color-mix(in srgb, var(--rk) 16%, var(--surface)); color: var(--rk); }
.gam-toast .ic svg { width: 15px; height: 15px; }
.gam-toast .plus { font-weight: 800; color: var(--rk); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gam-toast .tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gam-toast .x { color: var(--text-faint); font-size: var(--size-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gam-toast a { color: var(--accent); font-weight: 600; white-space: nowrap; }
.gam-toast.soft { --rk: var(--text-muted); }
.gam-toast.ice { --rk: var(--freeze); }
.gam-toast.mis { --rk: var(--accent); border-radius: var(--radius); padding: 8px 14px 8px 8px; }
.gam-toast.mis .ic { width: 30px; height: 30px; background: var(--rk); color: var(--accent-ink); }
.gam-toast.mis .ic path { stroke-dasharray: 20; stroke-dashoffset: 0; }
.gam-toast.out { opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .gam-toast { animation: gam-tin .34s cubic-bezier(.2,.9,.3,1.25); }
  .gam-toast.out { animation: gam-tout .26s ease forwards; }
  .gam-toast .plus { display: inline-block; animation: gam-plus .5s cubic-bezier(.2,.9,.3,1.6) .08s both; }
  .gam-toast.mis .ic { animation: gam-check-pop .5s cubic-bezier(.2,.9,.3,1.5); }
  .gam-toast.mis .ic path { animation: gam-check .5s ease .18s both; }
  .gam-toast.ice .ic { animation: gam-frost 1.6s ease; }
}
@media (prefers-reduced-motion: reduce) { .gam-toast { animation: gam-fade .15s ease; } }
@keyframes gam-tin { from { transform: translateY(14px) scale(.96); opacity: 0; } }
@keyframes gam-tout { to { transform: translateY(6px); opacity: 0; } }
@keyframes gam-plus { from { transform: scale(.4); } }
@keyframes gam-check-pop { 0% { transform: scale(.3); } 60% { transform: scale(1.2); } }
@keyframes gam-check { from { stroke-dashoffset: 20; } }
@keyframes gam-frost { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--freeze) 60%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } }
@keyframes gam-fade { from { opacity: 0; } }

/* El emblema: animación en reposo de cada rango (la de la maqueta). */
.em { display: block; overflow: visible; }
.em .bgx { fill: var(--surface-sunken); }
@media (prefers-reduced-motion: no-preference) {
  .em-1 .breathe { animation: em-breathe 4s ease-in-out infinite; }
  .em-2 .ping { animation: em-ping 3s ease-in-out infinite; transform-origin: 32px 21px; transform-box: view-box; }
  .em-3:hover .cubes, .gam-chip:hover .em-3 .cubes { animation: em-flash 1s ease; }
  .em-4 .lk { animation: em-link 6s linear infinite; }
  .em-4 .lk2 { animation-delay: 1s; }
  .em-5 .orbit { animation: em-spin 10s linear infinite; transform-origin: 32px 32px; transform-box: view-box; }
  .em-6 .shim { animation: em-shim 5s ease-in-out infinite; }
  .em-7 .flow { animation: em-flow 1.6s linear infinite; }
  .em-8 .rays { animation: em-spin 24s linear infinite; transform-origin: 32px 32px; transform-box: view-box; }
  .em-8 .sats { animation: em-spin 14s linear infinite reverse; transform-origin: 32px 32px; transform-box: view-box; }
  .em-8 { animation: em-glow 3s ease-in-out infinite; }
}
@keyframes em-breathe { 50% { opacity: .45; } }
@keyframes em-ping { 0%, 70%, 100% { transform: scale(1); opacity: 1; } 80% { transform: scale(1.9); opacity: .4; } }
@keyframes em-flash { 40% { filter: brightness(1.6); } }
@keyframes em-link { 0%, 100% { opacity: .35; } 10%, 20% { opacity: 1; } }
@keyframes em-spin { to { transform: rotate(360deg); } }
@keyframes em-shim { 0%, 55% { transform: translateX(-40px) skewX(-20deg); } 85%, 100% { transform: translateX(90px) skewX(-20deg); } }
@keyframes em-flow { to { stroke-dashoffset: -20; } }
@keyframes em-glow { 50% { filter: drop-shadow(0 0 7px color-mix(in srgb, var(--rk-8) 60%, transparent)); } }
