/* ═══════════════════════════════════════════════════════
   플러그 쿼카 — 모바일 전용 스타일 (max-width: 768px)
   레이아웃: 헤더 → 영상(16:9) → 스킵바 → 탭바 → 탭콘텐츠
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px), (max-width: 1024px) and (any-pointer: coarse), (orientation: landscape) and (max-height: 1024px) and (any-pointer: coarse) {

  /* ─────────────────────────────────────────
     기본 리셋
  ───────────────────────────────────────── */
  #pcSubtitleBtn { display: none !important; }
  body {
    overflow: hidden;
    height: 100dvh;
  }

  /* iOS 자동 줌 방지 */
  input[type="text"],
  input[type="search"] {
    font-size: 16px !important;
  }

  /* PC 전용 버튼 모바일에서 완전 숨김 */
  .btn-ws-playlist,
  .btn-expand,
  .btn-widescreen {
    display: none !important;
  }

  /* ─────────────────────────────────────────
     로비 / 모달
  ───────────────────────────────────────── */
  .lobby-card {
    width: calc(100vw - 32px);
    max-width: 400px;
    padding: 28px 20px;
    gap: 12px;
    border-radius: 20px;
  }
  .lobby-logo { font-size: 24px; }
  .lobby-btn  { padding: 11px 14px; }
  .lobby-btn-icon { font-size: 20px; }
  .lobby-btn-text strong { font-size: 14px; }
  .lobby-avatar-circle { width: 60px; height: 60px; font-size: 22px; }
  .lobby-profile-row { gap: 12px; }

  .modal-box {
    width: calc(100vw - 40px);
    max-width: 360px;
    padding: 24px 18px;
  }
  #profileModal .modal-logo { display: none; }
  .invite-code { font-size: 22px; letter-spacing: 4px; }

  /* ─────────────────────────────────────────
     헤더
  ───────────────────────────────────────── */
  .header {
    padding: 0 10px;
    padding: max(0px, env(safe-area-inset-top)) 10px 0 10px;
    height: 44px;
    height: calc(44px + env(safe-area-inset-top));
    flex-shrink: 0;
  }
  .header-logo      { font-size: 14px; min-width: unset; }
  .header-center    { padding: 0 6px; }
  .room-name-header { font-size: 12px; }
  .now-playing-header { font-size: 10px; }
  .btn-invite, .btn-profile, .btn-admin-header, .theme-toggle-btn { font-size: 11px; padding: 5px 8px; height: 26px; }
  .user-count       { font-size: 11px; }

  /* ─────────────────────────────────────────
     앱 셸 — 세로 레이아웃
  ───────────────────────────────────────── */
  .app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  .body {
    flex: 0 0 auto;  /* 영상+버튼 크기만큼만 차지, 나머지는 탭콘텐츠가 가져감 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* 내부 여백이 검은 줄로 보이지 않도록 배경 제거 */
    background: transparent;
  }

  /* 데스크톱 전용 패널 완전 숨김 */
  .side-panel,
  .panel-toggle-btn,
  .right-panel {
    display: none !important;
  }

  /* ─────────────────────────────────────────
     center-panel: 영상 + 스킵 버튼만 담당
  ───────────────────────────────────────── */
  .center-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: transparent;
    /* 콘텐츠(영상+버튼) 크기에만 맞게 — 검은 여백 제거 */
  }

  /* 영상 비율 — 기본 16:9, Shorts 모드에서 9:16으로 전환 */
  .video-wrap {
    flex: none !important;
    width: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    overflow: hidden;
    background: #000;
  }
  /* Shorts 모드: 9:16 비율 (최대 높이 제한으로 영상 영역 넘침 방지) */
  .video-wrap.shorts-mode {
    aspect-ratio: 9 / 16 !important;
    max-height: 55dvh;
    width: auto;
    margin: 0 auto;
  }

  /* 최소화 버튼 숨김 */
  .btn-expand { display: none !important; }

  /* 음량 컨트롤 — 모바일에서 완전 숨김 */
  .volume-control {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }
  /* mini-participants 모바일 완전 제거 */
  #miniParticipants {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .video-controls {
    flex-shrink: 0;
    padding: 0;
    gap: 0;
    background: var(--bg2);
    border-top: none;
    display: flex;
    align-items: center;
    min-height: 0;
    height: 0;
    overflow: hidden;
  }
  /* 스킵 버튼 있을 때만 높이 확보 */
  .video-controls:has(.btn-skip:not(.hidden)) {
    height: auto;
    padding: 5px 10px;
    border-top: 1px solid var(--border);
  }
  .btn-skip {
    font-size: 12px;
    padding: 5px 12px;
  }

  /* ── 모바일 세로모드 투표 바 (채팅 헤더 내 배치) ── */
  .m-vote-bar {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .m-vote-bar.hidden { display: none; }
  .m-vote-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 16px;
    padding: 3px 8px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    min-width: 32px;
    height: 26px;
  }
  .m-vote-btn:active {
    transform: scale(0.85);
    background: rgba(255,255,255,0.12);
  }
  .m-vote-btn.voted-state {
    opacity: 0.35;
    pointer-events: none;
  }
  /* 투표 완료 후 누른 버튼 강조 */
  .m-vote-btn.voted-active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 139,92,246), 0.15);
  }

  /* SVG 별 스타일 (찜하기) */
  .m-vote-btn.star .m-star-icon polygon {
    fill: none;
    stroke: var(--text2);
    stroke-width: 1.8;
    stroke-linejoin: round;
    transition: fill 0.18s, stroke 0.18s;
  }
  .m-vote-btn.star.starred {
    border-color: #FFD93D;
    background: rgba(255,217,61,0.1);
  }
  .m-vote-btn.star.starred .m-star-icon polygon {
    fill: #FFD93D;
    stroke: #FFD93D;
  }
  .m-vote-btn.star:active .m-star-icon polygon {
    fill: rgba(255, 217, 61, 0.4);
    stroke: #FFD93D;
  }
  /* 모바일에서 lsMylistBtn / lsPlaylistBtn 숨김 (vote bar가 대신함) */
  .video-controls .btn-ls-playlist { display: none; }

  /* 영상 호스트 배지 — 모바일에서 완전 숨김 (여백 제거) */
  #videoHostBadge {
    display: none !important;
  }

  /* ─────────────────────────────────────────
     모바일 탭 콘텐츠 영역
  ───────────────────────────────────────── */
  #mobileTabContent {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    width: 100%;
    background: var(--bg2);
  }

  .m-tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  .m-tab-panel.active {
    display: flex;
  }

  /* ── 채팅 탭 ── */
  #mTabChat {
    display: none;
    flex-direction: column;
    overflow: visible;
    flex: 1;
    min-height: 0;
  }
  #mTabChat.active { display: flex; }

  /* 채팅 탭에서 참여자 섹션 완전 숨김 → 채팅창이 전체 높이 사용 */
  #mTabChat .users-section {
    display: none !important;
  }

  #mTabChat .chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  #mTabChat .chat-section .section-header {
    flex-shrink: 0;
    padding: 4px 12px;
    font-size: 12px;
    gap: 4px;
  }
  /* 채팅 레이블 — 왼쪽 고정 */
  #mTabChat .chat-section .section-header > span:first-child {
    flex-shrink: 0;
  }
  /* 투표 바 — 중앙 공간 차지 */
  #mTabChat .chat-section .section-header .m-vote-bar {
    flex: 1;
    justify-content: center;
  }
  #mTabChat .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    min-height: 0;
  }
  #mTabChat .img-preview-bar {
    flex-shrink: 0;
  }
  #mTabChat .chat-input-row {
    flex-shrink: 0;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 6px;
  }
  #mTabChat .chat-input-row input {
    font-size: 16px;
  }
  #mTabChat .btn-emoji {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
  #mTabChat .emoji-picker {
    bottom: calc(100% + 4px);
    right: 8px;
    width: min(296px, 90vw);
    max-height: 220px;
    z-index: 9999 !important;
  }
  #mTabChat .btn-send {
    padding: 0;
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 13px;
  }
  #mTabChat .btn-send svg { width: 18px; height: 18px; }

  /* ── 플레이리스트 탭 ── */
  #mTabQueue {
    display: none;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }
  #mTabQueue.active { display: flex; }

  #mTabQueue .add-section {
    flex-shrink: 0;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
  }
  #mTabQueue .add-tabs {
    margin-bottom: 6px;
  }
  #mTabQueue .add-tab {
    font-size: 12px;
    padding: 6px 0;
  }
  /* 검색결과 — 모바일은 좀 더 작게 */
  #mTabQueue .search-results {
    max-height: 180px;
  }
  #mTabQueue .search-thumb-wrap {
    width: 80px;
    height: 46px;
  }
  #mTabQueue .search-item img {
    width: 80px;
    height: 46px;
  }
  #mTabQueue .search-item-title { font-size: 12px; }
  #mTabQueue .search-item-ch,
  #mTabQueue .search-item-views { font-size: 10px; }
  /* 추가 버튼 모바일은 항상 표시 */
  #mTabQueue .search-add-btn { opacity: 1 !important; font-size: 11px; padding: 5px 8px; }
  /* 별표 버튼 모바일 상시 표시 */
  .star-mylist-btn { opacity: 0.3; }
  .star-mylist-btn.starred { opacity: 1; }

  #mTabQueue .queue-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  #mTabQueue .queue-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    min-height: 0;
  }
  .queue-item { padding: 8px 10px; }
  .queue-remove { display: block !important; }

  /* ── 내 목록 탭 ── */
  #mTabMylist {
    display: none;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }
  #mTabMylist.active { display: flex; }

  #mTabMylist .mylist-header-bar {
    flex-shrink: 0;
    padding: 8px 12px 6px;
    border-bottom: 1px solid var(--border);
  }
  #mTabMylist #mMylistList {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  /* ── 참여자 탭 ── */
  #mTabUsers {
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    gap: 6px;
    flex: 1;
  }
  #mTabUsers.active { display: flex; }
  #mTabUsers .user-chip {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  /* ─────────────────────────────────────────
     하단 탭바
  ───────────────────────────────────────── */
  #mobileTabBar {
    flex-shrink: 0;
    display: flex;
    width: 100%;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .m-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 4px;
    min-height: 44px; /* 최소 터치 영역 44px 보장 */
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: color .15s;
    position: relative;
  }
  .m-tab-btn.active { color: var(--accent); }
  .m-tab-btn.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 0 0 2px 2px;
  }
  .m-tab-icon  { font-size: 18px; line-height: 1; }
  .m-tab-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

  /* 읽지 않은 채팅 뱃지 */
  .m-tab-btn .m-badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 18px);
    background: var(--accent2);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    display: none;
  }
  .m-tab-btn .m-badge.show { display: block; }

  /* ─────────────────────────────────────────
     기타
  ───────────────────────────────────────── */
  #toast {
    bottom: calc(58px + env(safe-area-inset-bottom));
    font-size: 12px;
    padding: 8px 16px;
  }

  /* 이미지 첨부 미리보기 */
  .img-preview-bar {
    padding: 5px 10px;
    gap: 6px;
  }
  .img-preview-bar img {
    width: 32px;
    height: 32px;
  }

  /* ─────────────────────────────────────────
     탭 버튼 터치 영역 (add-tabs)
  ───────────────────────────────────────── */
  .add-tab {
    min-height: 44px;
    min-width: 44px;
  }

  /* ─────────────────────────────────────────
     닉네임 색상 — 다크 배경 대비 보정
     너무 밝거나 채도 높은 색은 읽기 어려우므로
     chat-name에 text-shadow + filter로 보정
  ───────────────────────────────────────── */
  [data-theme="dark"] .chat-name {
    filter: brightness(0.92) saturate(0.85);
    text-shadow: 0 0 8px rgba(0,0,0,0.6);
  }
  [data-theme="light"] .chat-name {
    text-shadow: none;
  }

  /* user-dot (참여자 리스트 색 점)은 그대로 유지 */
  .user-dot {
    filter: none;
  }

  /* ─────────────────────────────────────────
     방 목록 모달 — 모바일 최적화
  ───────────────────────────────────────── */

  /* 모달 박스 화면 꽉 채우기 */
  #browseModal .modal-box {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    padding: 20px 14px !important;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
  }

  #adminModal .modal-box {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    padding: 20px 14px !important;
    max-height: 95dvh !important;
    display: flex;
    flex-direction: column;
  }

  .admin-panel-title {
    display: none !important;
  }
  
  .admin-btn-group {
    width: 100%;
    justify-content: space-between;
    gap: 4px !important;
  }
  
  .admin-btn-group button {
    flex: 1;
    padding: 6px 0 !important;
    font-size: 10px !important;
    white-space: nowrap !important;
    letter-spacing: -0.5px;
  }

  /* 관리자 패널 이모지 목록 크기 조절 (방 목록 공간 확보) */
  #adminModal #adminQuokkaEmojiList {
    max-height: 200px !important;
  }

  /* 방 목록 스크롤 영역 높이 제한 */
  .room-list-container {
    max-height: 55dvh !important;
    -webkit-overflow-scrolling: touch;
  }

  /* 카드 썸네일 작게 */
  .room-list-thumb {
    width: 56px !important;
    min-width: 56px !important;
    height: 38px !important;
  }

  .room-list-name  { font-size: 13px !important; }
  .room-video-title { font-size: 10px !important; }
  .room-list-users { font-size: 10px !important; }

  /* 입장 버튼 터치 영역 확보 */
  .room-join-btn {
    font-size: 12px !important;
    padding: 9px 12px !important;
    min-height: 44px;
    min-width: 52px;
  }

  /* 새로고침/닫기 버튼 전체 너비 */
  #refreshRoomsBtn,
  #cancelBrowseBtn {
    min-height: 44px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
  }

  /* ─────────────────────────────────────────
     비공개 토글 — 모바일 터치 최적화
  ───────────────────────────────────────── */
  .private-toggle-box {
    padding: 12px 14px;
    min-height: 54px;
  }
  .private-toggle-text strong { font-size: 14px; }
  .private-toggle-text small  { font-size: 11px; }

}

