/* ============================================================
   MDuck Live Rewards — v2.0 mobile-first design system
   ============================================================ */

:root {
  /* Brand */
  --brand-purple: #7b5cff;
  --brand-cyan: #44e2ff;
  --brand-pink: #ff4fb8;
  --brand-gold: #ffc24a;

  /* Surface */
  --bg-0: #07080d;
  --bg-1: #0d1018;
  --bg-2: #131826;
  --bg-3: #1a2030;
  --bg-elev: rgba(20, 24, 38, 0.85);
  --stroke: rgba(255,255,255,0.08);
  --stroke-2: rgba(255,255,255,0.16);

  /* Text */
  --text-1: #ffffff;
  --text-2: #c5cce0;
  --text-3: #7c87a3;
  --text-muted: #5a6586;

  /* States */
  --success: #46d39a;
  --warn: #ffb24f;
  --danger: #ff5d6c;
  --info: #44e2ff;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", monospace;

  /* Spacing scale (4-pt) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-card: 0 18px 40px rgba(0,0,0,0.4);
  --shadow-glow-purple: 0 0 24px rgba(123, 92, 255, 0.4);

  /* Layout */
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.45;
  font-size: 15px;
  min-height: 100dvh;
  /* Reserve space for bottom nav */
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
}
body.no-bottom-nav { padding-bottom: 0; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { padding-left: 18px; }
input, select, textarea {
  font: inherit;
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-cyan);
}

/* Background atmosphere */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 600px at 8% -8%, rgba(123,92,255,0.12), transparent 60%),
    radial-gradient(900px 700px at 110% 0%, rgba(68,226,255,0.10), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(255,79,184,0.08), transparent 60%);
  z-index: -1;
  pointer-events: none;
}

/* ============================================================
   Layout primitives
   ============================================================ */
.app {
  width: 100%;
  max-width: 480px;       /* mobile-first; widens via media queries */
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
}
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.tiny { font-size: 12px; color: var(--text-3); letter-spacing: 0.04em; }

/* ============================================================
   Top bar (per page)
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(7,8,13,0.96), rgba(7,8,13,0.78));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.topbar .logo {
  /* PNG 1772×1772: conteúdo em y=496–1091 (28% top / 38% bottom vazio).
     Renderiza a 113px para conteúdo aparecer ~38px (= altura dos icon-btn).
     Margens negativas removem o espaço vazio do layout sem cortar visualmente. */
  height: 113px;
  width: auto;
  margin-top: -32px;
  margin-bottom: -43px;
  filter: drop-shadow(0 4px 14px rgba(123,92,255,0.35));
}
@media (min-width: 720px) {
  .topbar .logo { height: 134px; margin-top: -38px; margin-bottom: -51px; }
}
.topbar .title {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar-right { display: flex; gap: var(--sp-2); align-items: center; }
.topbar .icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--stroke);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.topbar .icon-btn:active { background: var(--bg-3); }
.topbar .icon-btn svg { width: 20px; height: 20px; display: block; }
.topbar .icon-btn .dot {
  position: absolute;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-pink);
  top: 6px; right: 6px;
}

/* ============================================================
   Page title with SVG icon
   ============================================================ */
.page-title { display: flex; align-items: center; gap: 10px; }
.page-title svg { width: 28px; height: 28px; flex-shrink: 0; color: var(--brand-purple); }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-card);
}
.card.callout {
  background: linear-gradient(135deg, rgba(123,92,255,0.18), rgba(68,226,255,0.10));
  border-color: rgba(123,92,255,0.35);
}
.card-title {
  font-size: 18px; font-weight: 700;
  margin: 0 0 4px; letter-spacing: -0.01em;
}
.card-sub { color: var(--text-3); font-size: 13px; margin: 0; }
.card-section { margin-top: var(--sp-5); }

/* ============================================================
   Hero (avatar + nick + chips) — Início
   ============================================================ */
