.topbar {
    position: relative;
    /* Lift the topbar above .body content so the currency dropdown menu
       (positioned inside it) doesn't land behind the welcome card / rank
       cards that come later in DOM order. */
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-radius: 22px;
    margin: 22px 0 0;
    /* Decorative glow blobs are baked into the background so we don't need
       overflow:hidden — that was clipping the currency dropdown menu. */
    background:
        radial-gradient(380px 380px at 5% -45%,
            rgba(191, 212, 255, 0.18) 0%, transparent 65%),
        radial-gradient(280px 280px at 95% 145%,
            rgba(225, 217, 90, 0.10) 0%, transparent 65%),
        linear-gradient(135deg, rgba(26, 38, 58, 0.82), rgba(34, 50, 76, 0.55));
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(191, 212, 255, 0.08);
    gap: 16px;
    min-height: 130px;
}

.topbar-left,
.topbar-actions { position: relative; z-index: 1; }

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0;
}

/* === Small floating logo === */
.topbar-logo {
    position: relative;
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-logo::before {
    content: "";
    position: absolute;
    width: 65%;
    height: 18%;
    bottom: 4%;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(ellipse, rgba(8, 16, 28, 0.5) 0%, transparent 70%);
    filter: blur(6px);
    z-index: 0;
    animation: topbarLogoShadow 3.5s ease-in-out infinite;
}

.topbar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45))
            drop-shadow(0 0 14px rgba(191, 212, 255, 0.18));
    animation:
        topbarLogoFloat 3.5s ease-in-out infinite,
        topbarLogoWiggle 5.7s ease-in-out infinite;
}

@keyframes topbarLogoFloat {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -6px; }
}

@keyframes topbarLogoWiggle {
    0%, 100% { rotate: -2deg; }
    50%      { rotate:  2deg; }
}

@keyframes topbarLogoShadow {
    0%, 100% { transform: translateX(-50%) scale(1);    opacity: 0.9; }
    50%      { transform: translateX(-50%) scale(0.85); opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    .topbar-logo-img,
    .topbar-logo::before { animation: none; }
}

.topbar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}

.topbar-brand-text strong {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0.4px;
    background: linear-gradient(135deg, #FFFFFF 0%, var(--primary) 60%, var(--accent) 110%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1;
}

.topbar-brand-text span {
    font-size: 12px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 8px;
    font-weight: 800;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.action-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.currency-pill {
    background: rgba(191, 212, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--border-color);
}

.currency-pill:hover {
    border-color: var(--primary);
    background: rgba(191, 212, 255, 0.15);
    transform: translateY(-1px);
}

.currency-pill .chev { font-size: 10px; opacity: 0.7; }
.currency-pill i:first-child { color: var(--accent); }

/* === Basket button === */
.basket {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #0c1626;
    padding: 8px 18px 8px 12px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all 0.2s ease;
    box-shadow: 0 8px 22px rgba(191, 212, 255, 0.3);
    overflow: hidden;
}

.basket:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(191, 212, 255, 0.45);
}

.basket-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0c1626;
    font-size: 18px;
    flex-shrink: 0;
}

.basket-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    display: block;
}

.basket-bubble {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #2a2a10;
    border-radius: 999px;
    padding: 0 6px;
    height: 20px;
    min-width: 20px;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #142037;
}

.basket-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.basket-text strong {
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    color: #0c1626;
}

.basket-text span {
    font-size: 12px;
    font-weight: 600;
    color: rgba(12, 22, 38, 0.7);
}

.basket-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
    transform: translateX(-150%) skewX(-20deg);
    pointer-events: none;
}

.basket--guest {
    background: linear-gradient(135deg, var(--accent), #d6cd44 55%, var(--primary));
    background-size: 200% 100%;
    background-position: 0% 0%;
    animation: basketSheen 5s ease-in-out infinite;
    box-shadow:
        0 0 0 2px rgba(225, 217, 90, 0.15),
        0 12px 30px rgba(225, 217, 90, 0.35),
        0 0 22px rgba(191, 212, 255, 0.25);
}

.basket--guest .basket-icon-wrap {
    background: rgba(255, 255, 255, 0.55);
    animation: basketIconBob 1.6s ease-in-out infinite;
}

.basket--guest .basket-glow {
    animation: basketSweep 3s ease-in-out infinite;
}

@keyframes basketSheen {
    0%, 100% { background-position:   0% 0%; }
    50%      { background-position: 100% 0%; }
}

@keyframes basketIconBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px) rotate(-3deg); }
}

