/* ===========================================
   Visual Novel - Stylesheet
   =========================================== */

:root {
  --bg-color: #0a0a0f;
  --text-color: #f0f0f0;
  --accent: #d4af37;
  --accent-dim: #8a7330;
  --dialogue-bg: rgba(0, 0, 0, 0.75);
  --dialogue-border: rgba(212, 175, 55, 0.4);
  --modal-bg: rgba(15, 15, 25, 0.95);
  --button-bg: rgba(40, 40, 55, 0.9);
  --button-hover: rgba(70, 70, 90, 0.9);
  --font-main: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --font-title: 'Noto Serif KR', 'Batang', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #000;
  color: var(--text-color);
  font-family: var(--font-main);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ============ 화면 공통 ============ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.screen.visible {
  display: block;
}

/* ============ 타이틀 화면 ============ */
#screen-title {
  background: #000;
}

.title-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(40, 30, 60, 0.4), transparent 70%),
    linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f1419 100%);
  background-size: cover;
}

.title-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}

.title-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.title-main {
  font-family: var(--font-title);
  font-size: 5rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.title-sub {
  font-size: 1rem;
  letter-spacing: 0.4em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 2rem;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 220px;
}

.title-menu button {
  background: transparent;
  color: var(--text-color);
  border: 1px solid rgba(212, 175, 55, 0.2);
  padding: 0.8rem 1.5rem;
  font-family: var(--font-main);
  font-size: 1rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.title-menu button:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.title-menu button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.title-version {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
}

/* ============ 게임 화면 ============ */
#screen-game {
  background: #000;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* --- 배경 --- */
.layer-bg {
  background: #000;
}

.bg-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  /* VN 표준 dissolve: 700ms, Material standard easing */
  transition: opacity 700ms cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-image.active {
  opacity: 1;
}

/* placeholder 스타일 (에셋 없을 때) */
.bg-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* --- 캐릭터 --- */
.layer-char {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding-bottom: 30%;
}

.char-slot {
  position: absolute;
  bottom: 6%;            /* 다이얼로그 박스가 캐릭터 발 위로 살짝 겹쳐서 자연스럽게 가려지도록 위로 올림 */
  height: 88%;
  width: 33%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.4s ease;
  transform: translateY(20px);
  pointer-events: none;
}

.char-slot[data-pos="left"]   { left: 0; }
.char-slot[data-pos="center"] { left: 33.5%; }
.char-slot[data-pos="right"]  { right: 0; }

.char-slot.visible {
  opacity: 1;
  transform: translateY(0);
}

.char-slot.dim {
  filter: brightness(0.5) saturate(0.7);
}

/* --- 등장 애니메이션 (화면 밖에서 들어옴) --- */
.char-slot.enter-left {
  animation: char-enter-left 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.char-slot.enter-right {
  animation: char-enter-right 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes char-enter-left {
  0%   { opacity: 0; transform: translateX(-80%) translateY(0); }
  100% { opacity: 1; transform: translateX(0) translateY(0); }
}
@keyframes char-enter-right {
  0%   { opacity: 0; transform: translateX(80%) translateY(0); }
  100% { opacity: 1; transform: translateX(0) translateY(0); }
}

/* --- 퇴장 애니메이션 --- */
.char-slot.exit-left {
  animation: char-exit-left 0.5s ease-in both;
}
.char-slot.exit-right {
  animation: char-exit-right 0.5s ease-in both;
}
@keyframes char-exit-left {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(-80%); }
}
@keyframes char-exit-right {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(80%); }
}

/* --- 통통 튀기 (강조) — 위아래로만 튐, 스케일 변형 없음 --- */
.char-slot.bounce {
  animation: char-bounce 0.85s cubic-bezier(0.28, 0.84, 0.42, 1);
}
@keyframes char-bounce {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-40px); }
  45%  { transform: translateY(0); }
  60%  { transform: translateY(-18px); }
  78%  { transform: translateY(0); }
  88%  { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

/* --- 앉기 (의자에 앉는 모션 — 아래로 한 번 내려갔다 살짝 튐) --- */
.char-slot.sit {
  animation: char-sit 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes char-sit {
  0%   { transform: translateY(0); }
  55%  { transform: translateY(28px); }
  78%  { transform: translateY(12px); }
  100% { transform: translateY(0); }
}

/* --- 등장 느림 옵션 (slow) --- */
.char-slot.enter-left.enter-slow,
.char-slot.enter-right.enter-slow {
  animation-duration: 1.4s !important;
  animation-timing-function: cubic-bezier(0.18, 0.55, 0.3, 1) !important;
}

.char-slot img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom;
}

/* 입모양 토글용 — base는 항상 보이고, talk는 위에 absolute로 깔아 opacity만 바꿈 */
.char-slot .char-img-talk {
  position: absolute !important;
  left: 50% !important;
  bottom: 0 !important;
  transform: translateX(-50%) !important;
  opacity: 0 !important;
  transition: opacity 0.05s linear !important;
  pointer-events: none !important;
}
.char-slot .char-img-talk.mouth-open {
  opacity: 1 !important;
}

.char-slot .char-placeholder {
  width: 80%;
  height: 80%;
  background: rgba(80, 60, 100, 0.6);
  border: 2px dashed rgba(255,255,255,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  font-size: 1.2rem;
  text-align: center;
  padding: 1rem;
}

.char-slot .char-placeholder small {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-top: 0.5rem;
}

/* --- CG --- */
.layer-cg {
  display: flex;
  align-items: center;
  justify-content: center;
}
/* TV 꺼짐 효과 동안 CG 뒤 배경이 비치지 않게 layer 자체를 검게 */
.layer-cg.tvoff-bg {
  background: #000;
}

#cg-image {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: transparent;      /* 투명 PNG/WebP가 자연스럽게 비치도록 */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  /* opacity만 transition. max-width/max-height는 즉시 적용 (sd 클래스 add 시 깜빡임 방지) */
  transition: opacity 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  font-size: 1.3rem;
  letter-spacing: 0.2em;
  overflow: hidden;
}

/* SD CG: 화면 꽉 채우지 않고 중앙에 표시 (이전보다 ~30% 키움) */
#cg-image.sd {
  max-width: 60%;
  max-height: 80%;
  margin: auto;
  z-index: 2;
  position: relative;
}

/* SD CG일 때 화면 가장자리 검정 비네팅 — 일러스트에 시선 집중
   (.layer는 이미 position: absolute + inset: 0 이므로 has-sd에 position 덧붙이면
    레이아웃이 깨져 height 0이 됨 — 절대 position 재정의 금지) */
.layer-cg.has-sd::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 65% 75% at center,
    transparent 30%,
    rgba(0, 0, 0, 0.55) 70%,
    rgba(0, 0, 0, 0.92) 95%,
    #000 100%
  );
  z-index: 1;
  opacity: 0;
  transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1);
}
.layer-cg.has-sd::before { opacity: 1; }

