* {
  box-sizing: border-box;
}

:root {
  --surface: #12141c;
  --grid-dot: rgba(50, 52, 62, 0.45);
  --green: #7ed957;
  --green-deep: #3ea24a;
  --poison: #c8ff4d;
  --red: #ff5a6e;
  --panel: rgba(20, 23, 33, 0.92);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SN Pro", system-ui, -apple-system, sans-serif;
  color: #e8eaf0;
  background-color: var(--surface);
  background-image: radial-gradient(var(--grid-dot) 1px, var(--surface) 1px);
  background-size: 20px 20px;
  display: flex;
  justify-content: center;
  overscroll-behavior: none;
}

.game {
  width: min(1000px, 100%);
  padding: 12px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.hud__item {
  background: var(--panel);
  border: 1px solid rgba(126, 217, 87, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9aa2b5;
  white-space: nowrap;
}

.hud__item b {
  color: var(--poison);
  font-size: 16px;
  font-weight: 600;
}

.hud__hearts {
  color: var(--red);
  font-size: 17px;
  letter-spacing: 2px;
  margin-left: auto;
}

.hud__hearts .dim {
  color: #444a5c;
}

.hud__ammo .bar {
  width: 110px;
  height: 12px;
  background: #232735;
  border-radius: 6px;
  overflow: hidden;
  display: block;
}

.hud__ammo .bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green-deep), var(--poison));
  border-radius: 6px;
  transition: width 0.08s linear;
}

/* ---------- Stage / canvas ---------- */
.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(126, 217, 87, 0.2);
  line-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0c1713;
  touch-action: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 9, 0.72);
  backdrop-filter: blur(4px);
  line-height: 1.5;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.overlay--hidden {
  display: none;
}

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

.card {
  width: min(560px, 100%);
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(126, 217, 87, 0.35);
  border-radius: 20px;
  padding: 26px 26px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.card__emoji {
  font-size: 40px;
  letter-spacing: 6px;
  margin-bottom: 6px;
  animation: bob 2.2s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

.card h1 {
  margin: 0 0 10px;
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: clamp(26px, 6vw, 42px);
  letter-spacing: 0.08em;
  color: var(--green);
  text-shadow: 0 0 18px rgba(126, 217, 87, 0.5);
}

.card h1 span {
  color: var(--poison);
}

.card__title--over {
  color: var(--red) !important;
  text-shadow: 0 0 18px rgba(255, 90, 110, 0.5) !important;
}

.card__lead {
  margin: 0 0 14px;
  color: #b8bdcf;
  font-size: 15px;
}

.card__keys {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
  color: #9aa2b5;
  font-size: 14px;
}

kbd {
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: 12px;
  background: #232735;
  border: 1px solid #3a4053;
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 2px 7px;
  color: #e8eaf0;
  margin: 0 1px;
}

.card__score {
  margin: 4px 0;
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: 18px;
  color: #b8bdcf;
}

.card__score b {
  color: var(--poison);
  font-size: 24px;
}

.card__score--best b {
  color: #ffd166;
}

.btn {
  font-family: "SN Pro", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #0c1713;
  background: linear-gradient(180deg, var(--poison), var(--green));
  border: none;
  border-radius: 14px;
  padding: 14px 34px;
  cursor: pointer;
  box-shadow: 0 8px 0 #3b7a37, 0 14px 26px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #3b7a37, 0 6px 14px rgba(0, 0, 0, 0.45);
}

/* ---------- Footer help ---------- */
.help {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  font-size: 13px;
  color: #8a91a5;
  font-family: "JetBrains Mono", Menlo, monospace;
}

.help b {
  color: var(--green);
}

/* ---------- Touch controls ---------- */
.touch {
  display: none;
}

@media (pointer: coarse) {
  .touch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    user-select: none;
    -webkit-user-select: none;
  }

  .dpad {
    position: relative;
    width: 168px;
    height: 168px;
  }

  .dpad__b {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    border: 1px solid rgba(126, 217, 87, 0.35);
    background: var(--panel);
    color: var(--green);
    font-size: 20px;
    cursor: pointer;
    touch-action: none;
  }

  .dpad__b:active {
    background: #2b3a2a;
  }

  .dpad__up {
    left: 56px;
    top: 0;
  }

  .dpad__left {
    left: 0;
    top: 56px;
  }

  .dpad__down {
    left: 56px;
    top: 112px;
  }

  .dpad__right {
    left: 112px;
    top: 56px;
  }

  .fire {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 3px solid rgba(200, 255, 77, 0.6);
    background: radial-gradient(circle at 35% 30%, #a4e83f, #4d8f2a);
    color: #0c1713;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    touch-action: none;
  }

  .fire:active {
    transform: scale(0.94);
  }

  .help {
    display: none;
  }
}