@keyframes basketSweep {
    0%   { transform: translateX(-150%) skewX(-20deg); }
    60%  { transform: translateX(150%)  skewX(-20deg); }
    100% { transform: translateX(150%)  skewX(-20deg); }
}

.currency-wrapper { position: relative; }

.currency-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    padding: 10px;
    border-radius: 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 200;
    min-width: 220px;
}

.currency-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.currency-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.currency-grid button {
    background: rgba(191, 212, 255, 0.08);
    border: 1px solid transparent;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s ease;
}

.currency-grid button:hover {
    background: rgba(191, 212, 255, 0.18);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* === Tablet + mobile: compact icon-with-label-below pills === */
@media (max-width: 1024px) {
    .topbar {
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        min-height: 0;
    }

    /* Promote currency-wrapper + basket to direct topbar children so
       margin-left:auto works to push basket far-right while currency
       sits next to the logo. */
    .topbar-actions { display: contents; }

    .topbar-left {
        flex: 0 1 auto;
        justify-content: flex-start;
        gap: 10px;
        min-width: 0;
    }

    .topbar-logo { width: 80px; height: 80px; }
    .topbar-brand-text strong { font-size: 25px; letter-spacing: 0.4px; }
    .topbar-brand-text span { font-size: 11px; letter-spacing: 2.4px; margin-top: 6px; }

    .currency-wrapper { flex: 0 0 auto; }
    .basket { flex: 0 0 auto; margin-left: auto; }

    /* Compact icon + small label below — no more horizontal "card" */
    .currency-pill {
        flex-direction: column;
        gap: 3px;
        padding: 7px 12px;
        font-size: 10px;
        line-height: 1;
        min-width: 56px;
        justify-content: center;
    }
    .currency-pill i:first-child { font-size: 16px; }
    .currency-pill > span { font-size: 10px; font-weight: 800; letter-spacing: 0.5px; }
    .currency-pill .chev { display: none; }

    .basket {
        flex-direction: column;
        gap: 4px;
        padding: 6px 10px 7px;
        text-align: center;
        min-width: 60px;
        border-radius: 12px;
    }
    .basket-icon-wrap {
        width: 32px;
        height: 32px;
        font-size: 14px;
        border-radius: 8px;
    }
    .basket-text {
        align-items: center;
        line-height: 1;
    }
    .basket-text strong { display: none; }
    .basket-text span { display: none; }
    .basket-text::after {
        content: "Basket";
        font-size: 10px;
        font-weight: 800;
        letter-spacing: 0.3px;
        color: #0c1626;
    }

    .currency-menu { right: auto; left: 0; min-width: 200px; }
}

@media (max-width: 768px) {
    .topbar { padding: 10px 12px; gap: 8px; }
    .topbar-logo { width: 68px; height: 68px; }
    .topbar-brand-text strong { font-size: 22px; letter-spacing: 0.3px; }
    .topbar-brand-text span { font-size: 10px; letter-spacing: 2px; margin-top: 5px; }
}

@media (max-width: 480px) {
    .topbar { padding: 9px 10px; gap: 6px; }
    .topbar-logo { width: 60px; height: 60px; }
    .topbar-brand-text strong { font-size: 19px; letter-spacing: 0.3px; }
    .topbar-brand-text span { font-size: 10px; letter-spacing: 1.6px; margin-top: 4px; }
    .currency-pill { padding: 6px 10px; min-width: 50px; }
    .basket { padding: 5px 9px 6px; min-width: 56px; }
    .basket-icon-wrap { width: 30px; height: 30px; font-size: 13px; }
}

/* Minimum supported width: 360px */
@media (max-width: 360px) {
    .topbar { padding: 10px 10px; gap: 6px; border-radius: 16px; margin-top: 14px; }
    .topbar-logo { width: 56px; height: 56px; }
    .topbar-brand-text strong { font-size: 17px; letter-spacing: 0.3px; }
    .topbar-brand-text span { font-size: 9px; letter-spacing: 1.4px; margin-top: 3px; }
    .currency-pill { padding: 5px 8px; min-width: 44px; }
    .currency-pill i:first-child { font-size: 14px; }
    .currency-pill > span { font-size: 9px; }
    .basket { padding: 4px 7px 5px; min-width: 50px; }
    .basket-icon-wrap { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }
    .basket-text::after { font-size: 9px; }
    .basket-bubble { top: -5px; right: -5px; height: 16px; min-width: 16px; font-size: 9px; padding: 0 4px; }
}
