/**
 * 털보티비 모바일 스타일 (최종본)
 * 빠른티비 스타일 참고, 흰색 톤, 단순한 구조
 *
 * 원칙:
 * - 뷰포트 단위(vh/dvh) 사용
 * - flex chain 최소화 (단순 block + padding)
 * - position:fixed for chrome
 * - 콘텐츠 스크롤은 body 자연 스크롤
 */

/* ================================================================
   1. 리셋
   ================================================================ */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html {
    -webkit-text-size-adjust: 100%;
}
body {
    margin: 0;
    padding: 0;
    padding-top: 136px;   /* 상단 헤더(60) + 카테고리(76) */
    padding-bottom: 66px; /* 하단 네비(60) + 여백 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #212529;
    background: #f5f6f8;
    -webkit-overflow-scrolling: touch;
    min-height: 100vh;
    min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; }
button { cursor: pointer; }

/* ================================================================
   2. 상단 헤더 (position:fixed, 60px)
   ================================================================ */
.m-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-bottom: 1px solid #eee;
}
.m-hamburger {
    background: none;
    border: none;
    width: 44px;
    height: 44px;
    font-size: 22px;
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}
.m-hamburger:active { background: #f0f0f0; }
.m-header-logo {
    flex: 1;
    text-align: center;
}
.m-header-logo img {
    height: 34px;
    display: inline-block;
    vertical-align: middle;
}
.m-header-right a {
    width: 44px;
    height: 44px;
    font-size: 20px;
    color: #212529;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}
.m-header-right a:active { background: #f0f0f0; }

/* ================================================================
   3. 카테고리 4-아이콘 (position:fixed, top:60, 76px)
   ================================================================ */
.m-cat-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    height: 76px;
    background: #ffffff;
    display: flex;
    align-items: center;
    padding: 8px 6px;
    gap: 6px;
    z-index: 99;
    border-bottom: 1px solid #eee;
}
.m-cat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    color: #495057;
    border-radius: 10px;
}
.m-cat-item:active { background: #f8f9fa; }
.m-cat-item:hover, .m-cat-item:focus, .m-cat-item:visited {
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}
.m-cat-item span, .m-cat-item p { text-decoration: none !important; border-bottom: none !important; }
.m-cat-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #dc3545, #b52a37);
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(220,53,69,0.28);
}
.m-cat-item:nth-child(2) .m-cat-icon {
    background: linear-gradient(135deg, #ffc107, #d69e00);
    box-shadow: 0 2px 6px rgba(255,193,7,0.28);
}
.m-cat-item:nth-child(3) .m-cat-icon {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
    box-shadow: 0 2px 6px rgba(13,110,253,0.28);
}
.m-cat-item:nth-child(4) .m-cat-icon {
    background: linear-gradient(135deg, #198754, #146c43);
    box-shadow: 0 2px 6px rgba(25,135,84,0.28);
}
.m-cat-item p {
    font-size: 11px;
    font-weight: 600;
    color: #212529;
    text-align: center;
    line-height: 1.2;
    margin: 0;
}

/* ================================================================
   4. 메인 콘텐츠 컨테이너 (자연 스크롤, 헤더/네비 padding으로 처리)
   ================================================================ */
.m-main {
    display: block;
    width: 100%;
    padding: 10px;
    background: transparent;
}

/* 홈: 라이브 iframe */
.m-main-iframe {
    display: block;
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 12px;
    background: #000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 12px;
}

/* 홈: 하이라이트 섹션 */
.m-hl-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 12px;
}
.m-hl-header {
    font-size: 15px;
    font-weight: 700;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #212529;
    margin-bottom: 10px;
}
.m-hl-header i { color: #dc3545; }
.m-hl-scroll {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.m-hl-scroll::-webkit-scrollbar { display: none; }
.m-hl-card {
    flex: 0 0 130px;
    width: 130px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}
.m-hl-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #ddd;
    overflow: hidden;
}
.m-hl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-hl-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: rgba(220,53,69,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.m-hl-play::before {
    content: "";
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 7px solid #fff;
    margin-left: 2px;
}
.m-hl-title {
    padding: 6px 8px 8px;
    font-size: 11px;
    line-height: 1.3;
    color: #212529;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3em;
}

/* ================================================================
   5. 범용 페이지 스타일 (하이라이트/게시판/폼 등)
   ================================================================ */

/* 하이라이트 페이지 그리드 (2열 카드) */
.video-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
}
.video-item {
    width: 100% !important;
    background: #fff !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}
.video-thumb {
    position: relative !important;
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    overflow: hidden !important;
    background: #ddd !important;
    cursor: pointer !important;
}
.video-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.play-button {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 44px !important;
    height: 44px !important;
    background: rgba(220,53,69,0.9) !important;
    border-radius: 50% !important;
}
.play-button::before {
    content: "" !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-40%, -50%) !important;
    width: 0 !important;
    height: 0 !important;
    border-top: 7px solid transparent !important;
    border-bottom: 7px solid transparent !important;
    border-left: 12px solid #fff !important;
}
.video-title {
    padding: 8px 10px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    color: #212529 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    min-height: 3.5em !important;
}
.video-date {
    padding: 0 10px 8px !important;
    font-size: 11px !important;
    color: #6c757d !important;
}

/* iframe 자동 반응형 */
iframe:not(.m-main-iframe):not(#youtube-player) {
    max-width: 100% !important;
    width: 100% !important;
    border: none !important;
    border-radius: 8px !important;
    background: #fff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}

/* 게시판 리스트 → 카드 */
.board_list, .tbl_head01, .tbl_wrap {
    background: transparent !important;
    width: 100% !important;
}
.board_list table, .tbl_head01 table, .tbl_wrap table {
    width: 100% !important;
    background: transparent !important;
    border-collapse: separate;
    border-spacing: 0;
}
.board_list thead, .tbl_head01 thead { display: none !important; }
.board_list tbody tr, .tbl_head01 tbody tr {
    display: block !important;
    background: #fff !important;
    border-radius: 10px !important;
    margin-bottom: 8px !important;
    padding: 12px 14px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}
.board_list tbody td, .tbl_head01 tbody td {
    display: inline-block !important;
    border: none !important;
    padding: 0 6px 0 0 !important;
    font-size: 12px !important;
    color: #6c757d !important;
    background: transparent !important;
}
.board_list td.td_subject, .board_list td.subject {
    display: block !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #212529 !important;
    padding-bottom: 6px !important;
}

/* 폼 */
input[type="text"], input[type="password"], input[type="email"],
input[type="tel"], input[type="number"], input[type="search"],
textarea, select {
    font-size: 16px !important;
    min-height: 46px !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    border: 1px solid #dee2e6 !important;
    background: #fff !important;
    width: 100%;
    max-width: 100%;
}
button:not(.close-btn):not(.m-hamburger):not(.btn-close),
input[type="submit"], input[type="button"], .btn {
    min-height: 46px !important;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    border: none;
}

/* 페이지네이션 */
.pg_wrap, .pg {
    text-align: center !important;
    padding: 12px 0 !important;
    margin: 12px 0 !important;
}
.pg_page, .pg_current {
    display: inline-block !important;
    padding: 8px 12px !important;
    margin: 0 2px !important;
    border-radius: 6px !important;
    background: #fff !important;
    color: #212529 !important;
    text-decoration: none !important;
    font-size: 13px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    min-height: 36px !important;
}
.pg_current { background: #dc3545 !important; color: #fff !important; }
.pg_info {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    margin-top: 8px;
}

/* 게시글 본문 */
#bo_v_atc, .bo_v_cont {
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    font-size: 14px;
    line-height: 1.7;
}
#bo_v_atc img, .bo_v_cont img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 6px;
    margin: 8px 0;
}

/* ================================================================
   6. 하단 고정 네비 (position:fixed, bottom, 60px)
   ================================================================ */
.m-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    z-index: 90;
    padding-bottom: env(safe-area-inset-bottom);
}
.m-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 0;
    color: #6c757d;
    font-size: 10px;
    font-weight: 600;
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}
.m-bottom-nav a:hover, .m-bottom-nav a:focus, .m-bottom-nav a:visited {
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}
.m-bottom-nav a i { font-size: 20px; }
.m-bottom-nav a span { text-decoration: none !important; border-bottom: none !important; }
.m-bottom-nav a:active, .m-bottom-nav a.active { color: #dc3545; }
.m-bottom-nav .live-badge { position: relative; }
.m-bottom-nav .live-badge::after {
    content: "";
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    width: 6px;
    height: 6px;
    background: #dc3545;
    border-radius: 50%;
    animation: livePulse 1.5s infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.4); }
}

