/* ==============================
   게임 폰트
============================== */

@font-face {
    font-family: 'NeoDunggeunmo';
    src: url('fonts/neodgm.ttf') format('truetype');
}

/* 초청장 위쪽 문구용 폰트 */
@font-face {
    font-family: 'Continuous';
    src: url('fonts/continuous.ttf') format('truetype');
}

/* 티켓북 위치: 현재 게임 표시 영역의 오른쪽/위쪽 여백, 실제 아이콘 너비 */
#ticketbookUI {
    --ticketbook-icon-right: 24px;
    --ticketbook-icon-top: 24px;
    --ticketbook-icon-width: 64px;
    --ticketbook-panel-scale: 0.55;
    --ticketbook-panel-gap: 12px;
    --ticketbook-panel-padding: 24px; /* 축소 전 기준 여백 */
    position: fixed;
    z-index: 200000;
    pointer-events: none;
}
#ticketbookUI[hidden], #ticketbookModal[hidden], .ticketbook-page[hidden],
.ticketbook-stamp[hidden] { display: none !important; }
#ticketbookToggle {
    position: absolute;
    right: var(--ticketbook-icon-right);
    top: var(--ticketbook-icon-top);
    width: var(--ticketbook-display-icon-width, var(--ticketbook-icon-width));
    height: calc(var(--ticketbook-display-icon-width, var(--ticketbook-icon-width)) * 627 / 586);
    padding: 0;
    border: 0;
    background: transparent;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
}
#ticketbookToggle img {
    position: absolute;
    width: calc(var(--ticketbook-display-icon-width, var(--ticketbook-icon-width)) * 1254 / 586);
    height: auto;
    left: calc(var(--ticketbook-display-icon-width, var(--ticketbook-icon-width)) * -335 / 586);
    top: calc(var(--ticketbook-display-icon-width, var(--ticketbook-icon-width)) * -327 / 586);
    image-rendering: pixelated;
    pointer-events: none;
}
#ticketbookModal { position: absolute; inset: 0; pointer-events: auto; }
#ticketbookPanel {
    position: absolute;
    right: var(--ticketbook-icon-right);
    top: calc(var(--ticketbook-icon-top) + var(--ticketbook-icon-width) * 627 / 586 + var(--ticketbook-panel-gap));
    width: 1000px; height: 414px;
    transform: scale(var(--ticketbook-ui-scale, 0.6));
    transform-origin: top right;
    outline: none;
}
#ticketbookPanel::before {
    content: '';
    position: absolute;
    inset: calc(0px - var(--ticketbook-panel-padding));
    box-sizing: border-box;
    background: #E8DCC5;
    border: 2px solid #A99A80;
    border-radius: 0;
    z-index: -1;
    pointer-events: none;
}
.ticketbook-page { position: absolute; width: 1774px; height: 887px; transform-origin: 0 0; }
.ticketbook-page > img { position: absolute; pointer-events: none; image-rendering: pixelated; }
.ticketbook-art { width: 1774px; height: auto; left: 0; top: 0; }
.ticketbook-hit {
    position: absolute; padding: 0; border: 0; background: transparent;
    cursor: pointer; color: transparent;
}
.ticketbook-hit:focus-visible, #ticketbookToggle:focus-visible { outline: 2px solid #FFFFFF; }
.ticketbook-complete {
    position: absolute; z-index: 3; line-height: 1.1;
    display: flex; align-items: center; justify-content: center;
    white-space: pre; transform-origin: center;
    text-align: center; font-family: 'NeoDunggeunmo', sans-serif;
    font-weight: 900; color: #C62828;
    pointer-events: none;
}

/* Hall 1 작품만 겹쳐 표시. 배경/NPC/플레이어 배치는 변경하지 않음. */
.hall1-artwork-layer { position: fixed; z-index: 1; pointer-events: none; }
.hall1-shadow-layer {
    position: absolute; inset: 0; overflow: hidden;
    z-index: -1; pointer-events: none;
}
.hall1-object-shadow, .hall1-npc-shadow {
    position: absolute; pointer-events: none;
    /* 흐림 없이 작은 계단형 접지 그림자. 액자/벽은 개별 형태로 덮어씀. */
    clip-path: polygon(12% 0, 88% 0, 88% 25%, 100% 25%, 100% 75%,
        88% 75%, 88% 100%, 12% 100%, 12% 75%, 0 75%, 0 25%, 12% 25%);
}
.hall1-npc-shadow { z-index: -1; }
.hall1-human-shadow-layer {
    position: fixed; inset: 0; overflow: hidden;
    z-index: 1; pointer-events: none;
}
.hall1-human-shadow-layer[hidden] { display: none !important; }
/* Hall 2도 Hall 1의 그림자 요소/클리핑 스타일을 그대로 사용. */
.hall2-shadow-layer {
    position: fixed; z-index: 1; overflow: hidden; pointer-events: none;
}
.hall2-shadow-layer[hidden] { display: none !important; }
.hall1-artwork-layer[hidden], .hall1-artwork-view[hidden],
.hall1-artwork-arrow[hidden] { display: none !important; }
.hall1-artwork-frame { position: absolute; overflow: hidden; }
.hall1-artwork-frame img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hall1-artwork-arrow { position: absolute; width: 40px; height: auto; }
.hall1-artwork-view {
    --artwork-image-max-width: 1000px;
    --artwork-dialogue-max-width: 1000px;
    --artwork-padding: 24px;
    --artwork-gap: 16px;
    position: fixed;
    z-index: 150000; /* 티켓북 아래, 게임 위 */
    box-sizing: border-box;
    padding: var(--artwork-padding);
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: var(--artwork-gap);
    justify-items: center;
}
.hall1-artwork-enlarged {
    display: block;
    width: min(100%, var(--artwork-image-max-width));
    height: 100%; min-height: 0; max-height: 100%;
    object-fit: contain;
    object-position: center;
}
.hall1-artwork-dialogue { position: relative; width: min(100%, var(--artwork-dialogue-max-width)); }
.hall1-artwork-dialogue .dialogue-box { display: block; position: relative; left: auto; top: auto; width: 100%; height: auto; }
.hall1-artwork-dialogue .dialogue-text {
    display: block; position: absolute; left: 8%; top: 18%; width: 84%;
    font-size: clamp(14px, 2vw, 26px); line-height: 1.4;
    word-break: keep-all; overflow-wrap: anywhere;
}
.hall1-artwork-dialogue .dialogue-next {
    display: block; position: absolute; left: auto; top: auto; right: 6%; bottom: 15%;
    border-left-width: 10px; border-right-width: 10px; border-top-width: 14px;
}

