/* =====================================================================
   CAEDES FEROX - Sistema visual
   Negro, rojo y grises oscuros. Estetica gaming competitiva.
   ===================================================================== */

:root {
    /* Superficies, de la mas profunda a la mas elevada */
    --bg-void:      #050506;
    --bg-base:      #0A0A0C;
    --bg-surface:   #111114;
    --bg-raised:    #17171B;
    --bg-overlay:   #1E1E24;
    --bg-hover:     #232329;

    /* Rojo de la marca */
    --red:          #E11D2A;
    --red-bright:   #FF2D3E;
    --red-deep:     #9E0E19;
    --red-glow:     rgba(225, 29, 42, 0.35);
    --red-faint:    rgba(225, 29, 42, 0.08);
    --red-line:     rgba(225, 29, 42, 0.25);

    /* Texto */
    --text:         #F2F3F5;
    --text-soft:    #A8ACB4;
    --text-dim:     #6E727B;
    --text-faint:   #4A4D55;

    /* Bordes */
    --line:         #24242B;
    --line-soft:    #1B1B21;
    --line-bright:  #33333C;

    /* Estados */
    --ok:           #2ECC71;
    --warn:         #F0A500;
    --danger:       #FF4757;
    --info:         #3A9BFF;

    /* Rarezas de medallas */
    --r-comun:      #8A8F98;
    --r-poco:       #4FB477;
    --r-rara:       #3A9BFF;
    --r-epica:      #B93BFF;
    --r-legendaria: #FFB020;
    --r-exclusiva:  #FF2D3E;

    /* Formas */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-full: 999px;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
    --shadow-red: 0 6px 24px rgba(225, 29, 42, 0.28);

    /* Medidas del armazon */
    --header-h: 62px;
    --bottom-h: 68px;
    --sidebar-w: 264px;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------------------
   Base
   -------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-base);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, 'Roboto', 'Helvetica Neue', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Resplandor rojo tenue de fondo, fijo tras todo el contenido */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(1000px 520px at 12% -10%, rgba(225, 29, 42, 0.10), transparent 62%),
        radial-gradient(760px 420px at 100% 4%, rgba(225, 29, 42, 0.06), transparent 60%);
}

h1, h2, h3, h4, h5 {
    margin: 0 0 .5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    /* Los nicknames de Free Fire son palabras largas sin espacios: sin esto
       se salen del contenedor y arrastran la pagina a lo ancho. */
    overflow-wrap: anywhere;
}

/* Icon::render() emite los SVG sin width ni height. Si ninguna regla de
   componente les da tamano, el navegador usa el de un objeto sin dimensiones
   (300x150) y el icono sale gigante, ensanchando la pagina entera. Este es
   el tamano por defecto; al ser un selector de elemento, cualquier regla de
   componente (.btn svg, .icon-btn svg, .card-title svg...) sigue mandando. */
svg {
    width: 1.05em;
    height: 1.05em;
    flex: none;
    vertical-align: -0.15em;
}

h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: 1.08rem; }
h4 { font-size: .96rem; }

p { margin: 0 0 .85rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--red-bright);
    text-decoration: none;
    transition: color .18s var(--ease);
}
a:hover { color: #FF6070; }

img { max-width: 100%; display: block; }

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1.25rem 0;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
    background: var(--line-bright);
    border-radius: var(--r-full);
    border: 2px solid var(--bg-base);
}
::-webkit-scrollbar-thumb:hover { background: var(--red-deep); }

::selection { background: var(--red); color: #fff; }

:focus-visible {
    outline: 2px solid var(--red-bright);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------
   Tipografia de apoyo
   -------------------------------------------------------------------- */

.eyebrow {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.muted   { color: var(--text-soft); }
.dim     { color: var(--text-dim); }
.tiny    { font-size: .78rem; }
.small   { font-size: .86rem; }
.strong  { font-weight: 700; }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.red     { color: var(--red-bright); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); }
.mono {
    font-family: 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
    font-size: .88em;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------
   Armazon
   -------------------------------------------------------------------- */

.shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1;
    width: 100%;
    max-width: 1220px;
    margin: 0 auto;
    padding: 1.1rem 1rem calc(var(--bottom-h) + 2rem);
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-soft); font-size: .9rem; }

/* --------------------------------------------------------------------
   Cabecera
   -------------------------------------------------------------------- */

.header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 0 1rem;
    background: rgba(10, 10, 12, 0.86);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}

