:root {
  --db-surface: #ffffff;
  --db-surface-soft: #f8fbf9;
  --db-border: #dbe9e0;
  --db-text-muted: #4f6b5d;
  --db-shadow: 0 12px 30px rgba(21, 63, 48, 0.08);
  --db-radius-xl: 18px;
  --db-piggy-body: #d9efe3;
  --db-piggy-fill: #56b287;
  --db-piggy-outline: #245c44;
  --db-piggy-shadow: rgba(36, 92, 68, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.db-shell-bg {
  background:
    radial-gradient(circle at top left, #eef8f2 0%, rgba(238, 248, 242, 0) 44%),
    radial-gradient(circle at 85% 10%, #fff3e8 0%, rgba(255, 243, 232, 0) 32%),
    linear-gradient(180deg, #f6fbf8 0%, #f9fafb 100%);
}

.db-card {
  background: var(--db-surface);
  border: 1px solid var(--db-border);
  border-radius: var(--db-radius-xl);
  box-shadow: var(--db-shadow);
}

.db-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.db-btn:hover {
  transform: translateY(-1px);
}

.db-btn:focus-visible {
  outline: 2px solid #2f8f67;
  outline-offset: 2px;
}

.db-btn-primary {
  color: #ffffff;
  background: #2f8f67;
  box-shadow: 0 8px 20px rgba(47, 143, 103, 0.25);
}

.db-btn-primary:hover {
  background: #267856;
}

.db-btn-danger {
  color: #8a2b2b;
  background: #fff1f1;
  border-color: #fecaca;
}

.db-btn-danger:hover {
  background: #ffe5e5;
}

.db-btn-secondary {
  color: #1f513b;
  background: #e7f5ee;
  border-color: #b7ddca;
}

.db-btn-secondary:hover {
  background: #daf0e5;
}

.db-btn-outline {
  color: #334155;
  background: #ffffff;
  border-color: #d1d5db;
}

.db-btn-outline:hover {
  background: #f8fafc;
}

.db-btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
}

.db-input {
  width: 100%;
  border: 1px solid #bfd8ca;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  line-height: 1.2;
  color: #1f2937;
  background: #ffffff;
}

.db-input:focus {
  outline: 2px solid rgba(47, 143, 103, 0.25);
  border-color: #2f8f67;
}

.db-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.32rem 0.72rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.db-badge-success {
  background: #ddf3e7;
  color: #1f6a4b;
}

.db-badge-soft {
  background: #eef2ff;
  color: #3b4b82;
}

.db-money {
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #0f3d2c;
}

.db-money-sm {
  font-size: 1rem;
}

.db-money-lg {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
}

.db-piggy-shell {
  position: relative;
  width: min(100%, 360px);
  height: 208px;
  margin-inline: auto;
  --db-piggy-fill-target: 0%;
}

.db-piggy-shadow {
  position: absolute;
  left: 66px;
  right: 32px;
  bottom: 13px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(36, 92, 68, 0), var(--db-piggy-shadow), rgba(36, 92, 68, 0));
}

.db-piggy-icon-frame {
  position: absolute;
  inset: 0;
}

.db-piggy-icon {
  position: absolute;
  left: 18px;
  right: 6px;
  bottom: 10px;
  width: calc(100% - 24px);
  height: calc(100% - 18px);
  fill: currentColor;
}

.db-piggy-icon-fill {
  color: var(--db-piggy-fill);
}

.db-piggy-icon-base {
  color: var(--db-piggy-body);
}

.db-piggy-icon-outline {
  color: var(--db-piggy-outline);
}

.db-piggy-fill-layer {
  position: absolute;
  inset: 0;
  clip-path: inset(calc(100% - var(--db-piggy-fill-target)) 0 0 0);
}

.db-piggy-fill-animate {
  animation: db-piggy-fill-reveal 1800ms cubic-bezier(0.22, 0.75, 0.3, 1) both;
}

.db-piggy-target-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #cce3d8;
  overflow: hidden;
}

.db-piggy-target-fill {
  display: block;
  height: 100%;
  width: var(--db-piggy-fill-target);
  background: linear-gradient(90deg, #6ec098 0%, #2f8f67 100%);
}

.db-piggy-target-fill-animate {
  animation: db-piggy-progress-fill 1600ms cubic-bezier(0.22, 0.75, 0.3, 1) both;
}

@media (max-width: 1023px) {
  .db-piggy-shell {
    width: min(100%, 328px);
    height: 196px;
  }
}

.db-kid-chip {
  border-radius: 999px;
  background: var(--db-surface-soft);
  border: 1px solid #d8e7dd;
}

.db-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 0.35rem;
  line-height: 1;
}

.db-help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #b5c8bc;
  background: #ffffff;
  color: #355448;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.db-help-trigger:focus-visible {
  outline: 2px solid #2f8f67;
  outline-offset: 2px;
}

.db-help-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.45rem);
  width: min(320px, 78vw);
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #cce2d5;
  background: #f7fcf9;
  color: #244436;
  box-shadow: 0 10px 28px rgba(21, 63, 48, 0.16);
  z-index: 400;
  pointer-events: auto;
}