/* Wine 매대 같은 짧은 클로즈업: 작게 위에서 떠올랐다 사라지는 효과 */
#cg-image.float {
  max-width: 45%;
  max-height: 78%;
  margin: auto;
  animation: cg-float-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  z-index: 2;
  position: relative;
}
.layer-cg.has-float::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 55% 70% at center,
    transparent 25%,
    rgba(0, 0, 0, 0.55) 70%,
    rgba(0, 0, 0, 0.92) 95%,
    #000 100%
  );
  z-index: 1;
}
@keyframes cg-float-in {
  0%   { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}

#cg-image.visible {
  opacity: 1;
}

#cg-image.placeholder {
  background: rgba(20, 20, 40, 0.85);
  border: 1px solid rgba(255,255,255,0.1);
}

/* --- CG 글리치 (지지직 + 살짝 흔들림) --- */
#cg-image.glitch {
  animation: cg-shake 0.18s linear infinite;
}
#cg-image.glitch::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.05) 0px,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: overlay;
  animation: cg-scan 1.4s linear infinite;
}
#cg-image.glitch::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(120, 200, 255, 0.04);
  mix-blend-mode: screen;
  animation: cg-flicker 0.27s steps(2) infinite;
}
@keyframes cg-shake {
  0%   { transform: translate(0, 0); filter: none; }
  20%  { transform: translate(-2px, 1px); filter: contrast(1.15) brightness(1.05); }
  40%  { transform: translate(2px, -1px); filter: hue-rotate(-3deg); }
  60%  { transform: translate(-1px, -1px); filter: contrast(1.1); }
  80%  { transform: translate(1px, 1px); filter: brightness(1.08); }
  100% { transform: translate(0, 0); filter: none; }
}
@keyframes cg-scan {
  0%   { transform: translateY(0); opacity: 0.6; }
  50%  { opacity: 1; }
  100% { transform: translateY(8px); opacity: 0.6; }
}
@keyframes cg-flicker {
  0%, 100% { opacity: 0; }
  50%      { opacity: 1; }
}

