/* 전역 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f0f0f0;
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('images/bg1.png') no-repeat center center;
    background-size: cover;
    z-index: 0;
}

body.hide-bg::before {
    display: none;
}

/* 게임 컨테이너 */
#gameContainer {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: transparent;
    margin: 0;
    padding: 0;
    z-index: 1;
}

/* 레이어 공통 스타일 */
.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* 여기를 수정 */
    background-color: transparent;
}

/* 활성화된 레이어 표시 - !important 추가 */
.layer.active {
    display: block !important;
}

/* 로딩 레이어 */
#loadingLayer {
    z-index: 1000;
    background-color: #2c3e50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-text {
    font-size: 24px;
    margin-bottom: 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 시작 레이어 스타일 */
#startLayer {
    background-color: transparent;
    z-index: 100;
    position: relative;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
}

.start-content {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo {
    position: absolute;
    top: 10vh;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 350px;
    z-index: 3;
}

.start-button-area {
    position: absolute;
    top: 75vh;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 300px;
    z-index: 3;
    display: flex; /* 수정 */
    flex-direction: column; /* 수정 */
    align-items: center; /* 수정 */
}

.start-button {
    width: 80%; /* 부모 요소의 80% 너비 */
    height: auto; /* 비율에 맞게 높이 자동 조정 */
    cursor: pointer; /* 마우스 오버 시 커서 변경 */
    transition: transform 0.2s ease; /* 부드러운 변형 효과 */
    position: relative; /* 상대적 위치 지정 */
    z-index: 4; /* 레이어 순서 */
    -webkit-tap-highlight-color: transparent; /* 탭 시 하이라이트 효과 제거 (모바일) */
    touch-action: manipulation; /* 터치 동작 최적화 */
}

.start-button img {
    width: 100%; /* 부모 요소의 전체 너비 사용 */
    height: auto; /* 비율에 맞게 높이 자동 조정 */
    display: block; /* 블록 요소로 표시하여 여백 제거 */
}


#startBtn:hover, #startBtn:active {
    transform: scale(1.05);
}

.player-animation {
    position: absolute;
    top: -65px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    background: url('images/playerr.png') no-repeat center center;
    background-size: contain;
    animation: playerJump 1.5s infinite ease-in-out;
    z-index: 3;
}

@keyframes playerJump {
    0% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-30px); }
    100% { transform: translateX(-50%) translateY(0); }
}

.bottom-buttons {
    position: absolute;
    bottom: 8vh;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 10vw;
    z-index: 3;
}

.bottom-buttons img {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.bottom-buttons img:hover, .bottom-buttons img:active {
    transform: scale(1.1);
}

/* 게임 레이어 */
#gameLayer {
    background-color: #87CEEB; /* 하늘색 배경 */
    z-index: 200;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 201;
}

/* 게임 UI */
#gameUI {
    position: absolute;
    top: 60px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 202;
    pointer-events: none;
}

/* 게임 버튼 스타일 */
.game-button {
    pointer-events: auto;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.game-button:hover, .game-button:active {
    transform: scale(1.1);
    background-color: rgba(0, 0, 0, 0.7);
}

/* 일시 정지 버튼 */
#pauseBtn {
    position: absolute;
    top: 10px;
    right: 20px;
}

/* 진행 바 공통 스타일 */
.progress-bar {
    width: 60px;
    height: 200px;
    background-color: rgba(20, 20, 20, 0.6);
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    margin: 0 10px;
    border: 3px solid rgba(255, 255, 255, 0.7);
    padding: 3px;
    box-sizing: border-box;
}

/* 에너지 바 */
#energyBar {
    margin-left: 10px;
    width: 70px;
}

#energyFill {
    width: calc(100% - 6px);
    height: 100%;
    background-color: rgba(52, 152, 219, 0.8); /* 반투명 파란색 */
    position: absolute;
    bottom: 3px;
    left: 3px;
    max-height: calc(100% - 6px);
    transition: height 0.3s, background-color 0.5s;
    border-radius: 10px;
}

/* 높이 바 */
#heightBar {
    margin-right: 10px;
    width: 70px;
}

#heightFill {
    width: calc(100% - 6px);
    height: 0%;
    background-color: rgba(241, 196, 15, 0.8); /* 반투명 노란색 */
    position: absolute;
    bottom: 3px;
    left: 3px;
    max-height: calc(100% - 6px);
    transition: height 0.3s;
    border-radius: 10px;
}

#heightValue {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.progress-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 8px;
}

.progress-icon {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.7);
}

/* 컨트롤 영역 */
#controlArea {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: space-between;
    z-index: 202;
}

.control-button {
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.control-button:active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* 게임오버 레이어 */
#gameOverLayer {
    background-color: rgba(0, 0, 0, 0.7); /* 반투명 배경 */
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute; /* 절대 위치 설정 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.gameover-content {
    text-align: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    width: 80%;
    max-width: 400px;
    position: relative;
    z-index: 1001;
}

.gameover-content h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.score-display {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 16px;
    color: #bdc3c7;
    margin-bottom: 5px;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    color: #f1c40f;
}

.button-container {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
}

.ui-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    margin: 10px 5px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    min-width: 120px;
    position: relative;
    z-index: 1001;
}

.ui-button:hover, .ui-button:active {
    background-color: #2980b9;
    transform: scale(1.05);
}

/* 전체화면 버튼 */
#fullscreenBtn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid white;
    border-radius: 5px;
    cursor: pointer;
    z-index: 10;
    font-size: 14px;
    transition: all 0.2s ease;
}

#fullscreenBtn:hover, #fullscreenBtn:active {
    background-color: rgba(0, 0, 0, 0.8);
}

/* 반응형 스타일 */
@media (max-width: 768px) {
    .progress-bar {
        width: 20px;
        height: 150px;
    }
    
    .gameover-content h2 {
        font-size: 28px;
    }
    
    .score-value {
        font-size: 24px;
    }
    
    .ui-button {
        font-size: 16px;
        padding: 10px 16px;
    }
    
    /* 모바일에서 컨트롤 영역 높이 증가 */
    #controlArea {
        height: 120px;
    }
}

/* 가로 모드 대응 */
@media (orientation: landscape) {
    .progress-bar {
        height: 120px;
    }
    
    #controlArea {
        height: 80px;
    }
    
    .bottom-buttons img {
        width: 50px;
        height: 50px;
    }
    
    .logo {
        top: 5vh;
        max-width: 250px;
    }
    
    .start-button-area {
        top: 50vh;
    }
}

/* 작은 화면 대응 */
@media (max-height: 500px) {
    .progress-bar {
        height: 100px;
    }
    
    .progress-label {
        font-size: 10px;
        bottom: -18px;
    }
    
    #controlArea {
        height: 60px;
    }
    
    .control-button {
        font-size: 18px;
    }
}

/* 게임오버 레이어 특별 스타일 추가 */
#gameOverLayer.active {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 1000 !important; /* 최상위 z-index로 설정 */
    background-color: rgba(0, 0, 0, 0.7) !important; /* 반투명 배경 유지 */
}
