:root {
  --bg-app: #0a0e17;
  --bg-panel: #111827;
  --bg-card: #161f30;
  --bg-card-inner: #0f1624;
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(0, 0, 0, 0.4);
  --accent-key: #38bdf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --border-subtle: rgba(255, 255, 255, 0.07);

  /* 스탯 전용 색상 */
  --stat-dmg-color: #f87171;
  --stat-dmg-bg: rgba(239, 68, 68, 0.12);
  --stat-hp-color: #4ade80;
  --stat-hp-bg: rgba(34, 197, 94, 0.12);

  /* T1 기본 테마 */
  --tier-color: #b45309;
  --tier-glow: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;   /* 모바일 터치 시 나타나는 기본 파란/회색 채움 박스 제거 */
  -webkit-touch-callout: none;                /* iOS 길게 누를 때 메뉴/미리보기 방지 */
}

/* 터치 반응 지연(더블탭 확대 대기) 제거 */
button, a, [role="button"], .equip-slot, .nav-tab-btn, .chest-display-box {
  touch-action: manipulation;
}

body {
  background-color: #05070b;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

/* 모바일 폰 뷰포트 (430px) */
.mobile-frame {
  width: 100%;
  max-width: 430px;
  height: 880px;
  max-height: 96vh;
  background: var(--bg-app);
  border-radius: 28px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 1. 최상단 상태 & 자원 바 (모던 클린 헤더) */
.header-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(180deg, #111827 0%, #090e17 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 36px;
  height: 36px;
  background: radial-gradient(circle at 35% 35%, #1e293b 0%, #0f172a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border: 1.5px solid rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
  cursor: pointer;
  flex: 0 0 auto;
}

.avatar:active {
  transform: scale(0.94);
}

.header-avatar-img {
  width: 130%;
  height: 130%;
  object-fit: contain;
  image-rendering: pixelated;
  margin-top: 4px;
  pointer-events: none;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-level {
  font-size: 0.72rem;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: -0.2px;
}

.stat-summary-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-tag {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1.5px 5.5px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
}

.stat-tag.dmg {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.stat-tag.hp {
  color: #86efac;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.currencies {
  display: flex;
  align-items: center;
  gap: 6px;
}

.currency-badge {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 9px;
  height: 29px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 5px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
}

.currency-badge .cur-icon {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
}

.gold-badge {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, rgba(15, 23, 42, 0.88) 100%);
}
.gold-badge .cur-val { 
  color: #fbbf24;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.key-badge {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.14) 0%, rgba(15, 23, 42, 0.88) 100%);
}
.key-badge .cur-val { 
  color: #38bdf8;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.gem-badge {
  border-color: rgba(14, 165, 233, 0.5);
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.22) 0%, rgba(15, 23, 42, 0.92) 100%);
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.gem-badge .cur-val { 
  color: #38bdf8;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.smart-ticket-badge {
  border-color: rgba(236, 72, 153, 0.4);
  background: linear-gradient(180deg, rgba(236, 72, 153, 0.14) 0%, rgba(15, 23, 42, 0.88) 100%);
}
.smart-ticket-badge .cur-val { 
  color: #f472b6;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(236, 72, 153, 0.3);
}

.ticket-badge {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.1);
}
.ticket-badge .cur-val { color: #c084fc; }

/* 2. 메인 컨텐츠 바디 */
.content-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-view {
  display: none !important;
  flex-direction: column;
  height: 100%;
}

.tab-view.active {
  display: flex !important;
}

/* ⚔️ 전투 탭은 다른 탭에 가 있어도 display:none 으로 접지 않고 "보이지 않게만" 유지.
   (display:none 이면 전투 화면의 크기/좌표가 전부 0으로 측정되어, 그 사이 진행되는 전투의 위치 계산이
    깨져 돌아왔을 때 영웅/몬스터 위치가 어긋남) */
#tab-forge.tab-view:not(.active) {
  display: flex !important;
  visibility: hidden;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

/* ==========================================================================
   하단 네비게이션 탭 & 공통 토스트 / 알림
   ========================================================================== */
/* 3. 최하단 6대 네비게이션 탭 (1행 균등 배치) */
.bottom-nav-bar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);   /* 의상실 / 펫 / 전투 / 연구실 / 투기장 / 클랜 / 상점 */
  background: #0f172a;
  border-top: 1px solid var(--border-subtle);
  padding: 6px 2px;
  z-index: 30;
  gap: 2px;
}

.nav-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 1px;
  border-radius: 8px;
  position: relative;
  transition: color 0.15s;
  min-width: 0;
}

.nav-tab-btn .nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

/* 하단 메뉴 이미지 아이콘 (assets/icons/menu): 도트 이미지를 선명하게 */
.nav-tab-btn .nav-icon-img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}
.nav-tab-btn.locked-tab .nav-icon-img { filter: grayscale(0.85) brightness(0.65); }
.nav-tab-btn.active .nav-icon-img { filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.7)); }

.nav-tab-btn .nav-label {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.tab-lock-badge {
  position: absolute;
  top: -2px;
  right: 0;
  background: #ef4444;
  color: #fff;
  font-size: 0.48rem;
  font-weight: 900;
  padding: 1px 3px;
  border-radius: 5px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.nav-tab-btn.active {
  color: #38bdf8;
}

.nav-tab-btn.active .nav-icon {
  transform: scale(1.08);
}

/* 플레이스홀더 탭 화면 */
.placeholder-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

.placeholder-tab h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.placeholder-tab p {
  font-size: 0.85rem;
  color: var(--text-muted);
}


/* 이모지를 대신하는 아이콘 이미지 (js/ui-icons.js) */
img.emo { display: inline-block; flex: none; align-self: center; height: 1.2em; width: auto; max-width: none; object-fit: contain; vertical-align: -0.24em; image-rendering: auto; pointer-events: none; -webkit-user-drag: none; user-select: none; }

/* 하단 메뉴 완료 알림 빨간 점 (js/nav-dots.js) */
.nav-icon { position: relative; }
.nav-red-dot { display: none; position: absolute; top: -2px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 1.5px solid #0f172a; box-shadow: 0 0 6px rgba(239, 68, 68, 0.9); animation: navDotPulse 1.2s ease-in-out infinite; pointer-events: none; z-index: 3; }
@keyframes navDotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