.header::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--red), transparent);
    opacity: .5;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
    font-weight: 900;
    letter-spacing: .04em;
    flex-shrink: 0;
}
.brand:hover { color: var(--text); }

.brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px var(--red-glow));
}

.brand-name {
    font-size: .96rem;
    line-height: 1.05;
}
.brand-name span {
    display: block;
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .22em;
    color: var(--red-bright);
}

.header-spacer { flex: 1; }

.header-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
}

/* Navegacion superior (escritorio) */
.top-nav {
    display: none;
    align-items: center;
    gap: .15rem;
    margin-left: .75rem;
}

.top-nav a {
    padding: .5rem .8rem;
    border-radius: var(--r-sm);
    color: var(--text-soft);
    font-size: .875rem;
    font-weight: 600;
    transition: all .18s var(--ease);
}

.top-nav a:hover {
    background: var(--bg-raised);
    color: var(--text);
}

.top-nav a.is-active {
    color: var(--text);
    background: var(--red-faint);
    box-shadow: inset 0 -2px 0 var(--red);
}

/* Boton icono de la cabecera */
.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    color: var(--text-soft);
    cursor: pointer;
    transition: all .18s var(--ease);
}

.icon-btn:hover {
    border-color: var(--red-line);
    color: var(--red-bright);
    background: var(--bg-raised);
}

.icon-btn svg { width: 19px; height: 19px; }

.badge-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    display: grid;
    place-items: center;
    border-radius: var(--r-full);
    background: var(--red);
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
    border: 2px solid var(--bg-base);
    animation: pop .25s var(--ease);
}

@keyframes pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Avatar de la cabecera */
.header-avatar {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .3rem .3rem .7rem;
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    background: var(--bg-surface);
    transition: all .18s var(--ease);
}
.header-avatar:hover { border-color: var(--red-line); }

.header-avatar .who {
    display: none;
    text-align: right;
    line-height: 1.15;
}
.header-avatar .who strong {
    display: block;
    font-size: .8rem;
    color: var(--text);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-avatar .who span { font-size: .66rem; color: var(--text-dim); }

/* --------------------------------------------------------------------
   Avatares
   -------------------------------------------------------------------- */

.avatar {
    position: relative;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--r-full);
    background: linear-gradient(135deg, var(--red-deep), #2A0A0E);
    color: #fff;
    font-weight: 800;
    font-size: .82rem;
    letter-spacing: .02em;
    overflow: hidden;
    border: 1px solid var(--line-bright);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar.xs { width: 28px; height: 28px; font-size: .62rem; }
.avatar.sm { width: 34px; height: 34px; font-size: .7rem; }
.avatar.lg { width: 62px; height: 62px; font-size: 1.2rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.9rem; border-width: 2px; }
.avatar.xxl { width: 128px; height: 128px; font-size: 2.6rem; border-width: 3px; }

.avatar.ring {
    box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--red);
}

/* --------------------------------------------------------------------
   Navegacion inferior (movil)
   -------------------------------------------------------------------- */

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    background: rgba(10, 10, 12, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
}

.bottom-nav a,
.bottom-nav button {
    position: relative;
    /* Base 0 y min-width 0: los huecos salen iguales aunque las etiquetas
       midan distinto. */
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    font-family: inherit;
    color: var(--text-dim);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    transition: color .18s var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav a span,
.bottom-nav button > span:not(.nav-more-icon):not(.nav-badge) {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottom-nav a svg { width: 21px; height: 21px; }

/* Boton "Mas": el + va dentro de un circulo para que se lea como accion y
   no como un apartado mas de la barra. */
.nav-more-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    background: linear-gradient(180deg, var(--red-bright), var(--red-deep));
    color: #fff;
    box-shadow: 0 2px 10px var(--red-glow);
}

.nav-more-icon svg { width: 17px; height: 17px; }

.bottom-nav .is-active { color: var(--red-bright); }

.bottom-nav .is-active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 34px;
    height: 3px;
    border-radius: 0 0 var(--r-full) var(--r-full);
    background: var(--red);
    box-shadow: 0 0 12px var(--red-glow);
}

.bottom-nav .nav-badge {
    position: absolute;
    top: 8px;
    right: calc(50% - 20px);
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    display: grid;
    place-items: center;
    border-radius: var(--r-full);
    background: var(--red);
    color: #fff;
    font-size: .58rem;
    font-weight: 800;
}

/* Hoja que despliega el boton "Mas" de la barra inferior.
   Reutiliza la maquinaria de los modales, pero anclada abajo. */
.nav-sheet-backdrop {
    align-items: flex-end;
    padding: 0;
}

.nav-sheet {
    width: 100%;
    background: var(--bg-surface);
    border-top: 1px solid var(--line-bright);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    /* Deja libre el alto de la barra para no taparla con la hoja. */
    padding: .9rem 1rem calc(1rem + var(--bottom-h) + env(safe-area-inset-bottom, 0px));
    animation: sheet-in .26s var(--ease);
}

@keyframes sheet-in {
    from { transform: translateY(100%); }
    to   { transform: none; }
}

.nav-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .8rem;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.nav-sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
}

