/* Player Popup Card - Premium Sports Card Aesthetic
 * Design: Collectible trading card meets esports player card
 * Features: Glass morphism, holographic shimmer, staggered animations
 */

/* ==========================================================================
   TRIGGER STYLES
   ========================================================================== */

/* Avatar Popup Trigger */
.player-avatar-popup-trigger {
    display: inline-block;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    position: relative;
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-avatar-popup-trigger::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        var(--theme-primary) 0deg,
        var(--theme-info) 120deg,
        var(--theme-primary) 240deg,
        var(--theme-primary) 360deg
    );
    opacity: 0;
    z-index: -1;
    transition: opacity 200ms ease;
}


.player-avatar-popup-trigger:focus-visible {
    outline: none;
}

.player-avatar-popup-trigger:focus-visible::before {
    opacity: 1;
}

.player-avatar-popup-trigger img {
    display: block;
    border-radius: 50%;
    position: relative;
    z-index: 1;
}


/* Name Trigger */
.player-name-trigger {
    text-decoration: none;
    color: color-mix(in srgb, var(--theme-primary) 65%, var(--theme-text-primary));
    cursor: pointer;
    position: relative;
    transition: color 150ms ease;
    text-underline-offset: 3px;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
}

/* Expand icon indicator */
.player-name-trigger::before {
    content: "\f35d"; /* fa-up-right-from-square */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.65em;
    opacity: 0.4;
    transition: opacity 150ms ease, transform 150ms ease;
}

/* Animated underline on hover */
.player-name-trigger::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--theme-primary), var(--theme-info));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-name-trigger:hover {
    color: var(--theme-primary);
}

.player-name-trigger:hover::before {
    opacity: 1;
    transform: scale(1.1);
}

.player-name-trigger:hover::after {
    transform: scaleX(1);
}

.player-name-trigger:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 3px;
    border-radius: 2px;
}

.player-name-trigger--has-popup {
    position: relative;
}

.player-name-trigger--badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--theme-border-color);
    background: var(--theme-surface-1);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    margin: -0.15rem 0;
    gap: 0.25rem;
    transition: all 150ms ease;
}

.player-name-trigger--badge::before {
    display: none; /* Badge style is already visually distinct */
}

.player-name-trigger--badge:hover {
    background: var(--theme-surface-2);
    border-color: var(--theme-primary);
}

.player-name-trigger--compact {
    font-size: 0.925rem;
    opacity: 0.95;
}

.player-name-trigger--link-only {
    text-decoration: none;
}

.player-name-trigger--link-only::before {
    display: none; /* No icon for plain link style */
}

.player-name-trigger--link-only:hover {
    text-decoration: underline;
}

/* Recap player name triggers - subtle styling within narrative text */
.player-name-trigger--recap {
    font-weight: inherit;
    color: var(--theme-primary);
    cursor: pointer;
    border-radius: 3px;
    padding: 0 2px;
    margin: 0 -2px;
    transition: background-color 150ms ease, color 150ms ease;
    display: inline; /* Override flex for inline narrative text */
}

.player-name-trigger--recap::before {
    display: none; /* No icon in narrative text */
}

.player-name-trigger--recap:hover {
    background-color: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.15);
    color: var(--theme-primary);
}

.player-name-trigger--recap:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 1px;
}

/* Ensure bold styling is preserved in recaps */
strong .player-name-trigger--recap {
    font-weight: 700;
}

/* ==========================================================================
   POPUP CARD - MAIN CONTAINER
   ========================================================================== */

.player-popup-card {
    --popup-glow: var(--theme-primary);
    --popup-surface: rgba(15, 15, 20, 0.92);
    --popup-surface-light: rgba(255, 255, 255, 0.03);
    --popup-border: rgba(255, 255, 255, 0.08);

    position: fixed;
    z-index: 10100; /* Above modals (9999) and Bootstrap modals (1055) */
    width: min(380px, calc(100vw - 1.5rem));
    border-radius: 20px;
    overflow: hidden;
    transform-origin: top left;

    /* Glass effect */
    background: var(--popup-surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);

    /* Layered border effect */
    border: 1px solid var(--popup-border);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 80px -20px var(--popup-glow);

    /* Initial state */
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    visibility: hidden;
    transition:
        opacity 250ms cubic-bezier(0.16, 1, 0.3, 1),
        transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0ms 250ms;
}

