:root {
    /* 기본 판형 높이(모든 특수판형 시작부 높이와 동일해야 함) - 1.2배 확대 */
    --baseH: min(114vh, 1440px);
    --ratio: 1.41421356;
    /* A-series √2 */
    --baseW: calc(var(--baseH) / var(--ratio));
    --bg: #222574;
    --ink: rgb(245, 245, 240);
}
@font-face {
    font-family: 'JoseonGulim';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@1.0/ChosunGu.woff') format('woff');
    font-weight: normal;
    font-display: swap;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: JoseonGulim, system-ui, -apple-system, Segoe UI, Roboto, 'Noto Sans KR', sans-serif;
}

body.cursor-left {
    cursor: url('leftarrow.svg') 13 13, w-resize;
}

body.cursor-right {
    cursor: url('rightarrow.svg') 13 13, e-resize;
}

body.cursor-scroll {
    cursor: url('scroll.svg') 13 13, all-scroll;
}

/* special 페이지에서 기본 스크롤바만 숨기기 위한 클래스 */
html.hide-scrollbar,
body.hide-scrollbar {
    scrollbar-width: none;           /* Firefox */
    -ms-overflow-style: none;        /* IE/Edge */
}
html.hide-scrollbar::-webkit-scrollbar,
body.hide-scrollbar::-webkit-scrollbar {
    display: none;                   /* Chrome/Safari */
}

#cameraWrapper {
    width: 100%;
    height: 100%;
    position: fixed;
    transform-origin: 50% 50%; /* 고정! */
    transform-style: preserve-3d; /* ✅ 추가: 자식 요소들을 3D 공간에 유지 */
}

/* 월드(카메라가 보는 대상). 카메라 이동/회전 = viewer를 변환 */
#viewer {
    position: absolute;
    left: 0;
    top: 0;
    /* will-change: transform; */ /* ❌ 제거: JS에서 동적으로 관리하여 강제 래스터화 방지 */
    transform: translate3d(0, 0, 0);
    transform-style: preserve-3d; /* ✅ 추가: 자식 요소들을 3D 공간에 유지 */
}

/* 페이지들이 놓이는 스테이지 */
#pageStage {
    position: absolute;
    left: 0;
    top: 0;
    min-width: 100vw;
    min-height: 100vh;
    overflow: visible; 
}

/* 상단 왼쪽 전체/확대 보기 토글 */
#overviewToggle {
    padding:0;
    position: fixed;
    left: 37%;
    top: 20px;
    transform: translateX(-50%);
    z-index: 1100;
    border: none;
    color: rgba(245, 245, 240, 0.8);
    font-size: 14px;
    cursor: url('focus.svg') 13 13, pointer;
    background: transparent;
    mix-blend-mode: difference;
    font-family: JoseonGulim, system-ui, sans-serif;
}

#overviewToggle:hover {
    color: rgba(245, 245, 240, 1);
    transform: translateX(-50%) scale(1.1);
}

/* 상단 중앙 타이틀 */
#appTitle {
    position: fixed;
    left: 5%;
    top: 20px;
    z-index: 1100;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 14px;
    color: rgba(245, 245, 240, 0.9);
    mix-blend-mode: difference;
}

/* 초기 페이지 안내 문구 (p1~p3에서만 표시) */
#initialGuide {
    position: fixed;
    left: 50%;
    top: 30%;
    transform: translateX(-50%);
    z-index: 1100;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 16px;
    color: rgba(245, 245, 240, 0.9);
    mix-blend-mode: difference;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#initialGuide[aria-hidden="false"] {
    opacity: 1;
}

/* 전시용 대기 모드 안내 문구 */
#idleMessage {
    position: fixed;
    left: 50%;
    top: 15%;
    transform: translateX(-50%);
    z-index: 1150;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 24px;
    color: var(--ink);
    background: transparent;
    padding: 20px 40px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    line-height: 1.8;
}

#idleMessage[aria-hidden="false"] {
    opacity: 1;
    animation: idlePulse 3s ease-in-out infinite;
}

.idle-restart-hint {
    font-size: 20px;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.9);
    display: block;
    margin-top: 10px;
}

