* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #9147ff;
    --bg: #1a1b1e;
    --bg-surface: #242529;
    --bg-elevated: #2c2d31;
    --text: #e4e4e7;
    --text-secondary: #b0b0b8;
    --border: #3a3b40;
    --live: #eb0400;
    --muted: #8b8b96;
    --hover: rgba(255, 255, 255, 0.06);
    --header-h: 36px;
    --chat-w: 340px;
}

/* Light theme */
[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-surface: #ffffff;
    --bg-elevated: #f0f0f2;
    --text: #1a1a1a;
    --text-secondary: #4a4a52;
    --border: #d4d4d8;
    --muted: #71717a;
    --hover: rgba(0, 0, 0, 0.04);
}

html, body {
    height: 100%;
    /* IMPORTANT: No overflow:hidden/clip here — Twitch's embed checks
       IntersectionObserver from inside its iframe, and ANY non-visible
       overflow on an ancestor creates a clip boundary that makes bottom-row
       iframes appear 'not visible', blocking autoplay.  The flex layout
       with height:100vh + min-height:0 on children already prevents
       content from overflowing. */
    overscroll-behavior: none;
    touch-action: manipulation;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ─── Container ───────────────────────────────────────────────── */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ─── Header ── ultra-compact ─────────────────────────────────── */
header {
    height: var(--header-h);
    min-height: var(--header-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
    flex-shrink: 0;
    z-index: 200;
    transition: margin-top 0.2s ease;
}

header.collapsed {
    margin-top: calc(-1 * var(--header-h) - 1px);
}

header h1 {
    font-size: 15px;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: 1.5px;
}

.live-count {
    font-size: 11px;
    color: var(--muted);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 1;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    max-height: var(--header-h);
}

.header-group {
    display: flex;
    gap: 2px;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 2px;
}

.hdr-btn {
    background: none;
    border: none;
    color: var(--muted);
    border-radius: 6px;
    width: 30px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
}
.hdr-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}
.hdr-btn.active {
    color: var(--primary);
    background: rgba(145, 71, 255, 0.15);
}
.hdr-btn:active {
    transform: scale(0.92);
}

/* Chat toggle special styling */
.chat-toggle-btn.active {
    color: #fff;
    background: var(--primary);
}
.chat-toggle-btn.active:hover {
    background: #7c3aed;
}

/* Keep legacy .btn-icon for any remaining uses */
.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--primary); }
.btn-icon.active { color: var(--primary); border-color: var(--primary); }

/* ─── Main Layout ─────────────────────────────────────────────── */
/* IMPORTANT: No overflow:hidden/clip here — this is an ancestor of
   Twitch embeds, and any non-visible overflow creates an IO clip boundary
   that blocks autoplay for bottom-row iframes.  The flex + min-height:0
   layout prevents content overflow without needing to clip. */
.main-layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ─── Streams Area ────────────────────────────────────────────── */
/* IMPORTANT: No overflow:hidden — Twitch rejects autoplay if any
   ancestor clips content. The flex + min-height:0 layout prevents
   overflow without needing to clip. */
.streams-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.no-streams-msg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--muted);
}

/* ─── Offline Section ─────────────────────────────────────────── */
.offline-section {
    padding: 10px 20px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
}

.offline-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.offline-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.offline-grid::-webkit-scrollbar { display: none; }

.offline-card {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 0;
    flex: 1 1 0;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
    gap: 8px;
}
.offline-card:hover {
    border-color: rgba(145, 71, 255, 0.4);
    background: rgba(145, 71, 255, 0.04);
}

/* Live streamer card variant in VODs view */
.offline-card.offline-card-live {
    border-color: rgba(235, 4, 0, 0.3);
    background: rgba(235, 4, 0, 0.04);
}
.offline-card.offline-card-live:hover {
    border-color: rgba(235, 4, 0, 0.5);
    background: rgba(235, 4, 0, 0.08);
}

.offline-card-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.offline-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.offline-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.offline-info {
    min-width: 0;
    overflow: hidden;
}

.offline-name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-game {
    font-size: 10px;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-title {
    display: none;
}

.offline-date {
    font-size: 9px;
    color: var(--muted);
    opacity: 0.7;
    white-space: nowrap;
}

.offline-tags {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: 1px;
}

.offline-tag {
    font-size: 8px;
    padding: 1px 5px;
    border-radius: 8px;
    background: rgba(145, 71, 255, 0.12);
    color: var(--primary);
    white-space: nowrap;
    line-height: 1.4;
}

.offline-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.offline-action-btn {
    padding: 3px 8px;
    font-size: 9px;
    font-weight: 700;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    white-space: nowrap;
}
.offline-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.offline-action-btn.vod-btn {
    background: rgba(145, 71, 255, 0.1);
    border-color: rgba(145, 71, 255, 0.3);
    color: var(--primary);
}
.offline-action-btn.vod-btn:hover {
    background: rgba(145, 71, 255, 0.2);
    border-color: var(--primary);
}

/* ─── VOD Player ──────────────────────────────────────────────── */
.vod-player {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 300px;
}

.vod-player.hidden { display: none !important; }

.vod-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    gap: 12px;
}

.vod-player-header span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vod-close-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.vod-close-btn:hover {
    color: var(--text);
    border-color: var(--text);
}

.vod-embed {
    flex: 1;
    position: relative;
    background: #000;
}
.vod-embed iframe,
.vod-embed > div {
    width: 100% !important;
    height: 100% !important;
    border: none;
    position: absolute;
    inset: 0;
}

/* ─── Co-Streams Section ──────────────────────────────────────── */
.costreams-section {
    padding: 16px 20px 24px;
    border-top: 1px solid var(--border);
}

.costreams-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.costreams-header > span:first-child {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.3px;
}

