/* ============================================================
   MYTHIC VOYAGER PORTAL - Styles v2.0
   Dark RPG Theme
   ============================================================ */

:root {
  --bg: #030712;
  --bg-card: #0f172a;
  --bg-card2: #1e293b;
  --bg-card3: #0d1424;
  --border: #1e293b;
  --border-hover: #334155;
  --purple-900: #1e1b4b;
  --purple-700: #4338ca;
  --purple-500: #8b5cf6;
  --purple-400: #a78bfa;
  --gold: #f59e0b;
  --gold-light: #fcd34d;
  --emerald: #10b981;
  --red: #ef4444;
  --blue: #0ea5e9;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #475569;
  --sidebar-w: 220px;
  --bottom-nav-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; cursor: pointer; }

/* ===== LAYOUT ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar-nav {
  width: var(--sidebar-w);
  background: var(--bg-card3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  gap: 2px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 20px;
}

.logo-icon { font-size: 1.8rem; }
.logo-title {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--purple-400);
  letter-spacing: 0.1em;
  line-height: 1;
}
.logo-sub {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  line-height: 1.5;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--bg-card2);
  color: var(--text);
}

.sidebar-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--purple-400);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.sidebar-item i {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding-bottom: 20px;
}

/* Bottom nav (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card3);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item i { font-size: 1.1rem; }
.nav-item:hover, .nav-item.active { color: var(--purple-400); }
.nav-item.active { background: rgba(124, 58, 237, 0.1); }

/* ===== PAGE BODY ===== */
.page { height: 100%; }

.page-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: white;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== SECTION CARD ===== */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.danger-title { color: #f87171 !important; }

.section-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ===== CHARACTER CARD ===== */
.character-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 60%, #1a0a3a 100%);
  border: 1px solid rgba(124, 58, 237, 0.4);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.character-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(124,58,237,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.character-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.character-class {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--purple-400);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.character-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.character-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.character-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.level-badge {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  display: inline-block;
}

.avail-xp {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ===== XP BAR ===== */
.xp-bar-track {
  background: #1e293b;
  border-radius: 9999px;
  height: 10px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  background: linear-gradient(90deg, #7c3aed, #a78bfa, #f59e0b);
  height: 100%;
  border-radius: 9999px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-200%); }
  100% { transform: translateX(200%); }
}

.xp-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  transition: border-color 0.15s;
}

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--border-hover); }

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

.stat-denom {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
}

.stat-badge.perfect {
  font-size: 0.6rem;
  font-weight: 700;
  color: #34d399;
  margin-top: 2px;
}

