html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  background-color: #ffffff;
  margin: 0;
  font-family: sans-serif;
  color: black;
  text-align: center;
}

header img {
  height: 80px;
  margin: 20px;
}

.toolbar-frame {
  width: 100%;
  background-color: #000;
  border-radius: 12px;
  padding: 15px;
  margin: 20px auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  z-index: 100;
  position: relative;
}

.toolbar, .designs, .color-stats {
  margin: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
}


.frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: #000;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 30px;
  box-sizing: border-box;
}


.grid {
  display: grid;
  /* Will be set by JS */
  /* Will be set by JS */
  gap: 6px;
  justify-content: center;
}

.circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #333333;
  cursor: pointer;
  user-select: none;
  /* box-shadow removed to prevent gray peg glow */
  transition: box-shadow 0.4s ease, transform 0.2s;
}

.circle.colored {
  box-shadow: 0px 0px 6px 2px rgba(255, 255, 255, 0.5);
}

.design-button {
  background-color: #222;
  padding: 8px 12px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
}

button, select {
  background-color: gold;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  color: black;
  font-size: 14px;
}

select {
  appearance: none;
}

.color-stats {
  background-color: #000;
  padding: 10px;
  border-radius: 12px;
  max-width: 800px;
  margin: 20px auto;
}
.color-stats div {
  color: white;
  font-size: 14px;
}

@media (max-width: 768px) {
  .grid {
  max-width: 100%;
  overflow: auto;
  margin: 0 auto;
  }


  .toolbar-frame {
    padding: 10px;
  }

  .color-stats {
    flex-wrap: wrap;
    max-width: 90vw;
  }

  header img {
    height: 60px;
  }

  .design-button {
    font-size: 14px;
    padding: 6px 10px;
  }

  button, select {
    font-size: 13px;
    padding: 5px 10px;
  }

  .color-swatch {
    width: 18px;
    height: 18px;
  }
}

  
.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}

  
}



.frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: #000;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 30px;
  box-sizing: border-box;
}



.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}


.grid {
  display: grid;
  /* Will be set by JS */
  /* Will be set by JS */
  gap: 2px;
  background: black;
  padding: 10px;
  border-radius: 12px;
  max-width: 100%;
  position: relative;
}

body.fullscreen-mode,
body.fullscreen-mode html {
  overflow: hidden !important;
  height: 100% !important;
  width: 100%;
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

.fullscreen-mode 
.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}


body.fullscreen-mode {
  display: block; /* Reset it to avoid interfering */
}

/*body.fullscreen-mode #appContainer {
  transform-origin: center center;
}*/

body.fullscreen-mode #savedDesigns {
  display: none;
}

body.fullscreen-mode .frame,
body.fullscreen-mode 
.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}


#appContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}



body.fullscreen-mode #savedDesigns {
  display: flex;
}

body.fullscreen-mode,
body.fullscreen-mode html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.fullscreen-mode #appContainer {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* ✅ centers vertically */
  transform-origin: center center;
}

body.fullscreen-mode 
.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}


.custom-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  padding: 8px 12px;
  font-size: 14px;
  background-color: #222;
  color: #fff;
  border: 1px solid #666;
  border-radius: 6px;
  cursor: pointer;
}

.dropdown-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #000;
  border: 1px solid #666;
  position: absolute;/*Default for Desktop*/
  z-index: 1000;
  width: 100%;
  top: 110%;
  left: 0;
  border-radius: 6px;
}

.dropdown-menu li {
  padding: 10px;
  color: #fff;
  cursor: pointer;
}

.dropdown-menu li:hover {
  background-color: #333333;
}

.hidden {
  display: none;
}

body.ios-fake-fullscreen {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: white;
}

.selection-overlay {
  background-color: rgba(255, 255, 255, 0.1); /* temporary highlight */
  border: 1px dashed white;
}

body.ios-fake-fullscreen #appContainer {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

body.ios-fake-fullscreen 
.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  overflow-x: auto;
  max-width: 100vw;
  box-sizing: border-box;
}

body.bloom-off .circle.colored {
  box-shadow: none !important;
}

#bloomToggleBtn {
  background-color: #2563eb; /* deep blue */
  color: #fff;
  border: 2px solid #222;
  transition: background 0.15s, border 0.15s;
}
#bloomToggleBtn.active {
  background-color: #ffe066 !important;
  color: #222 !important;
  border: 2px solid #ffc300;
}
.circle.colored {
  box-shadow: 0px 0px 6px 2px rgba(255,255,255,0.5);
}
body.bloom-off .circle.colored {
  box-shadow: none !important;
}

.color-stats {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: auto;
  min-width:320px;
  max-width: 95vw;
  z-index: 100;
  background: #111;
  border-radius: 0 0 12px 12px;
  margin: 0;
  padding: 10px 30px 6px 30px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.13);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 40px;
  min-height: 38px;
}

#coordDisplay {
  color: #ffe066;
  font-size: 18px;
  font-family: monospace;
  padding: 0 24px 0 16px;
  min-width: 80px;
  text-align: left;
}

#colorCountBar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

body {
  padding-bottom: 74px; /* make sure it's as tall as your stats bar */
}
#overlayContainer {
  border: 2px dashed #ffc700;
  box-sizing: border-box;
  transition: box-shadow 0.15s;
  cursor: move;
  user-select: none;
}
#overlayContainer.editing {
  box-shadow: 0 0 0 3px #ffeb99;
}
#overlayContainer .resize-handle {
  width: 18px; height: 18px;
  position: absolute;
  background: #fffcc2;
  border: 2px solid #f7b731;
  border-radius: 50%;
  z-index: 20;
  cursor: nwse-resize;
  box-shadow: 0 0 6px #2223;
}
#overlayContainer .resize-handle.tr { top: -9px; right: -9px; }
#overlayContainer .resize-handle.tl { top: -9px; left: -9px; }
#overlayContainer .resize-handle.br { bottom: -9px; right: -9px; }
#overlayContainer .resize-handle.bl { bottom: -9px; left: -9px; }
.toolbar-overlay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: rgba(255,224,102,0.10); /* subtle gold tint */
  border-radius: 14px;
  padding: 8px 12px;
  margin: 7px 0 0 0;
}
@media (max-width: 900px) {
  .toolbar-main, .toolbar-overlay {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .toolbar-frame {
    gap: 10px;
  }
}
