html, body {
  margin: 0;
  padding: 0;
  font-family: georgia;
  user-select: none;
  background: #000; /* Black behind everything initially */
  height: 100%;
}

/* Body might scroll if canvas is larger than window height */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-top: 60px; /* Height of statsBar + some spacing */
  padding-bottom: 180px; /* adds buffer below game grid */
}

/* Overlay color scheme */
#overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #2f4f4f;
  color: #f0ead6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  text-align: center;
  padding: 40px;
  font-family: 'Public Sans', sans-serif; /* Set Public Sans font */
}

#overlay h1 {
  margin-top: -20px; /* Move the title closer to the top */
  margin-bottom: 50px; /* Reduce spacing below the title */
  font-size: 36px;
  font-family: 'Public sans', sans-serif;
  color: #d2b48c; /* Keep existing color */
  text-align: center;
}

/* Duplicate rules for #overlay h1 - leaving them in place to avoid altering your layout */
#overlay h1 {
  margin-top: -20px; 
  margin-bottom: 10px; 
  font-size: 36px; 
  font-family: 'Public sans', sans-serif; 
  color: #d2b48c; 
  text-align: center; 
}

#overlay h2 {
  margin-top: 0px;
  margin-bottom: 50px;
  font-size: 20px;
  font-family: 'georgia', sans-serif;
  color: #d2b48c;
  text-align: center;
}

/* Within h2, styling for anchor links if needed */
#overlay h2 a {
  display: inline-block;
  color: #d2b48c;
  margin: 0 10px;
  text-decoration: none;
}

#overlay h2 a:hover {
  text-decoration: underline;
}

#overlay p {
  margin-bottom: 20px;
  max-width: 400px;
  line-height: 1.5;
  font-family: 'public sans', sans-serif; 
  color: #f0ead6;
  text-align: center;
}

.p2 { /* custom formatting for text on aboutme page */
  margin-bottom: 30px;
  max-width: 1500px; 
  line-height: 1.8;
  font-family: 'inter'; 
  color: #d2b48c; 
  width: 100%;
}

#overlay button {
  margin-top: 10px;
  padding: 10px 20px;
  font-size: 16px;
  font-family: 'Public Sans', sans-serif;
  cursor: pointer;
  background: #d2b48c;
  color: #000;
  border: none;
}

.color-picker label {
  color: #f0ead6;
}

.rainbow-container label {
  color: #f0ead6;
}

#canvasContainer {
  position: relative;
  display: inline-block;
  transition: border 0.2s ease;
}

#gameCanvas {
  display: block;
}

/* The HUD canvas is absolutely positioned over the gameCanvas */
#hudCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.rainbow-container {
  margin: 10px 0;
  text-align: center;
}

.tagline {
  position: absolute;
  bottom: 10px;
  width: 100%;
  text-align: center;
  color: #ccc;
  font-size: 14px;
}

/* New Styles for the Fixed Top Bar */
#statsBar {
  position: fixed;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  height: 40px;
  background: rgba(128, 128, 128, 0.5);
  color: #f0ead6;
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 10000;
  font-size: 18px;
  padding: 0 20px;
  box-sizing: border-box;
  border-radius: 8px;
  max-width: 1500px;
  width: auto;
  white-space: nowrap;
  font-family: 'Inter', sans-serif; 
}

/* Ensure stats are spaced properly */
#statsBar > div {
  margin: 0 10px;
}

a {
  color: inherit;
  text-decoration: none;
}

a:visited {
  color: inherit; 
}

a:hover {
  text-decoration: underline;
}

/* =========================
   MOBILE-SPECIFIC ADJUSTMENTS
   ========================= */
@media (max-width: 1000px) {
  /* Remove horizontal overflow so it fits phone screens by default */
  body {
    overflow-x: hidden;
  }

  /* Make the top bar use full width and remove horizontal transform */
  #statsBar {
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    flex-wrap: wrap; /* allow items to break into multiple lines */
    height: auto;    /* let bar expand to fit two lines */
  }

  /* Force "Last Clicked" to line #2 */
  #statsBar > #lastClicked {
    flex: 1 1 100%;         /* take entire row on mobile */
    text-align: center;
    margin-top: 5px;        /* small spacing above */
  }

  /* Container fits screen width; still allow pinch-zoom, but avoid double-tap zoom */
  #canvasContainer {
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
    touch-action: manipulation;
  }

  /* Slightly scale down text on narrower screens */
  #overlay h1 {
    font-size: 28px;
  }

  #overlay p,
  #overlay .color-picker {
    font-size: 15px;
  }
}