.player-popup-card.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    transition:
        opacity 350ms cubic-bezier(0.16, 1, 0.3, 1),
        transform 350ms cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0ms;
}

/* When popup opens above the trigger, animate from bottom */
.player-popup-card.is-above {
    transform-origin: bottom left;
    transform: translateY(-12px) scale(0.95);
}

.player-popup-card.is-above.is-open {
    transform: translateY(0) scale(1);
}

.player-popup-card.is-above.is-closing {
    transform: translateY(-12px) scale(0.95);
}

/* Closing animation - reverse of opening */
.player-popup-card.is-closing {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    visibility: visible;
    transition:
        opacity 200ms cubic-bezier(0.4, 0, 1, 1),
        transform 200ms cubic-bezier(0.4, 0, 1, 1),
        visibility 0ms 200ms;
}

/* Reset child elements quickly during close */
.player-popup-card.is-closing .player-popup-card__banner img {
    opacity: 0;
    transform: scale(1.05);
    transition: all 150ms ease;
}

.player-popup-card.is-closing .player-popup-card__close {
    opacity: 0;
    transform: scale(0.8);
    transition: all 100ms ease;
}

.player-popup-card.is-closing .player-popup-card__avatar {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transition: all 120ms ease;
}

.player-popup-card.is-closing .player-popup-card__info {
    opacity: 0;
    transform: translateX(-8px);
    transition: all 100ms ease;
}

.player-popup-card.is-closing .player-popup-card__stat {
    opacity: 0;
    transform: translateY(8px);
    transition: all 100ms ease;
}

.player-popup-card.is-closing .player-popup-card__course-pill {
    opacity: 0;
    transform: translateY(8px);
    transition: all 100ms ease;
}

.player-popup-card.is-closing .player-popup-card__cta-row {
    opacity: 0;
    transform: translateY(8px);
    transition: all 100ms ease;
}

/* Light theme adjustments - use data-bs-theme attribute (Bootstrap) */
[data-bs-theme="light"] .player-popup-card {
    --popup-surface: rgba(255, 255, 255, 0.96);
    --popup-surface-light: rgba(0, 0, 0, 0.03);
    --popup-border: rgba(0, 0, 0, 0.1);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06) inset,
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 0 60px -20px rgba(var(--theme-primary-rgb, 99, 102, 241), 0.2);
}

