:root {
  --bg: #0d1210;
  --panel: #152019;
  --ink: #e8f5ec;
  --muted: #7a9a88;
  --accent: #f0c75e;
  --player: #4ecdc4;
  --enemy: #ff6b4a;
  --hp: #3dce7a;
  --border: #2a4036;
  --font: "Press Start 2P", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, #1a2e24 0%, transparent 60%),
    var(--bg);
}

#game-wrap {
  position: relative;
  width: min(100vw, calc(100vh * 4 / 3));
  max-width: 960px;
  aspect-ratio: 4 / 3;
  box-shadow: 0 0 0 4px var(--border), 0 20px 60px rgba(0, 0, 0, 0.55);
  background: #000;
}

#game {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

#hud {
  position: absolute;
  z-index: 5;
  inset: 0 0 auto 0;
  padding: 10px 12px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
  font-size: 9px;
  line-height: 1.4;
  text-shadow: 1px 1px 0 #000;
}

#hud.hidden {
  display: none;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hp-bar {
  flex: 1;
  max-width: 160px;
  height: 12px;
  border: 2px solid var(--ink);
  background: #1a1a1a;
  position: relative;
}

#hud-hp-fill {
  height: 100%;
  width: 100%;
  background: var(--hp);
  transition: width 0.15s linear;
}

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 11, 0.82);
  padding: 16px;
  pointer-events: auto;
}

.overlay.hidden {
  display: none;
}

.panel {
  text-align: center;
  max-width: 420px;
  padding: 28px 24px;
  background: var(--panel);
  border: 4px solid var(--border);
  box-shadow: inset 0 0 0 2px #1e332a;
}

.panel.hidden {
  display: none;
}

.panel h1 {
  margin: 0 0 16px;
  font-size: clamp(18px, 4vw, 28px);
  color: var(--accent);
  letter-spacing: 1px;
  line-height: 1.3;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: clamp(14px, 3vw, 20px);
  color: var(--accent);
  line-height: 1.4;
}

.blurb {
  margin: 0 0 18px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1.7;
}

.controls {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  font-size: 8px;
  color: var(--ink);
  line-height: 2;
  text-align: left;
}

.controls kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid var(--muted);
  color: var(--player);
  font-family: inherit;
  font-size: 8px;
}

.hi-score {
  margin: 0 0 20px;
  font-size: 9px;
  color: var(--accent);
}

.panel p {
  margin: 0 0 18px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1.7;
}

.btn {
  display: block;
  width: 100%;
  margin: 0 auto 10px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 11px;
  color: #102018;
  background: var(--accent);
  border: 3px solid #fff3c4;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--muted);
}

@media (max-width: 520px) {
  #hud { font-size: 7px; }
  .controls { font-size: 7px; }
  .btn { font-size: 9px; padding: 12px; }
}