/* ===== LOADING / ERROR ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 12px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--purple-400);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-text {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  color: #f87171;
  gap: 8px;
  font-size: 0.9rem;
}

.error-state i { font-size: 2rem; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 20px;
  text-align: center;
}

.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

.empty-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ===== HABIT CARDS (Today Page) ===== */
.today-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.today-counter {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.today-count {
  font-size: 1.6rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

.today-pct {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.today-counter.perfect .today-count { color: #34d399; }

.perfect-banner {
  text-align: center;
  font-weight: 900;
  font-size: 0.9rem;
  color: #34d399;
  padding: 6px 0;
  animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
  50% { text-shadow: 0 0 20px rgba(52, 211, 153, 0.8); }
}

.today-xp-line {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.habit-stack { display: flex; flex-direction: column; gap: 8px; }

.habit-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.habit-card.done {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.05);
}

.habit-card.missed-card {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.03);
}

.habit-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid #334155;
  background: var(--bg-card3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  color: #475569;
}

.habit-toggle:hover { border-color: var(--purple-500); transform: scale(1.05); }
.habit-toggle:active { transform: scale(0.95); }
.habit-toggle.complete { background: #7c3aed; border-color: #a78bfa; color: white; }
.habit-toggle.missed { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #f87171; }

.habit-info { flex: 1; min-width: 0; }

.habit-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.habit-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
  margin-bottom: 4px;
  line-height: 1.35;
  font-style: italic;
}

.habit-dots {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot.done { background: var(--purple-400); }
.dot.miss { background: #ef444466; border: 1px solid #ef444499; }
.dot.empty { background: var(--border); }

.habit-xp {
  flex-shrink: 0;
  text-align: right;
  min-width: 36px;
}

.xp-earn { font-size: 0.75rem; font-weight: 700; color: #34d399; }
.xp-loss { font-size: 0.75rem; font-weight: 700; color: #f87171; }
.xp-pend { font-size: 0.75rem; font-weight: 600; color: #475569; }

.today-tip {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  padding: 4px;
}

/* ===== HABIT MANAGEMENT ===== */
.habits-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.summary-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
}

.summary-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 3px;
  font-weight: 600;
}

.habit-manage-list { display: flex; flex-direction: column; gap: 8px; }

.habit-manage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.habit-manage-card:hover { border-color: var(--border-hover); }

.habit-manage-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.habit-manage-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-manage-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ===== STREAK BADGE ===== */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.streak-badge.high {
  background: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.35);
  color: #c4b5fd;
}

.streak-badge.max {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #fcd34d;
  animation: glow-gold 2s ease-in-out infinite alternate;
}

@keyframes glow-gold {
  from { box-shadow: 0 0 4px rgba(245, 158, 11, 0.3); }
  to { box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
}

/* ===== STREAK ROWS ===== */
.streak-list { display: flex; flex-direction: column; gap: 8px; }

.streak-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-rank {
  font-size: 0.68rem;
  color: var(--text-dim);
  width: 20px;
  flex-shrink: 0;
}

.streak-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: #e2e8f0;
}

.streak-leaderboard { display: flex; flex-direction: column; gap: 10px; }
.streak-lb-row { display: flex; align-items: center; gap: 10px; }
.streak-lb-rank { font-size: 0.7rem; color: var(--text-dim); width: 24px; }
.streak-lb-name { flex: 1; font-size: 0.85rem; color: #e2e8f0; }

/* ===== HABIT ROW (Dashboard) ===== */
.habit-list { display: flex; flex-direction: column; gap: 8px; }
.habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.danger-row {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}

.habit-row.clickable { cursor: pointer; }
.habit-row.clickable:hover { border-color: #ef4444; }
.habit-row-info { flex: 1; }
.habit-row-name { font-size: 0.82rem; font-weight: 600; color: #e2e8f0; }
.habit-row-meta { font-size: 0.68rem; margin-top: 2px; }

/* ===== XP LIST ===== */
.xp-list { display: flex; flex-direction: column; }
.xp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.xp-row:last-child { border-bottom: none; }
.xp-row-name {
  font-size: 0.77rem;
  color: #94a3b8;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.xp-row-amount {
  font-size: 0.77rem;
  font-weight: 700;
  flex-shrink: 0;
}
.xp-row-amount.earn { color: #34d399; }
.xp-row-amount.spend { color: #f87171; }

/* ===== TODO CHIPS ===== */
.todo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.todo-chip {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 9999px;
}

.todo-chip.muted { color: var(--text-dim); }

.perfect-day-card {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.04);
}

/* ===== QUEST CARDS ===== */
.quest-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tab-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover { background: var(--bg-card2); color: var(--text); }
.tab-btn.active { background: rgba(124, 58, 237, 0.15); color: var(--purple-400); }

.tab-content { display: flex; flex-direction: column; gap: 8px; }
.tab-content.hidden { display: none; }

.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.15s;
}

.quest-card:hover { border-color: rgba(59, 130, 246, 0.4); }
.quest-card.completed { opacity: 0.55; cursor: default; }
.quest-card.completed:hover { border-color: var(--border); }

.quest-info { flex: 1; min-width: 0; }
.quest-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}
.quest-name.done-text { text-decoration: line-through; color: #64748b; }
.quest-notes {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.quest-xp { flex-shrink: 0; text-align: right; }
.xp-reward {
  font-size: 1rem;
  font-weight: 800;
  color: #fcd34d;
}
.xp-earned {
  font-size: 0.88rem;
  font-weight: 700;
  color: #34d399;
}
.quest-status.active {
  font-size: 0.65rem;
  color: #60a5fa;
  font-weight: 600;
  margin-top: 2px;
}

/* ===== COLLECTION CARDS ===== */
.collection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.collection-card:hover { border-color: rgba(124, 58, 237, 0.4); }

.collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.collection-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.collection-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.collection-next-milestone {
  font-size: 0.7rem;
  color: var(--purple-400);
  margin-top: 6px;
}

/* ===== CAREER ===== */
.career-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.career-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.career-source {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.career-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.career-stats { text-align: right; }

/* ===== PROGRESS BAR ===== */
.progress-track {
  background: var(--bg-card2);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  height: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.8s ease;
}

/* ===== PROGRAMS ===== */
.program-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.program-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.program-name {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.program-dates {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.program-stats { text-align: right; }
.program-xp { font-size: 0.9rem; font-weight: 700; }
.program-days-stat { font-size: 0.68rem; color: var(--text-dim); }

.program-habits {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.program-habit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prog-habit-name {
  font-size: 0.72rem;
  color: #94a3b8;
  width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.program-compliance-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.program-habit-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #e2e8f0;
  transition: background 0.15s;
}

.program-habit-check:hover { background: #334155; }

/* ===== REWARDS ===== */
.xp-balance-card {
  background: linear-gradient(135deg, #1a1200, #0f172a);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.balance-value {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
}

.balance-breakdown {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rewards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.reward-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}

.reward-card.affordable {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.03);
}

.reward-card.locked { opacity: 0.75; }

.reward-top { flex: 1; }
.reward-name { font-size: 0.88rem; font-weight: 600; color: #e2e8f0; }
.reward-desc { font-size: 0.7rem; color: var(--text-dim); margin-top: 3px; }
.reward-price { font-size: 0.7rem; color: var(--text-dim); margin-top: 3px; }

.reward-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reward-xp-cost {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fcd34d;
}

.reward-locked-msg {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.reward-purchased {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reward-date { font-size: 0.68rem; color: var(--text-dim); }

/* ===== LEDGER ===== */
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ledger-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.ledger-stat-val {
  font-size: 1.3rem;
  font-weight: 900;
}

.ledger-stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
}

.ledger-entries { display: flex; flex-direction: column; gap: 4px; }

.ledger-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.1s;
}

.ledger-entry:hover { border-color: var(--border-hover); }
.ledger-entry-info { flex: 1; min-width: 0; }
.ledger-entry-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-entry-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.ledger-type {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--bg-card);
}
.ledger-type.habit { color: #a78bfa; }
.ledger-type.quest, .ledger-type.quest_complete { color: #60a5fa; }
.ledger-type.reward_spend { color: #f87171; }
.ledger-type.collection, .ledger-type.collection_milestone { color: #34d399; }
.ledger-type.career { color: #fb923c; }
.ledger-type.program { color: #38bdf8; }
.ledger-type.manual { color: #94a3b8; }

.ledger-entry-amount {
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ledger-entry-amount.earn { color: #34d399; }
.ledger-entry-amount.spend { color: #f87171; }

/* ===== ANALYTICS ===== */
.analytics-source-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

@media (min-width: 480px) {
  .analytics-source-wrap {
    flex-direction: row;
    align-items: flex-start;
  }
}

.source-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.source-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-label {
  flex: 1;
  font-size: 0.78rem;
  color: #94a3b8;
  text-transform: capitalize;
}

.source-xp {
  font-size: 0.78rem;
  font-weight: 700;
  color: #34d399;
}

.compliance-list { display: flex; flex-direction: column; gap: 12px; }

.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.compliance-info { flex: 1; }
.compliance-name { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.compliance-meta { font-size: 0.68rem; color: var(--text-dim); margin-top: 2px; }

.compliance-pct {
  font-size: 1rem;
  font-weight: 900;
  margin-left: 12px;
}

.compliance-pct.good { color: #34d399; }
.compliance-pct.ok { color: #fbbf24; }
.compliance-pct.low { color: #f87171; }

/* ===== SETTINGS ===== */
.xp-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.xp-breakdown-item {
  text-align: center;
  padding: 10px;
  background: var(--bg-card2);
  border-radius: 10px;
}

.xp-breakdown-val {
  font-size: 1.1rem;
  font-weight: 800;
}

.xp-breakdown-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.titles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  font-size: 0.75rem;
}

.title-row.achieved { border-left: 3px solid var(--purple-400); }
.title-level { color: var(--text-dim); width: 36px; flex-shrink: 0; }
.title-name { flex: 1; color: #cbd5e1; font-weight: 500; }
.title-xp { color: var(--purple-400); font-weight: 700; }
.title-check { color: #34d399; font-size: 0.8rem; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0;
}

.modal-overlay.open { opacity: 1; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-overlay.wide .modal-sheet { max-width: 560px; }
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-sheet { transform: translateY(0); }

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 20px;
    max-width: 480px;
    transform: scale(0.96);
  }
  .modal-overlay.open .modal-sheet { transform: scale(1); }
  .modal-overlay.wide .modal-sheet { max-width: 560px; }
}

.modal-content { display: flex; flex-direction: column; gap: 16px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: white;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

/* ===== FORMS ===== */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--purple-500); }

textarea.form-input { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 16px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
}
.btn-success:hover:not(:disabled) { background: linear-gradient(135deg, #10b981, #059669); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.25); }

.btn-ghost {
  background: var(--bg-card2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #334155; color: var(--text); }

.btn-gold {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: white;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(135deg, #f59e0b, #d97706); }

.btn-sm {
  padding: 7px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.7rem;
  border-radius: 6px;
}

.w-full { width: 100%; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }

/* ===== CHART ===== */
.chart-wrap {
  position: relative;
  height: 160px;
  width: 100%;
}

/* ===== COLLECTION ITEMS ===== */
.milestone-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.milestone-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.milestone-chip.achieved {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.collection-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 8px;
  padding-right: 2px;
}

.group-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border);
}

.collection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.collection-item:hover { background: #334155; }
.collection-item.completed { opacity: 0.7; }
.collection-item.set-bonus { border-color: rgba(234, 179, 8, 0.2); background: rgba(234, 179, 8, 0.04); }

.item-rank {
  font-size: 0.65rem;
  color: var(--text-dim);
  width: 28px;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.item-xp {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}

.item-xp.earned { color: #34d399; }

.item-check {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.set-bonus-badge {
  font-size: 0.6rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 4px;
  padding: 2px 5px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: all 0.25s ease;
  max-width: 320px;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(16, 185, 129, 0.5); color: #34d399; }
.toast.error { border-color: rgba(239, 68, 68, 0.5); color: #f87171; }
.toast.gold { border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }

/* ===== XP POP ===== */
.xp-pop {
  position: fixed;
  font-size: 0.85rem;
  font-weight: 900;
  color: #a78bfa;
  pointer-events: none;
  z-index: 9999;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.5);
  animation: float-up 1.6s ease-out forwards;
  transform: translateX(-50%);
}

@keyframes float-up {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 9999px; }

/* ===== MOBILE ===== */
@media (max-width: 767px) {
  .sidebar-nav { display: none; }
  .bottom-nav { display: flex; }
  .main-content { margin-left: 0; padding-bottom: var(--bottom-nav-h); }

  .toast { bottom: calc(var(--bottom-nav-h) + 12px); }
  .xp-pop { }

  .rewards-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { gap: 8px; }
  .stat-value { font-size: 1.2rem; }
  .character-title { font-size: 1.2rem; }
}

@media (max-width: 380px) {
  .rewards-grid { grid-template-columns: 1fr; }
}

/* ===== UTILITIES ===== */
.text-emerald-400 { color: #34d399 !important; }
.text-red-400 { color: #f87171 !important; }
.text-yellow-400 { color: #fbbf24 !important; }
.text-blue-400 { color: #60a5fa !important; }
.text-purple-400 { color: #c084fc !important; }
.text-gray-400 { color: #9ca3af !important; }
.text-gray-500 { color: #6b7280 !important; }
.text-white { color: #fff !important; }
.font-bold { font-weight: 700 !important; }
.font-black { font-weight: 900 !important; }
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.875rem !important; }
.text-base { font-size: 1rem !important; }
.text-lg { font-size: 1.125rem !important; }
.text-xl { font-size: 1.25rem !important; }
.text-2xl { font-size: 1.5rem !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.uppercase { text-transform: uppercase !important; }
.capitalize { text-transform: capitalize !important; }
.tracking-wider { letter-spacing: 0.05em !important; }
.tracking-widest { letter-spacing: 0.1em !important; }
.line-through { text-decoration: line-through !important; }
.opacity-70 { opacity: 0.7 !important; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.p-4 { padding: 16px; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.mr-1 { margin-right: 4px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-wrap { flex-wrap: wrap; }
.min-w-0 { min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounded { border-radius: 4px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 9999px; }
.border-b { border-bottom: 1px solid var(--border); }
.last\:border-0:last-child { border-bottom: none !important; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.max-h-60 { max-height: 15rem; }
.max-h-64 { max-height: 16rem; }
.max-h-96 { max-height: 24rem; }
.space-y-1 > * + * { margin-top: 4px; }
.space-y-1\.5 > * + * { margin-top: 6px; }

/* ===== ADDITIONAL RESPONSIVE / UTILITY ===== */
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }
.mt-1 { margin-top: 4px; }
.mb-1 { margin-bottom: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.pr-1 { padding-right: 4px; }
.mr-2 { margin-right: 8px; }
.text-4xl { font-size: 2.25rem !important; }
.accent-purple-500 { accent-color: #8b5cf6; }

/* Sticky sidebar scroll */
@media (min-width: 768px) {
  .sidebar-nav::-webkit-scrollbar { display: none; }
}

/* Better focus styles */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}

/* Improved chart containers */
.chart-wrap canvas { display: block; }

/* Loading screen (initial page load) */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
  gap: 16px;
  transition: opacity 0.4s ease;
}

#loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-logo {
  font-size: 3rem;
  animation: pulse-logo 1.5s ease-in-out infinite;
}

@keyframes pulse-logo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.loading-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--purple-400);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.loading-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Program habit check - larger touch target */
.program-habit-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Better reward card on small screens */
@media (max-width: 480px) {
  .rewards-grid { grid-template-columns: 1fr; }
  .xp-balance-card { flex-direction: column; gap: 12px; }
  .balance-breakdown { text-align: left; }
  .balance-value { font-size: 2rem; }
}

/* Analytics specific */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .analytics-kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.analytics-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}

.analytics-kpi-val {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
}

.analytics-kpi-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Subtle separator */
.sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Link-style button */
.btn-link {
  background: none;
  border: none;
  color: var(--purple-400);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Danger zone / at-risk highlighting */
.text-orange-400 { color: #fb923c !important; }
.text-orange-300 { color: #fdba74 !important; }

/* Better mobile nav icon sizing */
@media (max-width: 380px) {
  .nav-item { padding: 6px 8px; }
  .nav-item i { font-size: 1rem; }
  .nav-item span { font-size: 0.55rem; }
}

/* Quest summary identical to habit summary */
.quest-summary .summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

/* Flex utilities */
.flex-end { justify-content: flex-end; }
.items-end { align-items: flex-end; }

/* Programs detail modal */
.prog-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 3px;
}

.prog-day-dot {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  cursor: default;
}

.prog-day-dot.perfect { background: rgba(124,58,237,0.25); color: #a78bfa; }
.prog-day-dot.partial { background: rgba(245,158,11,0.15); color: #fcd34d; }
.prog-day-dot.miss { background: rgba(239,68,68,0.1); color: #f87171; }

/* Modal wide override */
@media (min-width: 640px) {
  .modal-overlay.wide .modal-sheet { max-width: 600px; }
}

/* Textarea placeholder */
textarea::placeholder, input::placeholder { color: var(--text-dim); }

/* Milestone label wrap fix */
.collection-next-milestone {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ============================================================
   STYLES v2.1 ADDITIONS
   ============================================================ */

/* Streak right-aligned in dashboard */
.streak-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.streak-label-best {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* XP row with date */
.xp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(30,41,59,0.6);
}
.xp-row:last-child { border-bottom: none; }
.xp-row-name {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xp-row-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.xp-row-amount {
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}
.xp-row-amount.earn { color: var(--emerald); }
.xp-row-amount.spend { color: var(--red); }

/* History banner in Today page */
.history-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #fcd34d;
}

/* Ledger filter bar */
.ledger-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ledger-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ledger-filter-btn:hover { border-color: var(--purple-400); color: var(--purple-400); }
.ledger-filter-btn.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--purple-400);
  color: var(--purple-400);
}

/* Ledger type badge inline */
.ledger-type {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(30,41,59,0.8);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* Streak lb right */
.streak-lb-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

/* Analytics source wrap flex */
.analytics-source-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
@media (min-width: 500px) {
  .analytics-source-wrap {
    flex-direction: row;
    align-items: flex-start;
  }
}
.source-legend {
  flex: 1;
  width: 100%;
}

/* Compliance list */
.compliance-list { display: flex; flex-direction: column; gap: 14px; }
.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.compliance-info { flex: 1; }
.compliance-name { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.compliance-meta { font-size: 0.72rem; color: var(--text-dim); margin-top: 1px; }
.compliance-pct {
  font-size: 1.1rem;
  font-weight: 900;
  margin-left: 12px;
}
.compliance-pct.good { color: var(--emerald); }
.compliance-pct.ok { color: var(--gold); }
.compliance-pct.low { color: var(--red); }

/* Program habit row with percent */
.program-habit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.prog-habit-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 100px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Today XP line enhanced */
.today-xp-line {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Quest notes clamp */
.quest-notes {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Reward purchased card */
.reward-purchased {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.reward-date { font-size: 0.7rem; color: var(--text-dim); margin-top: 1px; }

/* Better mobile Today page */
@media (max-width: 480px) {
  .today-header { gap: 8px; }
  .habit-card { padding: 10px 12px; gap: 10px; }
  .habit-toggle { width: 36px; height: 36px; font-size: 0.95rem; }
  .habit-dots .dot { width: 9px; height: 9px; }
}

/* Source row in analytics */
.source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.78rem;
}
.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.source-label {
  flex: 1;
  color: var(--text);
  text-transform: capitalize;
  font-weight: 500;
}
.source-xp {
  font-weight: 700;
  color: var(--emerald);
}

/* Ledger summary 4-col */
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 480px) {
  .ledger-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   FORGE TOTALS PAGE
   ============================================================ */

/* Goal card grid — side by side on mobile */
.ft-goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 480px) {
  .ft-goal-grid { grid-template-columns: 1fr; }
}

.ft-goal-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
}
.ft-goal-weight { border-top: 3px solid #f97316; }
.ft-goal-cardio { border-top: 3px solid #22d3ee; }

.ft-goal-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.ft-goal-icon {
  font-size: 1.25rem;
  margin-top: 2px;
}
.ft-goal-weight .ft-goal-icon { color: #f97316; }
.ft-goal-cardio .ft-goal-icon { color: #22d3ee; }

.ft-goal-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.ft-goal-target {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.ft-goal-pct {
  margin-left: auto;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
}

/* Progress bar */
.ft-progress-bar-track {
  height: 10px;
  background: var(--bg-card2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ft-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}
.ft-fill-weight { background: linear-gradient(90deg, #ea580c, #f97316, #fb923c); }
.ft-fill-cardio { background: linear-gradient(90deg, #0891b2, #22d3ee, #67e8f9); }

/* Goal stats row */
.ft-goal-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}
.ft-goal-stat-val {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
}
.ft-goal-stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ft-weight-color { color: #f97316; }
.ft-cardio-color { color: #22d3ee; }

.ft-pace-line {
  font-size: 0.72rem;
  margin-top: 4px;
}
.ft-pace-ahead { color: #34d399; font-weight: 600; }
.ft-pace-behind { color: #f87171; font-weight: 600; }

/* Quick Add Card */
.ft-add-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.ft-add-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.ft-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 400px) {
  .ft-form-grid { grid-template-columns: 1fr; }
}
.ft-form-notes { grid-column: 1 / -1; }

.ft-form-group { display: flex; flex-direction: column; gap: 4px; }
.ft-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ft-optional { font-weight: 400; font-style: italic; text-transform: none; }

.ft-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.ft-input:focus { border-color: #f97316; }
.ft-input::placeholder { color: var(--text-muted); }
.ft-input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.6); }

.ft-btn-add {
  width: 100%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.15s, transform 0.1s;
}
.ft-btn-add:active { opacity: 0.85; transform: scale(0.98); }

/* Section cards */
.ft-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.ft-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Monthly table */
.ft-monthly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.ft-monthly-table th {
  text-align: left;
  padding: 5px 6px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border);
}
.ft-monthly-table td { padding: 7px 6px; }
.ft-monthly-table tr + tr { border-top: 1px solid var(--border-subtle, #1e293b); }
.ft-mo-name { font-weight: 600; color: var(--text); }
.ft-mo-val  { color: var(--text); text-align: right; }
.ft-mo-cnt  { color: var(--text-muted); text-align: right; }
.ft-empty-cell { text-align: center; color: var(--text-muted); padding: 16px; }
.ft-monthly-total td {
  font-weight: 700;
  color: var(--text);
  border-top: 2px solid var(--border);
  padding-top: 8px;
}

/* Entry cards */
.ft-entry-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle, #1e293b);
}
.ft-entry-card:last-child { border-bottom: none; }
.ft-entry-card.ft-editing {
  flex-direction: column;
  align-items: stretch;
  background: var(--bg-card2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 6px;
  border-bottom: none;
}

.ft-entry-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 80px;
  white-space: nowrap;
}
.ft-entry-stats {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ft-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}
.ft-weight-chip { background: rgba(249,115,22,0.15); color: #fb923c; }
.ft-cardio-chip { background: rgba(34,211,238,0.12); color: #22d3ee; }
.ft-entry-notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  width: 100%;
}
.ft-entry-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.ft-icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 5px 7px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}
.ft-icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.ft-delete-btn:hover { color: #f87171; border-color: #f87171; }

/* Edit form inside entry card */
.ft-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.ft-input-notes { grid-column: 1 / -1; }
.ft-entry-actions {
  display: flex;
  gap: 8px;
}
.ft-btn-save {
  flex: 1;
  background: #059669;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}
.ft-btn-cancel {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.ft-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 24px 0;
}

/* ============================================================
   QUICK LOG FLOATING ACTION BUTTON
   ============================================================ */
.quick-log-fab {
  position: fixed;
  right: 20px;
  bottom: 84px; /* sits above the bottom nav */
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: 1px solid rgba(167, 139, 250, 0.55);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 10px 28px rgba(124, 58, 237, 0.45),
    0 0 40px rgba(124, 58, 237, 0.22);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.quick-log-fab:hover {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 14px 36px rgba(139, 92, 246, 0.55),
    0 0 60px rgba(139, 92, 246, 0.35);
}
.quick-log-fab:active { transform: translateY(0) scale(0.97); }
.quick-log-fab .fa-bolt { font-size: 0.95rem; }
@media (min-width: 768px) {
  .quick-log-fab { bottom: 24px; right: 24px; padding: 14px 22px; font-size: 0.9rem; }
}
@media (max-width: 480px) {
  .quick-log-fab .quick-log-label { display: none; }
  .quick-log-fab { padding: 14px; }
}

/* ============================================================
   INLINE COLLECTION ITEM ADD ROW
   ============================================================ */
.collection-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px dashed rgba(167, 139, 250, 0.4);
  border-radius: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.collection-add-row:focus-within {
  border-color: rgba(167, 139, 250, 0.8);
  border-style: solid;
  background: rgba(124, 58, 237, 0.14);
}
.collection-add-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #e5e7eb;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 4px 0;
}
.collection-add-input::placeholder { color: rgba(167, 139, 250, 0.6); font-weight: 600; }
.collection-add-xp {
  width: 60px;
  background: rgba(3, 7, 18, 0.5);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  padding: 4px 6px;
  outline: none;
}
.collection-add-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: transform 0.12s ease, background 0.15s ease;
}
.collection-add-btn:hover { background: linear-gradient(135deg, #8b5cf6, #7c3aed); transform: scale(1.05); }
.collection-add-btn:active { transform: scale(0.95); }

/* Empty state inside collection detail */
.empty-state-mini {
  text-align: center;
  padding: 16px 12px;
  color: var(--text-muted, #9ca3af);
  font-size: 0.85rem;
}

/* Form checkbox row */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}
.form-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #7c3aed;
  cursor: pointer;
}

/* ============================================================
   MOBILE "MORE" POPOVER MENU
   ============================================================ */
.more-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.6);
  backdrop-filter: blur(2px);
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.more-menu-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.more-menu {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bottom-nav-h) + 12px);
  z-index: 960;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--bg-card3, #161625);
  border: 1px solid var(--border, #2a2a3a);
  border-radius: 14px;
  padding: 6px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 18px 40px rgba(0, 0, 0, 0.55),
    0 0 30px rgba(124, 58, 237, 0.18);
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.more-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: #e5e7eb;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.more-menu-item:hover,
.more-menu-item:active {
  background: rgba(124, 58, 237, 0.18);
  color: #fff;
}
.more-menu-item i {
  width: 18px;
  text-align: center;
  color: #a78bfa;
  font-size: 0.95rem;
}
/* Hide More button on desktop (sidebar handles it) */
@media (min-width: 768px) {
  .more-menu, .more-menu-backdrop { display: none !important; }
}

/* ============================================================
   MOBILE FIXES FOR QUEST LOG HEADER & QUICK ADDS
   ============================================================ */
@media (max-width: 480px) {
  /* Wrap quest log header buttons so they don't overflow */
  .page-header { flex-wrap: wrap; gap: 8px; }
  .page-header > .flex { flex-wrap: wrap; }

  /* Inline collection-add row: more comfortable taps on phones */
  .collection-add-row { padding: 12px; gap: 6px; }
  .collection-add-input { font-size: 0.95rem; padding: 6px 0; }
  .collection-add-xp { width: 54px; font-size: 0.85rem; }
  .collection-add-btn { width: 36px; height: 36px; font-size: 0.95rem; }

  /* Tighter FAB position so it doesn't crowd nav items */
  .quick-log-fab { right: 14px; bottom: calc(var(--bottom-nav-h) + 14px); }

  /* Make modal form spacing comfortable on phones */
  .form-stack .form-row { flex-direction: column; gap: 12px; }
  .form-row > .form-group { width: 100%; }
}

/* Ensure FAB sits above bottom nav on every screen size */
.quick-log-fab { z-index: 940; }

/* ============================================================
   AUDIO TOGGLE BUTTONS (top-right corner)
   ============================================================ */
.audio-toggles {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 945;
  pointer-events: auto;
}
.audio-toggle-btn {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(15, 17, 28, 0.72);
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.audio-toggle-btn:hover {
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.18);
  background: rgba(30, 33, 48, 0.85);
}
.audio-toggle-btn:active { transform: scale(0.94); }
.audio-toggle-btn.on {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}
.audio-toggle-btn .audio-slash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.audio-toggle-btn .audio-slash::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 15%;
  right: 15%;
  height: 2px;
  background: #ef4444;
  transform: translateY(-50%) rotate(-30deg);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.audio-toggle-btn.on .audio-slash { display: none; }

/* On mobile keep toggles compact and out of the way of header buttons */
@media (max-width: 480px) {
  .audio-toggles { top: 8px; right: 8px; gap: 4px; }
  .audio-toggle-btn { width: 30px; height: 30px; font-size: 0.78rem; }
}

/* ============================================================
   MYTHIC PROGRESSION OVERLAY — Avatar Page
   ============================================================ */

/* ---- Dashboard strip ---- */
.mythic-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.mythic-strip:empty { display: none; }
.mythic-strip-slots {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.mythic-strip-slot {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(15,17,28,0.55);
  color: #94a3b8;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.mythic-strip-slot.empty { color: #475569; border-style: dashed; }
.mythic-strip-link {
  background: transparent;
  border: 1px solid rgba(167,139,250,0.45);
  color: #c4b5fd;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.mythic-strip-link:hover {
  background: rgba(124,58,237,0.12);
  border-color: rgba(167,139,250,0.7);
}

/* ---- Avatar page layout ---- */
.avatar-page { padding-bottom: 80px; }

.avatar-unlock-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(251,191,36,0.10), rgba(124,58,237,0.10));
  border: 1px solid rgba(251,191,36,0.35);
  animation: avatar-banner-glow 2.4s ease-in-out infinite alternate;
}
.avatar-unlock-banner i {
  color: #fbbf24;
  font-size: 1.4rem;
  filter: drop-shadow(0 0 6px rgba(251,191,36,0.6));
}
@keyframes avatar-banner-glow {
  from { box-shadow: 0 0 0 0 rgba(251,191,36,0.0); }
  to   { box-shadow: 0 0 24px 0 rgba(251,191,36,0.25); }
}

/* Portrait card */
.avatar-portrait-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(30,33,48,0.95), rgba(15,17,28,0.95));
  border: 1px solid rgba(167,139,250,0.25);
  box-shadow: 0 0 40px rgba(124,58,237,0.12) inset;
}
/* ---- v2.3 Portrait Progression: level-aware frame ---- */
.avatar-portrait-frame {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* The SVG XP-ring sits in the same square as the portrait, behind the image */
.avatar-portrait-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.avatar-portrait-ring .ring-track {
  fill: none;
  stroke: rgba(167,139,250,0.15);
  stroke-width: 6;
}
.avatar-portrait-ring .ring-progress {
  fill: none;
  stroke: #c4b5fd;
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(167,139,250,0.6));
  transition: stroke-dashoffset 0.6s ease;
}
.avatar-portrait-img-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(167,139,250,0.20), rgba(15,17,28,0.95));
  border: 2px solid rgba(167,139,250,0.55);
  box-shadow: 0 0 30px rgba(124,58,237,0.25) inset;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
}
.avatar-portrait-silhouette {
  font-size: 3.4rem;
  color: #c4b5fd;
  filter: drop-shadow(0 0 12px rgba(167,139,250,0.5));
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-portrait-badge {
  position: absolute;
  bottom: 0;
  right: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #facc15, #b45309);
  color: #1f1306;
  border: 2px solid rgba(15,17,28,0.95);
  box-shadow: 0 0 12px rgba(250,204,21,0.5);
  line-height: 1;
}
.avatar-portrait-badge .badge-label {
  font-size: 0.46rem;
  letter-spacing: 0.12em;
  font-weight: 800;
  opacity: 0.85;
}
.avatar-portrait-badge .badge-value {
  font-size: 1.05rem;
  font-weight: 900;
}

.avatar-portrait-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.avatar-class { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.15em; color: #94a3b8; text-transform: uppercase; }
.avatar-title { font-size: 1.4rem; font-weight: 900; color: #f1f5f9; letter-spacing: 0.02em; }
.avatar-level { font-size: 0.8rem; color: #c4b5fd; }

.avatar-progress-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}
.avatar-progress-pct { color: #c4b5fd; font-weight: 800; }
.avatar-progress-arrow { color: #64748b; }
.avatar-progress-next { color: #e2e8f0; font-weight: 700; }
.avatar-progress-xp { color: #64748b; font-size: 0.68rem; }

.avatar-portrait-caption {
  font-size: 0.78rem;
  font-style: italic;
  color: #cbd5e1;
  margin-top: 6px;
  line-height: 1.35;
  opacity: 0.85;
}

.avatar-portrait-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15,17,28,0.6);
  border: 1px dashed rgba(167,139,250,0.35);
  align-self: flex-start;
  max-width: 100%;
}
.avatar-portrait-next.mythic-attained {
  border-style: solid;
  border-color: rgba(250,204,21,0.55);
  background: rgba(180,83,9,0.10);
}
.avatar-portrait-next-label {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 800;
}
.avatar-portrait-next-level {
  font-size: 0.78rem;
  font-weight: 900;
  color: #c4b5fd;
}
.avatar-portrait-next.mythic-attained .avatar-portrait-next-level { color: #facc15; }
.avatar-portrait-next-title {
  font-size: 0.78rem;
  color: #e2e8f0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

/* ---- v2.3 Mythic strip portrait thumb ---- */
.mythic-strip-portrait {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.mythic-strip-portrait img {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(167,139,250,0.6);
  image-rendering: pixelated;
}
.mythic-strip-portrait-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.mythic-strip-portrait-ring .ring-track {
  fill: none;
  stroke: rgba(167,139,250,0.15);
  stroke-width: 3;
}
.mythic-strip-portrait-ring .ring-progress {
  fill: none;
  stroke: #c4b5fd;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.mythic-strip-portrait-level {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: linear-gradient(135deg, #facc15, #b45309);
  color: #1f1306;
  font-size: 0.6rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 1px 5px;
  border: 1.5px solid rgba(15,17,28,0.95);
  min-width: 18px;
  text-align: center;
  line-height: 1.2;
}

/* Section titles */
.avatar-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 18px 0 10px;
}

/* Equipped slots row */
.avatar-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.avatar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: 10px;
  background: rgba(15,17,28,0.55);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  min-width: 0;
}
.avatar-slot:hover { background: rgba(30,33,48,0.85); border-color: rgba(167,139,250,0.4); }
.avatar-slot:active { transform: scale(0.97); }
.avatar-slot.empty { border-style: dashed; opacity: 0.7; }
.avatar-slot-frame {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 1.15rem;
  color: #94a3b8;
  margin-bottom: 6px;
}
.avatar-slot-label {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}
.avatar-slot-name {
  font-size: 0.7rem;
  color: #cbd5e1;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.avatar-slot.empty .avatar-slot-name { color: #475569; }

/* ---- Tier colors (mythic-strip, slots, vault cards, modals) ---- */
.tier-1 .avatar-slot-frame,
.tier-1.vault-card .vault-card-frame,
.tier-1.mythic-strip-slot,
.tier-1.slot-picker-option .slot-picker-frame,
.artifact-detail.tier-1 .artifact-detail-icon { color: #cbd5e1; border-color: rgba(203,213,225,0.45); }

.tier-2 .avatar-slot-frame,
.tier-2.vault-card .vault-card-frame,
.tier-2.mythic-strip-slot,
.tier-2.slot-picker-option .slot-picker-frame,
.artifact-detail.tier-2 .artifact-detail-icon { color: #6ee7b7; border-color: rgba(110,231,183,0.45); }

.tier-3 .avatar-slot-frame,
.tier-3.vault-card .vault-card-frame,
.tier-3.mythic-strip-slot,
.tier-3.slot-picker-option .slot-picker-frame,
.artifact-detail.tier-3 .artifact-detail-icon { color: #93c5fd; border-color: rgba(147,197,253,0.55); }

.tier-4 .avatar-slot-frame,
.tier-4.vault-card .vault-card-frame,
.tier-4.mythic-strip-slot,
.tier-4.slot-picker-option .slot-picker-frame,
.artifact-detail.tier-4 .artifact-detail-icon { color: #c4b5fd; border-color: rgba(196,181,253,0.55); box-shadow: 0 0 12px rgba(167,139,250,0.25); }

.tier-5 .avatar-slot-frame,
.tier-5.vault-card .vault-card-frame,
.tier-5.mythic-strip-slot,
.tier-5.slot-picker-option .slot-picker-frame,
.artifact-detail.tier-5 .artifact-detail-icon { color: #fbbf24; border-color: rgba(251,191,36,0.65); box-shadow: 0 0 16px rgba(251,191,36,0.35); }

.avatar-slot.tier-3 .avatar-slot-name,
.vault-card.tier-3 .vault-card-name { color: #bfdbfe; }
.avatar-slot.tier-4 .avatar-slot-name,
.vault-card.tier-4 .vault-card-name { color: #ddd6fe; }
.avatar-slot.tier-5 .avatar-slot-name,
.vault-card.tier-5 .vault-card-name { color: #fde68a; }

/* ---- Artifact Vault ---- */
.vault-group { margin-bottom: 18px; }
.vault-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cbd5e1;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 10px;
}
.vault-group-header i { color: #94a3b8; }
.vault-group-count { margin-left: auto; color: #64748b; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; }

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.vault-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 10px;
  background: rgba(15,17,28,0.55);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.vault-card:hover { border-color: rgba(167,139,250,0.45); }
.vault-card:active { transform: scale(0.97); }
.vault-card.locked { opacity: 0.55; }
.vault-card.locked .vault-card-frame { color: #475569; border-style: dashed; }
.vault-card.locked .vault-card-name { color: #64748b; font-style: italic; }
.vault-card-frame {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 1.4rem;
  color: #94a3b8;
  margin-bottom: 8px;
}
.vault-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
}
.vault-card-hint {
  font-size: 0.62rem;
  color: #64748b;
  letter-spacing: 0.05em;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.vault-equipped-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(110,231,183,0.15);
  color: #6ee7b7;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

/* ---- Artifact detail modal ---- */
.artifact-detail .artifact-detail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px auto;
  width: 96px;
  height: 96px;
  border-radius: 14px;
  border: 2px solid rgba(167,139,250,0.45);
  background: radial-gradient(circle at center, rgba(167,139,250,0.15), rgba(15,17,28,0.9));
  font-size: 3rem;
}
.artifact-detail.locked .artifact-detail-icon {
  border-style: dashed;
  opacity: 0.7;
}
.artifact-detail-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}
.artifact-slot-chip,
.artifact-tier-chip {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
}
.artifact-tier-chip.tier-2 { background: rgba(110,231,183,0.12); color: #6ee7b7; }
.artifact-tier-chip.tier-3 { background: rgba(147,197,253,0.12); color: #93c5fd; }
.artifact-tier-chip.tier-4 { background: rgba(196,181,253,0.15); color: #ddd6fe; }
.artifact-tier-chip.tier-5 { background: rgba(251,191,36,0.15); color: #fbbf24; }
.artifact-flavor {
  text-align: center;
  font-style: italic;
  color: #a5b4fc;
  margin: 14px 12px 16px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.artifact-context {
  text-align: center;
  font-size: 0.75rem;
  color: #6ee7b7;
  margin-bottom: 14px;
}
.artifact-context i { margin-right: 4px; }
.artifact-locked-desc {
  text-align: center;
  color: #94a3b8;
  margin: 14px 12px 12px;
  font-size: 0.88rem;
}
.artifact-unlock-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 12px 16px;
  border-radius: 8px;
  background: rgba(15,17,28,0.7);
  border: 1px dashed rgba(255,255,255,0.12);
  color: #cbd5e1;
  font-size: 0.85rem;
}
.artifact-unlock-hint i { color: #fbbf24; }

/* ---- Slot picker modal ---- */
.slot-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.slot-picker-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border-radius: 10px;
  background: rgba(15,17,28,0.55);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.slot-picker-option:hover { border-color: rgba(167,139,250,0.45); }
.slot-picker-option:active { transform: scale(0.96); }
.slot-picker-option.selected { border-color: #6ee7b7; box-shadow: 0 0 0 2px rgba(110,231,183,0.25) inset; }
.slot-picker-frame {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 1.2rem;
  color: #94a3b8;
  margin-bottom: 6px;
}
.slot-picker-frame.empty { border-style: dashed; color: #475569; }
.slot-picker-name {
  font-size: 0.7rem;
  color: #cbd5e1;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
}
.slot-picker-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: rgba(110,231,183,0.2);
  color: #6ee7b7;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---- Mobile tweaks ---- */
@media (max-width: 480px) {
  .avatar-slots { gap: 4px; }
  .avatar-slot { padding: 8px 2px; }
  .avatar-slot-frame { width: 38px; height: 38px; font-size: 1rem; }
  .avatar-slot-label { font-size: 0.55rem; }
  .avatar-slot-name { font-size: 0.65rem; }
  .vault-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .vault-card-frame { width: 46px; height: 46px; font-size: 1.2rem; }
  .vault-card-name { font-size: 0.72rem; }
  .vault-card-hint { font-size: 0.58rem; }
  .avatar-portrait-card { flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 14px; }
  .avatar-portrait-frame { width: 132px; height: 132px; }
  .avatar-portrait-img-wrap { width: 108px; height: 108px; }
  .avatar-portrait-badge { width: 36px; height: 36px; }
  .avatar-portrait-badge .badge-value { font-size: 0.9rem; }
  .avatar-portrait-silhouette { font-size: 2.6rem; }
  .avatar-title { font-size: 1.15rem; }
  .avatar-portrait-info { align-items: center; }
  .avatar-progress-line { justify-content: center; }
  .mythic-strip { flex-direction: column; align-items: stretch; gap: 10px; }
  .mythic-strip-link { align-self: flex-end; }
  .mythic-strip-portrait { align-self: center; }
}

/* ============================================================
   VOYAGE PAGE
   ============================================================ */

.voyage-loop-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple-400);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 999px;
  vertical-align: middle;
}

/* Hero / start screen */
.voyage-hero {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card3);
}
.voyage-hero-img {
  width: 100%;
  display: block;
  filter: brightness(0.55);
}
.voyage-hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  background: linear-gradient(180deg, transparent 0%, rgba(3,7,18,0.6) 100%);
}
.voyage-hero-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.voyage-hero-sub {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 18px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* World banner (active voyage) */
.voyage-banner {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}
.voyage-banner-img {
  width: 100%;
  display: block;
  max-height: 200px;
  object-fit: cover;
  filter: brightness(0.5);
}
.voyage-banner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(180deg, rgba(3,7,18,0.3) 0%, rgba(3,7,18,0.7) 100%);
}
.voyage-banner-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
}
.voyage-stat {
  text-align: center;
}
.voyage-stat-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  line-height: 1.1;
}
.voyage-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #cbd5e1;
  margin-top: 2px;
}

/* Continent strip (horizontal scrollable) */
.voyage-continents-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}
.voyage-continents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.voyage-continents-preview .voyage-continent-tile {
  cursor: default;
}
.voyage-continent-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--bg-card3);
}
.voyage-continent-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.2s ease;
}
.voyage-continent-tile.locked img {
  filter: grayscale(1) brightness(0.45);
}
.voyage-continent-tile.completed img {
  filter: brightness(0.9) saturate(1.1);
}
.voyage-continent-tile.active img {
  filter: brightness(1);
}
.voyage-continent-tile.not_started img {
  filter: brightness(0.7) saturate(0.8);
}
.voyage-continent-tile:hover {
  transform: translateY(-2px);
  border-color: var(--purple-400);
}
.voyage-continent-tile.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}
.voyage-continent-tile.completed {
  border-color: rgba(16, 185, 129, 0.5);
}
.voyage-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  background: linear-gradient(180deg, rgba(3,7,18,0) 30%, rgba(3,7,18,0.85) 100%);
  pointer-events: none;
}
.voyage-tile-order {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 1px 3px #000;
  background: rgba(3,7,18,0.7);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voyage-tile-status {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  text-shadow: 0 1px 3px #000;
}
.voyage-tile-name {
  font-size: 0.7rem;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: 0 1px 3px #000;
  line-height: 1.15;
  margin-top: auto;
}
.voyage-tile-theme {
  font-size: 0.6rem;
  color: #cbd5e1;
  margin-top: 2px;
  text-shadow: 0 1px 2px #000;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.voyage-tile-progress {
  margin-top: 4px;
}
.voyage-tile-progress-bar {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
}
.voyage-tile-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-500), var(--gold));
  border-radius: 2px;
  transition: width 0.3s ease;
}
.voyage-tile-progress-text {
  font-size: 0.55rem;
  color: #e2e8f0;
  margin-top: 2px;
  text-shadow: 0 1px 2px #000;
  font-weight: 700;
}

/* Chapter detail */
.voyage-chapter-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.voyage-empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.voyage-chapter-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.voyage-chapter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.voyage-chapter-title {
  font-size: 1.3rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.voyage-chapter-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple-700);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 900;
}
.voyage-chapter-theme {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.voyage-chapter-status-active   { color: var(--blue);    font-size: 0.75rem; font-weight: 700; }
.voyage-chapter-status-completed{ color: var(--emerald); font-size: 0.75rem; font-weight: 700; }
.voyage-chapter-status-locked   { color: var(--text-dim);font-size: 0.75rem; font-weight: 700; }
.voyage-chapter-status-not_started { color: var(--gold); font-size: 0.75rem; font-weight: 700; }
.voyage-chapter-locked-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
}
.voyage-chapter-done-badge {
  color: var(--emerald);
  font-weight: 800;
  padding: 8px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
}
.voyage-gate-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  line-height: 1.4;
}

.voyage-slots {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.voyage-slot {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card3);
}
.voyage-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}
.voyage-slot-title {
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}
.voyage-slot-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}
.voyage-quest-list {
  display: flex;
  flex-direction: column;
}
.voyage-quest-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.6);
  cursor: pointer;
  transition: background 0.12s ease;
}
.voyage-quest-row:last-child { border-bottom: none; }
.voyage-quest-row:hover {
  background: rgba(139, 92, 246, 0.06);
}
.voyage-quest-row.done {
  opacity: 0.55;
}
.voyage-quest-row.in_progress {
  background: rgba(14, 165, 233, 0.04);
}
.voyage-quest-row-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  flex-wrap: wrap;
}
.voyage-quest-row-name {
  font-weight: 600;
  font-size: 0.88rem;
  flex: 1;
  min-width: 0;
}
.voyage-quest-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.voyage-quest-counter {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--blue);
  background: rgba(14, 165, 233, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}
.voyage-quest-stage-badge {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--gold-light);
}
.voyage-quest-hosting {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.voyage-quest-gate {
  color: var(--purple-400);
}
.voyage-quest-optional {
  color: var(--text-dim);
}
.voyage-quest-xp {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
}
.voyage-quest-xp-earned {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--emerald);
}
.voyage-quest-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.voyage-stage-done {
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  color: var(--emerald);
  font-weight: 600;
  font-size: 0.85rem;
}
.voyage-quest-completed-note {
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  color: var(--emerald);
  font-weight: 600;
}

/* ============================================================
   VOYAGE MAP VIEW (Phase B1)
   ============================================================ */

/* Map/List view toggle button group */
.voyage-view-toggle {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.voyage-view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.voyage-view-toggle-btn:hover {
  color: var(--text);
  background: rgba(167, 139, 250, 0.08);
}
.voyage-view-toggle-btn.active {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}
.voyage-view-toggle-btn i {
  font-size: 0.85rem;
}

/* Map container & surface */
.voyage-map-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

/* Viewport: the fixed-size window we look through.
   16:9-ish aspect, clips overflow during pan/zoom. */
.voyage-map-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;             /* matches continent images (1024×768) */
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(circle at 25% 30%, rgba(124, 58, 237, 0.10) 0%, transparent 55%),
    radial-gradient(circle at 75% 70%, rgba(212, 168, 67, 0.06) 0%, transparent 55%),
    linear-gradient(160deg, rgba(15, 23, 42, 0.85), rgba(8, 14, 30, 0.95));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 0 60px rgba(15, 23, 42, 0.6);
  cursor: grab;
  touch-action: none;              /* let JS handle pan + pinch */
  user-select: none;
  -webkit-user-select: none;
}
.voyage-map-viewport.panning { cursor: grabbing; }

/* Image layer: holds the continent map image. Gets translate + scale during
   pan/zoom. The pin layer is a sibling (NOT inside this) so pin chrome stays
   at fixed pixel size at every zoom. */
.voyage-map-image-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;            /* image is decorative; pan capture is on viewport */
}

/* The continent image fills the image layer. Pixel art rendered crisply. */
.voyage-map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* Pin layer: SIBLING of image-layer. Gets translate (pan) only \u2014 NOT scale.
   Pin buttons are absolute-positioned in PIXELS by JS, so they track the
   underlying image's scaled coordinates while staying at fixed visual size. */
.voyage-map-pin-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;            /* pins re-enable on themselves */
  transform-origin: center center;
  will-change: transform;
}

/* Zoom controls — overlaid on the viewport, not transformed with the stage. */
.voyage-map-zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.voyage-map-zoom-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.voyage-map-zoom-btn:hover {
  background: rgba(124, 58, 237, 0.45);
  border-color: rgba(167, 139, 250, 0.7);
}
.voyage-map-zoom-btn:active { transform: scale(0.94); }
.voyage-map-fullscreen-btn {
  margin-top: 4px;             /* small separation from the zoom triplet */
  border-color: rgba(212, 168, 67, 0.45);
  font-size: 1rem;
}
.voyage-map-fullscreen-btn:hover {
  background: rgba(212, 168, 67, 0.35);
  border-color: rgba(212, 168, 67, 0.85);
}

/* Individual pin button.
   POSITIONING: `left` / `top` are written by JS in PIXELS on every pan/zoom,
   in the coordinate space of the (pan-only) pin-layer. The pin button itself
   is foot-anchored at its coordinate via translate(-50%, -100%).
   No counter-scale anymore \u2014 pins live OUTSIDE the scaled image layer, so
   their visual size is constant at every zoom. */
.voyage-map-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  z-index: 1;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  transition: filter 0.15s ease;
}
.voyage-map-pin:hover {
  z-index: 4;
  filter: brightness(1.15);
}
.voyage-map-pin:active {
  filter: brightness(0.95);
}

/* Marker container \u2014 sized identically whether art or CSS variant. */
.voyage-map-pin-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  position: relative;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

/* CSS-circle marker variant: used for "crossing" slot and as art-image fallback */
.voyage-map-pin-marker--css {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pin-color, #a78bfa);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18),
    inset 0 1px 1px rgba(255, 255, 255, 0.4);
}
.voyage-map-pin-glyph {
  font-size: 11px;
  color: rgba(15, 23, 42, 0.85);
  line-height: 1;
}
.voyage-map-pin:hover .voyage-map-pin-marker--css {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.18),
    0 3px 8px rgba(0, 0, 0, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18),
    inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* Pin-art marker variant: the real PNG pin image. Foot-anchored visually
   via the translate(-50%, -100%) on the parent .voyage-map-pin. */
.voyage-map-pin-marker--art {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6))
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.4));
}
.voyage-map-pin-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.voyage-map-pin:hover .voyage-map-pin-marker--art {
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.45))
    drop-shadow(0 3px 5px rgba(0, 0, 0, 0.7));
}
/* State-based styling \u2014 CSS-circle marker variant
   (not-started = dimmed; in-progress = blue glow; done = green glow) */
.voyage-map-pin.not-started .voyage-map-pin-marker--css {
  opacity: 0.78;
  filter: saturate(0.65);
}
.voyage-map-pin.in-progress .voyage-map-pin-marker--css {
  box-shadow:
    0 0 0 2px rgba(96, 165, 250, 0.55),
    0 2px 6px rgba(96, 165, 250, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18);
}
.voyage-map-pin.done .voyage-map-pin-marker--css {
  background: var(--emerald, #10b981);
  box-shadow:
    0 0 0 2px rgba(16, 185, 129, 0.45),
    0 2px 6px rgba(16, 185, 129, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18);
}
.voyage-map-pin.done .voyage-map-pin-glyph { color: #fff; }

/* Gate ring \u2014 outer gold halo, only for required gate quests (CSS marker) */
.voyage-map-pin.gate-required .voyage-map-pin-marker--css {
  box-shadow:
    0 0 0 2px rgba(212, 168, 67, 0.7),
    0 2px 5px rgba(0, 0, 0, 0.55),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18);
}
.voyage-map-pin.gate-required.done .voyage-map-pin-marker--css {
  box-shadow:
    0 0 0 2px rgba(212, 168, 67, 0.85),
    0 0 0 4px rgba(16, 185, 129, 0.35),
    0 2px 6px rgba(16, 185, 129, 0.5);
}

/* State-based styling \u2014 pin-art variant (filter-based; the art itself stays).
   not-started: dim + desaturate. in-progress: cool blue cast. done: warm emerald
   tint via underlying ::after halo. */
.voyage-map-pin.not-started .voyage-map-pin-marker--art {
  opacity: 0.82;
  filter:
    saturate(0.6)
    brightness(0.92)
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}
.voyage-map-pin.in-progress .voyage-map-pin-marker--art {
  filter:
    drop-shadow(0 0 5px rgba(96, 165, 250, 0.7))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}
.voyage-map-pin.done .voyage-map-pin-marker--art {
  filter:
    drop-shadow(0 0 5px rgba(16, 185, 129, 0.7))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}
.voyage-map-pin.gate-required .voyage-map-pin-marker--art {
  filter:
    drop-shadow(0 0 4px rgba(212, 168, 67, 0.75))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}
.voyage-map-pin.gate-required.done .voyage-map-pin-marker--art {
  filter:
    drop-shadow(0 0 5px rgba(212, 168, 67, 0.85))
    drop-shadow(0 0 8px rgba(16, 185, 129, 0.55))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}

/* Checkmark badge — small green dot in upper right */
.voyage-map-pin-check {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--emerald, #10b981);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.6);
  z-index: 2;
  line-height: 1;
}
.voyage-map-pin-check .fas { font-size: 7px; }

/* Counter badge — shows "0/3" etc. for counter-type quests */
.voyage-map-pin-counter {
  position: absolute;
  top: -7px;
  right: -10px;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  background: rgba(14, 165, 233, 0.95);
  padding: 1px 5px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.55);
  z-index: 2;
  white-space: nowrap;
  line-height: 1.2;
}

/* Label — small dark pill beneath the pin marker, hover-revealed by default */
.voyage-map-pin-label {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  line-height: 1.15;
  max-width: 90px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
/* Show labels on hover and for active states (done/in-progress) */
.voyage-map-pin:hover .voyage-map-pin-label,
.voyage-map-pin.done .voyage-map-pin-label,
.voyage-map-pin.in-progress .voyage-map-pin-label {
  opacity: 1;
}
.voyage-map-pin.done .voyage-map-pin-label {
  color: var(--emerald);
}
.voyage-map-pin.in-progress .voyage-map-pin-label {
  color: var(--blue);
}

/* Legend below the map */
.voyage-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--text-dim);
  align-items: center;
}
.voyage-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.voyage-map-legend-icon {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.voyage-map-legend-icon-emoji {
  font-size: 0.95rem;
  line-height: 1;
}
/* Mini-pin for legend — same shape language as the map pins so the legend
   is a true key. White border, slot color background, FA icon inside. */
.voyage-map-legend-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--pin-color, #a78bfa);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.voyage-map-legend-pin .fas {
  font-size: 8px;
  color: rgba(15, 23, 42, 0.85);
}
.voyage-map-legend-hint {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
  opacity: 0.7;
  font-style: italic;
}

.voyage-map-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* ============================================================
   FULLSCREEN MAP MODAL
   Built by openVoyageMapFullscreen(); the shell hosts a second
   renderVoyageMapView() with the :fs map-key suffix. The viewport
   inside expands to fill the available space; the same pan/zoom
   code drives it.
   ============================================================ */
.voyage-map-fs-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}
.voyage-map-fs-modal.open {
  display: flex;
}
body.voyage-map-fs-open {
  overflow: hidden;          /* lock background scroll */
}
.voyage-map-fs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.voyage-map-fs-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  height: 100vh;             /* fallback */
  max-width: 100vw;
  max-height: 100dvh;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.95), rgba(8, 14, 30, 0.98));
  color: var(--text);
}
.voyage-map-fs-titlebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.65);
}
.voyage-map-fs-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.voyage-map-fs-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
}
.voyage-map-fs-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;             /* allow flex children to shrink */
  padding: 10px;
  gap: 8px;
  overflow: hidden;
}
/* The fullscreen variant of the map container fills the body. */
.voyage-map-container--fs {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
  margin-top: 0;
}
/* Fullscreen viewport: drop the 4:3 aspect-ratio cage so we use all the
   space available. The map image still uses object-fit: cover so it fills
   the viewport without distortion. */
.voyage-map-viewport--fs {
  flex: 1 1 auto;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 12px;
}
/* Inside the fullscreen modal: legend is more compact + scrollable so it
   doesn't crowd the map on phone-sized screens. */
.voyage-map-container--fs .voyage-map-legend {
  flex: 0 0 auto;
  font-size: 0.68rem;
  padding: 6px 10px;
  gap: 8px 14px;
}
.voyage-map-container--fs .voyage-map-unmapped {
  flex: 0 0 auto;
  max-height: 20vh;
  overflow-y: auto;
}

/* Rotate-your-device hint when the modal is open in portrait on a narrow
   screen. The map is much more usable in landscape, but we DON'T force it
   \u2014 just suggest. */
@media (max-width: 720px) and (orientation: portrait) {
  .voyage-map-fs-hint::after {
    content: ' \u00B7 Tip: turn your device sideways';
  }
}

/* Unmapped quests — fallback for any quest lacking pin_x/pin_y.
   We never silently hide work, so they render below the map as buttons. */
.voyage-map-unmapped {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed rgba(167, 139, 250, 0.25);
  border-radius: 10px;
}
.voyage-map-unmapped-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.voyage-map-unmapped-count {
  background: rgba(0,0,0,0.3);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 700;
}
.voyage-map-unmapped-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.voyage-map-unmapped-pin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.voyage-map-unmapped-pin:hover {
  background: rgba(124, 58, 237, 0.25);
  border-color: rgba(167, 139, 250, 0.6);
}
.voyage-map-unmapped-icon { font-size: 0.85rem; }

/* Mobile responsive */
@media (max-width: 640px) {
  .voyage-map-viewport {
    aspect-ratio: 4 / 3;
    border-radius: 10px;
  }
  .voyage-map-pin-icon {
    width: 30px;
    height: 30px;
  }
  .voyage-map-pin-label {
    font-size: 0.56rem;
    max-width: 80px;
  }
  .voyage-map-zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  .voyage-map-legend-hint {
    margin-left: 0;
    width: 100%;
  }
  .voyage-view-toggle-btn {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
}

/* ============================================================
   RELICS GALLERY PAGE
   ============================================================ */

.relics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.relics-active-bonuses {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--emerald);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 22px;
}
.relics-active-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.relics-active-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.relics-active-chip {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.relics-active-target {
  font-weight: 600;
  color: #a7f3d0;
  text-transform: capitalize;
  margin-left: 4px;
}

.relics-continent {
  margin-bottom: 26px;
}
.relics-continent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.relics-continent-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
}
.relics-continent-title {
  font-weight: 800;
  flex: 1;
}
.relics-continent-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
}

.relics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.relic-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.relic-card:hover {
  transform: translateY(-2px);
  border-color: var(--purple-400);
}
.relic-card.unearned {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.7;
}
.relic-card.earned {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.15) inset;
}
.relic-card.earned:hover {
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.25);
}
.relic-tier-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.6rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}
.relic-tier-badge.tier-1 { background: rgba(14, 165, 233, 0.2); color: #7dd3fc; }
.relic-tier-badge.tier-2 { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
.relic-tier-badge.tier-3 { background: rgba(245, 158, 11, 0.2); color: var(--gold-light); }
.relic-sprite {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card2);
  border-radius: 8px;
  overflow: hidden;
}
.relic-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.relic-sprite-placeholder {
  font-size: 2rem;
  opacity: 0.5;
}
.relic-sprite-placeholder-lg {
  font-size: 4rem;
  opacity: 0.5;
}
.relic-card-name {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text);
  line-height: 1.2;
}
.relic-card-figure {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.relic-card.unearned .relic-card-name { color: var(--text-dim); }
.relic-card-bonus {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--emerald);
  margin-top: 4px;
}

/* Daruma special render variant — the PNG itself shows the state
   (one eye painted vs both eyes painted). JS swaps the image src
   between asia_daruma_one_eye.png and asia_daruma_both_eyes.png
   based on the user's streak state. */
.relic-card.variant-daruma .relic-sprite {
  position: relative;
}

/* Relic detail modal */
.relic-modal .modal-content { max-width: 540px; }
.relic-modal-sprite {
  width: 100%;
  max-width: 200px;
  height: 200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.relic-modal-sprite.unearned {
  filter: grayscale(1) brightness(0.4);
}
.relic-modal-sprite img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .voyage-continents-strip {
    grid-template-columns: repeat(4, 1fr);
  }
  .voyage-banner-img {
    max-height: 140px;
  }
  .voyage-banner-stats {
    gap: 18px;
  }
  .voyage-stat-value {
    font-size: 1.25rem;
  }
  .voyage-chapter-header {
    flex-direction: column;
  }
  .voyage-tile-name {
    font-size: 0.6rem;
  }
  .voyage-tile-theme {
    display: none;
  }
}
@media (max-width: 480px) {
  .voyage-continents-strip {
    grid-template-columns: repeat(3, 1fr);
  }
  .relics-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* ============================================================
   STORYBOOK INTRO (Phase A3)
   ============================================================ */

/* Hide app chrome while intro is active */
body.intro-active .sidebar-nav,
body.intro-active .top-nav,
body.intro-active .bottom-nav,
body.intro-active .quick-log-fab,
body.intro-active #audio-toggle {
  display: none !important;
}
body.intro-active {
  overflow: hidden;
}
body.intro-active .page,
body.intro-active #page-content {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
}

/* Full-screen overlay */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: #030712;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: intro-fade-in 0.6s ease both;
}
.intro-overlay.intro-fading-out {
  animation: intro-fade-out 0.6s ease both;
  pointer-events: none;
}
@keyframes intro-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes intro-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Skip button */
.intro-skip-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.4s ease;
  opacity: 0.6;
}
.intro-skip-btn:hover {
  opacity: 1;
  background: rgba(124, 58, 237, 0.25);
  color: #f5f3ff;
  border-color: rgba(167, 139, 250, 0.6);
}
.intro-skip-btn i { font-size: 0.7rem; }

/* Stage wrapper — applies to both video and pages */
.intro-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}
.intro-stage.fading {
  opacity: 0;
}

/* ACT I — VIDEO STAGE */
.intro-stage-video {
  background: #000;
}
.intro-video {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  background: #000;
}

/* "Footage pending" placeholder for unavailable clips */
.intro-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0f172a 0%, #030712 80%);
}
.intro-placeholder-inner {
  text-align: center;
  color: #cbd5e1;
  padding: 40px;
  max-width: 480px;
}
.intro-placeholder-clip-num {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #a78bfa;
  margin-bottom: 16px;
}
.intro-placeholder-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #f5f3ff;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}
.intro-placeholder-status {
  font-size: 0.85rem;
  font-style: italic;
  color: #94a3b8;
  margin-bottom: 28px;
}
.intro-placeholder-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 2px solid #1e293b;
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Clip progress bar — thin line at the bottom */
.intro-clip-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(15, 23, 42, 0.4);
  z-index: 5;
}
.intro-clip-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa, #d4a843);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}

/* ACT II — STORYBOOK PAGES STAGE */
.intro-stage-pages {
  background:
    radial-gradient(ellipse at center, #1a1535 0%, #030712 70%);
  padding: 40px 20px;
}

/* The parchment card */
.intro-parchment {
  position: relative;
  width: min(720px, 92vw);
  min-height: min(640px, 80vh);
  max-height: 88vh;
  padding: 60px 50px 80px;
  background:
    radial-gradient(ellipse at top, rgba(245, 222, 179, 0.04) 0%, transparent 60%),
    linear-gradient(180deg, #e8d8b5 0%, #d8c89a 100%);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(140, 100, 60, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 80px rgba(140, 100, 60, 0.15),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  color: #2c1810;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  font-family: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
}
.intro-parchment::before {
  /* Subtle parchment texture overlay (CSS-only) */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  background-image:
    repeating-linear-gradient(45deg, rgba(140, 100, 60, 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(-45deg, rgba(80, 50, 20, 0.02) 0 1px, transparent 1px 6px);
  mix-blend-mode: multiply;
}
.intro-parchment::after {
  /* Edge darkening / aged-paper vignette */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  box-shadow:
    inset 0 0 80px rgba(80, 50, 20, 0.25),
    inset 0 0 200px rgba(60, 30, 10, 0.1);
}

/* Page content + flip animation */
.intro-page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.intro-page-content.flipping {
  opacity: 0;
  transform: translateX(-12px);
}
.intro-page-content.flipping-in {
  opacity: 0;
  transform: translateX(12px);
}

/* Title page */
.intro-page-content.page-title {
  text-align: center;
  align-items: center;
  justify-content: center;
}
.intro-title {
  font-family: 'Cinzel', 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  color: #2c1810;
  margin-bottom: 24px;
  letter-spacing: 0.03em;
  line-height: 1.15;
  animation: intro-text-in 1.2s ease both;
}
.intro-subtitle {
  font-style: italic;
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  color: #4a2f15;
  letter-spacing: 0.02em;
  max-width: 30em;
  margin: 0 auto;
  animation: intro-text-in 1.2s ease 0.4s both;
}
@keyframes intro-text-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Codex-speaks blocks (pages 2-5) */
.intro-codex-block {
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  line-height: 1.7;
  color: #2c1810;
  font-style: italic;
}
.intro-codex-block p {
  margin-bottom: 1.2em;
  animation: intro-text-in 0.8s ease both;
}
.intro-codex-block p:nth-child(1) { animation-delay: 0.1s; }
.intro-codex-block p:nth-child(2) { animation-delay: 0.6s; }
.intro-codex-block p:nth-child(3) { animation-delay: 1.1s; }
.intro-codex-block p:nth-child(4) { animation-delay: 1.6s; }
.intro-codex-final {
  font-weight: 600;
  color: #5c3b1e;
}
.intro-codex-choose {
  text-align: center;
  font-size: clamp(1.3rem, 3.5vw, 1.8rem) !important;
  font-weight: 700;
  font-style: normal !important;
  letter-spacing: 0.08em;
  color: #5c3b1e !important;
  margin-top: 1.5em;
  text-shadow: 0 0 12px rgba(212, 168, 67, 0.4);
}

/* Continent list (page 4) */
.intro-continent-list {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 1em;
}
.intro-continent-list li {
  padding: 4px 0;
  font-style: normal;
  animation: intro-text-in 0.5s ease both;
}
.intro-continent-list li:nth-child(1) { animation-delay: 0.6s; }
.intro-continent-list li:nth-child(2) { animation-delay: 0.9s; }
.intro-continent-list li:nth-child(3) { animation-delay: 1.2s; }
.intro-continent-list li:nth-child(4) { animation-delay: 1.5s; }
.intro-continent-list li:nth-child(5) { animation-delay: 1.8s; }
.intro-continent-list li:nth-child(6) { animation-delay: 2.1s; }
.intro-continent-list li:nth-child(7) { animation-delay: 2.4s; }
.intro-continent-list li strong {
  font-weight: 700;
  color: #5c3b1e;
}

/* Page navigation buttons — manual page turns only (no auto-advance).
   .intro-page-advance is the primary affordance (pulses, on the right).
   .intro-page-back is the secondary affordance (muted, on the left, no pulse). */
.intro-page-advance,
.intro-page-back {
  position: absolute;
  bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(92, 59, 30, 0.1);
  color: #5c3b1e;
  border: 1px solid rgba(92, 59, 30, 0.3);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-style: italic;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s ease, opacity 0.2s ease;
}
.intro-page-advance {
  right: 30px;
  animation: intro-pulse 2.5s ease-in-out infinite;
}
.intro-page-back {
  left: 30px;
  opacity: 0.72;
  /* No pulse on back — primary affordance is forward; back is a quiet option. */
}
.intro-page-advance:hover,
.intro-page-back:hover {
  background: rgba(92, 59, 30, 0.2);
  border-color: rgba(92, 59, 30, 0.5);
  opacity: 1;
  transform: translateY(-1px);
}
.intro-page-advance:active,
.intro-page-back:active {
  transform: translateY(0);
}
@keyframes intro-pulse {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50%      { transform: translateY(-2px); opacity: 1; }
}
.intro-tap-hint {
  font-size: 0.78rem;
}

/* Final-page choice buttons (wax seals) */
.intro-choice-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 32px;
  flex-wrap: wrap;
  animation: intro-text-in 1s ease 2.5s both;
}
.intro-choice-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  background: linear-gradient(180deg, #d8c89a, #a8895e);
  color: #2c1810;
  border: 2px solid #5c3b1e;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(80, 50, 20, 0.3);
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}
.intro-choice-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(80, 50, 20, 0.3);
}
.intro-choice-btn:active {
  transform: translateY(0);
}
.intro-choice-seal {
  font-size: 1.8rem;
  display: block;
}
.intro-choice-label {
  font-size: 0.82rem;
}
.intro-choice-begin {
  background: linear-gradient(180deg, #e8c876, #b8893e);
  border-color: #6a4a1c;
  box-shadow:
    0 4px 16px rgba(212, 168, 67, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(100, 60, 20, 0.4);
}
.intro-choice-begin:hover {
  box-shadow:
    0 8px 24px rgba(232, 200, 118, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(100, 60, 20, 0.4);
}

/* Page progress dots */
.intro-page-dots {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.intro-page-dot {
  /* Now a <button> for direct page jumps. Strip default button chrome and
     mimic the original dot affordance. */
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.3);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.2s ease;
}
.intro-page-dot:hover {
  background: rgba(167, 139, 250, 0.55);
  transform: scale(1.2);
}
.intro-page-dot.past {
  background: rgba(167, 139, 250, 0.45);
}
.intro-page-dot.active {
  background: #d4a843;
  border-color: #e8c876;
  box-shadow: 0 0 10px rgba(212, 168, 67, 0.6);
  transform: scale(1.35);
}
.intro-page-dot.active:hover {
  /* Don't grow further on hover when already active. */
  transform: scale(1.35);
}

/* Mobile responsive */
@media (max-width: 640px) {
  .intro-parchment {
    padding: 40px 24px 60px;
    min-height: 70vh;
  }
  .intro-choice-row {
    gap: 14px;
    flex-direction: column;
    width: 100%;
  }
  .intro-choice-btn {
    width: 100%;
  }
  .intro-skip-btn {
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    font-size: 0.7rem;
  }
  .intro-page-advance {
    bottom: 16px;
    right: 18px;
    padding: 8px 14px;
  }
  .intro-page-back {
    bottom: 16px;
    left: 18px;
    padding: 8px 14px;
  }
}

/* =============================================================
   ADVENTURE MODE — PHASE 1: WALKABLE AVATAR
   =============================================================
   The avatar layer is a SIBLING of .voyage-map-image-layer and
   .voyage-map-pin-layer inside .voyage-map-viewport. Like the pin
   layer it gets translate(panX, panY) but never scales — the avatar
   keeps a constant on-screen size regardless of map zoom. The
   avatar element itself is absolutely positioned in pixels;
   applyVoyageMapTransform recomputes those pixels every frame from
   AVATAR_STATE.pctX / pctY × viewport size × zoom.

   See docs/voyage/ADVENTURE_MODE_ARCHITECTURE.md and
   docs/avatar/AVATAR_PROMPTS.md for the design rationale.
   ============================================================= */

.voyage-map-avatar-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;     /* taps go through to the viewport */
  transform-origin: center; /* same convention as pin-layer */
  z-index: 6;               /* above pins (5) but below zoom controls (10) */
  will-change: transform;
}

.voyage-map-avatar {
  /* Phase 1 sprite is 36×36 CSS px (user requested "smaller"). The avatar's
     PNG anchor convention (per AVATAR_PROMPTS.md) is feet-at-bottom-center,
     so we translate -50% horizontally and -100% vertically — the avatar's
     feet sit exactly on the (pctX, pctY) coordinate. */
  position: absolute;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1;
  /* Soft drop shadow so the avatar reads as a person standing on terrain
     rather than a sticker. Keep this subtle so it never competes with the
     pin glows. */
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
  transition: filter 200ms ease;
}

.voyage-map-avatar img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* Direction-aware horizontal flip. The reference sprite faces slightly
   LEFT by default (per AVATAR_PROMPTS.md), so we only flip when walking
   right. Phase 1 has a static sprite; this is the only "animation"
   feedback the user gets until Tier 3 walk-cycle sheets land. */
.voyage-map-avatar.facing-right img {
  transform: scaleX(-1);
}

/* Subtle walking bob — a tiny vertical sine wobble while moving. Pure CSS
   animation keyed off the .walking class. Suppressed when the variant has
   real walk-cycle frames installed (the frame swap IS the animation —
   stacking the bob on top looks janky). Also disabled for reduced-motion
   users. */
.voyage-map-avatar.walking img {
  animation: voyage-avatar-bob 0.45s ease-in-out infinite;
}
.voyage-map-avatar.has-walk-frames.walking img {
  animation: none;
}
@keyframes voyage-avatar-bob {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -1.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .voyage-map-avatar.walking img { animation: none; }
}

/* Placeholder shown until /static/images/avatar/<variant_id>/base.png is
   commissioned. Lavender square with "?" so we can verify movement before
   art exists. As soon as base.png is dropped in, the renderer prefers
   the image — the placeholder DOM disappears on next render. */
.voyage-map-avatar.placeholder {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border: 2px solid #1a0033;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #1a0033;
  font-size: 0.9rem;
  font-weight: 900;
  font-family: 'Georgia', serif;
  letter-spacing: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}
.voyage-map-avatar.placeholder::before {
  content: "?";
}
.voyage-map-avatar.placeholder img {
  display: none;
}

/* =============================================================
   SKIN-TONE PRESETS (applied to the avatar element, NOT relic
   overlays — relics carry their own colors per AVATAR_PROMPTS.md §5).
   Filter values are starting points from the spec; fine-tune by eye
   once real base.png art exists.
   ============================================================= */
.avatar-skin-pale        { /* filter: none — default */ }
.avatar-skin-light_tan   { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(8deg)  saturate(1.15) brightness(0.95); }
.avatar-skin-medium_tan  { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(12deg) saturate(1.25) brightness(0.85); }
.avatar-skin-olive       { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(18deg) saturate(1.2)  brightness(0.78); }
.avatar-skin-brown       { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(15deg) saturate(1.4)  brightness(0.65); }
.avatar-skin-dark_brown  { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(18deg) saturate(1.5)  brightness(0.5);  }
.avatar-skin-deep_brown  { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45)) hue-rotate(20deg) saturate(1.6)  brightness(0.42); }

/* =============================================================
   D-PAD — on-screen 4-direction walk controls.
   Lives inside .voyage-map-viewport, bottom-center, semi-transparent.
   Hit targets are intentionally generous (48px) for thumb use on
   mobile. Buttons stop pointer events from reaching the tap-walk
   handler (see app.js attachAvatarTapHandler).
   ============================================================= */
.voyage-map-dpad {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
  z-index: 10;
  pointer-events: auto;
  opacity: 0.78;
  transition: opacity 150ms ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;       /* prevent native scroll/zoom on hold */
}
.voyage-map-dpad:hover { opacity: 0.95; }

.voyage-map-dpad-btn {
  appearance: none;
  background: rgba(20, 12, 40, 0.78);
  color: #f3e8ff;
  border: 2px solid rgba(243, 232, 255, 0.5);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Georgia', serif;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 120ms ease, transform 80ms ease;
  -webkit-tap-highlight-color: transparent;
}
.voyage-map-dpad-btn:hover  { background: rgba(40, 24, 70, 0.85); }
.voyage-map-dpad-btn.active,
.voyage-map-dpad-btn:active {
  background: rgba(124, 58, 237, 0.85);
  border-color: #f3e8ff;
  transform: scale(0.94);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6),
              inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.voyage-map-dpad-btn:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}
/* Cross layout: empty corners, ▲ top-center, ◀ mid-left, ▶ mid-right, ▼ bottom-center */
.voyage-map-dpad-btn.dpad-up    { grid-column: 2; grid-row: 1; }
.voyage-map-dpad-btn.dpad-left  { grid-column: 1; grid-row: 2; }
.voyage-map-dpad-btn.dpad-right { grid-column: 3; grid-row: 2; }
.voyage-map-dpad-btn.dpad-down  { grid-column: 2; grid-row: 3; }

/* Slightly smaller on cramped viewports */
@media (max-width: 480px) {
  .voyage-map-dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    bottom: 10px;
  }
}

/* ============================================================================
 * OVERWORLD — screen-grid renderer (Phase 1 Foundation)
 * Loaded for the harness at /screen-grid; future use by the NA voyage map.
 * Design rationale: docs/voyage/OVERWORLD_MAP.md §4.5 + §4.6 + §7.1
 * ========================================================================= */

.ow-root {
  position: relative;
  width: 100%;
  height: calc(100vh - 120px);
  min-height: 480px;
  background: #0a0e14;
  outline: none;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}

/* Viewport scales the 640x480 logical screen to fit available space */
.ow-viewport {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  overflow: hidden;
  background: #000;
}

.ow-screen {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 640px;
  height: 480px;
  transform-origin: center center;
  /* Pixel-art crispness while scaled */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ow-floor {
  position: absolute;
  inset: 0;
  width: 640px;
  height: 480px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ow-object-layer {
  position: absolute;
  inset: 0;
  width: 640px;
  height: 480px;
  pointer-events: none;
}

.ow-obj {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI Symbol', 'Apple Color Emoji', sans-serif;
  line-height: 1;
  border-radius: 3px;
  /* Decorative subtlety controlled inline (lower opacity, no border) */
}
.ow-obj-glyph {
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

/* Pins per OVERWORLD_MAP.md §4.6 — 32x32 px world objects, halo glow, sine float */
.ow-pin {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  --ow-pin-halo: #ffd83f;
  animation: ow-pin-float 1.6s ease-in-out infinite;
}
@keyframes ow-pin-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.ow-pin-halo {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ow-pin-halo) 0%, transparent 65%);
  opacity: 0.7;
  filter: blur(2px);
  animation: ow-pin-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ow-pin-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.95); }
  50%      { opacity: 0.9;  transform: scale(1.05); }
}
.ow-pin-icon {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 18, 30, 0.85);
  border: 2px solid var(--ow-pin-halo);
  border-radius: 8px;
  color: var(--ow-pin-halo);
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Avatar — 32x32, placeholder body in Phase 1 */
.ow-avatar-layer {
  position: absolute;
  inset: 0;
  width: 640px;
  height: 480px;
  pointer-events: none;
}
.ow-avatar {
  position: absolute;
  left: 0; top: 0;
  width: 32px;
  height: 32px;
  transition: none;
  z-index: 10;
}
.ow-avatar-body {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #d4a05f 0%, #c08840 50%, #6f4a22 100%);
  border: 2px solid #2a1a06;
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.5), inset 0 -3px 0 rgba(0,0,0,0.25);
  position: relative;
}
.ow-avatar-body::after {
  /* tiny "face" mark so it's obvious which way the avatar faces (south by default) */
  content: '';
  position: absolute;
  left: 50%;
  top: 30%;
  width: 6px;
  height: 6px;
  background: #2a1a06;
  border-radius: 50%;
  transform: translateX(-50%);
}

/* HUD strip — debug readout for Phase 1 testing */
.ow-hud {
  flex: 0 0 auto;
  background: rgba(8, 12, 20, 0.96);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #c8c8d8;
}
.ow-hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}
.ow-hud-row + .ow-hud-row { margin-top: 6px; }
.ow-hud-row--instructions {
  color: #8a8a9a;
  font-family: system-ui, sans-serif;
  font-size: 12px;
}
.ow-hud-row--instructions b {
  color: #e0d28a;
  font-weight: 600;
}
.ow-hud-label {
  color: #6a6a7a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.ow-hud-val {
  color: #f0e8c0;
  font-weight: 600;
}

/* Virtual joystick — bottom-left, 120px base, analog magnitude per §9 */
.ow-joystick {
  position: absolute;
  left: 20px;
  bottom: 20px;
  width: 120px;
  height: 120px;
  z-index: 50;
  pointer-events: none;  /* base receives pointer events */
}
.ow-joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: auto;
  cursor: pointer;
}
.ow-joystick-base--active {
  background: radial-gradient(circle at center, rgba(255, 220, 120, 0.18), rgba(255, 220, 120, 0.04));
  border-color: rgba(255, 220, 120, 0.45);
}
.ow-joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d4a05f 0%, #8c5a22 100%);
  border: 2px solid #2a1a06;
  box-shadow: 0 3px 0 rgba(0,0,0,0.4), inset 0 -2px 0 rgba(0,0,0,0.3);
  transform: translate(0, 0);
  transition: transform 80ms ease-out;
  pointer-events: none;
}
.ow-joystick-base--active .ow-joystick-stick {
  transition: none;
}

.ow-error {
  padding: 24px;
  color: #ff9b9b;
  background: rgba(60, 20, 20, 0.6);
  border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

@media (max-width: 600px) {
  .ow-joystick {
    left: 12px;
    bottom: 12px;
    width: 110px;
    height: 110px;
  }
  .ow-joystick-stick {
    width: 50px;
    height: 50px;
    margin-left: -25px;
    margin-top: -25px;
  }
}
