* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #0a0a0f; color: #fff; font-family: 'Malgun Gothic', sans-serif; }

.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px; background: #12121a; border-bottom: 1px solid #222;
    position: sticky; top: 0; z-index: 900;
}
.logo { font-size: 20px; font-weight: bold; color: #00e5ff; letter-spacing: 4px; }
.update-time { font-size: 12px; color: #666; }

.market-bar {
    display: flex; gap: 30px; padding: 10px 20px;
    background: #15151f; border-bottom: 1px solid #1e1e2e;
}
.market-item { display: flex; flex-direction: column; }
.market-label { font-size: 11px; color: #888; }
.market-value { font-size: 16px; font-weight: bold; margin-top: 2px; }
.up { color: #ff4444; }
.down { color: #4488ff; }
.neutral { color: #aaa; }

.legend {
    display: flex; gap: 10px; padding: 8px 20px;
    background: #0f0f18; border-bottom: 1px solid #1e1e2e;
    font-size: 11px; color: #888; flex-wrap: wrap; align-items: center;
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-box { width: 12px; height: 12px; border-radius: 2px; }

.board {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 12px; align-items: flex-start;
}

.block-wrap {
    position: relative;
    border-radius: 4px;
    background: #2a2a2a;
    flex-shrink: 0;
    overflow: hidden;
}

.block {
    position: absolute;
    top: 0; left: 0;
    border-radius: 4px;
    cursor: pointer;
    display: flex; flex-direction: column;
    justify-content: flex-end;
    padding: 6px;
    transition: all 0.8s ease;
    overflow: hidden;
    border: 1px solid transparent;
}
.block:hover { filter: brightness(1.3); z-index: 10; }

.block .name {
    font-size: 11px; font-weight: bold;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.block .rate { font-size: 12px; font-weight: bold; margin-top: 1px; }
.block .vol  { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 1px; }

.block .rank-badge {
    position: absolute; top: 4px; left: 5px;
    font-size: 10px; color: rgba(255,255,255,0.55);
}
.block .rank-change {
    position: absolute; top: 4px; right: 5px; font-size: 10px;
}

@keyframes sparkle {
    0%   { box-shadow: 0 0 6px 3px gold; border-color: gold; }
    50%  { box-shadow: 0 0 20px 8px gold; border-color: #ffe066; }
    100% { box-shadow: 0 0 6px 3px gold; border-color: gold; }
}
.new-entry { animation: sparkle 1.2s infinite; }
.new-entry::after {
    content: '★ 신규진입';
    position: absolute; bottom: 4px; right: 5px;
    font-size: 9px; color: gold;
}

.tab-bar {
    display: flex; gap: 4px; padding: 8px 20px;
    background: #12121a; border-bottom: 1px solid #222;
}
.tab-btn {
    padding: 6px 16px; border-radius: 4px; border: none;
    background: #1e1e2e; color: #888; cursor: pointer;
    font-size: 12px; font-family: 'Malgun Gothic', sans-serif;
    transition: all 0.2s;
}
.tab-btn:hover { background: #2a2a3e; color: #ccc; }
.tab-btn.active { background: #00e5ff; color: #000; font-weight: bold; }

/* 탭 그룹별 색상 (왼쪽 테두리로 구분) */
.tab-btn.group-content {
    border-top: 2px solid #ffb74d;   /* 콘텐츠: 주황 */
}
.tab-btn.group-data {
    border-top: 2px solid #00e5ff;   /* 데이터: 청록 */
}
.tab-btn.group-personal {
    border-top: 2px solid #b388ff;   /* 개인: 보라 */
}

/* 활성 탭은 해당 그룹 색으로 채움 */
.tab-btn.group-content.active { background: #ffb74d; color: #1a1a1a; }
.tab-btn.group-data.active    { background: #00e5ff; color: #1a1a1a; }
.tab-btn.group-personal.active{ background: #b388ff; color: #1a1a1a; }

.tab-btn { flex-shrink: 0; white-space: nowrap; }

/* 모바일 햄버거 버튼 + 서랍 배경 (기본은 데스크톱이라 숨김) */
.hamburger {
    display: none;
    background: none; border: none; color: #fff;
    font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.menu-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
}

/* 표(테이블) 좌우 스크롤 컨테이너 - 좁은 화면에서 글자가 세로로 쪼개지는 것 방지 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { white-space: nowrap; }

/* 섹터별 거래대금 화면(왼쪽 순위 + 오른쪽 전광판) 레이아웃 */
.sector-layout { display: flex; height: calc(100vh - 200px); gap: 0; }
.sector-sidebar {
    width: 220px; min-width: 220px; background: #12121a;
    border-right: 1px solid #222; overflow-y: auto;
}
.sector-board-wrap { flex: 1; overflow-y: auto; padding: 12px; }

/* ===== 반응형 (태블릿) ===== */
@media (max-width: 768px) {
    .header { padding: 8px 12px; }
    .logo { font-size: 17px; letter-spacing: 2px; }

    .hamburger { display: block; }

    .market-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-left: 12px; padding-right: 12px;
        gap: 18px;
    }
    .market-item { flex-shrink: 0; }

    /* 메뉴: 왼쪽에서 밀려나오는 서랍 */
    .tab-bar {
        position: fixed; top: 0; left: 0;
        width: 240px; max-width: 80%; height: 100%;
        flex-direction: column; align-items: stretch; gap: 6px;
        padding: 16px 12px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1100; overflow-y: auto;
        border-bottom: none; border-right: 1px solid #222;
    }
    .tab-bar.open { transform: translateX(0); }
    .menu-backdrop.open { display: block; }

    .tab-btn {
        width: 100%; text-align: left;
        padding: 12px 14px; font-size: 14px;
        border-top: none; border-left: 3px solid transparent;
    }
    .tab-btn.group-content { border-left-color: #ffb74d; }
    .tab-btn.group-data    { border-left-color: #00e5ff; }
    .tab-btn.group-personal{ border-left-color: #b388ff; }

    .board { padding: 8px; gap: 4px; }
    .legend { padding: 8px 12px; }
}

/* ===== 반응형 (모바일) ===== */
@media (max-width: 480px) {
    /* 섹터 화면: 좌우 배치를 위/아래로 전환 */
    .sector-layout { flex-direction: column; height: auto; }
    .sector-sidebar {
        width: 100%; min-width: 0;
        max-height: 180px; border-right: none;
        border-bottom: 1px solid #222;
    }
    .sector-board-wrap { padding: 8px; }

    .market-value { font-size: 14px; }

    /* 블록이 커진 만큼 내부 글씨도 키워 가독성 확보 */
    .block .name { font-size: 13px; }
    .block .rate { font-size: 14px; }
    .block .vol  { font-size: 11px; }
    .block .rank-badge { font-size: 11px; }
}