body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    background-color: #f0f2f5;
    pointer-events: none !important; /* body는 클릭 차단 */
}

/* 모든 자식 요소는 클릭 가능 */
#matterport-iframe,
#main-app-container,
#video-player-container,
#hamburger-menu,
#exit-fullscreen-button,
#popup-overlay {
    pointer-events: auto !important;
}

/* 브라우저 확장 프로그램 요소 차단 */
whale-quicksearch,
[translate="no"] {
    pointer-events: none !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* 전체화면 모드에서 pointer-events 재설정 */
:fullscreen,
:-webkit-full-screen,
:-moz-full-screen,
:-ms-fullscreen {
    pointer-events: none !important;
}

:fullscreen #matterport-iframe,
:-webkit-full-screen #matterport-iframe,
:-moz-full-screen #matterport-iframe,
:-ms-fullscreen #matterport-iframe,
:fullscreen #main-app-container,
:-webkit-full-screen #main-app-container,
:-moz-full-screen #main-app-container,
:-ms-fullscreen #main-app-container,
:fullscreen #bottom-ui-wrapper,
:-webkit-full-screen #bottom-ui-wrapper,
:-moz-full-screen #bottom-ui-wrapper,
:-ms-fullscreen #bottom-ui-wrapper,
:fullscreen #chat-container,
:-webkit-full-screen #chat-container,
:-moz-full-screen #chat-container,
:-ms-fullscreen #chat-container,
:fullscreen #hamburger-menu,
:-webkit-full-screen #hamburger-menu,
:-moz-full-screen #hamburger-menu,
:-ms-fullscreen #hamburger-menu,
:fullscreen #exit-fullscreen-button,
:-webkit-full-screen #exit-fullscreen-button,
:-moz-full-screen #exit-fullscreen-button,
:-ms-fullscreen #exit-fullscreen-button {
    pointer-events: auto !important;
}

/* 비디오 플레이어 스타일 */
.video-player-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important; /* 최상위 레이어로 설정 */
    background-color: #000 !important;
    display: none; /* 기본적으로 숨김 */
    pointer-events: auto !important;
}

.video-player {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* 비디오가 화면을 꽉 채우도록 */
    background-color: #000 !important;
    z-index: 10000 !important; /* 컨테이너보다 높은 z-index */
    pointer-events: auto !important;
}

/* 비디오 컨트롤 숨기기 */
.video-player::-webkit-media-controls {
    display: none !important;
}

.video-player::-webkit-media-controls-panel {
    display: none !important;
}

.video-player::-webkit-media-controls-play-button {
    display: none !important;
}

.video-player::-webkit-media-controls-timeline {
    display: none !important;
}

.video-player::-webkit-media-controls-current-time-display {
    display: none !important;
}

.video-player::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

.video-player::-webkit-media-controls-mute-button {
    display: none !important;
}

.video-player::-webkit-media-controls-volume-slider {
    display: none !important;
}

.video-player::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

.video-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 10001 !important; /* 비디오보다 높은 z-index */
    display: flex !important;
    gap: 15px;
    align-items: center;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.play-button {
    background-color: rgba(0, 123, 255, 0.9);
    color: white;
    border: 2px solid white;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.play-button:hover {
    background-color: rgba(0, 123, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.skip-button {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0; /* 기본적으로 숨김 */
    pointer-events: none;
}

.skip-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.skip-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.mute-button {
    background-color: #ff6b6b;
    color: white;
    border: 2px solid white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 10px;
}

.mute-button:hover {
    background-color: #ff5252;
    transform: scale(1.05);
}

.mute-button.unmuted {
    background-color: #4caf50;
}

.mute-button.unmuted:hover {
    background-color: #45a049;
}

#matterport-iframe {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    z-index: 8 !important;
    pointer-events: auto !important;
    display: none; /* 기본적으로 숨김 */
    visibility: hidden;
    opacity: 0;
}

#main-app-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none; /* 기본적으로 숨김 */
    justify-content: center;
    align-items: flex-end; /* 하단 정렬 */
    padding-bottom: 50px; /* 하단에서 50px 떨어뜨림 */
    box-sizing: border-box;
    z-index: 10 !important; /* iframe(8)보다 높게, 하지만 pointer-events 관리로 투과 */
    pointer-events: none !important; /* 기본적으로 클릭 차단 (자식만 활성화) */
    visibility: hidden; /* 기본적으로 숨김 */
    opacity: 0; /* 기본적으로 투명 */
}

#main-app-container > div {
    pointer-events: auto !important; /* 자식 요소는 이벤트 활성화 */
}

/* New layout styles - 통합된 main-app-container 스타일 */

/* 햄버거 메뉴 스타일 */
#hamburger-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002; /* 비디오 플레이어(9999)와 비디오(10000)보다 높게 설정 */
    pointer-events: auto;
}