/* ═══════════════════════════════════════════════════════
   [Fix 2] 모바일 가로모드 (Landscape) 레이아웃
   JS applyLandscapeMode() 가 .body 안으로 #mobileTabContent를 이동시키고
   body에 .landscape-mobile 클래스를 붙인다.
   CSS는 그 상태에서 영상(좌60%) | 채팅(우40%) 2단 레이아웃을 담당.
   ═══════════════════════════════════════════════════════ */

/* 가로모드 공통 — CSS orientation 미디어쿼리 대신 JS가 붙이는 클래스로 제어
   (CSS @media orientation은 기기 회전 잠금을 무시하므로 사용 안 함) */
body.landscape-mobile-active .header { display: none !important; }
body.landscape-mobile-active #mobileTabBar { display: none !important; }
body.landscape-mobile-active .side-panel,
body.landscape-mobile-active .panel-toggle-btn,
body.landscape-mobile-active .right-panel { display: none !important; }
body.landscape-mobile-active #videoHostBadge { display: none !important; }
body.landscape-mobile-active { overflow: hidden; height: 100dvh; }
body.landscape-mobile-active .app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

/* ── .landscape-mobile: JS가 DOM 이동 완료 후 붙이는 클래스 ── */
body.landscape-mobile .app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* .body가 가로 2단: center-panel(영상) + #mobileTabContent(채팅) */
body.landscape-mobile .body {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}