@keyframes idlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 기본 판형 (A5) */
.page {
    position: absolute;
    width: var(--baseW);
    height: var(--baseH);
    background: rgba(0, 0, 0, 0) center/cover no-repeat;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* 고화질 이미지 렌더링 */
    /* z-index 기본값 설정 (페이지가 겹칠 때 순서 제어) */
    z-index: 0;
    -ms-interpolation-mode: bicubic;
    /* 이미지 스케일링 품질 향상 */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* ✅ CSS 기반 dim 효과 - 기본적으로 모든 페이지 dim */
    filter: brightness(0.7);
    transition: filter 0.5s ease, box-shadow 0.5s ease;
}

/* 썸네일 레이어 - ::before 의사 요소 사용 */
.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--thumbnail-url);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

/* Overview 모드에서 썸네일 레이어 표시 */
.page.overview-thumbnail-mode::before {
    opacity: 1;
}

/* ✅ 현재 페이지만 밝게 표시 */
.page.current {
    filter: brightness(1);
}

/* 현재 보고 있지 않은 페이지 - dim 처리 (레거시, 제거 예정) */
.page.dimmed {
    filter: brightness(0.7);
}

/* Overview 모드에서 현재 보고 있던 페이지 강조 - 타이핑 커서처럼 깜빡이는 효과 */
.page.overview-highlight {
    animation: overviewBlink 1s step-end infinite;
}

@keyframes overviewBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* Overview 모드에서 페이지 호버 효과 */
.page.overview-hover {
    cursor: pointer;
    filter: brightness(1.2);
    /* transform은 GSAP로 제어되므로 CSS에서 제거 */
    transition: filter 0.2s ease;
    z-index: 1000 !important;
}

/* 빈 페이지 스타일 */
.page.blank {
    background: transparent;
}

/* 페이지 오른쪽 하단 pageId/레이블 숨김 */
.page.basic::after {
    display: none;
}

#ui {
    position: fixed;
    left: 50%;
    bottom: 70px; /* 슬라이더와 겹치지 않도록 위로 올림 */
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 1000;
    mix-blend-mode: difference;
}

#ui button {
    background: transparent;
    border: none;
    color: var(--ink);
    padding: 4px 8px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#ui button:hover:not(:disabled) {
    opacity: 1;
    transform: scale(1.1);
}

#ui button:disabled {
    opacity: 0.2;
    cursor: default;
    transform: none;
}

#ui span {
    font: 14px/1.4 JoseonGulim, system-ui, sans-serif;
    opacity: .8;
}

/* 로딩 화면 */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#loadingScreen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: var(--ink);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(233, 238, 242, 0.2);
    border-top-color: var(--ink);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    color: var(--ink);
}

.loading-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 700px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(233, 238, 242, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--ink);
    width: 0%;
    transition: width 0.3s ease-out;
    border-radius: 4px;
}

.progress-text {
    font-size: 11px;
    color: rgba(233, 238, 242, 0.7);
    font-weight: 500;
}

/* 페이지 슬라이더 */
#pageSlider {
    position: fixed;
    left: 50%;
    bottom: 20px; /* 화면 맨 아래와도 여유 있게 간격 */
    transform: translateX(-50%) translateY(0);
    width: min(90%);
    z-index: 1000;
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    mix-blend-mode: difference; /* 배경과 '제외' 블렌딩 */
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.8s ease;
    pointer-events: auto;
}

#pageSlider.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(100px);
    pointer-events: none;
}

/* special2용 오른쪽 상단 미니 경로 뷰어 - 1.2배 확대 */
.special-mini-map {
    position: fixed;
    right: 0%;
    top: 50%;
    transform: translateY(-50%);
    width: 144px; /* 120px × 1.2 */
    height: 144px;
    background: transparent;
    padding-right: 1%;
    z-index: 1200;
    mix-blend-mode: difference;
    overflow: visible; /* 인디케이터가 밖으로 나갈 수 있도록 */
}

.special-mini-map svg {
    position: relative;
    width: 132px; /* 110px × 1.2 */
    height: 132px;
    overflow: visible; /* 인디케이터가 밖으로 나갈 수 있도록 */
}