/* --- TV 꺼짐 (CRT 줄어들며 사라짐) --- */
#cg-image.tvoff {
  animation: tv-off 0.65s cubic-bezier(0.55, 0, 0.4, 1) forwards;
  transform-origin: 50% 50%;
}
@keyframes tv-off {
  0%   { transform: scale(1, 1);          filter: brightness(1);   opacity: 1; }
  20%  { transform: scale(1.02, 0.06);     filter: brightness(2.5); opacity: 1; }
  55%  { transform: scale(0.06, 0.012);    filter: brightness(3);   opacity: 1; }
  100% { transform: scale(0.0, 0.0);       filter: brightness(0);   opacity: 0; }
}

/* --- FX --- */
#overlay-fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  /* 기본 transition (swipe는 JS에서 in/out 별도 easing 적용) */
  transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 8;     /* 다이얼로그(z:15) 아래에 두어 암전 상태에서도 독백 보이게 */
}

#overlay-fade.active {
  opacity: 1;
}

/* --- 중앙 타이프라이터 (검은 화면 위 한 글자씩) --- */
#center-type {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-size: 2.6rem;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.18);
  opacity: 0;
  transition: opacity 0.7s ease;
  z-index: 50;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  font-weight: 300;
}
#center-type.visible { opacity: 1; }

/* --- 크레딧 스크롤 --- */
#credits-roll {
  position: absolute;
  inset: 0;
  background: #000;
  display: none;
  overflow: hidden;
  z-index: 200;
  pointer-events: auto;
  cursor: pointer;
}
#credits-roll.visible { display: block; }

#credits-content {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 80%;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.88);
  text-align: center;
  font-size: 1rem;
  line-height: 1.7;
  padding: 2rem 0;
  transform: translate(-50%, 0);
}
#credits-roll.visible #credits-content {
  animation: credits-scroll 42s linear forwards;
}

@keyframes credits-scroll {
  0%   { transform: translate(-50%, 0); }
  100% { transform: translate(-50%, calc(-100% - 60vh)); }
}

.credits-section { margin: 3rem 0; }
.credits-section h2 {
  font-family: var(--font-title);
  color: var(--accent);
  font-size: 2.2rem;
  letter-spacing: 0.3em;
  font-weight: 300;
  margin-bottom: 0.5rem;
}
.credits-section h3 {
  color: var(--accent);
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  margin-bottom: 1.2rem;
  font-weight: 400;
}
.credits-sub {
  font-size: 0.85rem;
  letter-spacing: 0.4em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 1rem;
}
.credits-name {
  font-size: 1.15rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.95);
}
.credit-item {
  margin: 1.4rem 0;
  padding: 0 0.5rem;
}
.credit-item .credit-name {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
}
.credit-item .credit-meta {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.25rem;
}
.credit-item .credit-url {
  font-size: 0.72rem;
  color: rgba(212, 175, 55, 0.55);
  font-family: 'Consolas', monospace;
  margin-top: 0.15rem;
}
.credits-end {
  margin-top: 6rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.2em;
}

