body {
  background-color: #111;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 16px;
  box-sizing: border-box;
  min-height: 100vh;
  flex-wrap: wrap;
}

.rulesModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.rulesPanel {
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: #08141a;
  border: 2px solid #00d2ff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  color: #e8f7ff;
  padding: 18px 20px;
  box-sizing: border-box;
}

.rulesPanel h1 {
  margin: 0 0 12px;
  font: 700 24px monospace;
  color: #33ff33;
}

.rulesText {
  margin: 0;
  white-space: pre-wrap;
  font: 14px/1.5 monospace;
  color: #d8f5ff;
}

#startGameButton {
  margin-top: 14px;
  border: 1px solid #33ff33;
  background: #12331a;
  color: #ffffff;
  padding: 8px 14px;
  font: 700 14px monospace;
  cursor: pointer;
}

#hud {
  z-index: 10;
  pointer-events: none;
  padding: 10px 12px;
  border: 2px solid #00d2ff;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font: 14px monospace;
  line-height: 1.5;
  min-width: 260px;
  width: 300px;
  max-height: none;
  overflow: visible;
  box-sizing: border-box;
}

#hudControls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  /*This Allows clicks, hovers, and other events to be detected on the element. */
  pointer-events: auto;
}

#hudControls button {
  border: 1px solid #00d2ff;
  background: #08212d;
  color: #ffffff;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
}

#hudRoomAlert {
  min-height: 20px;
  margin-top: 6px;
  color: #d7a8ff;
  font-weight: bold;
}

#hudShortcuts {
  margin-top: 4px;
  padding: 6px;
  border: 1px solid rgba(0, 210, 255, 0.15);
  background: rgba(255, 255, 255, 0.03);
  color: #bfe9ff;
  font-size: 12px;
  line-height: 1.4;
}

#enemyInfo {
  margin-top: 8px;
  max-height: none;
  overflow: visible;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 6px;
  border: 1px solid rgba(0, 210, 255, 0.08);
  pointer-events: none;
}

.legendRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legendSwatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.legendText {
  flex: 1 1 auto;
  color: #cfefff;
}

.legendCount {
  color: #ffd4a3;
  min-width: 26px;
  text-align: right;
}

canvas {
  background-color: #051a05;
  border: 2px solid #33ff33;
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  width: 800px;
  height: auto;
}

/* to make it responsive */
#hud {
  max-width: 95%;
  width: 300px;
  min-width: unset;
}

@media (max-width: 600px) {
  body {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px;
  }
  #hud {
    width: 100%;
  }
  canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
  }
}