.special-mini-path {
    fill: none;
    stroke: rgba(233, 238, 242, 0.6);
    stroke-width: 2.4; /* 2 × 1.2 */
}

.special-mini-indicator {
    fill: #fff;
}

/* 미니맵 수직 중앙 SCROLL 텍스트 */
.special-mini-label {
    position: absolute;
    left: 40%;
    top: -10%;
    transform: translate(-50%, -50%);
    font-size: 13px; /* 11px × 1.2 ≈ 13px */
    color: rgba(245, 245, 240, 0.6);
    font-family: JoseonGulim, system-ui, sans-serif;
    white-space: nowrap;
    letter-spacing: 1.2px; /* 1px × 1.2 */
    mix-blend-mode: difference;
    pointer-events: none;
}

/* 햄버거 메뉴 */
#menuToggle {
    position: fixed;
    right: 5%;
    top: 20px;
    z-index: 1100;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(245, 245, 240, 0.6);
    background: transparent;
    color: rgba(245, 245, 240, 0.9);
    font-size: 14px;
    cursor: url('focus.svg') 13 13, pointer;
    mix-blend-mode: difference;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#menuToggle:hover {
    transform: scale(1.1);
    opacity: 1;
}

#menuPanel {
    position: fixed;
    right: 8%;
    top: 20px;
    min-width: 160px;
    max-width: 180px;
    background: transparent;
    color: var(--ink);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 8px 0;
    z-index: 1100;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.6;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    mix-blend-mode: difference;
}

#menuPanel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.menu-item {
    padding: 10px 14px;
    cursor: url('focus.svg') 13 13, pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
    color: var(--ink);
}

.menu-item:hover {
    background: rgba(34, 37, 116, 0.1);
}

.menu-item.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.menu-item:first-child {
    border-radius: 12px 12px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 12px 12px;
}

/* 인포 아이콘 & 패널 */
#infoToggle {
    position: fixed;
    right: 5%;
    top: 54px;
    z-index: 1100;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(245, 245, 240, 0.6);
    background: transparent;
    color: rgba(245, 245, 240, 0.9);
    font-size: 14px;
    cursor: url('focus.svg') 13 13, pointer;
    mix-blend-mode: difference;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#infoToggle:hover {
    transform: scale(1.1);
}

#infoPanel {
    position: fixed;
    right: 8%;
    top: 54px;
    min-width: 180px;
    max-width: 200px;
    background: rgba(245, 245, 240 0.7);
    color: rgba(245, 245, 240, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 14px;
    z-index: 1100;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.6;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    mix-blend-mode: difference;
}

#infoPanel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* pageStage 블러 효과 */
#pageStage.blurred {
    filter: blur(8px);
    transition: filter 0.3s ease;
}

/* 새로고침 확인 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: rgba(245, 245, 240, 0.95);
    color: rgba(34, 37, 116, 0.95);
    border-radius: 16px;
    padding: 32px 28px;
    min-width: 320px;
    max-width: 90%;
    z-index: 2001;
    font-family: JoseonGulim, system-ui, sans-serif;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.open .modal-content {
    transform: scale(1);
}

.modal-message {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
    text-align: center;
    color: rgba(34, 37, 116, 0.9);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 24px;
    border: 1px solid rgba(34, 37, 116, 0.3);
    border-radius: 8px;
    font-size: 11px;
    font-family: JoseonGulim, system-ui, sans-serif;
    cursor: url('focus.svg') 13 13, pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.modal-btn-cancel {
    color: rgba(34, 37, 116, 0.7);
}

.modal-btn-cancel:hover {
    background: rgba(34, 37, 116, 0.1);
    border-color: rgba(34, 37, 116, 0.5);
}

.modal-btn-confirm {
    color: rgba(245, 245, 240, 0.95);
    background: rgba(34, 37, 116, 0.9);
    border-color: rgba(34, 37, 116, 0.9);
}

.modal-btn-confirm:hover {
    background: rgba(34, 37, 116, 1);
    transform: scale(1.05);
}

/* p70 선택지 모달 */
.choice-modal-content {
    min-width: 360px;
}