/* 기존 하단 대화창을 복제해 사용하는 전체 스탬프 획득 독백. */
.all-stamps-dialogue {
    position: fixed;
    z-index: 150001;
    box-sizing: border-box;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 24px;
}
.all-stamps-dialogue:focus { outline: none; }

/* Hall 2: 원본 배경의 액자 테두리와 내부 cover 이미지를 함께 렌더링. */
.hall2-artwork-layer { position: fixed; z-index: 1; pointer-events: none; }
.hall2-artwork-layer[hidden], .hall2-artwork-arrow[hidden] { display: none !important; }
.hall2-artwork-canvas { position: absolute; left: 0; top: 0; width: 1536px; height: 988px; transform-origin: 0 0; }
.hall2-artwork-frame { position: absolute; overflow: hidden; background-repeat: no-repeat; }
.hall2-artwork-frame img { position: absolute; display: block; object-fit: cover; }
.hall2-artwork-stage { position: relative; width: 100%; height: 100%; min-height: 0; overflow: visible; }
.hall2-artwork-panel { position: absolute; background: #E8DCC5; pointer-events: none; }
.hall2-artwork-group { position: absolute; transform-origin: 0 0; }
/* 대화 진행용 컨테이너 포커스의 브라우저 기본 외곽선만 제거. */
.hall2-artwork-view:focus { outline: none; }
.hall2-artwork-view .hall2-quiz-content { max-height: 72%; overflow-y: auto; }
.hall1-artwork-view:focus { outline: none; }
.hall1-artwork-view:not(.hall2-artwork-view) .dialogue-text { white-space: pre-line; }
.hall1-artwork-view:not(.hall2-artwork-view) .hall2-quiz-content { max-height: 72%; overflow-y: auto; }
.hall2-quiz-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hall2-quiz-controls button, .hall2-quiz-controls input {
    font-family: inherit; font-size: 16px; color: #333; background: #E8DCC5;
    border: 1px solid #403A34; padding: 4px 8px;
}
.hall2-quiz-controls button { cursor: pointer; }
.hall2-quiz-controls input { width: 90px; }
.hall2-quiz-controls :focus-visible { outline: 2px solid #403A34; outline-offset: 2px; }
.hall2-quiz-controls input[aria-invalid='true'] { outline: 2px solid #a33; }

body {
    margin: 0;
    background: #222;

    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;
}

/* Logical development coordinates stay fixed, including Hall 1's background
   offset (498, 217). Viewport/zoom changes affect this single uniform scale. */
html, body { width: 100%; height: 100%; overflow: hidden; }
.room, .lobby-scene, .exhibition-scene, .game-overlay-stage {
    position: fixed !important;
    left: 50%; top: 50%;
    flex: none;
    transform: translate(-50%, -50%) scale(var(--game-scale, 1));
    transform-origin: center;
}
.room { width: 900px; height: 900px; }
#exhibition01Scene { width: 2560px; height: 1440px; }
#exhibition01Background {
    display: block; position: absolute;
    left: calc((2560px - 1564px) / 2);
    top: calc((1440px - 1006px) / 2);
    width: 1564px; height: 1006px;
}
#exhibition02Scene { width: 1536px; height: 988px; }
#exhibition03Scene { width: 1564px; height: 1006px; }
#exhibition02Background, #exhibition03Background { display: block; }
.game-overlay-stage {
    width: 2560px; height: 1440px; pointer-events: none; z-index: 1000;
}
.game-dialogue-stage { z-index: 100000; }
.room > .game-overlay-stage {
    position: absolute !important;
    left: calc((900px - 2560px) / 2);
    top: calc((900px - 1440px) / 2);
    transform: none;
}
/* Only the exhibition NPC UI uses this panel. Artwork/event panels keep their CSS. */
.game-dialogue-stage.hall-dialogue-active {
    left: var(--hall-dialogue-left); top: var(--hall-dialogue-top);
    width: 1500px; height: 265px;
    transform: scale(var(--hall-dialogue-scale)); transform-origin: 0 0;
}
.hall-dialogue-active > #dialogueBox { left: 0; top: 53px; }
.hall-dialogue-active > #dialogueNameBox { left: 0; top: 0; }
.hall-dialogue-active > #dialogueNameText { left: 80px; top: 25px; }
.hall-dialogue-active > #dialogueText {
    left: 120px; top: 91.16px; width: 1260px;
    font-size: 26px; line-height: 1.4; text-align: left;
    word-break: keep-all; overflow-wrap: anywhere;
}
.hall-dialogue-active > #dialogueNext {
    left: 1390px; top: 219.2px;
    border-left-width: 10px; border-right-width: 10px; border-top-width: 14px;
}
/* Floor-object narration uses the same 1500x212 body and Hall 3's existing 8%/18% insets.
   Scoped to normal dialogue so artwork views and trophy quiz/feedback keep their UI. */
