@charset "UTF-8";

/* ==========================================================================
   1. CSS Variables & Reset
   ========================================================================== */
:root {
    --bg-base: #0f172a;
    /* Slate 900 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --bg-surface-hover: #334155;
    /* Slate 700 */
    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --accent: #3b82f6;
    /* Blue 500 */
    --accent-hover: #2563eb;
    /* Blue 600 */
    --live-red: #ef4444;
    /* Red 500 */
    --border: #334155;
    --text-muted: #94a3b8;
    --header-height: 64px;
    /* Increased header height slightly */
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scrolling */
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. Header (Navigation)
   ========================================================================== */
header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    justify-content: center;
    /* Center the contents */
    flex-shrink: 0;
    z-index: 100;
    gap: 1rem;
    position: relative;
    /* Add relative for absolute children */
}

.header-left {
    position: absolute;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.025em;
    z-index: 1;
    /* Ensure logo is above other elements */
}

.logo-img {
    height: 32px;
    width: auto;
    display: block;
}

/* Header Actions */
.header-actions {
    position: absolute;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    /* 간격 줄임 (기존 16px 추정) */
}

.user-btn {
    background: var(--bg-surface-hover);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.user-btn:hover {
    background: var(--border);
}

.user-btn.active {
    color: var(--accent);
}

.user-btn.active svg {
    fill: var(--accent);
}

/* 원형 ON/OFF 토글 래퍼 */
.subtitle-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    /* 라벨과 버튼 사이 간격 줄임 */
    margin-right: 4px;
    /* 프로필 버튼과의 간격 줄임 */
}

/* 좌측 '자막' 텍스트 라벨 */
.subtitle-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, sans-serif;
    user-select: none;
}

/* 원형 ON/OFF 버튼 스타일 (다크 테마 적용) */
.circle-toggle-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    /* 기본(OFF) 테두리: 짙은 회색 */
    border: 3px solid var(--border);
    /* 버튼 내부: 다크 테마에 어울리는 짙은 그라데이션 */
    background: radial-gradient(circle at 30% 30%, #475569, #1e293b);
    /* 3D 그림자 효과 */
    box-shadow:
        0 3px 5px rgba(0, 0, 0, 0.6),
        inset 0 -2px 5px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    padding: 0;

    /* 기본(OFF) 텍스트 스타일: 흐린 회색 */
    color: var(--text-secondary);
    font-weight: 800;
    font-size: 11px;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* CSS Content로 텍스트 생성 (OFF) */
.circle-toggle-btn::after {
    content: 'OFF';
}

/* 버튼 눌렀을 때 효과 */
.circle-toggle-btn:active {
    transform: scale(0.94);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 켜짐(ON) 상태 스타일 */
.circle-toggle-btn.is-on {
    border-color: var(--accent);
    /* 테마 강조색(파란색) 테두리 */
    color: var(--text-primary);
    /* 밝은 텍스트 */
    background: radial-gradient(circle at 30% 30%, #3b82f6, #1d4ed8);
    /* 파란색 발광 느낌 */
    box-shadow:
        0 0 10px rgba(59, 130, 246, 0.4),
        /* 파란색 외부 네온 효과 */
        inset 0 -2px 5px rgba(0, 0, 0, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

/* 켜짐(ON) 텍스트 변경 */
.circle-toggle-btn.is-on::after {
    content: 'ON';
}

/* ==========================================================================
   3. Layout Architecture (PC Grid 4 Columns)
   ========================================================================== */
.layout {
    display: grid;
    /* 1. 채널 선택(360px) | 2. 영상(가변) | 3. 채팅(340px) */
    grid-template-columns: 360px minmax(320px, 1fr) 340px;
    grid-template-rows: 100%;
    height: calc(100dvh - var(--header-height));
    overflow: hidden;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.layout.hide-channels {
    grid-template-columns: 0px minmax(320px, 1fr) 340px;
}

.layout>* {
    min-height: 0;
    min-width: 0;
}

/* ==========================================================================
   4. Channels Section
   ========================================================================== */
.channels-section {
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
    /* Added to fix scroll issue */
    transition: opacity 0.2s ease, visibility 0.3s;
    min-width: 0;
    /* Prevent grid blowout when shrinking */
}

.layout.hide-channels .channels-section {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}


.channels-header {
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.sport-filters {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    /* 每行固定6个 */
    background: var(--bg-surface);
    /* 전체 박스 배경색 */
    padding: 0;
    gap: 0;
    /* 박스 사이 간격 없앰 */
    overflow: hidden;
    /* 둥근 모서리 바깥으로 나가는 자식 요소 숨김 */
}

.sport-filter-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    /* 아이콘과 카운트를 위아래로 배치 */
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    /* 오른쪽 테두리 (칸 나누기) */
    border-bottom: 1px solid var(--border);
    /* 아래쪽 테두리 (칸 나누기) */
    color: var(--text-secondary);
    padding: 10px 0;
    border-radius: 0;
    /* 개별 모서리 둥글기 제거 */
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 6px;
    box-shadow: none;
}

/* 오른쪽 끝 칸은 오른쪽 테두리 제거 */
.sport-filter-btn:nth-child(6n) {
    border-right: none;
}

/* 마지막 줄 칸들은 아래쪽 테두리 제거 */
.sport-filter-btn:nth-last-child(-n+6) {
    border-bottom: none;
}

.sport-filter-btn .count {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1;
}

.sport-filter-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
    transform: none;
    /* 호버 시 떠오르는 효과 제거 */
    box-shadow: none;
}

.sport-filter-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border-color: transparent;
    box-shadow: none;
    transform: none;
}

.sport-filter-btn.active .count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.sport-filter-btn.empty {
    cursor: default;
    pointer-events: none;
    background: transparent;
}

.sport-filter-btn.empty:hover {
    background: transparent;
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10px;
    /* add some space at the bottom */
    min-height: 0;
    /* Important for flex scrolling */
}

/* Custom Scrollbar for Channel List */
.channel-list::-webkit-scrollbar {
    width: 6px;
}

.channel-list::-webkit-scrollbar-track {
    background: transparent;
}

.channel-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}

.channel-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.channel-card {
    background-color: transparent;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    cursor: default;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border);
}

.channel-card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    cursor: pointer;
    gap: 8px;
}

.channel-card-body:hover {
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.channel-card:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.channel-card.active {
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--accent);
}

.ch-source-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 2px;
}

