:root {
  --primary: #1E3A5F;
  --primary-light: #2E5A8F;
  --primary-dark: #152A45;
  --background: #FAF9F6;
  --background-gradient: #F0EDE6;
  --surface: #FFFFFF;
  --surface-variant: #F5F4F0;
  --text-primary: #1A1A2E;
  --text-secondary: #4A5568;
  --text-muted: #718096;
  --accent: #D4A574;
  --accent-light: #E8D4B8;
  --accent-dark: #B8935F;
  --danger: #9B2335;
  --border: #E2E0D9;
  --border-light: #F0EEE8;
  --ring-size: 240px;
  --ring-stroke: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  background: linear-gradient(180deg, var(--background) 0%, var(--background-gradient) 100%);
  color: var(--text-primary);
  overflow: hidden;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.hidden { display: none !important; }

/* Pages */
.page {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 0 24px;
  overflow-y: auto;
}
.page.active { display: flex; }

/* Header */
.header {
  padding-top: 44px;
  padding-bottom: 12px;
  text-align: center;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 5px;
}
.header-ornament {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 6px;
  margin-top: 6px;
}

/* ===== COUNTER PAGE ===== */
.main-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

/* Tap ripple effect */
.main-section::after {
  content: '';
  position: absolute;
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 165, 116, 0.15) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.main-section.tapped::after {
  opacity: 1;
  transform: scale(1.15);
}

/* Counter Ring */
.counter-ring-container {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  display: flex;
  justify-content: center;
  align-items: center;
}

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

.progress-ring-track {
  fill: none;
  stroke: var(--border-light);
  stroke-width: var(--ring-stroke);
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: var(--ring-stroke);
  stroke-linecap: round;
  stroke-dasharray: 678.58;
  stroke-dashoffset: 678.58;
  transition: stroke-dashoffset 0.4s ease;
}

/* Milestone glow */
.counter-ring-container.milestone .progress-ring-fill {
  stroke: var(--accent-dark);
  filter: drop-shadow(0 0 8px rgba(212, 165, 116, 0.6));
}
.counter-ring-container.milestone {
  animation: milestone-pulse 1.5s ease-in-out;
}
@keyframes milestone-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.06); }
  60% { transform: scale(1); }
  80% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.counter-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.counter-number {
  font-size: 72px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -2px;
  line-height: 1;
  display: block;
  transition: transform 0.15s ease;
}

/* Tap animation on the number */
.counter-number.bump {
  transform: scale(1.08);
}