.nav-sheet-grid a {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .95rem .35rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg-raised);
    color: var(--text-soft);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.nav-sheet-grid a svg { width: 22px; height: 22px; }

.nav-sheet-grid a.is-active {
    border-color: var(--red-line);
    color: var(--red-bright);
}

/* --------------------------------------------------------------------
   Tarjetas
   -------------------------------------------------------------------- */

.card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 1.1rem;
    transition: border-color .2s var(--ease), transform .2s var(--ease);
}

.card.hover:hover {
    border-color: var(--red-line);
    transform: translateY(-2px);
}

.card.flush { padding: 0; overflow: hidden; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .9rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--line-soft);
}

.card-head h2, .card-head h3 { margin: 0; }

.card-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .95rem;
    font-weight: 800;
}

.card-title svg {
    width: 17px;
    height: 17px;
    color: var(--red-bright);
}

/* Tarjeta con acento rojo lateral */
.card.accent::before {
    content: '';
    position: absolute;
    left: 0;
    top: 18%;
    bottom: 18%;
    width: 3px;
    border-radius: 0 var(--r-full) var(--r-full) 0;
    background: linear-gradient(180deg, var(--red-bright), var(--red-deep));
}

/* --------------------------------------------------------------------
   Rejillas
   -------------------------------------------------------------------- */

.grid { display: grid; gap: 1rem; }

/* Un item de rejilla no baja de su ancho de contenido minimo mientras no se
   le indique. Sin esto, la fila de pestanas -que ya trae su propio scroll
   horizontal- estira su columna hasta caber entera, y con ella el documento:
   la pagina acaba mas ancha que la pantalla y se puede arrastrar a los lados.
   Con min-width:0 la columna se ajusta al ancho disponible y las pestanas
   pasan a desplazarse por dentro, que es como estaban pensadas. */
.grid > *,
.split > * { min-width: 0; }

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-medals { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .85rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.tight { gap: .55rem; }
.row {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
.row.between { justify-content: space-between; }
.row.tight { gap: .35rem; }
.row.nowrap-row { flex-wrap: nowrap; }

.spacer { flex: 1; }

/* --------------------------------------------------------------------
   Estadisticas
   -------------------------------------------------------------------- */

.stat {
    position: relative;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color .2s var(--ease);
}

.stat:hover { border-color: var(--red-line); }

.stat::after {
    content: '';
    position: absolute;
    right: -26px;
    top: -26px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--red-faint);
}

.stat .label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: .3rem;
}

.stat .label svg { width: 13px; height: 13px; }

.stat .value {
    font-size: 1.65rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.stat .foot {
    margin-top: .2rem;
    font-size: .74rem;
    color: var(--text-dim);
}

.stat.is-red .value { color: var(--red-bright); }
.stat.is-ok .value { color: var(--ok); }
.stat.is-warn .value { color: var(--warn); }

/* Fila compacta de estadisticas del perfil */
.stat-row {
    display: grid;
    /* min() evita que el minimo de 84px sea mayor que el propio contenedor
       en pantallas estrechas, que es lo que provocaba el desbordamiento. */
    grid-template-columns: repeat(auto-fit, minmax(min(84px, 100%), 1fr));
    gap: .5rem;
}

.stat-chip {
    padding: .65rem .5rem;
    text-align: center;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    /* Sin esto una cifra larga de puntos ensancha su columna. */
    min-width: 0;
}

.stat-chip .n {
    display: block;
    font-size: 1.2rem;
    font-weight: 900;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.stat-chip .t {
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* --------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .62rem 1.05rem;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--red-bright), var(--red-deep));
    color: #fff;
    box-shadow: var(--shadow-red);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #FF4453, var(--red));
    box-shadow: 0 8px 30px rgba(225, 29, 42, 0.42);
}

.btn-outline {
    background: transparent;
    border-color: var(--line-bright);
    color: var(--text-soft);
}
.btn-outline:hover {
    border-color: var(--red);
    color: var(--red-bright);
    background: var(--red-faint);
}

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
}
.btn-ghost:hover { background: var(--bg-raised); color: var(--text); }

