* {
  box-sizing: border-box;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, #8ed7ff 0 22%, #6fb9ea 42%, #4b8fc7 100%);
  font-family: "Courier New", "Microsoft YaHei", monospace;
  color: #fff;
}

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

#gameWrap {
  position: relative;
  width: min(100vw, 1280px);
  height: min(100vh, 720px);
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  border: 8px solid #2b1d12;
  box-shadow:
    0 0 0 6px #6b4427,
    0 24px 80px rgba(0, 0, 0, .45);
  background: #78c850;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.topBar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  text-shadow: 3px 3px 0 rgba(0,0,0,.45);
  font-weight: 900;
  letter-spacing: 1px;
}

.panel {
  padding: 9px 12px;
  border: 4px solid #2b1d12;
  background:
    linear-gradient(135deg, rgba(97, 64, 36, .95), rgba(52, 32, 19, .95));
  box-shadow:
    inset 3px 3px 0 rgba(255,255,255,.18),
    inset -3px -3px 0 rgba(0,0,0,.25),
    4px 4px 0 rgba(0,0,0,.28);
  font-size: 14px;
  white-space: nowrap;
}

.health {
  display: flex;
  gap: 5px;
  align-items: center;
}

.heart {
  width: 19px;
  height: 19px;
  background: #e73a36;
  border: 3px solid #6c1010;
  box-shadow: inset 3px 3px 0 rgba(255,255,255,.2);
}

.heart.empty {
  background: #3e2222;
  border-color: #160909;
}

.bottomHelp {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 4px solid #2b1d12;
  background: rgba(20, 18, 14, .72);
  box-shadow: 4px 4px 0 rgba(0,0,0,.28);
  font-size: 13px;
  color: #f7edca;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
  min-width: 860px;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(rgba(26, 19, 12, .45), rgba(26, 19, 12, .65));
  pointer-events: auto;
}

.menu {
  width: min(92%, 740px);
  padding: 28px;
  text-align: center;
  border: 8px solid #2b1d12;
  background:
    linear-gradient(135deg, #7d522d 0 50%, #5b351d 50% 100%);
  box-shadow:
    inset 6px 6px 0 rgba(255,255,255,.16),
    inset -6px -6px 0 rgba(0,0,0,.22),
    10px 10px 0 rgba(0,0,0,.35);
}

.menu h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 6vw, 58px);
  line-height: .95;
  color: #ffe275;
  text-shadow:
    4px 4px 0 #332112,
    7px 7px 0 rgba(0,0,0,.35);
  letter-spacing: 2px;
}

.menu p {
  margin: 10px auto;
  color: #fff3cc;
  line-height: 1.55;
  max-width: 620px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
}

.btn {
  display: inline-block;
  margin-top: 18px;
  padding: 14px 34px;
  border: 5px solid #2b1d12;
  background:
    linear-gradient(180deg, #83d653, #3f9b32);
  color: #10220e;
  font-weight: 900;
  font-size: 22px;
  font-family: inherit;
  cursor: pointer;
  box-shadow:
    inset 4px 4px 0 rgba(255,255,255,.25),
    inset -4px -4px 0 rgba(0,0,0,.22),
    5px 5px 0 rgba(0,0,0,.36);
  text-transform: uppercase;
}

.btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow:
    inset 4px 4px 0 rgba(255,255,255,.18),
    inset -4px -4px 0 rgba(0,0,0,.28),
    2px 2px 0 rgba(0,0,0,.36);
}

.credit {
  margin-top: 16px;
  font-size: 12px;
  color: #f5deb1;
  opacity: .9;
}

@media (max-width: 720px) {
  #gameWrap {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border: none;
    box-shadow: none;
  }

  .bottomHelp {
    min-width: auto;
    width: calc(100% - 24px);
    font-size: 10px;
  }

  .topBar {
    align-items: flex-start;
    gap: 6px;
  }

  .panel {
    font-size: 10px;
    padding: 7px 8px;
  }

  .heart {
    width: 14px;
    height: 14px;
  }
}
