:root {
  --bg: #0b0a0e;
  --panel: rgba(23, 19, 28, 0.94);
  --panel-solid: #17131c;
  --panel-2: #221c2a;
  --line: rgba(231, 184, 82, 0.32);
  --line-soft: rgba(244, 237, 225, 0.1);
  --gold: #e7b852;
  --gold-hi: #f8dc8e;
  --gold-lo: #b9822c;
  --text: #f4ede1;
  --muted: #b9ae9c;
  --ember: #ff8a2a;
  --ink: #1b1308;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --display: 'Cinzel', 'Times New Roman', serif;
  --title: 'Maplestory', 'Pretendard', sans-serif;
}

/* 메이플스토리 서체 (넥슨, 무료·상업적 사용 가능) — 장소 이름표와 장소 제목에 */
@font-face {
  font-family: 'Maplestory';
  src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@2.1/MaplestoryOTFBold.woff') format('woff');
  font-weight: 700; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--gold-hi); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ── 모드 전환 ───────────────────────────── */
body.mode-world { overflow: hidden; overscroll-behavior: none; height: 100dvh; }
body.mode-world .classic { display: none; }
body.mode-classic #world,
body.mode-classic .labels,
body.mode-classic .hud,
body.mode-classic .intro,
body.mode-classic .dialog,
body.mode-classic .sheet,
body.mode-classic .scrim { display: none !important; }

