body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

/* 찬송가 플레이어 컨트롤 스타일 */
.controls {
    position: fixed;
    top: 90px;  /* 헤더 높이 */
    left: 0;
    right: 0;
    background: #f4f3ef;
    padding: 8px 15px 15px 15px;
    box-shadow: none;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    gap: 5px;
}

/* 검색 영역 */
.search-area {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#hymn-select {
    padding: 6px;  /* 패딩 줄임 */
    min-width: 150px;
    font-size: 14px;
    background: #f4f3ef;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 키 조절 영역 */
.key-controls {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;  /* 간격 줄임 */
}

.key-controls button {
    padding: 6px 12px;  /* 패딩 줄임 */
    font-size: 14px;
    min-width: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f4f3ef;
    cursor: pointer;
}

.key-controls button:hover {
    background: #e8e8e8;
}

#current-key {
    font-size: 14px;
    min-width: 25px;
}

/* 프리뷰 컨테이너 */
.preview-container {
    margin-top: 140px;  /* 헤더(70px) + 컨트롤 영역 높이(70px) */
    margin-bottom: 20px;
    text-align: center;
    max-width: 100%;
    overflow-x: auto;
}

.preview-image {
    max-height: calc(100vh - 170px);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 90vw;
}

/* 2장 이상일 때의 크기 조정 */
.preview-container:has(.preview-image:nth-child(2)) .preview-image {
    max-height: 85vh;
    max-width: min(calc(((100vw - 100px) / 3) * 1.25), calc(85vh * 0.7));
}

/* 큰 화면에서의 최대 크기 제한 */
@media screen and (min-width: 1600px) {
    .preview-container:has(.preview-image:nth-child(2)) .preview-image {
        max-width: min(625px, calc(85vh * 0.7));
    }
}

/* 작은 화면에서의 조정 */
@media screen and (max-width: 1200px) {
    .preview-container:has(.preview-image:nth-child(2)) .preview-image {
        max-width: min(calc((100vw - 80px) / 2), calc(85vh * 0.7));
    }
}

/* 모바일 환경을 위한 미디어 쿼리 */
@media screen and (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 10px 15px 20px 15px;
        top: 90px;  /* 헤더 높이를 PC와 동일하게 설정 */
    }

    .search-area {
        grid-column: 1;
        grid-row: 1;
    }

    #hymn-select {
        font-size: 14px;
        padding: 8px;
        min-width: 180px;
    }

    .key-controls {
        grid-column: 1;
        grid-row: 2;
        display: flex;
        justify-content: center;
        gap: 10px;
    }

    .key-controls button {
        font-size: 16px;
        padding: 8px 16px;
        min-width: 40px;
    }

    #current-key {
        font-size: 16px;
        min-width: 30px;
    }

    .preview-container {
        margin-top: 190px;  /* 헤더(90px) + 컨트롤 영역 높이(100px) */
    }
}

/* 더 작은 화면을 위한 추가 조정 */
@media screen and (max-width: 375px) {
    .controls {
        padding: 12px 15px 25px 15px;
    }

    #hymn-select {
        font-size: 14px;
    }

    .key-controls button {
        font-size: 16px;
        padding: 10px 20px;
    }

    #current-key {
        font-size: 16px;
    }

    .preview-container {
        margin-top: 200px;  /* 더 작은 화면에서의 여백 조정 */
    }
}

/* 스크롤바 스타일 */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
    border: 3px solid #f1f1f1;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

/* 컨테이너 내부 여백 조정 */
@media screen and (min-width: 1200px) {
    .preview-container {
        padding: 20px 40px;
    }
}

#hymn-select:focus {
    outline: none;
    border-color: #4a90e2;
}

.save-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    margin: 0;
    background-color: white;
    color: #333333;
    min-width: 50px;
    border: 1.5px solid #666666;
    font-weight: normal;
    padding: 8px 15px;
    z-index: 90;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.save-btn:hover {
    background-color: #f8f8f8;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* 로고 컨테이너 스타일 */
.logo-container {
    text-align: center;
    margin: 20px 0;
}

.logo-container .logo {
    width: 15%;  /* 400% 줄임 (100% / 4) */
    height: auto;
    max-width: 200px;  /* 최대 너비 제한 */
    margin: 0 auto;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #002937;
    padding: 15px 0;
    border-radius: 5px;
    min-width: 200px;
    z-index: 1002;  /* z-index 값을 높임 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 모바일 환경에서의 드롭다운 메뉴 */
@media screen and (max-width: 768px) {
    .nav-links .dropdown-menu {
        position: static;
        transform: none;
        width: 100%;
        background-color: #002937;
        margin-top: 2px;
        padding: 0;
        box-shadow: none;
        display: none;
        max-height: none;
        overflow: visible;
        z-index: 1002;  /* 모바일에서도 z-index 유지 */
    }
}
