:root {
  --bg: #000000;
  --bg-soft: #0e0f14;
  --card: #14151c;
  --card-2: #1b1d27;
  --text: #ffffff;
  --muted: #8b8f9a;
  --green: #34d27b;
  --p1: #6a5cff;
  --p2: #9b6bff;
  --grad: linear-gradient(135deg, #6a5cff 0%, #b06bff 100%);
  --danger: #e0556a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.green { color: var(--green); }

/* DEMO ribbon */
#demo-ribbon {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9000;
  background: repeating-linear-gradient(45deg, #2a221a, #2a221a 12px, #332a1f 12px, #332a1f 24px);
  color: #ffcf8a;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 5px 10px;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,207,138,.25);
}

.screen {
  position: fixed;
  inset: 0;
  padding-top: 26px; /* room for ribbon */
}

/* Buttons */
.btn {
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 22px;
  color: #fff;
  cursor: pointer;
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); }
.btn-ghost { background: #1f2027; color: #d7d9e0; }
.btn-block { width: 100%; display: block; }
.glow { box-shadow: 0 0 30px rgba(123, 92, 255, .55); }

.link-muted {
  background: none; border: none; color: var(--muted);
  font-size: 14px; padding: 12px; cursor: pointer; width: 100%;
}

/* ---------------- Onboarding ---------------- */
#onboarding { display: flex; flex-direction: column; }
.dots {
  display: flex; justify-content: center; gap: 8px;
  padding: 14px 0 6px;
}
.dots .dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: #2b2d39; transition: all .25s;
}
.dots .dot.active { width: 26px; background: var(--p1); }

.slides { flex: 1; position: relative; overflow: hidden; }
.slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 34px;
  opacity: 0; transform: translateX(40px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.slide.active { opacity: 1; transform: translateX(0); pointer-events: auto; }
.slide .big-emoji { font-size: 78px; margin-bottom: 26px; }
.slide h1 { font-size: 28px; margin: 0 0 14px; }
.slide p { color: var(--muted); font-size: 16px; line-height: 1.5; margin: 0; }

.onboarding-footer { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); }
.onboarding-buttons { display: flex; gap: 12px; }
.onboarding-buttons .btn-ghost { flex: 0 0 110px; }
.onboarding-buttons .btn-primary { flex: 1; }

/* ---------------- Activation ---------------- */
#activation { display: flex; align-items: center; justify-content: center; }
.activation-inner { text-align: center; padding: 0 26px; width: 100%; max-width: 460px; }
.big-emoji { font-size: 80px; }
.activation-inner h1 { font-size: 28px; margin: 18px 0 10px; }
.bonus-card {
  background: linear-gradient(135deg, rgba(106,92,255,.18), rgba(176,107,255,.12));
  border: 1px solid rgba(123,92,255,.35);
  border-radius: 18px; padding: 18px; margin: 26px 0 22px;
}
.bonus-label { color: #cfd0da; font-size: 14px; margin-bottom: 8px; }
.bonus-value { color: #ff9d52; font-size: 30px; font-weight: 800; }

/* ---------------- Balance pill ---------------- */
.balance-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(20,21,28,.85);
  border: 1px solid #2a2c38;
  padding: 9px 16px; border-radius: 99px;
  font-size: 17px; font-weight: 800;
  backdrop-filter: blur(8px);
}
.balance-pill .coin { color: #f5b942; }
.balance-pill.solo { margin-bottom: 18px; }

/* ---------------- Main app ---------------- */
#app { padding-top: 0; }
.tab-page { position: absolute; inset: 26px 0 0; }
.page-scroll {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
}
.page-title { font-size: 30px; margin: 4px 0 4px; }

/* ---------------- Reels ---------------- */
#page-reels { background: #000; }
.reels-topbar {
  position: absolute; top: 12px; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 14px;
  pointer-events: none;
}
.reels-topbar .balance-pill { pointer-events: auto; border-color: #34d27b55; box-shadow: 0 0 0 1px #34d27b33; }

.watch-ring { position: relative; width: 44px; height: 44px; }
.watch-ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.watch-ring circle { fill: none; stroke-width: 3.5; }
.ring-bg { stroke: rgba(255,255,255,.18); }
.ring-fg { stroke: #fff; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear; }
.watch-ring.done .ring-fg { stroke: var(--green); }
.ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.watch-ring.done .ring-num { font-size: 16px; color: var(--green); }

.reels-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.reels-feed { height: 100%; transition: transform .35s cubic-bezier(.22,.61,.36,1); }
.reel {
  height: 100%; width: 100%;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.reel video {
  width: 100%; height: 100%; object-fit: cover;
  background: #000;
}
.reel .placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px;
}
.reel .placeholder .ph-emoji { font-size: 60px; margin-bottom: 14px; }
.reel .placeholder .ph-title { font-size: 22px; font-weight: 800; }
.reel .placeholder .ph-sub { color: rgba(255,255,255,.7); margin-top: 8px; }
.reel .handle {
  position: absolute; left: 14px; bottom: 14px; z-index: 5;
  font-size: 14px; color: rgba(255,255,255,.85);
}
.reel .sound-btn {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  width: 38px; height: 38px; border-radius: 99px;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 16px;
}

.swipe-hint {
  position: absolute; left: 0; right: 0; bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 25; text-align: center; color: rgba(255,255,255,.85);
  pointer-events: none;
}
.swipe-hint .chev { font-size: 22px; animation: bob 1.4s infinite; }
.swipe-hint > div:last-child {
  display: inline-block; background: rgba(0,0,0,.45);
  border-radius: 12px; padding: 8px 16px; font-size: 13px;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Reward animation */
.reward-overlay {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.reward-ripple {
  position: absolute; width: 80px; height: 80px; border-radius: 99px;
  border: 2px solid var(--green);
  animation: ripple 1.1s ease-out forwards;
}
.reward-bag { font-size: 56px; animation: pop .5s ease forwards; }
.reward-amount {
  font-size: 44px; font-weight: 900; color: var(--green);
  text-shadow: 0 0 24px rgba(52,210,123,.6);
  animation: pop .5s ease forwards;
}
.reward-text { color: #cfeede; letter-spacing: 3px; font-weight: 700; margin-top: 4px; animation: pop .5s ease forwards; }
@keyframes ripple { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(5); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ---------------- Friends ---------------- */
.two-cards { display: flex; gap: 12px; margin-top: 14px; }
.info-card, .stat-card {
  flex: 1; background: var(--card); border: 1px solid #20222c;
  border-radius: 16px; padding: 16px;
}
.info-card .ic-emoji { font-size: 22px; }
.info-card .ic-label { color: var(--muted); font-size: 13px; margin: 8px 0 6px; }
.info-card .ic-value { font-size: 18px; font-weight: 800; }
.stat-card { text-align: center; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.goal-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 22px 0 8px; }
.progress { height: 6px; background: #1c1e27; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--grad); transition: width .4s; }

.link-label { color: var(--muted); font-size: 13px; margin: 22px 0 8px; }
.link-row { display: flex; gap: 8px; }
.link-row input {
  flex: 1; background: var(--card); border: 1px solid #20222c; color: #c9ccd6;
  border-radius: 12px; padding: 14px; font-size: 13px; min-width: 0;
}
.copy-btn { width: 50px; background: var(--card-2); border: 1px solid #2a2c38; color: #fff; border-radius: 12px; font-size: 18px; }
#invite-btn { margin-top: 16px; }

/* ---------------- Tasks ---------------- */
.task-card { background: var(--card); border: 1px solid #20222c; border-radius: 18px; padding: 16px; margin-top: 14px; }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; }
.task-emoji { font-size: 22px; }
.task-reward { color: var(--green); background: rgba(52,210,123,.12); border-radius: 99px; padding: 5px 12px; font-weight: 800; font-size: 14px; }
.task-title { font-size: 17px; font-weight: 800; margin: 12px 0 4px; }
.task-desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.task-actions { display: flex; gap: 10px; }
.task-actions .t-primary { flex: 1; background: #2f6df6; color: #fff; border: none; border-radius: 12px; padding: 12px; font-weight: 700; }
.task-actions .t-secondary { flex: 1; background: #1f2129; color: #d7d9e0; border: none; border-radius: 12px; padding: 12px; font-weight: 700; }
.task-card.done { opacity: .6; }
.task-done-badge { color: var(--green); font-weight: 800; text-align: center; padding: 10px; }

/* ---------------- Withdraw ---------------- */
.warn-banner {
  background: rgba(224,85,106,.12); border: 1px solid rgba(224,85,106,.4);
  color: #ff9aa8; border-radius: 14px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
}
.balance-box {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(106,92,255,.18), rgba(176,107,255,.10));
  border: 1px solid rgba(123,92,255,.3);
  border-radius: 16px; padding: 18px; margin-bottom: 18px;
}
.balance-box span:first-child { color: var(--muted); }
.balance-box-value { font-size: 22px; font-weight: 800; }
.field-label { display: block; color: var(--muted); font-size: 14px; margin: 14px 0 8px; }
.field, .select-field {
  width: 100%; background: var(--card); border: 1px solid #20222c; color: #fff;
  border-radius: 14px; padding: 16px; font-size: 16px;
}
.select-field { border-color: rgba(123,92,255,.4); }
.warn-min { color: #ff9aa8; background: rgba(224,85,106,.10); border: 1px solid rgba(224,85,106,.35); border-radius: 12px; padding: 12px; font-size: 13px; margin: 16px 0; }
#withdraw-btn { margin-top: 4px; }

/* ---------------- Bottom nav ---------------- */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: rgba(8,9,12,.92);
  border-top: 1px solid #18191f;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px);
}
.nav-item {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; flex: 1; cursor: pointer;
}
.nav-item .nav-ic { font-size: 18px; }
.nav-item.active { color: #fff; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: #1c1e27; border: 1px solid #2a2c38; color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 14px; z-index: 9999;
  max-width: 86%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
