/* Ranking de muertes (BETA) — v22.16: podio + lista con barras. Familia «placa Exiles» (DESIGN.md §24).
   Solo tokens de :root. Adaptativo por contenedor (@container sobre .rk), no por viewport.
   Sin style="" (CSP): el color de cada clasificación va en --rk por clase, las barras de la lista en .rk-w-N y la barra de
   composición del ganador es un <svg> con atributos. */
.rk {
  --rank-1: var(--tone-gold); --rank-2: #b9b2a6; --rank-3: #b8743a;   /* oro · plata · bronce del podio */
  --rk: var(--tone-gold);
  max-width: 1040px; margin: 0 auto; padding-block: clamp(1.2rem, 3vw, 2.2rem) 2.5rem;
  container: rk / inline-size;
}
.rk-b-all { --rk: var(--tone-gold); }
.rk-b-pvp { --rk: var(--tone-red); }
.rk-b-pve { --rk: var(--tone-green); }

/* ---------- Cabecera y avisos ---------- */
.rk-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; font: 400 calc(var(--fs-h1) * .85)/1.2 var(--font-title); letter-spacing: .03em; -webkit-text-stroke: .03em currentColor; text-transform: uppercase; color: var(--text-strong); }

/* Una sola franja: «cuenta muertes sufridas» + BETA */
.rk-head .rk-beta { font: 800 var(--fs-xs)/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; -webkit-text-stroke: 0; }
.rk-notes { display: grid; grid-template-columns: 1fr 1fr; margin: 1.1rem 0 1.3rem; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(224, 180, 74, .14); }
.rk-notes > p { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem 1rem; font-size: var(--fs-sm); line-height: 1.5; color: var(--text); }
.rk-notes > p:only-child { grid-column: 1 / -1; }
.rk-notes > p + p { border-left: 1px solid var(--border); }
.rk-notes .ico { flex: none; margin-top: .1rem; color: var(--tone-gold); }
.rk-notes strong { color: var(--text-strong); }
.rk-notes .is-beta .ico { color: var(--warn); }
.rk .alert { margin-bottom: 1.1rem; }

/* ---------- Pestañas (control segmentado: --radius-lg fuera, --radius dentro) ---------- */
.rk-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; padding: .35rem; margin-bottom: 1.2rem; background: rgba(0, 0, 0, .25); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.rk-tab { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .7rem; min-height: 56px; padding: .45rem .9rem; text-align: left; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted); font: inherit; cursor: pointer; transition: var(--transition); }
.rk-tab .ico { grid-row: span 2; color: var(--rk); }
.rk-tab b { font-size: var(--fs-base); font-weight: 700; letter-spacing: .03em; color: inherit; }
.rk-tab small { font-size: var(--fs-xs); color: var(--muted-dark); line-height: 1.25; }
.rk-tab:hover { background: rgba(255, 255, 255, .05); color: var(--text-strong); }
.rk-tab.is-active { color: var(--text-strong); border-color: color-mix(in srgb, var(--rk) 65%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--rk) 20%, var(--surface-2)), var(--surface)); box-shadow: inset 0 1px 0 rgba(255, 233, 200, .07), var(--shadow-sm); }
.rk-tab.is-active small { color: var(--muted); }
.rk-tab:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .rk-tab.is-active { border-color: var(--border-accent); } }

/* ---------- Placa del tablero ---------- */
.rk-board { position: relative; margin-bottom: 1.8rem; padding: clamp(1rem, 3cqw, 1.8rem); background: linear-gradient(170deg, var(--surface-2), var(--surface) 60%); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(224, 180, 74, .18); }
.rk-board::before { content: ""; position: absolute; left: 1.2rem; top: -1px; width: 54px; height: 3px; background: var(--rk); }
.rk-board[hidden] { display: none; }