.choice-buttons {
    display: flex;
    flex-direction: row;
    gap: 40px;
    justify-content: center;
    align-items: center;
    margin-top: 24px;
}

.choice-btn {
    padding: 0;
    border: none;
    cursor: url('focus.svg') 13 13, pointer;
    transition: all 0.3s ease;
    background: transparent;
    overflow: hidden;
    width: auto;
    height: auto;
}

.choice-btn img {
    width: 100%;
    height: 100%;
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

.choice-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

/* 슬라이더 경고 토스트 */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    min-width: 300px;
    max-width: 500px;
    padding: 16px 20px;
    background: rgba(34, 37, 116, 0.95);
    color: rgba(245, 245, 240, 0.95);
    border-radius: 12px;
    font-family: JoseonGulim, system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: bottom 0.4s ease, opacity 0.4s ease;
    pointer-events: none;
}

.toast.show {
    bottom: 100px;
    opacity: 1;
    pointer-events: auto;
}

.toast-message {
    margin: 0;
}

.choice-btn:active {
    transform: translateY(0);
}

.info-row {
    display: grid;
    grid-template-columns: 90px 1fr; /* 고정 라벨 폭 → 두 번째 컬럼 x 위치 고정 */
    column-gap: 10px;
    row-gap: 6px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.info-row-title {
    margin-bottom: 10px;
}

.info-cell-label {
    font-size: 11px;
    opacity: 0.9;
    white-space: nowrap;
}

.info-cell-value {
    font-size: 9px;
}

.info-cell-value div + div {
    margin-top: 2px;
}

.slider-inner {
    position: relative;
    flex: 1;
}

.slider-tooltip {
    position: absolute;
    bottom: 100%;
    margin-bottom: 8px;
    padding: 4px 8px;
    color: var(--ink);
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

#pageSlider:hover .slider-tooltip {
    opacity: 1;
}

.slider-edge-label {
    font-size: 12px;
    color: rgba(233, 238, 242, 0.7);
    font-weight: 500;
    min-width: 16px;
    text-align: center;
    margin-top:0px;
}

#sliderInput {
    position: absolute;
    top: -8px; /* 인식 범위 확대를 위해 위로 이동 */
    left: 0;
    width: 100%;
    height: 20px; /* 인식 범위만 넓힘 (4px + 위아래 8px씩) */
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: url('focus.svg') 13 13, pointer;
    z-index: 2;
    margin: 0;
    padding: 0;
    pointer-events: none; /* 트랙 위에서는 이벤트 비활성화 */
}

/* 슬라이더 트랙 배경 - 투명하게 (진행 부분이 보이도록) */
#sliderInput::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
    border-radius: 4px;
    pointer-events: none; /* 트랙 위에서는 thumb가 마우스를 따라오지 않음 */
}

/* thumb는 pointer-events가 pseudo-element에서 작동하지 않으므로 JavaScript로 처리 */

#sliderInput::-moz-range-track {
    height: 4px;
    background: transparent;
    border-radius: 4px;
    pointer-events: none; /* 트랙 위에서는 thumb가 마우스를 따라오지 않음 */
}

.slider-container {
    position: relative;
    width: 100%;
    padding: 12px 0; /* 위아래 여유 공간 추가로 클릭 영역 확대 */
    cursor: url('focus.svg') 13 13, pointer;
}

.slider-track-wrapper {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(233, 238, 242, 0.1);
    border-radius: 4px;
}

.slider-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background: rgba(245, 245, 240, 1);
    border-radius: 4px;
    pointer-events: none;
    transition: width 0.1s ease;
    width: 0%;
    z-index: 1;
}

#sliderInput::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--ink);
    border-radius: 50%;
    cursor: url('focus.svg') 13 13, pointer;
    transition: transform 0.2s;
    margin-top: -4px;
}

#sliderInput::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

#sliderInput::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--ink);
    border-radius: 50%;
    cursor: url('focus.svg') 13 13, pointer;
    border: none;
    transition: transform 0.2s;
}

#sliderInput::-moz-range-thumb:hover {
    transform: scale(1.3);
}

/* .slider-labels: 더 이상 사용하지 않음 (구 버전 구조) */