/* Light mode: avatar border */
[data-bs-theme="light"] .player-popup-card__avatar {
    border-color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Light mode: close button */
[data-bs-theme="light"] .player-popup-card__close {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Light mode: stat cards */
[data-bs-theme="light"] .player-popup-card__stat {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

/* Light mode: course pill */
[data-bs-theme="light"] .player-popup-card__course-pill {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-bs-theme="light"] .player-popup-card__course-bg {
    filter: none;
    opacity: 0.08;
}

[data-bs-theme="light"] .player-popup-card__course-pill:hover .player-popup-card__course-bg {
    opacity: 0.12;
}

/* Light mode: course emblem border */
[data-bs-theme="light"] .player-popup-card__course-emblem {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Light mode: ensure high contrast text (use !important to override prefers-color-scheme fallbacks) */
[data-bs-theme="light"] .player-popup-card__name,
.player-popup-card[data-bs-theme="light"] .player-popup-card__name {
    color: #1a1a2e !important;
}

[data-bs-theme="light"] .player-popup-card__stat-value,
.player-popup-card[data-bs-theme="light"] .player-popup-card__stat-value {
    color: #1a1a2e !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: #1a1a2e !important;
    background-clip: unset !important;
}

[data-bs-theme="light"] .player-popup-card__stat-label,
.player-popup-card[data-bs-theme="light"] .player-popup-card__stat-label {
    color: rgba(26, 26, 46, 0.7) !important;
}

[data-bs-theme="light"] .player-popup-card__course-name,
.player-popup-card[data-bs-theme="light"] .player-popup-card__course-name {
    color: #1a1a2e !important;
}

/* Dark mode: ensure high contrast text */
[data-bs-theme="dark"] .player-popup-card__name {
    color: #fff;
}

[data-bs-theme="dark"] .player-popup-card__stat-value {
    color: #fff;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: #fff;
    background-clip: unset;
}

[data-bs-theme="dark"] .player-popup-card__stat-label {
    color: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] .player-popup-card__course-name {
    color: #fff;
}

/* Fallback for prefers-color-scheme when no data-bs-theme is set on html/body */
@media (prefers-color-scheme: light) {
    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card {
        --popup-surface: rgba(255, 255, 255, 0.96);
        --popup-surface-light: rgba(0, 0, 0, 0.03);
        --popup-border: rgba(0, 0, 0, 0.1);
        box-shadow:
            0 0 0 1px rgba(0, 0, 0, 0.06) inset,
            0 25px 50px -12px rgba(0, 0, 0, 0.15),
            0 0 60px -20px rgba(var(--theme-primary-rgb, 99, 102, 241), 0.2);
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__name {
        color: #1a1a2e;
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__stat-value {
        color: #1a1a2e;
        background: none;
        -webkit-background-clip: unset;
        -webkit-text-fill-color: #1a1a2e;
        background-clip: unset;
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__stat-label {
        color: rgba(26, 26, 46, 0.7);
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__course-name {
        color: #1a1a2e;
    }
}

/* Dark mode fallback for prefers-color-scheme when no data-bs-theme is set on html/body */
@media (prefers-color-scheme: dark) {
    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__name {
        color: #fff;
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__stat-value {
        color: #fff;
        background: none;
        -webkit-background-clip: unset;
        -webkit-text-fill-color: #fff;
        background-clip: unset;
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__stat-label {
        color: rgba(255, 255, 255, 0.7);
    }

    html:not([data-bs-theme]):not(:has([data-bs-theme])) .player-popup-card__course-name {
        color: #fff;
    }
}

/* ==========================================================================
   BANNER SECTION
   ========================================================================== */

.player-popup-card__banner {
    position: relative;
    height: 100px;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--theme-primary) 80%, black),
        color-mix(in srgb, var(--theme-info) 70%, black)
    );
}

.player-popup-card__banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transform: scale(1.1);
    transition: opacity 400ms ease 100ms, transform 600ms ease 100ms;
}

.player-popup-card.is-open .player-popup-card__banner img {
    opacity: 1;
    transform: scale(1);
}

/* Cinematic gradient overlay */
.player-popup-card__banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg,
            transparent 0%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0.7) 100%
        ),
        linear-gradient(90deg,
            rgba(var(--theme-primary-rgb, 99, 102, 241), 0.15) 0%,
            transparent 50%,
            rgba(var(--theme-info-rgb, 59, 130, 246), 0.15) 100%
        );
    pointer-events: none;
}

/* Close button */
.player-popup-card__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-popup-card.is-open .player-popup-card__close {
    opacity: 1;
    transform: scale(1);
    transition-delay: 200ms;
}

.player-popup-card__close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.player-popup-card__close:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   BODY SECTION
   ========================================================================== */

.player-popup-card__body {
    padding: 0 1.25rem 1.25rem;
    position: relative;
}

/* ==========================================================================
   HEADER - HORIZONTAL LAYOUT (Avatar left, Info right)
   ========================================================================== */

.player-popup-card__header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-top: -40px;
    padding: 0 1.25rem;
    position: relative;
    z-index: 5;
}

.player-popup-card__avatar-wrap {
    flex-shrink: 0;
}

.player-popup-card__avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
    opacity: 0;
    transform: translateY(16px) scale(0.9);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
    border: 3px solid var(--popup-surface);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    background: var(--theme-surface-2);
}

.player-popup-card.is-open .player-popup-card__avatar {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition-delay: 80ms;
}

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

/* Avatar initials fallback */
.player-popup-card__avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--theme-text-primary);
    background: linear-gradient(
        135deg,
        var(--theme-surface-2) 0%,
        color-mix(in srgb, var(--theme-surface-2) 80%, var(--theme-primary)) 100%
    );
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Info section (name + meta) */
.player-popup-card__info {
    flex: 1;
    min-width: 0;
    padding-top: 44px;
    opacity: 0;
    transform: translateX(-12px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-popup-card.is-open .player-popup-card__info {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 120ms;
}

.player-popup-card__name {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--theme-text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}

.player-popup-card__meta {
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.player-popup-card__meta .pdga-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    background: var(--popup-surface-light);
    border: 1px solid var(--popup-border);
    border-radius: 999px;
    color: var(--theme-text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 200ms ease;
}

.player-popup-card__meta .pdga-link:hover {
    background: rgba(var(--theme-primary-rgb, 99, 102, 241), 0.15);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.player-popup-card__meta .pdga-icon-inline {
    height: 1em;
    width: auto;
    opacity: 0.9;
}

/* PDGA logo white in dark mode */
[data-bs-theme="dark"] .player-popup-card__meta .pdga-icon-inline,
.player-popup-card__meta .pdga-icon-inline {
    filter: brightness(0) invert(1);
}

/* Light mode: keep blue logo */
[data-bs-theme="light"] .player-popup-card__meta .pdga-icon-inline {
    filter: none;
}

@media (prefers-color-scheme: light) {
    :not([data-bs-theme="dark"]) .player-popup-card__meta .pdga-icon-inline {
        filter: none;
    }
}

/* Stats Mode Badge */
.player-popup-card__stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 200ms ease;
    white-space: nowrap;
}

.player-popup-card__stats-badge i {
    font-size: 0.7rem;
}

/* Active variant - player has throw data */
.player-popup-card__stats-badge--active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08));
    color: var(--theme-success, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.3);
    cursor: default;
}