.hall-floor-dialogue { padding: calc(24px * var(--hall-floor-scale)); }
.hall-floor-dialogue > .hall1-artwork-dialogue {
    width: calc(1500px * var(--hall-floor-scale));
    max-width: none;
}
.hall-floor-dialogue > .hall1-artwork-dialogue .dialogue-text {
    font-size: calc(26px * var(--hall-floor-scale));
}
.hall-floor-dialogue > .hall1-artwork-dialogue .dialogue-next {
    border-left-width: calc(10px * var(--hall-floor-scale));
    border-right-width: calc(10px * var(--hall-floor-scale));
    border-top-width: calc(14px * var(--hall-floor-scale));
}
#exhibition01Scene > .hall1-artwork-layer { position: absolute; }
.exhibition-scene > .hall2-artwork-layer { position: absolute; }
#exhibition01Scene > .hall1-human-shadow-layer { position: absolute; }
.game-overlay-stage > .monitor-popup {
    position: absolute; left: 640px; top: 144px;
    width: 1448px; height: 1086px; pointer-events: auto;
}
.game-overlay-stage > .obs-button,
.game-overlay-stage > .start-button { position: absolute; pointer-events: auto; }

.room {
    position: relative;
}

.room-background {
    display: block;
    width: 900px;
    height: auto;
}

/* 컴퓨터 상호작용 영역 */
.computer {
    position: absolute;

    left: 140px;
    top: 565px;

    width: 95px;
    height: 55px;

    background: transparent;
    opacity: 0.5;

    border: none;

    z-index: 999;
}

/* 모니터 팝업 */
.workroom-computer-arrow {
    display: none;
    position: absolute;

    /* 컴퓨터 위 화살표 위치 / 크기 조정 */
    left: 165px;
    top: 530px;
    width: 40px;
    height: auto;

    z-index: 100001;
    pointer-events: none;
    animation: npcArrowFloat 0.8s ease-in-out infinite;
}

/* 모니터 팝업 */
.monitor-popup {
    display: none;

    position: fixed;

    left: 25%;
    top: 10%;

    height: 100vh;

    z-index: 1000;
}

.monitor-image {
    display: block;

    width: 100%;
    height: auto;
}

/* OBS Studio 상호작용 영역 */
.obs-button {
    display: none;

    position: fixed;

    left: 685px;
    top: 550px;

    width: 120px;
    height: 120px;

    background: transparent;

    border: none;
    outline: none;
    cursor: pointer;

    z-index: 9999;
}

/* OBS 화면 */
.obs-screen {
    display: none;

    position: absolute;
    left: 0;
    top: 0;

    width: 100%;
    height: auto;

    z-index: 2;
}

/* Connecting만 OBS 원본 미리보기 경계에 맞춤. 기존 stage 배율을 그대로 사용. */
.workroom-connecting-image {
    position: absolute;
    left: var(--connecting-left);
    top: var(--connecting-top);
    width: var(--connecting-width);
    height: var(--connecting-height);
    object-fit: cover;
    object-position: center;
    z-index: 20;
    pointer-events: none;
}

/* 방송 시작 버튼 상호작용 영역 */
.start-button {
    display: none;

    position: fixed;

    left: 1690px;
    top: 815px;

    width: 230px;
    height: 50px;

    background: transparent;

    border: none;
    cursor: pointer;

    z-index: 10000;
}

/* 방송 시작은 모든 입력 상태에서 투명한 클릭 영역만 유지 */
.start-button,
.start-button:hover,
.start-button:active,
.start-button:focus,
.start-button:focus-visible {
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    animation: none;
}

/* ==============================
   블루스크린 오류 문구
============================== */

.bdos-text {
    display: none;

    position: absolute;
    left: 18%;
    top: 18%;
    width: 60%;

    color: white;
    font-family: 'NeoDunggeunmo', sans-serif;

    z-index: 9999;
}

/* :( 표시 */
.bdos-face {
    font-size: 120px;
    margin-bottom: 25px;
}

