* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14111e;
  color: #f8f2e8;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
}

.hidden { display: none !important; }

/* 2.5D 뷰포트 & 월드 스테이지 */
#viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #261e38 0%, #110e1a 100%);
  cursor: pointer;
}

#world-stage {
  position: relative;
  width: 1280px;
  height: 720px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
  user-select: none;
}

#town-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

#hotspots-layer, #avatars-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#hotspots-layer { z-index: 10; pointer-events: none; }
#avatars-layer { z-index: 20; pointer-events: none; }

/* 랜드마크 핫스팟 — 평소에는 배경을 가리지 않고, 호버 시에만 은은하게 발광 */
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hotspot-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid transparent;
  background: radial-gradient(circle, rgba(255, 220, 140, 0) 0%, rgba(255, 220, 140, 0) 70%);
  transition: all 0.28s ease;
}
.hotspot:hover .hotspot-ring, .hotspot.highlighted .hotspot-ring {
  border-color: rgba(255, 224, 150, 0.85);
  background: radial-gradient(circle, rgba(255, 225, 145, 0.28) 0%, rgba(255, 180, 90, 0.04) 72%);
  box-shadow: 0 0 32px rgba(255, 210, 115, 0.75);
  transform: scale(1.06);
}
.hotspot-label {
  position: absolute;
  bottom: -4px;
  background: rgba(24, 19, 36, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 218, 145, 0.55);
  color: #fff5df;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.hotspot:hover .hotspot-label, .hotspot.highlighted .hotspot-label {
  opacity: 1;
  transform: translateY(0);
}

/* 2.5D 점토·3D 일러스트풍 고퀄리티 아바타 */
.avatar-unit {
  position: absolute;
  transform: translate(-50%, -94%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  will-change: left, top;
}
.avatar-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  padding: 2.5px 9px;
  border-radius: 999px;
  margin-bottom: 3px;
  white-space: nowrap;
  background: rgba(20, 16, 32, 0.86);
  color: #fff7e6;
  border: 1px solid rgba(255, 224, 178, 0.36);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.avatar-unit.is-player .avatar-name {
  background: rgba(243, 166, 93, 0.96);
  color: #1f1421;
  border-color: #fff6df;
}
.avatar-svg-wrap {
  position: relative;
  width: 46px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 6px 6px rgba(18, 12, 24, 0.45));
  transition: transform 0.2s ease;
}
.avatar-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}
.avatar-unit.walking .avatar-svg-wrap {
  animation: walkStep 0.36s infinite alternate ease-in-out;
}
.avatar-unit.sitting .avatar-svg-wrap {
  transform: translateY(6px) scaleY(0.88);
}
@keyframes walkStep {
  0% { transform: translateY(0) rotate(-2.5deg); }
  100% { transform: translateY(-4.5px) rotate(2.5deg); }
}
.avatar-wave-bubble {
  position: absolute;
  top: -22px;
  font-size: 16px;
  animation: floatUp 1.2s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(4px) scale(0.7); }
  30% { opacity: 1; transform: translateY(-4px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-18px) scale(0.9); }
}