/* 영상 패널 — 왼쪽 70% */
body.landscape-mobile .center-panel {
  flex: 0 0 70%;
  width: 70%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

/* 모바일 가로모드 채팅창 확대 */
#mToggleChatSizeBtn { display: none; }
body.landscape-mobile #mToggleChatSizeBtn { display: inline-flex; }
body.landscape-mobile.m-chat-expanded .center-panel {
  flex: 0 0 50%;
  width: 50%;
}


body.landscape-mobile .video-wrap {
  flex: 1 !important;
  width: 100% !important;
  aspect-ratio: unset !important;
  max-height: unset !important;
  height: 100% !important;
  background: #000;
  position: relative;
  overflow: hidden;
}

body.landscape-mobile .video-controls {
  flex-shrink: 0;
  height: 0;
  overflow: hidden;
  padding: 0;
}
body.landscape-mobile .video-controls:has(.btn-skip:not(.hidden)) {
  height: auto;
  padding: 3px 8px;
  overflow: visible;
}
body.landscape-mobile .btn-skip { font-size: 11px; padding: 3px 10px; }
/* 가로모드: 투표 바 숨김, 플리/찜 버튼 복원 */
body.landscape-mobile .m-vote-bar { display: none !important; }
body.landscape-mobile .video-controls .btn-ls-playlist { display: flex; }

/* 채팅 패널 — 오른쪽 나머지 */
body.landscape-mobile #mobileTabContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
}