/* 오류 메시지 */
.bdos-message {
    font-size: 24px;
    line-height: 1.6;
}

/* 진행률 */
.bdos-progress {
    font-size: 24px;
    margin-top: 25px;
}

/* 하단 오류 정보 */
.bdos-detail {
    font-size: 16px;
    line-height: 1.5;
    margin-top: 35px;
}

/* ==============================
   공용 대화 UI
============================== */

/* 플레이어 대화박스 */
.dialogue-box {
    display: none;
    position: absolute;

    left: 530px;
    top: 853px;

    width: 1500px;
    height: 212px;

    z-index: 100000;
}


/* NPC 대화박스 */
.dialogue-name-box {
    display: none;
    position: absolute;

    left: 530px;
    top: 800px;

    width: 1500px;
    height: 265px;

    z-index: 100000;
}


/* NPC 이름 */
.dialogue-name-text {
    display: none;
    position: absolute;

    left: 610px;
    top: 825px;

    width: 300px;
    text-align: center;

    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 30px;

    z-index: 100002;
}


/* 플레이어 / NPC 공통 대화 본문 */
.dialogue-text {
    display: none;
    position: absolute;

    left: 650px;
    top: 890px;

    width: 1250px;

    color: rgb(0, 0, 0);
    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 32px;

    z-index: 100002;
}


/* 다음 대사 ▼ */
.dialogue-next {
    display: none;
    position: absolute;

    left: 1900px;
    top: 1010px;

    width: 0;
    height: 0;

    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 25px solid #333333;

    z-index: 100003;
}

/* ==============================
   닫힌 초청장
============================== */

.invitation-closed {
    display: none;

    position: absolute;

    /* 위치/크기는 초청장 띄운 뒤 조정 */
    left: 500px;
    top: 360px;

    width: 450px;
    height: auto;

    /* BDOS 위에 표시 */
    z-index: 10003;
}

/* 원본 1280 × 256px: 가로 5프레임, 셀 256 × 256px */
.invitation-sprite {
    display: none;
    position: fixed;
    width: 256px;
    height: 256px;
    background-image: url('assets/invitation animation.png');
    background-size: 500% 100%;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
    z-index: 10005;
}

/* 이벤트별 배치 영역. 블루스크린에서만 기존 공용 UI를 잠시 배치 */
.event-dialogue-frame {
    position: fixed;
    container-type: inline-size;
    pointer-events: none;
    z-index: 100000;
}

.event-dialogue-frame:is([data-dialogue-event='bdos'], [data-dialogue-event='ending']) .event-dialogue-panel {
    position: absolute;
    left: var(--dialogue-left);
    bottom: var(--dialogue-bottom);
    width: var(--dialogue-width);
    max-height: 90%;
    aspect-ratio: 1865 / 296;
    container-type: inline-size;
}

.event-dialogue-frame:is([data-dialogue-event='bdos'], [data-dialogue-event='ending']) .dialogue-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.event-dialogue-frame:is([data-dialogue-event='bdos'], [data-dialogue-event='ending']) .dialogue-text {
    position: absolute;
    left: 8%;
    top: 24%;
    bottom: auto;
    width: 80%;
    font-size: 2.7cqw;
    line-height: 1.4;
}

.event-dialogue-frame:is([data-dialogue-event='bdos'], [data-dialogue-event='ending']) .dialogue-next {
    position: absolute;
    left: auto;
    right: 6%;
    top: auto;
    bottom: 16%;
    border-left-width: 1.2cqw;
    border-right-width: 1.2cqw;
    border-top-width: 1.7cqw;
}

/* ==============================
   초청장 위쪽 문구
============================== */

.invitation-text-top {
    display: none;
    position: absolute;

    /* 위치는 나중에 직접 맞출 예정 */
    left: 630px;
    top: 320px;

    font-family: 'Continuous', sans-serif;
    font-size: 40px;

    z-index: 99999;
}


/* ==============================
   초청장 아래쪽 문구
============================== */

.invitation-text-bottom {
    display: none;
    position: absolute;

    /* 위치는 나중에 직접 맞출 예정 */
    left: 590px;
    top: 575px;

    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 20px;

    z-index: 10007;
}

/* ==============================
   전시장 로비 씬
============================== */

/* ==============================
   전시장 로비 씬
============================== */

.lobby-scene {
    display: none;
    position: relative;

    width: 1536px;
    height: 864px;

    overflow: hidden;
}

.lobby-background {
    display: block;

    width: 1536px;
    height: 864px;
}