.db-help-right .db-help-panel {
  right: 0;
}

.db-help-left .db-help-panel {
  left: 0;
}

.db-help:hover .db-help-panel,
.db-help:focus-within .db-help-panel {
  display: block;
}

.db-help.is-open .db-help-panel {
  display: block;
}

.db-help-title {
  display: block;
  margin: 0 0 0.2rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-transform: none;
}

.db-help-text {
  display: block;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
  letter-spacing: normal;
  text-transform: none;
}

.db-undo-toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  z-index: 80;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}

.db-undo-toast {
  width: min(92vw, 460px);
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
  border-radius: 14px;
  padding: 12px;
  pointer-events: auto;
}

.db-settings-toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 85;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.db-settings-toast {
  width: min(92vw, 360px);
  border: 1px solid #bbf7d0;
  background: rgba(240, 253, 244, 0.98);
  color: #14532d;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  pointer-events: auto;
}

.db-goal-item {
  position: relative;
  overflow: visible;
}

.db-goal-progress-track {
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.db-goal-progress-fill {
  transition: width 2100ms cubic-bezier(0.22, 0.8, 0.22, 1);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15), 0 0 20px rgba(34, 197, 94, 0.34);
}

.db-goal-celebrate {
  animation: db-goal-pop 760ms ease;
}

.db-goal-success-message.is-popping {
  animation: db-goal-message-pop 900ms ease;
}

.db-goal-confetti {
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  height: 0;
  pointer-events: none;
  z-index: 2;
}

.db-goal-confetti-piece {
  position: absolute;
  left: calc(50% - 4px);
  top: 0;
  width: 10px;
  height: 12px;
  border-radius: 2px;
  background: hsl(var(--hue), 80%, 58%);
  opacity: 0;
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation: db-goal-confetti-burst 1300ms ease-out forwards;
  animation-delay: var(--delay);
}

@keyframes db-goal-confetti-burst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--dx), var(--dy), 0) rotate(520deg) scale(1);
  }
}

@keyframes db-goal-pop {
  0% {
    transform: scale(1);
  }

  28% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes db-goal-message-pop {
  0% {
    transform: translateY(0) scale(1);
  }

  30% {
    transform: translateY(-2px) scale(1.08);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes db-piggy-fill-reveal {
  from {
    clip-path: inset(100% 0 0 0);
  }

  to {
    clip-path: inset(calc(100% - var(--db-piggy-fill-target)) 0 0 0);
  }
}

@keyframes db-piggy-progress-fill {
  from {
    width: 0;
  }

  to {
    width: var(--db-piggy-fill-target);
  }
}

@media (prefers-reduced-motion: reduce) {
  .db-piggy-fill-animate,
  .db-piggy-target-fill-animate {
    animation: none;
  }
}