/* 채팅 탭 레이아웃 */
body.landscape-mobile #mTabChat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
/* ── 가로모드 참여자 섹션 ──
   스마트폰: 화면이 너무 좁아 완전 숨김 (채팅이 전체 높이 사용)
   태블릿  : PC처럼 채팅창 상단에 접고/펼치는 참여자 탭 노출 */
body.landscape-mobile:not(.tablet-device) #mTabChat .users-section { display: none !important; }

body.landscape-mobile.tablet-device #mTabChat .users-section {
  display: flex !important;
  flex: 0 0 auto;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}
body.landscape-mobile.tablet-device #mTabChat .users-section .section-header {
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 11px;
}
body.landscape-mobile.tablet-device #mTabChat .users-list {
  padding: 0 10px;
  gap: 5px;
}
/* 펼침 시에도 채팅 영역을 과하게 잠식하지 않도록 높이 제한 */
body.landscape-mobile.tablet-device #mTabChat .users-list.expanded {
  max-height: 32vh;
  overflow-y: auto;
  padding: 5px 10px 7px;
  -webkit-overflow-scrolling: touch;
}
body.landscape-mobile.tablet-device #mTabChat .users-list .user-chip {
  font-size: 12px;
  padding: 4px 10px;
}

body.landscape-mobile #mTabChat .chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
body.landscape-mobile #mTabChat .section-header {
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 11px;
}
body.landscape-mobile #mTabChat .chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 10px;
  min-height: 0;
  word-break: break-word;
}
body.landscape-mobile #mTabChat .chat-input-row {
  flex-shrink: 0;
  padding: 5px 8px;
  padding-bottom: max(5px, env(safe-area-inset-bottom));
  gap: 5px;
}
body.landscape-mobile #mTabChat .chat-input-row input { font-size: 15px; }

