/* Office Escape Survivor - Stylesheet
   1. 폰트/토큰/베이스  2. 인게임 HUD  3. 디자인 토큰  4. 아이콘  5. 버튼
   6. 모달  7. 로비  8. 조이스틱/대시  9. 반응형 HUD */
/* Pretendard는 Google Fonts에 없으므로 jsDelivr 공식 배포본 사용 */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700;800;900&display=swap');

:root {
  --font-main: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Rajdhani', 'Pretendard', sans-serif;

  --bg-dark: #080c16;
  --panel-bg: rgba(15, 23, 42, 0.90);
  --panel-border: rgba(99, 140, 255, 0.28);
  --panel-glow: rgba(0, 240, 255, 0.2);

  --accent-cyan: #00f0ff;
  --accent-gold: #ffd700;
  --accent-red: #ff3355;
  --accent-green: #00ffaa;
  --accent-purple: #b044ff;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-main);
  color: var(--text-main);
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* 아틀라스 스프라이트 UI (캐릭터 초상화 등) */
.sprite-ui {
  display: inline-block;
  background-repeat: no-repeat;
  vertical-align: middle;
  flex-shrink: 0;
}

/* 1. 메인 게임 렌더 캔버스 */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* 2. 최상단 고정 일체형 HUD 바 */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: env(safe-area-inset-top, 8px) 12px 6px 12px;
  background: linear-gradient(180deg, rgba(8, 12, 22, 0.96) 0%, rgba(8, 12, 22, 0.85) 75%, transparent 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 20;
  pointer-events: none;
}

.hud-top-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  gap: 8px;
}

/* 좌측: 플레이어 프로필 & 체력 카드 */
.hud-player-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  flex-shrink: 1;
  min-width: 0;
}

.player-avatar-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255, 215, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.player-status-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 0;
}

.player-name {
  font-weight: 700;
  font-size: 11.5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-rank {
  font-size: 9.5px;
  background: rgba(255, 215, 0, 0.2);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 215, 0, 0.4);
  padding: 0.5px 3.5px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.hp-bar-track {
  width: 85px;
  height: 10px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 50, 80, 0.6);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff2255, #ff5577);
  box-shadow: 0 0 10px #ff2255;
  transition: width 0.15s ease-out;
}

.hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  font-family: var(--font-title);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

