body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #222;
    font-family: 'Malgun Gothic', sans-serif;
}

#app {
    width: 1500px;
    height: 1080px;
    position: relative;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#main-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: auto;
}

#main-screen .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    pointer-events: none; 
}

.title-overlay {
    position: relative;
    z-index: 52;
    max-width: 100%;
    margin-bottom: 40px;
    animation: floatAnimation 3s ease-in-out infinite;
    pointer-events: none; 
}

#main-screen .start-btn {
    position: relative;
    z-index: 9999;
    top: -120px;
    padding: 15px 40px;
    font-size: 24px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 12px;
    border: 3px solid #000;
    background: rgba(255, 255, 255, 0.9);
    pointer-events: auto !important;
}

#affinity-bar-container {
    position: absolute;
    top: 60px;
    left: 50px;
    width: 35px;
    height: 600px;
    background: rgba(0,0,0,0.6);
    z-index: 5;
    border: 5px solid #000;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#affinity-bar {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
}

#affinity-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: #ff4757;
    transition: height 0.4s ease, background-color 0.4s ease;
}

#affinity-title {
    position: absolute;
    top: 660px;
    color: #ff4757;
    font-weight: 900;
    font-size: 50px;
    text-shadow: 
        -3px -3px 0 #000,
        0px -3px 0 #000,
        3px -3px 0 #000,
        -3px 0px 0 #000,
        3px 0px 0 #000,
        -3px 3px 0 #000,
        0px 3px 0 #000,
        3px 3px 0 #000;
    width: 200px;
    text-align: left;
    left: 270%;
    transform: translateX(-50%);
    white-space: nowrap;
}

#affinity-text {
    position: absolute;
    bottom: -55px;
    color: #fff;
    font-weight: 900;
    font-size: 32px;
    text-shadow: 
        -3px -3px 0 #000,
        0px -3px 0 #000,
        3px -3px 0 #000,
        -3px 0px 0 #000,
        3px 0px 0 #000,
        -3px 3px 0 #000,
        0px 3px 0 #000,
        3px 3px 0 #000;
    width: 100px;
    text-align: center;
    left: 50%;
    transform: translateX(-50%);
}

#dialog-box {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    height: 220px;
    background: rgba(0, 0, 0, 0.75);
    border: 5px solid #000;
    border-radius: 15px;
    z-index: 6;
    color: #fff;
    padding: 40px;
    box-sizing: border-box;
    cursor: pointer;
}

#dialog-text {
    margin: 0;
    font-size: 36px;
    line-height: 1.6;
}

#ending-dialog-box {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    height: 220px;
    background: rgba(0, 0, 0, 0.85);
    border: 5px solid #000;
    border-radius: 15px;
    z-index: 10;
    color: #fff;
    padding: 40px;
    box-sizing: border-box;
    cursor: pointer;
}

#ending-dialog-text {
    margin: 0;
    font-size: 36px;
    line-height: 1.6;
}

#choice-box {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 25px;
    z-index: 7;
    width: 65%;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.choice-btn {
    padding: 30px;
    font-size: 34px;
    background: rgba(255,255,255,0.95);
    color: #111;
    border: 3px solid #555;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s;
    font-weight: bold;
}

.choice-btn:active {
    transform: scale(0.98);
}

#ending-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
  background: transparent;
    pointer-events: auto;
}

#ending-overlay {
    position: absolute !important;
    left: 40px !important;
    bottom: -100px !important;
    width: 600px !important;
    max-width: 600px !important;
    height: auto !important;
    object-fit: contain !important;
    z-index: 21 !important;
    pointer-events: none !important;
}

#restart-btn {
    position: absolute;
    right: 50px;
    bottom: 50px;
    z-index: 22;
    padding: 15px 40px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 12px;
    border: 3px solid #000;
    background: #fff;
    pointer-events: auto;
}

.char {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 98%;
    max-height: 1050px;
    object-fit: contain;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
}

#affinity-popup {
    position: absolute;
    top: 35%;
    left: 70%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    font-weight: 900;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    text-shadow: 
        -3px -3px 0 #000,
        0px -3px 0 #000,
        3px -3px 0 #000,
        -3px 0px 0 #000,
        3px 0px 0 #000,
        -3px 3px 0 #000,
        0px 3px 0 #000,
        3px 3px 0 #000;
}

#affinity-popup.show {
    opacity: 1;
    transform: translate(-50%, -60%);
}

@keyframes floatAnimation {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.title-overlay, #ending-overlay {
    animation: floatAnimation 3s ease-in-out infinite;
}

#game-screen .bg,
#bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
    pointer-events: none;
}

#ending-screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#ending-screen img, 
#ending-bg, 
.ending-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
}

/* 엔딩 크레딧 전체 컨테이너 */
#credit-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* 영역 밖 글자 숨김 */
    pointer-events: none; /* 클릭 이벤트 통과 */
    z-index: 25;
}

/* 스크롤되는 크레딧 영역 및 색상 설정 */
#credit-scroll {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 100%; /* 화면 아래쪽 밖에서 시작 */
    
    /* [색상 수정] 크레딧 일반 글자 색상 (원하는 HEX/RGB 코드로 변경하세요) */
    color: #fff; 
    
    font-size: 24px;
    line-height: 2.2;
    font-weight: bold;
    0
}

/* [색상 수정] 크레딧 내부 제목/타이틀 색상 (선택 사항) */
#credit-scroll h1,
#credit-scroll h2,
#credit-scroll .credit-title {
    color: #fff; /* 타이틀 글자 색상 (예: 연한 노란색) */
    font-size: 32px;
    margin-top: 30px;
    margin-bottom: 10px;
}

/* 애니메이션 동작 클래스 */
.animate-credits {
    /* 12s(12초) 시간을 늘리면 올라가는 속도가 천천히 느려집니다 (예: 16s) */
    animation: rollCredits 30s linear forwards; 
}

/* 크레딧 스크롤 이동 키프레임 */
@keyframes rollCredits {
    0% {
        transform: translateY(0);
    }
    100% {
        /* -200%에서 -300%로 변경하여 긴 글자도 끝까지 완전하게 화면 밖으로 올라가도록 수정 */
        transform: translateY(-300%); 
    }
}