* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(180deg, #E8E0F0 0%, #F8F6FC 30%, #FFFFFF 100%);
  min-height: 100vh;
  color: #2D2D3A;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #E8E0F0 0%, #D4C8E8 100%);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #9B7ED9 0%, #7B5EB0 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(123, 94, 176, 0.3);
}

.app-title h1 {
  font-size: 20px;
  font-weight: 800;
  color: #2D2D3A;
  letter-spacing: -0.5px;
}

.app-title span {
  font-size: 11px;
  color: #7B7B8F;
  font-weight: 600;
}

.header-right {
  text-align: right;
}

.level-display {
  font-size: 12px;
  font-weight: 800;
  color: #5A4A7A;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.xp-bar {
  width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 3px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #4ECDC4 0%, #44B3AC 100%);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Main */
.main {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Pet Container */
.pet-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
}

.speech-bubble {
  background: white;
  padding: 8px 16px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  color: #5A4A7A;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  white-space: pre-line;
  text-align: center;
}

.speech-bubble.visible {
  opacity: 1;
  transform: translateY(0);
}

.pet {
  width: 120px;
  height: 100px;
  background: #FFE066;
  border-radius: 50% 50% 45% 45%;
  position: relative;
  box-shadow: 0 8px 24px rgba(255, 200, 0, 0.3);
  transition: transform 0.3s ease, background-color 0.5s ease;
}

.pet.bounce-0 { animation: petBounce 2s ease-in-out infinite; }
.pet.bounce-1 { animation: petBounce 2.2s ease-in-out infinite 0.1s; }
.pet.bounce-2 { animation: petBounce 1.8s ease-in-out infinite 0.2s; }

.pet.celebrating {
  animation: celebrate 0.5s ease-in-out;
}

@keyframes petBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.02); }
}

@keyframes celebrate {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-5deg); }
  50% { transform: scale(1.1) rotate(5deg); }
  75% { transform: scale(1.15) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.pet-crown {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  animation: crownBob 2s ease-in-out infinite;
}

@keyframes crownBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

.pet-sparkles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  font-size: 12px;
  animation: sparkle 1.5s ease-in-out infinite;
}

.sparkle.s1 { top: -5px; right: -5px; animation-delay: 0s; }
.sparkle.s2 { top: 10px; left: -10px; animation-delay: 0.5s; }

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.pet-face {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 40px;
}

.eye {
  position: absolute;
  width: 8px;
  height: 10px;
  background: #2D2D3A;
  border-radius: 50%;
  top: 8px;
  transition: transform 0.2s ease, height 0.1s ease;
}

.eye.left { left: 12px; }
.eye.right { right: 12px; }

.eye.blink { height: 2px; }

.cheek {
  position: absolute;
  width: 14px;
  height: 8px;
  background: #FFB3B3;
  border-radius: 50%;
  top: 22px;
  opacity: 0.7;
}

.cheek.left { left: 2px; }
.cheek.right { right: 2px; }

.mouth {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  border: 2px solid #2D2D3A;
  border-top: none;
  border-radius: 0 0 16px 16px;
}

.mouth.sad {
  border: 2px solid #2D2D3A;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  bottom: 8px;
}

.mouth.neutral {
  border: none;
  border-bottom: 2px solid #2D2D3A;
  border-radius: 0;
  height: 0;
  width: 12px;
}

.level-badge {
  background: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #5A4A7A;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Mood Selector */
.mood-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 10px 16px;
  border-radius: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.mood-label {
  font-size: 13px;
  font-weight: 600;
  color: #7B7B8F;
}

.mood-options {
  display: flex;
  gap: 4px;
}

.mood-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.5;
}

.mood-btn:hover { opacity: 0.8; transform: scale(1.1); }
.mood-btn.active { opacity: 1; background: #F0E8F8; transform: scale(1.15); }

/* Habits Grid */
.habits-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.habit-card {
  background: white;
  border: none;
  border-radius: 16px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.habit-card:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.habit-card:active:not(:disabled) {
  transform: scale(0.98);
}

.habit-card.completed {
  opacity: 0.6;
  cursor: default;
}

.habit-card.completed::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(78, 205, 196, 0.1) 0%, rgba(78, 205, 196, 0.05) 100%);
}