/* 좌우 번호 표지판: 로비 내부 좌표(px). 위쪽 파란 구조물 아래의 실내 방향. */
.lobby-entrance-sign {
    --lobby-sign-width: 64px;
    --lobby-sign-height: 40px;
    --lobby-sign-font-size: 26px;
    position: absolute;
    left: var(--lobby-sign-left);
    top: var(--lobby-sign-top);
    width: var(--lobby-sign-width);
    height: var(--lobby-sign-height);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #668ac2;
    background: #dcecff;
    box-shadow: inset 0 3px #f4faff, inset 0 -3px #b8d1ed;
    clip-path: polygon(6px 0, calc(100% - 6px) 0, calc(100% - 6px) 3px,
        100% 3px, 100% calc(100% - 3px), calc(100% - 6px) calc(100% - 3px),
        calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 3px),
        0 calc(100% - 3px), 0 3px, 6px 3px);
    color: #123b70;
    font: var(--lobby-sign-font-size)/1 'NeoDunggeunmo', monospace;
    z-index: 3;
    pointer-events: none;
    user-select: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms linear, visibility 0s linear 120ms;
}
.lobby-entrance-sign-right {
    --lobby-sign-left: 1316px;
    --lobby-sign-top: 440px;
}
.lobby-entrance-sign-left {
    --lobby-sign-left: 156px;
    --lobby-sign-top: 440px;
}
.lobby-entrance-sign.is-visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* 카운터 윗선 아래는 JS 설정으로 가림. 플레이어/기존 효과 아래의 정적 이미지. */
.lobby-fan {
    position: absolute;
    z-index: 2;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges; /* 지원 브라우저에서 nearest-neighbor, 미지원 시 위 선언 사용 */
    pointer-events: none;
    user-select: none;
}
.lobby-fan[hidden] { display: none !important; }

/* 로비 컷씬 일러스트 조정: 컷씬 영역 기준, 원본 비율은 자동 유지. */
.lobby-cutscene-portrait {
    --lobby-portrait-center-x: 75%;
    --lobby-portrait-top: 2%;
    --lobby-portrait-width: 32%;
    --lobby-portrait-fade-duration: 180ms;
    position: absolute;
    left: var(--lobby-portrait-center-x);
    top: var(--lobby-portrait-top);
    width: var(--lobby-portrait-width);
    height: auto;
    transform: translateX(-50%);
    z-index: 40; /* 배경 위, 별도 대화창 레이어(z-index: 100000) 아래 */
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--lobby-portrait-fade-duration) ease,
        visibility 0s linear var(--lobby-portrait-fade-duration);
    pointer-events: none;
    user-select: none;
}
.lobby-cutscene-portrait.is-visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}
.lobby-cutscene-portrait[hidden] { display: none !important; }

/* Hall 01 입구 의성어 효과: 위치 / 크기 / 색상 / 길이 조정 */
.lobby-rustle {
    --rustle-left: 1355px;
    --rustle-top: 410px;
    --rustle-width: 76px;
    --rustle-height: 34px;
    --rustle-color: #FFFFFF;
    --rustle-duration: 2.8s; /* 기존 움직임 + 마지막 표시 유지 1초 */
    display: none;
    position: absolute;
    left: var(--rustle-left);
    top: var(--rustle-top);
    width: var(--rustle-width);
    height: var(--rustle-height);
    pointer-events: none;
    z-index: 30;
}

.lobby-rustle .rustle-line {
    position: absolute;
    top: -6px;
    left: 0;
    width: 100%;
    height: 46px;
    background: var(--rustle-color);
}
/* 그룹 기준 위 선 중심 Y=-4px → 8px: 오른쪽 끝은 유지 */
.lobby-rustle .rustle-line-left {
    clip-path: polygon(0 0,25% 0,25% 4px,50% 4px,50% 8px,75% 8px,75% 12px,100% 12px,100% 16px,75% 16px,75% 12px,50% 12px,50% 8px,25% 8px,25% 4px,0 4px);
}
/* 그룹 기준 아래 선 중심 Y=38px → 26px: 오른쪽 끝은 유지 */
.lobby-rustle .rustle-line-right {
    clip-path: polygon(0 42px,25% 42px,25% 38px,50% 38px,50% 34px,75% 34px,75% 30px,100% 30px,100% 34px,75% 34px,75% 38px,50% 38px,50% 42px,25% 42px,25% 46px,0 46px);
}
.lobby-rustle .rustle-label {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 10px;
    color: var(--rustle-color);
    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}
.lobby-rustle.is-playing {
    display: block;
    animation: lobbyRustle  var(--rustle-duration) steps(1) 1;
}
@keyframes lobbyRustle {
    /* 첫 1.44초의 움직임 시각 유지, 마지막 표시 구간만 1초 연장 */
    0%, 25.714285714286%, 32.142857142857%, 93.571428571429%, 100% { opacity: 0; transform: translateX(0); }
    6.428571428571%, 38.571428571429% { opacity: 1; transform: translateX(-2px); }
    12.857142857143%, 45% { opacity: 1; transform: translateX(2px); }
    19.285714285714%, 51.428571428571% { opacity: 1; transform: translateX(-1px); }
}