.hamburger-btn {
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    color:#ffffff;
}

.hamburger-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.hamburger-btn span {
    width: 20px;
    height: 2px;
    background: #fff;
    transition: all 0.3s ease;
}

.menu-panel {
    position: absolute;
    top: 60px;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 10px 0;
    min-width: 310px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    color:#ffffff;
    z-index: 10003; /* 햄버거 버튼보다 높게 설정 */
}

.menu-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    padding: 12px 20px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 활성 상태 스타일 */
.menu-item.active {
    background-color: rgb(189 189 189 / 70%);
    color: #000;
    font-weight: 600;
}

.menu-item.active::before {
    content: "✓";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #000;
    font-weight: bold;
    font-size: 12px;
}

.menu-item.active {
    padding-left: 30px; /* 체크마크를 위한 공간 확보 */
}

#bottom-ui-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    pointer-events: auto !important; /* UI 요소들이 클릭 가능하도록 활성화 */
    padding: 10px;
    border-radius: 10px;
    z-index: 11; /* main-app-container(10)보다 높게 설정 */
}

#character-wrapper {
    flex-shrink: 0;
    width: 250px;
    height: auto; /* Adjust to image aspect ratio */
    position: relative; /* For name tag positioning */
    pointer-events: auto;
}

#hwaju-image {
    width: 100%;
    height: auto;
    display: block;
}

#hwaju-name-tag {
    position: absolute;
    bottom: 10px; /* Adjust as needed */
    left: 50%;
    transform: translateX(-50%);
    background-color: #0d6efd;
    color: white;
    padding: 8px 25px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}


#chat-container {
    display: flex;
    flex-direction: column; /* Rows */
    gap: 15px;
    width: 80%;
    max-width: 1200px;
    height: auto;
    pointer-events: auto;
}

#chat-top-panel {
    display: flex;
    gap: 20px;
}

#chat-output-panel {
    flex: 2; /* Takes up 2/3 of the space */
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid #ccc;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    height: 150px; /* Adjust height as needed */
    display: flex;
    flex-direction: column;
}

#chat-bottom-panel {
    width: 100%;
}

#chat-input-panel {
    /* This element is no longer used for layout */
    display: contents; 
}


/* --- End of New layout styles --- */


/* 햄버거 메뉴 및 관련 스타일 */
#hamburger-menu-wrapper {
    position: absolute;
    top: 20px;
    right: 20px; /* 오른쪽 상단으로 이동 */
    z-index: 1002;
    pointer-events: auto;
}

#hamburger-menu-button {
    background-color: rgba(0, 0, 0, 0.7); /* 검은색 배경 */
    color: white;
    border: none;
    border-radius: 5px;
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: background-color 0.2s ease;
}

#hamburger-menu-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

#main-menu {
    position: absolute;
    top: 65px; /* 버튼 아래로 배치 */
    right: 0; /* 오른쪽 정렬 */
    width: 250px;
    background-color: rgba(0, 0, 0, 0.8); /* 어두운 배경 */
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    padding: 10px 0;
    display: flex; /* Hidden by default 에서 flex 로 변경 */
    z-index: 1001;
    flex-direction: column;
    align-items: stretch;
}

#main-menu.hidden {
    display: none; /* hidden 클래스가 있을 때만 숨김 */
}

#main-menu button, #main-menu .episode-item {
    width: 100%;
    padding: 12px 15px;
    text-align: left;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: white;
    transition: background-color 0.2s ease;
    box-sizing: border-box;
}

#main-menu button:hover, #main-menu .episode-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#go-home-button {
    font-weight: bold;
    color: #4CAF50; /* 초록색 */
}

.episode-menu {
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 10px;
}
.episode-item {
    color: #ccc; /* 에피소드 텍스트 색상 */
}

#chat-output {
    min-height: 50px; /* 답변 표시 영역 최소 높이 */
    background-color: rgba(255, 255, 255, 0.1); /* 투명한 흰색 배경 */
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    color: white;
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#chat-input-area {
    display: flex;
    gap: 10px;
    position: relative;
    /* margin-top: 10px; */ /* No longer needed */
}

#chat-input-area input {
    flex-grow: 1;
    padding: 15px 20px; /* Increased padding */
    border: 2px solid #000;
    border-radius: 20px;
    background-color: #ffffff;
    color: #333;
    font-size: 1rem;
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-left: 10%;
}


#chat-input-area input::placeholder {
    color: #888;
}

#chat-input-area button {
   display: none; /* Hide original button */
}

/* FAQ 리스트 및 관련 스타일 */
#faq-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1; /* Takes up 1/3 of the space */
    max-width: 300px;
}

