/* ============================================================
   Salat al-Nariyaa — Group Counter PWA
   Design: white on black, calm, readable, mobile-first
   ============================================================ */

@font-face {
  font-family: 'Muhammadi Quranic';
  src: url('fonts/muhammadi-quranic.woff') format('woff'),
       url('fonts/muhammadi-quranic.ttf')  format('truetype');
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

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

:root {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #9a9a9a;
  --dim: #555555;
  --accent: #ffffff;
  --accent-dim: rgba(255,255,255,0.15);
  --accent-soft: rgba(255,255,255,0.08);
  --error: #ff6b6b;
  --success: #6bff9c;
  --radius: 14px;
  --max-w: 560px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

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

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 18px 60px;
}

.screen[hidden] { display: none; }

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  text-align: center;
  padding-top: 18vh;
}

/* ---------- Registration ---------- */

.title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 48px;
  font-size: 14px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.welcome-text {
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 15px;
}

#register-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

input[type="text"] {
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 17px;
  padding: 14px 16px;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus { border-color: var(--fg); }

.primary-btn {
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s;
}

.primary-btn:active { transform: scale(0.98); }

.error {
  color: var(--error);
  font-size: 14px;
  margin-top: 12px;
}

/* ---------- App header ---------- */

.app-header {
  width: 100%;
  max-width: var(--max-w);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.user-info { display: flex; flex-direction: column; }
.label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; }
.user-name { font-size: 18px; font-weight: 600; margin-top: 2px; }
.label-small { color: var(--muted); font-size: 13px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--dim);
  color: var(--fg);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Recitation text ---------- */

.recitation {
  width: 100%;
  max-width: var(--max-w);
  font-family: 'Muhammadi Quranic', 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 2.4;
  text-align: center;
  margin: 8px 0 28px;
  padding: 24px 18px;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  background: var(--accent-soft);
  letter-spacing: 0;
  font-weight: 400;
}

.recitation p {
  margin: 0 0 6px;
}

.recitation p:last-child {
  margin-bottom: 0;
}

/* ---------- Counter button ---------- */

.counter-wrap {
  width: 100%;
  max-width: var(--max-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.tap-btn {
  width: 100%;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 28px 18px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.08s, background 0.2s;
  user-select: none;
}

.tap-btn:active {
  transform: scale(0.97);
  background: #e0e0e0;
}

.tap-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  opacity: 0.7;
}

.my-count {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tap-sublabel {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.55;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  margin-top: 14px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
}

/* ---------- Progress section ---------- */

.progress-section {
  width: 100%;
  max-width: var(--max-w);
  margin-bottom: 36px;
  text-align: center;
}

.progress-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.big-num {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--accent-dim);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--fg);
  width: 0%;
  transition: width 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
  border-radius: 4px;
}

.progress-footer {
  color: var(--muted);
  font-size: 13px;
}

#remaining-num {
  color: var(--fg);
  font-weight: 600;
}

/* ---------- Leaderboard ---------- */

.leaderboard {
  width: 100%;
  max-width: var(--max-w);
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 12px;
  padding-left: 4px;
}

.participants-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--accent-dim);
  border-radius: var(--radius);
  overflow: hidden;
}

.participants-list li {
  background: var(--bg);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}

.participants-list li.me {
  background: var(--accent-soft);
  font-weight: 600;
}

.participants-list li .p-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.participants-list li .p-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.participants-list li.empty {
  color: var(--muted);
  justify-content: center;
  font-style: italic;
}

/* ---------- Status pill ---------- */

.status-pill {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(255,255,255,0.1);
  z-index: 100;
  animation: pop 0.25s ease;
}

.status-pill.offline {
  background: #ff6b6b;
  color: #fff;
}

@keyframes pop {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-content {
  background: #111;
  border: 1px solid var(--dim);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.modal-content h3 {
  margin: 0 0 18px;
  font-weight: 600;
}

.modal-btn {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--dim);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
}

.modal-btn.close {
  background: var(--fg);
  color: var(--bg);
  margin-top: 8px;
}

.modal-note {
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0 0;
}

/* ---------- Pulse animation when count increases ---------- */

.pulse {
  animation: pulse 0.3s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
