/* ===========================================
   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: 100%;
  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;
  transition: opacity 0.8s ease;
}

.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: 0;
  height: 90%;
  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: #000;             /* 배경 가리기용 검은 백드롭 */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  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;
}

#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: opacity 0.6s ease;
  pointer-events: none;
}

#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: 230px;
  background: linear-gradient(to top,
    rgba(0,0,0,0.92) 0%,
    rgba(0,0,0,0.8) 70%,
    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;
}

#dialogue-text.narration {
  color: rgba(255, 255, 255, 0.85);
  font-style: italic;
  text-align: center;
  padding-top: 0.5rem;
}

#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; }

/* ============================================================
   회전 안내 (모바일 세로 모드)
   ============================================================ */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: var(--font-main);
  text-align: center;
  letter-spacing: 0.2em;
  font-size: 1.1rem;
  line-height: 1.6;
  padding: 2rem;
}
#rotate-hint .rotate-icon {
  font-size: 4rem;
  animation: rotate-spin 2.4s ease-in-out infinite;
  margin-bottom: 1.5rem;
  display: inline-block;
}
@keyframes rotate-spin {
  0%, 50%, 100% { transform: rotate(0deg); }
  20%           { transform: rotate(90deg); }
  70%           { transform: rotate(90deg); }
}

/* ============================================================
   모바일 — 작은 화면 (터치, 폰트 축소, 패딩 조정)
   ============================================================ */
@media (max-width: 900px) {
  /* 타이틀 */
  .title-main {
    font-size: 3rem;
    letter-spacing: 0.25em;
  }
  .title-sub {
    font-size: 0.8rem;
    letter-spacing: 0.3em;
  }
  .title-menu {
    min-width: 70vw;
    max-width: 320px;
    gap: 0.6rem;
  }
  .title-menu button {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    min-height: 48px;     /* 터치 권장 영역 */
  }
  .title-version {
    font-size: 0.7rem;
  }

  /* 다이얼로그 박스 */
  #ui-dialogue {
    height: 36vh;
    min-height: 160px;
    max-height: 230px;
    padding: 1rem 1.3rem 1rem;
  }
  .dialogue-content {
    font-size: 1.2rem;
    line-height: 1.65;
  }
  #speaker-name {
    font-size: 1.25rem;
    padding: 0.18rem 0.8rem;
  }
  .name-plate {
    height: 32px;
    margin-bottom: 0.4rem;
  }

  /* 빠른 메뉴 — 터치 영역 확대 */
  #ui-quick {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.25rem;
  }
  #ui-quick button {
    padding: 0.6rem 0.7rem;
    font-size: 0.7rem;
    min-height: 38px;
    min-width: 44px;
  }

  /* 씬 타이틀 */
  #scene-title {
    font-size: 1.7rem;
    letter-spacing: 0.3em;
  }

  /* 캐릭터 슬롯 — 다이얼로그 박스 위로 약간 올림 */
  .layer-char {
    padding-bottom: 36vh;
  }
  .char-slot {
    height: 80%;
  }

  /* 모달 */
  .modal-box {
    width: 95%;
    max-height: 90vh;
  }
  .modal-box header {
    padding: 0.75rem 1rem;
  }
  .modal-box header h2 {
    font-size: 1.05rem;
    letter-spacing: 0.15em;
  }
  .modal-close {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }
  .modal-body {
    padding: 1rem;
  }

  /* 설정 행 */
  .config-row {
    grid-template-columns: 100px 1fr 50px;
    gap: 0.6rem;
    padding: 0.6rem 0;
  }
  .config-row label {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
  }
  .config-row select,
  .config-row button {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    min-height: 40px;
  }
  .config-row input[type="range"] {
    height: 32px;
  }

  /* 세이브 슬롯 — 1열 */
  .save-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .save-slot {
    padding: 0.7rem;
    min-height: 80px;
  }
  .save-slot .slot-thumb {
    width: 90px;
    height: 55px;
  }

  /* 확인 다이얼로그 */
  .confirm-buttons button {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    min-height: 48px;
    flex: 1;
  }

  /* 클릭 영역 — 다이얼로그 박스 위쪽까지만 */
  #click-area {
    bottom: 36vh;
  }

  /* 중앙 타이프라이터 (우 리 는 살 ...) */
  #center-type {
    font-size: 1.6rem;
    letter-spacing: 0.2em;
    white-space: normal;
    width: 90%;
    line-height: 1.6;
  }

  /* 크레딧 */
  #credits-content {
    width: 90%;
    font-size: 0.92rem;
    line-height: 1.6;
  }
  .credits-section h3 {
    font-size: 0.95rem;
  }
  .credit-item .credit-name {
    font-size: 0.85rem;
  }
  .credit-item .credit-meta {
    font-size: 0.72rem;
  }
  .credit-item .credit-url {
    font-size: 0.66rem;
  }

  /* 백로그 */
  .log-entry {
    padding: 0.5rem 0.6rem;
  }
  .log-entry .log-name {
    font-size: 0.78rem;
  }
  .log-entry .log-text {
    font-size: 0.88rem;
  }
}

/* ============================================================
   초소형 화면 (스마트폰 가로 - 짧은 높이)
   ============================================================ */
@media (max-width: 900px) and (max-height: 450px) {
  #ui-dialogue {
    height: 42vh;
    min-height: 130px;
    padding: 0.7rem 1rem 0.6rem;
  }
  .dialogue-content {
    font-size: 1.05rem;
    line-height: 1.55;
  }
  #speaker-name {
    font-size: 1.05rem;
  }
  .name-plate {
    height: 26px;
    margin-bottom: 0.25rem;
  }
  .layer-char {
    padding-bottom: 42vh;
  }
  #click-area {
    bottom: 42vh;
  }
  #scene-title {
    font-size: 1.4rem;
  }
}

/* ============================================================
   세로 모드 (모바일 portrait) — 회전 안내 표시
   ============================================================ */
@media (max-width: 900px) and (orientation: portrait) {
  #rotate-hint {
    display: flex;
  }
  /* 세로일 땐 게임 일시 가림 */
  #app {
    visibility: hidden;
  }
}

/* 터치 디바이스: hover 효과 비활성, :active 강조 */
@media (hover: none) {
  .title-menu button:hover,
  #ui-quick button:hover,
  .modal-close:hover,
  .save-slot:hover,
  .confirm-buttons button:hover {
    background: var(--button-bg);
    color: var(--text-color);
    border-color: rgba(255,255,255,0.1);
  }
  .title-menu button:active {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(0.97);
  }
  .save-slot:active {
    border-color: var(--accent);
    background: rgba(20,20,30,0.6);
  }
  .confirm-buttons button:active {
    background: rgba(212, 175, 55, 0.3);
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(0.96);
  }
}

::-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);
}