.faq-item {
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #eee;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.2s ease;
    border: none; /* remove border */
    position: relative;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

/* FAQ 활성 상태 스타일
.faq-item.active {
    background-color: rgb(189 189 189 / 70%);
    color: #007AFF;
    font-weight: 600;
    border: 2px solid rgb(255 0 0 / 50%);
}
 */
.faq-item.active::before {
    content: "✓";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-weight: bold;
    font-size: 12px;
}

.faq-item.active {
    padding-left: 25px; /* 체크마크를 위한 공간 확보 */
}

.hidden {
    display: none !important;
}

/* --- 새로운 채팅 UI 스타일 --- */
#chat-messages-container {
    flex-grow: 1;
    overflow-y: auto;
    /* padding: 10px; */ /* Padding is on parent now */
    display: flex;
    flex-direction: column;
    gap: 10px; /* 메시지 버블 간 간격 */
    /* max-height: 300px; */ /* No longer needed, it will fill the container */
    color: #333; /* Default text color for output */
    
    /* 스크롤바 숨기기 */
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}

#chat-messages-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera*/
}

.chat-message-bubble {
    max-width: 80%; /* 메시지 버블 최대 너비 */
    padding: 15px 20px;
    border-radius: 20px;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 말풍선 꼬리 효과 */
.chat-message-bubble::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.user-message-bubble {
    background-color: #007AFF; /* 파란색 배경 */
    align-self: flex-end; /* 오른쪽 정렬 */
    border-bottom-right-radius: 5px;
    color: white; /* 흰색 텍스트 */
}

/* 사용자 메시지 말풍선 꼬리 (오른쪽 하단) */
.user-message-bubble::after {
    bottom: 8px;
    right: -15px;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent #007AFF;
}

.ai-message-bubble {
    background-color: #f0f0f0; /* 회색 배경 */
    align-self: flex-start; /* 왼쪽 정렬 */
    border-bottom-left-radius: 5px;
    color: #333; /* 검은색 텍스트 */
}

/* AI 메시지 말풍선 꼬리 (왼쪽 하단) */
.ai-message-bubble::after {
    bottom: 8px;
    left: -15px;
    border-width: 12px 20px 12px 0;
    border-color: transparent #f0f0f0 transparent transparent;
}

/* 랜딩 영상 버튼 스타일 */
.landing-buttons {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translate(-50%, 50%);
    display: none; /* 기본적으로 숨김 */
    flex-direction: column;
    gap: 20px;
    z-index: 10002 !important;
    align-items: center;
}

.landing-buttons.visible {
    display: flex;
}

.landing-btn {
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
    border: 3px solid #000;
    padding: 18px 60px;
    border-radius: 50px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    min-width: 250px;
    text-align: center;
}

.landing-btn:hover {
    background-color: #000;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

/* 팝업 스타일 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10003 !important;
    display: none;
    justify-content: center;
    align-items: center;
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background-color: #fff;
    border-radius: 20px;
    padding: 40px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background-color: #ff0000;
    transform: rotate(90deg);
}

#popup-body {
    color: #333;
    line-height: 1.8;
    font-size: 16px;
}

#popup-body h1 {
    color: #000;
    margin-bottom: 20px;
}

#popup-body h2 {
    color: #333;
    margin-top: 25px;
    margin-bottom: 15px;
}

#popup-body p {
    margin-bottom: 15px;
}

#popup-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

/* 말풍선 안에 있는 스토리 버튼 스타일 */
.story-button-inline {
    background-color: #007AFF;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    text-align: left;
    white-space: normal;
    width: 100%;
    line-height: 1.4;
    display: block;
}

.story-button-inline:hover {
    background-color: #0051D5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.story-button-inline:active {
    transform: translateY(0);
    background-color: #003D99;
}

/* 전체화면 종료 버튼 (왼쪽 하단 고정) */
.exit-fullscreen-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10002;
    padding: 12px 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: none; /* 기본적으로 숨김 */
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.exit-fullscreen-button.active {
    display: block; /* 전체화면일 때만 표시 */
}

.exit-fullscreen-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.exit-fullscreen-button:active {
    transform: scale(0.98);
    background-color: rgba(0, 0, 0, 1);
}

/* Matterport iframe 상태 클래스 */
#matterport-iframe.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#matterport-iframe.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 8 !important;
}

/* 비디오 플레이어 상태 클래스 */
.video-player-container.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

.video-player-container.active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10000 !important;
    pointer-events: auto !important;
    background-color: #000 !important;
}

/* Main App Container 상태 클래스 */
#main-app-container.hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    display: none !important;
}

#main-app-container.active {
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10 !important;
    pointer-events: none !important;
}

/* Main App Container의 자식 요소는 항상 pointer-events: auto */
#main-app-container.active #bottom-ui-wrapper {
    pointer-events: auto !important; /* UI 클릭 가능 */
}

#main-app-container.active #chat-container {
    pointer-events: auto !important;
}

#main-app-container.active #character-wrapper {
    pointer-events: auto !important;
}
