*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sage:       #4a7c6b;
  --sage-light: #7aac98;
  --sage-pale:  #d4ece4;
  --sand:       #c4a96e;
  --sand-light: #f5e8cc;
  --sand-pale:  #fdf6eb;
  --ivory:      #faf8f3;
  --cream:      #f0ece2;
  --ink:        #1e2a26;
  --ink-soft:   #3d4f47;
  --ink-muted:  #7a8c85;
  --border:     rgba(74,124,107,0.18);
  --border-sand:rgba(196,169,110,0.3);
  --radius:     14px;
  --radius-lg:  22px;
  --shadow:     0 4px 28px rgba(30,42,38,0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--ivory);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Background ornaments ── */
body::before {
  content: '';
  position: fixed;
  top: -120px; right: -120px;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,236,228,0.55) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  bottom: -80px; left: -80px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,232,204,0.5) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

.page-wrap { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 2.5rem 1.25rem 5rem; }

/* ── Header ── */
.header { text-align: center; margin-bottom: 3rem; }
.header-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sage-pale), var(--sand-light));
  margin-bottom: 1rem; font-size: 26px;
}
.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 0.4rem;
}
.header p { font-size: 0.95rem; color: var(--ink-muted); font-weight: 300; letter-spacing: 0.01em; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  transition: box-shadow 0.25s;
}
.card:hover { box-shadow: 0 6px 36px rgba(30,42,38,0.12); }

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem; font-weight: 500;
  color: var(--ink); margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 10px;
}
.card-title-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--sage-pale); display: flex;
  align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0;
}

/* ── Counter hero ── */
.counter-hero {
  background: linear-gradient(145deg, var(--sage) 0%, #2f5c4d 100%);
  border: none; color: #fff; text-align: center;
  padding: 2.5rem 1.75rem;
}
.counter-hero .card-title { color: rgba(255,255,255,0.75); justify-content: center; margin-bottom: 1.5rem; }
.counter-hero .card-title-icon { background: rgba(255,255,255,0.15); }

.counter-display { display: flex; align-items: baseline; justify-content: center; gap: 0.4rem; margin-bottom: 0.4rem; }
.counter-num {
  font-family: 'Playfair Display', serif;
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 700; line-height: 1;
  color: #fff;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
}
.counter-num.bump { transform: scale(1.18); }
.counter-label { font-size: 0.9rem; color: rgba(255,255,255,0.65); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 2rem; }

.progress-bar-wrap { background: rgba(255,255,255,0.18); border-radius: 100px; height: 8px; overflow: hidden; max-width: 340px; margin: 0 auto 2rem; }
.progress-bar-fill {
  height: 100%; background: var(--sand);
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.counter-meta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.counter-stat {
  background: rgba(255,255,255,0.12);
  border-radius: 10px; padding: 0.6rem 1.1rem; text-align: center;
}
.counter-stat-num { font-size: 1.3rem; font-weight: 500; color: #fff; }
.counter-stat-lbl { font-size: 0.72rem; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Log button ── */
.log-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--sand); color: var(--ink);
  border: none; border-radius: 100px;
  padding: 0.85rem 2rem; font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem; font-weight: 500; cursor: pointer;
  margin-top: 1.5rem;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  box-shadow: 0 2px 14px rgba(196,169,110,0.35);
}
.log-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(196,169,110,0.5); }
.log-btn:active { transform: scale(0.97); }
.log-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Reason selector ── */
.reason-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.reason-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0.9rem 0.6rem; border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--ivory); cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem;
  font-weight: 400; color: var(--ink-muted);
  transition: all 0.2s; text-align: center; line-height: 1.3;
}
.reason-btn .reason-emoji { font-size: 1.5rem; }
.reason-btn:hover { border-color: var(--sage-light); color: var(--sage); background: var(--sage-pale); }
.reason-btn.active {
  border-color: var(--sage); background: var(--sage-pale);
  color: var(--sage); font-weight: 500;
  box-shadow: 0 2px 12px rgba(74,124,107,0.18);
}

.reason-other-wrap { margin-top: 12px; display: none; }
.reason-other-wrap.show { display: block; }
.reason-other-input {
  width: 100%; padding: 0.65rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--ivory);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  color: var(--ink); outline: none;
  transition: border-color 0.2s;
}
.reason-other-input:focus { border-color: var(--sage); }

