* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #dfe8f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CONTENEDOR PRINCIPAL COMO EL INDEX */
.ranking-page {
    position: relative;
    width: min(100vw, calc(100svh * 16 / 9));
    height: min(100svh, calc(100vw * 9 / 16));
    overflow: hidden;
    background: #001a55;
}

/* FONDO */
.ranking-bg {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ranking-bg img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

/* BOTÓN VOLVER */
.back-button {
    position: absolute;
    top: 5%;
    left: 4%;
    z-index: 5;

    height: 42px;
    min-width: 118px;
    padding: 0 18px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 9px;

    background: rgba(0, 72, 180, 0.7);
    color: #ffffff;

    font-size: clamp(13px, 1.2vw, 20px);
    font-weight: 900;
    text-decoration: none;

    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease, background 0.25s ease;
}

.back-button:hover {
    transform: translateY(-2px);
    background: rgba(0, 105, 235, 0.9);
}

/* CONTENIDO */
.ranking-content {
    position: relative;
    z-index: 3;

    width: 100%;
    height: 100%;

    padding: 5.5% 7% 4%;

    display: flex;
    flex-direction: column;
    align-items: center;
}

/* HEADER */
.ranking-header {
    text-align: center;
    margin-bottom: 3.4%;
}

.ranking-header h1 {
    color: #ffa31a;
    font-size: clamp(44px, 5.6vw, 92px);
    line-height: 0.9;
    font-weight: 950;
    letter-spacing: -2px;

    text-shadow:
        0 5px 0 rgba(105, 60, 0, 0.65),
        0 10px 24px rgba(0, 0, 0, 0.35);
}

.ranking-header p {
    margin-top: 2.2%;

    color: #ffffff;
    font-size: clamp(16px, 1.65vw, 28px);
    font-weight: 900;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
}

/* LAYOUT */
.ranking-layout {
    width: 72%;
    display: grid;
    grid-template-columns: 24% 1fr;
    gap: 3%;
    align-items: center;
}

/* TARJETA MI POSICIÓN */
.my-position-card {
    position: relative;

    min-height: 300px;
    padding: 18px 16px 20px;

    border: 2px solid rgba(75, 170, 255, 0.95);
    border-radius: 18px;

    background:
        linear-gradient(180deg, rgba(0, 49, 130, 0.92), rgba(0, 21, 73, 0.96));

    color: #ffffff;
    text-align: center;

    box-shadow:
        0 0 22px rgba(35, 150, 255, 0.72),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.position-label {
    font-size: clamp(11px, 0.95vw, 16px);
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.position-badge {
    position: absolute;
    left: 8%;
    top: 22%;

    width: 58px;
    height: 72px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: linear-gradient(180deg, #153b94, #001b55);
    border: 3px solid #ffca2e;
    border-radius: 8px 8px 22px 22px;

    color: #ffcf32;
    font-size: clamp(26px, 2.2vw, 38px);
    font-weight: 950;

    box-shadow: 0 0 18px rgba(255, 207, 50, 0.65);
}

.my-avatar {
    width: clamp(82px, 7vw, 120px);
    height: clamp(82px, 7vw, 120px);

    border-radius: 50%;
    object-fit: cover;

    border: 4px solid #ffcb2e;
    box-shadow: 0 0 22px rgba(255, 207, 50, 0.9);
}

.my-position-card h2 {
    margin-top: 14px;
    font-size: clamp(19px, 1.7vw, 31px);
    font-weight: 950;
    text-transform: uppercase;
}

.my-stats {
    margin-top: 14px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.my-stats strong {
    color: #ffca2e;
    font-size: clamp(20px, 1.7vw, 28px);
    font-weight: 950;
}

.my-stats span {
    font-size: clamp(15px, 1.2vw, 20px);
    font-weight: 900;
}

.my-stats small {
    display: block;
    margin-top: 3px;
    font-size: clamp(8px, 0.7vw, 11px);
    font-weight: 900;
    text-transform: uppercase;
}

.circle-progress {
    width: clamp(58px, 4.7vw, 76px);
    height: clamp(58px, 4.7vw, 76px);

    border-radius: 50%;
    border: 8px solid #ffca2e;
    border-left-color: rgba(255, 255, 255, 0.2);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: clamp(17px, 1.5vw, 24px);
    font-weight: 950;

    box-shadow: 0 0 18px rgba(255, 207, 50, 0.55);
}

.motivation {
    margin-top: 14px;
    padding-top: 12px;

    border-top: 1px solid rgba(255, 255, 255, 0.2);

    font-size: clamp(10px, 0.85vw, 14px);
    font-weight: 800;
    line-height: 1.25;
}

/* TABLA */
.ranking-table-card {
    overflow: hidden;

    border: 2px solid rgba(255, 202, 46, 0.55);
    border-radius: 20px;

    background: rgba(0, 20, 73, 0.88);
    color: #ffffff;

    box-shadow:
        0 0 28px rgba(0, 120, 255, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ranking-table-header,
.ranking-row {
    display: grid;
    grid-template-columns: 90px 1.2fr 1fr 1.2fr;
    align-items: center;
}

.ranking-table-header {
    min-height: 50px;
    padding: 0 24px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.15);

    color: rgba(255, 255, 255, 0.78);
    font-size: clamp(10px, 0.8vw, 14px);
    font-weight: 950;
    text-transform: uppercase;
}

.ranking-row {
    min-height: 60px;
    padding: 0 24px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.11);
    transition: background 0.2s ease, transform 0.2s ease;
}

.ranking-row:last-child {
    border-bottom: none;
}

.ranking-row:hover {
    background: rgba(0, 110, 255, 0.18);
}

.rank-position {
    color: #ffffff;
    font-size: clamp(18px, 1.55vw, 26px);
    font-weight: 950;
}

.top-one .rank-position,
.current-user .rank-position {
    color: #ffca2e;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.user-info img {
    width: clamp(34px, 2.8vw, 46px);
    height: clamp(34px, 2.8vw, 46px);

    border-radius: 50%;
    object-fit: cover;

    border: 3px solid #ffca2e;
    box-shadow: 0 0 10px rgba(255, 207, 50, 0.65);
    flex-shrink: 0;
}

.user-info strong {
    font-size: clamp(13px, 1.1vw, 20px);
    font-weight: 950;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cards-count {
    font-size: clamp(13px, 1.1vw, 20px);
    font-weight: 900;
}

.cards-count strong {
    color: #ffca2e;
    font-size: clamp(16px, 1.35vw, 24px);
}

.progress-info {
    display: grid;
    grid-template-columns: 1fr 52px;
    align-items: center;
    gap: 14px;
}

.progress-info strong {
    color: #ffca2e;
    font-size: clamp(14px, 1.2vw, 22px);
    font-weight: 950;
}

.bar {
    width: 100%;
    height: 12px;

    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.bar i {
    height: 100%;
    display: block;

    border-radius: inherit;
    background: linear-gradient(90deg, #ff9b00, #ffdd4a);
}

.bar.silver i {
    background: linear-gradient(90deg, #d7d7d7, #ffffff);
}

.bar.bronze i {
    background: linear-gradient(90deg, #d46f1f, #ffbd60);
}

.bar.blue i {
    background: linear-gradient(90deg, #176dff, #68adff);
}

.current-user {
    background: rgba(0, 95, 255, 0.22);
    outline: 2px solid rgba(55, 155, 255, 0.95);
    box-shadow:
        0 0 18px rgba(35, 150, 255, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* BOTONES */
.ranking-actions {
    margin-top: 3.4%;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
}

.action-btn {
    width: clamp(220px, 18vw, 330px);
    height: clamp(58px, 5vw, 82px);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;

    border-radius: 18px;
    border: 2px solid rgba(255, 255, 255, 0.75);

    text-decoration: none;
    color: #ffffff;

    background: rgba(0, 30, 91, 0.84);

    box-shadow:
        0 0 20px rgba(46, 157, 255, 0.75),
        inset 0 1px 0 rgba(255, 255, 255, 0.26);

    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.action-btn:hover {
    transform: translateY(-3px) scale(1.02);
}

.action-btn img {
    width: clamp(42px, 3.8vw, 64px);
    height: clamp(42px, 3.8vw, 64px);
    object-fit: contain;
}

.action-btn span {
    font-size: clamp(15px, 1.2vw, 22px);
    font-weight: 950;
    text-transform: uppercase;
    font-style: italic;
}

.action-btn strong {
    color: #ffca2e;
    font-size: clamp(30px, 3vw, 48px);
    line-height: 1;
}

.packs-btn {
    border-color: rgba(255, 202, 46, 0.9);
    box-shadow:
        0 0 20px rgba(255, 202, 46, 0.72),
        inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

/* TABLET HORIZONTAL */
@media (min-width: 769px) and (max-width: 1180px) and (orientation: landscape) {
    .ranking-content {
        padding: 5% 5% 3.5%;
    }

    .ranking-layout {
        width: 80%;
        grid-template-columns: 25% 1fr;
    }

    .ranking-row {
        min-height: 54px;
    }

    .my-position-card {
        min-height: 270px;
    }
}

/* TABLET VERTICAL Y MÓVIL */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        overflow: hidden;
    }

    .ranking-page {
        width: min(100vw, calc(100svh * 9 / 16));
        height: min(100svh, calc(100vw * 16 / 9));
        overflow: hidden;
    }

    .ranking-bg img {
        object-fit: fill;
    }

    .back-button {
        top: 2.4%;
        left: 4%;
        min-width: 86px;
        height: 34px;
        padding: 0 12px;
        border-width: 2px;
        font-size: 13px;
    }

    .ranking-content {
        padding: 8% 4.5% 4%;
    }

    .ranking-header {
        margin-bottom: 3%;
    }

    .ranking-header h1 {
        font-size: clamp(38px, 11vw, 52px);
        letter-spacing: -1px;
    }

    .ranking-header p {
        width: 90%;
        margin: 10px auto 0;
        font-size: clamp(12px, 3.5vw, 16px);
        line-height: 1.2;
    }

    .ranking-layout {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* EN MÓVIL PRIMERO VA TU POSICIÓN */
    .my-position-card {
        order: 1;
        width: 100%;
        min-height: 150px;
        padding: 10px 12px 12px;

        display: grid;
        grid-template-columns: 70px 1fr 70px;
        grid-template-rows: auto auto auto;
        column-gap: 10px;
        align-items: center;

        text-align: left;
        border-radius: 15px;
    }

    .position-label {
        grid-column: 1 / -1;
        text-align: center;
        font-size: 11px;
        margin-bottom: 6px;
    }

    .position-badge {
        position: static;
        grid-column: 1;
        grid-row: 2 / 4;

        width: 52px;
        height: 58px;
        font-size: 24px;
        justify-self: center;
    }

    .my-avatar {
        grid-column: 2;
        grid-row: 2;
        width: 58px;
        height: 58px;
        justify-self: start;
    }

    .my-position-card h2 {
        grid-column: 2;
        grid-row: 3;
        margin-top: 4px;
        font-size: 17px;
    }

    .my-stats {
        grid-column: 3;
        grid-row: 2 / 4;
        margin-top: 0;
        gap: 6px;
        flex-direction: column;
        text-align: center;
    }

    .my-stats strong {
        font-size: 18px;
    }

    .my-stats span {
        font-size: 12px;
    }

    .my-stats small {
        font-size: 7px;
    }

    .circle-progress {
        width: 50px;
        height: 50px;
        border-width: 6px;
        font-size: 15px;
    }

    .motivation {
        grid-column: 1 / -1;
        margin-top: 8px;
        padding-top: 7px;
        font-size: 10px;
        text-align: center;
    }

    .ranking-table-card {
        order: 2;
        width: 100%;
        border-radius: 15px;
    }

    .ranking-table-header {
        display: none;
    }

    .ranking-row {
        min-height: 52px;
        padding: 0 10px;
        grid-template-columns: 44px 1fr 78px 76px;
    }

    .rank-position {
        font-size: 17px;
    }

    .user-info {
        gap: 8px;
    }

    .user-info img {
        width: 34px;
        height: 34px;
        border-width: 2px;
    }

    .user-info strong {
        font-size: 12px;
    }

    .cards-count {
        font-size: 11px;
        text-align: center;
    }

    .cards-count strong {
        font-size: 14px;
    }

    .progress-info {
        grid-template-columns: 1fr;
        gap: 3px;
        text-align: center;
    }

    .bar {
        height: 8px;
    }

    .progress-info strong {
        font-size: 12px;
    }

    .ranking-actions {
        width: 100%;
        margin-top: 3%;
        gap: 10px;
    }

    .action-btn {
        width: 48%;
        height: 50px;
        gap: 8px;
        border-radius: 13px;
    }

    .action-btn img {
        width: 36px;
        height: 36px;
    }

    .action-btn span {
        font-size: 11px;
    }

    .action-btn strong {
        font-size: 25px;
    }
}

/* MÓVILES PEQUEÑOS */
@media (max-width: 390px) and (orientation: portrait) {
    .ranking-content {
        padding-top: 7%;
    }

    .ranking-header h1 {
        font-size: 38px;
    }

    .ranking-header p {
        font-size: 12px;
    }

    .my-position-card {
        min-height: 138px;
        grid-template-columns: 60px 1fr 62px;
    }

    .my-avatar {
        width: 50px;
        height: 50px;
    }

    .my-position-card h2 {
        font-size: 15px;
    }

    .ranking-row {
        min-height: 47px;
        grid-template-columns: 38px 1fr 66px 65px;
    }

    .user-info img {
        width: 30px;
        height: 30px;
    }

    .user-info strong {
        font-size: 11px;
    }

    .action-btn {
        height: 46px;
    }
}

/* CELULAR HORIZONTAL */
@media (max-height: 500px) and (orientation: landscape) {
    .ranking-content {
        padding: 4% 5% 3%;
    }

    .ranking-header {
        margin-bottom: 2.4%;
    }

    .ranking-header h1 {
        font-size: 42px;
    }

    .ranking-header p {
        margin-top: 8px;
        font-size: 13px;
    }

    .ranking-layout {
        width: 76%;
        grid-template-columns: 23% 1fr;
        gap: 2.5%;
    }

    .my-position-card {
        min-height: 205px;
        padding: 10px;
    }

    .my-avatar {
        width: 62px;
        height: 62px;
    }

    .position-badge {
        width: 42px;
        height: 50px;
        font-size: 21px;
    }

    .my-position-card h2 {
        font-size: 15px;
        margin-top: 6px;
    }

    .my-stats {
        margin-top: 8px;
    }

    .motivation {
        display: none;
    }

    .ranking-row {
        min-height: 42px;
        padding: 0 14px;
    }

    .ranking-table-header {
        min-height: 36px;
    }

    .ranking-actions {
        margin-top: 2.2%;
    }

    .action-btn {
        height: 46px;
    }
}

/* ======================================================
   AJUSTE FINAL RANKING WEB + BOTONES VISIBLES
   Pegar al final de ranking.css
====================================================== */

/* WEB: mantener pantalla sin scroll y que no se corten botones */
@media (min-width: 769px) {
    html,
    body {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    body {
        background: #dfe8f6;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .ranking-page {
        width: min(100vw, calc(100svh * 16 / 9));
        height: min(100svh, calc(100vw * 9 / 16));
        min-height: unset;
        overflow: hidden;
    }

    .ranking-content {
        width: 100%;
        height: 100%;
        min-height: unset;

        padding: 4.2% 6.8% 2.4%;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
    }

    .ranking-header {
        margin-bottom: 2.6%;
    }

    .ranking-header h1 {
        font-size: clamp(48px, 5.1vw, 84px);
        line-height: 0.9;
    }

    .ranking-header p {
        margin-top: 1.5%;
        font-size: clamp(15px, 1.45vw, 24px);
    }

    .ranking-layout {
        width: 76%;
        display: grid;
        grid-template-columns: 260px 1fr;
        gap: 28px;
        align-items: center;
    }

    /* TARJETA TU POSICIÓN MÁS LIMPIA */
    .my-position-card {
        min-height: 310px;
        padding: 16px 14px 18px;
        border-radius: 18px;
    }

    .position-label {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .position-badge {
        left: 18px;
        top: 76px;

        width: 58px;
        height: 66px;

        font-size: 31px;
        border-radius: 9px 9px 22px 22px;
    }

    .my-avatar {
        width: 105px;
        height: 105px;
        margin-left: 18px;
    }

    .my-position-card h2 {
        margin-top: 12px;
        font-size: 25px;
        line-height: 1;
    }

    .my-stats {
        margin-top: 12px;
        gap: 14px;
    }

    .my-stats strong {
        font-size: 24px;
    }

    .my-stats span {
        font-size: 16px;
    }

    .my-stats small {
        font-size: 9px;
        line-height: 1.05;
    }

    .circle-progress {
        width: 66px;
        height: 66px;
        border-width: 7px;
        font-size: 20px;
    }

    .motivation {
        margin-top: 12px;
        padding-top: 10px;
        font-size: 12px;
        line-height: 1.15;
    }

    /* TABLA MÁS ORDENADA EN WEB */
    .ranking-table-card {
        border-radius: 18px;
    }

    .ranking-table-header,
    .ranking-row {
        grid-template-columns: 90px 1.15fr 0.85fr 1fr;
    }

    .ranking-table-header {
        min-height: 44px;
        padding: 0 22px;
        font-size: 12px;
    }

    .ranking-row {
        min-height: 55px;
        padding: 0 22px;
    }

    .rank-position {
        font-size: 22px;
    }

    .user-info {
        gap: 11px;
    }

    .user-info img {
        width: 42px;
        height: 42px;
    }

    .user-info strong {
        font-size: 17px;
        max-width: 170px;
    }

    .cards-count {
        font-size: 16px;
    }

    .cards-count strong {
        font-size: 21px;
    }

    .progress-info {
        grid-template-columns: 1fr 48px;
        gap: 12px;
    }

    .progress-info strong {
        font-size: 18px;
    }

    .bar {
        height: 11px;
    }

    /* BOTONES VISIBLES */
    .ranking-actions {
        margin-top: 2.4%;
        gap: 20px;
        flex-shrink: 0;
    }

    .action-btn {
        width: clamp(210px, 17vw, 300px);
        height: clamp(54px, 4.6vw, 72px);
        border-radius: 17px;
        gap: 14px;
    }

    .action-btn img {
        width: clamp(38px, 3.3vw, 54px);
        height: clamp(38px, 3.3vw, 54px);
    }

    .action-btn span {
        font-size: clamp(14px, 1.05vw, 19px);
    }

    .action-btn strong {
        font-size: clamp(26px, 2.5vw, 40px);
    }

    .back-button {
        top: 5%;
        left: 4%;
        height: 40px;
        min-width: 110px;
        font-size: 17px;
    }
}

/* PANTALLAS WEB PEQUEÑAS O PORTÁTILES BAJITOS */
@media (min-width: 769px) and (max-height: 760px) {
    .ranking-content {
        padding-top: 3.4%;
        padding-bottom: 1.8%;
    }

    .ranking-header {
        margin-bottom: 2%;
    }

    .ranking-header h1 {
        font-size: clamp(42px, 4.7vw, 72px);
    }

    .ranking-header p {
        margin-top: 1%;
        font-size: clamp(13px, 1.25vw, 19px);
    }

    .ranking-layout {
        width: 72%;
        grid-template-columns: 230px 1fr;
        gap: 22px;
    }

    .my-position-card {
        min-height: 270px;
        padding: 12px;
    }

    .position-label {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .position-badge {
        width: 48px;
        height: 56px;
        top: 62px;
        left: 14px;
        font-size: 26px;
    }

    .my-avatar {
        width: 82px;
        height: 82px;
        margin-left: 16px;
    }

    .my-position-card h2 {
        font-size: 21px;
        margin-top: 9px;
    }

    .my-stats {
        margin-top: 9px;
    }

    .my-stats strong {
        font-size: 20px;
    }

    .circle-progress {
        width: 56px;
        height: 56px;
        font-size: 17px;
        border-width: 6px;
    }

    .motivation {
        margin-top: 9px;
        padding-top: 8px;
        font-size: 10px;
    }

    .ranking-table-header {
        min-height: 38px;
        font-size: 10px;
    }

    .ranking-row {
        min-height: 47px;
    }

    .user-info img {
        width: 34px;
        height: 34px;
    }

    .user-info strong {
        font-size: 14px;
    }

    .cards-count {
        font-size: 13px;
    }

    .cards-count strong {
        font-size: 17px;
    }

    .progress-info strong {
        font-size: 15px;
    }

    .ranking-actions {
        margin-top: 1.8%;
    }

    .action-btn {
        height: 50px;
        width: 230px;
    }

    .action-btn img {
        width: 38px;
        height: 38px;
    }

    .action-btn span {
        font-size: 14px;
    }
}

/* MÓVIL: mantener tu posición primero y tabla después */
@media (max-width: 768px) and (orientation: portrait) {
    .ranking-layout {
        display: flex;
        flex-direction: column;
    }

    .my-position-card {
        order: 1;
    }

    .ranking-table-card {
        order: 2;
    }

    .ranking-actions {
        order: 3;
    }
}

/* ==============================
   PAGINACIÓN RANKING
============================== */

.ranking-pagination {
    margin-top: 14px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;

    grid-column: 2;
}

.ranking-pagination button {
    width: 42px;
    height: 36px;

    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 10px;

    background: rgba(0, 72, 180, 0.75);
    color: #ffffff;

    font-size: 28px;
    font-weight: 900;
    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 0 14px rgba(45, 150, 255, 0.65),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);

    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ranking-pagination button:hover:not(:disabled) {
    transform: scale(1.08);
}

.ranking-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ranking-pagination span {
    min-width: 64px;

    color: #ffffff;
    font-size: 18px;
    font-weight: 900;
    text-align: center;

    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
}

/* Ajuste para que en web la paginación quede debajo de la tabla */
.ranking-layout {
    align-items: start;
}

.ranking-table-card {
    width: 100%;
}

/* Móvil */
@media (max-width: 768px) and (orientation: portrait) {
    .ranking-pagination {
        order: 3;
        grid-column: auto;
        margin-top: 8px;
        gap: 10px;
    }

    .ranking-pagination button {
        width: 36px;
        height: 32px;
        font-size: 24px;
    }

    .ranking-pagination span {
        font-size: 14px;
        min-width: 54px;
    }
}

/* ======================================================
   FIX FINAL RANKING WEB
   Corrige tabla apretada + botones cortados
====================================================== */

@media (min-width: 769px) {

    html,
    body {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .ranking-page {
        width: min(100vw, calc(100svh * 16 / 9));
        height: min(100svh, calc(100vw * 9 / 16));
        overflow: hidden;
    }

    .ranking-content {
        position: relative;
        width: 100%;
        height: 100%;
        min-height: unset;

        padding: 3.2% 5.5% 2%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Título más compacto */
    .ranking-header {
        margin-bottom: 6.8%;
    }

    .ranking-header h1 {
        font-size: clamp(42px, 4.4vw, 72px);
        line-height: 0.9;
    }

    .ranking-header p {
        margin-top: 0.8%;
        font-size: clamp(14px, 1.25vw, 21px);
    }

    /* Darle más ancho a la tabla */
    .ranking-layout {
        width: 86%;
        display: grid;
        grid-template-columns: 250px minmax(0, 1fr);
        gap: 26px;
        align-items: start;
    }

    .ranking-table-wrapper {
        width: 100%;
        min-width: 0;
    }

    .ranking-table-card {
        width: 100%;
        border-radius: 18px;
    }

    /* Tabla menos estripada */
    .ranking-table-header,
    .ranking-row {
        grid-template-columns: 74px minmax(180px, 1.2fr) 150px 190px;
        padding: 0 20px;
    }

    .ranking-table-header {
        min-height: 38px;
        font-size: 11px;
    }

    .ranking-row {
        min-height: 46px;
    }

    .rank-position {
        font-size: 20px;
    }

    .user-info {
        gap: 10px;
        min-width: 0;
    }

    .user-info img {
        width: 34px;
        height: 34px;
        border-width: 2px;
    }

    .user-info strong {
        font-size: 15px;
        max-width: 170px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cards-count {
        font-size: 14px;
        white-space: nowrap;
    }

    .cards-count strong {
        font-size: 18px;
    }

    .progress-info {
        grid-template-columns: 1fr 44px;
        gap: 10px;
    }

    .progress-info strong {
        font-size: 15px;
    }

    .bar {
        height: 10px;
    }

    /* Tarjeta tu posición más proporcionada */
    .my-position-card {
        min-height: 276px;
        padding: 13px 12px 14px;
        border-radius: 17px;
    }

    .position-label {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .position-badge {
        width: 48px;
        height: 58px;
        top: 70px;
        left: 16px;
        font-size: 27px;
    }

    .my-avatar {
        width: 86px;
        height: 86px;
        margin-left: 18px;
    }

    .my-position-card h2 {
        margin-top: 9px;
        font-size: 22px;
    }

    .my-stats {
        margin-top: 9px;
        gap: 12px;
    }

    .my-stats strong {
        font-size: 21px;
    }

    .my-stats span {
        font-size: 15px;
    }

    .my-stats small {
        font-size: 8px;
    }

    .circle-progress {
        width: 56px;
        height: 56px;
        border-width: 6px;
        font-size: 17px;
    }

    .motivation {
        margin-top: 9px;
        padding-top: 8px;
        font-size: 10px;
        line-height: 1.15;
    }

    /* Paginación compacta */
    .ranking-pagination {
        margin-top: 8px;
        gap: 12px;
    }

    .ranking-pagination button {
        width: 36px;
        height: 32px;
        font-size: 23px;
        border-radius: 9px;
    }

    .ranking-pagination span {
        font-size: 16px;
        min-width: 54px;
    }

    /* Botones siempre visibles abajo */
    .ranking-actions {
        position: absolute;
        left: 50%;
        bottom: 2.2%;
        transform: translateX(-50%);

        margin-top: 0;
        display: flex;
        gap: 22px;
        z-index: 6;
    }

    .action-btn {
        width: 250px;
        height: 54px;
        border-radius: 15px;
        gap: 12px;
    }

    .action-btn img {
        width: 40px;
        height: 40px;
    }

    .action-btn span {
        font-size: 15px;
    }

    .action-btn strong {
        font-size: 32px;
    }
}

/* Ajuste extra para pantallas bajitas como Mac en navegador */
@media (min-width: 769px) and (max-height: 760px) {

    .ranking-content {
        padding-top: 2.4%;
    }

    .ranking-header {
        margin-bottom: 5.4%;
    }

    .ranking-header h1 {
        font-size: clamp(38px, 4vw, 64px);
    }

    .ranking-header p {
        font-size: clamp(13px, 1.1vw, 18px);
    }

    .ranking-layout {
        width: 84%;
        grid-template-columns: 235px minmax(0, 1fr);
        gap: 22px;
    }

    .ranking-row {
        min-height: 43px;
    }

    .ranking-table-header {
        min-height: 34px;
    }

    .my-position-card {
        min-height: 255px;
    }

    .my-avatar {
        width: 78px;
        height: 78px;
    }

    .my-position-card h2 {
        font-size: 19px;
    }

    .motivation {
        font-size: 9px;
    }

    .ranking-actions {
        bottom: 1.6%;
    }

    .action-btn {
        height: 48px;
        width: 230px;
    }

    .action-btn img {
        width: 35px;
        height: 35px;
    }

    .action-btn span {
        font-size: 14px;
    }
}

/* ======================================================
   FIX MÓVIL RANKING
   Tu posición primero + tabla + botones visibles
====================================================== */

@media (max-width: 768px) and (orientation: portrait) {

    html,
    body {
        width: 100%;
        min-height: 100%;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        display: block;
        background: #001a55;
    }

    .ranking-page {
        width: 100%;
        min-height: 100svh;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        display: block;
        padding: 0;
    }

    .ranking-bg {
        position: fixed;
        inset: 0;
        z-index: 1;
    }

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

    .ranking-content {
        position: relative;
        z-index: 3;

        width: 100%;
        height: auto;
        min-height: 100svh;

        padding: 78px 14px 28px;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
    }

    .back-button {
        position: fixed;
        top: 16px;
        left: 14px;
        z-index: 20;

        min-width: 94px;
        height: 36px;
        padding: 0 12px;

        font-size: 14px;
        border-width: 2px;
    }

    .ranking-header {
        width: 100%;
        margin-bottom: 18px;
        text-align: center;
    }

    .ranking-header h1 {
        font-size: 44px;
        line-height: 1;
        letter-spacing: -1px;
    }

    .ranking-header p {
        width: 92%;
        margin: 10px auto 0;
        font-size: 14px;
        line-height: 1.25;
    }

    .ranking-layout {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 16px;
        align-items: center;
    }

    /* 1. TU POSICIÓN DE PRIMERAS */
    .my-position-card {
        order: 1;

        width: 100%;
        max-width: 380px;
        min-height: auto;

        padding: 14px 14px 16px;
        border-radius: 16px;

        display: grid;
        grid-template-columns: 64px 1fr 76px;
        grid-template-rows: auto auto auto auto;
        column-gap: 12px;
        align-items: center;

        text-align: left;
    }

    .position-label {
        grid-column: 1 / -1;
        text-align: center;
        font-size: 12px;
        margin-bottom: 8px;
    }

    .position-badge {
        position: static;

        grid-column: 1;
        grid-row: 2 / 4;

        width: 54px;
        height: 62px;

        font-size: 26px;
        justify-self: center;
    }

    .my-avatar {
        grid-column: 2;
        grid-row: 2;

        width: 62px;
        height: 62px;
        margin: 0;
        justify-self: start;
    }

    .my-position-card h2 {
        grid-column: 2;
        grid-row: 3;

        margin-top: 6px;
        font-size: 18px;
        line-height: 1;
    }

    .my-stats {
        grid-column: 3;
        grid-row: 2 / 4;

        margin: 0;
        gap: 6px;

        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .my-stats strong {
        font-size: 19px;
    }

    .my-stats span {
        font-size: 13px;
    }

    .my-stats small {
        font-size: 8px;
        line-height: 1;
    }

    .circle-progress {
        width: 52px;
        height: 52px;
        border-width: 6px;
        font-size: 15px;
    }

    .motivation {
        grid-column: 1 / -1;
        grid-row: 4;

        margin-top: 10px;
        padding-top: 8px;

        font-size: 11px;
        line-height: 1.25;
        text-align: center;
    }

    /* 2. TABLA DEBAJO */
    .ranking-table-wrapper {
        order: 2;
        width: 100%;
        max-width: 430px;
    }

    .ranking-table-card {
        width: 100%;
        border-radius: 16px;
        overflow: hidden;
    }

    .ranking-table-header {
        display: none;
    }

    .ranking-row {
    width: 100%;
    min-height: 58px;

    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 74px 68px;
    gap: 6px;

    padding: 0 10px;
}

    .rank-position {
        font-size: 17px;
    }

    .user-info {
        gap: 7px;
        min-width: 0;
    }

    .user-info img {
        width: 34px;
        height: 34px;
        border-width: 2px;
        flex-shrink: 0;
    }

    .user-info strong {
        font-size: 12px;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cards-count {
        font-size: 11px;
        text-align: center;
        white-space: nowrap;
    }

    .cards-count strong {
        font-size: 14px;
    }

    .progress-info {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
        text-align: center;
    }

    .bar {
        height: 8px;
    }

    .progress-info strong {
        font-size: 12px;
    }

    /* PAGINACIÓN DEBAJO DE TABLA */
    .ranking-pagination {
        margin-top: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 12px;
    }

    .ranking-pagination button {
        width: 36px;
        height: 32px;
        font-size: 24px;
    }

    .ranking-pagination span {
        min-width: 54px;
        font-size: 14px;
    }

    /* 3. BOTONES AL FINAL */
    .ranking-actions {
        order: 3;

        position: static;
        transform: none;

        width: 100%;
        max-width: 430px;

        margin-top: 18px;

        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .action-btn {
        width: 100%;
        height: 58px;

        border-radius: 15px;
        gap: 12px;
    }

    .action-btn img {
        width: 42px;
        height: 42px;
    }

    .action-btn span {
        font-size: 15px;
    }

    .action-btn strong {
        font-size: 30px;
    }
}

/* MÓVILES PEQUEÑOS */
@media (max-width: 390px) and (orientation: portrait) {

    .ranking-content {
        padding: 70px 10px 24px;
    }

    .ranking-header h1 {
        font-size: 38px;
    }

    .ranking-header p {
        font-size: 12px;
    }

    .my-position-card {
        grid-template-columns: 56px 1fr 66px;
        padding: 12px;
    }

    .position-badge {
        width: 48px;
        height: 56px;
        font-size: 23px;
    }

    .my-avatar {
        width: 54px;
        height: 54px;
    }

    .my-position-card h2 {
        font-size: 16px;
    }

    .circle-progress {
        width: 46px;
        height: 46px;
        font-size: 13px;
    }

    .ranking-row {
        grid-template-columns: 36px minmax(0, 1fr) 64px 58px;
        min-height: 54px;
        padding: 0 8px;
    }

    .user-info img {
        width: 30px;
        height: 30px;
    }

    .user-info strong {
        font-size: 11px;
    }

    .cards-count {
        font-size: 10px;
    }

    .cards-count strong {
        font-size: 12px;
    }

    .progress-info strong {
        font-size: 10px;
    }
}