/* ================================================================
   7. Offcanvas 사이드 메뉴
   ================================================================ */
.m-offcanvas {
    max-width: 320px;
    background: #ffffff;
    border-right: 1px solid #eee;
}
.m-offcanvas .offcanvas-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.m-offcanvas .offcanvas-body {
    padding: 0;
    overflow-y: auto;
}

.m-user-box {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}
.m-user-nick {
    font-size: 15px;
    font-weight: 700;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.m-user-nick i { font-size: 22px; color: #6c757d; }
.m-user-actions { display: flex; gap: 6px; }
.m-user-actions a {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 13px;
    color: #212529;
    font-weight: 500;
}
.m-user-box.guest {
    display: flex;
    gap: 6px;
}
.m-btn-login, .m-btn-register {
    flex: 1;
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}
.m-btn-login { background: #212529; color: #fff; }
.m-btn-register { background: #fff; color: #212529; border: 1px solid #dee2e6; }

.m-menu-list li { border-bottom: 1px solid #f5f5f5; }
.m-menu-list li:last-child { border-bottom: none; }
.m-menu-list li > a,
.m-menu-list li > .m-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    color: #212529;
    text-decoration: none !important;
    box-shadow: none !important;
    font-size: 15px;
    font-weight: 500;
}
.m-menu-list li > a i:first-child,
.m-menu-list li > .m-menu-header > i:first-child {
    width: 20px;
    font-size: 16px;
    color: #6c757d;
}
.m-menu-list li > a:active { background: #f8f9fa; }
.m-menu-list .m-menu-header {
    justify-content: space-between;
}
.m-menu-list .m-menu-header .arrow {
    margin-left: auto;
    font-size: 12px;
    color: #adb5bd;
    transition: transform 0.2s;
}
.m-menu-list li.open .m-menu-header .arrow { transform: rotate(180deg); }
.m-menu-list .m-menu-sub {
    display: none;
    background: #f8f9fa;
    padding: 6px 0;
}
.m-menu-list li.open .m-menu-sub { display: block; }
.m-menu-list .m-menu-sub a {
    display: block;
    padding: 12px 20px 12px 52px;
    color: #495057;
    font-size: 14px;
    text-decoration: none !important;
    box-shadow: none !important;
}
.m-menu-list a:hover, .m-menu-list a:focus, .m-menu-list a:visited,
.m-menu-list .m-menu-header:hover, .m-menu-list .m-menu-header:focus {
    text-decoration: none !important;
    box-shadow: none !important;
}
.m-menu-list a span, .m-menu-list .m-menu-header span,
.m-menu-list a p, .m-menu-list .m-menu-header p {
    text-decoration: none !important;
    border-bottom: none !important;
}
.m-badge {
    background: #dc3545;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

/* ================================================================
   8. 모달 (동영상)
   ================================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.modal[style*="block"] { display: flex !important; }
.modal-content {
    background: #fff;
    width: 95%;
    max-width: 600px;
    border-radius: 12px;
    overflow: hidden;
}
.modal-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #212529;
    color: #fff;
}
.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    padding-right: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}
.close-btn {
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    background: none;
    border: none;
}
.player-container {
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
}
#youtube-player {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}

/* ================================================================
   9. 원본 데스크톱 요소 완전 숨김 (혹시 남아있는 잔재)
   ================================================================ */
#hd_pop, .quick, .top_line, .header, .aside, .asideb, .id_box,
.footer, .con_banner, u-chat, #ol_before, .ol,
.wrap > .inner {
    /* 데스크톱 사이드바/헤더 요소들 완전 숨김 */
}

/* 특정하게 숨김 (모바일 뷰) */
.wrap > .top_line,
.wrap > .header,
.wrap > .quick,
.wrap .aside,
.wrap .asideb,
.wrap .id_box,
.wrap > div[style*="height:90px"],
.wrap > div[style*="height: 90px"],
.wrap .con_banner,
u-chat,
#ol_before {
    display: none !important;
}

/* ================================================================
   10. 데스크톱 HTML의 모바일 chrome 표시 제어
   dt-mobile-only 클래스: 좁은 뷰포트(991px 이하)에서만 표시
   ================================================================ */
.dt-mobile-only {
    display: none;
}
@media (max-width: 991px) {
    .dt-mobile-only { display: block !important; }
    .m-bottom-nav.dt-mobile-only { display: flex !important; }

    /* 좁은 뷰포트에서 데스크톱 콘텐츠 숨김 (desktop HTML로 봐도 mobile 처럼) */
    body > *:not(.wrap):not(.m-bottom-nav):not(.offcanvas):not(script):not(style) { }
    .top_line, .header, .quick, .aside, .asideb, .id_box, .con_banner,
    .wrap > .top_line, .wrap > .header, .wrap > .quick,
    .wrap > div[style*="height:90px"],
    .wrap > div[style*="height: 90px"],
    u-chat, #ol_before, .footer, #ft {
        display: none !important;
    }

    /* .wrap 리셋 */
    .wrap { min-width: 0 !important; width: 100% !important; }

    /* body는 mobile chrome 있으므로 padding */
    body {
        padding-top: 136px !important;
        padding-bottom: 66px !important;
        background: #f5f6f8 !important;
    }

    /* content 영역 */
    .content { width: 100% !important; padding: 10px !important; float: none !important; }
}

/* ================================================================
   11. 가위바위보 (rps) - Bootstrap box-sizing 리셋 무효화
   Bootstrap의 * { box-sizing: border-box }가 rps.css 고정 좌표와 충돌하는 것 방지
   ================================================================ */
.rps_wrap, .rps_wrap *,
.rps_wrap *::before, .rps_wrap *::after {
    box-sizing: content-box !important;
}
