/* =====================================================
   VRC POP Live Activity Page
   Page-specific styles for the Live Activity visualization
   ===================================================== */

/* ===== Page Layout ===== */
.live-activity-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);  /* Minimum full viewport */
    height: calc(100vh - 64px);  /* Fixed height for proper grid sizing */
    overflow-x: hidden;  /* Prevent horizontal overflow */
    overflow-y: auto;  /* Allow vertical scroll if banners push content */
    background: var(--bg-primary);
    padding: var(--space-4);
    box-sizing: border-box;
    max-width: 100%;
}

/* When leaderboard is expanded, allow page to grow and scroll */
.live-activity-page:has(.leaderboard--expanded) {
    height: auto;
    min-height: calc(100vh - 64px);
}

/* Fullscreen mode - lock to viewport */
.live-activity-page--fullscreen {
    height: calc(100vh - 64px) !important;
    overflow: hidden !important;
}

/* ===== Page Header ===== */
.live-activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;  /* Don't shrink header */
}

.live-activity-header__title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.live-activity-header__title h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.live-activity-header__controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-shrink: 1;  /* Allow controls to shrink if needed */
}

/* Mode Toggle Container with Stats */
.mode-toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.live-stats {
    display: flex;
    gap: var(--space-5);
    padding-left: var(--space-4);
    border-left: 1px solid var(--border-subtle);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Emerging Clubs Toggle ===== */
.emerging-toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-left: var(--space-4);
    border-left: 1px solid var(--border-subtle);
}

.emerging-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

/* Attention-grabbing animation for first-time users */
.emerging-toggle:not(.emerging-toggle--active):not(.emerging-toggle--noticed) {
    animation: emerging-attention 3s ease-in-out infinite;
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
}

@keyframes emerging-attention {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
        border-color: rgba(16, 185, 129, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 12px 2px rgba(16, 185, 129, 0.3);
        border-color: rgba(16, 185, 129, 0.7);
    }
}

/* "New" badge for the button */
.emerging-toggle::after {
    content: 'New!';
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: badge-pulse 2s ease-in-out infinite;
}

.emerging-toggle--noticed::after,
.emerging-toggle--active::after {
    display: none;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.emerging-toggle:hover {
    background: var(--bg-elevated);
    border-color: #10B981;
    color: var(--text-primary);
    animation: none;
    transform: scale(1.02);
}

.emerging-toggle--active {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border-color: #059669;
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    animation: none;
}

.emerging-toggle--active:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border-color: #047857;
    color: white;
    transform: scale(1.02);
}

/* Once user has interacted, stop animation */
.emerging-toggle--noticed {
    animation: none;
    border-color: var(--border-subtle);
}

.emerging-toggle__icon {
    font-size: 1.1em;
    line-height: 1;
}

.emerging-toggle__label {
    line-height: 1;
}

.emerging-toggle__info {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    opacity: 0.7;
    transition: all var(--transition-fast);
}

.emerging-toggle__info:hover {
    color: var(--brand-primary);
    opacity: 1;
}

/* Quest Only Toggle */
.quest-toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-left: var(--space-4);
    border-left: 1px solid var(--border-subtle);
}

.quest-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

/* Icon wrapper with circular background */
.quest-toggle__icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    transition: background var(--transition-fast);
}

.quest-toggle__icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: #3DDC84;  /* Always Quest green */
}

.quest-toggle__label {
    line-height: 1;
}

/* Checkmark hidden by default */
.quest-toggle__check {
    display: none;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.quest-toggle:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.quest-toggle:hover .quest-toggle__icon-wrapper {
    background: rgba(61, 220, 132, 0.2);
}

/* Active state - clearly shows filtering is ON */
.quest-toggle--active {
    background: var(--bg-elevated);
    border-color: #3DDC84;
    color: var(--text-primary);
    box-shadow: 0 0 0 1px rgba(61, 220, 132, 0.2);
}

.quest-toggle--active .quest-toggle__icon-wrapper {
    background: #3DDC84;
}

.quest-toggle--active .quest-toggle__icon {
    color: white;
}

.quest-toggle--active .quest-toggle__check {
    display: block;
    color: #3DDC84;
}

.quest-toggle--active:hover {
    border-color: #2BC270;
}

.quest-toggle--active:hover .quest-toggle__icon-wrapper {
    background: #2BC270;
}

/* Emerging mode indicator banner */
.emerging-mode-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.15) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    color: #10B981;
    font-size: var(--text-sm);
    font-weight: 500;
    margin-bottom: var(--space-3);
    flex-shrink: 0;  /* Don't shrink when space is tight */
}

.emerging-mode-banner--visible {
    display: flex;
}

.emerging-mode-banner__icon {
    font-size: 1.1em;
}

.emerging-mode-banner__text {
    flex: 1;
}

.emerging-mode-banner__link {
    color: #10B981;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.emerging-mode-banner__link:hover {
    color: #059669;
}

/* Hide on small screens */
@media (max-width: 768px) {
    .emerging-toggle-container {
        padding-left: 0;
        border-left: none;
    }
    
    .emerging-toggle__label {
        display: none;
    }
    
    .emerging-toggle {
        padding: var(--space-2);
    }
    
    .emerging-toggle__info {
        display: none;
    }
    
    .quest-toggle-container {
        padding-left: 0;
        border-left: none;
    }
    
    .quest-toggle__label {
        display: none;
    }
    
    .quest-toggle {
        padding: var(--space-2);
    }
}