.costreams-subtitle {
    font-size: 10px;
    color: var(--muted);
    font-weight: 400;
}

.costreams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: 12px;
}

/* ─── Co-Stream Card ──────────────────────────────────────────── */
.costream-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.costream-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(145, 71, 255, 0.12);
}

/* Thumbnail row: stacked VOD thumbnails */
.costream-thumbs {
    display: flex;
    height: 140px;
    overflow: hidden;
    position: relative;
}

.costream-thumb-slot {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.costream-thumb-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: brightness(0.85);
    transition: filter 0.2s;
}
.costream-card:hover .costream-thumb-slot img {
    filter: brightness(1);
}

.costream-thumb-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 8px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0px 6px rgba(0,0,0,0.4);
}

.costream-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.2s;
}
.costream-card:hover .costream-play-overlay {
    opacity: 1;
}

.costream-play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    transition: transform 0.15s;
}
.costream-card:hover .costream-play-btn {
    transform: scale(1.1);
}
.costream-play-btn svg {
    width: 20px;
    height: 20px;
    color: #fff;
    margin-left: 2px;
}

/* Card body */
.costream-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.costream-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.costream-meta-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.costream-date {
    font-size: 11px;
    color: var(--muted);
}

.costream-views {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.costream-duration {
    font-size: 10px;
    font-weight: 700;
    color: rgba(145, 71, 255, 0.85);
    background: rgba(145, 71, 255, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(145, 71, 255, 0.12);
}

/* Avatars row */
.costream-avatars {
    display: flex;
    align-items: center;
    gap: 8px;
}

.costream-avatar-group {
    display: flex;
    align-items: center;
}

.costream-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
    object-fit: cover;
}
.costream-avatar + .costream-avatar {
    margin-left: -8px;
}

.costream-names {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Game tag */
.costream-game {
    font-size: 10px;
    color: var(--primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Watch together CTA */
.costream-cta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0;
    transition: opacity 0.2s;
}
.costream-card:hover .costream-cta {
    opacity: 1;
}
.costream-cta svg {
    width: 12px;
    height: 12px;
}

/* No co-streams placeholder */
.costreams-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}
.costreams-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Loading skeleton */
.costreams-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--muted);
    font-size: 12px;
}
.costreams-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Solo card uses costream-card structure — extra styles ──── */
.costream-card-solo .costream-thumbs {
    /* Single full-width thumbnail — same height as co-stream cards */
}

/* Stream title line (shown on solo cards) */
.costream-title {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* When live streams exist in live-view, hide offline section entirely
   so the stream grid gets 100% of available vertical space. */
#live-view.has-live .offline-section {
    display: none;
}

@media (max-width: 768px) {
    .offline-section, .clips-section { padding: 8px 12px; }
    .offline-grid { flex-direction: column; flex-wrap: nowrap; }
    .offline-card { flex: none; width: 100%; padding: 5px 8px; }
    .offline-avatar { width: 28px; height: 28px; }
    .offline-name { font-size: 11px; }
    .clip-card { width: 150px; min-width: 150px; }
    .clip-info { padding: 6px; }
    .clips-group-header { gap: 6px; }
    .clips-group-avatar { width: 20px; height: 20px; }
    .clips-group-name { font-size: 11px; }
}

/* ─── Stream Grid ─── fills 100% of streams-area ──────────────── */
.live-streams {
    flex: 1;
    display: grid;
    gap: 1px;
    min-height: 0;
}

/* Grid layouts — each stream fills its cell completely */
.live-streams.grid-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
.live-streams.grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}
.live-streams.grid-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.live-streams.grid-3 > .stream:first-child {
    grid-column: 1 / -1;
}
.live-streams.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.live-streams.grid-5 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.live-streams.grid-5 > .stream:first-child {
    grid-column: 1 / 3;
}

/* ─── Enlarged Layout (click-to-focus) ────────────────────────── */
.live-streams.grid-enlarged {
    grid-template-columns: 3fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.live-streams.grid-enlarged > .stream.enlarged {
    grid-row: 1 / -1;
    grid-column: 1;
    order: -1; /* always first */
}

.live-streams.grid-enlarged > .stream:not(.enlarged) {
    grid-column: 2;
}

/* Subtle border on enlarged to indicate it's focused */
.stream.enlarged {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* If only 1 side stream, don't force 2 rows */
.live-streams.grid-enlarged > .stream:not(.enlarged):only-of-type {
    grid-row: 1 / -1;
}

/* ─── Stream Cell ─────────────────────────────────────────────── */
/* IMPORTANT: No overflow:hidden — Twitch rejects embeds in clipped parents */
.stream {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #000;
    min-width: 0;
    min-height: 0;
}

/* ─── Stream Info Bar — labels & actions above the grid ───────── */
.stream-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 1;
    overflow: hidden;
    max-height: 48px;
}
.stream-info-bar.hidden { display: none !important; }

/* ─── Stream Toolbar — now lives in the info bar, always visible ─ */
.stream-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.85);
    flex: 1 1 auto;
    min-height: 22px;
    gap: 6px;
}
.stream-toolbar.hidden { display: none !important; }

.stream-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

/* IMPORTANT: Do NOT use overflow:hidden on .stream-embed.
   Twitch's visibility check rejects embeds in clipped containers. */
.stream-embed {
    flex: 1;
    min-height: 0;
    width: 100%;
    visibility: visible;
}

/* Twitch Embed wrapper div — fill the embed area via flow layout (never use position:absolute,
   as Twitch's visibility check rejects embeds whose parent chain includes absolute/hidden elements) */
.stream-embed > div {
    width: 100%;
    height: 100%;
}

.stream-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    visibility: visible;
}