/* --- 클릭 영역 --- */
#click-area {
  position: absolute;
  inset: 0;
  bottom: 250px;
  cursor: pointer;
  z-index: 5;
}

/* --- 씬 타이틀 --- */
#scene-title {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-size: 2.5rem;
  letter-spacing: 0.4em;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

#scene-title.visible {
  opacity: 1;
}

/* --- 다이얼로그 박스 (캐릭터 발이 가려져도 자연스럽도록 더 진한 검정 그라데이션) --- */
#ui-dialogue {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 260px;
  background: linear-gradient(to top,
    rgba(0,0,0,0.98) 0%,
    rgba(0,0,0,0.95) 35%,
    rgba(0,0,0,0.82) 65%,
    rgba(0,0,0,0.45) 85%,
    rgba(0,0,0,0) 100%);
  padding: 2rem 4rem 1.6rem;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.name-plate {
  height: 36px;
  margin-bottom: 0.6rem;
}

#speaker-name {
  display: inline-block;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.25rem 1.1rem;
  border-left: 3px solid var(--accent);
  letter-spacing: 0.1em;
  min-height: 1.5rem;
}

#speaker-name:empty {
  display: none;
}

.dialogue-content {
  flex: 1;
  position: relative;
  font-size: 1.4rem;
  line-height: 1.75;
  color: var(--text-color);
}

#dialogue-text {
  white-space: pre-wrap;
  text-align: left;
  /* 한 줄짜리도 3줄 공간 미리 확보 → 글자 늘어나도 위 라인 안 밀림 */
  min-height: calc(1.75em * 3);
  align-self: flex-start;
  font-size: 1.4rem;
  letter-spacing: 0;
  transform-origin: left center;
}

/* @grow — 외침/충격: 한 줄에만 폰트가 점점 커지고 살짝 흔들림 */
@keyframes vn-grow-text {
  0%   { font-size: 1.4rem; letter-spacing: 0;     text-shadow: none; }
  60%  { font-size: 2.6rem; letter-spacing: 0.03em; text-shadow: 0 0 12px rgba(255,80,80,0.35); }
  100% { font-size: 3.0rem; letter-spacing: 0.05em; text-shadow: 0 0 18px rgba(255,80,80,0.5); }
}
#dialogue-text.grow {
  animation: vn-grow-text 1.6s cubic-bezier(0.3, 0, 0.7, 1) forwards;
  color: #ffdada;
  font-weight: 700;
}

#dialogue-text.narration {
  color: rgba(255, 255, 255, 0.85);
  font-style: italic;
  text-align: left;
  padding-top: 0.5rem;
}

/* 다이얼로그는 페이드 위에 떠야 암전 상태에서도 독백 보임 */
#ui-dialogue {
  z-index: 15;
}

#dialogue-arrow {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 0.9rem;
  color: var(--accent);
  opacity: 0;
  animation: arrow-blink 1.2s infinite;
}

#dialogue-arrow.visible {
  opacity: 1;
}

@keyframes arrow-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- 빠른 메뉴 --- */
#ui-quick {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  display: flex;
  gap: 0.3rem;
  pointer-events: auto;
  z-index: 20;             /* click-area(z:5)보다 위에 와야 클릭됨 */
}

#ui-quick button {
  background: var(--button-bg);
  color: var(--text-color);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  font-family: var(--font-main);
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

#ui-quick button:hover {
  background: var(--button-hover);
  color: var(--accent);
}

#ui-quick button:active {
  transform: scale(0.92);
  background: rgba(212, 175, 55, 0.4);
  color: #fff;
  border-color: var(--accent);
}

#ui-quick button.active {
  background: rgba(212, 175, 55, 0.3);
  color: var(--accent);
  border-color: var(--accent);
}