/* Promo variant - encourage enabling stats */
.player-popup-card__stats-badge--promo {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    color: var(--theme-info, #3b82f6);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.player-popup-card__stats-badge--promo:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(59, 130, 246, 0.15));
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--theme-info, #3b82f6);
    text-decoration: none;
}

/* ==========================================================================
   STATS GRID
   ========================================================================== */

.player-popup-card__stats {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
}

.player-popup-card__stat {
    position: relative;
    background: var(--popup-surface-light);
    border: 1px solid var(--popup-border);
    border-radius: 14px;
    padding: 0.875rem 0.5rem;
    text-align: center;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-popup-card.is-open .player-popup-card__stat {
    opacity: 1;
    transform: translateY(0);
}

.player-popup-card.is-open .player-popup-card__stat:nth-child(1) { transition-delay: 200ms; }
.player-popup-card.is-open .player-popup-card__stat:nth-child(2) { transition-delay: 250ms; }
.player-popup-card.is-open .player-popup-card__stat:nth-child(3) { transition-delay: 300ms; }

/* Subtle glow on hover */
.player-popup-card__stat::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at 50% 0%,
        rgba(var(--theme-primary-rgb, 99, 102, 241), 0.1) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 200ms ease;
}

.player-popup-card__stat:hover::before {
    opacity: 1;
}

.player-popup-card__stat-value {
    font-weight: 800;
    font-size: 1.375rem;
    color: var(--theme-text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, var(--theme-text-primary) 0%, color-mix(in srgb, var(--theme-text-primary) 70%, var(--theme-primary)) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.player-popup-card__stat-label {
    margin-top: 0.35rem;
    color: var(--theme-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   HEAD-TO-HEAD SECTION - Stadium Scoreboard Aesthetic
   Compact version for popup cards with coordinated styling
   ========================================================================== */

.player-popup-card__h2h {
    --h2h-glow-start: var(--flipt-primary, #00a69c);
    --h2h-glow-mid: #16c79a;
    --h2h-glow-end: var(--bs-warning, #f59e0b);
    --h2h-track-shadow: rgba(0, 166, 156, 0.4);

    margin-top: 1rem;
    padding: 0.875rem 1rem 0.75rem;
    position: relative;
    background: var(--popup-surface-light);
    border: 1px solid var(--popup-border);
    border-radius: 14px;
    opacity: 0;
    transform: translateY(12px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

/* Subtle diagonal texture overlay */
.player-popup-card__h2h::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        135deg,
        transparent 0px,
        transparent 2px,
        rgba(var(--theme-primary-rgb, 0, 166, 156), 0.03) 2px,
        rgba(var(--theme-primary-rgb, 0, 166, 156), 0.03) 4px
    );
    pointer-events: none;
    opacity: 0.6;
}

.player-popup-card.is-open .player-popup-card__h2h {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 320ms;
}

/* Closing animation */
.player-popup-card.is-closing .player-popup-card__h2h {
    opacity: 0;
    transform: translateY(8px);
    transition: all 100ms ease;
}

/* Label with crossed swords icon */
.player-popup-card__h2h-label {
    color: var(--theme-text-muted);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    z-index: 1;
}

.player-popup-card__h2h-label::before {
    content: "⚔";
    font-size: 0.85em;
    opacity: 0.5;
    filter: grayscale(0.3);
}

/* Main row: record + win rate */
.player-popup-card__h2h-row {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem;
    position: relative;
    z-index: 1;
}

/* Record stat boxes */
.player-popup-card__h2h-record {
    display: inline-flex;
    align-items: stretch;
    gap: 0.375rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--theme-text-primary);
}

.player-popup-card__h2h-record-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem 0.25rem;
    border-radius: 8px;
    background: rgba(var(--theme-primary-rgb, 0, 166, 156), 0.06);
    border: 1px solid rgba(var(--theme-primary-rgb, 0, 166, 156), 0.1);
    min-width: 2.25rem;
    transition: background-color 150ms ease, border-color 150ms ease;
}

/* Color-coded hover states */
.player-popup-card__h2h-record-part[aria-label="Wins"]:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.player-popup-card__h2h-record-part[aria-label="Losses"]:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.player-popup-card__h2h-record-part[aria-label="Ties"]:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.2);
}

.player-popup-card__h2h-record-key {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--theme-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.player-popup-card__h2h-record-value {
    font-family: var(--font-display, system-ui, -apple-system, sans-serif);
    font-size: 1.125rem;
    font-weight: 900;
    color: var(--theme-text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* Color accent on hover for values */
.player-popup-card__h2h-record-part[aria-label="Wins"]:hover .player-popup-card__h2h-record-value {
    color: #10b981;
}

.player-popup-card__h2h-record-part[aria-label="Losses"]:hover .player-popup-card__h2h-record-value {
    color: #ef4444;
}

.player-popup-card__h2h-record-part[aria-label="Ties"]:hover .player-popup-card__h2h-record-value {
    color: #8b5cf6;
}

/* Win rate badge */
.player-popup-card__h2h-rate {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--theme-text-primary);
    padding: 0.25rem 0.6rem 0.25rem 0.5rem;
    border-radius: 999px;
    background: linear-gradient(
        135deg,
        rgba(var(--theme-primary-rgb, 0, 166, 156), 0.15) 0%,
        rgba(var(--theme-primary-rgb, 0, 166, 156), 0.08) 100%
    );
    border: 1px solid rgba(var(--theme-primary-rgb, 0, 166, 156), 0.25);
    box-shadow:
        0 2px 6px -2px rgba(var(--theme-primary-rgb, 0, 166, 156), 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    letter-spacing: -0.01em;
}

.player-popup-card__h2h-rate-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Last matchup meta */
.player-popup-card__h2h-meta {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--popup-border);
    color: var(--theme-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    z-index: 1;
}

/* Calendar icon */
.player-popup-card__h2h-meta::before {
    content: "\f073";
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
    font-size: 0.8em;
    opacity: 0.5;
}

/* Rivalry meter section */
.player-popup-card__h2h-rivalry {
    margin-top: 0.625rem;
    position: relative;
    z-index: 1;
}

.player-popup-card__h2h-rivalry-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.player-popup-card__h2h-rivalry-label {
    color: var(--theme-text-muted);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Flame icon for high rivalry */
.player-popup-card__h2h-rivalry-label::before {
    content: "🔥";
    font-size: 0.75em;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 200ms ease, transform 200ms ease;
}

/* Show flame when rivalry is 40+ */
.player-popup-card__h2h-rivalry[style*="--rivalry-score:4"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:5"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:6"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:7"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:8"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:9"],
.player-popup-card__h2h-rivalry[style*="--rivalry-score:100"] {
    & .player-popup-card__h2h-rivalry-label::before {
        opacity: 1;
        transform: scale(1);
    }
}

.player-popup-card__h2h-rivalry-value {
    font-family: var(--font-display, system-ui, -apple-system, sans-serif);
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--theme-text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* The rivalry track - enhanced gradient bar */
.player-popup-card__h2h-rivalry-track {
    position: relative;
    height: 12px;
    border-radius: 999px;
    overflow: visible;
    background: linear-gradient(
        90deg,
        var(--h2h-glow-start) 0%,
        var(--h2h-glow-mid) 50%,
        var(--h2h-glow-end) 100%
    );
    border: 1px solid var(--popup-border);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 16px -4px var(--h2h-track-shadow);
}

/* Animated shimmer on track */
.player-popup-card__h2h-rivalry-track::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: popup-h2h-shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes popup-h2h-shimmer {
    0%, 100% { background-position: 200% center; }
    50% { background-position: -200% center; }
}

/* Glow highlight up to marker position */
.player-popup-card__h2h-rivalry-track::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: calc(var(--rivalry-score, 0) * 1%);
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.05) 100%
    );
    pointer-events: none;
}

/* The crossed swords marker */
.player-popup-card__h2h-rivalry-marker {
    position: absolute;
    top: 50%;
    left: calc(var(--rivalry-score, 0) * 1%);
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    display: block;
    font-size: 1.75em;
    line-height: 1;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    user-select: none;
    pointer-events: none;
    z-index: 2;
    filter:
        drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5))
        drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Subtle pulse on hover */
.player-popup-card__h2h:hover .player-popup-card__h2h-rivalry-marker {
    animation: popup-h2h-pulse 1.5s ease-in-out infinite;
}

@keyframes popup-h2h-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Light mode adjustments for H2H */
[data-bs-theme="light"] .player-popup-card__h2h {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-bs-theme="light"] .player-popup-card__h2h::before {
    background: repeating-linear-gradient(
        135deg,
        transparent 0px,
        transparent 2px,
        rgba(0, 166, 156, 0.04) 2px,
        rgba(0, 166, 156, 0.04) 4px
    );
}

[data-bs-theme="light"] .player-popup-card__h2h-record-part {
    background: rgba(0, 166, 156, 0.05);
    border-color: rgba(0, 166, 156, 0.1);
}

[data-bs-theme="light"] .player-popup-card__h2h-rivalry-track {
    border-color: rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   BIO SECTION
   ========================================================================== */

.player-popup-card__bio {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    position: relative;
    background: var(--popup-surface-light);
    border: 1px solid var(--popup-border);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(12px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-popup-card.is-open .player-popup-card__bio {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 320ms;
}

.player-popup-card.is-closing .player-popup-card__bio {
    opacity: 0;
    transform: translateY(8px);
    transition: all 100ms ease;
}

/* Decorative quote mark */
.player-popup-card__bio::before {
    content: """;
    position: absolute;
    top: -0.1rem;
    left: 0.5rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2.5rem;
    line-height: 1;
    color: var(--theme-primary);
    opacity: 0.25;
    pointer-events: none;
}

.player-popup-card__bio-text {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--theme-text-secondary);
    font-style: italic;
    margin: 0;
    padding-left: 0.25rem;
    /* Clamp to 3 lines max with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

/* Light mode adjustments */
[data-bs-theme="light"] .player-popup-card__bio-text,
.player-popup-card[data-bs-theme="light"] .player-popup-card__bio-text {
    color: var(--theme-text-secondary);
}

/* ==========================================================================
   HOME COURSE PILL
   ========================================================================== */

.player-popup-card__course-pill {
    display: flex;
    align-items: center;
    margin-top: 1rem;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    text-decoration: none;
    color: var(--theme-text-primary);
    background: var(--popup-surface-light);
    border: 1px solid var(--popup-border);
    opacity: 0;
    transform: translateY(12px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-popup-card.is-open .player-popup-card__course-pill {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 360ms;
}

.player-popup-card__course-pill:hover {
    border-color: var(--theme-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Tileable background pattern */
.player-popup-card__course-bg {
    position: absolute;
    inset: 0;
    background-size: 120px auto;
    background-repeat: repeat;
    opacity: 0.12;
    z-index: 0;
    transition: opacity 200ms ease;
}

.player-popup-card__course-pill:hover .player-popup-card__course-bg {
    opacity: 0.18;
}

/* Dark mode: increase pattern visibility */
[data-bs-theme="dark"] .player-popup-card__course-bg {
    opacity: 0.15;
    filter: invert(1) brightness(1.5);
}

[data-bs-theme="dark"] .player-popup-card__course-pill:hover .player-popup-card__course-bg {
    opacity: 0.22;
}

/* Content layer */
.player-popup-card__course-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    position: relative;
    z-index: 1;
    width: 100%;
}

/* Course emblem */
.player-popup-card__course-emblem {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background: var(--theme-surface-2);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.player-popup-card__course-pill:hover .player-popup-card__course-emblem {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Fallback icon when no emblem */
.player-popup-card__course-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--theme-info), var(--theme-primary));
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Course name */
.player-popup-card__course-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--theme-text-primary);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   CTA BUTTON
   ========================================================================== */

.player-popup-card__cta-row {
    margin-top: 1rem;
    opacity: 0;
    transform: translateY(12px);
    transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-popup-card.is-open .player-popup-card__cta-row {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 400ms;
}

.player-popup-card__cta-row .btn-theme-base {
    width: 100%;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    font-weight: 700;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.player-popup-card__cta-row .btn-theme-base::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 400ms ease;
}

.player-popup-card__cta-row .btn-theme-base:hover::before {
    transform: translateX(100%);
}

/* ==========================================================================
   LOADING & ERROR STATES
   ========================================================================== */

.player-popup-card__loading,
.player-popup-card__error {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--theme-text-secondary);
}

.player-popup-card__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.player-popup-card__loading .spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
    color: var(--theme-primary);
}

.player-popup-card__error {
    color: var(--theme-text-muted);
}

/* ==========================================================================
   FRIEND BUTTON STYLES
   ========================================================================== */

.player-popup-card__friend-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--popup-border);
    border-radius: 999px;
    background: var(--popup-surface-light);
    color: var(--theme-text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-popup-card__friend-btn:hover {
    transform: translateY(-1px);
}

.player-popup-card__friend-btn:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

.player-popup-card__friend-btn i {
    font-size: 0.75rem;
}

/* Add Friend - Primary action with glow */
.player-popup-card__friend-btn--add {
    background: linear-gradient(135deg, var(--theme-primary), color-mix(in srgb, var(--theme-primary) 80%, var(--theme-info)));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 12px -2px rgba(var(--theme-primary-rgb, 99, 102, 241), 0.5);
}

.player-popup-card__friend-btn--add:hover {
    box-shadow: 0 4px 20px -2px rgba(var(--theme-primary-rgb, 99, 102, 241), 0.6);
    transform: translateY(-2px);
}

/* Pending - Muted status indicator */
.player-popup-card__friend-btn--pending {
    background: rgba(var(--theme-warning-rgb, 251, 191, 36), 0.12);
    border-color: rgba(var(--theme-warning-rgb, 251, 191, 36), 0.3);
    color: color-mix(in srgb, var(--theme-warning, #fbbf24) 90%, var(--theme-text-primary));
    cursor: default;
}

.player-popup-card__friend-btn--pending:hover {
    transform: none;
    background: rgba(var(--theme-warning-rgb, 251, 191, 36), 0.15);
}

/* Accept - Success green */
.player-popup-card__friend-btn--accept {
    background: linear-gradient(135deg, var(--theme-success, #22c55e), color-mix(in srgb, var(--theme-success, #22c55e) 80%, #10b981));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 12px -2px rgba(34, 197, 94, 0.4);
}

.player-popup-card__friend-btn--accept:hover {
    box-shadow: 0 4px 16px -2px rgba(34, 197, 94, 0.5);
}

/* Decline - Subtle danger */
.player-popup-card__friend-btn--decline {
    background: transparent;
    border-color: var(--popup-border);
    color: var(--theme-text-muted);
    padding: 0.35rem 0.6rem;
}

.player-popup-card__friend-btn--decline:hover {
    background: var(--theme-danger, #dc3545);
    border-color: var(--theme-danger, #dc3545);
    color: #fff;
}

/* Friends - Static success indicator */
.player-popup-card__friend-btn--friends {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--theme-success, #22c55e);
    cursor: default;
}

.player-popup-card__friend-btn--friends:hover {
    transform: none;
}

/* Friend actions container */
.player-popup-card__friend-actions {
    display: inline-flex;
    gap: 0.4rem;
}

/* Loading state */
.player-popup-card__friend-btn--loading {
    pointer-events: none;
    opacity: 0.7;
}

.player-popup-card__friend-btn--loading::before {
    content: "";
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: friend-btn-spin 0.6s linear infinite;
}

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

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Mobile: Full-screen drawer from bottom */
@media (max-width: 767px) {
    .player-popup-card {
        width: 100vw;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        bottom: 0;
        left: 0 !important;
        top: auto !important;
        transform-origin: bottom center;
        overflow-y: auto;
    }

    .player-popup-card:not(.is-open) {
        transform: translateY(100%) scale(1);
    }

    .player-popup-card.is-open {
        transform: translateY(0) scale(1);
    }

    .player-popup-card.is-closing {
        transform: translateY(100%) scale(1);
    }

    /* Override is-above on mobile - always use bottom drawer behavior */
    .player-popup-card.is-above {
        transform-origin: bottom center;
        transform: translateY(100%) scale(1);
    }

    .player-popup-card.is-above.is-open {
        transform: translateY(0) scale(1);
    }

    .player-popup-card.is-above.is-closing {
        transform: translateY(100%) scale(1);
    }

    .player-popup-card__banner {
        height: 120px;
    }

    .player-popup-card__stats {
        gap: 0.5rem;
    }

    .player-popup-card__stat {
        padding: 0.75rem 0.4rem;
    }

    .player-popup-card__stat-value {
        font-size: 1.125rem;
    }

    .player-popup-card__stat-label {
        font-size: 0.65rem;
    }

    /* H2H section mobile adjustments */
    .player-popup-card__h2h {
        padding: 0.75rem 0.875rem 0.625rem;
    }

    .player-popup-card__h2h-record-part {
        padding: 0.3rem 0.4rem 0.2rem;
        min-width: 2rem;
    }

    .player-popup-card__h2h-record-value {
        font-size: 1rem;
    }

    .player-popup-card__h2h-rate {
        font-size: 0.85rem;
        padding: 0.2rem 0.5rem 0.2rem 0.4rem;
    }

    .player-popup-card__h2h-rivalry-track {
        height: 10px;
    }

    .player-popup-card__h2h-rivalry-marker {
        font-size: 1.5em;
    }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .player-popup-card,
    .player-popup-card *,
    .player-avatar-popup-trigger,
    .player-avatar-popup-trigger::before,
    .player-name-trigger,
    .player-name-trigger::after {
        animation: none !important;
        transition: opacity 150ms ease !important;
    }

    .player-popup-card.is-open .player-popup-card__avatar,
    .player-popup-card.is-open .player-popup-card__info,
    .player-popup-card.is-open .player-popup-card__stat,
    .player-popup-card.is-open .player-popup-card__bio,
    .player-popup-card.is-open .player-popup-card__h2h,
    .player-popup-card.is-open .player-popup-card__course-pill,
    .player-popup-card.is-open .player-popup-card__cta-row,
    .player-popup-card.is-open .player-popup-card__close,
    .player-popup-card.is-open .player-popup-card__banner img {
        opacity: 1;
        transform: none;
        transition-delay: 0ms;
    }

    /* Disable H2H animations */
    .player-popup-card__h2h-rivalry-track::before,
    .player-popup-card__h2h:hover .player-popup-card__h2h-rivalry-marker {
        animation: none;
    }

    .player-popup-card__h2h-record-part {
        transition: none;
    }

    /* Closing state respects reduced motion */
    .player-popup-card.is-closing {
        opacity: 0;
        transform: none !important;
        transition: opacity 100ms ease !important;
    }
}