/* Stream label — inline in toolbar */
.stream-label {
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.live-badge {
    background: var(--live);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 2px;
    letter-spacing: 0.5px;
}

.label-game {
    font-weight: 400;
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.85;
}

/* ─── Desktop wide ────────────────────────────────────────────── */
@media (min-width: 1600px) {
}

/* ─── Tablet ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
}

/* ─── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --header-h: 34px;
    }

    .main-layout {
        flex-direction: column;
    }

    /* On mobile, streams use single-stream layout by default (handled by JS) */
    /* Fallback: if not mobile-single, stack them */
    .live-streams.grid-2,
    .live-streams.grid-3,
    .live-streams.grid-4,
    .live-streams.grid-5 {
        grid-template-columns: 1fr;
    }
    .live-streams.grid-2 { grid-template-rows: 1fr 1fr; }
    .live-streams.grid-3 { grid-template-rows: 1fr 1fr 1fr; }
    .live-streams.grid-3 > .stream:first-child { grid-column: auto; }
    .live-streams.grid-4 { grid-template-rows: 1fr 1fr 1fr 1fr; }
    .live-streams.grid-5 { grid-template-columns: 1fr; grid-template-rows: repeat(5, 1fr); }
    .live-streams.grid-5 > .stream:first-child { grid-column: auto; }

    /* Enlarged on mobile = top stream big, rest scroll below */
    .live-streams.grid-enlarged {
        grid-template-columns: 1fr;
        grid-template-rows: 2fr 1fr 1fr;
    }
    .live-streams.grid-enlarged > .stream.enlarged {
        grid-row: auto;
        grid-column: auto;
    }
    .live-streams.grid-enlarged > .stream:not(.enlarged) {
        grid-column: auto;
    }

    /* Hide offline section on mobile when live (it's in VODs view) */
    #live-view.has-live .offline-section {
        display: none;
    }

    header h1 { font-size: 13px; }
    .live-count { font-size: 10px; }
    .stream-label { font-size: 9px; }
    .header-actions { gap: 4px; }
    .hdr-btn { width: 34px; height: 32px; min-width: 34px; min-height: 32px; border-radius: 8px; }
    .header-group { padding: 2px; border-radius: 10px; }
}

/* ─── Small phones ────────────────────────────────────────────── */
@media (max-width: 480px) {
    .live-streams.grid-2 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

@media (max-width: 360px) {
    header h1 { font-size: 11px; letter-spacing: 0; }
    .live-count { display: none; }
    .hdr-btn { width: 30px; height: 28px; min-width: 30px; min-height: 28px; }
    .hdr-btn svg { width: 13px; height: 13px; }
}

/* ─── Landscape phones ────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    :root { --header-h: 24px; }

    /* Hide header bars to maximize stream view */
    header { display: none !important; }
    .view-tabs { display: none !important; }
    .audio-bar { display: none !important; }
    .stream-info-bar { display: none !important; }

    .main-layout { flex-direction: row; }

    .live-streams.grid-1 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }
    .live-streams.grid-2 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
    }
    .live-streams.grid-3 {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr;
    }
    .live-streams.grid-3 > .stream:first-child { grid-column: auto; }

    /* Stacked mobile layout should fill screen in landscape */
    .live-streams.mobile-stacked {
        padding-bottom: 0;
    }
    .live-streams.mobile-stacked .stream {
        aspect-ratio: unset;
        flex: 1;
    }
}


/* ─── Floating Restore Button ─────────────────────────────────── */
.restore-btn {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 5px 14px 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    transition: opacity 0.2s, transform 0.2s;
    opacity: 0.6;
}
.restore-btn:hover {
    opacity: 1;
    border-color: var(--primary);
    color: var(--primary);
}
.restore-btn.hidden { display: none !important; }

@media (max-width: 768px) {
    .restore-btn {
        padding: 8px 16px 8px 12px;
        font-size: 12px;
        border-radius: 24px;
    }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── Audio Focus Button (toolbar) ────────────────────────────── */
.audio-focus-btn {
    position: relative;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.audio-focus-btn svg { width: 12px; height: 12px; }
.audio-focus-btn:hover { color: #fff; border-color: #fff; }
.audio-focus-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(145, 71, 255, 0.3);
}

/* Muted slash on non-focused streams */
.audio-focus-btn:not(.active)::after {
    content: '';
    position: absolute;
    width: 1.5px;
    height: 14px;
    background: rgba(255,255,255,0.5);
    transform: rotate(45deg);
    border-radius: 1px;
}
.audio-focus-btn:not(.active):hover::after {
    background: #fff;
}

/* ─── Minimize Button (toolbar) ───────────────────────────────── */
.minimize-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.minimize-btn svg { width: 12px; height: 12px; }
.minimize-btn:hover {
    color: #fff;
    border-color: #fff;
}

/* ─── Ended Stream Banner (compact inline notification) ───────── */
.ended-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    animation: streamSlideIn 0.3s ease;
}
.ended-banner-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}
.ended-banner-name {
    font-weight: 700;
    color: var(--text);
}
.ended-banner-text {
    color: var(--muted);
    font-style: italic;
}
.ended-banner-link {
    margin-left: auto;
    color: var(--primary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
}
.ended-banner-link:hover {
    text-decoration: underline;
}
.ended-banner-dismiss {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.ended-banner-dismiss:hover {
    color: var(--text);
}

/* ─── Minimized Stream ────────────────────────────────────────── */
.stream.minimized {
    flex: none !important;
    min-height: 0 !important;
    height: 80px;
    max-height: 80px;
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    order: 100;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}
.stream.minimized .stream-embed {
    width: 142px; /* ~16:9 at 80px */
    height: 100%;
    overflow: hidden;
    border-right: 1px solid var(--border);
}
/* Minimized toolbar in info bar — dim + highlight restore button */
.stream-toolbar.minimized {
    opacity: 0.5;
}
.stream-toolbar.minimized .minimize-btn {
    color: var(--primary);
    border-color: var(--primary);
    opacity: 1;
}

/* ─── Enlarged Layout — skip minimized from grid rows ─────────── */
.live-streams.grid-enlarged > .stream.minimized {
    grid-column: 1 / -1;
}

/* ─── Clip Button (toolbar) ───────────────────────────────────── */
.clip-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.clip-btn:hover {
    color: #22c55e;
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}
.clip-btn:active {
    transform: scale(0.92);
}

/* ─── Enlarge Button (toolbar) ────────────────────────────────── */
.enlarge-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.enlarge-btn svg { width: 12px; height: 12px; }
.enlarge-btn:hover {
    color: #fff;
    border-color: #fff;
}
.stream-toolbar.enlarged .enlarge-btn {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(145, 71, 255, 0.3);
}

/* ─── Delay Button (toolbar) ──────────────────────────────────────── */
.delay-btn {
    width: 26px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    position: relative;
}
.delay-btn:hover {
    color: #00cec9;
    border-color: #00cec9;
}
.delay-btn.has-delay {
    color: #00cec9;
    border-color: #00cec9;
    background: rgba(0, 206, 201, 0.12);
    box-shadow: 0 0 6px rgba(0, 206, 201, 0.25);
}
.delay-btn.has-delay::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #00cec9;
}

/* ─── Delay Popup ─────────────────────────────────────────────────── */
.delay-popup {
    position: fixed;
    z-index: 9000;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.delay-popup.hidden {
    display: none !important;
}

.delay-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.delay-popup-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.delay-popup-value {
    font-size: 14px;
    font-weight: 800;
    color: #00cec9;
    font-variant-numeric: tabular-nums;
}

.delay-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    margin: 4px 0 10px;
    cursor: pointer;
}
.delay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00cec9;
    cursor: pointer;
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 4px rgba(0, 206, 201, 0.4);
}
.delay-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00cec9;
    cursor: pointer;
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 4px rgba(0, 206, 201, 0.4);
}

