* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #1a1f16;
  color: #eef0e6;
  font-family: "Segoe UI", "Avenir", system-ui, sans-serif;
  display: grid;
  place-items: center;
}

#app {
  width: 940px;
  max-width: 98vw;
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  background: #2c3324;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  white-space: nowrap;
}

.pill.danger { background: #5a2c22; color: #f0b0a0; }

.weapon-pill {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar {
  display: inline-block;
  width: 40px;
  height: 8px;
  background: #142016;
  border-radius: 999px;
  overflow: hidden;
}

.bar.small { width: 34px; height: 6px; }

.bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7a8a4a, #a9502f);
  transition: width 0.2s ease;
}

/* ---------- Stage ---------- */
#stage { position: relative; }

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  background: #3b4a34;
}

/* ---------- Interact prompt ---------- */
#interactPrompt {
  position: absolute;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  background: rgba(20, 24, 16, 0.9);
  border: 1px solid #4a5540;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

#channelBar {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  width: 140px;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  overflow: hidden;
}

#channelFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a9502f, #e2572b);
}

/* ---------- Toast ---------- */
#toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 24, 16, 0.94);
  border: 1px solid #4a5540;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 90%;
  text-align: center;
}

/* ---------- Controls ---------- */
#controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.btn {
  background: #2c3324;
  color: #eef0e6;
  border: 1px solid #4a5540;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:hover { background: #384030; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: #7a8a4a; border-color: #7a8a4a; color: #131810; font-weight: bold; }
.btn.primary:hover { background: #8c9d57; }
.btn.danger { border-color: #8c4a3f; color: #f0b0a0; }
.btn.active { background: #7a8a4a; color: #131810; font-weight: bold; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 8, 0.86);
  display: grid;
  place-items: center;
  z-index: 20;
}

.panel {
  background: #202619;
  border: 1px solid #4a5540;
  border-radius: 20px;
  padding: 28px 34px;
  width: min(460px, 92vw);
  text-align: center;
}

.panel h1 { margin: 0 0 10px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.panel h2 { margin: 0 0 14px; }

.title-icon {
  width: 1.4em;
  height: 1.4em;
  object-fit: cover;
  border-radius: 10px;
  vertical-align: middle;
}

.subtle { opacity: 0.7; font-size: 13px; }
.warning { color: #e2a05a; }

.controls-legend {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  text-align: left;
  font-size: 13px;
}

.controls-legend div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #2c3324;
  border-radius: 10px;
  padding: 8px 12px;
}

.controls-legend strong { color: #cfd6bf; }
.controls-legend span { opacity: 0.75; }

#difficultyPick {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 16px 0 6px;
}

#nextLevelBtn, #playAgainBtn { width: 100%; margin-top: 10px; }

#endOverlay.won .panel { border-color: #7a8a4a; }

.hidden { display: none !important; }