.channel-card-body--multi-source {
    cursor: pointer;
}

.ch-source-row-wrap {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.22s ease, opacity 0.2s ease;
}

.ch-source-row-wrap--collapsed {
    grid-template-rows: 0fr;
    opacity: 0;
    pointer-events: none;
}

.ch-source-row-inner {
    min-height: 0;
    overflow: hidden;
}

.channel-card--multi .ch-source-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    width: 100%;
}

.ch-source-btn {
    flex: 1;
    min-width: 4rem;
    padding: 4px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ch-source-btn:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.ch-source-btn--active {
    border-color: var(--accent);
    color: #fff;
    background: rgba(59, 130, 246, 0.2);
}

.ch-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.ch-top {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.ch-date {
    font-weight: 500;
}

.ch-league {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.65rem;
}

.ch-bottom {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.ch-scoreboard {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.ch-team {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ch-team-left {
    justify-content: flex-end;
}

.ch-team-right {
    justify-content: flex-start;
}

.ch-team-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    /* text-overflow: ellipsis; removed for marquee */
    flex: 1;
    min-width: 0;
}

/* Text wrapper for marquee */
.ch-team-name-inner {
    display: inline-block;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

/* We will apply this class using JS only to elements that overflow */
.marquee-text {
    animation: marquee-scroll 8s linear infinite;
    padding-left: 100%;
}

@keyframes marquee-scroll {
    0% {
        transform: translateX(0%);
    }

    100% {
        transform: translateX(-100%);
    }
}

.ch-team-score {
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ch-team-score.score-high {
    color: var(--live-red);
}

.ch-team-score.score-low {
    color: var(--text-primary);
}

.ch-team-score.score-tie {
    color: var(--text-secondary);
}

/* WebSocket 比分更新：得分方短暂黄色底（约 3s） */
@keyframes score-side-flash {
    0% {
        background-color: #fbbf24;
        box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.4);
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.ch-team.score-flash-pulse {
    animation: score-side-flash 3s ease-out forwards;
    border-radius: 8px;
    padding: 2px 6px;
    margin: -2px -6px;
}

.pc-match-info>.team-block.score-flash-pulse {
    animation: score-side-flash 3s ease-out forwards;
    border-radius: 10px;
    padding: 6px 10px;
    margin: -6px -10px;
}

.ch-match-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 46px;
    max-width: 7rem;
    width: auto;
    text-align: center;
}

.ch-match-badge.badge-live {
    background-color: var(--accent);
    color: white;
}

.ch-match-badge.badge-upcoming {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.ch-status-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 50px;
}

.ch-status-col .live-badge {
    position: static;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ef4444;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: transparent;
    padding: 0;
    backdrop-filter: none;
}

.ch-status-col .live-dot {
    width: 5px;
    height: 5px;
    background-color: #ef4444;
    border-radius: 50%;
    animation: ch-pulse 1.5s infinite;
}

@keyframes ch-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.upcoming-badge {
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ==========================================================================
   5. Video Player Section
   ========================================================================== */
.video-section {
    background: #000;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.video-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-height: 100%;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Decorative Background elements */
.video-placeholder::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 60%);
    animation: rotate 20s linear infinite;
    pointer-events: none;
}

/* PC Match Info Board */
.pc-match-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    width: 100%;
    padding: 30px 40px;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #000;
}

/* 赛事：三栏（队徽 / 比分 / 队徽） */
.pc-match-info-sports {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

/* [hidden] 会被上面的 display:flex 覆盖，TV 模式下赛事板必须彻底隐藏 */
.pc-match-info-sports[hidden] {
    display: none !important;
}

/* TV：仅居中标题 + 灰色副标题（图二） */
.pc-match-info--tv {
    justify-content: center;
}

.pc-match-info-tv {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    gap: 6px;
}

.pc-match-info-tv[hidden] {
    display: none !important;
}

.pc-match-info-tv-title {
    font-size: 2rem;
    font-weight: 800;
    color: #000;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin: 0;
}

.pc-match-info-tv-sub {
    font-size: 1.05rem;
    font-weight: 400;
    color: #666666;
    margin: 0;
    line-height: 1.4;
}

.pc-match-info .team-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.pc-match-info .team-logo {
    height: 60px;
    object-fit: contain;
    margin-bottom: 4px;
}

.pc-match-info .team-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: #000;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.pc-match-info .team-rank {
    font-size: 0.9rem;
    color: #666;
}

.pc-match-info .score-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.pc-match-info .score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.pc-match-info .score-left {
    font-size: 4.5rem;
    font-weight: 700;
    color: #ed1c24;
    /* Red color matching the image */
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pc-match-info .score-right {
    font-size: 4.5rem;
    font-weight: 700;
    color: #333333;
    /* Dark grey color matching the image */
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pc-match-info .match-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    gap: 4px;
}

.pc-match-info .status-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #888888;
    line-height: 1;
}

.pc-match-info .status-time {
    font-size: 1.1rem;
    color: #888888;
    line-height: 1;
}

.pc-match-info .match-date {
    font-size: 1.1rem;
    color: #555555;
    font-weight: 400;
}

/* Hide on mobile/tablet */
@media (max-width: 992px) {
    .pc-match-info {
        display: none;
    }
}

/* ==========================================================================
   9. Game Panel & Floating Button
   ========================================================================== */
.game-float-btn {
    position: absolute;
    top: 485px;
    right: 0;
    /* 화면 오른쪽 끝에 붙임 */
    width: 57px;
    height: 51px;
    border-radius: 40px 0 0 40px;
    /* 왼쪽만 둥글게 처리하여 화면에 붙은 느낌 강조 */
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    box-shadow: -4px 4px 15px rgba(0, 0, 0, 0.3);
    /* 그림자 방향을 왼쪽으로 조정 */
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
}

.game-float-btn:hover {
    transform: translateX(-4px) scale(1.05);
    /* 위로 뜨는 대신 왼쪽으로 살짝 당겨짐 */
    box-shadow: -6px 6px 20px rgba(0, 0, 0, 0.4);
}

.game-float-btn:active {
    transform: translateX(0) scale(0.95);
}


.game-panel {
    position: fixed;
    top: 0;
    /* 화면 맨 위부터 시작 */
    right: -450px;
    /* Hidden by default */
    bottom: 0;
    width: 450px;
    max-width: 100vw;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    z-index: 150;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.game-panel.open {
    right: 0;
}

.game-close-btn {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.game-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateX(-50%) scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.game-iframe-container {
    flex: 1;
    width: 100%;
    height: 100%;
    background: var(--bg-base);
}

.game-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   Danmaku (Flying Chat) Overlay
   ========================================================================== */
.danmaku-message {
    position: absolute;
    white-space: nowrap;
    color: #fff;
    font-weight: 800;
    font-size: 1.4rem;
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        0px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    will-change: transform;
    z-index: 100;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.play-btn {
    width: 72px;
    height: 72px;
    background: rgba(59, 130, 246, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.5);
}

.play-btn:hover {
    transform: scale(1.1);
    background: var(--accent);
}

.live-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(239, 68, 68, 0.9);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2;
    letter-spacing: 0.5px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* ==========================================================================
   6. Match Info Section (Removed, moved to header)
   ========================================================================== */

/* ==========================================================================
   7. Chat Section
   ========================================================================== */
/* 채팅 영역: PC grid 3번째 열. 외부 채팅은 section 없이 iframe.chat-section 단독 사용 */
.chat-section {
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    overflow: hidden;
    min-height: 0;
}

.chat-section:not(iframe) {
    display: flex;
    flex-direction: column;
}

iframe.chat-section.chat-iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 280px;
    border: none;
    box-sizing: border-box;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.chat-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-surface-hover);
    border-radius: 3px;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.msg-user {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.msg-time {
    font-size: 0.75rem;
    color: #64748b;
}

.msg-bubble {
    background: var(--bg-base);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    width: fit-content;
    max-width: 90%;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.message.mine {
    align-items: flex-end;
}

.message.mine .msg-header {
    flex-direction: row-reverse;
}

.message.mine .msg-bubble {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    border-top-left-radius: 1rem;
    border-top-right-radius: 0.25rem;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    z-index: 10;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.875rem 1.25rem;
    border-radius: 999px;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.chat-submit {
    background: var(--accent);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.chat-submit:hover {
    background: var(--accent-hover);
}

.chat-submit:active {
    transform: scale(0.95);
}

.chat-submit:disabled {
    background: var(--border);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Removed mobile tabs styles */

/* Mobile overlay styling (hidden by default) */
.mobile-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}

/* Removed obsolete Channels Section styles to fix scroll issue */

/* Custom Modal Styles */
.custom-modal {
    display: none;
    /* Hidden by default, toggled via JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.custom-modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.custom-modal-title {
    margin-bottom: 8px;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.custom-modal-desc {
    margin-bottom: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.custom-modal-input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 24px;
}

.custom-modal-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.custom-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.custom-modal-btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.cancel-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.cancel-btn:hover {
    background-color: var(--bg-base);
    color: var(--text-primary);
}

.save-btn {
    background-color: var(--accent);
    color: white;
}

.save-btn:hover {
    background-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Nickname modal panel (dark + color swatches, reference UI) */
.custom-modal-content.nickname-modal-panel {
    background-color: #1b2533;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.nickname-modal-panel .custom-modal-title {
    margin-bottom: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.nickname-modal-panel .custom-modal-desc {
    margin-bottom: 20px;
    font-size: 0.875rem;
    line-height: 1.45;
    color: #94a3b8;
}

.nickname-modal-panel .custom-modal-input {
    background: #0f1623;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: inherit;
    margin-bottom: 22px;
}

.nickname-modal-panel .custom-modal-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.nickname-modal-panel .custom-modal-input::placeholder {
    color: #64748b;
}

.nickname-color-block {
    margin-bottom: 24px;
}

.nickname-color-label {
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: #94a3b8;
}

.nickname-color-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.nickname-color-swatch {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nickname-color-swatch:hover {
    transform: scale(1.06);
}

.nickname-color-swatch:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.nickname-color-swatch--light {
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.nickname-color-swatch.is-selected {
    box-shadow:
        0 0 0 2px #3b82f6,
        inset 0 0 0 2px #ffffff;
}

.nickname-color-swatch--light.is-selected {
    border-color: transparent;
    box-shadow:
        0 0 0 2px #3b82f6,
        inset 0 0 0 2px #ffffff;
}

.nickname-modal-panel .cancel-btn {
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.45);
    background-color: transparent;
}

.nickname-modal-panel .cancel-btn:hover {
    background-color: rgba(15, 22, 35, 0.85);
    color: #f8fafc;
}

.nickname-modal-panel .save-btn {
    background-color: #3b82f6;
    color: #ffffff;
    font-weight: 700;
}

.nickname-modal-panel .save-btn:hover {
    background-color: #2563eb;
}

/* ==========================================================================
   8. Responsive Design (Mobile Simultaneous Watch & Chat)
   ========================================================================== */
@media (max-width: 992px) {
    .layout {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - var(--header-height));
    }

    /* The crucial part: Video sticks to the top */
    .video-section {
        position: sticky;
        top: 0;
        z-index: 50;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .chat-section {
        flex: 1;
        border-left: none;
        /* Removes PC header inside chat to save space on mobile */
    }

    .chat-section .chat-header {
        display: none;
    }

    /* Mobile Header adjustments for Info */
    header {
        height: auto;
        min-height: var(--header-height);
        flex-direction: row;
        padding: 10px;
        gap: 8px;
        position: relative;
        /* Make sure header is relative for absolute positioning of children */
        justify-content: center;
    }

    .header-left {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        width: auto;
    }

    #channel-toggle-btn {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
    }

    .logo {
        width: auto;
        justify-content: center;
        position: relative;
        z-index: 1;
    }

    .header-actions {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 10px;
    }

    /* Mobile Sidebar for Channels */
    .channels-section {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: 348px;
        max-width: 85vw;
        z-index: 200;
        transform: translateX(0);
        transition: transform 0.3s ease;
        background: var(--bg-surface);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        display: flex;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Hide channels when hide-channels class is present (default on mobile) */
    .layout.hide-channels .channels-section {
        transform: translateX(-100%);
        pointer-events: none;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
    }

    /* Show overlay when channels are open */
    .layout:not(.hide-channels) .mobile-overlay {
        display: block;
    }

    /* iframe 채팅: .chat-section 의 flex:1 로 남은 영역 사용 (display:flex 는 구 section 용) */
}


/* TV 三列网格：对齐预期（标题视觉居中 + 仅右上星标 + 选中浅蓝底与底边条） */
.channel-list.tv-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    align-content: start;
    background: transparent;
}

.channel-list.tv-grid .channel-wrapper {
    border-bottom: none;
    background: var(--bg-surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    height: 73px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.channel-list.tv-grid .channel-wrapper:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(148, 163, 184, 0.35);
}

.channel-list.tv-grid .channel-card {
    position: relative;
    padding: 0;
    margin: 0;
    border: none;
    border-bottom: none;
    border-radius: 8px;
    min-height: 75px;
    max-height: 104px;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
    align-items: stretch;
    text-align: center;
    background: transparent;
    box-sizing: border-box;
    cursor: pointer;
}

.channel-list.tv-grid .channel-card:hover {
    background: transparent;
}

.channel-list.tv-grid .channel-card.active {
    border-left: none !important;
    border-bottom: 4px solid var(--accent);
    background: rgba(59, 130, 246, 0.14);
    box-shadow: none;
}

.channel-list.tv-grid .tv-channel-wrapper {
    cursor: grab;
}

.channel-list.tv-grid .tv-channel-wrapper:active {
    cursor: grabbing;
}

.channel-list.tv-grid .channel-card>.ch-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-height: 0;
    width: 100%;
}

.channel-list.tv-grid .channel-card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

.channel-list.tv-grid .ch-info {
    justify-content: center;
    align-items: stretch;
    width: 100%;
}

.channel-list.tv-grid .ch-bottom {
    width: 100%;
}

/* 右侧为星标预留空间，标题在剩余区域水平居中（避免图一「标题被挤到一侧」） */
.channel-list.tv-grid .tv-ch-scoreboard {
    position: relative;
    width: 100%;
    min-height: 0;
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    box-sizing: border-box;
}

.channel-list.tv-grid .tv-favorite-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 5;
    padding: 2px;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    line-height: 0;
    border-radius: 4px;
}

.channel-list.tv-grid .tv-favorite-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.channel-list.tv-grid .tv-favorite-icon {
    display: block;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--text-muted, #94a3b8);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: fill 0.15s ease, stroke 0.15s ease;
}

.channel-list.tv-grid .tv-favorite-btn.is-favorite .tv-favorite-icon {
    fill: #facc15;
    stroke: #facc15;
}

.channel-list.tv-grid .tv-ch-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    flex: 1;
}

.channel-list.tv-grid .tv-ch-team .ch-team-name {
    font-size: 0.95rem;
    line-height: 1.25;
    text-align: center;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    max-width: 100%;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.channel-list.tv-grid .tv-ch-team .ch-team-name-inner {
    color: inherit;
}

.channel-list.tv-grid .tv-ch-sub {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-list.tv-grid .inline-line-selection {
    position: absolute;
    z-index: 10;
    width: calc(100% - 24px);
    left: 12px;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
}

.channel-list.tv-grid .tv-favorite-icon-wrapper button {
    position: absolute;
    top: -18px;
    right: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 5;
    padding: 4px;
}

.tv-channel-wrapper .ch-bottom {
    margin-top: 10px;
}