.delay-popup-actions {
    display: flex;
    gap: 6px;
}
.delay-popup-actions button {
    flex: 1;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}
.delay-reset-btn {
    background: transparent;
    color: var(--text);
}
.delay-reset-btn:hover {
    border-color: var(--danger, #e74c3c);
    color: var(--danger, #e74c3c);
}
.delay-apply-btn {
    background: #00cec9;
    color: #000;
    border-color: #00cec9;
}
.delay-apply-btn:hover {
    background: #00b5b0;
    border-color: #00b5b0;
}

/* ─── Resync Button Animation ───────────────────────────────────── */
#resync-btn.resyncing svg {
    animation: resync-spin 0.6s linear infinite;
}
#resync-btn.resyncing {
    color: var(--primary);
}
@keyframes resync-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .stream-toolbar { padding: 2px 4px; min-height: 22px; }
    .enlarge-btn, .audio-focus-btn, .minimize-btn, .clip-btn, .delay-btn { width: 24px; height: 22px; }
}

/* ─── Stream Victory Button (in toolbar) ──────────────────────── */
.stream-victory-btn {
    flex-shrink: 0;
}
.stream-victory-btn .victory-btn {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.15);
    color: #aaa;
    padding: 1px 5px;
    font-size: 10px;
}
.stream-victory-btn .victory-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
}
.stream-victory-btn .victory-btn.has-victories {
    color: #f59e0b;
    border-color: #f59e0b;
}

/* ─── Play All Streams Banner ─────────────────────────────────── */
.play-all-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(145, 71, 255, 0.15), rgba(145, 71, 255, 0.05));
    border-bottom: 1px solid rgba(145, 71, 255, 0.2);
    flex-shrink: 0;
    z-index: 10;
    animation: playBannerSlide 0.3s ease;
}
@keyframes playBannerSlide {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.play-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(145, 71, 255, 0.3);
}
.play-all-btn:hover {
    background: #7c3aed;
    transform: scale(1.03);
}
.play-all-btn:active {
    transform: scale(0.97);
}
.play-all-btn svg {
    flex-shrink: 0;
}

.play-all-dismiss {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.play-all-dismiss:hover {
    color: var(--text);
}

@media (max-width: 768px) {
    .play-all-banner {
        padding: 5px 10px;
    }
    .play-all-btn {
        font-size: 11px;
        padding: 5px 14px;
    }
}

/* ─── Toast Notifications ─────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 40px;
    right: 12px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    max-width: 260px;
}

.toast.show {
    transform: translateX(0);
}

.toast-live {
    border-left: 3px solid var(--live);
}

.toast-offline {
    border-left: 3px solid var(--muted);
}

.toast-info {
    border-left: 3px solid var(--primary);
}

@media (max-width: 768px) {
    #toast-container { top: 32px; right: 6px; }
    .toast { font-size: 11px; padding: 6px 10px; }
}

/* ─── Help Overlay ────────────────────────────────────────────── */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.help-overlay.hidden { display: none !important; }

.help-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.help-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.help-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.help-close:hover { color: var(--text); }

.help-section {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 16px 0 8px;
}

.help-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-row kbd {
    display: inline-block;
    min-width: 36px;
    text-align: center;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    white-space: nowrap;
}

.help-row span {
    font-size: 12px;
    color: var(--text);
    opacity: 0.85;
}

.help-icon {
    min-width: 36px;
    text-align: center;
    font-size: 14px;
}

@media (max-width: 480px) {
    .help-panel { padding: 16px; }
    .help-header h2 { font-size: 14px; }
}

/* ─── Settings Overlay ────────────────────────────────────────── */
.settings-overlay,
.sessions-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.settings-panel,
.sessions-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.settings-header,
.sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.settings-header h2,
.sessions-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.settings-body,
.sessions-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}

.settings-desc {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

/* Toggle row */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 0;
    font-size: 12px;
    color: var(--text);
}