/* ===== Main Content Grid ===== */
.live-activity-content {
    display: grid;
    grid-template-columns: 1fr 280px;  /* Slightly narrower feed */
    grid-template-rows: 1fr auto auto;  /* Scene takes available space */
    gap: var(--space-3);
    flex: 1 1 auto;
    min-height: 0;  /* Critical: allow grid to shrink within flex container */
    overflow: hidden;  /* Contain the grid content */
}

/* When leaderboard is expanded, allow content to grow */
.live-activity-page:has(.leaderboard--expanded) .live-activity-content {
    overflow: visible;
    flex: 0 0 auto;  /* Don't shrink or grow, use natural size */
    grid-template-rows: auto auto auto;  /* All rows use natural height */
}

/* When leaderboard is expanded, lock feed to same height as scene */
.live-activity-page:has(.leaderboard--expanded) .live-activity-feed {
    height: max(400px, calc(100vh - 400px));  /* Match scene height */
    max-height: max(400px, calc(100vh - 400px));
    align-self: start;  /* Don't stretch to fill grid cell */
}

/* Desktop: Scene on left, Feed on right, scrubber and leaderboard span full width */
@media (min-width: 1200px) {
    .live-activity-content {
        grid-template-areas:
            "scene feed"
            "scrubber scrubber"
            "leaderboard leaderboard";
    }
}

/* When activity feed is collapsed, scene takes full width */
.live-activity-content:has(.activity-feed--collapsed) {
    grid-template-columns: 1fr;
    grid-template-areas:
        "scene"
        "scrubber"
        "leaderboard";
}

/* Hide feed grid area when collapsed */
.live-activity-content:has(.activity-feed--collapsed) .live-activity-feed {
    display: none;
}

/* Tablet: Feed becomes bottom drawer */
@media (max-width: 1199px) {
    .live-activity-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;  /* All rows use natural height on tablet/mobile */
        grid-template-areas:
            "scene"
            "scrubber"
            "leaderboard";
        overflow: visible;  /* Allow content to be visible */
    }
    
    .live-activity-scene {
        min-height: 350px;  /* Minimum height for bubble display */
        height: auto;  /* Let content determine height */
        max-height: calc(100vh - 300px);  /* Cap at reasonable height */
    }
    
    /* Feed is an overlay on mobile/tablet, not in the grid */
    .live-activity-feed {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        z-index: 500;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    
    /* When collapsed, hide it completely */
    .live-activity-feed.activity-feed--collapsed {
        display: none !important;
    }
    
    /* When leaderboard is expanded on tablet/mobile, allow page to scroll */
    .live-activity-page:has(.leaderboard--expanded) {
        height: auto !important;
        min-height: calc(100vh - 64px);
        overflow-y: auto !important;
    }
    
    .live-activity-page:has(.leaderboard--expanded) .live-activity-scene {
        min-height: 250px;
        max-height: 350px;
    }
}

/* Mobile: Everything stacked, scene takes priority */
@media (max-width: 768px) {
    .live-activity-page {
        padding: var(--space-2);
        height: auto;  /* Allow page to grow */
        min-height: calc(100vh - 64px);
        overflow-x: hidden;
        overflow-y: auto;  /* Allow scroll */
    }
    
    .live-activity-content {
        flex: 0 0 auto;  /* Don't flex, use natural height */
        min-height: 0;
        overflow: visible;  /* Show all content including leaderboard */
    }
    
    .live-activity-scene {
        min-height: 250px;
        height: auto;  /* Let content determine */
        max-height: calc(100vh - 350px);
        max-width: 100%;  /* Prevent horizontal overflow */
    }
    
    /* Mobile: When leaderboard is expanded, shrink scene more */
    .live-activity-page:has(.leaderboard--expanded) .live-activity-scene {
        min-height: 180px;
        max-height: 250px;
    }
    
    .live-activity-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }
    
    .live-activity-header__controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .mode-toggle-container {
        flex-wrap: wrap;
    }
    
    .live-stats {
        display: none;  /* Hide stats on mobile */
    }
    
    /* Bubble text stroke reduced on mobile for smaller text */
    .scene-bubble__name {
        stroke-width: 1.5px;
    }
    
    .scene-bubble__count {
        stroke-width: 2px;
    }
    
    /* Reduce playback time overlay size on mobile */
    .playback-time-overlay {
        padding: var(--space-2) var(--space-3) var(--space-1);
    }
}

/* Small tablets - hide stats */
@media (max-width: 1024px) {
    .live-stats {
        display: none;
    }
}

/* ===== The Scene (Visualization Container) ===== */
.live-activity-scene {
    grid-area: scene;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    min-height: 400px;  /* Minimum height for scene */
    max-width: 100%;  /* Prevent horizontal overflow */
    width: 100%;  /* Fill available width */
}

/* When leaderboard is expanded, lock scene to a fixed height so it doesn't shrink */
.live-activity-page:has(.leaderboard--expanded) .live-activity-scene {
    height: max(400px, calc(100vh - 400px));  /* Reasonable fixed height */
    flex-shrink: 0;
}

/* ===== Large Playback Time Overlay ===== */
/* Default state (live mode) - subtle styling */
.playback-time-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-4) var(--space-2);
    z-index: 20;
    pointer-events: none;
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0.4) 0%, 
        rgba(0, 0, 0, 0.15) 50%,
        transparent 100%);
    transition: all 0.3s ease;
}