/* 부모의 overflow:hidden에 잘리지 않도록 fixed를 사용하되, 원래의 자연스러운 우측 하단 위치와 크기를 그대로 유지합니다. */
body.landscape-mobile #mTabChat .emoji-picker {
  position: fixed !important; /* 부모 제약을 탈출하여 잘림 방지 */
  bottom: calc(45px + env(safe-area-inset-bottom)) !important; /* 채팅 입력창 바로 위 */
  right: max(20px, env(safe-area-inset-right)) !important; /* 약간 왼쪽으로 당겨 우측 잘림 방지 */
  left: auto !important;
  width: min(296px, 90vw) !important; /* 세로모드/PC의 이모지 그리드 규격(6개)이 넉넉히 들어가는 원래 너비로 복구 */
  max-height: 220px !important; /* 원래 높이 유지 */
  z-index: 99999 !important; /* 모든 요소보다 최상단 */
}

/* 토스트 */
body.landscape-mobile #toast {
  bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 11px;
}

/* ═══════════════════════════════════════════════════════
   가로모드 플레이리스트 버튼 + 드로어
   ═══════════════════════════════════════════════════════ */

/* 세로모드·데스크톱에서는 버튼 완전 숨김 */
#lsPlaylistBtn,
#lsMylistBtn { display: none !important; }
#lsDrawer      { display: none !important; }

/* 가로모드에서만 버튼 표시 */
body.landscape-mobile #lsPlaylistBtn,
body.landscape-mobile #lsMylistBtn {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  background: rgba(124,92,252,0.15);
  border: 1px solid rgba(124,92,252,0.45);
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  white-space: nowrap;
  transition: background .2s;
  font-family: 'Inter', sans-serif;
}

body.landscape-mobile #lsMylistBtn .ls-btn-icon {
  color: #888;
  line-height: 1;
  font-size: 16px;
  transition: color 0.2s;
}

body.landscape-mobile #lsMylistBtn .ls-btn-label {
  line-height: 1;
  color: #888;
  transition: color 0.2s;
}

body.landscape-mobile #lsMylistBtn.saved {
  color: #f6c644;
  border-color: rgba(246, 198, 68, 0.55);
  background: rgba(246, 198, 68, 0.14);
}

body.landscape-mobile #lsMylistBtn.saved .ls-btn-label {
  color: #f6c644;
}

body.landscape-mobile #lsMylistBtn.saved .ls-btn-icon {
  color: #f6c644;
}

body.landscape-mobile #lsMylistBtn:disabled {
  opacity: 0.45;
  cursor: default;
}

body.landscape-mobile #lsPlaylistBtn:active,
body.landscape-mobile #lsMylistBtn:active {
  background: rgba(124,92,252,0.3);
}