.toggle-row.compact {
    padding: 0;
}

.toggle-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Field rows */
.settings-group {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.field-row label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}

.field-row input[type="text"],
.field-row input[type="password"],
.field-row input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.field-row input:focus {
    border-color: var(--primary);
}

.field-row-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.field-row-inline .field-row {
    flex: 1;
}

/* Settings buttons */
.settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.settings-btn {
    padding: 7px 14px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.settings-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.settings-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.settings-btn.primary:hover {
    background: #7c3aed;
    border-color: #7c3aed;
}

.settings-btn.small {
    padding: 4px 10px;
    font-size: 10px;
}

.settings-btn.danger {
    color: var(--muted);
}

.settings-btn.danger:hover {
    border-color: var(--live);
    color: var(--live);
}

.settings-status {
    font-size: 11px;
    margin-top: 8px;
    min-height: 16px;
    color: var(--muted);
}

.settings-status.success { color: #22c55e; }
.settings-status.error { color: var(--live); }

.settings-hint {
    margin-top: 14px;
    padding: 10px;
    background: rgba(145, 71, 255, 0.06);
    border: 1px solid rgba(145, 71, 255, 0.15);
    border-radius: 6px;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
}

.settings-hint a {
    color: var(--primary);
    text-decoration: none;
}

.settings-hint a:hover {
    text-decoration: underline;
}

/* ─── Sessions Panel ──────────────────────────────────────────── */
.sessions-list-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 14px 0 8px;
}

.session-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color 0.15s;
}

.session-card:hover {
    border-color: rgba(145, 71, 255, 0.3);
}

.session-card.active-session {
    border-color: var(--live);
    background: rgba(235, 4, 0, 0.04);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.session-date {
    font-size: 11px;
    color: var(--muted);
}

.session-duration {
    font-size: 10px;
    color: var(--primary);
    font-weight: 600;
}

.session-live-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--live);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.session-streamers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.session-streamer {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
}

.session-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.session-dimmed {
    opacity: 0.45;
}

.session-game {
    font-weight: 400;
    color: var(--primary);
    font-size: 10px;
}

.no-vod {
    font-weight: 400;
    color: var(--muted);
    font-size: 9px;
    font-style: italic;
}

.session-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.session-note {
    font-size: 10px;
    color: var(--muted);
    font-style: italic;
}

.sessions-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 20px;
    line-height: 1.6;
}

/* Sync viewer styles are in sync-styles.css (loaded by sync.html) */

@media (max-width: 700px) {
    .settings-panel,
    .sessions-panel {
        width: 95%;
        max-height: 90vh;
    }

    .costreams-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .costreams-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .costream-thumbs {
        height: 80px;
    }
    
    .costream-body {
        padding: 10px;
    }
}

/* ─── Rating Stars ────────────────────────────────────────────── */
.rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    cursor: pointer;
    user-select: none;
}
.rating-stars.rating-compact {
    gap: 0;
}

.rating-star {
    font-size: 14px;
    color: var(--border);
    transition: color 0.1s, transform 0.1s;
    line-height: 1;
}
.rating-compact .rating-star {
    font-size: 11px;
}

.rating-star.filled {
    color: #f59e0b;
}
.rating-star.hover {
    color: #fbbf24;
    transform: scale(1.15);
}
.rating-star:hover {
    transform: scale(1.2);
}

.rating-info {
    font-size: 9px;
    color: var(--muted);
    margin-left: 4px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.rating-submitted {
    animation: ratingPulse 0.4s ease;
}
@keyframes ratingPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Locked rating (already rated) */
.rating-locked .rating-star {
    cursor: default;
}
.rating-star.user-rated {
    color: #f59e0b;
}

/* ─── Card Actions Row (rating + victory inline) ──────────────── */
.card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

/* ─── Victory Button ──────────────────────────────────────────── */
.victory-btn-wrap {
    display: inline-flex;
    position: relative;
}

.victory-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    transition: all 0.15s;
}
.victory-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}
.victory-btn.has-victories {
    color: #f59e0b;
    border-color: #f59e0b;
}

.victory-count {
    font-weight: 700;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    min-width: 12px;
    text-align: center;
}

/* ─── Victory Panel (popover) ─────────────────────────────────── */
.victory-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.victory-panel {
    position: fixed;
    z-index: 1000;
    width: 320px;
    max-height: 450px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.victory-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.victory-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.victory-panel-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.victory-panel-close:hover {
    color: var(--text);
}

/* ─── Victory List ────────────────────────────────────────────── */
.victory-panel-list {
    overflow-y: auto;
    max-height: 180px;
    padding: 6px 0;
}

.victory-panel-empty {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 14px;
}

.victory-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 11px;
    transition: background 0.1s;
    flex-wrap: wrap;
}
.victory-row:hover {
    background: rgba(145, 71, 255, 0.05);
}
.victory-row.victory-seekable {
    cursor: pointer;
}
.victory-row.victory-seekable:hover .victory-row-time {
    color: var(--primary);
    text-decoration: underline;
}

.victory-row-trophy {
    font-size: 13px;
    flex-shrink: 0;
}

