/* === 폰트 (유지) === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap');
/* ================================= */

:root {
    /* === 변수 (유지) === */
    --primary-color: #14b8a6;
    --tracking-detected-bg: rgba(32, 201, 151, 0.85);
    --ui-element-bg: rgba(40, 40, 55, 0.75);
    --like-accent-color: #FF69B4;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
    /* 모바일 브라우저 주소창 고려 */
    height: 100dvh;
    height: -webkit-fill-available;
    touch-action: none;
    font-family: 'Inter', sans-serif;
    /* 폰트 유지 */
    /* Safe Area 지원 */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --- 로딩 화면 (유지) --- */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0f172a;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(30, 227, 207, 0.3) 0%, transparent 30%),
        radial-gradient(circle at 80% 30%, rgba(93, 197, 253, 0.2) 0%, transparent 35%),
        radial-gradient(circle at 30% 80%, rgba(255, 105, 180, 0.25) 0%, transparent 30%),
        radial-gradient(circle at 70% 70%, rgba(250, 204, 21, 0.15) 0%, transparent 25%);
    background-size: 200% 200%;
    animation: moveBlobs 25s ease-in-out infinite alternate;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

@keyframes moveBlobs {
    0% {
        background-position: 0% 50%, 100% 50%, 0% 100%, 100% 0%;
    }

    100% {
        background-position: 100% 50%, 0% 50%, 100% 0%, 0% 100%;
    }
}

#loading-screen h2 {
    margin: 0 0 15px 0;
    font-weight: 400;
}

#loading-screen p {
    font-size: 14px;
    opacity: 0.9;
    max-width: 80%;
    line-height: 1.6;
    margin: 10px 0 30px 0;
    font-weight: 300;
}

#start-button {
    padding: 14px 28px;
    background: var(--primary-color);
    color: white;
    border: 1px solid rgba(30, 227, 207, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    margin-top: 25px;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

#start-button:hover {
    background-color: #0f766e;
    border-color: rgba(30, 227, 207, 0.5);
    transform: scale(1.03);
    box-shadow: 0 5px 15px rgba(15, 118, 110, 0.3);
}

#start-button:active {
    transform: scale(0.97);
    transition-duration: 0.1s;
}

/* --- A-Frame 장면 (변경 없음) --- */
a-scene {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    display: none;
}

/* --- 오류 메시지 (변경 없음) --- */
.fallback-message {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
}

.fallback-message h3 {
    font-size: 16px;
    color: #ff8a80;
    margin-bottom: 10px;
    font-weight: 500;
}

.fallback-message p {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 15px;
    font-weight: 300;
}

.fallback-message button {
    padding: 8px 15px;
    font-size: 13px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: 400;
}

.fallback-message button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}


/* --- 도움말/인식 상태 UI 스타일 (복구 및 유지) --- */
#help-ui {
    position: fixed;
    top: 15px;
    left: 15px;
    padding: 8px 15px;
    font-size: 13px;
    background: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    border-radius: 20px;
    z-index: 100;
    /* switch-camera-button 보다 아래 */
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    /* JS에서 로드 후 1로 변경 */
    transition: opacity 0.8s ease-in-out, background-color 0.3s ease, display 0s linear 0.8s;
    /* 사라질 때 display none 지연 */
    display: block;
    /* 초기에는 보이도록 */
}

#help-ui.detected {
    background-color: var(--tracking-detected-bg);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- 카메라 전환 버튼 스타일 (수정: 초기 숨김, help-ui 위치) --- */
#switch-camera-button {
    position: fixed;
    top: 15px;
    /* help-ui 위치 */
    left: 15px;
    /* help-ui 위치 */
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    border-radius: 50%;
    /* 원형 버튼 */
    cursor: pointer;
    z-index: 101;
    /* help-ui 보다 위에 */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    /* === 수정: 초기 숨김 상태 === */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.95);
    /* 등장 애니메이션 시작점 */
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0s linear 0.4s, background-color 0.2s ease, box-shadow 0.2s ease;
    /* ========================= */
}

#switch-camera-button.visible {
    /* === 수정: 보이는 상태 === */
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
    /* 등장 애니메이션 끝점 */
    transition-delay: 0s;
    /* visibility 지연 제거 */
    /* ====================== */
}

#switch-camera-button:hover {
    /* hover/active 효과 유지 */
    background-color: rgba(70, 70, 90, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

#switch-camera-button:active {
    transform: scale(0.9);
    transition-duration: 0.1s;
}


/* --- 다시보기 버튼 스타일 (유지) --- */
#replay-button {
    position: fixed;
    top: 15px;
    right: 15px;
    padding: 6px 12px;
    font-size: 13px;
    background-color: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s, background-color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#replay-button.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#replay-button:hover {
    background-color: rgba(70, 70, 90, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

#replay-button:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
}