@media (orientation: landscape) and (max-height: 540px) and (any-pointer: coarse) {
  body.landscape-mobile #lsMylistBtn {
    min-width: 34px;
    width: 34px;
    height: 30px;
    justify-content: center;
    padding: 0;
    gap: 0;
  }

  body.landscape-mobile #lsMylistBtn .ls-btn-label {
    display: none;
  }

  body.landscape-mobile #lsMylistBtn .ls-btn-icon {
    font-size: 15px;
  }
}

/* video-controls 가로모드: 항상 표시 (드로어 버튼 때문에) */
body.landscape-mobile .video-controls {
  height: auto !important;
  padding: 4px 8px !important;
  overflow: visible !important;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* 가로모드 투표 바 완전 숨김 */
body.landscape-mobile .m-vote-bar { display: none !important; }
/* videoHostBadge flex:1 으로 버튼들을 양 끝 정렬 */
body.landscape-mobile #videoHostBadge {
  flex: 1;
}
/* expandBtn 가로모드에서 숨김 (공간 절약) */
body.landscape-mobile .btn-expand {
  display: none !important;
}

/* ── 드로어 (center-panel 위에 절대 오버레이) ── */
body.landscape-mobile #lsDrawer {
  display: flex !important;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  flex-direction: column;
  background: var(--bg2);
  z-index: 50;
  /* 닫힌 상태: 왼쪽으로 슬라이드 아웃 */
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
body.landscape-mobile #lsDrawer.open {
  transform: translateX(0);
}

/* center-panel이 position:relative 되어야 드로어 절대위치 기준 */
body.landscape-mobile .center-panel {
  position: relative;
}

.ls-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text1);
  flex-shrink: 0;
}
.ls-drawer-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 6px;
}
.ls-drawer-close:active { background: var(--bg3); }

.ls-drawer-tabs {
  flex-shrink: 0;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--border);
}

.ls-drawer-mode-tabs {
  flex-shrink: 0;
}

.ls-drawer-mode-tabs .queue-tab-btn {
  font-size: 12px;
  padding: 8px 10px;
}

.ls-drawer-mode-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.ls-drawer-mode-panel.active {
  display: flex;
}

.ls-panel-content {
  flex-shrink: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.ls-panel-content .add-row input {
  font-size: 16px; /* iOS 자동 줌 방지 */
}

/* 검색결과 — 드로어 안에서 최대 높이 제한 */
#lsSearchResults {
  max-height: 130px;
  overflow-y: auto;
}

.ls-drawer-queue {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.ls-drawer-queue .queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

#lsDrawerMylistPanel .mylist-header-bar {
  flex-shrink: 0;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
}

#lsMylistList {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* ── 세로모드 채팅 여백 제거 보강 ─────────────────────────
   .body가 데스크톱 CSS의 flex:1을 물려받아 과도한 공간을
   차지하지 않도록 명시적으로 차단                          */
@media (max-width: 768px) and (orientation: portrait), (max-width: 1024px) and (any-pointer: coarse) and (orientation: portrait) {
  .body {
    flex: 0 0 auto !important;
  }
  #mobileTabContent {
    flex: 1 1 0 !important;
    min-height: 0 !important;
  }
}

/* ── 모바일 세로모드 재생 시간 표시 ─────────────────────── */
@media (max-width: 768px), (max-width: 1024px) and (any-pointer: coarse), (orientation: landscape) and (max-height: 1024px) and (any-pointer: coarse) {
  .mobile-time-display {
    display: none; /* 기본 숨김, 영상 재생 중일 때만 표시 */
    margin-left: auto;
    font-size: 11px;
    color: var(--text2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
  }
  .mobile-time-display.visible {
    display: flex;
  }
  .mobile-time-host {
    color: var(--text3, var(--text2));
    font-size: 10px;
    opacity: 0.7;
  }
}

/* 세로모드에서 헤더 로고 텍스트 숨김 (아이콘은 유지) */
@media (max-width: 768px) and (orientation: portrait), (max-width: 1024px) and (any-pointer: coarse) and (orientation: portrait) {
  .logo-text { display: none; }
}

/* ── 모바일 세로모드 헤더 센터: 재생 중 제목만 표시 ────── */
@media (max-width: 768px) and (orientation: portrait), (max-width: 1024px) and (any-pointer: coarse) and (orientation: portrait) {
  /* 방제목·구분자 숨김 */
  .header-center .room-name-header { display: none; }
  .header-center .mobile-hide { display: none; }

  /* 즐겨찾기 버튼 숨김 */
  #nowPlayingStarBtn { display: none !important; }

  /* header-center가 남은 공간 전부 차지 */
  .header-center {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  /* 슬라이딩 텍스트 래퍼 */
  .mobile-now-playing-wrap {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
  }

  /* 짧은 제목: 그냥 표시 / 긴 제목: marquee 애니메이션 */
  #nowPlayingHeader {
    display: inline-block;
    white-space: nowrap;
    font-size: 11px;
  }
  #nowPlayingHeader.marquee {
    animation: marquee-scroll 18s linear infinite;
    padding-left: 100%;
  }
  @keyframes marquee-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-100%); }
  }
}

