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

:root {
    --accent: #a855f7;
    --accent-soft: rgba(168, 85, 247, 0.12);
    --accent-border: rgba(168, 85, 247, 0.25);
    --like: #ff4d8d;

    --bg-color: #0d0d0d;
    --overlay-bg: rgba(0, 0, 0, 0.65);
    --card-bg: rgba(28, 28, 32, 0.75);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    --text-color: #fff;
    --bio-color: #b3b3b3;
    --meta-color: #9ca3af;
    --server-box-bg: rgba(18, 18, 20, 0.6);
    --server-box-border: rgba(255, 255, 255, 0.05);
    --action-btn-bg: rgba(255, 255, 255, 0.08);
    --action-btn-hover: rgba(255, 255, 255, 0.15);
    --action-btn-border: rgba(255, 255, 255, 0.05);
    --dropdown-bg: rgba(28, 28, 32, 0.95);
    --dropdown-border: rgba(255, 255, 255, 0.1);
    --avatar-border: #1c1c20;
    --scroll-track: #141416;
    --scroll-thumb: #363636;

    color-scheme: dark;
}

/* Scoped to <html> so the theme menu buttons (which also carry data-theme) are not restyled */
:root[data-theme="light"] {
    --accent: #9333ea;
    --accent-soft: rgba(147, 51, 234, 0.1);
    --accent-border: rgba(147, 51, 234, 0.25);

    --bg-color: #f0f2f5;
    --overlay-bg: rgba(255, 255, 255, 0.45);
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --text-color: #1a1a1a;
    --bio-color: #555555;
    --meta-color: #666666;
    --server-box-bg: rgba(240, 240, 245, 0.7);
    --server-box-border: rgba(0, 0, 0, 0.05);
    --action-btn-bg: rgba(0, 0, 0, 0.05);
    --action-btn-hover: rgba(0, 0, 0, 0.1);
    --action-btn-border: rgba(0, 0, 0, 0.05);
    --dropdown-bg: rgba(255, 255, 255, 0.95);
    --dropdown-border: rgba(0, 0, 0, 0.1);
    --avatar-border: #ffffff;
    --scroll-track: #e6e8ec;
    --scroll-thumb: #c4c4cc;

    color-scheme: light;
}

html {
    background-color: var(--bg-color);
    scrollbar-color: var(--accent) var(--scroll-track);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 20px;
    transition: color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* Blurred banner as page background. Done on fixed pseudo-elements instead of
   background-attachment: fixed, which is broken on iOS Safari. */
body::before,
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    background: url('../assets/banner.png') center / cover no-repeat;
    filter: blur(18px);
    transform: scale(1.1);
    z-index: -2;
}

body::after {
    background: var(--overlay-bg);
    z-index: -1;
    transition: background 0.3s ease;
}

.main-container {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- Cards ---------- */

.card,
.profile-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    /* backwards (not both) so the end state doesn't lock transform and block hover */
    animation: rise-in 0.5s ease backwards;
}

.main-container > :nth-child(2) { animation-delay: 0.05s; }
.main-container > :nth-child(3) { animation-delay: 0.1s; }
.main-container > :nth-child(4) { animation-delay: 0.15s; }
.main-container > :nth-child(5) { animation-delay: 0.2s; }
.main-container > :nth-child(6) { animation-delay: 0.25s; }
.main-container > :nth-child(n+7) { animation-delay: 0.3s; }

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

/* ---------- Profile ---------- */

.banner {
    aspect-ratio: 520 / 150;
    position: relative;
    width: 100%;
}

.banner img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* z-index keeps it above .profile-content, which is pulled up over the banner by the avatar margin */
.like-container {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.like-btn:hover { background: rgba(0, 0, 0, 0.6); }
.like-btn:disabled { cursor: default; opacity: 0.7; }
.like-btn:active { transform: scale(0.95); }

.like-btn svg {
    width: 16px;
    height: 16px;
    fill: transparent;
    stroke: currentColor;
    stroke-width: 2;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.like-btn.liked svg {
    fill: var(--like);
    stroke: var(--like);
}

.like-btn.pop svg { animation: pop 0.35s ease; }

@keyframes pop {
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.profile-content {
    padding: 0 24px 22px;
    position: relative;
}

.avatar-container {
    position: relative;
    width: 86px;
    height: 86px;
    margin-top: -43px;
    margin-bottom: 12px;
}

.avatar {
    display: block;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    border: 4px solid var(--avatar-border);
    object-fit: cover;
    background: var(--avatar-border);
    transition: border-color 0.3s ease;
}

.username-area h1 {
    font-size: 21px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 10px;
}

.badges {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.badge {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.bio {
    font-size: 13.5px;
    color: var(--bio-color);
    line-height: 1.5;
}

.bio-line {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 12px 0;
}

.meta-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12.5px;
    color: var(--meta-color);
}

.meta-info i {
    color: var(--accent);
    margin-right: 6px;
    width: 14px;
    text-align: center;
}

/* ---------- Social cards ---------- */

.social-card {
    --brand: var(--accent);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
    color: inherit;
    text-decoration: none;
}

.social-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.5px;
    color: var(--text-color);
    padding: 0 2px;
}

.social-header-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.social-header-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 17px;
    color: var(--brand);
    flex-shrink: 0;
}

.social-header-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--brand);
    box-shadow: 0 0 10px var(--brand);
}

.social-server-box {
    background: var(--server-box-bg);
    border: 1px solid var(--server-box-border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background 0.3s ease;
}

.social-server-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.social-server-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.social-server-icon--empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--brand);
    background: var(--action-btn-bg);
}

