/* Perfil v3 — héroe con avatar y XP, KPIs, amigos, barras por prueba, logros, cuenta, ajustes. Solo .pf-* */

.pf-wrap {
  --pf-bronze: linear-gradient(145deg, #FFD3AE, #D98E4F 55%, #9A5426);
  --pf-silver: linear-gradient(145deg, #F4F7FB, #AFC0D8 55%, #7D8AA3);
  --pf-gold: linear-gradient(145deg, #FFE7A3, #FFB547 55%, #E07B12);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 12px;
}
.pf-ic { display: inline-grid; place-items: center; line-height: 0; }
.pf-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pf-section[hidden] { display: none; }
.pf-sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pf-sec-title h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.pf-cols { display: flex; flex-direction: column; gap: 22px; }
.pf-col-main, .pf-col-side { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
/* Una columna: profile.js mete todas las secciones en .pf-col-main (en orden de lectura) y oculta la otra */
.pf-col-side[hidden] { display: none; }

/* --- Héroe ---------------------------------------------------------------- */
.pf-hero {
  --pf-tier: #D98E4F;
  --pf-tier-grad: var(--pf-bronze);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px 20px;
  border-radius: var(--radius-2xl, 28px);
  color: #fff;
  background: var(--grad-brand, linear-gradient(135deg, #7C5CFF, #C155FF 50%, #FF5E8A));
  box-shadow: var(--glow-brand, 0 20px 50px -20px rgba(124, 92, 255, 0.7));
  isolation: isolate;
}
.pf-hero[data-tier="silver"] { --pf-tier-grad: var(--pf-silver); }
.pf-hero[data-tier="gold"] { --pf-tier-grad: var(--pf-gold); }
.pf-hero[data-tier="platinum"] { --pf-tier-grad: linear-gradient(145deg, #C9FFF3, #4FE3C8 55%, #1B9E8A); }
.pf-hero[data-tier="diamond"] { --pf-tier-grad: linear-gradient(145deg, #DDF0FF, #6FB7FF 50%, #7C5CFF); }
.pf-hero[data-tier="master"] { --pf-tier-grad: linear-gradient(145deg, #FFB547, #FF5E8A 45%, #C155FF 75%, #7C5CFF); }
.pf-hero-glow {
  position: absolute;
  z-index: -1;
  inset: -40% -30% auto auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent 65%);
  pointer-events: none;
  animation: pf-drift 9s ease-in-out infinite alternate;
}
.pf-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: auto auto -50% -20%;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pf-tier), transparent 65%);
  opacity: 0.45;
  pointer-events: none;
}
.pf-hero-id { display: flex; align-items: center; gap: 18px; min-width: 0; }
.pf-avatar { position: relative; flex: none; }
.pf-avatar-ring {
  padding: 4px;
  border-radius: 50%;
  background: var(--pf-tier-grad);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), 0 14px 36px -10px var(--pf-tier);
  animation: pf-pop 800ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}
.pf-avatar-ring .avatar { display: block; border-radius: 50%; box-shadow: 0 0 0 3px rgba(12, 8, 40, 0.35); }
.pf-lv-badge {
  position: absolute;
  left: 50%;
  bottom: -8px;
  translate: -50% 0;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 999px);
  background: var(--pf-tier-grad);
  color: #1C1030;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.35);
}
.pf-hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.pf-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
/* Nombre de hasta 24 caracteres: baja de tamaño en móvil y parte en dos líneas antes de recortarse */
.pf-name {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display, inherit);
  font-size: clamp(22px, 6.4vw, 30px);
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -0.03em;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  /* tilde de las mayúsculas (Ó, Á), descendentes (g, j, p) y borde de la última letra con tracking negativo */
  padding: 0.1em 0.06em 0.1em 0;
  margin-block: -0.1em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.18);
}
.pf-edit {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}
.pf-edit:hover { background: rgba(255, 255, 255, 0.28); }
.pf-edit:active { transform: scale(0.94); }
.pf-edit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pf-tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill, 999px);
  background: rgba(20, 10, 50, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.pf-tier-chip .pf-ic { color: var(--pf-tier); }
.pf-tier-chip[hidden], .pf-xp[hidden], .pf-lv-badge[hidden] { display: none; }

.pf-xp {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-xl, 22px);
  background: rgba(15, 8, 45, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.pf-ring { flex: none; color: rgba(255, 255, 255, 0.2); }
.pf-ring-fallback { position: relative; width: 108px; height: 108px; }
.pf-ring-fallback svg { display: block; }
.pf-ring-bar { transition: stroke-dashoffset 1.2s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)); }
.pf-ring-fallback .pf-ring-bar { stroke: #fff; }
.pf-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.pf-ring-center b { font-size: 32px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.pf-ring-center small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }
.pf-hero .ring { color: #fff; }
.pf-xp-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.pf-xp-total b { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }
.pf-xp-total small { font-size: 13px; font-weight: 800; opacity: 0.85; }
.pf-xp-next { font-size: 13px; font-weight: 600; opacity: 0.9; font-variant-numeric: tabular-nums; }
.pf-xp-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.pf-xp-bar span {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, #fff, var(--pf-tier));
  animation: pf-grow 1.2s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) both 300ms;
  transform-origin: 0 50%;
}

/* --- KPIs ----------------------------------------------------------------- */
.pf-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pf-kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
  min-width: 0;
}
.pf-kpi:first-child { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; }
.pf-kpi:first-child .pf-kpi-num { order: 2; margin-left: auto; }
.pf-kpi-ic {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #fff;
  background: var(--grad-brand, linear-gradient(135deg, #7C5CFF, #C155FF 50%, #FF5E8A));
}
.pf-kpi-ic[data-tone="gold"] { background: var(--grad-gold, var(--pf-gold)); color: #3A2300; }
.pf-kpi-ic[data-tone="warm"] { background: var(--grad-warm, linear-gradient(135deg, #FFB547, #FF5E8A)); }
.pf-kpi-ic[data-tone="cool"] { background: var(--grad-cool, linear-gradient(135deg, #22D3EE, #7C5CFF)); }
.pf-kpi-num { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.pf-kpi .kpi-value { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.pf-kpi-num small { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.pf-kpi .kpi-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* --- Barras por prueba ---------------------------------------------------- */
.pf-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
}
.pf-bar { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.pf-bar + .pf-bar { border-top: 1px solid var(--separator); }
.pf-bar-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--brand-1, var(--accent));
  background: color-mix(in srgb, var(--brand-1, #7C5CFF) 14%, transparent);
}
.pf-bar[data-played="false"] .pf-bar-ic { color: var(--ink-3); background: var(--surface-2); }
.pf-bar-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pf-bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pf-bar-name { font-size: 15px; font-weight: 700; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pf-bar-val { font-size: 15px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.pf-bar[data-played="false"] .pf-bar-val { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pf-bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pf-bar-fill {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: inherit;
  background: var(--grad-brand, linear-gradient(90deg, #7C5CFF, #C155FF 50%, #FF5E8A));
  transition: width 1.1s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
}
.pf-bar-sub { font-size: 12px; color: var(--ink-2); }

/* --- Logros --------------------------------------------------------------- */
.pf-ach-count { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.pf-ach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pf-ach {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 14px 6px 12px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: transform 220ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), box-shadow 220ms ease;
}
.pf-ach:hover { transform: translateY(-2px); }
.pf-ach:active { transform: scale(0.96); }
.pf-ach:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 2px; }
.pf-ach-grid[data-collapsed="true"] > [data-extra] { display: none; }
.pf-ach-more { align-self: center; min-height: 44px; padding: 0 20px; }
@media (min-width: 360px) {
  .pf-ach-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .pf-ach .pf-medal:not(.pf-medal-big) { width: 52px; height: 52px; }
  .pf-ach { padding: 12px 4px 10px; }
}
.pf-ach-name { font-size: 12px; font-weight: 700; line-height: 1.25; text-align: center; color: var(--ink); overflow-wrap: anywhere; }
.pf-ach[data-unlocked="false"] .pf-ach-name { color: var(--ink-2); }

.pf-medal {
  --pf-m: var(--pf-bronze);
  --pf-mglow: rgba(217, 142, 79, 0.55);
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #2A1606;
  background: var(--pf-m);
  box-shadow: 0 8px 22px -8px var(--pf-mglow), inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.pf-medal[data-tier="silver"] { --pf-m: var(--pf-silver); --pf-mglow: rgba(160, 180, 210, 0.6); color: #1D2433; }
.pf-medal[data-tier="gold"] { --pf-m: var(--pf-gold); --pf-mglow: rgba(255, 181, 71, 0.7); color: #3A2300; }
.pf-medal[data-unlocked="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.7) 45%, transparent 60%);
  transform: translateX(-130%);
  animation: pf-shine 4.2s ease-in-out infinite;
}
.pf-ach:nth-child(3n+2) .pf-medal::after { animation-delay: 1.3s; }
.pf-ach:nth-child(3n) .pf-medal::after { animation-delay: 2.6s; }
.pf-medal[data-unlocked="false"] {
  background: var(--surface-2);
  color: var(--ink-3);
  box-shadow: inset 0 0 0 2px var(--separator);
  filter: grayscale(1);
}
.pf-medal-lock {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-2);
}
.pf-medal-big { width: 104px; height: 104px; }
.pf-medal-big .pf-medal-lock { width: 30px; height: 30px; right: 8px; bottom: 8px; }
.pf-ach-prog { display: block; width: 70%; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pf-ach-prog span { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--grad-brand, var(--accent)); border-radius: inherit; }
.pf-ach-prog-big { width: 100%; max-width: 260px; height: 10px; border-radius: 5px; }

.pf-ach-sheet { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 8px 0 12px; }
.pf-ach-sheet .pf-medal-big { animation: pf-pop 700ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both; }
.pf-ach-desc { margin: 0; max-width: 36ch; font-size: 16px; line-height: 1.45; color: var(--ink); }
.pf-ach-prog-text { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pf-ach-sheet .chip { display: inline-flex; align-items: center; gap: 6px; }

/* --- Ajustes ---------------------------------------------------------------- */
.pf-settings, .pf-links {
  display: flex;
  flex-direction: column;
  padding: 4px 14px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
}
/* Si la etiqueta y el control no caben en una línea, el control baja a la derecha (nunca se recorta) */
.pf-set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 60px; padding: 8px 0; }
.pf-set-row + .pf-set-row, .pf-link + .pf-link { border-top: 1px solid var(--separator); }
.pf-set-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #fff;
  background: var(--grad-brand, linear-gradient(135deg, #7C5CFF, #C155FF));
}
.pf-set-ic[data-tone="cool"] { background: var(--grad-cool, linear-gradient(135deg, #22D3EE, #7C5CFF)); }
.pf-set-ic[data-tone="warm"] { background: var(--grad-warm, linear-gradient(135deg, #FFB547, #FF5E8A)); }
.pf-set-label { flex: 1 0 auto; font-size: 16px; font-weight: 600; color: var(--ink); }
.pf-set-row--tap, .pf-set-row--tap .pf-set-label { cursor: pointer; }
.pf-set-row--tap .pf-set-label { align-self: stretch; display: flex; align-items: center; min-height: 44px; }
.pf-set-ctrl { flex: none; display: flex; justify-content: flex-end; max-width: 100%; margin-left: auto; }

/* Columnas iguales (la pastilla deslizante de .segmented asume anchos iguales) del ancho de la etiqueta más larga */
.pf-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.pf-seg .pf-seg-item { min-height: 44px; min-width: 52px; padding: 0 12px; white-space: nowrap; }

/* Enlaces */
.pf-link { display: flex; align-items: center; gap: 12px; min-height: 52px; color: var(--ink); text-decoration: none; }
.pf-link .pf-ic { color: var(--brand-1, var(--accent)); }
.pf-link-label { flex: 1; font-size: 16px; font-weight: 600; }
.pf-chev { color: var(--ink-3); font-size: 22px; line-height: 1; }
.pf-link:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 2px; border-radius: 8px; }

/* Borrado */
.pf-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border-radius: var(--radius-xl, 22px);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  color: var(--bad-text, var(--bad));
  font-weight: 700;
}
.pf-delete:hover { background: color-mix(in srgb, var(--bad) 16%, transparent); }

/* --- Animaciones ---------------------------------------------------------- */
@keyframes pf-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes pf-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pf-shine {
  0%, 65% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}
@keyframes pf-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-30px, 20px) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .pf-hero-glow, .pf-avatar-ring, .pf-xp-bar span, .pf-medal::after, .pf-ach-sheet .pf-medal-big { animation: none !important; }
  .pf-bar-fill, .pf-ring-bar { transition: none !important; }
}

/* --- Pantallas medianas y escritorio -------------------------------------- */
@media (min-width: 480px) {
  .pf-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Héroe en fila solo si la columna de contenido es ancha (en tableta la app mide ~730 px: se queda en
   columna; en escritorio, ≥ 900 px, va en fila) */
.pf-wrap { container-type: inline-size; }
@container (min-width: 900px) {
  .pf-hero { flex-direction: row; align-items: center; justify-content: space-between; padding: 28px; }
  .pf-hero-id { flex: 1 1 auto; }
  .pf-xp { flex: 0 1 360px; }
  .pf-name { font-size: 36px; }
}
@media (min-width: 1024px) {
  .pf-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr); align-items: start; gap: 24px; }
}
/* Logros: 12 visibles = filas completas con 3, 4 o 6 columnas (según el ancho de la sección, no de la ventana) */
.pf-ach-section { container-type: inline-size; }
@container (min-width: 560px) {
  .pf-ach-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
}

/* --- Ojito y armario (integración v3) ------------------------------------------- */
.pf-avatar--ojito { display: grid; place-items: center; }
.pf-ojito {
  position: relative; display: grid; place-items: center; width: 124px; height: 124px;
  text-decoration: none; border-radius: 50%;
  animation: pf-pop 800ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
  filter: drop-shadow(0 14px 22px rgba(12, 8, 40, 0.35));
  transition: transform 0.35s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
.pf-ojito::before {
  content: ""; position: absolute; inset: 10% 6% 0; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
}
.pf-ojito .ojito, .pf-ojito svg { display: block; width: 124px; height: 124px; }
.pf-ojito:hover, .pf-ojito:focus-visible { transform: translateY(-4px) scale(1.03); }
.pf-ojito:active { transform: scale(0.96); }
.pf-avatar--ojito .pf-lv-badge { bottom: -4px; }
.pf-new-dot {
  position: absolute; top: 8px; right: 8px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--brand-4, #FFB547); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 14px var(--brand-4, #FFB547);
}
.pf-wardrobe-slot[hidden] { display: none; }
.pf-wardrobe {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 12px;
  text-decoration: none; font-weight: 800;
}
.pf-wardrobe-coins {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--radius-pill, 999px);
  background: rgba(58, 29, 0, 0.16); font-variant-numeric: tabular-nums;
}
.pf-wardrobe-new {
  padding: 2px 8px; border-radius: var(--radius-pill, 999px); font-size: 11px; font-weight: 900;
  letter-spacing: 0.04em; text-transform: uppercase; background: #3A1D00; color: #FFE27A;
}
@media (prefers-reduced-motion: reduce) {
  .pf-ojito { animation: none; transition: none; }
}
.pf-wardrobe-slot { max-width: 100%; }
/* Móvil estrecho: Ojito algo menor para que el nombre tenga sitio */
@media (max-width: 419px) {
  .pf-hero { padding: 22px 16px 16px; }
  .pf-hero-id { gap: 12px; }
  .pf-ojito, .pf-ojito .ojito, .pf-ojito svg { width: 108px; height: 108px; }
}
@media (max-width: 479px) {
  .pf-wardrobe { gap: 6px; padding: 0 12px; }
  .pf-wardrobe > .pf-ic, .pf-wardrobe-new { display: none; }
}

/* --- Cuenta (invitado / Google) ------------------------------------------------ */
.pf-account {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
}
.pf-acc-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pf-acc-badge { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: #fff; }
.pf-acc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-acc-title { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); }
.pf-acc-sub { margin: 0; font-size: 15px; line-height: 1.4; color: var(--ink-2); }
.pf-acc-kind { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.pf-acc-email {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-acc-gbtn {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  /* el iframe de Google tiene ancho propio (se calcula con el ancho de la tarjeta): nunca desborda */
  max-width: 100%;
}
.pf-acc-gbtn .auth-gis { display: flex; justify-content: center; width: 100%; min-height: 44px; }
/* El iframe de Google es un documento en tema claro: con la página en oscuro el navegador le pinta un fondo
   opaco (esquinas blancas alrededor de la pastilla). Mismo color-scheme que el iframe = fondo transparente. */
.pf-acc-gbtn .auth-gis, .pf-acc-gbtn .auth-gis iframe { color-scheme: light; }
.pf-acc-gbtn .auth-gis > div { border-radius: 999px; }
/* Mismo ancho máximo que el botón oficial (400 px) y que los de email: columna de botones simétrica */
.pf-acc-gbtn .auth-dev-btn { width: 100%; max-width: 400px; min-height: 46px; }
.pf-acc-wait, .pf-acc-unavail { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); text-align: center; }
.pf-acc-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.pf-acc-note a { color: var(--accent-text, var(--brand-1)); font-weight: 700; text-underline-offset: 2px; }

.pf-acc-sync {
  --pf-dot: var(--good);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--pf-dot) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--pf-dot) 28%, transparent);
}
.pf-acc-sync[data-tone="brand"] { --pf-dot: var(--brand-1, var(--accent)); }
.pf-acc-sync[data-tone="warn"] { --pf-dot: var(--warn); }
.pf-acc-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--pf-dot);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pf-dot) 22%, transparent);
}
.pf-acc-sync[data-tone="brand"] .pf-acc-dot { animation: pf-blink 1.2s ease-in-out infinite; }
.pf-acc-sync-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-acc-sync-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.pf-acc-sync-time { margin: 0; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pf-signout { width: 100%; min-height: 46px; }

/* --- Amigos ---------------------------------------------------------------------- */
.pf-fr-count {
  min-width: 28px;
  padding: 2px 10px;
  border-radius: var(--radius-pill, 999px);
  background: var(--accent-soft);
  color: var(--accent-text, var(--brand-1));
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}
.pf-fr-count[hidden] { display: none; }
.pf-friends {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-xl, 22px);
  background: var(--glass, var(--surface));
  border: 1px solid var(--glass-border, var(--separator));
  min-width: 0;
}
.pf-fr-top { display: flex; flex-direction: column; gap: 12px; }
.pf-fr-codebox { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pf-fr-code-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.pf-fr-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  border: 1px dashed color-mix(in srgb, var(--brand-1, #7C5CFF) 55%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--brand-1, #7C5CFF) 10%, transparent);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms var(--ease-spring, ease);
}
.pf-fr-code:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-1, #7C5CFF) 16%, transparent); }
.pf-fr-code:active:not(:disabled) { transform: scale(0.98); }
.pf-fr-code:disabled { cursor: default; }
.pf-fr-code:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 2px; }
.pf-fr-code > .pf-ic { color: var(--accent-text, var(--brand-1)); }
.pf-fr-code-text {
  display: inline-flex;
  gap: 0.6em;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.1;
}
.pf-fr-skel { color: var(--ink-3); }
.pf-fr-share { width: 100%; min-height: 48px; }

.pf-fr-add { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.pf-fr-add-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.pf-fr-add-row { display: flex; gap: 8px; min-width: 0; }
.pf-fr-input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--glass, var(--surface));
  box-shadow: inset 0 0 0 1px var(--glass-border, var(--separator)), inset 0 1px 2px rgba(0, 0, 0, 0.12);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pf-fr-input::placeholder { color: var(--ink-3); letter-spacing: 0.08em; font-weight: 600; }
.pf-fr-input:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--brand-1, var(--accent)), 0 0 0 4px rgba(124, 92, 255, 0.22);
}
.pf-fr-input[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--bad); }
.pf-fr-addbtn { flex: none; min-height: 48px; padding: 0 18px; }
.pf-fr-err, .pf-fsheet-err { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--bad-text, var(--bad)); }
.pf-fr-err[hidden], .pf-fsheet-err[hidden] { display: none; }

.pf-fr-listwrap { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--separator); }
.pf-fr-list-title { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.pf-fr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; }
.pf-fr-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 6px 0; }
.pf-fr-row + .pf-fr-row { border-top: 1px solid var(--separator); }
.pf-fr-row-skel { min-height: 52px; border-radius: 14px; background: var(--surface-2); opacity: 0.55; animation: pf-blink 1.4s ease-in-out infinite; }
.pf-fr-row-skel + .pf-fr-row-skel { margin-top: 8px; border-top: 0; }
.pf-fr-fig { flex: none; display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border-radius: 50%; }
.pf-fr-fig > * { max-width: 100%; max-height: 100%; }
.pf-fr-fig .avatar { display: block; border-radius: 50%; }
.pf-fr-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pf-fr-name { font-size: 16px; font-weight: 700; color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pf-fr-since { font-size: 13px; color: var(--ink-2); }
.pf-fr-remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.pf-fr-remove:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad-text, var(--bad)); }
.pf-fr-remove:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 1px; }
.pf-fr-empty { margin: 0; padding: 6px 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.pf-fr-offline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 0; }
.pf-fr-offline p { margin: 0; flex: 1 1 200px; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.pf-fr-offline .btn { min-height: 44px; }

/* Código + Invitar en una fila solo si la tarjeta es ancha (en escritorio vive en la columna estrecha) */
.pf-friends { container-type: inline-size; }
@container (min-width: 480px) {
  .pf-fr-top { flex-direction: row; align-items: flex-end; }
  .pf-fr-codebox { flex: 1; }
  .pf-fr-share { width: auto; flex: none; min-height: 56px; padding: 0 22px; }
}

/* --- Hojas: invitación de amigo (main.js), confirmaciones y borrado --------------- */
/* Sin prefijo de pantalla: la hoja de invitación se abre sobre el ranking. */
.pf-fsheet, .pf-csheet, .pf-dsheet { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 8px; }
.pf-fsheet { align-items: center; text-align: center; }
.pf-fsheet-loading, .pf-fsheet-msg { margin: 0; padding: 18px 0 6px; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.pf-fsheet-fig { display: grid; place-items: center; min-height: 96px; }
.pf-fsheet-fig .avatar { border-radius: 50%; box-shadow: 0 10px 30px -12px rgba(124, 92, 255, 0.8); }
.pf-fsheet-q { margin: 0; max-width: 32ch; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.pf-fsheet-hint { margin: 0; max-width: 40ch; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.pf-fsheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 4px; }
.pf-fsheet-actions > .btn { min-height: 50px; width: 100%; min-width: 0; padding: 8px 14px; white-space: normal; text-align: center; }
.pf-fsheet-actions > .btn:only-child { grid-column: 1 / -1; }
.pf-csheet-text { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink); }

.pf-danger {
  background: var(--grad-bad, #E8385A);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(255, 77, 106, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.pf-danger:disabled { opacity: 0.45; box-shadow: none; }

.pf-dsheet-head { display: flex; align-items: center; gap: 12px; }
.pf-dsheet-ic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: #fff; }
.pf-dsheet-lead { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: -0.02em; color: var(--bad-text, var(--bad)); }
.pf-dsheet-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.45; color: var(--ink); }
.pf-dsheet-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  cursor: pointer;
}
.pf-dsheet-cb { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--bad); cursor: pointer; }
.pf-dsheet-cb:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 2px; }

@keyframes pf-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .pf-acc-sync[data-tone="brand"] .pf-acc-dot, .pf-fr-row-skel { animation: none; }
  .pf-fr-code { transition: none; }
}

/* --- Cuentas con email (Fase 2): tarjeta Cuenta y hojas de formulario --------------- */
/* Las hojas pueden abrirse sobre /perfil o desde /restablecer: sin depender de body[data-screen]. */
.pf-acc-gbtn[hidden], .pf-acc-or[hidden], .pf-acc-mail[hidden], .pf-acc-pwbtn[hidden] { display: none; }
.pf-acc-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
}
.pf-acc-or::before, .pf-acc-or::after { content: ""; flex: 1; height: 1px; background: var(--separator); }
.pf-acc-mail { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pf-acc-mailbtn { width: 100%; max-width: 400px; min-height: 46px; }
.pf-acc-mailbtn svg, .pf-acc-pwbtn svg, .pf-signout svg { flex: none; }
.pf-acc-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pf-acc-actions > .btn { flex: 1 1 180px; min-height: 46px; width: auto; }

.pf-af, .pf-af-box { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 8px; margin: 0; }
.pf-af-box > .pf-af { padding: 0; }
.pf-af-lead { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.pf-af-lead a { color: var(--accent-text); font-weight: 700; text-underline-offset: 2px; overflow-wrap: anywhere; }
.pf-af-field { min-width: 0; }
.pf-af-field .pf-af-input[aria-invalid="true"] {
  box-shadow: inset 0 0 0 1.5px var(--bad), 0 0 0 4px color-mix(in srgb, var(--bad) 18%, transparent);
}
.pf-af-hint { margin: 0; font-size: 13px; line-height: 1.4; }
.pf-af-pw { position: relative; display: flex; }
.pf-af-pw .pf-af-input { padding-right: 56px; }
.pf-af-eye {
  position: absolute;
  top: 50%;
  right: 3px;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.pf-af-eye:hover { background: var(--accent-soft); color: var(--accent-text); }
.pf-af-eye:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: -2px; }
.pf-af-eye .pf-af-slash { opacity: 0; transition: opacity 150ms ease; }
.pf-af-eye[aria-pressed="true"] { color: var(--accent-text); }
.pf-af-eye[aria-pressed="true"] .pf-af-slash { opacity: 1; }
.pf-af-err {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  color: var(--bad-text, var(--bad));
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}
.pf-af-err:empty { display: none; }
.pf-af-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent);
  text-underline-offset: 3px;
}
.pf-af-link:hover { text-decoration-color: currentColor; }
.pf-af-link:focus-visible { outline: 2px solid var(--brand-1, var(--accent)); outline-offset: 2px; border-radius: 8px; }
.pf-af-row-end { display: flex; justify-content: flex-end; margin: -8px 0 -4px; }
.pf-af-switch { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; margin: -2px 0 0; font-size: 15px; color: var(--ink-2); }
.pf-af-legal { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.pf-af-legal a { color: var(--accent-text); font-weight: 700; text-underline-offset: 2px; }
.pf-af-submit { margin-top: 2px; }
.pf-af-spin {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: pf-spin 800ms linear infinite;
}
.pf-af-submit[aria-busy="true"] { opacity: 0.85; cursor: progress; }
.pf-af-submit[aria-busy="true"] .pf-af-spin { display: inline-block; }
.pf-af-user { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
.pf-af-done { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 2px; text-align: center; }
.pf-af-done-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; }
.pf-af-done strong { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.pf-af-done p { margin: 0; max-width: 38ch; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
@keyframes pf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pf-af-spin { animation-duration: 2.4s; }
  .pf-af-eye, .pf-af-eye .pf-af-slash { transition: none; }
}

/* Hoja «Editar nombre»: pista legible (ink-2, no ink-3) y error con el mismo rojo accesible que el resto */
.pf-name-hint { margin: 6px 0 0; color: var(--ink-2); }
.pf-name-err { margin: 6px 0 0; color: var(--bad-text, var(--bad)); font-weight: 600; }
.pf-name-err[hidden] { display: none; }
