* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    position: fixed;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: #f1f1f1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
    /* 모바일 브라우저 주소표시줄 대응 */
    height: 100vh;
    height: 100dvh; /* 동적 뷰포트 높이 */
}

/* 인트로 화면 */
.intro-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: 100vh;
    max-height: 100dvh;
    max-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.intro-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

@keyframes backgroundPulseZoom {
    0% {
        background-size: 200%;
        transform: scale(1);
    }
    100% {
        background-size: 114%;
        transform: scale(1);
    }
}

.intro-title-text {
    position: relative;
    z-index: 2;
    max-width: 80%;
    height: auto;
    opacity: 0;
    transform: scale(0.3);
    animation: titleBounce 1.2s cubic-bezier(0.9, -3.55, 0.865, 1.55) 0.5s forwards;
}

@keyframes titleBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    60% {
        opacity: 1;
        transform: scale(1.1);
    }
    80% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.start-button {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    touch-action: manipulation;
    z-index: 3;
    opacity: 0;
}

.start-button.show {
    animation: buttonFadeIn 0.5s ease-out forwards;
}

@keyframes buttonFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.start-button:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
}

.start-button:active {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    height: 100dvh; /* 동적 뷰포트 높이 */
    height: calc(var(--vh, 1vh) * 100); /* JavaScript로 계산된 높이 */
    max-height: 100vh;
    max-height: 100dvh;
    max-height: calc(var(--vh, 1vh) * 100);
    background-image: url('img/bg_02.jpg');
    background-size: 114%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.app-bar {
    background: rgba(0, 0, 0, 0);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.app-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.people-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
}

.people-icon {
    font-size: 16px;
}

.people-count {
    color: white;
    font-size: 14px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.gift-box-counter {
    display: flex; /* 기본적으로 표시 */
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
}

.people-counter.hidden,
.gift-box-counter.hidden {
    display: none; /* E0S1~E0S6만 숨김 */
}

.gift-box-icon {
    font-size: 16px;
}

.gift-box-count {
    color: white;
    font-size: 14px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.scene-number {
    color: white;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.7;
}

.selected-player {
    color: white;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.selected-player span {
    font-weight: 600;
}

/* 햄버거 메뉴 버튼 */
.hamburger-button {
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
}

.hamburger-button span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-button:hover {
    background: rgba(0, 0, 0, 0.5);
}

.hamburger-button:active {
    background: rgba(0, 0, 0, 0.4);
}

/* 메뉴 오버레이 */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* 메뉴 패널 */
.menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100%;
    background: #000;
    background-image: url('img/title_01.jpg');
    background-size: 270%;
    background-position: 44% 80%;
    background-repeat: no-repeat;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.menu-panel.active {
    transform: translateX(0);
}

.menu-panel .scene-number {
    color: white;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0.7;
    cursor: pointer;
}

.menu-panel .node-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-panel .page-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-item {
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    text-align: left;
    margin-bottom: 10px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(5px);
}

.menu-item:active {
    background: rgba(255, 255, 255, 0.25);
}

/* 구조도 관련 스타일은 tree.css로 이동됨 */

.back-button {
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.back-button:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateY(-1px);
}

.back-button:active {
    transform: translateY(0);
    background: rgba(0, 0, 0, 0.4);
}

.back-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scene-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.white-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.episode-title-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1600;
    opacity: 0;
    pointer-events: none;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.episode-title-overlay img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.2s ease-in-out;
}

.text-content {
    flex: 1;
    font-size: 18px;
    line-height: 1.8;
    color: #333;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    margin-bottom: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    max-height: 40vh;
    overflow-y: auto;
}

.choice-button {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    color: white;
    border: none;
    padding: 18px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.choice-button:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 1);
}

.choice-button:active {
    transform: translateY(0);
    background: rgba(173, 216, 230, 0.5);
    border-color: rgba(255, 255, 255, 0.9);
    transition: none;
}

.choice-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 모바일 최적화 */
@media (max-width: 480px) {
    body {
        padding: 0;
        height: 100vh;
        height: 100dvh; /* 동적 뷰포트 높이 */
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .game-container {
        max-width: 100%;
        border-radius: 0;
        height: 100vh;
        height: 100dvh; /* 동적 뷰포트 높이 */
        height: calc(var(--vh, 1vh) * 100);
        max-height: 100vh;
        max-height: 100dvh;
        max-height: calc(var(--vh, 1vh) * 100);
    }
    
    .app-bar {
        padding: 12px 15px;
    }
    
    .app-bar-left {
        gap: 8px;
    }
    
    .hamburger-button {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .hamburger-button span {
        width: 18px;
    }
    
    .back-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .menu-panel {
        width: 220px;
    }
    
    .menu-item {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .app-bar-right {
        gap: 10px;
    }
    
    .people-counter {
        padding: 5px 10px;
        gap: 5px;
    }
    
    .people-icon {
        font-size: 14px;
    }
    
    .people-count {
        font-size: 13px;
    }
    
    .gift-box-counter {
        padding: 5px 10px;
        gap: 5px;
    }
    
    .gift-box-icon {
        font-size: 14px;
    }
    
    .gift-box-count {
        font-size: 13px;
    }
    
    .home-button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .scene-number {
        font-size: 12px;
    }
    
    .scene-container {
        padding: 15px;
    }
    
    .text-content {
        font-size: 16px;
        padding: 15px;
    }
    
    .choice-button {
        padding: 16px 20px;
        font-size: 15px;
    }
    
    .choices-container {
        max-height: 35vh;
    }
}

/* 전화 통화 다이얼로그 */
.phone-call-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-call-screen {
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('img/profile.jpg') center/cover no-repeat;
    border-radius: 30px;
    padding: 60px 40px 40px 40px;
    width: 300px;
    max-width: 90%;
    text-align: center;
    animation: phoneShake 0.5s ease-in-out, phonePulse 0.8s ease-in-out 0.5s infinite;
}

@keyframes phoneShake {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-5px) scale(1); }
    75% { transform: translateY(5px) scale(1); }
}

@keyframes phonePulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(0) scale(1.02); }
}

.caller-name {
    color: white;
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 10px;
    white-space: pre-line;
}

.caller-number {
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    margin-bottom: 50px;
}

.call-buttons {
    display: flex;
    justify-content: space-around;
    gap: 40px;
    margin-top: 30px;
}

.decline-button,
.accept-button {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
    color: white;
    font-weight: 500;
}

.decline-button {
    background: #e74c3c;
}

.decline-button:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.accept-button {
    background: #27ae60;
}

.accept-button:hover {
    background: #229954;
    transform: scale(1.1);
}


/* 통화 중 UI */
.phone-call-active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-active-screen {
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('img/profile.jpg') center/cover no-repeat;
    border-radius: 30px;
    padding: 60px 40px 40px 40px;
    width: 300px;
    max-width: 90%;
    text-align: center;
    animation: phonePulse 0.8s ease-in-out infinite;
}

.call-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    margin-bottom: 40px;
}

.call-controls {
    margin-top: 30px;
}

.skip-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.skip-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 닉네임 입력 모달 */
.nickname-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nickname-modal-content {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 40px;
    width: 300px;
    max-width: 90%;
    text-align: center;
}

.nickname-modal-content h3 {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.nickname-modal-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.nickname-modal-content input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.nickname-modal-content input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
}

.nickname-modal-content button {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nickname-modal-content button:hover {
    background: #229954;
}

.nickname-modal-content button:active {
    background: #1e8449;
}

/* 스크롤바 스타일링 */
.text-content::-webkit-scrollbar {
    width: 6px;
}

.text-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.text-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.text-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

