/* ===== CSS Custom Properties ===== */
:root {
  --bg: #fafafa;
  --card-bg: #ffffff;
  --primary: #ff6b35;
  --primary-hover: #e85a28;
  --primary-active: #d44d1f;
  --cashout: #2ecc71;
  --cashout-hover: #27ae60;
  --cashout-active: #219a52;
  --text: #2d2d2d;
  --text-light: #6b6b6b;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
  --font-main: 'Fredoka', system-ui, sans-serif;
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: var(--font-main);
  color: var(--text);
  line-height: 1.5;
  padding: 1rem;
}

.app-container { width: 100%; max-width: 420px; }

/* ===== Header ===== */
.app-header { text-align: center; margin-bottom: 1.5rem; }
.app-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  color: var(--primary);
  text-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
  letter-spacing: -0.02em;
}
.subtitle {
  font-size: 1rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  font-weight: 400;
}

/* ===== Counter Card ===== */
.counter-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
  text-align: center;
  transition: box-shadow var(--transition-normal), transform var(--transition-fast);
  position: relative;
}
.counter-card:active { transform: scale(0.98); }

.counter-display { margin-bottom: 2rem; }
.counter-value {
  font-family: var(--font-display);
  font-size: clamp(4rem, 18vw, 6rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  display: block;
  transition: transform var(--transition-bounce);
}
.counter-value.bump { animation: bump 0.4s var(--transition-bounce); }
.counter-label {
  font-size: 1.25rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
  display: block;
}

/* ===== Buttons ===== */
.button-group { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.btn {
  flex: 1 1 140px;
  max-width: 180px;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  touch-action: manipulation;
}
.btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
.btn:active { transform: scale(0.95); }
.btn-icon { font-size: 1.25em; line-height: 1; }
.btn-text { display: none; }
@media (min-width: 360px) { .btn-text { display: inline; } }

.btn-add {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}
.btn-add:hover { background: var(--primary-hover); box-shadow: 0 6px 16px rgba(255, 107, 53, 0.5); }
.btn-add:active { background: var(--primary-active); }

.btn-cashout {
  background: var(--cashout);
  color: white;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}
.btn-cashout:hover { background: var(--cashout-hover); box-shadow: 0 6px 16px rgba(46, 204, 113, 0.5); }
.btn-cashout:active { background: var(--cashout-active); }
.btn-cashout:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Celebration Zone ===== */
.celebration-zone {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--radius);
}
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 1.5s ease-out forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  justify-content: space-around;
  margin-top: 1.5rem;
  padding: 1rem;
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-radius: var(--radius-sm);
  animation: slide-up 0.4s var(--transition-bounce);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== Footer ===== */
.app-footer { text-align: center; margin-top: 2rem; color: var(--text-light); font-size: 0.875rem; }

/* ===== Counter Animations ===== */
@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.25); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes cashout-flash {
  0% { background: var(--card-bg); }
  50% { background: #ffeaa7; }
  100% { background: var(--card-bg); }
}
.counter-card.cashing-out { animation: cashout-flash 0.6s ease; }

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}