*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { overflow: hidden; width: 100%; height: 100%; }
body { background: #fff; }
#container { width: 100vw; height: 100vh; }

/* ── PROGRESS ─────────────────────────────────────── */
#progress-bar {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 1000;
  font-family: Arial, sans-serif;
  transition: opacity 0.3s ease;
}
#progress-bar svg   { width: 300px; height: 75px; }
#progress-bar progress { width: 300px; height: 14px; margin-top: 15px; }
#progress-text {
  margin-top: 10px; font-size: 12px; color: #333;
  user-select: none; -webkit-user-select: none;
}
#progress-error {
  position: absolute; bottom: 38px; left: 0; width: 100%;
  text-align: center; font-size: 12px; color: #b00020;
  display: none; padding: 0 10px;
  user-select: none; -webkit-user-select: none;
}

/* ── COLOR CONTROLS ───────────────────────────────── */
.color-controls {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  max-width: calc(100vw - 32px);
  overflow: visible;
}
.color-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── COLOR BUTTON ─────────────────────────────────── */
.color-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 10px;
  background: #fff;
  border: 1.5px solid #d0d0d0;
  border-radius: 100px;
  cursor: pointer;
  font-size: 13px;
  font-family: Arial, sans-serif;
  color: #333;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s cubic-bezier(.34,1.56,.64,1),
    color 0.18s ease;
  outline: none;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.color-btn:hover {
  background: #f5f5f5;
  border-color: #bbb;
  box-shadow: 0 3px 12px rgba(0,0,0,0.13);
}
.color-btn:active {
  transform: scale(0.93);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.color-btn.active {
  border-color: currentColor;
  box-shadow: 0 0 0 2px currentColor, 0 3px 10px rgba(0,0,0,0.12);
}

/* ── COLOR DOT ────────────────────────────────────── */
.color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1);
}
.color-btn:hover  .color-dot { transform: scale(1.2); }
.color-btn.active .color-dot { transform: scale(1.15); border-color: rgba(0,0,0,0.25); }

/* ── RIPPLE ───────────────────────────────────────── */
.color-btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  transform: scale(0);
  animation: ripple-anim 0.45s linear;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

/* ── CONTROLS HINT ────────────────────────────────── */
#controls-hint,
#controls-hint-mobile {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 13px;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 2000;
  max-width: 220px;
  line-height: 1.5;
  transition: opacity 0.35s ease, transform 0.35s ease;
  user-select: none; -webkit-user-select: none;
}
#controls-hint h4,
#controls-hint-mobile h4 {
  font-size: 14px; font-weight: bold; margin-bottom: 6px;
}
#controls-hint p,
#controls-hint-mobile p { margin: 2px 0; }

#controls-hint.show,
#controls-hint-mobile.show {
  animation: hintFadeIn 0.5s ease-out both;
}
@keyframes hintFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ── MOBILE ───────────────────────────────────────── */
@media (max-width: 768px) {

  /* контейнер: grid 3 колонки, перевёрнут — строки растут вверх */
  .color-controls {
    bottom: 16px;
    transform: translateX(-50%) scaleY(-1);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: calc(100vw - 32px);
    max-width: 420px;
  }

  /* каждую кнопку переворачиваем обратно */
  .color-btn {
    transform: scaleY(-1);
    justify-content: center;
    padding: 14px 10px;
    font-size: 15px;
    border-radius: 14px;
    gap: 8px;
  }

  /* переопределяем состояния с учётом флипа */
  .color-btn:hover {
    transform: scaleY(-1);
  }
  .color-btn:active {
    transform: scaleY(-1) scale(0.93);
  }
  .color-btn.active {
    transform: scaleY(-1);
  }

  .color-dot {
    width: 18px;
    height: 18px;
  }

  /* хинт поднимаем выше кнопок */
  #controls-hint-mobile {
    bottom: 180px;
  }
}