/* Mortal Ascend Telegram Mini App - Ink wash xianxia theme */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #0d0907 0%, #1a0f0a 50%, #2a1810 100%);
  color: #e8d9b8;
  user-select: none;
}
#app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 480px; margin: 0 auto;
}
/* Top bar */
#top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid #3a2418;
  background: rgba(13, 9, 7, 0.95); backdrop-filter: blur(10px);
}
.realm { font-size: 14px; color: #c9a576; }
.realm .muted { color: #6a4f3a; margin: 0 4px; }
#realm-name { font-weight: 600; color: #e8d9b8; }
.currency { font-size: 14px; }
.currency span { font-weight: 600; color: #f5d76e; }

/* Main */
#content {
  flex: 1; overflow-y: auto; padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.tab { display: none; }
.tab.active { display: block; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Cultivate tab */
.qi-display {
  background: radial-gradient(circle at 50% 30%, rgba(245, 215, 110, 0.15), transparent 70%);
  padding: 32px 16px; border-radius: 12px; text-align: center;
  margin-bottom: 20px;
}
.qi-number {
  font-size: 56px; font-weight: 700; color: #f5d76e;
  text-shadow: 0 0 20px rgba(245, 215, 110, 0.4);
  font-variant-numeric: tabular-nums;
}
.qi-rate { font-size: 14px; color: #c9a576; margin: 8px 0 20px; }
.qi-progress {
  height: 6px; background: #2a1810; border-radius: 3px; overflow: hidden;
  margin-bottom: 20px;
}
#qi-bar {
  height: 100%; background: linear-gradient(90deg, #c9a576, #f5d76e);
  width: 0%; transition: width 0.3s ease;
}
.primary-btn {
  background: linear-gradient(135deg, #8b3a1f, #c9572e);
  color: #fff; border: none;
  padding: 14px 32px; border-radius: 8px;
  font-size: 16px; font-weight: 600;
  cursor: pointer; width: 100%;
  box-shadow: 0 4px 12px rgba(139, 58, 31, 0.4);
}
.primary-btn:disabled { background: #3a2418; color: #6a4f3a; box-shadow: none; cursor: not-allowed; }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }

.offline-banner {
  background: linear-gradient(135deg, #2a1810, #3a2418);
  border: 1px solid #c9a576; border-radius: 12px;
  padding: 16px; margin-top: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.offline-banner .amount { font-size: 24px; color: #f5d76e; font-weight: 700; }
.offline-banner button {
  background: #c9a576; color: #1a0f0a; border: none;
  padding: 8px 24px; border-radius: 6px; font-weight: 600; cursor: pointer;
}

/* Immortals tab */
.immortals-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 20px;
}
.immortal-card {
  aspect-ratio: 3/4; border-radius: 8px;
  background: #2a1810; border: 2px solid #3a2418;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 8px; position: relative; overflow: hidden;
  font-size: 12px;
}
.immortal-card.owned { border-color: #c9a576; background: linear-gradient(180deg, transparent, rgba(201, 165, 118, 0.2)); }
.immortal-card.ssr.owned { border-color: #f5d76e; box-shadow: 0 0 12px rgba(245, 215, 110, 0.3); }
.immortal-card .name { font-weight: 600; color: #e8d9b8; }
.immortal-card .stars { color: #f5d76e; font-size: 10px; }
.immortal-card:not(.owned) { opacity: 0.4; filter: grayscale(1); }

h2 { font-size: 18px; color: #f5d76e; margin-bottom: 12px; font-weight: 600; }

/* Shop tab */
.shop-list { display: flex; flex-direction: column; gap: 12px; }
.shop-item {
  background: #2a1810; border: 1px solid #3a2418; border-radius: 12px;
  padding: 16px; display: flex; justify-content: space-between; align-items: center;
}
.shop-item .info { flex: 1; }
.shop-item .info .title { font-size: 15px; color: #e8d9b8; font-weight: 600; }
.shop-item .info .desc { font-size: 12px; color: #c9a576; margin-top: 4px; }
.shop-item .info .first-time { display: inline-block; background: #c9572e; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 10px; margin-top: 6px; }
.shop-item .price-btn {
  background: linear-gradient(135deg, #8b3a1f, #c9572e); color: #fff;
  border: none; padding: 10px 16px; border-radius: 6px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.shop-item .price-btn:active { transform: scale(0.96); }

/* Coming soon */
.coming-soon {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: #c9a576;
}
.coming-soon > div:first-child { font-size: 64px; margin-bottom: 16px; }

/* Bottom tab bar */
#tab-bar {
  display: flex; border-top: 1px solid #3a2418;
  background: rgba(13, 9, 7, 0.95); backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom);
}
#tab-bar button {
  flex: 1; background: none; border: none; color: #6a4f3a;
  padding: 10px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-family: inherit;
}
#tab-bar button.active { color: #f5d76e; }
#tab-bar button > span { font-size: 11px; }
#tab-bar button > :first-child { font-size: 22px; }

/* Toast */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(245, 215, 110, 0.95); color: #1a0f0a;
  padding: 10px 20px; border-radius: 20px;
  font-size: 14px; font-weight: 600; z-index: 9999;
  animation: toastIn 0.3s ease-out;
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