/* --- 촬영하기 버튼 스타일 (수정: 위치, 디자인 변경 + 수직 정렬 미세 조정) --- */
#capture-button {
    position: fixed;
    bottom: 15px;
    left: 15px;
    /* 왼쪽으로 이동 */
    width: 40px;
    /* 원형 버튼 크기 */
    height: 40px;
    /* 원형 버튼 크기 */
    font-size: 20px;
    /* 아이콘 크기 */
    background-color: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    border-radius: 50%;
    /* 원형 */
    cursor: pointer;
    z-index: 101;
    display: flex;
    /* 아이콘 중앙 정렬 */
    justify-content: center;
    /* 수평 중앙 정렬 */
    align-items: center;
    /* 수직 중앙 정렬 */
    box-sizing: border-box;
    /* 패딩이 크기에 영향을 주도록 설정 */
    /* === 수정: 아이콘 살짝 위로 올리기 === */
    padding-bottom: 4px;
    /* =============================== */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    /* === 등장 애니메이션 === */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    /* 아래에서 위로 */
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s, background-color 0.2s ease, box-shadow 0.2s ease;
    pointer-events: none;
    transform-origin: center center;
    /* 스케일 기준 */
}

#capture-button.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#capture-button:hover {
    background-color: rgba(70, 70, 90, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    /* 좋아요 버튼과 동일한 hover */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

#capture-button:active {
    transform: scale(0.9);
    /* 좋아요 버튼과 동일한 active */
    transition-duration: 0.1s;
}

/* --- 작품 정보 표시 영역 스타일 (수정: 위치 조정) --- */
#artwork-info {
    position: fixed;
    bottom: 15px;
    /* 촬영/좋아요 버튼과 같은 높이 */
    left: 65px;
    /* 촬영 버튼 오른쪽에 위치 (15px(왼쪽 여백) + 40px(버튼 너비) + 10px(간격)) */
    right: 65px;
    /* 좋아요 버튼 왼쪽까지 (15px(오른쪽 여백) + 40px(버튼 너비) + 10px(간격)) */
    /* transform: translate(-50%, ...) 제거 */
    transform: translateY(10px) scale(0.95);
    /* 등장 시작점 (Y축만) */
    padding: 10px 15px;
    /* 좌우 패딩 약간 줄임 */
    font-size: 12px;
    background-color: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    border-radius: 12px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s;
    text-align: center;
    pointer-events: none;
    /* max-width 제거 또는 조정 (left, right로 너비 결정) */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#artwork-info strong {
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
    font-size: 1.1em;
    color: white;
}

#artwork-info br {
    display: block;
    content: "";
    margin-top: 2px;
}

#artwork-info.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    /* 등장 끝점 (Y축만) */
}

/* --- 좋아요 버튼 스타일 (유지, 위치만 확인) --- */
#like-button {
    position: fixed;
    bottom: 15px;
    right: 15px;
    /* 오른쪽 위치 유지 */
    width: 40px;
    height: 40px;
    font-size: 20px;
    background-color: var(--ui-element-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E0E0E0;
    border-radius: 50%;
    cursor: pointer;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s, background-color 0.2s ease, color 0.3s ease, box-shadow 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform-origin: center center;
}

#like-button.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#like-button:hover {
    background-color: rgba(70, 70, 90, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

#like-button:active {
    transform: scale(0.9);
    transition-duration: 0.1s;
}

#like-button.liked {
    color: var(--like-accent-color);
    animation: button-press 0.3s ease-out forwards;
}

@keyframes button-press {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.85);
    }

    100% {
        transform: scale(1);
    }
}


/* --- 문구 클릭 효과 스타일 (원본 유지) --- */
.clickable-plane {}

@keyframes plane-click-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.plane-clicked {
    animation: plane-click-pulse 0.3s ease-out;
}

/* === 컨페티 파티클 효과 (애니메이션 유지) === */
.confetti-particle {
    position: fixed;
    font-size: 12px;
    user-select: none;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    animation: confetti-burst 0.8s ease-out forwards;
    display: flex;
    justify-content: center;
    align-items: center;
    --target-x: 0px;
    --target-y: 0px;
    transform-origin: center center;
}

@keyframes confetti-burst {
    0% {
        transform: translate(calc(-50% + 0px), calc(-50% - 10px)) scale(0.5) rotate(0deg);
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        transform: translate(calc(-50% + var(--target-x)), calc(-50% + var(--target-y))) scale(1) rotate(270deg);
        opacity: 0;
    }
}

/* ==================================== */

/* === 추가: 스크린 플래시 효과 === */
#screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    /* 플래시 색상 및 투명도 */
    opacity: 0;
    /* 초기 상태: 투명 */
    pointer-events: none;
    /* 클릭 방지 */
    z-index: 9998;
    /* 다른 UI 요소들 위에, 로딩/폴백보다는 아래 */
}

/* 플래시 애니메이션 정의 */
@keyframes screenFlashAnimation {
    0% {
        opacity: 0;
    }

    30% {
        opacity: 0.7;
    }

    /* 밝아지는 정점 */
    100% {
        opacity: 0;
    }
}

/* 플래시 애니메이션 적용 클래스 */
#screen-flash.flash-active {
    /* forwards를 사용하지 않아 애니메이션 후 자동으로 opacity: 0으로 돌아감 */
    animation: screenFlashAnimation 0.4s ease-out;
    /* 애니메이션 속도 조절 */
}

/* ============================ */

/* --- 이전 공통 .ar-action-button 스타일 제거되었음 --- */