.hero {
  background:
    radial-gradient(180% 140% at 100% 0%, rgba(170,68,255,0.30), transparent 60%),
    radial-gradient(160% 120% at 0% 100%, rgba(68,226,255,0.20), transparent 60%),
    var(--bg-elev);
  border: 1px solid rgba(123,92,255,0.28);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--sp-4);
  align-items: center;
}
.hero-avatar-wrap {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-cyan), var(--brand-purple) 60%, var(--brand-pink));
  padding: 3px;
  box-shadow: var(--shadow-glow-purple);
}
.hero-avatar {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px;
  background-size: cover;
  background-position: center;
  border: 3px solid var(--bg-1);
}
.hero-team-tag {
  position: absolute;
  bottom: -8px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-pink));
  color: white;
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  padding: 3px 10px; border-radius: var(--r-pill);
  text-transform: uppercase;
  white-space: nowrap;
}
.hero-name {
  font-size: 22px; font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.hero-handle { color: var(--text-3); font-size: 13px; margin: 0 0 var(--sp-2); }
.hero-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.hero-position-row {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--stroke-2);
  font-size: 13px; color: var(--text-2);
}
.hero-position-row strong { color: var(--text-1); }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.cyan { color: var(--brand-cyan); border-color: rgba(68,226,255,0.35); background: rgba(68,226,255,0.08); }
.chip.purple { color: #c4b5fd; border-color: rgba(123,92,255,0.4); background: rgba(123,92,255,0.10); }
.chip.gold { color: var(--brand-gold); border-color: rgba(255,194,74,0.4); background: rgba(255,194,74,0.10); }
.chip.green { color: var(--success); border-color: rgba(70,211,154,0.4); background: rgba(70,211,154,0.10); }
.chip.warn { color: var(--warn); border-color: rgba(255,178,79,0.4); background: rgba(255,178,79,0.10); }
.chip.danger { color: var(--danger); border-color: rgba(255,93,108,0.4); background: rgba(255,93,108,0.10); }

/* Stat row 3 cols (Diamantes / Dias válidos / Duração LIVE) */
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  text-align: center;
}
.stat-card .stat-icon { font-size: 18px; opacity: 0.85; }
.stat-card .stat-value {
  font-size: 18px; font-weight: 800;
  margin-top: 4px; letter-spacing: -0.02em;
}
.stat-card .stat-label {
  font-size: 11px; color: var(--text-3);
  margin-top: 2px; letter-spacing: 0.04em;
}

/* ============================================================
   Categoria do streamer (BATALHA / GAMER / etc.)
   ============================================================ */
.category-card {
  position: relative;
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  background: linear-gradient(135deg, rgba(170,68,255,0.20), rgba(255,79,184,0.12));
  border: 1px solid rgba(170,68,255,0.35);
  overflow: hidden;
}
.category-card .cat-label {
  font-size: 11px; color: var(--text-3); letter-spacing: 0.18em; text-transform: uppercase;
}
.category-card .cat-title {
  font-size: 26px; font-weight: 900; letter-spacing: -0.02em;
  margin: 4px 0 4px;
}
.category-card .cat-sub { font-size: 13px; color: var(--text-2); }
.category-card .cat-icon {
  position: absolute; top: 50%; right: var(--sp-4); transform: translateY(-50%);
  font-size: 40px; opacity: 0.6;
}

/* ============================================================
   Progresso até 80K + trilha de níveis
   ============================================================ */
.progress-card .progress-label-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.progress-card .progress-value {
  font-size: 20px; font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}
.progress-bar {
  height: 10px; border-radius: var(--r-pill);
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.progress-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-purple), var(--brand-pink));
  border-radius: var(--r-pill);
  transition: width 0.6s ease;
}

.level-track {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-top: var(--sp-4);
  padding: 0 4px;
}
.level-step { text-align: center; }
.level-step .level-mark {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--stroke-2);
  background: var(--bg-1);
  color: var(--text-3);
  font-size: 11px;
  margin-bottom: 4px;
}
.level-step.done .level-mark {
  background: linear-gradient(135deg, var(--success), #1f9c6b);
  border-color: rgba(70,211,154,0.6);
  color: white;
}
.level-step.current .level-mark {
  background: linear-gradient(135deg, var(--brand-gold), #d68f1d);
  border-color: rgba(255,194,74,0.7);
  color: #1a0e00;
  box-shadow: 0 0 16px rgba(255,194,74,0.6);
}
.level-step.locked .level-mark { opacity: 0.4; }
.level-step .level-amount { font-size: 9px; color: var(--text-3); display: block; }
.level-step .level-label { font-size: 9px; color: var(--text-3); display: block; }

/* Section-head: shared header pattern for cards (title + tag/action) */
.section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3);
}
.section-head > div { min-width: 0; flex: 1; }
.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em;
}
.section-head p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }

/* ============================================================
   Progress bars (used inside mission cards rendered by main.js)
   ============================================================ */
.progress-row { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.progress-row .progress-row-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 12px; color: var(--text-2);
  gap: 8px;
}
.progress-row .progress-row-head strong { color: var(--text-1); font-weight: 700; }

.progress {
  height: 10px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-purple), var(--brand-pink));
  border-radius: var(--r-pill);
  transition: width 0.6s ease;
}
.progress.slim { height: 6px; }

/* Period / scope chip used in mission cards */
.mission-period {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  color: var(--text-2);
}
.mission-description {
  font-size: 13px; color: var(--text-2); line-height: 1.5;
  margin: 4px 0 0;
  white-space: pre-wrap;
}
.mission-complete-tag {
  background: rgba(70,211,154,0.14);
  color: var(--success);
  border-color: rgba(70,211,154,0.4);
}

/* ============================================================
   Mission card
   ============================================================ */