.completed-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: #4ECDC4;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.habit-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.habit-name {
  font-size: 14px;
  font-weight: 700;
  color: #2D2D3A;
}

.habit-xp {
  font-size: 12px;
  font-weight: 600;
  color: #7B7B8F;
}

/* Stats Panel */
.stats-panel {
  width: 100%;
  max-width: 360px;
  margin-top: auto;
}

.stats-toggle {
  width: 100%;
  background: white;
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #5A4A7A;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.stats-toggle:hover {
  background: #F8F6FC;
}

.stats-content {
  background: white;
  margin-top: 8px;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid #F0E8F8;
}

.stat-row:last-child { border-bottom: none; }

.stat-value {
  font-weight: 700;
  color: #5A4A7A;
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
}

.footer a {
  color: #9B7ED9;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer a:hover { color: #7B5EB0; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 58, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  font-size: 20px;
  font-weight: 800;
  color: #2D2D3A;
  text-align: center;
  margin-bottom: 8px;
}

.modal-subtitle {
  text-align: center;
  font-size: 14px;
  color: #7B7B8F;
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #E8E0F0;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s ease;
}

.modal-input:focus {
  outline: none;
  border-color: #9B7ED9;
}

.journal-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #E8E0F0;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  resize: none;
  margin-bottom: 16px;
  transition: border-color 0.2s ease;
}

.journal-textarea:focus {
  outline: none;
  border-color: #9B7ED9;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #9B7ED9 0%, #7B5EB0 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(123, 94, 176, 0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-secondary {
  background: #F0E8F8;
  color: #5A4A7A;
}

.btn-secondary:hover { background: #E8E0F0; }

/* Breathe Modal */
.breathe-modal {
  text-align: center;
}

.breathe-circle-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  margin: 20px 0;
}

.breathe-circle {
  background: linear-gradient(135deg, #4ECDC4 0%, #44B3AC 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 700;
  white-space: pre-line;
  transition: all 1s ease;
  box-shadow: 0 8px 32px rgba(78, 205, 196, 0.3);
}

.breathe-circle.inhale { animation: pulse 4s ease-in-out infinite; }
.breathe-circle.hold { animation: glow 1s ease-in-out infinite; }
.breathe-circle.exhale { animation: shrink 8s ease-in-out; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 8px 32px rgba(78, 205, 196, 0.3); }
  50% { box-shadow: 0 8px 48px rgba(78, 205, 196, 0.5); }
}

.cycles-count {
  font-size: 14px;
  color: #7B7B8F;
  margin-bottom: 16px;
}

/* Break Timer */
.break-timer {
  font-size: 48px;
  font-weight: 800;
  color: #F4A261;
  text-align: center;
  margin: 30px 0;
  font-variant-numeric: tabular-nums;
}

/* Stretch Modal */
.stretch-display {
  text-align: center;
  padding: 20px 0;
}

.stretch-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.stretch-display h3 {
  font-size: 18px;
  font-weight: 700;
  color: #2D2D3A;
  margin-bottom: 8px;
}

.stretch-display p {
  font-size: 14px;
  color: #7B7B8F;
  margin-bottom: 16px;
}

.stretch-timer {
  font-size: 36px;
  font-weight: 800;
  color: #9B5DE5;
  margin-bottom: 8px;
}

.stretch-progress {
  font-size: 13px;
  color: #7B7B8F;
}

/* Confetti */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  top: -20px;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 380px) {
  .habits-grid {
    gap: 8px;
  }
  
  .habit-card {
    padding: 16px 12px;
  }
  
  .habit-icon {
    font-size: 24px;
  }
  
  .habit-name {
    font-size: 13px;
  }
}