/* ============ 모달 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
}

.modal.visible {
  display: flex;
}

.modal-box {
  background: var(--modal-bg);
  border: 1px solid rgba(212, 175, 55, 0.3);
  width: 80%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
}

.modal-large {
  max-width: 1000px;
}

.modal-small {
  max-width: 400px;
}

.modal-box header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-box header h2 {
  font-family: var(--font-title);
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-size: 1.3rem;
}

.modal-close {
  background: transparent;
  color: var(--text-color);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

/* --- 설정 모달 --- */
.config-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.config-row label {
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.1em;
  font-size: 0.95rem;
}

.config-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.config-row select,
.config-row button {
  background: var(--button-bg);
  color: var(--text-color);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.4rem 0.8rem;
  font-family: var(--font-main);
  cursor: pointer;
  border-radius: 2px;
}

.cfg-value {
  text-align: right;
  color: var(--accent);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* --- 세이브/로드 --- */
.save-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.save-slot {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 1rem;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  min-height: 100px;
  transition: all 0.15s ease;
}

.save-slot:hover {
  border-color: var(--accent);
  background: rgba(20,20,30,0.6);
}

.save-slot .slot-thumb {
  width: 120px;
  height: 70px;
  background: rgba(0,0,0,0.6);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
  font-size: 0.7rem;
}

.save-slot .slot-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.save-slot .slot-title {
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

.save-slot .slot-preview {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.save-slot .slot-date {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
}

.save-slot.empty {
  color: rgba(255,255,255,0.3);
  font-style: italic;
  align-items: center;
  justify-content: center;
}

/* --- 로그(백로그) --- */
#log-entries {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.log-entry {
  padding: 0.6rem 0.8rem;
  border-left: 2px solid transparent;
  background: rgba(0,0,0,0.3);
}

.log-entry.dialogue {
  border-left-color: var(--accent);
}

.log-entry.narration {
  border-left-color: rgba(255,255,255,0.3);
  font-style: italic;
}

.log-entry .log-name {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.log-entry .log-text {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-color);
}

/* --- 확인 다이얼로그 --- */
#confirm-message {
  margin-bottom: 1.5rem;
  text-align: center;
  line-height: 1.6;
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.confirm-buttons button {
  background: var(--button-bg);
  color: var(--text-color);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.6rem 2rem;
  font-family: var(--font-main);
  cursor: pointer;
  letter-spacing: 0.2em;
  border-radius: 2px;
}

.confirm-buttons button:hover {
  background: var(--button-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ 유틸 ============ */
.hidden { display: none !important; }

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
}
::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.5);
}

/* ============================================================
   주 파딱 — 핸드폰 UI
   ============================================================ */
.phone-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: 360px;
  height: 640px;
  max-width: 78vw;
  max-height: 78vh;
  background: #14161a;
  border-radius: 38px;
  box-shadow:
    0 0 0 4px #1f2228 inset,
    0 0 0 6px #2c3036 inset,
    0 28px 60px rgba(0,0,0,0.7),
    0 0 80px rgba(120,160,255,0.04);
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease, transform 0.55s ease;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.phone-frame.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.phone-frame::before {
  /* 노치/스피커 바 */
  content: '';
  position: absolute;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 22px;
  background: #0c0d10;
  border-radius: 0 0 14px 14px;
  z-index: 2;
}
.phone-screen {
  flex: 1;
  background: #f5f3ee;
  color: #1c1c20;
  border-radius: 22px;
  padding: 44px 22px 22px;
  font-size: 1rem;
  line-height: 1.55;
  font-family: var(--font-main);
  overflow-y: auto;
  position: relative;
  transition: opacity 0.25s ease;
}
.phone-screen.swap {
  opacity: 0;
}
.phone-screen.off {
  background: #050608;
  color: transparent;
}
.phone-line {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  margin-bottom: 0.55em;
}
.phone-line.visible {
  opacity: 1;
  transform: translateY(0);
}

/* DM/카톡식 말풍선 */
.phone-bubble {
  display: block;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 0.5em;
  max-width: 82%;
  font-size: 0.86rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.phone-bubble-mine {
  background: #fee500;       /* 카톡 노란색 */
  color: #1a1a1a;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.phone-bubble-other {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.08);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}
.phone-divider {
  border: 0;
  border-top: 1px solid rgba(0,0,0,0.18);
  margin: 0.6em 0;
}
.phone-header {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: rgba(0,0,0,0.45);
  text-align: center;
  margin-bottom: 0.4em;
}
.phone-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  margin: 0.5em 0 0.4em;
  letter-spacing: 0.02em;
}
.phone-body {
  font-size: 0.95rem;
}
.phone-image {
  width: 100%;
  margin: 0.8em 0;
  background: linear-gradient(135deg, #c8c2b3, #a39c8c);
  height: 130px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,0.45);
  font-size: 0.8rem;
  font-style: italic;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.phone-emphasis {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 휴대폰 안에서의 작은 박스 (사과글, 쪽지 등) */
.phone-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
  font-size: 0.9rem;
}
.phone-card-meta {
  font-size: 0.72rem;
  color: rgba(0,0,0,0.5);
  margin-bottom: 4px;
}


/* ============================================================
   주 파딱 — 회상 시퀀스 (모브 SD 패널 누적)
   ============================================================ */
.flashback-tint {
  position: absolute;
  inset: 0;
  /* 가운데는 살짝 어둡고 외곽으로 갈수록 거의 검정 — 비네팅 */
  background:
    radial-gradient(ellipse at center, rgba(18, 24, 40, 0.78) 0%, rgba(0, 0, 0, 0.98) 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.0s ease;
  z-index: 25;
}
.flashback-tint.visible {
  opacity: 1;
}
.flashback-grid {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.0s ease;
  z-index: 26;
}
.flashback-grid.visible {
  opacity: 1;
}
.flashback-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  /* 패널 크기를 40% 키움 — 단, 화면 밖으로 나가지 않게 vmin은 100으로 cap */
  width: min(100vmin, 1010px);
  height: min(100vmin, 1010px);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.7));
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.86);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.flashback-panel.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}