/* History/playback mode - more prominent styling */
.playback-time-overlay--history {
    padding: var(--space-4) var(--space-4) var(--space-2);
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0.7) 0%, 
        rgba(0, 0, 0, 0.4) 60%,
        transparent 100%);
}

.playback-time-overlay__time {
    font-size: 2.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1;
    letter-spacing: -0.02em;
    transition: all 0.3s ease;
}

/* Larger time display in history mode */
.playback-time-overlay--history .playback-time-overlay__time {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
}

.playback-time-overlay__relative {
    font-size: 0.95rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    margin-top: var(--space-1);
    transition: all 0.3s ease;
}

/* More prominent relative time in history mode */
.playback-time-overlay--history .playback-time-overlay__relative {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
    .playback-time-overlay__time {
        font-size: 2rem;
    }
    
    .playback-time-overlay--history .playback-time-overlay__time {
        font-size: 2.5rem;
    }
    
    .playback-time-overlay__relative {
        font-size: 0.9rem;
    }
    
    .playback-time-overlay--history .playback-time-overlay__relative {
        font-size: 1rem;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .live-activity-scene {
        min-height: 250px;
        height: calc(100vh - 380px);  /* Account for header, scrubber, leaderboard */
        max-height: 400px;
        max-width: 100%;
    }
    
    /* Bubble text stroke minimized for very small screens */
    .scene-bubble__name {
        stroke-width: 1px;
    }
    
    .scene-bubble__count {
        stroke-width: 1.5px;
    }
    
    .playback-time-overlay__time {
        font-size: 1.75rem;
    }
    
    .playback-time-overlay--history .playback-time-overlay__time {
        font-size: 2rem;
    }
    
    .playback-time-overlay__relative {
        font-size: 0.8rem;
    }
}

.scene-container {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    max-width: 100%;  /* Prevent overflow */
    overflow: hidden;
}

.scene-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;  /* Prevent overflow */
    display: block;
}

/* Scene loading overlay */
.scene-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    z-index: 10;
}

.scene-loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Bubble Styles ===== */
.scene-bubble {
    cursor: pointer;
    transition: opacity var(--transition-fast);
    /* Improve touch target on mobile */
    touch-action: manipulation;
}

.scene-bubble__circle {
    fill: var(--bg-elevated);
    stroke: var(--border-subtle);
    stroke-width: 2px;
    transition: all var(--transition-normal);
    /* Ensure the circle captures pointer events */
    pointer-events: all;
}

.scene-bubble:hover .scene-bubble__circle {
    stroke: var(--brand-primary);
    stroke-width: 3px;
}

.scene-bubble--dimmed {
    opacity: 0.4;
}

.scene-bubble--selected .scene-bubble__circle {
    stroke: var(--brand-primary);
    stroke-width: 3px;
}

/* Status-based bubble styling */
.scene-bubble--hot .scene-bubble__circle {
    stroke: var(--status-hot);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.scene-bubble--rising .scene-bubble__circle {
    stroke: var(--status-active);
}

.scene-bubble--declining .scene-bubble__circle {
    stroke: var(--status-warning);
}

.scene-bubble--quiet .scene-bubble__circle {
    stroke: var(--status-quiet);
    opacity: 0.6;
}

/* Inactive bubble (0 players) - gray, faded, and tiny */
.scene-bubble--inactive {
    opacity: 0.3;
    filter: grayscale(90%);
}

.scene-bubble--inactive .scene-bubble__circle {
    stroke: var(--text-muted);
    stroke-dasharray: 4 2;
    stroke-width: 1px;
    fill: var(--bg-surface);
}

/* Hide text and logo on inactive bubbles - they're too small */
.scene-bubble--inactive .scene-bubble__name,
.scene-bubble--inactive .scene-bubble__count {
    display: none;
}

.scene-bubble--inactive .scene-bubble__logo {
    opacity: 0.2;
}

/* Bubble logo styling */
.scene-bubble__logo {
    pointer-events: none;
    /* Ensure smooth scaling of logos */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Bubble text - base styles, font-size set dynamically via JS */
.scene-bubble__name {
    fill: var(--text-primary);
    /* font-size set dynamically in JS based on bubble radius */
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    dominant-baseline: middle;
    /* Prevent text from overflowing bubble */
    text-overflow: ellipsis;
    /* Add subtle text shadow for better readability over logos */
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.4);
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.scene-bubble__count {
    fill: var(--text-primary);
    /* font-size set dynamically in JS based on bubble radius */
    font-weight: 800;
    font-family: var(--font-mono);
    text-anchor: middle;
    pointer-events: none;
    dominant-baseline: middle;
    /* Make count more prominent with text shadow */
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.5);
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.scene-bubble__status-icon {
    font-size: 18px;
    text-anchor: middle;
    pointer-events: none;
}

.scene-bubble__change {
    fill: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
    text-anchor: middle;
    pointer-events: none;
}

.scene-bubble__change--positive {
    fill: var(--status-active);
}

.scene-bubble__change--negative {
    fill: var(--status-warning);
}

/* Platform badges on bubbles */
.scene-bubble__platforms {
    pointer-events: none;
}

.platform-badge {
    opacity: 0.95;
}

.platform-badge--pc {
    fill: #0078D4;
}

.platform-badge--quest {
    fill: #3DDC84;
}

.platform-badge__icon {
    pointer-events: none;
}

/* Hide platform badges on very small/inactive bubbles */
.scene-bubble--inactive .scene-bubble__platforms {
    display: none;
}

/* ===== Bubble Tooltip ===== */
.bubble-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-elevated);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    min-width: 240px;
    max-width: 320px;
    /* Start off-screen to prevent any touch interception */
    left: -9999px;
    top: -9999px;
}