/* ── Year / Ramadan selector ── */
.cal-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap;
}
.cal-nav-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--ivory);
  cursor: pointer; font-size: 15px; color: var(--ink-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.cal-nav-btn:hover { border-color: var(--sage); color: var(--sage); background: var(--sage-pale); }
.cal-title { font-family: 'Playfair Display', serif; font-size: 1rem; font-weight: 500; }

/* Year selector */
.year-select {
  padding: 0.45rem 0.85rem; border-radius: 100px;
  border: 1px solid var(--border-sand); background: var(--sand-pale);
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
  color: var(--ink); cursor: pointer; outline: none;
  transition: border-color 0.2s;
}
.year-select:focus { border-color: var(--sand); }

/* ── Calendar ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow {
  text-align: center; font-size: 0.7rem; font-weight: 500;
  color: var(--ink-muted); text-transform: uppercase;
  letter-spacing: 0.06em; padding: 4px 0 8px;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 10px; font-size: 0.82rem; font-weight: 400;
  cursor: pointer; border: 1.5px solid transparent;
  transition: all 0.18s; position: relative;
  color: var(--ink-soft); background: var(--ivory);
}
.cal-day:hover { border-color: var(--sage-light); background: var(--sage-pale); color: var(--sage); }
.cal-day.missed {
  background: linear-gradient(135deg, #fde8e4, #fcc8bc);
  border-color: #e88c78; color: #a03824; font-weight: 500;
}
.cal-day.missed:hover { background: linear-gradient(135deg, #f5c9c0, #f0a898); }
.cal-day.made-up {
  background: var(--sage-pale);
  border-color: var(--sage-light); color: var(--sage); font-weight: 500;
}
.cal-day.made-up::after {
  content: '✓'; position: absolute; top: 1px; right: 3px;
  font-size: 9px; color: var(--sage);
}
.cal-day.outside { opacity: 0.2; pointer-events: none; }
.cal-day.today { border-color: var(--sand) !important; }

/* Day tooltip label */
.cal-day-num { font-size: 0.82rem; line-height: 1; }

.cal-legend { display: flex; gap: 1.25rem; margin-top: 1rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--ink-muted); }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.legend-dot.missed { background: #f5c9c0; border: 1px solid #e88c78; }
.legend-dot.made-up { background: var(--sage-pale); border: 1px solid var(--sage-light); }
.legend-dot.regular { background: var(--ivory); border: 1.5px solid var(--border); }

/* ── Make-up calendar ── */
.makeup-cal-wrap .cal-day { cursor: pointer; }
.makeup-cal-wrap .cal-day.fasted-today {
  background: var(--sage-pale); border-color: var(--sage); color: var(--sage); font-weight: 500;
}
.makeup-cal-wrap .cal-day.fasted-today::after {
  content: '✓'; position: absolute; top: 1px; right: 3px;
  font-size: 9px; color: var(--sage);
}

/* ── Save button ── */
.save-btn {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--sage); color: #fff;
  border: none; border-radius: 100px;
  padding: 0.8rem 1.8rem; font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  margin-top: 1.25rem;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 2px 14px rgba(74,124,107,0.3);
}
.save-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(74,124,107,0.4); }
.save-btn:active { transform: scale(0.97); }

/* ── Toast ── */
.toast-wrap {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(120px);
  z-index: 9999; transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}
.toast-wrap.show { transform: translateX(-50%) translateY(0); }
.toast {
  background: var(--ink); color: #fff;
  padding: 0.75rem 1.5rem; border-radius: 100px;
  font-size: 0.88rem; white-space: nowrap;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
.toast.success { background: var(--sage); }

/* ── Celebration overlay ── */
.celebrate-overlay {
  position: fixed; inset: 0; background: rgba(30,42,38,0.7);
  z-index: 10000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.4s;
}
.celebrate-overlay.show { opacity: 1; pointer-events: all; }
.celebrate-box {
  background: #fff; border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; text-align: center; max-width: 360px; width: 90%;
  box-shadow: 0 20px 60px rgba(30,42,38,0.3);
  transform: scale(0.8); transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.celebrate-overlay.show .celebrate-box { transform: scale(1); }
.celebrate-box h2 { font-family: 'Playfair Display', serif; font-size: 1.7rem; margin: 0.75rem 0 0.5rem; color: var(--ink); }
.celebrate-box p { font-size: 0.9rem; color: var(--ink-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.celebrate-big { font-size: 3.5rem; display: block; margin-bottom: 0.25rem; }
.celebrate-close {
  background: var(--sage); color: #fff; border: none; border-radius: 100px;
  padding: 0.7rem 1.6rem; font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; cursor: pointer; font-weight: 500;
}

/* ── Reset Link ── */
.reset-link { display: inline-block; font-size: 0.78rem; color: var(--ink-muted); border: none; background: none; cursor: pointer; text-decoration: underline; padding: 0; margin-top: 0.75rem; }
.reset-link:hover { color: #c0392b; }

/* ── Confetti canvas ── */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
}

/* ── Responsive breakpoints ── */
@media (max-width: 480px) {
  .cal-day { font-size: 0.72rem; border-radius: 7px; }
  .card { padding: 1.25rem; }
  .reason-grid { grid-template-columns: repeat(2, 1fr); }
  .counter-num { font-size: 5rem; }
}