/* 회상 중 다이얼로그 박스 — 검은 배경 위에 텍스트가 안 묻히게 */
body.flashback-on #ui-dialogue {
  background: rgba(0, 0, 0, 0.85) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  z-index: 40;
}
body.flashback-on #dialogue-text {
  color: #f5f5f5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 0 18px rgba(0,0,0,0.7);
}

/* ============================================================
   주 파딱 — 시간 자막
   ============================================================ */
.subtitle-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1em 2.4em;
  font-family: var(--font-title);
  font-size: 2.2rem;             /* 1.5 → 2.2rem 크게 */
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55); /* 어두운 반투명 배경으로 가독성 ↑ */
  border-top: 2px solid rgba(255,255,255,0.85);
  border-bottom: 2px solid rgba(255,255,255,0.85);
  text-shadow: 0 2px 12px rgba(0,0,0,0.85), 0 0 24px rgba(0,0,0,0.6);
  z-index: 20;                   /* 다이얼로그(15)·페이드(8)보다 위 */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease;
  z-index: 28;
  white-space: nowrap;
  text-align: center;
}
.subtitle-box.visible {
  opacity: 1;
}


/* ============================================================
   주딱 파딱 — 핸드폰 부속 UI (알림 / 스피너 / 타이핑 / 잠금화면)
   ============================================================ */

/* 핸드폰이 hide 될 때 화면 콘텐츠도 같이 페이드아웃 */
.phone-frame:not(.visible) .phone-screen {
  opacity: 0;
  transition: opacity 0.45s ease;
}

/* 잠금화면 */
.phone-lock {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(0,0,0,0.7);
  font-size: 1.1rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
}
.phone-lock .lock-time {
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: 0.04em;
}
.phone-lock .lock-date {
  font-size: 0.85rem;
  margin-top: 0.3em;
  opacity: 0.65;
}