/* 호버 툴팁 */
#hover-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  min-width: 220px;
  max-width: 280px;
  background: rgba(24, 19, 36, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 218, 145, 0.55);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  transform: translate(16px, -50%);
}
.tooltip-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 209, 128, 0.2);
  color: #ffd685;
  margin-bottom: 5px;
}
.tooltip-title { font-size: 1rem; font-weight: 700; color: #fff9ef; margin-bottom: 4px; }
.tooltip-desc { font-size: 0.82rem; line-height: 1.45; color: #ddd4ea; }
.tooltip-hint { margin-top: 7px; font-size: 0.72rem; color: #ffca7a; }

/* 모달 & HUD 공통 (town_v0.1과 동일한 따뜻한 서재 스타일) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13, 10, 22, 0.68); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.welcome-card {
  width: 100%; max-width: 450px;
  background: linear-gradient(160deg, rgba(35, 28, 52, 0.96), rgba(23, 19, 36, 0.98));
  border: 1px solid rgba(255, 214, 145, 0.35); border-radius: 22px; padding: 28px 26px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65); text-align: center;
}
.welcome-eyebrow { font-size: 0.76rem; font-weight: 600; color: #ffd280; margin-bottom: 8px; }
.welcome-card h1 { font-size: 1.65rem; color: #fff7e6; margin-bottom: 10px; }
.welcome-sub { font-size: 0.9rem; line-height: 1.55; color: #cfc6de; margin-bottom: 20px; }
.form-group { text-align: left; margin-bottom: 15px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: #e8dec8; margin-bottom: 6px; }
.form-group input[type="text"] {
  width: 100%; padding: 10px 13px; border-radius: 11px;
  border: 1px solid rgba(255, 224, 178, 0.28); background: rgba(255, 255, 255, 0.07);
  color: #fff; font-size: 0.92rem; outline: none;
}
.color-picker { display: flex; gap: 10px; }
.color-dot {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
}
.color-dot.active { border-color: #fff6e0; transform: scale(1.14); box-shadow: 0 0 12px rgba(255, 214, 130, 0.7); }
.prop-picker { display: flex; gap: 8px; }
.prop-btn {
  flex: 1; padding: 9px 10px; border-radius: 11px;
  border: 1px solid rgba(255, 224, 178, 0.25); background: rgba(255, 255, 255, 0.05);
  color: #e6ddf0; font-size: 0.83rem; cursor: pointer;
}
.prop-btn.active { background: rgba(255, 206, 120, 0.22); border-color: #ffd280; color: #fff8e8; font-weight: 600; }
.audio-opt-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px; padding: 8px 12px; border-radius: 11px;
  background: rgba(255, 214, 130, 0.08); border: 1px solid rgba(255, 214, 130, 0.22);
  color: #f3e6cb; font-size: 0.82rem; cursor: pointer; user-select: none;
}
.audio-opt-row input[type="checkbox"] { accent-color: #f3a65d; width: 15px; height: 15px; cursor: pointer; }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 12px 18px; border: none; border-radius: 13px;
  background: linear-gradient(135deg, #f3a65d, #d97855); color: #1f1421;
  font-size: 0.96rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; border-radius: 13px; border: 1px solid rgba(255, 224, 178, 0.32);
  background: rgba(255, 255, 255, 0.07); color: #f6efe2; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.welcome-note { margin-top: 14px; font-size: 0.74rem; color: #a99fc0; }

.hud-panel {
  position: fixed; z-index: 40;
  background: rgba(24, 19, 36, 0.8); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 220, 155, 0.26); border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
#hud-top-left { top: 16px; left: 16px; z-index: 50; }
.hud-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hud-logo { font-size: 1rem; font-weight: 700; color: #ffebc2; }
.hud-ver { font-size: 0.7rem; padding: 2px 7px; border-radius: 999px; background: rgba(255, 212, 130, 0.18); color: #ffd482; font-weight: 600; }
.hud-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.online-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #e4dbef; background: rgba(255, 255, 255, 0.06); padding: 4px 10px; border-radius: 999px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #6ee7b7; box-shadow: 0 0 8px #6ee7b7; }
.icon-pill { border: 1px solid rgba(255, 220, 155, 0.25); background: rgba(255, 255, 255, 0.06); color: #f3ead8; font-size: 0.76rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; transition: background 0.18s ease, border-color 0.18s ease; }
.icon-pill:hover { background: rgba(255, 206, 120, 0.2); }
.icon-pill.playing { background: rgba(243, 166, 93, 0.22); border-color: rgba(255, 214, 130, 0.55); color: #ffebc2; }
.icon-pill.icon-only { padding: 4px 8px; }
.music-control { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.music-popover {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 65; width: 268px;
  background: rgba(24, 19, 36, 0.96); backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 218, 145, 0.42); border-radius: 15px; padding: 12px 13px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.6);
}
.mp-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.78rem; font-weight: 700; color: #ffebc2; margin-bottom: 9px; }
.mp-badge { font-size: 0.68rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: #cfc6de; }
.mp-badge.on { background: rgba(110, 231, 183, 0.18); color: #86efac; }
.mp-track-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.mp-track-btn {
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 10px;
  border: 1px solid rgba(255, 224, 178, 0.14); background: rgba(255, 255, 255, 0.04);
  color: #e9e1f2; cursor: pointer; transition: background 0.16s ease, border-color 0.16s ease;
}
.mp-track-btn:hover { background: rgba(255, 206, 120, 0.14); }
.mp-track-btn.active { background: rgba(243, 166, 93, 0.22); border-color: rgba(255, 214, 130, 0.55); color: #fff7e6; }
.mp-track-name { display: block; font-size: 0.8rem; font-weight: 700; }
.mp-track-sub { display: block; font-size: 0.68rem; color: #bfb5d1; margin-top: 2px; }
.mp-vol-row { display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 224, 178, 0.14); }
.mp-vol-icon { font-size: 0.82rem; }
.mp-vol-row input[type="range"] { flex: 1; accent-color: #f3a65d; cursor: pointer; }
.mp-vol-val { font-size: 0.72rem; color: #e2d8ee; min-width: 32px; text-align: right; }
.mp-note { margin-top: 8px; font-size: 0.68rem; line-height: 1.4; color: #a79cbe; }

#hud-top-right { top: 104px; left: 16px; right: auto; width: 245px; }
.nav-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.84rem; font-weight: 700; color: #ffebc2; }
.mini-btn { border: 1px solid rgba(255, 220, 155, 0.28); background: transparent; color: #d8cee6; font-size: 0.72rem; padding: 2px 8px; border-radius: 8px; cursor: pointer; }
.nav-list { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; max-height: 55vh; overflow-y: auto; }
.nav-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 10px; border: 1px solid transparent; background: rgba(255, 255, 255, 0.05); color: #f4eee4; font-size: 0.8rem; cursor: pointer; }
.nav-item:hover { background: rgba(255, 206, 120, 0.2); border-color: rgba(255, 212, 130, 0.45); }
.nav-item small { font-size: 0.7rem; color: #bfb5d1; }

.hud-bar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: rgba(24, 19, 36, 0.84); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 220, 155, 0.28); border-radius: 999px; padding: 8px 12px;
  max-width: calc(100vw - 24px); overflow-x: auto;
}
.action-btn { white-space: nowrap; border: 1px solid rgba(255, 224, 178, 0.2); background: rgba(255, 255, 255, 0.06); color: #f8f2e8; font-size: 0.82rem; font-weight: 600; padding: 8px 13px; border-radius: 999px; cursor: pointer; }
.action-btn:hover { background: rgba(255, 210, 130, 0.22); }
.action-btn.accent { background: rgba(243, 166, 93, 0.2); border-color: rgba(243, 166, 93, 0.5); color: #ffe3b0; }
.hud-divider { width: 1px; height: 22px; background: rgba(255, 224, 178, 0.2); }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: rgba(26, 21, 40, 0.94); border: 1px solid rgba(255, 214, 135, 0.5);
  color: #fff3d6; padding: 9px 16px; border-radius: 999px; font-size: 0.85rem;
}

.detail-card { position: relative; width: 100%; max-width: 480px; background: linear-gradient(160deg, rgba(35, 28, 52, 0.97), rgba(22, 18, 35, 0.99)); border: 1px solid rgba(255, 218, 150, 0.36); border-radius: 22px; padding: 26px; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255, 224, 178, 0.24); background: rgba(255, 255, 255, 0.06); color: #f3e9d8; cursor: pointer; }
.detail-badge { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: rgba(255, 210, 128, 0.2); color: #ffd582; margin-bottom: 8px; }
.detail-card h2, .drawer-header h2 { font-size: 1.4rem; color: #fff8ea; margin-bottom: 10px; }
.detail-desc { font-size: 0.92rem; line-height: 1.6; color: #dcd3eb; margin-bottom: 14px; }
.detail-features { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.feature-chip { font-size: 0.76rem; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 224, 178, 0.18); color: #f0e6d2; }
.detail-actions { display: flex; gap: 10px; }
.detail-actions .primary-btn { flex: 1.3; }
.detail-actions .secondary-btn { flex: 1; }
.detail-note { margin-top: 12px; font-size: 0.76rem; color: #b4a9c9; }

.drawer-card { position: relative; width: 100%; max-width: 680px; max-height: 86vh; display: flex; flex-direction: column; background: linear-gradient(160deg, rgba(32, 26, 48, 0.97), rgba(20, 16, 32, 0.99)); border: 1px solid rgba(255, 218, 150, 0.36); border-radius: 22px; padding: 24px; }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; padding-right: 36px; }
.drawer-sub { font-size: 0.85rem; color: #cbc2dc; line-height: 1.5; margin-bottom: 14px; }
.tab-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-btn { padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(255, 224, 178, 0.24); background: rgba(255, 255, 255, 0.05); color: #d6cde5; font-size: 0.82rem; cursor: pointer; }
.tab-btn.active { background: rgba(255, 206, 120, 0.24); border-color: #ffd280; color: #fff6e0; font-weight: 700; }
.drawer-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; margin-bottom: 12px; }
.resource-card, .idea-card { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 224, 178, 0.16); border-radius: 14px; padding: 13px 15px; }
.resource-meta, .idea-meta { display: flex; align-items: center; justify-content: space-between; font-size: 0.74rem; color: #ffd382; margin-bottom: 5px; }
.resource-title { font-size: 0.96rem; font-weight: 700; color: #fff7e8; margin-bottom: 5px; }
.resource-summary, .idea-text { font-size: 0.84rem; line-height: 1.5; color: #d8cfe6; }
.resource-link { display: inline-block; margin-top: 8px; font-size: 0.78rem; color: #9ed8ff; text-decoration: none; }
.comment-box, .idea-form { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 224, 178, 0.18); border-radius: 14px; padding: 12px; }
.idea-form { margin-bottom: 14px; }
.comment-box-title { font-size: 0.8rem; font-weight: 700; color: #ffe3b0; margin-bottom: 8px; }
.comment-row, .idea-form-row { display: flex; gap: 8px; margin-bottom: 8px; }
.comment-row select, .idea-form-row select { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255, 224, 178, 0.24); background: #221c33; color: #fff; font-size: 0.8rem; }
.comment-row input, .idea-form-row input { flex: 1; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255, 224, 178, 0.24); background: rgba(255, 255, 255, 0.07); color: #fff; font-size: 0.84rem; outline: none; }
.small-primary-btn { padding: 8px 14px; border-radius: 10px; border: none; background: linear-gradient(135deg, #f3a65d, #d97855); color: #1f1421; font-weight: 700; font-size: 0.82rem; cursor: pointer; white-space: nowrap; }
.comments-list { max-height: 110px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.comment-item { font-size: 0.8rem; color: #dfd7ec; background: rgba(255, 255, 255, 0.04); padding: 6px 10px; border-radius: 8px; }
.comment-item strong { color: #ffd582; }
.ethics-note { font-size: 0.72rem; color: #a99fc0; }
.idea-footer { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.status-pill { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: rgba(110, 231, 183, 0.16); color: #86efac; font-weight: 600; }
.vote-btn { border: 1px solid rgba(255, 214, 130, 0.35); background: rgba(255, 214, 130, 0.1); color: #ffe2a8; font-size: 0.76rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; }
