
:root {
  --stick-color: #333;
  --bg-color: #f4f4f4;
  --pace-speed: 10s;
}

.leg {
  width: 3px;
  height: 30px;
  background: var(--stick-color);
  position: absolute;
  top: 67px;
  /* Pivot from the hip, not the center */
  transform-origin: top center; 
}

/* Specific leg positioning */
.leg-l { 
  left: 18px; 
  animation: restless-walk 0.25s infinite alternate ease-in-out; 
}

.leg-r { 
  left: 22px; 
  animation: restless-walk 0.25s infinite alternate-reverse ease-in-out; 
  animation-delay: 0.1s; /* Offset for a more natural stride */
}

/* Improved restless leg animation */
@keyframes restless-walk {
  0% {
    transform: rotate(20deg) height(30px);
  }
  100% {
    transform: rotate(-25deg) height(28px); /* Slight lift/shorten to simulate a step */
  }
}

.scene {
  background: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  /* height: 100%; */
  overflow: hidden;
  border-bottom: 3px double #666;
  /* border-style: ridge; */
  box-shadow: 0 3px 0 #999 inset;
}


.stickman {
  position: relative;
  width: 40px;
  height: 80px;
  animation: 
    pace var(--pace-speed) infinite ease-in-out,
    body-bob 0.25s infinite alternate; /* Adds a vertical bounce to the walk */
}

@keyframes body-bob {
  from { transform: translateY(0); }
  to { transform: translateY(2px); }
}
/* Body parts styling */
.head {
  width: 24px;
  height: 24px;
  border: 3px solid var(--stick-color);
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  animation: jitter 0.5s infinite; /* Nervous twitch */
}

.torso {
  width: 3px;
  height: 40px;
  background: var(--stick-color);
  position: absolute;
  top: 27px;
  left: 50%;
  transform: translateX(-50%);
}

.arm, .leg {
  width: 3px;
  background: var(--stick-color);
  position: absolute;
}

.arm { height: 25px; top: 35px; }
.leg { height: 30px; top: 67px; }

.arm-l { left: 10px; transform: rotate(15deg); }
.arm-r { right: 10px; transform: rotate(-15deg); }
.leg-l { left: 12px; transform: rotate(5deg); animation: walk-l 0.5s infinite alternate; }
.leg-r { right: 12px; transform: rotate(-5deg); animation: walk-r 0.5s infinite alternate; }

.sigh-bubble {
  position: relative;
  top: -20px;
  left: 40px;
  font-family: sans-serif;
  font-size: 12px;
  font-style: italic;
  color: #666;
  opacity: 0;
  animation: sigh-anim 10s infinite;
}

@keyframes pace {
  0%,100% { 
    left: 0%; 
    transform: scaleX(1); 
  }
  
  35% { 
    left: 35%; 
    transform: scaleX(1); 
  } 

  70% { 
    left: -35%; 
    transform: scaleX(-1); 
    -webkit-transform: scaleX(-1);
  } 

  95% { 
    left: 0%; 
    transform: scaleX(-1); 
    -webkit-transform: scaleX(-1);
  } 
}
/* Subtle jitter to show uneasiness */
@keyframes jitter {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-52%) translateY(1px); }
}

/* Walking shuffle */
@keyframes walk-l { to { transform: rotate(-15deg); } }
@keyframes walk-r { to { transform: rotate(15deg); } }

/* The sigh happens periodically */
@keyframes sigh-anim {
  0%, 20%, 40%, 60%, 80%, 100% { opacity: 0; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-10px);left: 40px; }
  75% { opacity: 1; transform: translateY(-10px);left: -40px; }
}