.btn-danger {
    background: transparent;
    border-color: rgba(255, 71, 87, 0.4);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(255, 71, 87, 0.12); }

.btn-ok {
    background: transparent;
    border-color: rgba(46, 204, 113, 0.4);
    color: var(--ok);
}
.btn-ok:hover { background: rgba(46, 204, 113, 0.12); }

.btn-sm { padding: .4rem .7rem; font-size: .78rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: .82rem 1.5rem; font-size: .95rem; }
.btn-block { width: 100%; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
}

.btn.is-loading {
    color: transparent;
    pointer-events: none;
    position: relative;
}
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------
   Etiquetas y distintivos
   -------------------------------------------------------------------- */

.tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .55rem;
    border-radius: var(--r-full);
    background: var(--bg-overlay);
    border: 1px solid var(--line);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--text-soft);
    white-space: nowrap;
}

.tag svg { width: 12px; height: 12px; }

.tag-red    { background: var(--red-faint); border-color: var(--red-line); color: var(--red-bright); }
.tag-ok     { background: rgba(46,204,113,.1); border-color: rgba(46,204,113,.3); color: var(--ok); }
.tag-warn   { background: rgba(240,165,0,.1); border-color: rgba(240,165,0,.3); color: var(--warn); }
.tag-danger { background: rgba(255,71,87,.1); border-color: rgba(255,71,87,.3); color: var(--danger); }
.tag-info   { background: rgba(58,155,255,.1); border-color: rgba(58,155,255,.3); color: var(--info); }

/* Distintivo de jerarquia; el color lo pone el lider */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: var(--r-full);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    border: 1px solid currentColor;
    background: color-mix(in srgb, currentColor 12%, transparent);
}

.role-badge svg { width: 12px; height: 12px; }

/* Rareza de medallas */
.rarity {
    font-size: .64rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.rarity-comun      { color: var(--r-comun); }
.rarity-poco_comun { color: var(--r-poco); }
.rarity-rara       { color: var(--r-rara); }
.rarity-epica      { color: var(--r-epica); }
.rarity-legendaria { color: var(--r-legendaria); }
.rarity-exclusiva  { color: var(--r-exclusiva); }

/* --------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------- */

.field { margin-bottom: .95rem; }

.field label,
.label {
    display: block;
    margin-bottom: .35rem;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text-soft);
}

.field .hint {
    margin-top: .3rem;
    font-size: .74rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: .65rem .8rem;
    background: var(--bg-void);
    border: 1px solid var(--line-bright);
    border-radius: var(--r-sm);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

.input:focus,
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-faint);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input[type="color"] {
    width: 52px;
    height: 38px;
    padding: 3px;
    cursor: pointer;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E727B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .65rem center;
    background-size: 15px;
    padding-right: 2.2rem;
}

input:disabled, select:disabled, textarea:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }

.field-error {
    margin-top: .28rem;
    font-size: .76rem;
    color: var(--danger);
}

/* Casillas e interruptores */
.check {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    padding: .5rem .65rem;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg-void);
    cursor: pointer;
    transition: all .18s var(--ease);
}

.check:hover { border-color: var(--line-bright); }

.check input[type="checkbox"],
.check input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 1px 0 0;
    flex-shrink: 0;
    accent-color: var(--red);
    cursor: pointer;
}

.check span { font-size: .85rem; line-height: 1.4; }
.check .check-desc {
    display: block;
    font-size: .74rem;
    color: var(--text-dim);
    margin-top: .1rem;
}

.check:has(input:checked) {
    border-color: var(--red-line);
    background: var(--red-faint);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .85rem;
}

fieldset {
    margin: 0 0 1.1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg-void);
}

legend {
    padding: 0 .5rem;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--red-bright);
}

/* Selector de archivo */
input[type="file"] {
    width: 100%;
    padding: .5rem;
    background: var(--bg-void);
    border: 1px dashed var(--line-bright);
    border-radius: var(--r-sm);
    color: var(--text-soft);
    font-size: .82rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: .7rem;
    padding: .35rem .75rem;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--bg-hover);
    color: var(--text);
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}

input[type="file"]:hover { border-color: var(--red-line); }