/* ================================================
   모바일: 내 목록 탭 버튼 배지 위치
   ================================================ */
@media (max-width: 768px), (max-width: 1024px) and (any-pointer: coarse), (orientation: landscape) and (max-height: 1024px) and (any-pointer: coarse) {
  /* 사이드바 내 목록 탭은 PC 전용 */
  .queue-tab-btn[data-qtab="mylistPanel"] {
    display: none !important;
  }

  /* 내 목록 배지 */
  #mMylistBadge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 7px;
    font-size: 9px;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    font-weight: 700;
  }
  #mMylistBadge.visible { display: flex; }

  /* 내 목록 탭 URL/검색 패널 토글 */
  #mMylistSearchPanel { display: none; }
  #mMylistSearchPanel.active { display: flex !important; }
  #mMylistUrlPanel.hidden { display: none !important; }

  /* 모바일 폴더 시스템 */
  .mylist-folder-actions { display: flex !important; } /* 모바일에서 항상 표시 */
  .mylist-folder-header { padding: 8px 10px 7px; }
  .mylist-folder-action-btn { padding: 3px 8px; font-size: 14px; }
  .mylist-move-btn { padding: 4px 8px; font-size: 12px; }
  .mylist-addfolder-btn { padding: 3px 8px; font-size: 12px; }
  .mylist-folder-body .mylist-item { margin-left: 8px; }
  .mylist-item-btns { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  /* 모바일 체크박스 — 터치 영역 확보 */
  .mylist-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    cursor: pointer;
  }
  /* 모바일 멀티선택 액션바 — 버튼 줄바꿈 허용 */
  .mylist-multiselect-bar {
    gap: 5px;
  }
  .mylist-multiselect-btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* 자동재생/랜덤재생 버튼 — 모바일 터치 영역 확보 */
@media (max-width: 768px) {
  .mylist-folder-action-btn.autoplay-btn,
  .mylist-folder-action-btn.randomplay-btn {
    padding: 4px 9px;
    font-size: 12px;
    touch-action: manipulation;
  }
}

/* 모바일 스크롤 버튼 크기 조정 */
@media (max-width: 768px) {
  .scroll-nav-btn-group {
    bottom: 8px;
  }
  .scroll-nav-btn {
    width: 40px;
    height: 40px;
    touch-action: manipulation;
  }
  .scroll-nav-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* ── 팀버맨 로비 모바일 (영상영역에 맞게 축소) ── */
@media (max-width: 768px) {
  .timberman-lobby-dom {
    padding: 10px !important;
  }
  .timberman-lobby-dom h2 {
    font-size: 16px !important;
    margin: 5px 0 2px 0 !important;
  }
  .timberman-lobby-dom p {
    font-size: 12px !important;
    margin: 0 0 10px 0 !important;
  }
}





/* 모바일 대형 게임 전적 팝업 규격 처리 */
@media (max-width: 768px) {
  .game-stats-modal-card {
    width: 90vw !important;
    max-width: 360px !important;
    padding: 16px !important;
    border-radius: 14px !important;
  }
  .game-stats-title {
    font-size: 17px !important;
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
  }
  .game-stats-grid {
    gap: 8px !important;
  }
  .game-stats-item {
    padding: 10px 12px !important;
    border-radius: 8px !important;
  }
  .game-stats-item:hover {
    transform: none !important;
  }
  .game-stats-name {
    font-size: 14px !important;
    margin-bottom: 2px !important;
  }
  .game-stats-val {
    font-size: 12px !important;
  }
}
