:root {
  --gold: #f2b544;
  --gold-soft: #ffd88a;
  --gold-deep: #b9761a;
  --ink: #fff8ea;
  --muted: rgba(255, 244, 220, 0.7);
  --glass: rgba(20, 12, 2, 0.38);
  --glass-border: rgba(255, 210, 130, 0.22);
  --danger: #e2574c;
}

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

html, body { height: 100%; }

body {
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--ink);
  background: #1a1206;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Background ---------- */
.bg {
  position: fixed;
  inset: -4%;
  background: linear-gradient(180deg, #5a3a0c 0%, #c98a1c 55%, #7a4a0a 80%, #140c02 100%);
  animation: kenburns 40s ease-in-out infinite alternate;
  z-index: -3;
}
@keyframes kenburns {
  from { transform: scale(1) translateY(0); }
  to   { transform: scale(1.08) translateY(-1.5%); }
}
.bg-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 75%),
    linear-gradient(180deg, rgba(10,6,0,0.55) 0%, rgba(10,6,0,0.1) 40%, rgba(10,6,0,0.75) 100%);
  z-index: -2;
}
.stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.stars i {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--gold-soft);
  border-radius: 50%;
  opacity: 0;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: 0.9; transform: scale(1.6); } }

/* ---------- Layout ---------- */
.app {
  position: relative;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2vh, 18px);
  cursor: pointer;
  animation: fadeUp 0.8s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } }

.top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: default;
}
.brand { font-size: 1.35rem; font-weight: 300; letter-spacing: 0.5px; }
.brand span { font-weight: 700; color: var(--gold); }
.total {
  text-align: right;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: 14px;
  line-height: 1.1;
}
.total small { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.total strong { font-size: 1.1rem; color: var(--gold-soft); }

/* ---------- Dhikr chips ---------- */
.dhikr-list {
  width: 100%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
  cursor: default;
}
.dhikr-list::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.chip:hover { border-color: var(--gold); }
.chip.active {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #2a1a02;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(242, 181, 68, 0.45);
}

/* ---------- Dhikr text ---------- */
.dhikr-text { text-align: center; min-height: 110px; }
.dhikr-text.swap { animation: swap 0.5s ease; }
@keyframes swap {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); filter: blur(4px); }
  100% { opacity: 1; transform: none; filter: none; }
}
.arabic {
  font-family: "Amiri", serif;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: 1.5;
  color: var(--gold-soft);
  text-shadow: 0 2px 20px rgba(242, 181, 68, 0.5);
  direction: rtl;
}
.translit { font-size: 1.05rem; font-weight: 600; margin-top: 2px; }
.meaning { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* ---------- Counter ---------- */
.counter-wrap { flex: 1; display: grid; place-items: center; width: 100%; min-height: 0; }
.counter {
  position: relative;
  width: min(68vw, 42vh, 290px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 220, 150, 0.28), transparent 55%),
    radial-gradient(circle, rgba(40, 24, 4, 0.55), rgba(15, 9, 1, 0.75));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 0 0 1px var(--glass-border),
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 40px rgba(242, 181, 68, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, box-shadow 0.3s ease;
  outline: none;
}
.counter::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
  pointer-events: none;
}
.counter.pulse::after { animation: pulseRing 0.6s ease-out; }
@keyframes pulseRing {
  0% { opacity: 0.8; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.18); }
}
.counter.press { transform: scale(0.95); }
.counter.done {
  animation: glow 1.4s ease;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 1px var(--glass-border), 0 20px 60px rgba(0,0,0,0.55), inset 0 0 40px rgba(242,181,68,0.15); }
  30% { box-shadow: 0 0 0 3px var(--gold), 0 0 90px rgba(242,181,68,0.85), inset 0 0 60px rgba(242,181,68,0.5); }
}

.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: rgba(255, 220, 150, 0.12); }
.ring-fg {
  stroke: var(--gold);
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(242, 181, 68, 0.8));
  transition: stroke-dashoffset 0.35s cubic-bezier(.3,1.4,.5,1);
}