/* ── 3D 캔버스 ───────────────────────────── */
#world {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── 이름표 ───────────────────────────── */
.labels {
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  overflow: hidden;
}
.labels.on { opacity: 1; }
.label {
  position: absolute; left: 0; top: 0;
  pointer-events: auto;
  display: inline-flex; align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 5px;
  border: 1px solid rgba(231, 184, 82, 0.45);
  background: rgba(22, 15, 10, 0.84);
  color: #f3e6c8;
  font-family: var(--title);
  font-size: 13px; font-weight: 700; letter-spacing: 0;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.2s, border-color 0.2s;
  will-change: transform;
}
.label::after {
  content: '';
  position: absolute; left: 50%; bottom: -5px;
  width: 8px; height: 8px;
  background: inherit;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.label.is-near { background: #e2b04a; border-color: #f8dc8e; color: #24160a; }
.label-npc { font-size: 12px; }

/* ── HUD ───────────────────────────── */
.hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  background: linear-gradient(rgba(10, 8, 14, 0.55), rgba(10, 8, 14, 0));
}
.hud-brand {
  margin: 0;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: 0.04em;
  color: var(--gold-hi);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.hud-brand b { color: var(--text); font-weight: 700; }
.pill {
  pointer-events: auto;
  min-height: 36px; padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 15, 26, 0.72);
  font-size: 13px; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 0 calc(6px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.hud-copy {
  margin: -4px 0 0; font-size: 11px; letter-spacing: 0.02em;
  color: rgba(255, 246, 223, 0.6); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.hud-row { width: 100%; display: flex; align-items: center; gap: 8px; padding-right: calc(14px + var(--safe-r)); }
.quick {
  pointer-events: auto;
  flex: 1; min-width: 0;
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 4px 4px 4px calc(14px + var(--safe-l));
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.quick::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.chip:active { transform: translateY(1px); background: var(--panel-2); }
.fab {
  pointer-events: auto;
  flex: none;
  width: 54px; height: 54px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 10px;
  border: 1px solid var(--gold);
  background: linear-gradient(160deg, #3a2a14, #1c140a);
  color: var(--gold-hi);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(248, 220, 142, 0.25);
}
.prompt {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--gold-hi);
  background: linear-gradient(180deg, #f6d98a, #d59c3c);
  color: var(--ink);
  font-size: 15px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(231, 184, 82, 0.18);
  animation: pop 0.25s ease-out;
}
.fab-text { font-size: 10px; font-weight: 800; letter-spacing: 0.02em; line-height: 1; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 대화창 ───────────────────────────── */
.dialog {
  position: fixed;
  left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r));
  bottom: calc(88px + var(--safe-b));
  max-width: 560px; margin: 0 auto;
  padding: 18px 18px 22px;
  border-radius: 16px;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, rgba(34, 27, 40, 0.97), rgba(19, 15, 23, 0.97));
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), inset 0 0 0 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
.dialog.on { opacity: 1; transform: none; }
.dialog-who {
  position: absolute; top: -14px; left: 14px;
  margin: 0; padding: 2px 12px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  font-size: 13px; font-weight: 800;
}
.dialog-text { margin: 4px 0 0; font-size: 16px; line-height: 1.65; min-height: 3.3em; }
.dialog-next {
  position: absolute; right: 18px; bottom: 12px;
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 7px solid var(--gold-hi);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── 정보 시트 ───────────────────────────── */
.scrim {
  position: fixed; inset: 0;
  background: rgba(5, 3, 8, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 30;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 600px; margin: 0 auto;
  max-height: 80dvh;
  display: flex; flex-direction: column;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: linear-gradient(180deg, #221b29 0%, #16121b 40%);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(105%);
  transition: transform 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 40;
  visibility: hidden;
}
.sheet.open { transform: translateY(0); visibility: visible; }
.sheet-head {
  position: relative;
  flex: none;
  height: 40px;
  display: flex; justify-content: center; align-items: center;
  touch-action: none;
  cursor: grab;
}
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(244, 237, 225, 0.28); }
.sheet-close {
  position: absolute; right: 10px; top: 6px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 20px calc(24px + var(--safe-b));
}

/* ── 장소 내용 (시트·일반 모드 공용) ───────────────────────────── */
.eyebrow {
  margin: 0 0 2px;
  font-family: var(--display); font-weight: 700;
  font-size: 12px; letter-spacing: 0.18em;
  color: var(--gold);
}
.zone h2, .sheet-body h2 {
  margin: 0 0 10px;
  font-family: var(--title);
  font-size: 24px; font-weight: 700; line-height: 1.3;
  letter-spacing: 0;
}
.zone p, .sheet-body p { margin: 0 0 10px; color: #e2d9ca; }
.cards { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.cards li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.035);
}
.cards strong { font-size: 15px; color: var(--gold-hi); }
.cards span { font-size: 14px; color: var(--muted); }
.cards.contact a { font-size: 17px; font-weight: 700; text-decoration: none; }
.zone h3, .sheet-body h3 { margin: 26px 0 8px; font-family: var(--title); font-size: 19px; font-weight: 700; }
/* 회사 소개 (전망대) */
.story-logo { display: block; width: min(300px, 82%); height: auto; margin: 4px auto 18px; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45)); }
.story-lead { font-size: 16px; line-height: 1.7; }
.zone .story-quote, .sheet-body .story-quote {
  margin: 22px 0 0; padding: 4px 0 4px 14px;
  border-left: 3px solid var(--gold);
  font-family: var(--title); font-size: 17px; line-height: 1.6; color: #f3e6c8;
}
/* 소식 전광판: 소식 하나 = 배너 + 흐르는 한 줄 설명 + 내용, 좌우로 넘김 */
.news-deck { margin: 6px 0 0; }
.news-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.news-track::-webkit-scrollbar { display: none; }
.news-set { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.news-banner {
  margin: 0; aspect-ratio: 16 / 9; overflow: hidden;
  border: 2px solid rgba(226, 176, 74, 0.55); border-bottom: 0; border-radius: 12px 12px 0 0;
  background: linear-gradient(135deg, #2a1650, #0d0a24);
  display: flex; align-items: center; justify-content: center;
}
.news-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.news-banner-title { padding: 0 7%; font-family: var(--title); font-size: clamp(20px, 6vw, 34px); color: #fff6df; text-align: center; }
.news-ticker {
  overflow: hidden; white-space: nowrap;
  border: 2px solid rgba(226, 176, 74, 0.55); border-top: 0; border-radius: 0 0 12px 12px;
  background: #120a06; padding: 7px 0;
}
.news-ticker span {
  display: inline-block; padding-left: 100%;
  font-size: 14px; font-weight: 700; color: #ffb347; text-shadow: 0 0 8px rgba(255, 122, 26, 0.7);
  animation: news-run var(--dur, 14s) linear infinite;
}
@keyframes news-run { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .news-ticker span { padding-left: 12px; white-space: normal; } .news-ticker { white-space: normal; } }
.news-body { padding: 14px 2px 0; }
.news-meta { display: flex; align-items: center; gap: 8px; margin: 0 0 4px !important; }
.news-tag { padding: 2px 8px; border-radius: 4px; background: var(--gold); color: #24160a; font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; }
.news-meta time { font-size: 13px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.zone h3.news-title, .sheet-body h3.news-title { margin: 4px 0 10px; font-size: 21px; line-height: 1.35; }
.news-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.035); }
.news-info dt { font-size: 13px; color: var(--muted); }
.news-info dd { margin: 0; font-size: 14px; font-weight: 700; color: var(--gold-hi); }
.news-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.news-arrow { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--text); font-size: 24px; line-height: 1; }
.news-dots { display: flex; gap: 6px; }
.news-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.news-dots i.on { width: 20px; border-radius: 4px; background: var(--gold); }
/* 한글은 낱말 중간에서 줄이 바뀌지 않게 */
.zone, .sheet-body { word-break: keep-all; overflow-wrap: break-word; }
/* 게임랜드 안내원 */
.guide { display: flex; align-items: center; gap: 4px; margin: 14px 0 0; }
.maid {
  position: relative; flex: none;
  width: 124px; aspect-ratio: 411 / 760;
  padding: 0; border: 0; background: none; cursor: pointer;
  transform-origin: 50% 100%;
  animation: maid-sway 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
  -webkit-tap-highlight-color: transparent;
}
.maid-f { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.maid-blink, .maid-laugh { opacity: 0; }
.maid-blink { animation: maid-blink 4.6s infinite; }
.maid.is-laugh { animation: maid-hop 0.55s ease-out; }
.maid.is-laugh .maid-laugh { opacity: 1; }
.maid.is-laugh .maid-blink { animation: none; opacity: 0; }
@keyframes maid-sway { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg) translateY(-2px); } }
@keyframes maid-blink { 0%, 92% { opacity: 0; } 92.5%, 95.5% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes maid-hop { 0% { transform: none; } 35% { transform: translateY(-10px) scale(1.03); } 70% { transform: translateY(0) scale(0.99); } 100% { transform: none; } }
.guide-bubble {
  position: relative; flex: 1; min-width: 0;
  margin: 0 0 0 10px !important; padding: 12px 14px;
  border-radius: 14px; background: #fff7ee; color: #3a2a20 !important;
  font-size: 14px; line-height: 1.55;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.guide-bubble::before {
  content: ''; position: absolute; left: -9px; top: 50%; margin-top: -9px;
  border: 9px solid transparent; border-left: 0; border-right-color: #fff7ee;
}
.guide-bubble b { display: block; margin-bottom: 2px; font-family: var(--title); font-size: 17px; color: #d63a68; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 12px 20px;
  border-radius: 14px;
  font-size: 16px; font-weight: 800;
  text-decoration: none;
  border: 1px solid transparent;
  flex: 1 1 auto;
}
.btn-gold {
  background: linear-gradient(180deg, #f6d98a, #d29a3a);
  color: var(--ink);
  border-color: #f8e3a6;
  box-shadow: 0 6px 18px rgba(210, 154, 58, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.btn-ghost { background: rgba(255, 255, 255, 0.05); color: var(--text); border-color: var(--line); }
.btn:active { transform: translateY(1px); }

/* ── 오프닝 ───────────────────────────── */
.intro {
  position: fixed; inset: 0;
  background: #000;
  z-index: 50;
  overflow: hidden;
  transition: opacity 1.2s ease;
}
.intro.out { opacity: 0; pointer-events: none; }
.embers {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
}
.intro-actions, .loading, .sound { z-index: 2; }
.opening {
  position: absolute; left: 50%; top: 50%;
  width: min(100vw, 177.78dvh);
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  object-fit: contain;
  background: transparent;
  opacity: 0;
  transition: opacity 0.45s ease;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
  pointer-events: none;
}
.opening.on { opacity: 1; }
@media (orientation: portrait) {
  .opening { width: 112vw; }
}
.link {
  min-height: 44px; padding: 8px 14px;
  border: 0; background: none;
  color: var(--text); opacity: 0.75;
  font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
}
.intro-actions {
  position: absolute; left: 0; right: 0; bottom: calc(24px + var(--safe-b));
  display: flex; justify-content: center; gap: 10px;
  padding: 0 16px;
}
.skip {
  min-height: 44px; padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  font-size: 14px; font-weight: 700;
  animation: pop 0.3s ease-out;
}
/* 오프닝 소리 켜기·끄기 (오른쪽 위) */
.sound {
  position: absolute; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r));
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  font-size: 14px; font-weight: 700;
}
.sound .ico-off, .sound.is-off .ico-on { display: none; }
.sound.is-off .ico-off { display: block; }
.loading {
  position: absolute; left: 0; right: 0; bottom: calc(92px + var(--safe-b));
  margin: 0; text-align: center;
  color: var(--gold-hi); font-size: 14px;
  animation: blink 1.2s ease-in-out infinite;
}

/* ── 일반 모드 ───────────────────────────── */
.classic {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(72px + var(--safe-t)) 16px calc(40px + var(--safe-b));
}
/* 맨 위 고정 바: 작은 로고 + 회사 이름 + 하늘 섬 가기 */
.c-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: calc(56px + var(--safe-t));
  padding: var(--safe-t) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  background: rgba(20, 16, 24, 0.86);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.c-brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); text-decoration: none; }
.c-brand img { width: auto; height: 32px; flex: none; }
.c-brand span { font-family: var(--title); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-go {
  flex: none; min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid #f8e3a6;
  background: linear-gradient(180deg, #f6d98a, #d29a3a); color: var(--ink);
  font-size: 14px; font-weight: 800;
}
.c-go:active { transform: translateY(1px); }
.classic .zone {
  margin-top: 16px;
  padding: 22px 18px;
  border-radius: 18px;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #1d1823, #141117);
  scroll-margin-top: 72px;
}
.c-foot { margin-top: 32px; text-align: center; font-size: 13px; color: var(--muted); }
.c-foot p { margin: 2px 0; }

@media (min-width: 768px) {
  .hud-brand { font-size: 17px; }
  .quick { justify-content: center; -webkit-mask-image: none; mask-image: none; }
  .dialog { bottom: calc(102px + var(--safe-b)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
