:root {
  --app-bg: #f6f5f3;
  --card-bg: #ffffff;
  --primary: #5f259e;
  --primary-dark: #441a71;
  --accent: #f4a261;
  --danger: #e76f51;
  --text-main: #1f2933;
  --text-muted: #9ca3af;
  --shadow-soft: 0 8px 18px rgba(57, 18, 103, 0.16);
}

*, 
*::before, 
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--app-bg);
  color: var(--text-main);
}

.app-shell {
  max-width: 480px;
  height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
  position: relative;
}

/* Top bar */
.top-bar {
  height: 64px;
  background: linear-gradient(135deg, #5f259e, #8a42d1);
  padding-top: env(safe-area-inset-top);
  padding-bottom: 8px;
  box-shadow: 0 4px 12px rgba(52, 16, 96, 0.3);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.profile-initial {
  color: #ffffff;
  font-weight: 600;
  font-size: 18px;
}

.tiny-text {
  font-size: 11px;
}

.wallet-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-btn i {
  color: #ffffff;
  font-size: 18px;
}

/* Content area */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 72px;
}

/* Hero slider */
.hero-section {
  padding-top: 10px;
}

.hero-slider {
  position: relative;
  height: 140px;
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.hero-slide.active {
  opacity: 1;
  transform: translateX(0);
}

.hero-card {
  height: 100%;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.hero-img-card {
  background: #ffffff;
}

.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-title {
  font-size: 17px;
  font-weight: 600;
}

.hero-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
}

.hero-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.hero-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(95, 37, 158, 0.2);
}

.hero-dot.active {
  width: 16px;
  background: rgba(95, 37, 158, 0.9);
}

/* Sections */
.section-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 12px 12px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.referral-card {
  border: 1px solid rgba(95, 37, 158, 0.12);
  background: linear-gradient(135deg, rgba(95, 37, 158, 0.05), rgba(255, 255, 255, 0.9));
}

.referral-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(95, 37, 158, 0.12);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.referral-code-pill {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(95, 37, 158, 0.1);
  color: var(--primary-dark);
}

.referral-link-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.referral-link-group input {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.referral-distribution {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 10px;
  border: 1px dashed rgba(95, 37, 158, 0.2);
}

.distribution-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.distribution-item:first-child {
  border-top: none;
  padding-top: 0;
}

.distribution-item:last-child {
  padding-bottom: 0;
}

.distribution-badge {
  min-width: 64px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(95, 37, 158, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
}

.distribution-info .fw-semibold {
  font-size: 13px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
}

/* Tiles */
.action-tile {
  width: 100%;
  border: none;
  padding: 6px 4px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tile-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(95, 37, 158, 0.25);
}

.tile-icon i {
  display: inline-block;
}

.tile-icon-inner {
  letter-spacing: 0.5px;
}

/* icon color variants */
.bg-icon-1 {
  background: linear-gradient(135deg, #5f259e, #8a42d1);
}

.bg-icon-2 {
  background: linear-gradient(135deg, #5f259e, #2c7a7b);
}

.bg-icon-3 {
  background: linear-gradient(135deg, #f4a261, #e76f51);
}

.bg-icon-4 {
  background: linear-gradient(135deg, #5f259e, #1890ff);
}

.bg-icon-5 {
  background: linear-gradient(135deg, #ffb703, #fb8500);
}

.bg-icon-6 {
  background: linear-gradient(135deg, #e63946, #f3722c);
}

.bg-icon-7 {
  background: linear-gradient(135deg, #8e44ad, #c06c84);
}

.tile-label {
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-main);
}

.small-label {
  font-size: 10px;
}

/* QR result box */
.qr-result {
  min-height: 34px;
  font-size: 11px;
}

/* Footer nav */
.footer-nav {
  height: 60px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 -4px 12px rgba(15, 24, 38, 0.08);
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.footer-btn {
  border: none;
  background: transparent;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  font-size: 10px;
}

.footer-btn.active {
  color: var(--primary);
}

.footer-label {
  margin-top: 2px;
}

/* Footer icons */
.footer-icon {
  font-size: 18px;
}

/* QR button */
.qr-circle {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: linear-gradient(135deg, #5f259e, #8a42d1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(95, 37, 158, 0.45);
  margin-bottom: 18px;
  color: #ffffff;
}

/* History icon */
.history-icon span {
  display: none;
}

/* QR overlay */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.qr-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.qr-overlay-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #0b2530;
  border-radius: 16px 16px 0 0;
  padding: 10px 14px 12px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.qr-overlay-header {
  color: #ffffff;
}

.qr-reader {
  width: 100%;
  height: 260px;
  background: #000000;
  border-radius: 12px;
  overflow: hidden;
}

/* Hide html5-qrcode default borders */
#qrReader > div {
  border-radius: 12px !important;
}

/* utility */
.d-none {
  display: none !important;
}

@media (max-height: 700px) {
  .hero-section {
    display: none;
  }
  .app-content {
    padding-top: 6px;
  }
}