* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: transparent;
}

.sm-wrapper {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  text-align: center;
  background: #fdfdfd;
  transition: background 1s ease;
  margin: 0;
  padding: 20px;
  overflow-x: hidden;
  position: relative;
  min-height: 500px;
  border-radius: 12px;
  border: 1px solid #f1f2f6;
}

.sm-wrapper h1 {
  color: #2c3e50;
  font-weight: 300;
  margin-bottom: 50px;
}

/* Mood Backgrounds - Increased specificity with !important for mobile/theme compatibility */
.sm-wrapper.mood-close { background: #ffcfcf !important; }
.sm-wrapper.mood-far { background: #bddcfc !important; }
.sm-wrapper.mood-neutral { background: #fdfdfd !important; }

.score-container {
  font-size: 1.2rem;
  font-weight: bold;
  color: #2c3e50;
  margin-top: -10px;
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

.sm-wrapper .effects-layer {
  position: absolute;
  top: 15%; /* Higher placement */
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(40px, 15vw, 100px); /* Responsive heart size */
  opacity: 0.3;
  pointer-events: none;
  z-index: 1; /* Above background, below characters */
  transition: all 0.5s ease;
}

.sm-wrapper .line-container {
  position: relative;
  width: 90%;
  max-width: 800px;
  height: 80px;
  margin: 60px auto 30px; /* Adjusted margins */
  transition: transform 0.1s ease-out;
  z-index: 2;
}

.sm-wrapper .line {
  position: absolute;
  top: 50%;
  width: 100%;
  height: 2px;
  background: #dfe6e9;
  transform: translateY(-50%);
}

.sm-wrapper .footer {
  margin-top: 30px;
  padding-bottom: 40px;
}

.sm-wrapper .reset-btn {
  display: inline-block;
  width: auto;
  padding: 10px 20px;
  background: #dfe6e9;
  border: none;
  font-weight: 600;
  color: #636e72;
  cursor: pointer;
  border-radius: 8px;
}

.sm-wrapper .reset-btn:hover {
  background: #d1d8dc;
  color: #2d3436;
}

.sm-wrapper .person {
  position: absolute;
  top: 0px; /* Adjusted from 10px to align with line better */
  width: 40px;
  height: 60px;
  transition: left 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(-50%);
  z-index: 3;
}

.sm-wrapper .person svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sm-wrapper .controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: nowrap; /* Side-by-side */
  align-items: flex-start;
  z-index: 4;
  position: relative;
  width: 100%;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.sm-wrapper .side {
  background: rgba(255, 255, 255, 0.85); /* Slightly transparent to show background mood */
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  min-width: 0; /* Important for shrinking */
  flex: 1 1 0; /* Equally share space */
  width: 50%; /* Target 50% each */
}

.sm-wrapper h3 {
  margin-top: 0;
  font-size: 1.1em;
  color: #636e72;
  border-bottom: 2px solid #f1f2f6;
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.sm-wrapper button {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 10px;
  border: 1px solid #f1f2f6;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: #2d3436;
  font-size: 0.9em;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sm-wrapper button:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.impact-popup {
  position: absolute;
  pointer-events: none;
  font-weight: bold;
  font-size: 1.2rem;
  z-index: 100;
  animation: floatUp 1s ease-out forwards;
  text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.impact-popup.positive {
  color: #27ae60;
}

.impact-popup.negative {
  color: #e74c3c;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  20% {
    transform: translateY(-20px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-60px) scale(1);
    opacity: 0;
  }
}

.sm-wrapper button:active {
  transform: translateY(0);
}

/* Mobile Specific Optimizations */
@media screen and (max-width: 600px) {
  .sm-wrapper {
    padding: 10px 5px; /* Even tighter padding */
  }
  
  .sm-wrapper h1 {
    font-size: 1.2rem; /* Slightly smaller */
    margin-bottom: 10px; /* Dramatically reduced */
    padding: 0 10px;
  }

  .score-container {
    font-size: 1rem;
    margin-bottom: 5px;
  }
  
  .sm-wrapper .line-container {
    margin: 20px auto; /* Reduced from 30px */
    width: 90%;
    height: 50px; /* More compact simulation area */
  }

  .sm-wrapper .controls {
    margin-top: 10px; /* Reduced from 15px */
    gap: 8px;
    flex-wrap: nowrap; /* Forced side-by-side */
  }
  
  .sm-wrapper .side {
    padding: 8px; /* Tighter padding inside boxes */
    min-width: 0;
    flex: 1 1 0;
    width: 50%;
  }

  .sm-wrapper h3 {
    margin-bottom: 8px;
    font-size: 0.9rem;
    padding-bottom: 5px;
  }

  .sm-wrapper button {
    margin: 3px 0; /* More compact buttons */
    padding: 6px 4px;
    font-size: 0.75rem; /* Smaller button text for mobile side-by-side */
  }

  .sm-wrapper .footer {
    margin-top: 15px;
    padding-bottom: 20px;
  }
}