.bubble-tooltip--visible {
    opacity: 1;
    /* Enable pointer events so users can interact with copy button, close button, etc. */
    pointer-events: auto;
}

.bubble-tooltip__header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.bubble-tooltip__logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
}

.bubble-tooltip__title-group {
    flex: 1;
    min-width: 0;
}

.bubble-tooltip__name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

/* Tags container - full width section below header */
.bubble-tooltip__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

/* World name row */
.bubble-tooltip__world {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.bubble-tooltip__world-label {
    flex-shrink: 0;
}

.bubble-tooltip__world-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.tooltip-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: var(--text-xs);  /* Uses design system, typically 12px */
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid;
    white-space: nowrap;
    line-height: 1.3;
}

/* Header right section (platforms + VRC link) */
.bubble-tooltip__header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    margin-left: auto;
}

/* Platform compatibility icons */
.bubble-tooltip__platforms {
    display: flex;
    align-items: center;
    gap: 4px;
}

.platform-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.platform-icon svg {
    width: 14px;
    height: 14px;
}

/* PC/Windows icon - blue like VRChat */
.platform-icon--pc {
    background-color: #0078D4;
    color: white;
}

/* Quest/Android icon - green like VRChat */
.platform-icon--quest {
    background-color: #3DDC84;
    color: white;
}

/* VRChat external link button */
.bubble-tooltip__vrc-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.bubble-tooltip__vrc-link:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

.bubble-tooltip__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.bubble-tooltip__stat {
    display: flex;
    flex-direction: column;
}

.bubble-tooltip__stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.bubble-tooltip__stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Group Code Section */
.bubble-tooltip__group-code {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.bubble-tooltip__code-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.bubble-tooltip__code {
    flex: 1;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--brand-primary);
    background: var(--bg-surface);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
    letter-spacing: 0.02em;
}

.bubble-tooltip__copy-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--brand-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.bubble-tooltip__copy-btn:hover {
    background: var(--brand-primary-hover, #7c3aed);
}

.bubble-tooltip__copy-btn:active {
    transform: scale(0.95);
}

.bubble-tooltip__copy-btn.copied {
    background: var(--status-active);
}

.bubble-tooltip__copy-btn.copied .copy-text::after {
    content: '!';
}

/* Close button */
.bubble-tooltip__close-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bubble-tooltip__close-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Mobile tooltip positioning */
@media (max-width: 768px) {
    .bubble-tooltip {
        position: fixed !important;
        left: var(--space-3) !important;
        right: var(--space-3) !important;
        bottom: var(--space-3) !important;
        top: auto !important;
        max-width: none;
        width: auto;
        border-radius: var(--radius-lg);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        /* Keep pointer-events: none when hidden to not block scrubber */
    }
    
    /* Only enable pointer events when tooltip is actually visible on mobile */
    .bubble-tooltip--visible {
        pointer-events: auto;
    }
    
    .bubble-tooltip__header {
        padding-right: var(--space-6);
    }
    
    /* Larger tags on mobile for touch targets */
    .bubble-tooltip__tags {
        gap: 6px;
    }
    
    .tooltip-tag {
        padding: 4px 10px;
        font-size: var(--text-sm);  /* Slightly larger on mobile */
    }
    
    .bubble-tooltip__code {
        font-size: var(--text-sm);
        padding: var(--space-2);
    }
    
    .bubble-tooltip__copy-btn {
        padding: var(--space-2);
    }
    
    .bubble-tooltip__code-row {
        gap: var(--space-3);
    }
}

/* ===== Activity Feed ===== */
.live-activity-feed {
    grid-area: feed;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    min-height: 0;  /* Critical: allow shrinking */
    overflow: hidden;
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.feed-header__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.feed-header__actions {
    display: flex;
    gap: var(--space-2);
}

.feed-header__btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.feed-header__btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.feed-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;  /* Critical for flex overflow */
    padding: var(--space-2);
}

.feed-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.feed-item:hover {
    background: var(--bg-elevated);
}

.feed-item--highlighted {
    background: rgba(139, 92, 246, 0.1);
}

.feed-item__icon {
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.feed-item__content {
    flex: 1;
    min-width: 0;
}

.feed-item__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}

.feed-item__group {
    color: var(--text-primary);
    font-weight: 600;
}

.feed-item__time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: var(--space-1);
}

/* Feed filter indicator */
.feed-filter {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: rgba(139, 92, 246, 0.1);
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-xs);
    color: var(--brand-primary);
}

.feed-filter__clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    margin-left: auto;
}

.feed-filter__clear:hover {
    color: var(--text-primary);
}

/* ===== Leaderboard (Detail Strip) ===== */
.live-activity-leaderboard {
    grid-area: leaderboard;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-height: none;  /* Allow height to expand */
    flex-shrink: 0;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.leaderboard-header:hover {
    background: var(--bg-elevated);
}

.leaderboard-header__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-header__toggle {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.leaderboard-header__toggle--expanded {
    transform: rotate(180deg);
}

/* Strip wrapper with arrow controls */
.leaderboard-strip-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    padding: var(--space-2) 0;
}

/* Arrow buttons for navigation */
.leaderboard-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 48px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    z-index: 2;
}

.leaderboard-arrow:hover:not(:disabled) {
    background: var(--border-subtle);
    color: var(--text-primary);
}

.leaderboard-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.leaderboard-arrow--left {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    margin-left: var(--space-2);
}