.victory-row-time {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.victory-row-note {
    color: var(--muted);
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.victory-delete {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.victory-row:hover .victory-delete {
    opacity: 1;
}
.victory-delete:hover {
    color: #ef4444;
}

.victory-edit {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0 3px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.victory-row:hover .victory-edit {
    opacity: 1;
}
.victory-edit:hover {
    color: var(--primary);
}

.victory-share {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0 3px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.victory-row:hover .victory-share {
    opacity: 1;
}
.victory-share:hover {
    color: #3b82f6;
}

/* ─── Victory Inline Edit Form ────────────────────────────────── */
.victory-edit-form {
    width: 100%;
    padding: 8px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
}
.victory-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}
.victory-save-btn {
    font-size: 11px;
    padding: 4px 12px;
}
.victory-cancel-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.12s;
}
.victory-cancel-btn:hover {
    border-color: var(--text);
    color: var(--text);
}

/* ─── Victory Add Form ────────────────────────────────────────── */
.victory-panel-add {
    border-top: 1px solid var(--border);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.victory-panel-add-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.victory-form-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.victory-form-row label {
    font-size: 10px;
    color: var(--muted);
    font-weight: 600;
}
.victory-optional {
    font-weight: 400;
    opacity: 0.6;
}

.victory-input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.victory-input:focus {
    border-color: var(--primary);
}
.victory-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}
.victory-input-error {
    border-color: #ef4444 !important;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.victory-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 4px;
    padding: 6px 12px;
    background: #f59e0b;
    color: #000;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.victory-submit:hover {
    background: #d97706;
}

/* ─── Mobile Victory Panel ────────────────────────────────────── */
@media (max-width: 500px) {
    .victory-panel {
        width: calc(100vw - 20px);
        left: 10px !important;
    }
}

/* ─── Comments Section ────────────────────────────────────────── */
.comments-section {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
}

.comments-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    text-align: left;
}
.comments-toggle:hover {
    color: var(--text);
    background: rgba(145, 71, 255, 0.04);
}
.comments-toggle.open {
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.comments-chevron {
    margin-left: auto;
    transition: transform 0.2s;
}
.comments-toggle.open .comments-chevron {
    transform: rotate(180deg);
}
.comments-toggle-count {
    font-size: 10px;
    color: var(--primary);
    font-weight: 700;
}

/* ─── Comments List ───────────────────────────────────────────── */
.comments-body {
    max-height: 320px;
    display: flex;
    flex-direction: column;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    max-height: 200px;
}

.comments-empty, .comments-loading {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 16px 14px;
}

.comment-row {
    padding: 6px 14px;
    transition: background 0.1s;
}
.comment-row:hover {
    background: rgba(145, 71, 255, 0.03);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.comment-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
}

.comment-timestamp {
    font-size: 10px;
    font-weight: 600;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;
    transition: background 0.15s;
}
.comment-timestamp:hover {
    background: rgba(245, 158, 11, 0.25);
}

.comment-date {
    font-size: 9px;
    color: var(--muted);
    margin-left: auto;
}

.comment-delete {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0 3px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}
.comment-row:hover .comment-delete {
    opacity: 1;
}
.comment-delete:hover {
    color: #ef4444;
}

.comment-text {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

/* ─── Comments Form ───────────────────────────────────────────── */
.comments-form {
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.comments-form-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.comments-input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.comments-input:focus {
    border-color: var(--primary);
}
.comments-input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}
.comments-input-error {
    border-color: #ef4444 !important;
    animation: shake 0.3s;
}

.comments-author {
    width: 120px;
    flex-shrink: 0;
}

.comments-text {
    flex: 1;
    width: 100%;
    resize: vertical;
    min-height: 36px;
    max-height: 100px;
    line-height: 1.4;
}

.comments-ts-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s;
}
.comments-ts-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
}

.comments-ts-preview {
    font-size: 10px;
    color: #f59e0b;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.comments-form-actions {
    justify-content: flex-end;
}

.comments-submit {
    padding: 5px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.comments-submit:hover {
    background: #7c3aed;
}

@media (max-width: 500px) {
    .comments-author {
        width: 80px;
    }
    .comments-ts-btn span {
        display: none;
    }
}

/* ═════════════════════════════════════════════════════════════════
   WATCH STATS
   ═════════════════════════════════════════════════════════════════ */
.watch-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.watch-stats-total {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}
.watch-stats-total strong {
    color: var(--text);
    font-size: 14px;
}

.watch-stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.watch-stat-name {
    width: 100px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.watch-stat-bar-bg {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    min-width: 60px;
}

.watch-stat-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 2px;
}

.watch-stat-time {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    min-width: 50px;
    text-align: right;
    flex-shrink: 0;
}

/* ═════════════════════════════════════════════════════════════════
   VIEW TABS (Live | VODs)
   ═════════════════════════════════════════════════════════════════ */
.view-tabs {
    display: flex;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 0 10px;
    gap: 2px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
    position: relative;
    padding: 4px 14px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
    flex: 0 0 auto;
    scroll-snap-align: start;
}
.view-tab:hover {
    color: var(--text);
    background: var(--hover);
}
.view-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Link-style tab (e.g. Clips) */
.view-tab-link {
    text-decoration: none;
}

.view-tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    display: none;
}
.view-tab-dot.live-dot {
    background: var(--live);
    box-shadow: 0 0 6px var(--live);
    animation: pulse 2s infinite;
}
/* Show dot only when someone is live */
.view-tab.has-live .view-tab-dot { display: inline-block; }

.view-tab-count {
    font-size: 10px;
    font-weight: 800;
    background: var(--live);
    color: #fff;
    border-radius: 8px;
    padding: 0 5px;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
    display: none;
}
.view-tab.has-live .view-tab-count { display: inline-block; }

/* Hide view tabs when nobody is live (only Live tab needed) */
.view-tabs.no-live { display: none; }



/* ═════════════════════════════════════════════════════════════════
   AUDIO SELECTOR BAR
   ═════════════════════════════════════════════════════════════════ */
.audio-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.audio-bar::-webkit-scrollbar { display: none; }
.audio-bar.hidden { display: none !important; }

.audio-bar-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.audio-bar-label svg {
    opacity: 0.5;
}

.audio-bar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}
.audio-bar-btn:hover {
    border-color: var(--primary);
    background: rgba(145, 71, 255, 0.08);
}
.audio-bar-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 10px rgba(145, 71, 255, 0.3);
}
.audio-bar-btn .audio-bar-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 4px var(--live);
    flex-shrink: 0;
}
.audio-bar-btn.active .audio-bar-dot {
    background: #fff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}
.audio-bar-btn .audio-bar-game {
    font-weight: 400;
    font-size: 10px;
    opacity: 0.7;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.audio-bar-btn .audio-bar-speaker {
    font-size: 10px;
    margin-left: -2px;
}

.audio-bar-shortcut {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 2px;
    opacity: 0.6;
}

/* Mute All button */
.audio-bar-mute-all {
    border-color: rgba(255, 80, 80, 0.3);
    color: var(--muted);
}
.audio-bar-mute-all:hover {
    border-color: #ff5050;
    background: rgba(255, 80, 80, 0.1);
    color: var(--text);
}
.audio-bar-mute-all.active {
    background: rgba(255, 80, 80, 0.2);
    border-color: #ff5050;
    color: #ff5050;
    box-shadow: none;
}

/* Drag grip handle */
.audio-bar-grip {
    font-size: 10px;
    opacity: 0.3;
    cursor: grab;
    margin-right: 2px;
    user-select: none;
}
.audio-bar-btn:hover .audio-bar-grip { opacity: 0.6; }
.audio-bar-btn.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}
.audio-bar-btn.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(145, 71, 255, 0.4);
}