/* 알림 바 — 상단에서 슬라이드 다운 */
.notification-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: rgba(38, 40, 48, 0.94);
  color: #f3f3f5;
  border-radius: 14px;
  padding: 10px 14px;
  transform: translateY(-160%);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.3, 1.05), opacity 0.4s ease;
  z-index: 6;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  font-size: 0.85rem;
  cursor: pointer;
}
.notification-bar.visible {
  transform: translateY(0);
  opacity: 1;
}
.notification-bar.pressed {
  transform: translateY(0) scale(0.96);
  background: rgba(60, 64, 76, 0.98);
  transition: transform 0.12s ease, background 0.12s ease;
}
.notification-bar .notif-app {
  font-size: 0.7rem;
  opacity: 0.7;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.notification-bar .notif-title {
  font-weight: 600;
  line-height: 1.35;
}

/* 로딩 스피너 */
.phone-spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 35%;
  color: rgba(0,0,0,0.55);
  font-size: 0.9rem;
}
.phone-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: rgba(0,0,0,0.55);
  border-radius: 50%;
  animation: phone-spin 0.85s linear infinite;
}
@keyframes phone-spin {
  to { transform: rotate(360deg); }
}

/* 메시지 받는 중 — 점 3개 통통 */
.phone-typing {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-top: 2em;
  height: 18px;
}
.phone-typing span {
  width: 9px;
  height: 9px;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  animation: phone-bounce 1.2s ease infinite;
}
.phone-typing span:nth-child(2) { animation-delay: 0.18s; }
.phone-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes phone-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-7px); opacity: 1; }
}

/* 핸드폰 화면 안 큰 이미지 (지도, 도게자) */
.phone-image-bg {
  background-position: center;
  background-size: cover;
  height: 200px;
  border-radius: 10px;
  color: transparent;
  background-color: #2d2d35;
  background-image: none;
}

/* 다이얼로그 박스 페이드 트랜지션 (fade out 시 같이 숨길 수 있도록) */
#ui-dialogue {
  transition: opacity 0.6s ease, background 0.6s ease;
}
#ui-dialogue.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   주딱 파딱 — 메인 타이틀 화면 새 디자인
   ============================================================ */
.title-content {
  /* 기존 flex 흐름은 보조용. 핵심 요소들은 absolute로 직접 배치 */
  display: block !important;
  position: absolute;
  inset: 0;
}