/* 로비 이벤트 전용 대화창 설정: 다른 이벤트와 독립적으로 조정 */
.event-dialogue-frame[data-dialogue-event='lobby'] {
    --lobby-dialogue-left: 6%;
    --lobby-dialogue-bottom: 3%;
    --lobby-dialogue-width: 88%;
    --lobby-dialogue-font-size: 2.2cqw;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .event-dialogue-panel {
    position: absolute;
    left: var(--lobby-dialogue-left);
    bottom: var(--lobby-dialogue-bottom);
    width: var(--lobby-dialogue-width);
    aspect-ratio: 1865 / 296;
    container-type: inline-size;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .dialogue-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .dialogue-name-box {
    position: absolute;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: 125%;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .dialogue-name-text {
    position: absolute;
    left: 5.3%;
    top: -13%;
    width: 20%;
    font-size: 2.3cqw;
    text-align: center;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .dialogue-text {
    position: absolute;
    left: 8%;
    top: 18%;
    bottom: auto;
    width: 80%;
    font-size: var(--lobby-dialogue-font-size);
    line-height: 1.4;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: normal;
}
.event-dialogue-frame[data-dialogue-event='lobby'] .dialogue-next {
    position: absolute;
    left: auto;
    right: 6%;
    top: auto;
    bottom: 12%;
    border-left-width: 1.2cqw;
    border-right-width: 1.2cqw;
    border-top-width: 1.7cqw;
}

/* ==============================
   플레이어 캐릭터
============================== */

.player {
    position: absolute;

    /* 화면에서 보이는 캐릭터 크기 */
    width: 150px;
    height: 150px;

    left: 300px;
    top: 500px;

    z-index: 99999;

    /* 스프라이트 시트 */
    background-image: url('characters/test_sheet.png');
    background-repeat: no-repeat;
    image-rendering: pixelated;

    /*
       현재 1124×1180 시트를 4×4로 읽음: 원본 셀 281×295px.
       표시 시트는 해상도와 관계없이 600×600, 표시 셀은 150×150px.
       아래 위치 보정과 클리핑의 3px는 원본이 아닌 화면 표시 좌표.
    */
    background-size: 580px 580px;

    /* 첫 프레임에서 테두리 부분을 살짝 밀어냄 */
    background-position: 0px 0px;

    /* 바깥쪽 3px 영역 가리기 */
    clip-path: none;
}

/* ==============================
   전시관 01
============================== */

.exhibition-scene {
    display: none;
}



#exhibition02Scene {
    position: relative;
}

#exhibition03Scene {
    position: relative;
}

/* ==============================
   Hall 02 - Bee NPC
============================== */

.hall2-bee {
    position: absolute;

    /* 임시 위치 */
    left: 120px;
    top: 390px;

    /* 임시 크기 */
    width: 165px;
    height: auto;

    /* 화면에서 15% 확대 */
    transform: scale(1.15);

    z-index: 10;
}

/* ==============================
   Hall 02 - T100 NPC
============================== */

.hall2-t100 {
    position: absolute;

    /* 임시 위치 */
    left: 1160px;
    top: 420px;

    /* 앉은 프레임을 20% 크기로 표시 */
    width: 68px;
    height: 114px;

    background-image: url('characters/hall2_npc_t100.png');
    background-repeat: no-repeat;

    /* 원본 이미지도 20%로 축소 */
    background-size: 354.8px 177.4px;

    /* 앉은 자세 좌표도 20% */
    background-position: -35.9px -47.8px;

    /* 화면에서 15% 확대 */
    transform: scale(1.15);

    z-index: 10;
}


/* ==============================
   Hall 02 - Rematch
============================== */

/* 노란 캐릭터 */
.hall2-rematch-yellow {
    position: absolute;

    /* 확정 위치 - 건드리지 않음 */
    left: 890px;
    top: 650px;

    /* 실제 캐릭터가 들어갈 표시 영역 */
    width: 115px;
    height: 114px;

    background-image: url('characters/hall2_rematch.png');
    background-repeat: no-repeat;

    /* 원본 × 30% */
    background-size: 572.4px 247.2px;

    /* 노랑 대기 자세 - 발 위치 기준 보정 */
    background-position: -65.4px -3.6px;

    /* 기존 위치에서 보이는 캐릭터 위치를 유지하기 위한 보정 */
    transform: translateX(65px) scale(1.15);

    z-index: 10;
}


/* 빨간 캐릭터 */
.hall2-rematch-red {
    position: absolute;

    /* 임시 위치 */
    left: 1150px;
    top: 650px;

    /* 한 프레임 크기 × 30% */
    width: 190.8px;
    height: 123.6px;

    background-image: url('characters/hall2_rematch.png');
    background-repeat: no-repeat;

    /* 전체 스프라이트 시트 × 20% */
    background-size: 572.4px 247.2px;

    /* 아랫줄 첫 번째 프레임 */
    background-position: 0 -123.6px;

    /* 화면에서 15% 확대 */
    transform: scale(1.15);

    z-index: 10;
}

/* ==============================
   Hall 02 - Rematch Ball
============================== */

.hall2-rematch-ball {
    position: absolute;

    /* 임시 위치 - 나중에 직접 조정 */
    left: 980px;
    top: 705px;

    /* 공 크기 */
    width: 100px;
    height: 100px;

    background-image: url('characters/hall2_ball.png');
    background-repeat: no-repeat;

    /* 첫 번째 공 프레임 표시 */
    background-size: auto 100px;
    background-position: left center;

    z-index: 11;
}

/* ==============================
   Hall 02 - Ball Rolling Animation
============================== */

@keyframes hall2BallRoll {
    0% {
        background-position: left center;
        transform: translateX(0);
    }

    50% {
        background-position: right center;
        transform: translateX(38px);
    }

    100% {
        background-position: left center;
        transform: translateX(0);
    }
}

.hall2-ball-rolling {
    animation: hall2BallRoll 0.2s steps(1) infinite;
}

/* ==============================
   Hall 01 - 여자 NPC
============================== */

.hall1-npc01 {
    position: absolute;

    /* 당근 토끼 오른쪽: 배경 기준 발 중심 (528.27, 547.42). */
    left: 956px;
    top: 590px;

    /* 한 프레임이 보이는 영역 */
    width: 125px;
    height: 200px;

    background-image: url('characters/npc_01.png');
    background-repeat: no-repeat;

    /* 일단 정면 캐릭터 표시 */
    background-size: 500px auto;
    background-position: 0 0;

    z-index: 10;
}

/* ==============================
   Hall 01 - 후드 NPC
============================== */

.hall1-darknidi {
    position: absolute;
    /* 2프레임 발 중심 차이 156px × 표시 배율(200 / 887). 원본은 유지. */
    --darknidi-frame-2-offset-x: 35.174746px;

    /* PC 간판 오른쪽 끝과 몸 절반 겹침: 배경 기준 발 중심 (1289.38, 718.64). */
    left: 1661px;
    top: 748px;

    /* 한 프레임이 보이는 영역 */
    width: 200px;
    height: 200px;

    --darknidi-sprite-image: url('characters/hall1_darknidi.png');
    background-repeat: no-repeat;

    /* 2프레임 스프라이트 시트 */
    background-size: 400px 200px;
    background-position: 0 0;
    image-rendering: pixelated;

    z-index: 10;
}

.hall1-darknidi::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--darknidi-sprite-image);
    background-repeat: no-repeat;
    background-size: 400px 200px;
    background-position: 0 0;
    image-rendering: pixelated;
    pointer-events: none;
}