/* Barra de filtros */
.filters {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 1.1rem;
    padding: .85rem;
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.filters .field { margin: 0; flex: 1 1 160px; }
.filters .field label { font-size: .68rem; }

/* --------------------------------------------------------------------
   Avisos
   -------------------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    font-size: .875rem;
    line-height: 1.5;
    margin-bottom: .75rem;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { border-left-color: var(--ok);     color: #B7F5D0; background: rgba(46,204,113,.07); }
.alert-error   { border-left-color: var(--danger); color: #FFC9CE; background: rgba(255,71,87,.07); }
.alert-warning { border-left-color: var(--warn);   color: #FFE2AC; background: rgba(240,165,0,.07); }
.alert-info    { border-left-color: var(--info);   color: #C4E0FF; background: rgba(58,155,255,.07); }

/* Contenedor de notificaciones emergentes */
.toasts {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    right: 12px;
    left: 12px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem .9rem;
    background: var(--bg-overlay);
    border: 1px solid var(--line-bright);
    border-left: 3px solid var(--red);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    font-size: .86rem;
    pointer-events: auto;
    animation: toast-in .3s var(--ease);
}

.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
.toast svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.toast-success { border-left-color: var(--ok); }
.toast-success svg { color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-error svg { color: var(--danger); }
.toast-info svg { color: var(--info); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(20px); }
}

/* --------------------------------------------------------------------
   Estado vacio
   -------------------------------------------------------------------- */

.empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--text-dim);
}

.empty svg {
    width: 44px;
    height: 44px;
    margin-bottom: .7rem;
    opacity: .35;
}

.empty h3 {
    color: var(--text-soft);
    font-size: 1rem;
    margin-bottom: .3rem;
}

.empty p { font-size: .86rem; max-width: 380px; margin: 0 auto .85rem; }

/* --------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg-surface);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    min-width: 560px;
}

thead th {
    position: sticky;
    top: 0;
    padding: .7rem .85rem;
    text-align: left;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--line);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
}

tbody td {
    padding: .7rem .85rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: var(--bg-raised); }

td.actions {
    text-align: right;
    white-space: nowrap;
}

/* --------------------------------------------------------------------
   Paginacion
   -------------------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 36px;
    height: 36px;
    padding: 0 .55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    color: var(--text-soft);
    font-size: .84rem;
    font-weight: 700;
}

.pagination a:hover { border-color: var(--red-line); color: var(--red-bright); }
.pagination .is-current {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}
.pagination .is-disabled { opacity: .4; }

/* --------------------------------------------------------------------
   Modales
   -------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-backdrop.is-open {
    display: flex;
    animation: fade-in .2s var(--ease);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--line-bright);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in .28s var(--ease);
    overflow: hidden;
}

.modal.wide { max-width: 760px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-size: 1.02rem; }

.modal-body {
    padding: 1.15rem;
    overflow-y: auto;
    flex: 1;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .9rem 1.15rem;
    border-top: 1px solid var(--line);
    background: var(--bg-void);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all .18s var(--ease);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }

/* --------------------------------------------------------------------
   Utilidades
   -------------------------------------------------------------------- */

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hide { display: none !important; }

/* Se oculta en movil y no se declara 'display' en escritorio: asi el
   elemento conserva el suyo propio (.icon-btn es inline-flex y necesita el
   centrado del flex para que el icono no se pegue a la esquina). */
@media (max-width: 899.98px) {
    .only-desktop { display: none !important; }
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 1rem 0;
}

.scroll-x {
    display: flex;
    gap: .6rem;
    overflow-x: auto;
    padding-bottom: .4rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.scroll-x > * { scroll-snap-align: start; flex-shrink: 0; }
.scroll-x::-webkit-scrollbar { height: 4px; }

/* Pestanas */
.tabs {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.1rem;
}

.tabs a, .tabs button {
    padding: .6rem .9rem;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .18s var(--ease);
}

.tabs a:hover, .tabs button:hover { color: var(--text); }

.tabs .is-active {
    color: var(--red-bright);
    border-bottom-color: var(--red);
}

/* --------------------------------------------------------------------
   Escritorio
   -------------------------------------------------------------------- */

@media (min-width: 900px) {
    body { font-size: 15px; }

    .top-nav { display: flex; }
    .bottom-nav { display: none; }
    .only-mobile { display: none !important; }

    .header-avatar .who { display: block; }

    .page {
        padding: 1.6rem 1.5rem 3rem;
    }

    .toasts {
        left: auto;
        width: 360px;
    }

    .grid-medals { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
}

@media (min-width: 1280px) {
    .page { padding-left: 2rem; padding-right: 2rem; }
}

/* Menos movimiento si el sistema lo pide */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
