:root {
    --back-to-top-offset: 0px;
}

.back-to-top {
    align-items: center;
    appearance: none;
    background: rgba(5, 28, 73, 0.96);
    border: 1px solid rgba(212, 175, 55, 0.72);
    border-radius: 999px;
    bottom: calc(1rem + env(safe-area-inset-bottom) + var(--back-to-top-offset));
    box-shadow: 0 10px 24px rgba(3, 22, 56, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-family: Montserrat, Arial, sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    gap: 0.42rem;
    justify-content: center;
    letter-spacing: 0.09em;
    opacity: 0;
    padding: 0.32rem 0.62rem 0.32rem 0.4rem;
    pointer-events: none;
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right));
    text-transform: uppercase;
    transform: translateY(8px) scale(0.97);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease, background 180ms ease, box-shadow 180ms ease;
    visibility: hidden;
    white-space: nowrap;
    z-index: 1500;
}

.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    visibility: visible;
}

.back-to-top:hover,
.back-to-top:focus-visible {
    background: #0a397f;
    box-shadow: 0 13px 28px rgba(3, 22, 56, 0.26), 0 0 0 3px rgba(212, 175, 55, 0.12);
    transform: translateY(-2px) scale(1);
}

.back-to-top:focus-visible {
    outline: 2px solid #f0cf5c;
    outline-offset: 3px;
}

.back-to-top-arrow {
    align-items: center;
    background: linear-gradient(145deg, #f0cf5c, #d4af37);
    border-radius: 50%;
    color: #071d44;
    display: inline-flex;
    font-family: Georgia, serif;
    font-size: 0.94rem;
    height: 1.48rem;
    justify-content: center;
    line-height: 1;
    width: 1.48rem;
}

.back-to-top-label {
    line-height: 1;
}

@media (max-width: 1024px) {
    .back-to-top {
        bottom: calc(0.82rem + env(safe-area-inset-bottom) + var(--back-to-top-offset));
        gap: 0.34rem;
        padding: 0.28rem 0.56rem 0.28rem 0.34rem;
        right: calc(0.82rem + env(safe-area-inset-right));
    }

    .back-to-top::after {
        color: rgba(255, 255, 255, 0.92);
        content: 'TOP';
        font-size: 0.52rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        line-height: 1;
    }

    .back-to-top-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

@media (max-width: 480px) {
    .back-to-top {
        border-radius: 50%;
        bottom: calc(0.68rem + env(safe-area-inset-bottom) + var(--back-to-top-offset));
        height: 2.5rem;
        padding: 0.34rem;
        right: calc(0.68rem + env(safe-area-inset-right));
        width: 2.5rem;
    }

    .back-to-top-arrow {
        font-size: 1rem;
        height: 1.74rem;
        width: 1.74rem;
    }

    .back-to-top::after {
        content: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: none;
    }
}

@media print {
    .back-to-top {
        display: none;
    }
}
