:root {
  --bg: #121212;
  --panel: #222222;
  --text: #ffffff;
  --accent: #007acc;
  --danger: #d32f2f;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* --- Main Screen --- */
#main-screen {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
}

#empty-state {
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}
#empty-state h1 { font-size: 1.5rem; margin-bottom: 8px; }
#empty-state p { font-size: 0.9rem; }

/* --- Fullscreen Hint --- */
#fullscreen-hint {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1rem;
  pointer-events: none;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.5s ease;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
#fullscreen-hint.hidden-hint {
  opacity: 0;
}

/* --- Menu Overlay --- */
#menu {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#menu.hidden {
  opacity: 0;
  pointer-events: none;
}

/* =========================================
   BASE STYLES: NORMAL (1.0x) SIZE 
   (Used for Desktop & Tablet)
   ========================================= */

.menu-content {
  background: var(--panel);
  padding: 24px;
  border-radius: var(--radius);
  width: 90%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

.menu-title {
  text-align: center;
  font-size: 1.2rem;
  color: #bbb;
}

/* Quick Colors */
.quick-colors-container h3 {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 10px;
}
.quick-colors {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.quick-color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #555;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}
.quick-color-btn:active {
  transform: scale(0.85);
}

/* Controls & Buttons */
.controls { display: flex; gap: 10px; width: 100%; }
.double-col { display: flex; gap: 10px; }

.btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  color: #fff;
  background: #444;
  transition: transform 0.1s, background 0.2s;
}

.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: #555; }

/* Invisible Native Color Picker */
#color-picker {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Slider */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slider-group label {
  font-size: 0.9rem;
  color: #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
input[type="range"] {
  width: 100%;
  height: 24px;
  accent-color: var(--accent);
}

/* Tiny Default Button */
.btn-tiny {
  background: #444;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s;
}
.btn-tiny:active {
  transform: scale(0.9);
  background: #666;
}

/* Color List Palette */
.palette-container h3 {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 10px;
}
#color-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-height: 150px;
  overflow-y: auto;
}
.color-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #555;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.remove-btn {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: 1px solid #222;
}

/* =========================================
   MOBILE OVERRIDES: 1.5x SCALED + LOCKED FULLSCREEN
   (Triggers on screens 768px wide or smaller)
   ========================================= */

@media (max-width: 768px) {
  
  /* Lock the menu to the absolute edges of the screen, no full-page scrolling */
  .menu-content {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Adapts to mobile address bars shrinking/growing */
    max-width: 100%;
    border-radius: 0;
    padding: 24px 20px; /* Safe padding from edges */
    gap: 16px; /* Optimized gap so everything fits nicely */
    overflow: hidden; /* Prevent the main container from scrolling */
    justify-content: space-between; /* Spread elements out cleanly */
  }

  .menu-title {
    font-size: 1.8rem;
    margin: 0;
  }

  .quick-colors-container h3, 
  .palette-container h3 {
    font-size: 1.35rem;
    margin-bottom: 8px;
  }

  /* Keep quick colors perfectly horizontal */
  .quick-colors {
    gap: 8px;
    justify-content: space-between;
  }

  .quick-color-btn {
    width: 48px;
    height: 48px;
    border-width: 3px;
    flex-shrink: 0;
  }

  /* Buttons stay side-by-side but grow to 1.5x scale */
  .controls, .double-col {
    gap: 15px;
    flex-direction: row; 
  }

  .btn {
    padding: 16px;
    border-radius: 12px;
    font-size: 1.3rem; /* Scaled up, but fits side-by-side */
  }

  .slider-group {
    gap: 12px;
  }

  /* Default button stays pinned to the right side of the label to save height */
  .slider-group label {
    font-size: 1.35rem;
    flex-direction: row;
    align-items: center;
  }

  input[type="range"] {
    height: 32px;
    margin: 0;
  }

  .btn-tiny {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 1.1rem;
    width: auto;
  }

  /* --- THE MAGIC FIX: Only the color box expands and scrolls --- */
  .palette-container {
    flex: 1; /* Takes up all remaining screen space */
    min-height: 0; /* Prevents it from breaking out of the 100vh screen */
    display: flex;
    flex-direction: column;
  }

  #color-list {
    flex: 1; /* Fills the container */
    overflow-y: auto; /* Adds a scrollbar ONLY to the colors when full */
    gap: 16px;
    max-height: none; 
    align-content: flex-start; /* Keeps colors stacked at the top */
    padding-bottom: 10px; /* Slight padding so swatches aren't cut off */
  }

  .color-swatch {
    width: 64px;
    height: 64px;
    border-width: 3px;
  }

  .remove-btn {
    top: -4px; 
    right: -4px;
    width: 28px; 
    height: 28px;
    font-size: 16px;
    border-width: 2px;
  }
}