/* 중앙 타이머 */
.hud-timer-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 3px 10px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.timer-label {
  font-size: 8.5px;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.timer-digits {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
  line-height: 1.1;
  white-space: nowrap;
}

/* 우측 스코어/골드 */
.hud-score-card {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.score-pill {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.score-pill.gold {
  border-color: rgba(255, 215, 0, 0.4);
}

.pill-icon {
  font-size: 11px;
  line-height: 1;
  display: inline-block;
}

.pill-label {
  font-size: 8.5px;
  color: var(--text-muted);
  font-weight: 700;
  font-family: var(--font-title);
  white-space: nowrap;
}

.pill-val {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 12.5px;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.score-pill.gold .pill-val {
  color: var(--accent-gold);
}

.hud-icon-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  color: #fff;
  flex-shrink: 0;
}

.hud-icon-btn:active {
  transform: scale(0.92);
  border-color: var(--accent-cyan);
}

/* 일체형 경험치(XP) 게이지 바 */
.xp-bar-container {
  display: flex;
  align-items: center;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  gap: 8px;
}

.level-badge {
  background: linear-gradient(135deg, #ff8800, #ff2255);
  color: #fff;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(255, 60, 80, 0.5);
  white-space: nowrap;
  flex-shrink: 0;
}

.xp-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(10, 15, 26, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #00ffaa);
  box-shadow: 0 0 10px #00f0ff;
  transition: width 0.15s ease-out;
}

.xp-bar-text {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
  flex-shrink: 0;
}

/* 상단 HUD 일체형 무기 및 패시브 슬롯 바 */
.inventory-slots-deck {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

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

.slot-group-title {
  font-family: var(--font-title);
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.slot-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
}

.slots-container {
  display: flex;
  gap: 4px;
}

.slot-box {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(10, 16, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.slot-box.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 0.08);
}

.slot-box.super {
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.22), rgba(255, 60, 80, 0.22));
}

.slot-icon {
  font-size: 13px;
  line-height: 1;
}

.slot-level-dots {
  position: absolute;
  bottom: 1.5px;
  display: flex;
  gap: 1px;
}

.level-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}

.level-dot.fill {
  background: var(--accent-cyan);
  box-shadow: 0 0 4px var(--accent-cyan);
}

.slot-box.super .level-dot.fill {
  background: var(--accent-gold);
}

/* ==========================================================================
   3. 디자인 토큰 (로비 / 모달)
   ========================================================================== */
:root {
  --surface-0: #070b14;          /* 로비 배경 */
  --surface-1: #0e1522;          /* 카드 */
  --surface-2: #151f31;          /* 카드 hover / 입력 */
  --surface-3: #1d2940;          /* 강조 카드 */
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --brand: #38bdf8;
  --brand-strong: #0ea5e9;
  --brand-soft: rgba(56, 189, 248, 0.14);
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.14);
  --danger: #f43f5e;
  --success: #34d399;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   4. 아이콘 시스템 (SVG + Kenney 아이템 스프라이트)
   ========================================================================== */
.svg-icon {
  display: inline-block;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.item-icon {
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.tab-icon { width: 20px; height: 20px; }
.pill-svg-icon { width: 13px; height: 13px; }
.stat-svg { width: 16px; height: 16px; }
.btn-svg-icon { width: 18px; height: 18px; }
.inline-icon { width: 14px; height: 14px; }
.char-avatar-svg { width: 100%; height: 100%; }
.weapon-svg, .passive-svg, .shop-svg, .ach-svg, .monster-svg, .stage-svg { width: 24px; height: 24px; }
.star-svg { width: 15px; height: 15px; }
.slot-icon .svg-icon { width: 15px; height: 15px; }
.icon-fallback { font-size: 10px; color: var(--text-muted); }

/* ==========================================================================
   5. 버튼
   ========================================================================== */
.btn-primary,
.btn-secondary {
  width: 100%;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #4cc9ff 0%, #0ea5e9 100%);
  color: #04121f;
  font-size: 15px;
  padding: 14px 16px;
  border: none;
  box-shadow: 0 8px 22px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface-2);
  color: #cbd5e1;
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
}

.btn-secondary:active { transform: scale(0.98); }

.btn-secondary.danger {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-secondary.danger:hover { background: rgba(244, 63, 94, 0.12); }

/* ==========================================================================
   6. 모달 공통 (레벨업 / 일시정지 / 클리어 / 게임오버)
   ========================================================================== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: linear-gradient(180deg, #121b2c 0%, #0b111d 100%);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 22px 18px 18px;
  max-width: 440px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.modal-overlay.active .modal-window { transform: none; }

.modal-window::-webkit-scrollbar { width: 4px; }
.modal-window::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.modal-header { text-align: center; }

.modal-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.3px;
}

.modal-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

.modal-footer-column { display: flex; flex-direction: column; gap: 8px; }
.modal-footer-row { display: flex; gap: 8px; }

/* 레벨업 3택 1 */
.level-up-tag {
  display: inline-block;
  background: linear-gradient(90deg, #f59e0b, #f43f5e);
  color: #fff;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.45);
}

.upgrade-card-deck { display: flex; flex-direction: column; gap: 10px; }

.upgrade-card {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.upgrade-card:hover,
.upgrade-card:active {
  border-color: var(--gold);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.upgrade-card.super {
  border-color: rgba(244, 63, 94, 0.7);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.14), rgba(251, 191, 36, 0.12));
  box-shadow: 0 0 22px rgba(244, 63, 94, 0.3);
}

.upgrade-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upgrade-card-icon .svg-icon { width: 32px; height: 32px; }

.upgrade-card-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.upgrade-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.upgrade-card-title {
  font-weight: 800;
  font-size: 14.5px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upgrade-card-type {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
  flex-shrink: 0;
}

.upgrade-card.super .upgrade-card-type { background: rgba(244, 63, 94, 0.18); color: #fda4af; }

.upgrade-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.45; }

/* 레벨업 3택 1 (모바일 게임 카드 스타일) */
.modal-overlay.levelup-overlay {
  background: radial-gradient(80% 60% at 50% 38%, rgba(30, 58, 138, 0.55), rgba(3, 6, 12, 0.92) 70%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 12px;
}

.levelup-stage {
  position: relative;
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.levelup-rays {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 520px;
  height: 520px;
  margin-left: -260px;
  background: repeating-conic-gradient(from 0deg, rgba(251, 191, 36, 0.12) 0deg 8deg, transparent 8deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 62%);
  mask-image: radial-gradient(circle, #000 0%, transparent 62%);
  animation: luSpin 18s linear infinite;
  pointer-events: none;
}

@keyframes luSpin { to { transform: rotate(360deg); } }

.levelup-header { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }

.levelup-ribbon {
  position: relative;
  padding: 7px 34px 8px;
  background: linear-gradient(180deg, #fbbf24, #f59e0b 55%, #d97706);
  color: #3b1d00;
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 3px;
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.45);
  animation: luDrop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.levelup-ribbon span { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }

.levelup-level {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-title);
  color: #fff;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.8);
  animation: luDrop 0.45s 0.08s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.levelup-level small { font-size: 18px; font-weight: 800; color: #93c5fd; }
.levelup-level b { font-size: 44px; font-weight: 900; line-height: 1; }
.levelup-hint { font-size: 12.5px; font-weight: 700; color: #cbd5e1; opacity: 0.85; }

@keyframes luDrop {
  from { transform: translateY(-18px) scale(0.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.lu-deck {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  perspective: 900px;
}

.lu-card {
  --c1: #38bdf8;
  --c2: #1e3a8a;
  position: relative;
  border-radius: 18px;
  padding: 2px;
  background: linear-gradient(160deg, var(--c1), var(--c2) 60%, var(--c1));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 22px color-mix(in srgb, var(--c1) 35%, transparent);
  cursor: pointer;
  animation: luIn 0.5s calc(0.15s + var(--i) * 0.1s) cubic-bezier(0.2, 1.2, 0.35, 1) both;
  transition: transform 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.lu-card.rarity-passive { --c1: #34d399; --c2: #065f46; }
.lu-card.rarity-super_weapon { --c1: #fbbf24; --c2: #b91c1c; }
.lu-card.rarity-heal { --c1: #f472b6; --c2: #831843; }

.lu-card.rarity-super_weapon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  background: conic-gradient(from 0deg, transparent 0 70%, #fde68a 80%, transparent 90%);
  animation: luSpin 2.4s linear infinite;
  z-index: -1;
  filter: blur(2px);
}

@keyframes luIn {
  from { transform: translateY(40px) rotateY(80deg) scale(0.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.lu-card:hover { transform: translateY(-4px); }
.lu-card.picked { transform: translateY(-10px) scale(1.07); filter: brightness(1.15); box-shadow: 0 0 40px var(--c1); z-index: 2; }
.lu-card.dismiss { transform: translateY(24px) scale(0.92); opacity: 0; }

.lu-card-inner {
  position: relative;
  height: 100%;
  min-height: 262px;
  border-radius: 16px;
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--c1) 26%, transparent), transparent 60%),
    linear-gradient(180deg, #111a2c, #0a101b);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  overflow: hidden;
}

.lu-tag {
  position: absolute;
  top: 10px;
  right: -26px;
  transform: rotate(35deg);
  width: 96px;
  padding: 2px 0;
  background: var(--c1);
  color: #04121f;
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
}

.lu-tag.new { background: #f43f5e; color: #fff; }

.lu-icon {
  position: relative;
  width: 74px;
  height: 74px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lu-icon-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c1) 45%, transparent), transparent 70%);
  border: 1.5px solid color-mix(in srgb, var(--c1) 55%, transparent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--c1) 35%, transparent);
}

.lu-icon .svg-icon { position: relative; width: 46px; height: 46px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }

.lu-name {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  line-height: 1.25;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  word-break: keep-all;
}

.lu-pips { display: flex; gap: 3px; min-height: 8px; }
.lu-pips i { width: 9px; height: 5px; border-radius: 2px; background: rgba(148, 163, 184, 0.25); }
.lu-pips i.on { background: var(--c1); }
.lu-pips i.next { background: #fff; box-shadow: 0 0 8px var(--c1); animation: luBlink 0.9s ease-in-out infinite; }

@keyframes luBlink { 50% { opacity: 0.35; } }

.lu-desc {
  flex: 1;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  line-height: 1.45;
  word-break: keep-all;
}

.lu-kind {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--c1);
  letter-spacing: 1px;
  padding-top: 8px;
  width: 100%;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

@media (max-width: 380px) {
  .lu-deck { gap: 7px; }
  .lu-card-inner { min-height: 240px; padding: 12px 7px 10px; }
  .lu-icon { width: 62px; height: 62px; }
  .lu-icon .svg-icon { width: 38px; height: 38px; }
  .lu-name { font-size: 12.5px; }
  .lu-desc { font-size: 10.5px; }
  .levelup-ribbon { font-size: 19px; }
}

/* 탕비실 상점 (스테이지 사이) */
.rest-window { max-width: 460px; gap: 12px; }
.rest-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rest-kicker { font-family: var(--font-title); font-size: 11px; font-weight: 800; letter-spacing: 2px; color: var(--gold); }
.rest-head .modal-title { margin-top: 2px; }
.rest-next { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.rest-wallet {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(251, 191, 36, 0.4);
  flex-shrink: 0;
}

.rest-wallet .svg-icon { width: 18px; height: 18px; }
.rest-wallet b { font-family: var(--font-title); font-size: 18px; font-weight: 900; color: var(--gold); }

.rest-offers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.rest-item {
  --c: #94a3b8;
  position: relative;
  border-radius: var(--radius-md);
  padding: 12px 10px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, #111a2c), #0b111d);
  border: 1.5px solid color-mix(in srgb, var(--c) 55%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  animation: luIn 0.4s calc(var(--i, 0) * 0.06s) cubic-bezier(0.2, 1.2, 0.35, 1) both;
}

.rest-item.rarity-rare { --c: #38bdf8; }
.rest-item.rarity-epic { --c: #f59e0b; box-shadow: 0 0 18px rgba(245, 158, 11, 0.25); }
.rest-item.sold { opacity: 0.45; }

.rest-rarity {
  position: absolute;
  top: 7px;
  left: 8px;
  font-size: 10px;
  font-weight: 900;
  color: var(--c);
}

.rest-item-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%);
  margin-top: 6px;
}

.rest-item-icon .svg-icon { width: 36px; height: 36px; }
.rest-item-name { font-size: 13px; font-weight: 900; color: #fff; line-height: 1.25; }
.rest-item-desc { font-size: 11.5px; font-weight: 600; color: #cbd5e1; line-height: 1.4; min-height: 2.8em; }
.rest-item-owned { font-size: 10.5px; color: var(--text-muted); }

.rest-buy {
  margin-top: 4px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  background: linear-gradient(180deg, #fcd34d, #f59e0b);
  color: #2b1600;
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.rest-buy .svg-icon { width: 14px; height: 14px; }
.rest-item.sold .rest-buy { background: var(--surface-3); color: #94a3b8; font-family: var(--font-main); font-size: 12px; }
.rest-item.poor .rest-buy { filter: grayscale(0.8) brightness(0.8); }
.rest-buy:active { transform: scale(0.97); }

.rest-reroll {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: #e2e8f0;
  font-family: var(--font-main);
  font-size: 12.5px;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.rest-reroll .svg-icon { width: 14px; height: 14px; }
.rest-reroll.poor { opacity: 0.5; }

.rest-section { display: flex; flex-direction: column; gap: 6px; }
.rest-label { font-size: 11px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.5px; }
.rest-owned { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }

.rest-chip {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rest-chip .svg-icon { width: 24px; height: 24px; }
.rest-chip b { position: absolute; right: -4px; bottom: -4px; font-size: 10px; background: var(--brand); color: #04121f; border-radius: 6px; padding: 0 3px; }

.rest-mate {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  font-size: 12px;
  font-weight: 800;
  color: #a7f3d0;
}

.rest-mate .sprite-ui { border-radius: 50%; }
.rest-empty { font-size: 11.5px; color: #64748b; }


/* 일시정지 스탯 */
.pause-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
}

.pause-stat-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.pause-stat-icon .svg-icon { width: 18px; height: 18px; }
.pause-stat-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pause-stat-label { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.pause-stat-val { font-family: var(--font-title); font-size: 14px; color: #fff; white-space: nowrap; }

/* 클리어 / 게임오버 통계 */
.end-stats-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--text-muted); }
.stat-row b { font-family: var(--font-title); color: #fff; font-size: 16px; }
.stat-row.total-gold-row b { color: var(--gold); }

.clear-star-rating { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }

.star-pill {
  font-size: 30px;
  filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.7));
  animation: starPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.star-pill.empty { filter: grayscale(1) opacity(0.35); }
.star-pill.star-2 { animation-delay: 0.15s; }
.star-pill.star-3 { animation-delay: 0.3s; }

@keyframes starPop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   7. 로비 (전체 화면 모바일 게임 레이아웃)
   ========================================================================== */
.modal-overlay.lobby-overlay {
  padding: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(251, 191, 36, 0.07), transparent 60%),
    var(--surface-0);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  align-items: stretch;
}

.lobby-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 상단 바 */
.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(env(safe-area-inset-top), 14px) 16px 12px;
  flex-shrink: 0;
}

.lobby-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, #1e3a5f, #0b1628);
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.2);
}

.brand-mark svg { width: 24px; height: 24px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-sub {
  font-family: var(--font-title);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 1.6px;
}

.lobby-gold-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-soft);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.lobby-gold-badge .svg-icon { width: 18px; height: 18px; }

.gold-text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 16px;
  color: var(--gold);
}

/* 스크롤 본문 */
.lobby-body {
  flex: 1;
  overflow-y: auto;
  padding: 2px 16px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.lobby-body::-webkit-scrollbar { display: none; }

.tab-panel { display: none; flex-direction: column; gap: 12px; }
.tab-panel.active { display: flex; }

.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 4px 2px 0; }
.panel-title { font-size: 17px; font-weight: 900; color: #fff; letter-spacing: -0.3px; }
.panel-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.panel-count {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 챕터 히어로 카드 */
.chapter-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: linear-gradient(180deg, #13233d 0%, #0b1424 100%);
  min-height: 150px;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-card);
}

.chapter-hero-art {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 80% at 85% 0%, rgba(251, 191, 36, 0.18), transparent 60%),
    linear-gradient(180deg, transparent 40%, rgba(7, 11, 20, 0.85) 100%);
  pointer-events: none;
}

/* CSS 빌딩 실루엣 (창문 불빛) */
.chapter-hero-art::before,
.chapter-hero-art::after {
  content: '';
  position: absolute;
  bottom: 0;
  border-radius: 4px 4px 0 0;
  background-color: rgba(251, 191, 36, 0.5);
  background-image:
    linear-gradient(90deg, #0d1a2e 0 5px, transparent 5px 12px),
    linear-gradient(0deg, #0d1a2e 0 5px, transparent 5px 12px);
  background-size: 12px 12px;
  box-shadow: inset 0 0 0 5px #0d1a2e;
  opacity: 0.55;
}

.chapter-hero-art::before { right: 18px; width: 90px; height: 128px; }
.chapter-hero-art::after { right: 112px; width: 46px; height: 82px; opacity: 0.3; }

.chapter-hero-info {
  position: relative;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.chapter-badge {
  align-self: flex-start;
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 800;
  color: #04121f;
  background: var(--brand);
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.chapter-title { font-size: 18px; font-weight: 900; color: #fff; letter-spacing: -0.4px; }
.chapter-subtitle { font-size: 12px; color: #aab8cc; line-height: 1.45; max-width: 70%; }

.chapter-progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.chapter-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.chapter-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #a78bfa);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.chapter-progress-text {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 800;
  color: #dbeafe;
  white-space: nowrap;
}

/* 챕터 이동 버튼 & 점 인디케이터 */
.chapter-nav {
  position: absolute;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(7, 11, 20, 0.55);
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.chapter-nav svg { width: 18px; height: 18px; }
.chapter-nav.prev { right: 56px; }
.chapter-nav.next { right: 14px; }
.chapter-nav:disabled { opacity: 0.3; cursor: default; }
.chapter-nav.locked { color: #64748b; }
.chapter-nav:not(:disabled):active { transform: scale(0.92); }

.chapter-dots { display: flex; justify-content: center; gap: 6px; margin-top: -2px; }
.chapter-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(148, 163, 184, 0.35); transition: all 0.2s ease; }
.chapter-dot.locked { background: rgba(148, 163, 184, 0.12); }
.chapter-dot.active { width: 18px; border-radius: 3px; background: var(--brand); }

/* 모드 세그먼트 */
.mode-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-1);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.mode-toggle-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 800;
  padding: 10px 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.mode-toggle-btn.active {
  background: var(--surface-3);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

/* 스테이지 리스트 */
.stage-grid-container { display: flex; flex-direction: column; gap: 8px; }

.stage-card {
  flex-shrink: 0;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  position: relative;
}

.stage-card.unlocked:hover { background: var(--surface-2); }
.stage-card.unlocked:active { transform: scale(0.99); }

.stage-card.selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), var(--surface-1) 70%);
  box-shadow: 0 0 0 1px var(--brand), 0 8px 22px rgba(14, 165, 233, 0.18);
}

.stage-card.locked { cursor: not-allowed; padding: 10px 12px; }
.stage-card.locked .stage-card-title { color: #5b6b82; }

.stage-num {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
}

.stage-num small { font-size: 8px; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 3px; }
.stage-card.selected .stage-num { background: var(--brand); color: #04121f; border-color: transparent; }
.stage-card.selected .stage-num small { color: rgba(4, 18, 31, 0.7); }
.stage-card.boss .stage-num { box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.6); }
.stage-card.locked .stage-num { width: 38px; height: 38px; font-size: 14px; color: #5b6b82; background: transparent; }

.stage-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.stage-card-title {
  font-size: 14.5px;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-card-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stage-card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }

.stage-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.1);
  padding: 3px 8px;
  border-radius: 999px;
}

.stage-meta-tag .svg-icon { width: 12px; height: 12px; }
.stage-meta-tag.reward { color: #fde68a; background: var(--gold-soft); }
.stage-meta-tag.boss { color: #fda4af; background: rgba(244, 63, 94, 0.14); }

.stage-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.stage-stars-row { display: flex; gap: 1px; }
.stage-lock { color: #5b6b82; display: flex; }
.stage-lock svg { width: 18px; height: 18px; }

/* 서바이벌 모드 카드 */
.survival-card {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.16), var(--surface-1) 70%);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.survival-card[hidden] { display: none; }
.survival-card h3 { font-size: 16px; font-weight: 900; color: #fff; }
.survival-card p { font-size: 12px; color: #c4b5fd; line-height: 1.5; }

.survival-timeline { display: flex; flex-direction: column; gap: 6px; }

.survival-timeline li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #e2e8f0;
}

.survival-timeline b {
  font-family: var(--font-title);
  font-size: 13px;
  color: #c4b5fd;
  min-width: 42px;
}

/* 하단 출근 액션 바 */
.lobby-action-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(7, 11, 20, 0) 0%, rgba(7, 11, 20, 0.96) 30%);
  border-top: 1px solid var(--line);
}

.lobby-action-bar[hidden] { display: none; }
.lobby-action-bar .btn-primary { width: auto; flex-shrink: 0; padding: 14px 22px; }

.stage-selected-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.stage-selected-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-selected-reward {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 하단 탭 내비게이션 */
.lobby-nav {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #0a101c;
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 8px);
}

.menu-tab-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
  white-space: nowrap;
  position: relative;
}

.menu-tab-btn.active { color: #fff; }

.menu-tab-btn.active::before {
  content: '';
  position: absolute;
  top: -7px;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand);
  box-shadow: 0 0 10px var(--brand);
}

.menu-tab-btn.active .tab-icon { color: var(--brand); }

/* 사원 카드 */
.char-card-grid { display: flex; flex-direction: column; gap: 10px; }

.char-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.char-card:hover { background: var(--surface-2); }

.char-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 8px 22px rgba(14, 165, 233, 0.18);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), var(--surface-1) 70%);
}

.char-portrait {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 30%, #22324d, #0f1726);
  border: 1px solid var(--line);
  flex-shrink: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.player-avatar-box { overflow: hidden; }

.char-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.char-name-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.char-name { font-size: 15.5px; font-weight: 900; color: #fff; }
.char-title { font-size: 11px; font-weight: 700; color: var(--brand); }
.char-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }

.char-stats { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; margin-top: 4px; }
.char-stat-label { font-size: 10.5px; font-weight: 700; color: #94a3b8; }
.char-stat-bar { height: 5px; background: rgba(148, 163, 184, 0.15); border-radius: 999px; overflow: hidden; }
.char-stat-bar i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.char-stat-bar.hp i { background: var(--danger); }
.char-stat-val { font-family: var(--font-title); font-size: 12px; font-weight: 800; color: #e2e8f0; text-align: right; }

.char-perk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 7px 9px;
  background: rgba(148, 163, 184, 0.07);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: #fde68a;
}

.char-perk .svg-icon { width: 20px; height: 20px; }

.char-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 12px;
  font-weight: 900;
}

.char-card.selected .char-check { background: var(--brand); border-color: var(--brand); color: #04121f; }

/* 연봉 협상 (상점) */
.shop-grid { display: flex; flex-direction: column; gap: 8px; }

.shop-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.shop-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shop-card-icon .svg-icon { width: 26px; height: 26px; }
.shop-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.shop-card-name { font-weight: 800; font-size: 14px; color: #fff; }
.shop-card-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.shop-pips-row { display: flex; gap: 3px; }
.shop-pip { width: 18px; height: 4px; border-radius: 2px; background: rgba(148, 163, 184, 0.2); }
.shop-pip.fill { background: var(--gold); box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }

.shop-buy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(180deg, #fcd34d, #f59e0b);
  border: none;
  border-radius: var(--radius-sm);
  color: #2b1600;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 14px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.shop-buy-btn .svg-icon { width: 14px; height: 14px; }
.shop-buy-btn:active { transform: scale(0.96); }
.shop-buy-btn.poor { filter: grayscale(0.7) brightness(0.8); box-shadow: none; }
.shop-buy-btn.maxed { background: var(--surface-3); color: #94a3b8; cursor: default; box-shadow: none; font-family: var(--font-main); font-size: 12px; }

/* 업적 */
.ach-list { display: flex; flex-direction: column; gap: 8px; }

.ach-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ach-card.completed { border-color: rgba(52, 211, 153, 0.35); background: linear-gradient(135deg, rgba(52, 211, 153, 0.08), var(--surface-1) 70%); }

.ach-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ach-card:not(.completed) .ach-icon { filter: grayscale(1) opacity(0.5); }
.ach-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ach-title { font-weight: 800; font-size: 13.5px; color: #fff; }
.ach-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.ach-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-title);
  font-size: 12.5px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--gold-soft);
  color: var(--gold);
  flex-shrink: 0;
}

.ach-badge .svg-icon { width: 13px; height: 13px; }
.ach-card.completed .ach-badge { background: rgba(52, 211, 153, 0.15); color: var(--success); font-family: var(--font-main); font-size: 11px; }

/* 업무 도감 */
.bestiary-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.bestiary-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bestiary-card.boss { border-color: rgba(244, 63, 94, 0.3); }
.bestiary-head { display: flex; align-items: center; gap: 10px; }

.bestiary-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bestiary-card.locked .bestiary-icon .svg-icon { filter: brightness(0) invert(1) opacity(0.18); }
.bestiary-name { font-size: 13px; font-weight: 800; color: #fff; line-height: 1.3; }
.bestiary-type { font-size: 10.5px; font-weight: 700; color: var(--brand); }
.bestiary-card.boss .bestiary-type { color: #fda4af; }
.bestiary-desc { font-size: 11px; color: var(--text-muted); line-height: 1.45; }
.bestiary-strategy { font-size: 11px; color: #a5f3fc; line-height: 1.45; padding-top: 6px; border-top: 1px dashed var(--line); }
.bestiary-card.locked .bestiary-name { color: #5b6b82; }

/* 데스크톱: 로비를 폰 프레임처럼 중앙 정렬 */
@media (min-width: 520px) {
  .lobby-shell {
    height: calc(100% - 32px);
    margin: 16px auto;
    border: 1px solid var(--line);
    border-radius: 26px;
    overflow: hidden;
    background: rgba(7, 11, 20, 0.6);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  }
}

@media (max-width: 360px) {
  .menu-tab-btn { font-size: 10px; }
  .lobby-action-bar .btn-primary { padding: 13px 16px; }
  .chapter-subtitle { max-width: 100%; }
}

/* ==========================================================================
   8. 모바일 가상 조이스틱 & 대시
   ========================================================================== */
.joystick-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

.joystick-base {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, rgba(10, 16, 28, 0.6) 100%);
  border: 2px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
  transform: translate(-50%, -50%);
  display: none;
}

.joystick-base.active {
  display: block;
}

.joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, #00f0ff 0%, #0088ff 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 0 16px #00f0ff;
  transform: translate(-50%, -50%);
}

/* 5. 모바일 칼퇴 대시 버튼 (Sprint/Dodge) */
.mobile-dash-btn {
  position: absolute;
  right: max(20px, env(safe-area-inset-right, 20px));
  bottom: max(35px, env(safe-area-inset-bottom, 35px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.25) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  transition: transform 0.1s ease, border-color 0.2s ease;
}

.mobile-dash-btn:active {
  transform: scale(0.92);
}

.mobile-dash-btn.cooling {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  filter: grayscale(0.6);
}

.dash-btn-icon {
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
}

.dash-btn-label {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 9.5px;
  color: #fff;
  margin-top: 1px;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.dash-cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: none;
  transition: height 0.05s linear;
}

/* ==========================================================================
   9. 반응형 HUD
   ========================================================================== */
@media (max-width: 640px) {
  .hud-top-bar {
    padding: max(env(safe-area-inset-top, 4px), 4px) max(env(safe-area-inset-right, 6px), 6px) 4px max(env(safe-area-inset-left, 6px), 6px);
    gap: 3px;
  }
  .hud-top-content {
    gap: 4px;
  }
  .hud-player-card {
    padding: 3px 6px;
    gap: 5px;
    border-radius: 9px;
  }
  .player-avatar-box {
    width: 26px;
    height: 26px;
    font-size: 14px;
    border-radius: 6px;
  }
  .player-name {
    font-size: 10.5px;
    max-width: 65px;
  }
  .player-rank {
    font-size: 8.5px;
    padding: 0 3px;
  }
  .hp-bar-track {
    width: 65px;
    height: 9px;
  }
  .hp-text {
    font-size: 7.5px;
  }
  .hud-timer-card {
    padding: 2px 7px;
    border-radius: 9px;
  }
  .timer-label {
    font-size: 7.5px;
  }
  .timer-digits {
    font-size: 15px;
  }
  .hud-score-card {
    gap: 3px;
  }
  .score-pill {
    padding: 2px 5px;
    border-radius: 6px;
    gap: 3px;
  }
  .pill-icon {
    font-size: 10px;
  }
  .pill-label {
    font-size: 7.5px;
  }
  .pill-val {
    font-size: 11.5px;
  }
  .hud-icon-btn {
    width: 23px;
    height: 23px;
    font-size: 10.5px;
    border-radius: 6px;
  }

  /* 상단 슬롯 바 모바일 최적화 */
  .inventory-slots-deck {
    gap: 4px;
    padding: 3px 6px;
    border-radius: 9px;
  }
  .slot-group {
    gap: 3px;
  }
  .slot-group-title {
    font-size: 7.5px;
  }
  .slots-container {
    gap: 2px;
  }
  .slot-box {
    width: 21px;
    height: 21px;
    border-radius: 5px;
  }
  .slot-icon {
    font-size: 11px;
  }
  .slot-level-dots {
    bottom: 1px;
    gap: 0.8px;
  }
  .level-dot {
    width: 2px;
    height: 2px;
  }
  .slot-divider {
    height: 14px;
  }
}

@media (max-width: 400px) {
  .hud-top-bar {
    padding-left: 4px;
    padding-right: 4px;
    gap: 2.5px;
  }
  .hud-top-content {
    gap: 3px;
  }
  .hud-player-card {
    padding: 2px 4px;
    gap: 4px;
  }
  .player-avatar-box {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
  .player-name {
    font-size: 9.5px;
    max-width: 48px;
  }
  .hp-bar-track {
    width: 50px;
    height: 8px;
  }
  .hud-timer-card {
    padding: 2px 5px;
  }
  .timer-digits {
    font-size: 13.5px;
  }
  .score-pill .pill-label {
    display: none; /* 400px 이하 초소형 화면에서는 텍스트 라벨 숨김 (아이콘 + 숫자 조합으로 절대 잘리지 않음) */
  }
  .score-pill {
    padding: 2px 4px;
    gap: 2px;
  }
  .pill-icon {
    font-size: 9.5px;
  }
  .pill-val {
    font-size: 11px;
  }
  .hud-icon-btn {
    width: 21px;
    height: 21px;
    font-size: 9.5px;
  }
  .slot-box {
    width: 19px;
    height: 19px;
  }
  .slot-icon {
    font-size: 9.5px;
  }
}

/* ==========================================================================
   10. 인게임 HUD 추가 요소 (보스 체력바 / 동료·아이템 줄)
   ========================================================================== */
/* 보스 체력바 */
.hud-boss-bar {
  max-width: 960px;
  width: 100%;
  margin: 2px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(40, 8, 16, 0.85);
  border: 1px solid rgba(244, 63, 94, 0.55);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.3);
}

.hud-boss-bar[hidden] { display: none; }
.hud-boss-name { font-size: 11px; font-weight: 900; color: #fecdd3; white-space: nowrap; }
.hud-boss-track { flex: 1; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; }
.hud-boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #f43f5e, #fb923c); transition: width 0.15s ease-out; }

/* 동료 · 아이템 줄 */
.hud-run-row {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.hud-run-row[hidden] { display: none; }

.hud-run-group {
  display: flex;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 9px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
}

.hud-mate { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 1.5px solid #34d399; display: flex; align-items: center; justify-content: center; background: #0b1220; }
.hud-item { position: relative; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.hud-item .svg-icon { width: 18px; height: 18px; }
.hud-item b { position: absolute; right: -3px; bottom: -3px; font-size: 8px; line-height: 1; padding: 1px 2px; border-radius: 4px; background: var(--accent-cyan); color: #04121f; }

/* 크레딧 (일시정지 화면) */
.credits-line { font-size: 10px; color: #64748b; text-align: center; line-height: 1.5; }