/* 887×887 원본 프레임을 200×200으로 표시: 1초 / 1.5초 */
#exhibition01Scene[style*="display: block"] .hall1-darknidi.is-smoking::before {
    animation: hall1DarknidiSmoke 2.5s steps(1) infinite;
}
@keyframes hall1DarknidiSmoke {
    0%, 100% { background-position: 0 0; clip-path: inset(0); }
    40% {
        background-position: calc(-200px + var(--darknidi-frame-2-offset-x)) 0;
        /* 보정으로 들어오는 이전 셀의 픽셀만 가림 */
        clip-path: inset(0 0 0 var(--darknidi-frame-2-offset-x));
    }
}

/* ==============================
   Hall 01 NPC 상호작용 화살표
============================== */

@keyframes npcArrowFloat {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0);
    }
}

/* 엔딩 전용: 다른 장소와 도입부 대화창의 배치는 그대로 유지. */
.event-dialogue-frame[data-dialogue-event='ending'] { container-type: size; }
.event-dialogue-frame[data-dialogue-event='ending'] .event-dialogue-panel {
    height: clamp(100px, 22cqh, 230px);
    max-height: 46%;
    aspect-ratio: auto;
}
.event-dialogue-frame[data-dialogue-event='ending'] .dialogue-text {
    left: 6%;
    top: 16%;
    width: 84%;
    max-height: 68%;
    overflow-y: auto;
    pointer-events: auto;
    font-size: clamp(12px, 2.15cqw, 30px);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.event-dialogue-frame[data-dialogue-event='ending'] .dialogue-next {
    right: 5%;
    bottom: 13%;
    border-left-width: clamp(6px, 0.8cqw, 12px);
    border-right-width: clamp(6px, 0.8cqw, 12px);
    border-top-width: clamp(8px, 1.1cqw, 16px);
}
.ending-final-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: #000;
    color: #f4f1ea;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    overflow: hidden;
    font-family: 'NeoDunggeunmo', monospace;
}
.ending-final-lines { width: 94%; text-align: center; font-size: clamp(14px, 2.3vw, 32px); line-height: 1.7; }
.ending-final-lines p { margin: 0; min-height: 1.7em; opacity: 0; }
.ending-final-lines p + p { margin-top: 0.45em; }
.ending-final-lines p:nth-child(3) { margin-top: 2.6em; }

.ending-broadcast-preview {
    position: fixed;
    z-index: 1001;
    display: grid;
    grid-template-columns: var(--ending-image-share, 70%) minmax(0, 1fr);
    overflow: hidden;
    background: #000;
    pointer-events: none;
    container-type: inline-size;
    font-family: 'NeoDunggeunmo', monospace;
}
.ending-broadcast-preview[hidden], .ending-broadcast-image img[hidden] { display: none !important; }
.ending-broadcast-image { min-width: 0; min-height: 0; overflow: hidden; background: #242936; }
.ending-broadcast-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    image-rendering: pixelated;
}
.ending-chat {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #161a22;
    color: #eee;
    border-left: 2px solid #414958;
    box-sizing: border-box;
    overflow: hidden;
    font-size: clamp(8px, 1.25cqw, 18px);
}
.ending-chat-live {
    flex: none;
    color: #ff4d59;
    border-bottom: 2px solid #343c4a;
    padding: 0.65em 0.8em;
    font-weight: bold;
}
.ending-chat-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.ending-chat-stream { position: absolute; left: 0; right: 0; bottom: 0; }
.ending-chat-message { padding: 0.45em 0.8em; line-height: 1.45; overflow-wrap: anywhere; }

