:root {
  --night: #0D1B2A;
  --night-2: #142A42;
  --saffron: #FF6B35;
  --gold: #FFD700;
  --green: #25D366;
  --danger: #FF5C5C;
  --text: #F4F6F8;
  --text-dim: rgba(244,246,248,0.65);
  --text-faint: rgba(244,246,248,0.4);
  --border: rgba(255,255,255,0.1);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

h1, h2, h3 {
  font-family: 'Bebas Neue', 'Inter', sans-serif;
  letter-spacing: 0.02em;
  margin: 0 0 0.4rem;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: 1.25rem 1.1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--night);
  z-index: 10;
  padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
}

.topbar .logo { font-size: 1.1rem; font-weight: 700; }
.topbar .logo span { color: var(--saffron); }
.topbar .logo b { color: var(--gold); }
.topbar button.icon-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 0.85rem; padding: 6px 10px;
}

.card {
  background: var(--night-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--saffron);
  color: #1a0a00;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
  transition: transform 120ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.green { background: var(--green); color: #06210f; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--text-dim); }
.field input, .field textarea {
  background: var(--night);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--saffron); }

.error-msg { color: var(--danger); font-size: 0.85rem; }
.hint { color: var(--text-faint); font-size: 0.78rem; }

.tabs { display: flex; gap: 8px; }
.tabs button {
  flex: 1; background: var(--night-2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 10px; padding: 0.6rem; font-size: 0.85rem;
}
.tabs button.active { background: rgba(255,107,53,0.15); border-color: var(--saffron); color: var(--saffron); font-weight: 600; }

/* ---- progress ring ---- */
.ring-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--saffron); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset 500ms ease; }
.ring-fg.done { stroke: var(--green); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-center .big { font-size: 1.3rem; font-weight: 700; }
.ring-center .small { font-size: 0.7rem; color: var(--text-dim); }

/* ---- member cards (Head dashboard) ---- */
.member-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.member-card { background: var(--night-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem; }
.member-card .row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--night); background: var(--gold);
  flex-shrink: 0;
}
.member-card .name { font-size: 0.85rem; font-weight: 600; }
.bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: var(--saffron); }
.bar-fill.done { background: var(--green); }
.member-card .meta { font-size: 0.72rem; color: var(--text-faint); }
.status-pill {
  display: inline-block; font-size: 0.68rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: var(--text-dim);
}
.status-pill.done { background: rgba(37,211,102,0.15); color: var(--green); }
.status-pill.pending { background: rgba(255,107,53,0.15); color: var(--saffron); }

/* ---- coin / celebration ---- */
.coin-badge {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,215,0,0.05));
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 12px; padding: 0.7rem 0.9rem;
}
.coin-badge .count { font-size: 1.3rem; font-weight: 700; color: var(--gold); }

.celebrate-overlay {
  position: fixed; inset: 0; background: rgba(13,27,42,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1.5rem;
}
.celebrate-box { text-align: center; max-width: 320px; }
.celebrate-box h2 { font-size: 1.8rem; color: var(--gold); }
.gift-box {
  width: 110px; height: 110px; margin: 1.2rem auto; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; border-radius: 20px;
  background: linear-gradient(135deg, var(--saffron), #c0451c);
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.gold-coin {
  width: 130px; height: 130px; margin: 1rem auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF3B0, var(--gold) 60%, #C9A200 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 700; color: #6b5200;
  box-shadow: 0 0 40px rgba(255,215,0,0.5);
  animation: coin-pop 600ms cubic-bezier(.2,.8,.3,1.4);
}
@keyframes coin-pop { 0% { transform: scale(0) rotate(-20deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

.confetti-piece {
  position: absolute; pointer-events: none; border-radius: 2px;
}

/* ---- discount ladder ---- */
.ladder-row { display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.ladder-row:last-child { border-bottom: none; }
.ladder-row.active { color: var(--gold); font-weight: 700; }
.ladder-row.locked { color: var(--text-faint); }

/* ---- weekly feed ---- */
.post-card { background: var(--night-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; }
.post-card img, .post-card video { width: 100%; border-radius: 10px; margin-top: 8px; }
.post-card .who { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; }
.waiting-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06); border-radius: 999px; padding: 4px 10px; font-size: 0.75rem;
  color: var(--text-dim);
}

.bottom-nav {
  display: flex; border-top: 1px solid var(--border); background: var(--night);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav button {
  flex: 1; background: none; border: none; color: var(--text-faint);
  padding: 0.7rem 0; font-size: 0.68rem; display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.bottom-nav button.active { color: var(--saffron); }
.bottom-nav .nav-icon { font-size: 1.15rem; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--saffron);
  animation: spin 700ms linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-msg { text-align: center; color: var(--text-dim); padding: 2rem 1rem; font-size: 0.9rem; }