@media (max-width: 768px) {
    .audio-bar {
        padding: 3px 8px;
        gap: 5px;
    }
    .audio-bar-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    .audio-bar-shortcut { display: none; }
    .audio-bar-label { display: none; }
}

/* ═════════════════════════════════════════════════════════════════
   MOBILE STREAM SWITCHER
   ═════════════════════════════════════════════════════════════════ */
.mobile-stream-tabs {
    display: none; /* shown via JS on mobile */
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 4px 8px;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.mobile-stream-tabs::-webkit-scrollbar { display: none; }

.mobile-stream-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}
.mobile-stream-tab:hover {
    border-color: var(--primary);
}
.mobile-stream-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.mobile-stream-tab .tab-live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 4px var(--live);
}
.mobile-stream-tab.active .tab-live-dot {
    background: #fff;
    box-shadow: 0 0 4px rgba(255,255,255,0.6);
}
.mobile-stream-tab .tab-game {
    font-weight: 400;
    font-size: 10px;
    opacity: 0.7;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "All" tab variant */
.mobile-stream-tab-all {
    border-style: dashed;
    gap: 4px;
}
.mobile-stream-tab-all.active {
    border-style: solid;
}

/* ═════════════════════════════════════════════════════════════════
   VODS VIEW
   ═════════════════════════════════════════════════════════════════ */
.vods-view {
    overflow-y: auto;
    padding-bottom: 20px;
}
.vods-view .offline-section {
    display: block;
}
.vods-view .costreams-section {
    display: block;
}

/* ═════════════════════════════════════════════════════════════════
   MOBILE REDESIGN — Stacked Streams
   ═════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Utility ─────────────────────────────────────────────── */
    .mobile-hide { display: none !important; }

    /* ── View Tabs ───────────────────────────────────────────── */
    .view-tabs {
        padding: 0 6px;
        background-image: linear-gradient(to right, var(--bg-surface) 86%, transparent);
    }
    .view-tab {
        padding: 6px 12px;
        font-size: 11px;
    }



    /* ── Mobile Stream Tabs: removed in stacked mode ─────────── */
    .mobile-stream-tabs {
        display: none !important;
    }

    /* ── Streams: always stacked, full-width, 16:9 ───────────── */
    .live-streams.mobile-stacked {
        display: flex;
        flex-direction: column;
        gap: 0;
        flex: 1;
        padding-bottom: 0;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: y proximity;
    }
    .live-streams.mobile-stacked .stream {
        width: 100%;
        aspect-ratio: 16 / 9;
        min-height: 0;
        flex-shrink: 0;
        scroll-snap-align: start;
    }
    .live-streams.mobile-stacked .stream.hidden {
        display: none !important;
    }

    /* ── Legacy single-stream mode (kept for compat) ─────────── */
    .live-streams.mobile-single .stream {
        display: none;
    }
    .live-streams.mobile-single .stream.mobile-visible {
        display: block;
    }
    .live-streams.mobile-single {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    /* ── VODs view on mobile ─────────────────────────────────── */
    .vods-view {
        padding: 0;
    }
    .vods-view .costreams-section {
        padding: 12px;
    }
    .vods-view .offline-section {
        padding: 8px 12px;
    }
}

@media (max-width: 768px) {
    body.mobile-live-immersive .container,
    body.mobile-live-immersive .main-layout,
    body.mobile-live-immersive #live-view {
        min-height: 0;
    }

    body.mobile-live-immersive #live-streams,
    body.mobile-live-immersive #live-streams .stream,
    body.mobile-live-immersive #live-streams iframe {
        min-width: 0;
    }

    body.mobile-live-immersive #live-streams {
        flex: 1;
        height: auto;
        min-height: 0;
    }

    body.mobile-live-immersive #live-streams.grid-2 {
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.mobile-play-overlay {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 9000;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 10px 14px;
    background: rgba(12, 12, 16, 0.9);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.mobile-play-overlay:not(.hidden) {
    display: flex;
}
.mobile-play-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    font-size: 11px;
}

/* ── Landscape phones ─────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-stream-tabs { display: none !important; }
}

/* ═════════════════════════════════════════════════════════════════
   CHAT PANEL
   ═════════════════════════════════════════════════════════════════ */
.chat-panel {
    width: var(--chat-w);
    min-width: var(--chat-w);
    max-width: var(--chat-w);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
    z-index: 100;
    animation: chatSlideIn 0.25s ease;
}
.chat-panel.hidden {
    display: none !important;
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ═════════════════════════════════════════════════════════════════
   STREAM DYNAMIC ADD / REMOVE ANIMATIONS
   ═════════════════════════════════════════════════════════════════ */
@keyframes streamSlideIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes streamFadeOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.92); }
}