.mission-card {
  background: var(--bg-elev);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: grid;
  gap: var(--sp-3);
}
.mission-card.completed {
  border-color: rgba(70,211,154,0.4);
  background: linear-gradient(180deg, rgba(70,211,154,0.06), var(--bg-elev));
}
.mission-card-head {
  display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between;
}
.mission-card-title {
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em;
  margin: 0;
}
.mission-card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.mission-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.mission-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.mission-progress-line {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2);
}
.mission-progress-line strong { color: var(--text-1); }
.mission-progress { height: 6px; }
.mission-rewards-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.mission-rewards-list li { margin: 2px 0; }
.mission-locked-overlay {
  position: relative;
}
.mission-locked-overlay::after {
  content: "🔒";
  position: absolute;
  top: 12px; right: 12px;
  font-size: 18px;
}

/* ============================================================
   Bottom navigation
   ============================================================ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(7,8,13,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--stroke);
  padding: 6px var(--sp-2) calc(6px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 0 4px;
  color: var(--text-3);
  font-size: 10px; font-weight: 600;
  border-radius: var(--r-md);
  letter-spacing: 0.02em;
  position: relative;
}
.bottom-nav a .ic {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  margin-bottom: 3px;
  color: var(--text-3);
  opacity: 0.6;
  transition: color 0.15s, opacity 0.15s, transform 0.15s;
}
.bottom-nav a .ic svg { width: 24px; height: 24px; display: block; }
.bottom-nav a.active {
  color: var(--text-1);
}
.bottom-nav a.active .ic {
  color: var(--brand-purple);
  opacity: 1;
  transform: translateY(-2px);
}
.bottom-nav a.active::before {
  content: "";
  position: absolute;
  top: 0; left: 30%; right: 30%;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-pink));
  border-radius: 0 0 4px 4px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 700;
  border: 1px solid transparent;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-purple));
  color: white;
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.btn-secondary {
  background: var(--bg-2);
  border: 1px solid var(--stroke-2);
  color: var(--text-1);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ============================================================
   Helpers / version badge
   ============================================================ */
.version-badge {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
  right: 12px;
  font-size: 10px;
  color: rgba(125,211,252,0.7);
  background: rgba(14,165,233,0.10);
  border: 1px solid rgba(125,211,252,0.25);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  pointer-events: none;
  z-index: 99;
  letter-spacing: 0.4px;
  font-family: var(--font-mono);
}

.report-bug-btn {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 36px);
  right: 12px;
  font-size: 12px;
  background: rgba(255,93,108,0.12);
  border: 1px solid rgba(255,93,108,0.35);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  z-index: 98;
  font-weight: 600;
}

/* Tag */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  font-size: 11px; font-weight: 700;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  color: var(--text-2);
  letter-spacing: 0.04em;
}
.tag.cyan { background: rgba(68,226,255,0.10); color: var(--brand-cyan); border-color: rgba(68,226,255,0.4); }
.tag.purple { background: rgba(123,92,255,0.12); color: #c4b5fd; border-color: rgba(123,92,255,0.4); }
.tag.gold { background: rgba(255,194,74,0.12); color: var(--brand-gold); border-color: rgba(255,194,74,0.4); }
.tag.green { background: rgba(70,211,154,0.12); color: var(--success); border-color: rgba(70,211,154,0.4); }
.tag.warn { background: rgba(255,178,79,0.12); color: var(--warn); border-color: rgba(255,178,79,0.4); }
.tag.danger { background: rgba(255,93,108,0.12); color: var(--danger); border-color: rgba(255,93,108,0.4); }
.tag.success { background: rgba(70,211,154,0.12); color: var(--success); border-color: rgba(70,211,154,0.4); }

/* Section heading */
.section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: var(--sp-5) var(--sp-1) var(--sp-2);
}
.section-heading h2 {
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em;
  margin: 0;
}
.section-heading .see-all { font-size: 12px; color: var(--brand-cyan); font-weight: 600; }

/* Menu list — used by Mais (more) tab and similar */
.menu-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-elev);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  color: var(--text-1);
  text-decoration: none;
  position: relative;
}
.menu-item:active { background: var(--bg-3); }
.menu-item .menu-ic {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(123,92,255,0.20), rgba(68,226,255,0.10));
  border: 1px solid var(--stroke-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.menu-item .menu-text { flex: 1; min-width: 0; }
.menu-item .menu-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.menu-item .menu-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.menu-item .menu-arrow { color: var(--text-3); font-size: 18px; }
.menu-item.danger { border-color: rgba(255,93,108,0.35); }
.menu-item.danger .menu-ic { background: rgba(255,93,108,0.12); border-color: rgba(255,93,108,0.4); color: var(--danger); }
.menu-item.danger .menu-title { color: var(--danger); }

/* Empty state */
.empty {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-3);
  border: 1px dashed var(--stroke-2);
  border-radius: var(--r-lg);
}

/* ============================================================
   Responsive (tablet+)
   ============================================================ */
@media (min-width: 720px) {
  .app { max-width: 720px; padding: var(--sp-5) var(--sp-5) var(--sp-3); }
  body { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px); }
  .hero { grid-template-columns: 120px 1fr; }
  .hero-avatar-wrap { width: 120px; height: 120px; }
  .hero-name { font-size: 26px; }
}
@media (min-width: 1024px) {
  .app { max-width: 960px; }
}