.count {
  font-size: clamp(3.2rem, 15vw, 5rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff6e0, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.count.bump { animation: bump 0.28s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.target { font-size: 1rem; color: var(--muted); margin-top: 4px; }
.rounds {
  font-size: 0.75rem;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(242, 181, 68, 0.15);
  color: var(--gold-soft);
}

/* ---------- Beads ---------- */
.beads {
  width: 100%;
  height: 34px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
}
.beads::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(255, 220, 150, 0.4);
}
.bead-track {
  position: absolute;
  top: 3px;
  left: 50%;
  display: flex;
  gap: 8px;
  transition: transform 0.3s cubic-bezier(.3,1.3,.5,1);
}
.bead-track i {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe7b0, var(--gold) 45%, var(--gold-deep) 100%);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

/* ---------- Controls ---------- */
.controls { width: 100%; display: flex; flex-direction: column; gap: 10px; cursor: default; }
.targets, .actions { display: flex; gap: 8px; justify-content: center; }
.targets button, .icon-btn, .reset-btn {
  font: inherit;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.targets button { min-width: 58px; padding: 8px 12px; font-weight: 600; }
.targets button.active { border-color: var(--gold); color: var(--gold-soft); box-shadow: inset 0 0 12px rgba(242,181,68,0.3); }
.icon-btn { width: 46px; font-size: 1.15rem; }
.icon-btn.off { opacity: 0.4; filter: grayscale(1); }
.reset-btn { flex: 1; max-width: 240px; padding: 11px 18px; font-weight: 600; }
.reset-btn:hover { border-color: var(--danger); color: #ffb3ab; }
.targets button:active, .icon-btn:active, .reset-btn:active { transform: scale(0.94); }
.reset-btn.spin { animation: shake 0.5s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.hint { font-size: 0.75rem; color: var(--muted); text-align: center; }
kbd {
  font-family: inherit;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
}

/* ---------- Tap effects ---------- */
.ripple {
  position: fixed;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2px solid var(--gold-soft);
  pointer-events: none;
  animation: ripple 0.7s ease-out forwards;
  z-index: 50;
}
@keyframes ripple {
  to { transform: scale(9); opacity: 0; }
}
.plus {
  position: fixed;
  pointer-events: none;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--gold-soft);
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  animation: floatUp 0.9s ease-out forwards;
  z-index: 51;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.3); }
}
.particle {
  position: fixed;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 10px var(--gold);
  pointer-events: none;
  z-index: 52;
  animation: burst 1.1s cubic-bezier(.1,.8,.3,1) forwards;
}
@keyframes burst {
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 100;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 24px 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(50, 32, 6, 0.95), rgba(20, 12, 2, 0.95));
  border: 1px solid var(--glass-border);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(.3,1.4,.5,1);
}
.modal.open .modal-card { transform: none; }
.modal-card h3 { font-size: 1.3rem; color: var(--gold-soft); }
.modal-card p { color: var(--muted); margin: 8px 0 18px; font-size: 0.95rem; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions button {
  font: inherit;
  font-weight: 600;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s;
}
.modal-actions button:active { transform: scale(0.97); }
.modal-actions button:hover { filter: brightness(1.1); }
.btn-gold { background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #2a1a02; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--glass-border) !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 30px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 12, 2, 0.9);
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(.3,1.4,.5,1);
  z-index: 120;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 640px) {
  .dhikr-text { min-height: 0; }
  .meaning, .hint { display: none; }
  .beads { height: 26px; }
  .bead-track i { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- SEO / about / footer ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand img { border-radius: 7px; }
.brand b { font-weight: 300; }
.top-right { display: flex; align-items: center; gap: 8px; }
.info-btn { width: 40px; height: 40px; font-family: Georgia, serif; font-style: italic; font-weight: 700; color: var(--gold-soft); }
.footer { font-size: 0.72rem; color: var(--muted); text-align: center; margin-top: -6px; cursor: default; }
.footer a { color: var(--gold-soft); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.about-card { max-width: 440px; max-height: 85dvh; overflow-y: auto; text-align: left; user-select: text; -webkit-user-select: text; }
.about-card h2 { font-size: 1.3rem; color: var(--gold-soft); margin-bottom: 8px; }
.about-card h3 { font-size: 1rem; color: var(--gold-soft); margin-top: 14px; }
.about-card p, .about-card li { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.about-card p { margin: 6px 0 0; }
.about-card ul { padding-left: 18px; margin-top: 6px; }
.about-card a { color: var(--gold-soft); }
.about-card .btn-gold {
  width: 100%; margin-top: 18px; padding: 11px; border: none; border-radius: 12px;
  font: inherit; font-weight: 600; cursor: pointer;
}
