html, body {
  margin: 0;
  height: 100%;
  background: #1d261b;
  overflow: hidden;
  font-family: system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#wrap {
  --s: 3;
  position: relative;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(var(--s) * 3px);
  pointer-events: none;
  font-size: calc(var(--s) * 5.5px);
  color: #fff;
  text-shadow: 0 1px 0 #2a2228, 1px 0 0 #2a2228, -1px 0 0 #2a2228, 0 -1px 0 #2a2228;
}

#hud[hidden] { display: none; }
#hearts { letter-spacing: 1px; }
#score { font-weight: 700; }

#task {
  display: flex;
  align-items: center;
  gap: calc(var(--s) * 3px);
  background: rgba(255, 255, 255, 0.92);
  color: #2a2228;
  text-shadow: none;
  border: calc(var(--s) * 1px) solid #2a2228;
  border-radius: calc(var(--s) * 4px);
  padding: calc(var(--s) * 1.5px) calc(var(--s) * 4px);
  font-weight: 700;
}

#taskIcon {
  width: calc(var(--s) * 17px);
  height: calc(var(--s) * 11.5px);
  image-rendering: pixelated;
}

.bar {
  margin-top: calc(var(--s) * 1.5px);
  height: calc(var(--s) * 2.5px);
  background: #d9d3cc;
  border-radius: 99px;
  overflow: hidden;
}

#taskBar {
  height: 100%;
  width: 100%;
  background: #6cbf4a;
}

#task.hurry #taskBar { background: #e5533d; }
#task.hurry { animation: shake 0.3s infinite; }
#task.ride #taskBar { background: #f08a24; }

@keyframes shake {
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(29, 38, 27, 0.72);
  color: #fff;
  font-size: calc(var(--s) * 5.5px);
  padding: 16px;
}

.overlay[hidden] { display: none; }
.overlay h1 { margin: 0 0 0.4em; font-size: 2em; color: #ffe27a; text-shadow: 0 3px 0 #2a2228; }
.overlay p { margin: 0.3em 0; }
.overlay .big { font-size: 1.6em; font-weight: 700; }
.overlay .small { opacity: 0.85; font-size: 0.8em; line-height: 1.5; }

.overlay button {
  margin-top: 0.8em;
  font: inherit;
  font-weight: 700;
  font-size: 1.2em;
  padding: 0.4em 1.4em;
  border: 3px solid #2a2228;
  border-radius: 12px;
  background: #ffe27a;
  color: #2a2228;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a2228;
}

.overlay button:active { transform: translateY(3px); box-shadow: 0 1px 0 #2a2228; }