.title-main {
  position: absolute;
  left: 50%;
  top: 14vh;
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  font-weight: 900;
  font-size: clamp(2.6rem, 7.5vw, 5.4rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.title-line {
  display: block;
}
.title-line-1 {
  display: flex;
  justify-content: center;
  gap: 0.35em;
  margin-bottom: 0.06em;
}
.title-judak {
  color: #ff8c2a;
  text-shadow:
    0 0 22px rgba(255, 140, 42, 0.45),
    0 4px 14px rgba(0, 0, 0, 0.65);
}
.title-padak {
  color: #4a9eff;
  text-shadow:
    0 0 22px rgba(74, 158, 255, 0.45),
    0 4px 14px rgba(0, 0, 0, 0.65);
}
.title-line-2 {
  font-size: 0.78em;
  letter-spacing: 0.22em;
  color: #f0e9d8;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-left: 0.18em; /* letter-spacing 보정 */
}

/* 메뉴 — 왼쪽 세로 정렬, 화면 세로 가운데 */
.title-menu {
  position: absolute !important;
  left: 6vw !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 14px !important;
  width: clamp(180px, 20vw, 260px) !important;
  margin: 0 !important;
}
.title-menu button {
  width: 100%;
  text-align: center;
}

.title-version {
  position: absolute;
  right: 1.5vw;
  bottom: 1.2vh;
  font-size: 0.72rem;
  opacity: 0.5;
  margin: 0;
}


/* ============================================================
   추가 연출 — 흔들림 / 깜빡임 / 슬라이드 / 캐릭터 회색
   ============================================================ */

/* === 지진 흔들림 (@shake) === */
@keyframes vn-shake {
  0%, 100% { transform: translate(0, 0); }
  10%      { transform: translate(-7px, 2px); }
  20%      { transform: translate(7px, -2px); }
  30%      { transform: translate(-6px, -2px); }
  40%      { transform: translate(6px, 3px); }
  50%      { transform: translate(-5px, 1px); }
  60%      { transform: translate(5px, -1px); }
  70%      { transform: translate(-3px, 2px); }
  80%      { transform: translate(3px, -1px); }
  90%      { transform: translate(-2px, 0); }
}
#app.shaking {
  animation: vn-shake 0.45s linear infinite;
}

/* === 눈 깜빡임 (정신 차림 — @blink) === */
@keyframes vn-blink {
  0%   { filter: blur(10px) brightness(0.4); opacity: 0; }
  12%  { filter: blur(5px)  brightness(0.7); opacity: 0.7; }
  22%  { filter: blur(9px)  brightness(0.4); opacity: 0.2; }   /* 1차 깜빡 */
  40%  { filter: blur(3px)  brightness(0.85); opacity: 0.9; }
  55%  { filter: blur(5px)  brightness(0.6); opacity: 0.5; }   /* 2차 깜빡 (약함) */
  72%  { filter: blur(1px)  brightness(0.95); opacity: 1; }
  100% { filter: blur(0)    brightness(1);   opacity: 1; }
}
.blink-eyes .layer-bg,
.blink-eyes .layer-char,
.blink-eyes .layer-cg {
  animation: vn-blink 1.8s ease-out;
}

/* === 화면 전환 슬라이드 (@swipe) — 좌→우 슬라이드 인 === */
@keyframes vn-bg-slide-in {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(0); }
}
@keyframes vn-bg-slide-out {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
.bg-image.slide-enter {
  animation: vn-bg-slide-in 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.bg-image.slide-exit {
  animation: vn-bg-slide-out 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* === 비활성 캐릭터 회색 (대화 안 하는 캐릭터) — game.js가 .inactive 자동 부여 === */
.char-slot.inactive {
  filter: grayscale(0.85) brightness(0.55) saturate(0.6);
}
.char-slot {
  /* filter도 transition에 포함 (이미 dim용으로 있을 수 있음) */
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.4s ease;
}

/* === 인게임 설정창 — 메인 메뉴 vn-settings 톤과 통일 (단순) === */
#modal-config .modal-box,
#modal-save .modal-box,
#modal-load .modal-box,
#modal-log .modal-box,
#modal-confirm .modal-box {
  background: rgba(30, 22, 18, 0.95);
  border: 1px solid rgba(199, 178, 153, 0.18);
  border-radius: 16px;
  color: #fef3e0;
  font-family: 'Pretendard Variable', Pretendard, 'Noto Sans KR', sans-serif;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}
#modal-config header h2,
#modal-save header h2,
#modal-load header h2,
#modal-log header h2,
#modal-confirm header h2 {
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  color: #f8eed4;
  letter-spacing: -0.01em;
}
.modal-close {
  color: #8a7460 !important;
  background: transparent !important;
  border: none !important;
  font-size: 22px !important;
}
.modal-close:hover { color: #fef3e0 !important; }

.config-row label {
  color: #c7b299 !important;
  font-weight: 500 !important;
}
.config-row input[type="range"] {
  accent-color: #fb923c;
}
.cfg-value {
  color: #fef3e0 !important;
}
#confirm-yes, #confirm-no, #btn-fullscreen {
  background: transparent !important;
  border: 1px solid rgba(232, 212, 168, 0.22) !important;
  color: #c7b299 !important;
  font-family: inherit !important;
  border-radius: 10px !important;
  padding: 8px 18px !important;
  font-weight: 600 !important;
  transition: all 180ms ease;
}
#confirm-yes {
  background: #fb923c !important;
  border-color: #fb923c !important;
  color: #13100F !important;
}
#confirm-yes:hover { background: #fdba74 !important; border-color: #fdba74 !important; }
#confirm-no:hover, #btn-fullscreen:hover { color: #fef3e0 !important; border-color: rgba(232, 212, 168, 0.4) !important; }