.hall1-interaction-arrow {
    animation: npcArrowFloat 0.8s ease-in-out infinite;
}

/* ==============================
   Hall03 트로피 반짝임
============================== */

/* Hall03 트로피 반짝임 */

.hall3-trophy-sparkle {
    position: absolute;

    width: 45px;
    height: 45px;

    pointer-events: none;
    z-index: 20;
}


/* 네가 잡아둔 위치 */
.sparkle1 {
    left: 167px;
    top: 527px;
}


/* 2, 3은 일단 기존에 잡았던 위치 */
.sparkle2 {
    left: 255px;
    top: 445px;
}

.sparkle3 {
    left: 310px;
    top: 575px;
}

/* ==============================
   Hall03 솜눈이 하트 효과
============================== */

.somnooni-heart {
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: none;
    z-index: 1000;

    image-rendering: pixelated;

    animation: somnooniHeartFloat 2.5s ease-out forwards;
}

@keyframes somnooniHeartFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0);
    }

    100% {
        opacity: 0;
        transform: translate(var(--heart-drift), -45px);
    }
}

/* 작업실 시작 안내 */
#workroomStartHint {
    position: fixed;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%);
    color: white;
    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 24px;
    z-index: 100005;
    animation: workroomHintBlink 1.5s ease-in-out infinite;
}

@keyframes workroomHintBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* HTML-only keyboard hint, positioned in the player's logical scene. */
.movement-hint {
    position: absolute;
    transform: translate(-50%, -100%);
    box-sizing: border-box;
    width: max-content;
    padding: 9px 12px;
    border: 2px solid #403A34;
    box-shadow: 3px 3px 0 #A99A80;
    background: #E8DCC5;
    color: #403A34;
    font-family: 'NeoDunggeunmo', sans-serif;
    font-size: 16px;
    line-height: 1.4;
    text-align: center;
    pointer-events: none;
    z-index: 100000;
    opacity: 1;
    transition: opacity 180ms ease-out;
}
.movement-hint[hidden] { display: none !important; }
.movement-hint.is-leaving { opacity: 0; }
.movement-hint-keys { display: flex; justify-content: center; gap: 12px; margin-bottom: 5px; }
.movement-hint-keys span { border: 1px solid #A99A80; padding: 2px 6px; }
.monitor-interaction-hint { padding: 6px 9px; z-index: 100002; }
.monitor-interaction-key { display: inline-block; border: 1px solid #A99A80; padding: 2px 6px; }
@media (prefers-reduced-motion: reduce) {
    .movement-hint.is-leaving { display: none; }
}

/* 초기 작업실의 작은 초기화 버튼과 전용 확인창. 기존 게임 배율 사용. */
.progress-reset-button {
    position: absolute;
    right: 28px;
    bottom: 28px;
    z-index: 1001;
    padding: 8px 12px;
    border: 2px solid #403a34;
    box-shadow: 3px 3px 0 #a99a80;
    background: #e8dcc5;
    color: #403a34;
    font: 18px/1.4 'NeoDunggeunmo', monospace;
    cursor: pointer;
}
.progress-reset-button[hidden] { display: none !important; }
.progress-reset-dialog {
    box-sizing: border-box;
    width: min(calc(680px * var(--game-scale, 1)), calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: calc(28px * var(--game-scale, 1));
    border: 3px solid #403a34;
    box-shadow: 6px 6px 0 #a99a80;
    background: #e8dcc5;
    color: #403a34;
    font: calc(24px * var(--game-scale, 1))/1.6 'NeoDunggeunmo', monospace;
}
.progress-reset-dialog::backdrop { background: rgb(0 0 0 / 55%); }
.progress-reset-dialog p { margin: 0 0 1em; word-break: keep-all; overflow-wrap: anywhere; }
.progress-reset-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.progress-reset-dialog button {
    padding: .45em .65em;
    border: 2px solid #403a34;
    box-shadow: 3px 3px 0 #a99a80;
    background: #f5eedf;
    color: #403a34;
    font: inherit;
    font-size: .8em;
    cursor: pointer;
}
.progress-reset-dialog button:focus-visible,
.progress-reset-button:focus-visible { outline: 3px solid #345c94; outline-offset: 3px; }
.progress-reset-dialog .progress-reset-error { color: #8a2929; font-size: .8em; }

/* 작업실 전용 대화창 */
body.workroom-dialogue .dialogue-box {
    position: fixed;
    left: 50%;
    top: auto;
    bottom: 18%;
    transform: translateX(-50%);
    width: 800px;
    height: auto;
}

body.workroom-dialogue .dialogue-text {
    position: fixed;
    left: 50%;
    top: auto;
    bottom: calc(20% + 47px);
    transform: translateX(-50%);
    width: 690px;
    font-size: 22px;
}

body.workroom-dialogue .dialogue-next {
    position: fixed;
    left: calc(50% + 335px);
    top: auto;
    bottom: calc(18% + 24px);
    border-left-width: 10px;
    border-right-width: 10px;
    border-top-width: 14px;
}
