:root {
  color-scheme: dark;
  --panel: rgba(20, 20, 24, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8e8ec;
  --muted: #9a9aa4;
  --accent: #7aa5ff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#screen {
  position: fixed;
  inset: 0;
  background-color: #ffffff;
}

#overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* ---- Control panel ---- */

#controls {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%);
  width: min(92vw, 400px);
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#controls.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  justify-items: center;
}

.swatch {
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch:active {
  transform: scale(0.92);
}

.swatch.selected {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.15),
    0 0 0 2px var(--panel),
    0 0 0 4px var(--accent);
}

.swatch.custom {
  appearance: none;
  -webkit-appearance: none;
  background: conic-gradient(#ff5757, #ffe066, #5ad469, #4dd0e1, #5b9dff, #b57bee, #ff5757);
  overflow: hidden;
}

.swatch.custom::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.swatch.custom::-webkit-color-swatch { border: none; opacity: 0; }
.swatch.custom::-moz-color-swatch { border: none; opacity: 0; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

.icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ---- Brightness slider ---- */

#brightness {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

#brightness::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

#brightness::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ---- Fullscreen button ---- */

#fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

#fullscreen:active {
  background: rgba(255, 255, 255, 0.14);
}

#fullscreen .compress { display: none; }
body.is-fullscreen #fullscreen .expand { display: none; }
body.is-fullscreen #fullscreen .compress { display: block; }

/* ---- Hint toast ---- */

#hint {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateX(-50%) translateY(8px);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
