@charset "UTF-8";

/* ══════════════════════════════════════════════
   반응형 (≤ 768px) — 태블릿 세로 / 모바일
══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* 사이드바: 흐름에서 빼고 fixed로 전환 */
    #sidebar {
        position: fixed;
        top: var(--header-h);
        bottom: var(--footer-h);
        left: 0;
        /* 접힌 상태: 핸들 폭만큼만 보임 */
        width: 60px;
        z-index: 90;
        cursor: pointer;
        /* 텍스트가 밀려나오지 않도록 */
        overflow: hidden;
    }

    /* 펼쳐진 상태 */
    #sidebar.sidebar-open {
        width: 100vw;
        cursor: default;
    }

    /* 사이드바 접힌 상태에서 내용 투명 처리 */
    #sidebar:not(.sidebar-open) #sidebar-title,
    #sidebar:not(.sidebar-open) #sidebar-empty,
    #sidebar:not(.sidebar-open) .record-item {
        opacity: 0;
        transition: opacity 0.2s;
    }

    /* 사이드바 열린 상태에서 내용 표시 */
    #sidebar.sidebar-open #sidebar-title,
    #sidebar.sidebar-open #sidebar-empty,
    #sidebar.sidebar-open .record-item {
        opacity: 1;
        transition: opacity 0.2s 0.15s;
        /* 슬라이드 후 페이드인 */
        white-space: normal;
    }

    /* ── 핸들 (화살표 탭) ── */
    #sidebar-handle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 50%;
        left: 0;
        width: 60px;
        transform: translateY(-50%);
        z-index: 1;
        pointer-events: none;
        /* 사이드바 클릭 통과 */
        flex-direction: column;
        gap: 6px;
        color: rgba(255, 255, 255, 0.6);
        font-size: 11px;
    }

    /* 핸들 아이콘 (chevron) */
    #sidebar-handle::before {
        content: '▶';
        font-size: 16px;
        display: block;
        color: rgba(255, 255, 255, 0.7);
    }

    /* 열렸을 때 핸들 숨김 */
    #sidebar.sidebar-open #sidebar-handle {
        display: none;
    }

    /* ── 닫기 버튼 (열렸을 때만 보임) ── */
    #sidebar-close-btn {
        display: none;
        position: absolute;
        top: 12px;
        right: 14px;
        background: rgba(255, 255, 255, 0.15);
        border: none;
        color: white;
        font-size: 20px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        z-index: 2;
        transition: background 0.2s;
        font-family: sans-serif;
    }

    #sidebar-close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    #sidebar.sidebar-open #sidebar-close-btn {
        display: flex;
    }

    /* 사이드바 타이틀 — 열렸을 때 오른쪽에 닫기버튼 자리 확보 */
    #sidebar.sidebar-open #sidebar-title {
        padding-right: 54px;
    }

    /* 메인은 사이드바가 fixed이므로 왼쪽 여백 없이 전체 너비 */
    #main {
        width: 100%;
    }

    /* 타이머 숫자 크기 조정 */
    #timer-display {
        font-size: clamp(60px, 18vw, 120px);
        margin-bottom: 30px;
    }

    /* 버튼 너비 조정 */
    #timer-btn {
        width: 70%;
        max-width: 260px;
        height: 54px;
        font-size: 18px;
    }

    /* 문구 너비 조정 */
    #phrase-display {
        width: 80%;
        font-size: 15px;
        height: auto;
        min-height: 52px;
        padding: 12px 20px;
    }

    /* 캐릭터 크기 줄임 */
    #character-wrap {
        width: 130px;
        height: 180px;
        right: 10px;
    }

    /* 사이드바 열렸을 때 메인 위에 오버레이 어둡게 */
    #sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 89;
        /* sidebar(90) 아래 */
    }

    #sidebar-backdrop.show {
        display: block;
    }
}