.leaderboard-arrow--right {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-right: var(--space-2);
}

.leaderboard-arrow svg {
    width: 16px;
    height: 16px;
}

/* Collapsed view: horizontal strip */
.leaderboard-strip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    flex: 1;
    /* Hide scrollbar across browsers */
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.leaderboard-strip::-webkit-scrollbar {
    display: none;  /* Chrome, Safari, Opera */
}

.leaderboard-strip__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    scroll-snap-align: start;
}

.leaderboard-strip__item:hover {
    background: var(--border-subtle);
}

.leaderboard-strip__item--selected {
    border: 1px solid var(--brand-primary);
}

.leaderboard-strip__name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-strip__count {
    font-size: var(--text-sm);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.leaderboard-strip__status {
    font-size: var(--text-sm);
}

/* Mobile responsiveness for leaderboard arrows */
@media (max-width: 768px) {
    .leaderboard-arrow {
        width: 28px;
        height: 40px;
    }
    
    .leaderboard-arrow svg {
        width: 14px;
        height: 14px;
    }
    
    .leaderboard-strip__name {
        max-width: 100px;
    }
    
    .leaderboard-strip {
        gap: var(--space-2);
    }
}

/* Expanded view: full table */
.leaderboard-table {
    display: none;
}

.leaderboard--expanded .leaderboard-strip-wrapper {
    display: none;
}

.leaderboard--expanded .leaderboard-table {
    display: block;
}

.leaderboard-table__wrapper {
    overflow-x: auto;
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    text-align: left;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.leaderboard-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.leaderboard-table tr:hover {
    background: var(--bg-elevated);
}

.leaderboard-table tr:last-child td {
    border-bottom: none;
}

.leaderboard-table__rank {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    width: 40px;
}

.leaderboard-table__group {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.leaderboard-table__group-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.leaderboard-table__sparkline {
    width: 100px;
    height: 24px;
}

.leaderboard-table__sparkline svg {
    display: block;
}

.leaderboard-table__count {
    font-size: var(--text-base);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    text-align: right;
}

.leaderboard-table__trend {
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-mono);
    text-align: right;
    min-width: 50px;
}

.leaderboard-table__trend--positive {
    color: var(--status-active);
}

.leaderboard-table__trend--negative {
    color: var(--status-warning);
}

.leaderboard-table__trend--neutral {
    color: var(--text-muted);
}

/* ===== Heatmap View (History Mode) ===== */
.heatmap-container {
    width: 100%;
    height: 100%;
    padding: var(--space-4);
    overflow: hidden; /* No scrollbar - we use custom pan */
    position: relative;
}

/* Viewport wrapper for pan/zoom */
.heatmap-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    /* Allow vertical page scroll, we handle horizontal pan */
    touch-action: pan-y;
}

.heatmap-viewport[data-can-pan="false"] {
    cursor: default;
}

.heatmap-viewport--dragging {
    cursor: grabbing;
}

.heatmap-viewport--dragging .heatmap-cell {
    pointer-events: none;
}

/* Edge shadow indicators */
.heatmap-edge-shadow {
    position: absolute;
    top: 0;
    bottom: 40px; /* Leave room for time axis */
    width: 40px;
    pointer-events: none;
    z-index: 15;
    transition: opacity 0.2s ease;
}

.heatmap-edge-shadow--left {
    background: linear-gradient(to right, 
        var(--bg-surface) 0%, 
        rgba(var(--bg-surface-rgb, 17, 17, 17), 0.6) 40%,
        transparent 100%);
}

.heatmap-edge-shadow--right {
    background: linear-gradient(to left, 
        var(--bg-surface) 0%, 
        rgba(var(--bg-surface-rgb, 17, 17, 17), 0.6) 40%,
        transparent 100%);
}

/* First-time hint overlay */
.heatmap-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.heatmap-hint--visible {
    opacity: 1;
}

/* Zoom level indicator */
.heatmap-zoom-indicator {
    position: absolute;
    bottom: var(--space-3);
    right: var(--space-3);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 20;
    border: 1px solid var(--border-subtle);
}

.heatmap-zoom-indicator--visible {
    opacity: 1;
}

.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.heatmap-row {
    display: flex;
    align-items: center;
}

.heatmap-row__label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-right: var(--space-2);
    min-width: 0; /* Allow text truncation */
}

.heatmap-row__name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.heatmap-row__status {
    font-size: var(--text-xs);
    flex-shrink: 0;
}

/* Cells viewport - clips the scrollable area */
.heatmap-row__cells-viewport {
    overflow: hidden;
    flex-shrink: 0;
}

/* Cells track - the actual scrollable content */
.heatmap-row__cells-track {
    display: flex;
    gap: 1px;
    will-change: transform;
}

.heatmap-cell {
    flex: 0 0 auto;
    min-width: 8px;
    height: 32px;
    border-radius: 2px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scaleY(1.1);
    box-shadow: 0 0 0 1px var(--text-primary);
    z-index: 1;
}

.heatmap-row__current {
    flex-shrink: 0;
    text-align: right;
    font-size: var(--text-sm);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    padding-left: var(--space-2);
}

/* Time axis */
.heatmap-time-axis {
    display: flex;
    align-items: center;
    margin-top: var(--space-2);
}

.heatmap-time-axis__spacer {
    flex-shrink: 0;
}

/* Time axis labels viewport */
.heatmap-time-axis__labels-viewport {
    overflow: hidden;
    flex-shrink: 0;
}