/* ═════════════════════════════════════════════════════════════════
   PICTURE-IN-PICTURE BUTTON (toolbar)
   ═════════════════════════════════════════════════════════════════ */
.pip-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.pip-btn svg { width: 12px; height: 12px; }
.pip-btn:hover {
    color: #38bdf8;
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

/* ═════════════════════════════════════════════════════════════════
   THEATER MODE
   ═════════════════════════════════════════════════════════════════ */
.theater-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.5);
    border-radius: 3px;
    width: 22px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.theater-btn svg { width: 12px; height: 12px; }
.theater-btn:hover {
    color: #fff;
    border-color: #fff;
}
.theater-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(145, 71, 255, 0.3);
}

/* Theater mode: primary stream ~70%, others stacked vertically on the right */
.live-streams.theater-mode {
    grid-template-columns: 3fr 1fr !important;
    grid-template-rows: 1fr !important;
}
.live-streams.theater-mode > .stream.theater-primary {
    grid-row: 1 / -1;
    grid-column: 1;
}
.live-streams.theater-mode > .stream:not(.theater-primary):not(.hidden):not(.minimized) {
    grid-column: 2;
}
/* When theater has only 2 visible, give side stream full height */
.live-streams.theater-mode > .stream:not(.theater-primary):not(.hidden):not(.minimized):only-of-type {
    grid-row: 1 / -1;
}

/* ═════════════════════════════════════════════════════════════════
   STREAM HEALTH INDICATOR
   ═════════════════════════════════════════════════════════════════ */
.stream-health {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    margin-left: 6px;
    white-space: nowrap;
}
.stream-health-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stream-health-dot.health-good { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.stream-health-dot.health-fair { background: #f59e0b; box-shadow: 0 0 4px #f59e0b; }
.stream-health-dot.health-poor { background: #ef4444; box-shadow: 0 0 4px #ef4444; }
.stream-health-text { opacity: 0.8; }

/* ═════════════════════════════════════════════════════════════════
   GAME FILTER PILLS
   ═════════════════════════════════════════════════════════════════ */
.game-filter-bar {
    display: flex;
    gap: 6px;
    padding: 0 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: wrap;
}
.game-filter-bar::-webkit-scrollbar { display: none; }
.game-filter-bar:empty { display: none; }

.game-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}
.game-filter-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.game-filter-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.vod-filters-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 180px)) auto;
    gap: 8px;
    margin: 0 0 10px;
}

.vod-filter-select,
.vod-filter-reset {
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
    font-family: inherit;
}

.vod-filter-select {
    padding: 0 10px;
}

.vod-filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(145, 71, 255, 0.15);
}

.vod-filter-reset {
    padding: 0 12px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
    transition: all 0.15s;
}

.vod-filter-reset:hover {
    color: var(--primary);
    border-color: var(--primary);
}

@media (max-width: 980px) {
    .vod-filters-row {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 640px) {
    .vod-filters-row {
        grid-template-columns: 1fr;
    }
}

.chat-header {
    display: flex;
    align-items: center;
    position: relative;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0 4px 0 0;
    min-height: 32px;
    flex-shrink: 0;
    gap: 2px;
}

.chat-tabs {
    display: flex;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0;
    min-width: 0;
}
.chat-tabs::-webkit-scrollbar { display: none; }

.chat-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
}
.chat-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}
.chat-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(145, 71, 255, 0.06);
}
.chat-tab .chat-tab-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 4px var(--live);
    flex-shrink: 0;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.chat-close-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

.chat-embed {
    flex: 1;
    min-height: 0;
    position: relative;
    background: var(--bg);
}
.chat-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.chat-no-streams {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    padding: 20px;
    text-align: center;
}
.chat-no-streams svg {
    opacity: 0.3;
}

/* ── Chat Panel: Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-panel {
        position: fixed;
        bottom: 0;
        bottom: env(safe-area-inset-bottom, 0px);
        left: 0;
        right: 0;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: 55vh;
        max-height: 55vh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
        z-index: 500;
        animation: chatSlideUp 0.3s ease;
    }

    @keyframes chatSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    .chat-header {
        border-radius: 16px 16px 0 0;
        min-height: 36px;
        padding: 0 6px;
    }

    /* Drag handle indicator */
    .chat-header::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        border-radius: 3px;
        background: var(--border);
    }

    .chat-tab {
        padding: 8px 14px;
        font-size: 12px;
    }

    .chat-close-btn {
        width: 32px;
        height: 32px;
    }
}

/* ── Chat Panel: Landscape phones ─────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 300px !important;
        min-width: 300px !important;
        max-width: 300px !important;
        height: 100% !important;
        max-height: 100% !important;
        border-top: none;
        border-left: 1px solid var(--border);
        border-radius: 0;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.4);
        animation: chatSlideIn 0.25s ease;
    }

    .chat-header {
        border-radius: 0;
    }

    .chat-header::before { display: none; }
}

/* ── Transcript caption overlay (sync rewatch) ───────────────────── */
.sync-streams { position: relative; }
.sync-captions {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: min(90%, 900px);
  pointer-events: none;
  text-align: center;
}
.sync-captions.hidden { display: none; }
.sync-captions .cc-line {
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: clamp(15px, 2.1vw, 24px);
  line-height: 1.3;
  padding: 4px 12px;
  border-radius: 8px;
  max-width: 100%;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}
.sync-captions .cc-name { font-weight: 700; margin-right: 6px; }
#sync-cc-toggle.active { background: #9147ff; color: #fff; }
#sync-cc-toggle.cc-available::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
}