.social-server-icon--empty svg { width: 22px; height: 22px; }

.social-server-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.social-server-name {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.social-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--action-btn-bg);
    color: var(--text-color);
    font-weight: 600;
    font-size: 13px;
    padding: 7px 16px;
    border-radius: 10px;
    border: 1px solid var(--action-btn-border);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.social-action-btn i {
    font-size: 10px;
    opacity: 0.7;
}

@media (hover: hover) {
    .social-card:hover {
        transform: translateY(-2px);
        border-color: color-mix(in srgb, var(--brand) 40%, transparent);
        box-shadow: var(--card-shadow), 0 0 0 1px color-mix(in srgb, var(--brand) 15%, transparent);
    }

    .social-card:hover .social-action-btn {
        background: var(--brand);
        border-color: var(--brand);
        color: #fff;
    }
}

.social-card:active { transform: scale(0.99); }

/* ---------- Spotify player ---------- */

.embed-frame {
    border-radius: 12px;
    overflow: hidden;
    background: var(--server-box-bg);
    border: 1px solid var(--server-box-border);
}

.embed-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* TikTok and YouTube Shorts are portrait; keep them from getting huge */
.embed-portrait {
    width: 100%;
    max-width: 325px;
    margin: 0 auto;
}

/* ---------- Twitch live ---------- */

.live-group {
    --live: #eb0400;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
}

.live-group.is-live {
    background: var(--card-bg);
    border: 2px solid var(--live);
    box-shadow: 0 0 0 4px rgba(235, 4, 0, 0.12), 0 10px 34px rgba(235, 4, 0, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow: hidden;
    animation: live-glow 2.4s ease-in-out infinite;
}

/* While live the group draws the frame, so the inner card drops its own */
.live-group.is-live > .social-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
    animation: none;
}

@keyframes live-glow {
    50% { box-shadow: 0 0 0 4px rgba(235, 4, 0, 0.2), 0 10px 40px rgba(235, 4, 0, 0.45); }
}

.live-badge {
    display: none;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 10px;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--live);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
}

.is-live .live-badge { display: inline-flex; }
.is-live .social-header-indicator { display: none; }
.is-live .live-badge + .social-header-indicator { display: none; }

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    animation: live-pulse 1.4s ease-in-out infinite;
}

@keyframes live-pulse {
    50% { opacity: 0.3; }
}

.live-player {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: rise-in 0.4s ease backwards;
}

.live-info {
    font-size: 13px;
    color: var(--bio-color);
    line-height: 1.4;
    padding: 0 2px;
}

/* ---------- Announcements ---------- */

.announcements-card {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.announcement-list {
    display: flex;
    flex-direction: column;
}

.announcement {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--server-box-bg);
    border: 1px solid var(--server-box-border);
    border-radius: 12px;
    animation: rise-in 0.35s ease backwards;
}

.announcement + .announcement { margin-top: 10px; }

.announcement-date {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--meta-color);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.announcement-text {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-color);
    overflow-wrap: anywhere;
}

.announcement-text a {
    color: var(--accent);
    text-decoration: none;
}

.announcement-text a:hover { text-decoration: underline; }

.announcement-image {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--server-box-border);
}

.show-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    background: var(--action-btn-bg);
    border: 1px solid var(--action-btn-border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.show-more-btn:hover { background: var(--action-btn-hover); }
.show-more-btn:disabled { opacity: 0.6; cursor: default; }
.show-more-btn i { font-size: 11px; }

@media (hover: hover) {
    .embed-card:hover { transform: none; }
}

.embed-card:active { transform: none; }

/* ---------- Footer ---------- */

.site-footer {
    text-align: center;
    font-size: 12px;
    color: var(--meta-color);
    padding: 8px 0 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ---------- Theme switcher ---------- */

.theme-switcher-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-toggle-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.2s ease, background 0.3s ease;
}

.theme-toggle-btn:hover { transform: scale(1.05); }

.theme-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border);
    border-radius: 12px;
    width: 150px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.theme-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.theme-dropdown button {
    background: transparent;
    border: none;
    color: var(--text-color);
    font: inherit;
    text-align: left;
    padding: 9px 12px;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.theme-dropdown button span { flex-grow: 1; }
.theme-dropdown button:hover { background: var(--action-btn-hover); }

.theme-dropdown button i:first-child {
    width: 18px;
    color: var(--accent);
}

.check-icon {
    color: var(--accent);
    font-size: 12px;
    opacity: 0;
}

.theme-dropdown button.active .check-icon { opacity: 1; }

/* ---------- Focus & scrollbar ---------- */

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

.social-card:focus-visible { outline-offset: 3px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
    body {
        align-items: flex-start;
        padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    }

    /* Sits on the banner's top-right corner and scrolls away with the page */
    .theme-switcher-container {
        position: absolute;
        top: 26px;
        right: 26px;
    }

    .theme-toggle-btn {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .banner { aspect-ratio: 2.6 / 1; }

    .profile-content { padding: 0 18px 18px; }

    .avatar-container,
    .avatar {
        width: 78px;
        height: 78px;
    }

    .avatar-container { margin-top: -39px; }

    .social-card { padding: 14px 14px; gap: 10px; }

    .announcements-card { padding: 14px; }
    .announcement { padding: 12px; }
    .live-player { padding: 0 14px 14px; }

    .social-server-box { padding: 10px 12px; }

    .social-server-left { gap: 12px; }

    .social-server-icon { width: 42px; height: 42px; }

    .social-action-btn { padding: 8px 14px; }
}

@media (max-width: 360px) {
    .social-action-btn i { display: none; }
    .social-server-name { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