/* Time axis labels track */
.heatmap-time-axis__labels-track {
    display: flex;
    justify-content: space-between;
    will-change: transform;
}

.heatmap-time-axis__labels {
    display: flex;
    flex: 1;
    justify-content: space-between;
}

.heatmap-time-axis__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* "More groups" indicator */
.heatmap-more {
    text-align: center;
    padding: var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* Now line indicator */
.heatmap-now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--status-hot);
    z-index: 10;
}

.heatmap-now-line::after {
    content: 'NOW';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--status-hot);
    white-space: nowrap;
}

/* Heatmap tooltip */
.heatmap-tooltip {
    position: absolute;
    z-index: var(--z-tooltip);
    background: var(--bg-elevated);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    font-size: var(--text-sm);
}

.heatmap-tooltip__value {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.heatmap-tooltip__time {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

/* ===== Heatmap Mobile Styles ===== */
@media (max-width: 600px) {
    .heatmap-container {
        padding: var(--space-2);
    }
    
    .heatmap-row__label {
        gap: var(--space-1);
        padding-right: var(--space-1);
    }
    
    .heatmap-row__name {
        font-size: var(--text-xs);
        max-width: 70px;
    }
    
    .heatmap-row__status {
        display: none; /* Hide status emoji on mobile to save space */
    }
    
    .heatmap-cell {
        height: 28px;
        border-radius: 1px;
    }
    
    .heatmap-row__current {
        font-size: var(--text-xs);
        padding-left: var(--space-1);
    }
    
    .heatmap-time-axis {
        margin-top: var(--space-1);
    }
    
    .heatmap-time-axis__label {
        font-size: 10px;
    }
    
    .heatmap-now-line::after {
        font-size: 9px;
        top: -16px;
    }
    
    .heatmap-edge-shadow {
        width: 25px;
    }
    
    .heatmap-hint {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-3);
    }
    
    .heatmap-more {
        font-size: var(--text-xs);
        padding: var(--space-1);
    }
    
    .group-logo--sm {
        width: 20px;
        height: 20px;
    }
}

/* ===== Data Status Bar ===== */
.data-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--text-xs);
    color: var(--text-muted);
    flex-shrink: 0;  /* Never shrink */
    margin-top: auto;  /* Push to bottom if space available */
    position: relative;  /* Ensure proper stacking */
    z-index: 10;
    background: var(--bg-primary);  /* Solid background to prevent overlap */
}

.data-status-bar__left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.data-status-bar__right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.data-status-bar__refresh-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.data-status-bar__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-active);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.data-status-bar__dot--stale {
    background: var(--status-warning);
    animation: none;
}

.data-status-bar__dot--error {
    background: var(--error);
    animation: none;
}

/* ===== History Mode Dropdown ===== */
.time-range-dropdown {
    position: relative;
}

/* Split button group for Heat Map */
.mode-toggle__btn-group {
    display: flex;
    align-items: stretch;
}

.mode-toggle__btn-group .mode-toggle__btn--main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding-right: var(--space-3);
}

.mode-toggle__btn-group .mode-toggle__btn--arrow {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: var(--space-2) var(--space-2);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    min-width: auto;
}

.mode-toggle__btn-group .mode-toggle__btn--arrow svg {
    display: block;
}

/* When history mode is active, style both parts of the split button */
.mode-toggle__btn-group .mode-toggle__btn--active {
    background: linear-gradient(135deg, #8B5CF6, #6366F1);
    color: white;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.mode-toggle__btn-group .mode-toggle__btn--active:hover {
    background: linear-gradient(135deg, #9D6FFF, #7577F3);
}

/* Mobile responsive styles for split button */
@media (max-width: 480px) {
    .mode-toggle__btn-group .mode-toggle__btn--main {
        padding: var(--space-2) var(--space-2);
        font-size: var(--text-xs);
    }
    
    .mode-toggle__btn-group .mode-toggle__btn--arrow {
        padding: var(--space-2) var(--space-1);
    }
    
    .mode-toggle__btn-group .mode-toggle__btn--arrow svg {
        width: 10px;
        height: 10px;
    }
}

.time-range-dropdown__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    min-width: 150px;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
}

.time-range-dropdown--open .time-range-dropdown__menu {
    display: block;
}

.time-range-dropdown__item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.time-range-dropdown__item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.time-range-dropdown__item--selected {
    background: var(--brand-primary);
    color: white;
}

/* ===== Scene Empty State ===== */
.scene-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-8);
}

.scene-empty__bubbles {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    opacity: 0.3;
}