/* Fuego del campeón: resplandor y brasas detrás del podio, teñidos con el color de la clasificación (--rk). Solo transform/opacity */
.rk-board:has(.rk-fire) { isolation: isolate; background: radial-gradient(60% 26rem at 50% 24rem, color-mix(in srgb, var(--rk) 24%, transparent), transparent 70%), linear-gradient(170deg, var(--surface-2), var(--surface) 60%); }
.rk-fire { position: absolute; z-index: -1; top: 0; left: 0; right: 0; height: min(25rem, 100%); overflow: hidden; pointer-events: none; }
.rk-fire i { position: absolute; bottom: -8px; width: 3px; height: 3px; border-radius: 50%; background: #ffad55; background: color-mix(in srgb, var(--rk) 75%, #ffd9a0); opacity: 0; animation: rk-ember 6s linear infinite; }
.rk-fire i:nth-child(3n) { width: 4px; height: 4px; }
.rk-fire i:nth-child(4n) { width: 2px; height: 2px; }
.rk-fire i:nth-child(1) { left: 62%; animation-delay: -1.7s; animation-duration: 6s; --dx: -14px; }
.rk-fire i:nth-child(2) { left: 26%; animation-delay: -3.4s; animation-duration: 7s; --dx: 0px; }
.rk-fire i:nth-child(3) { left: 87%; animation-delay: -5.1s; animation-duration: 8s; --dx: 14px; }
.rk-fire i:nth-child(4) { left: 51%; animation-delay: -6.8s; animation-duration: 9s; --dx: 28px; }
.rk-fire i:nth-child(5) { left: 15%; animation-delay: -1.5s; animation-duration: 10s; --dx: -28px; }
.rk-fire i:nth-child(6) { left: 76%; animation-delay: -3.2s; animation-duration: 5s; --dx: -14px; }
.rk-fire i:nth-child(7) { left: 40%; animation-delay: -4.9s; animation-duration: 6s; --dx: 0px; }
.rk-fire i:nth-child(8) { left: 4%; animation-delay: -6.6s; animation-duration: 7s; --dx: 14px; }
.rk-fire i:nth-child(9) { left: 65%; animation-delay: -1.3s; animation-duration: 8s; --dx: 28px; }
.rk-fire i:nth-child(10) { left: 29%; animation-delay: -3.0s; animation-duration: 9s; --dx: -28px; }
.rk-fire i:nth-child(11) { left: 90%; animation-delay: -4.7s; animation-duration: 10s; --dx: -14px; }
.rk-fire i:nth-child(12) { left: 54%; animation-delay: -6.4s; animation-duration: 5s; --dx: 0px; }
.rk-fire i:nth-child(13) { left: 18%; animation-delay: -1.1s; animation-duration: 6s; --dx: 14px; }
.rk-fire i:nth-child(14) { left: 79%; animation-delay: -2.8s; animation-duration: 7s; --dx: 28px; }
.rk-fire i:nth-child(15) { left: 43%; animation-delay: -4.5s; animation-duration: 8s; --dx: -28px; }
.rk-fire i:nth-child(16) { left: 7%; animation-delay: -6.2s; animation-duration: 9s; --dx: -14px; }
.rk-fire i:nth-child(17) { left: 68%; animation-delay: -0.9s; animation-duration: 10s; --dx: 0px; }
.rk-fire i:nth-child(18) { left: 32%; animation-delay: -2.6s; animation-duration: 5s; --dx: 14px; }
.rk-fire i:nth-child(19) { left: 93%; animation-delay: -4.3s; animation-duration: 6s; --dx: 28px; }
.rk-fire i:nth-child(20) { left: 57%; animation-delay: -6.0s; animation-duration: 7s; --dx: -28px; }
.rk-fire i:nth-child(21) { left: 21%; animation-delay: -0.7s; animation-duration: 8s; --dx: -14px; }
.rk-fire i:nth-child(22) { left: 82%; animation-delay: -2.4s; animation-duration: 9s; --dx: 0px; }
.rk-fire i:nth-child(23) { left: 46%; animation-delay: -4.1s; animation-duration: 10s; --dx: 14px; }
.rk-fire i:nth-child(24) { left: 10%; animation-delay: -5.8s; animation-duration: 5s; --dx: 28px; }
.rk-fire i:nth-child(25) { left: 71%; animation-delay: -0.5s; animation-duration: 6s; --dx: -28px; }
.rk-fire i:nth-child(26) { left: 35%; animation-delay: -2.2s; animation-duration: 7s; --dx: -14px; }
.rk-fire i:nth-child(27) { left: 96%; animation-delay: -3.9s; animation-duration: 8s; --dx: 0px; }
.rk-fire i:nth-child(28) { left: 60%; animation-delay: -5.6s; animation-duration: 9s; --dx: 14px; }
.rk-fire i:nth-child(29) { left: 24%; animation-delay: -0.3s; animation-duration: 10s; --dx: 28px; }
.rk-fire i:nth-child(30) { left: 85%; animation-delay: -2.0s; animation-duration: 5s; --dx: -28px; }
@keyframes rk-ember { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translate(var(--dx, 20px), -24rem); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .rk-fire i { display: none; } }
.rk-board-t { margin: 0 0 1rem; font: 400 var(--fs-h3)/1.2 var(--font-display); color: var(--text-strong); }
.rk.is-js .rk-board-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* con pestañas el título lo da la pestaña */
.rk:not(.is-js) .rk-tabs { display: none; }
.rk:not(.is-js) .rk-board { margin-bottom: 1.4rem; }

/* ---------- Podio: 2 · 1 · 3 ---------- */
.rk-podium { display: grid; grid-template-columns: 1fr 1.35fr 1fr; align-items: end; gap: clamp(.6rem, 2cqw, 1.2rem); margin: 0; padding: 0; list-style: none; }
.rk-podium.is-n1 { grid-template-columns: minmax(0, 24rem); justify-content: center; }
.rk-podium.is-n2 { grid-template-columns: repeat(2, minmax(0, 17rem)); justify-content: center; }
.rk-podium.is-n2 .rk-pd-1 { order: 1; } .rk-podium.is-n2 .rk-pd-2 { order: 2; }
.rk-pd { --pc: var(--rank-2); position: relative; display: flex; flex-direction: column; align-items: center; gap: .55rem; min-width: 0; padding: 1.1rem .8rem 1rem; text-align: center; background: linear-gradient(180deg, rgba(0, 0, 0, .18), rgba(0, 0, 0, .3)); border: 1px solid color-mix(in srgb, var(--pc) 40%, var(--border)); border-radius: var(--radius); }
.rk-pd-1 { --pc: var(--rank-1); order: 2; padding-block: 1.5rem 1.3rem; background: radial-gradient(ellipse at 50% 0, color-mix(in srgb, var(--rk) 26%, transparent), transparent 70%), linear-gradient(180deg, var(--surface-2), var(--surface)); border-color: color-mix(in srgb, var(--rk) 65%, var(--border)); box-shadow: var(--shadow-sm); }
.rk-pd-2 { order: 1; }
.rk-pd-3 { --pc: var(--rank-3); order: 3; }
.rk-medal { position: absolute; top: -.85rem; left: 50%; translate: -50% 0; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; font: 400 1rem/1 var(--font-display); color: #1a1006; background: var(--pc); border: 2px solid var(--surface); box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.rk-pd-1 .rk-medal { width: 2.3rem; height: 2.3rem; top: -1.1rem; font-size: 1.2rem; }
.rk-pd-av { display: block; margin-top: .3rem; }
.rk-pd-name { max-width: 100%; font: 400 var(--fs-h4)/1.2 var(--font-display); color: var(--text-strong); overflow-wrap: anywhere; }
.rk-pd-1 .rk-pd-name { font-size: var(--fs-h3); }
.rk-pd-n { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.rk-pd-n strong { font: 400 clamp(1.8rem, 6cqw, 2.4rem)/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--pc); }
.rk-pd-1 .rk-pd-n strong { font-size: clamp(2.6rem, 9cqw, 3.8rem); text-shadow: 0 0 18px color-mix(in srgb, var(--rk) 45%, transparent); }
.rk-pd-n span { margin-top: .3rem; font-size: var(--fs-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* Marco de piedra y bronce: solo el ganador (esquinas doradas opuestas, solo CSS) */
.rk-frame { position: relative; margin-top: .4rem; padding: 10px; border-radius: var(--radius-sm); border: 2px solid #2d1d07; background: linear-gradient(145deg, var(--border-strong), #2a1d12 45%, var(--border)); box-shadow: inset 0 0 0 2px rgba(224, 180, 74, .3), 0 0 26px color-mix(in srgb, var(--rk) 30%, transparent), 0 10px 22px rgba(0, 0, 0, .55); }
.rk-frame::after { content: ""; position: absolute; inset: -4px; pointer-events: none;
  background: linear-gradient(var(--tone-gold), var(--tone-gold)) left top / 26px 3px no-repeat, linear-gradient(var(--tone-gold), var(--tone-gold)) left top / 3px 26px no-repeat,
              linear-gradient(var(--tone-gold), var(--tone-gold)) right bottom / 26px 3px no-repeat, linear-gradient(var(--tone-gold), var(--tone-gold)) right bottom / 3px 26px no-repeat; }
.rk-av { display: block; width: 128px; height: 128px; object-fit: cover; border: 2px solid #120c08; border-radius: 3px; background: var(--surface); }
/* Avatares del podio y de la lista: cuadrados redondeados dentro de la placa (el marco de staff se conserva) */
.rk .av-img, .rk .av-frame, .rk .av-plain { border-radius: var(--radius-sm); }
.rk .av-sm.av-plain .av-img { border: 1px solid var(--border-strong); }

/* Nombres y clanes pulsables */
.rk-name { max-width: 100%; font-weight: 700; color: var(--text-strong); overflow-wrap: anywhere; }
a.rk-name, a.rk-pd-name { text-decoration: underline; text-decoration-color: rgba(212, 163, 77, .5); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a.rk-name:hover, a.rk-pd-name:hover, a.rk-name:focus-visible, a.rk-pd-name:focus-visible { color: var(--accent-hover); text-decoration-color: currentColor; }
a.rk-name:focus-visible, a.rk-pd-name:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; border-radius: 4px; }
.rk-name.is-plain, .rk-pd-name.is-plain { cursor: default; }
button.rk-clan { display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; margin: -.15rem -.4rem; padding: .15rem .4rem; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--fs-sm); color: var(--muted); text-align: left; cursor: pointer; transition: var(--transition); }
.rk-clan-ico { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; color: var(--tone, var(--muted)); }
.rk-clan-ico .clan-logo { width: 20px; height: 20px; object-fit: contain; }
.rk-clan-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.rk-clan:hover { background: rgba(255, 255, 255, .07); }
button.rk-clan:hover .rk-clan-n, button.rk-clan:focus-visible .rk-clan-n { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
button.rk-clan:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 1px; }
.rk-noclan { font-size: var(--fs-sm); color: var(--muted-dark); }

/* ---------- Desglose del ganador ---------- */
.rk-detail { margin-top: 1.2rem; padding: .9rem 1.1rem; background: rgba(0, 0, 0, .22); border: 1px solid var(--border); border-radius: var(--radius); }
.rk-detail h3 { margin-bottom: .6rem; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.rk-detail h3 b { color: var(--text-strong); letter-spacing: .02em; text-transform: none; font-weight: 600; }
.rk-comp { display: block; width: 100%; height: 10px; border-radius: 999px; background: var(--surface-3); }
.rk-comp rect { height: 1px; }
.rk-comp .k-pvp { fill: var(--tone-red); } .rk-comp .k-pve { fill: var(--tone-green); } .rk-comp .k-env { fill: var(--muted-dark); }
.rk-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin: .7rem 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--muted); }
.rk-legend li { display: inline-flex; align-items: center; gap: .45rem; }
.rk-legend li::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--k); }
.rk-legend b { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.rk-legend .k-pvp { --k: var(--tone-red); } .rk-legend .k-pve { --k: var(--tone-green); } .rk-legend .k-env { --k: var(--muted-dark); }
.rk-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.rk-chips li { display: inline-flex; align-items: baseline; gap: .5rem; padding: .3rem .85rem; background: rgba(0, 0, 0, .25); border: 1px solid var(--border-strong); border-radius: 999px; font-size: var(--fs-sm); }
.rk-chips b { font-size: var(--fs-lg); color: var(--rk); font-variant-numeric: tabular-nums; }

/* ---------- Lista del 4.º al 10.º ---------- */
.rk-list { margin: 1.3rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border-strong); }
.rk-row { display: grid; grid-template-columns: 2.25rem 50px minmax(0, 1fr) minmax(80px, 30%) 3.6rem; align-items: center; column-gap: .9rem; padding: .6rem .4rem; border-bottom: 1px solid var(--border); transition: var(--transition); }
.rk-row:nth-child(even) { background: rgba(255, 255, 255, .02); }
.rk-row:hover { background: rgba(255, 255, 255, .05); }
/* El avatar con marco de staff mide 6px más que la imagen: la columna lo contempla y no se estira ni se corta */
.rk-row > .av-sm { justify-self: center; }
.rk-pos { display: inline-grid; place-items: center; justify-self: center; min-width: 2rem; height: 2rem; border-radius: 999px; font-size: var(--fs-sm); font-weight: 700; color: var(--text); background: var(--surface-3); border: 1px solid var(--border-strong); font-variant-numeric: tabular-nums; }
.rk-who { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-width: 0; }
.rk-bar { height: 6px; border-radius: 999px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.rk-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--rk) 55%, var(--surface-3)), var(--rk)); }
.rk-num { text-align: right; font: 400 var(--fs-h4)/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--text-strong); }
.rk-empty { margin: 0; padding: 1.6rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.rk-w-5{width:5%}.rk-w-10{width:10%}.rk-w-15{width:15%}.rk-w-20{width:20%}.rk-w-25{width:25%}.rk-w-30{width:30%}.rk-w-35{width:35%}.rk-w-40{width:40%}.rk-w-45{width:45%}.rk-w-50{width:50%}
.rk-w-55{width:55%}.rk-w-60{width:60%}.rk-w-65{width:65%}.rk-w-70{width:70%}.rk-w-75{width:75%}.rk-w-80{width:80%}.rk-w-85{width:85%}.rk-w-90{width:90%}.rk-w-95{width:95%}.rk-w-100{width:100%}

/* ====================== Adaptativo por contenedor ====================== */
@container rk (max-width: 760px) {
  .rk-head .rk-beta { font: 800 var(--fs-xs)/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; -webkit-text-stroke: 0; }
.rk-notes { grid-template-columns: 1fr; }
  .rk-notes > p + p { border-left: 0; border-top: 1px solid var(--border); }
  .rk-tab small { display: none; }
  .rk-tab { grid-template-columns: 1fr; justify-items: center; row-gap: .15rem; min-height: 58px; padding-inline: .4rem; text-align: center; }
  .rk-tab .ico { grid-row: auto; }
  .rk-tab b { font-size: var(--fs-sm); }
}
@container rk (max-width: 600px) {
  /* Podio: el ganador arriba a todo el ancho; 2.º y 3.º lado a lado */
  .rk-podium { grid-template-columns: 1fr 1fr; align-items: stretch; row-gap: 1.4rem; }
  .rk-podium.is-n1 { grid-template-columns: 1fr; }
  .rk-pd-1 { order: 0; grid-column: 1 / -1; margin-top: .8rem; }
  .rk-av { width: 112px; height: 112px; }
  /* Fila: puesto · avatar · nombre · muertes, y la barra debajo */
  .rk-row { grid-template-columns: 2rem 46px minmax(0, 1fr) auto; grid-template-areas: "pos av who num" ". . bar bar"; column-gap: .7rem; row-gap: .45rem; padding: .7rem .3rem; }
  .rk-pos { grid-area: pos; } .rk-row .av-img { width: 40px; height: 40px; } .rk-row > :nth-child(2) { grid-area: av; } .rk-who { grid-area: who; } .rk-row .rk-bar { grid-area: bar; } .rk-num { grid-area: num; }
}
@container rk (max-width: 320px) {
  .rk-podium { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .rk * { transition: none !important; } }
