:root {
  --bg: #0d1f17;
  --bg-soft: #10261c;
  --gold: #c9a227;
  --gold-soft: rgba(201, 162, 39, 0.24);
  --text: #f4f1eb;
  --text-soft: rgba(244, 241, 235, 0.7);
  --text-faint: rgba(244, 241, 235, 0.45);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --danger: #e06767;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(65% 52% at 50% 52%, rgba(201, 162, 39, 0.11), transparent 65%),
    radial-gradient(95% 65% at 50% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: max(env(safe-area-inset-top), 18px) 20px max(env(safe-area-inset-bottom), 24px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  margin: 0;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.35px;
  color: var(--text);
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 160ms var(--spring), color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.icon-btn:active {
  transform: scale(0.93);
}

.lock-icon {
  width: 20px;
  height: 20px;
}

.lock-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: transparent;
  box-shadow: 0 0 0 transparent;
}

body.locked .icon-btn {
  color: var(--gold);
  border-color: rgba(201, 162, 39, 0.52);
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.24);
}

body.locked .lock-indicator {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.65);
  animation: lockPulse 1.6s ease-in-out infinite;
}

.target-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.target-guide {
  margin: 8px 2px 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.35;
}

.target-pill {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-faint);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 10px 16px;
  border-radius: 999px;
  transition: all 180ms ease;
}

.target-pill:active {
  transform: scale(0.95);
}

.target-pill.active {
  color: #f9e4a5;
  border-color: rgba(201, 162, 39, 0.56);
  background: rgba(201, 162, 39, 0.14);
}

.counter-zone {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
}

.orbital-wrap {
  position: relative;
  width: min(78vw, 340px);
  aspect-ratio: 1 / 1;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.tasbih-bead {
  fill: rgba(255, 255, 255, 0.14);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1;
  transform-origin: center;
  transition: fill 160ms ease, stroke 160ms ease, opacity 160ms ease;
}

.tasbih-bead.done {
  fill: rgba(201, 162, 39, 0.85);
  stroke: rgba(249, 228, 165, 0.88);
}

.tasbih-bead.current {
  fill: #f9e4a5;
  stroke: rgba(255, 245, 209, 0.95);
}

.tasbih-bead.drop {
  animation: beadDrop 280ms var(--spring);
}

.tap-btn {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(201, 162, 39, 0.48);
  border-radius: 50%;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.04));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 20px 50px rgba(0, 0, 0, 0.25),
    0 0 26px rgba(201, 162, 39, 0.2);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: grid;
  place-items: center;
  transition: transform 120ms var(--spring), box-shadow 180ms ease;
  touch-action: manipulation;
}

.tap-btn svg {
  width: 44%;
  height: 44%;
  stroke: var(--gold);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 9px rgba(201, 162, 39, 0.52));
}

.tap-btn:active,
.tap-btn.pressing {
  transform: scale(0.94);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 16px 36px rgba(0, 0, 0, 0.3),
    0 0 34px rgba(201, 162, 39, 0.34);
}

.tap-btn::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid rgba(201, 162, 39, 0.7);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.96);
}

.tap-btn.ripple::after {
  animation: ringRipple 380ms ease-out;
}

.count-badge {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 16, 12, 0.44);
  color: var(--text);
  min-width: 86px;
  height: 42px;
  border-radius: 999px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.3px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: transform 170ms var(--spring), opacity 180ms ease;
}

.count-badge:active {
  transform: scale(0.96);
}

.count-badge.bump {
  animation: badgeBump 200ms var(--spring);
}

.footer-actions {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.reset-btn {
  border: none;
  background: transparent;
  color: rgba(240, 188, 188, 0.9);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background 180ms ease, transform 160ms var(--spring);
}

.reset-btn:active {
  background: rgba(224, 103, 103, 0.15);
  transform: scale(0.96);
}

.target-hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(4, 8, 6, 0.52);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.modal[hidden] {
  display: none;
}

.modal-center {
  place-items: center;
}

.modal-card {
  width: min(96vw, 420px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: #132a1f;
  padding: 18px;
}

.modal-card h2 {
  margin: 0;
  font-size: 18px;
}

.modal-card p {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
}

.modal-btn.neutral {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.modal-btn.danger,
.modal-btn.confirm {
  background: var(--danger);
  color: #fff;
}

.modal-btn.gold {
  background: rgba(201, 162, 39, 0.26);
  color: #f9e4a5;
  border: 1px solid rgba(201, 162, 39, 0.5);
}

body.locked #target-row,
body.locked .target-guide,
body.locked .reset-btn,
body.locked .target-hint,
body.locked .brand {
  opacity: 0.16;
  pointer-events: none;
}

body.locked .count-badge {
  pointer-events: none;
}

.input-label {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-soft);
}

.target-input {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(7, 16, 12, 0.55);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}

.target-input:focus {
  border-color: rgba(201, 162, 39, 0.6);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.16);
}

body.locked .tap-btn {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 42px rgba(0, 0, 0, 0.32),
    0 0 36px rgba(201, 162, 39, 0.46);
}

@keyframes ringRipple {
  to {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes beadDrop {
  0% {
    transform: translateY(-6px) scale(0.92);
    opacity: 0.7;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

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

@keyframes lockPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.75; }
  50% { transform: scale(1.2); opacity: 1; }
}

@media (min-width: 720px) {
  .app-shell {
    padding-left: 32px;
    padding-right: 32px;
  }

  .target-row {
    justify-content: center;
  }
}