.scene-empty__bubble {
    width: 20px;
    height: 20px;
    background: var(--bg-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: 50%;
}

.scene-empty__bubble:nth-child(2) {
    width: 30px;
    height: 30px;
}

.scene-empty__bubble:nth-child(4) {
    width: 25px;
    height: 25px;
}

.scene-empty__title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.scene-empty__description {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.scene-empty__highlight {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ===== Transitions for Mode Switching ===== */
.visualization-enter {
    opacity: 0;
    transform: scale(0.98);
}

.visualization-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 300ms ease, transform 300ms ease;
}

.visualization-exit {
    opacity: 1;
    transform: scale(1);
}

.visualization-exit-active {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 300ms ease, transform 300ms ease;
}

/* ===== Sparkline Styles ===== */
.sparkline {
    display: inline-block;
}

.sparkline__line {
    fill: none;
    stroke: var(--brand-primary);
    stroke-width: 1.5;
}

.sparkline__area {
    fill: url(#sparkline-gradient);
    opacity: 0.2;
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    .scene-bubble--hot .scene-bubble__circle,
    .status-dot--pulse,
    .data-status-bar__dot {
        animation: none;
    }
    
    * {
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.mode-toggle__btn:focus-visible,
.leaderboard-strip__item:focus-visible,
.feed-item:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* =====================================================
   Rewind Playback Scrubber
   ===================================================== */

/* Playback Banner - shown when viewing historical data */
.playback-banner {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    flex-shrink: 0;  /* Don't shrink when space is tight */
    animation: banner-fade-in 0.3s ease;
}

@keyframes banner-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.playback-banner__time {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.playback-banner__time::before {
    content: '⏱️';
}

.playback-banner__live-btn {
    background: var(--brand-primary);
    color: white;
    border: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-xs);
    font-weight: 600;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.playback-banner__live-btn:hover {
    background: var(--brand-primary-hover, #7c3aed);
    transform: translateX(2px);
}

/* Rewind Scrubber Container */
.scrubber-container {
    grid-area: scrubber;
    position: relative;
    z-index: 20;
}

.rewind-scrubber {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: relative;
    z-index: 20;
}

/* Play/Pause Button */
.scrubber-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.scrubber-play-btn:hover:not(:disabled) {
    background: var(--brand-primary-hover, #7c3aed);
    transform: scale(1.05);
}

.scrubber-play-btn:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: not-allowed;
}

.scrubber-play-btn__icon {
    line-height: 1;
}

/* Speed Buttons */
.scrubber-speeds {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.speed-btn {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.speed-btn:hover:not(:disabled) {
    background: var(--border-subtle);
    color: var(--text-primary);
}

.speed-btn--active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

.speed-btn--active:hover:not(:disabled) {
    background: var(--brand-primary-hover, #7c3aed);
}

.speed-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Track Container */
.scrubber-track-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

/* Track */
.scrubber-track {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    /* Allow horizontal panning for scrubbing, vertical scroll still works */
    touch-action: pan-x;
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
}

.scrubber-track__fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--brand-primary);
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s linear;
}

/* Scrubber Handle */
.scrubber-handle {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid var(--brand-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    z-index: 2;
    /* Prevent default touch behaviors like scrolling */
    touch-action: none;
}

.scrubber-handle:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.scrubber-handle:active,
.scrubber-handle--dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Scrubber Tooltip */
.scrubber-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.scrubber-handle:hover .scrubber-tooltip,
.scrubber-handle--dragging .scrubber-tooltip {
    opacity: 1;
}

/* Time Labels */
.scrubber-time-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
    min-width: 50px;
    flex-shrink: 0;
}

.scrubber-time-label--now {
    color: var(--status-active);
    font-weight: 600;
}

/* Collapsed Activity Feed during playback */
.activity-feed--collapsed {
    display: none !important;
}

/* Activity Feed Expand Button (floating) */
.feed-expand-btn {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    display: none;  /* Hidden by default on desktop */
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    box-shadow: 
        var(--shadow-lg),
        0 0 15px 3px rgba(139, 92, 246, 0.25),
        0 0 30px 5px rgba(139, 92, 246, 0.15);
    z-index: 1000;  /* Higher z-index to ensure it's above other elements */
    transition: all var(--transition-fast);
    /* Ensure touch events work */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(139, 92, 246, 0.3);
    /* Subtle pulse animation to draw attention */
    animation: feed-btn-glow 2.5s ease-in-out infinite;
}

@keyframes feed-btn-glow {
    0%, 100% {
        box-shadow: 
            var(--shadow-lg),
            0 0 15px 3px rgba(139, 92, 246, 0.25),
            0 0 30px 5px rgba(139, 92, 246, 0.15);
    }
    50% {
        box-shadow: 
            var(--shadow-lg),
            0 0 20px 5px rgba(139, 92, 246, 0.35),
            0 0 40px 8px rgba(139, 92, 246, 0.2);
    }
}

.feed-expand-btn:hover,
.feed-expand-btn:active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 
        var(--shadow-xl),
        0 0 25px 5px rgba(139, 92, 246, 0.4),
        0 0 50px 10px rgba(139, 92, 246, 0.25);
    animation: none;
}

/* Show button when feed is collapsed (class added by JS) */
.feed-expand-btn--visible {
    display: flex !important;  /* !important to override inline styles when visible */
}

/* On mobile/tablet, the button visibility is controlled entirely by --visible class */
@media (max-width: 1199px) {
    .feed-expand-btn {
        /* Mobile: only show when --visible class is present, not always */
        display: none;
    }
    
    /* Override: show when collapsed */
    .feed-expand-btn--visible {
        display: flex !important;
    }
}

/* Scene visual indicator for playback mode */
.live-activity-scene--playback {
    border-color: rgba(139, 92, 246, 0.5);
}

.live-activity-scene--playback::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-lg);
    pointer-events: none;
    z-index: 5;
    animation: playback-border-pulse 2s ease-in-out infinite;
}

@keyframes playback-border-pulse {
    0%, 100% {
        border-color: rgba(139, 92, 246, 0.2);
    }
    50% {
        border-color: rgba(139, 92, 246, 0.5);
    }
}

/* ===== Full Screen Toggle Button ===== */
.fullscreen-btn {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(30, 30, 40, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 25;
    transition: all var(--transition-fast);
    /* Glow effect */
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 12px 2px rgba(139, 92, 246, 0.2),
        0 0 24px 4px rgba(139, 92, 246, 0.1);
    animation: fullscreen-btn-glow 3s ease-in-out infinite;
}

@keyframes fullscreen-btn-glow {
    0%, 100% {
        box-shadow: 
            0 2px 8px rgba(0, 0, 0, 0.3),
            0 0 12px 2px rgba(139, 92, 246, 0.2),
            0 0 24px 4px rgba(139, 92, 246, 0.1);
        border-color: rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 
            0 2px 8px rgba(0, 0, 0, 0.3),
            0 0 18px 4px rgba(139, 92, 246, 0.3),
            0 0 35px 6px rgba(139, 92, 246, 0.15);
        border-color: rgba(139, 92, 246, 0.6);
    }
}

.fullscreen-btn:hover {
    background: rgba(40, 40, 55, 0.95);
    color: var(--text-primary);
    border-color: var(--brand-primary);
    transform: scale(1.05);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 0 20px 4px rgba(139, 92, 246, 0.4),
        0 0 40px 8px rgba(139, 92, 246, 0.2);
    animation: none;
}

.fullscreen-btn:active {
    transform: scale(0.98);
}

/* Icon visibility states */
.fullscreen-btn__icon--collapse {
    display: none;
}

.fullscreen-btn--active .fullscreen-btn__icon--expand {
    display: none;
}

.fullscreen-btn--active .fullscreen-btn__icon--collapse {
    display: block;
}

/* Active state styling */
.fullscreen-btn--active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* ===== Full Screen Mode Styles ===== */
.live-activity-page--fullscreen .live-activity-feed {
    display: none !important;
}

.live-activity-page--fullscreen .live-activity-leaderboard {
    display: none !important;
}

.live-activity-page--fullscreen .feed-expand-btn {
    display: none !important;
}

/* In fullscreen mode, scene takes full width */
.live-activity-page--fullscreen .live-activity-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;  /* Scene flexes, scrubber is fixed height */
    grid-template-areas:
        "scene"
        "scrubber";
    overflow: hidden;  /* Ensure content is contained */
    flex: 1 1 auto;
    min-height: 0;  /* Critical for proper grid behavior */
}

/* Scene fills available space in fullscreen, but doesn't overflow */
.live-activity-page--fullscreen .live-activity-scene {
    min-height: 0;  /* Let grid control the height */
    height: 100%;  /* Fill the grid cell */
    max-height: none;
}

/* Ensure scrubber is visible and on top in fullscreen */
.live-activity-page--fullscreen .scrubber-container {
    position: relative;
    z-index: 30;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .fullscreen-btn {
        width: 40px;
        height: 40px;
        top: var(--space-2);
        right: var(--space-2);
    }
    
    .fullscreen-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Mobile responsiveness for scrubber */
@media (max-width: 768px) {
    .rewind-scrubber {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: var(--space-2) var(--space-3);
        padding: var(--space-2) var(--space-3);
    }
    
    /* Slider track takes full width at top spanning both columns */
    .scrubber-track-container {
        grid-column: 1 / -1;
        grid-row: 1;
        width: 100%;
        /* Add vertical padding for easier touch targeting */
        padding: var(--space-2) 0;
    }
    
    /* Play button on second row, left */
    .scrubber-play-btn {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
    }
    
    /* Speed buttons on second row, right */
    .scrubber-speeds {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
    }
    
    .scrubber-time-label {
        min-width: 40px;
        font-size: 10px;
    }
    
    /* Larger touch targets for mobile */
    .scrubber-track {
        height: 16px;
        border-radius: 8px;
        /* Increase touch target area significantly via padding */
        padding: 20px 0;
        margin: -20px 0;
        background-clip: content-box;
        /* Use pan-x to allow horizontal scrubbing while not blocking vertical scroll */
        touch-action: pan-x;
        cursor: pointer;
        /* Ensure track is interactive */
        pointer-events: auto;
    }
    
    /* The fill bar should not block touch events */
    .scrubber-track__fill {
        pointer-events: none;
    }
    
    .scrubber-handle {
        width: 32px;
        height: 32px;
        /* Handle can use none since we manage its touch explicitly */
        touch-action: none;
        pointer-events: auto;
    }
    
    /* Ensure tooltip shows on touch */
    .scrubber-handle:active .scrubber-tooltip,
    .scrubber-handle--dragging .scrubber-tooltip {
        opacity: 1;
    }
    
    .playback-banner {
        flex-direction: column;
        gap: var(--space-2);
        text-align: center;
    }
    
    .playback-banner__time {
        font-size: var(--text-xs);
    }
    
    /* Feed expand button - larger on mobile for easy tapping */
    .feed-expand-btn {
        bottom: var(--space-3);
        right: var(--space-3);
        padding: var(--space-3) var(--space-4);
        min-width: 48px;
        min-height: 48px;
        border-radius: var(--radius-lg);
    }
    
    .feed-expand-btn span {
        display: none;  /* Hide text on mobile, just show icon */
    }
    
    .feed-expand-btn svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .scrubber-speeds {
        display: flex;
        gap: 2px;
    }
    
    .speed-btn {
        padding: var(--space-1);
        font-size: 9px;
        min-width: 32px;
        /* Ensure touch targets are adequate */
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .scrubber-play-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        /* Ensure touch target is adequate */
        touch-action: manipulation;
    }
    
    .feed-expand-btn {
        bottom: var(--space-2);
        right: var(--space-2);
        min-width: 52px;
        min-height: 52px;
    }
    
    .feed-expand-btn svg {
        width: 28px;
        height: 28px;
    }
}