.badge {
  margin-top: 8px;
  background: var(--accent);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
}
.badge-text {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

/* Tap hint & progress label */
.tap-hint {
  margin-top: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progress-label {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 600;
}
.tap-label {
  font-size: 13px;
  color: var(--border);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Bottom Buttons */
.button-section {
  padding-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.decrement-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.decrement-button:active {
  background: var(--surface-variant);
  border-color: var(--text-muted);
}

.reset-button {
  background: transparent;
  border: 1px solid var(--border);
  height: 48px;
  padding: 0 28px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s;
}
.reset-button:active {
  background: var(--border-light);
  color: var(--text-secondary);
}

/* ===== SETTINGS PAGE ===== */
.settings-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-box {
  width: 48px;
  height: 48px;
  background: var(--surface-variant);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}
.text-box { flex: 1; }
.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.card-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* Switch */
.switch {
  position: relative;
  width: 56px;
  height: 32px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #D1D5DB;
  border-radius: 32px;
  transition: background 0.3s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch input:checked + .switch-slider {
  background: var(--accent);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(24px);
}

/* Slider */
.slider-box { margin-top: 16px; }
.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.label-small, .label-large {
  font-size: 13px;
  color: var(--text-muted);
}
.label-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}
.slider {
  width: 100%;
  height: 40px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 50%;
  margin-top: -11px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(30,58,95,0.3);
}

/* Preview */
.preview-card {
  text-align: center;
  background: var(--surface-variant);
}
.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.preview-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px 32px;
  display: inline-block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.preview-number {
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  line-height: 1;
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 32px 0;
  text-align: center;
}
.footer-icon {
  width: 56px;
  height: 56px;
  background: var(--surface-variant);
  border-radius: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.footer-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.footer-version {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.footer-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  height: 72px;
  padding-bottom: 8px;
  padding-top: 6px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 16px rgba(30,58,95,0.08);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}
.tab-item.active { color: var(--primary); }
.tab-icon-container {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  transition: background 0.2s;
}
.tab-item.active .tab-icon-container {
  background: var(--accent-light);
}
.tab-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.modal-icon {
  margin-bottom: 16px;
}
.modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.modal-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}
.modal-button {
  width: 100%;
  height: 56px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
  transition: opacity 0.15s, transform 0.1s;
}
.modal-button:active {
  opacity: 0.85;
  transform: scale(0.98);
}
.modal-button-confirm {
  background: var(--danger);
  color: #fff;
}
.modal-button-cancel {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
}

/* ===== RESPONSIVE: Kucuk telefonlar (< 360px) ===== */
@media (max-width: 359px) {
  :root {
    --ring-size: 190px;
    --ring-stroke: 6px;
  }
  .page { padding: 0 16px; }
  .header { padding-top: 28px; padding-bottom: 8px; }
  .header-title { font-size: 15px; letter-spacing: 3px; }
  .header-ornament { font-size: 8px; }
  .counter-number { font-size: 56px; }
  .badge { padding: 4px 12px; }
  .badge-text { font-size: 10px; }
  .tap-hint { margin-top: 12px; }
  .progress-label { font-size: 13px; }
  .decrement-button { width: 48px; height: 48px; }
  .reset-button { height: 42px; font-size: 13px; padding: 0 20px; }
  .button-section { gap: 16px; }
  .tab-bar { height: 64px; }
  .tab-icon-container { width: 34px; height: 34px; border-radius: 17px; }
  .tab-icon-container svg { width: 20px; height: 20px; }
  .tab-label { font-size: 11px; }
}

/* ===== RESPONSIVE: Tablet (>= 600px) ===== */
@media (min-width: 600px) {
  :root {
    --ring-size: 300px;
    --ring-stroke: 10px;
  }
  .page { padding: 0 48px; }
  .header { padding-top: 56px; padding-bottom: 16px; }
  .header-title { font-size: 22px; letter-spacing: 6px; }
  .header-ornament { font-size: 12px; letter-spacing: 8px; }

  .counter-number { font-size: 88px; }
  .badge { padding: 8px 20px; }
  .badge-text { font-size: 14px; }
  .tap-hint { margin-top: 28px; }
  .progress-label { font-size: 17px; }
  .tap-label { font-size: 14px; }

  .decrement-button { width: 64px; height: 64px; }
  .decrement-button svg { width: 28px; height: 28px; }
  .reset-button { height: 56px; font-size: 16px; padding: 0 36px; border-radius: 28px; }

  .card { padding: 24px; border-radius: 20px; }
  .card-title { font-size: 20px; }
  .card-desc { font-size: 16px; }
  .icon-box { width: 56px; height: 56px; border-radius: 14px; }
  .icon-box svg { width: 32px; height: 32px; }

  .switch { width: 64px; height: 36px; }
  .switch-slider::before { width: 30px; height: 30px; }
  .switch input:checked + .switch-slider::before { transform: translateX(28px); }

  .slider::-webkit-slider-thumb { width: 32px; height: 32px; margin-top: -13px; }
  .slider::-webkit-slider-runnable-track { height: 8px; }
  .label-small, .label-large { font-size: 15px; }
  .label-value { font-size: 16px; }

  .preview-label { font-size: 14px; }
  .preview-box { padding: 28px 44px; }

  .modal-box { max-width: 420px; padding: 40px; border-radius: 28px; }
  .modal-title { font-size: 26px; }
  .modal-text { font-size: 18px; }
  .modal-button { height: 62px; font-size: 18px; }

  .tab-bar { height: 84px; padding-bottom: 12px; padding-top: 8px; }
  .tab-icon-container { width: 48px; height: 48px; border-radius: 24px; }
  .tab-label { font-size: 14px; }

  .footer-icon { width: 68px; height: 68px; border-radius: 34px; }
  .footer-icon svg { width: 36px; height: 36px; }
  .footer-title { font-size: 24px; }
  .footer-version { font-size: 15px; }
  .footer-desc { font-size: 16px; }
}

/* ===== RESPONSIVE: Buyuk tablet (>= 800px) ===== */
@media (min-width: 800px) {
  :root {
    --ring-size: 340px;
    --ring-stroke: 12px;
  }
  .page { padding: 0 80px; }
  .header { padding-top: 64px; padding-bottom: 20px; }
  .header-title { font-size: 24px; letter-spacing: 7px; }

  .counter-number { font-size: 96px; }

  .decrement-button { width: 72px; height: 72px; }
  .decrement-button svg { width: 32px; height: 32px; }
  .reset-button { height: 60px; font-size: 18px; padding: 0 40px; }

  .settings-content { max-width: 700px; gap: 20px; }
  .card { padding: 28px; }
  .card-title { font-size: 22px; }
  .card-desc { font-size: 17px; }
}

/* ===== Landscape orientation (yatay) ===== */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --ring-size: 160px;
    --ring-stroke: 5px;
  }
  .header { padding-top: 12px; padding-bottom: 4px; }
  .header-ornament { display: none; }
  .counter-number { font-size: 48px; }
  .tap-hint { margin-top: 8px; }
  .tap-label { display: none; }
  .button-section { padding-bottom: 6px; }
  .decrement-button { width: 40px; height: 40px; }
  .reset-button { height: 36px; font-size: 12px; }
  .tab-bar { height: 52px; padding-bottom: 4px; padding-top: 2px; }
  .tab-icon-container { width: 30px; height: 30px; border-radius: 15px; }
  .tab-icon-container svg { width: 18px; height: 18px; }
  .tab-label { font-size: 10px; }
}
