html, body {
  margin: 0;
  padding: 0;
  background: #111;
  color: white;
  font-family: sans-serif;
  user-select: none;
  overflow: hidden;
}

.page {
  height: 100vh;         /* десктопы */
  height: 100dvh;        /* мобильные (учёт адресной строки) */
  display: flex;
  flex-direction: column;
}

*,
*::before,
*::after {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

  -webkit-touch-callout: none; /* выключить контекстное меню по долгому тапу */
}

/* ===== ВЕРХНИЙ СЕЛЕКТОР КАРТИНОК ===== */

.image-selector {
  flex: 0 0 auto;
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10;
}

.image-selector .img-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #222;
  color: #fff;
  font-size: 14px;
}

.image-selector .img-btn.active {
  background: #555;
}

/* ===== ЦЕНТР: КАРТИНКА + КАНВАС ===== */

.canvas-wrapper {
  flex: 1 1 auto;
  display: flex;
  align-items: center;   /* центр по вертикали */
  justify-content: center; /* центр по горизонтали */
  padding: 4px 0;
  position: relative;
}

/* ограничиваем размер изображения */
#bg {
  max-width: 70vw;
  max-height: 70vh;
  object-fit: contain;

  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;

  display: block;
}

#canvas {
  position: absolute;
  cursor: crosshair;
  touch-action: none;
}

/* ===== НИЖНИЙ HUD ===== */

.controls {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;

  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);

  padding: 10px 12px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;

  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.controls input[type="color"] {
  padding: 0;
  border: none;
  width: 30px;
  height: 30px;
  background: transparent;
}

.controls input[type="range"] {
  width: 150px;
}

.controls button {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #222;
  color: #fff;
  font-size: 14px;
}

.controls button:hover {
  background: #333;
}

.hint {
  font-size: 12px;
  opacity: 0.7;
  text-align: center;
}

@media (max-width: 768px) {
  .image-selector .img-btn {
    font-size: 18px;
    padding: 10px 14px;
  }

  #bg {
    max-width: 90vw;
    max-height: 55vh;
  }

  .controls {
    padding: 14px 16px;
  }

  .controls label {
    font-size: 18px;
  }

  .controls input[type="color"] {
    width: 40px;
    height: 40px;
  }

  .controls input[type="range"] {
    width: 220px;
  }

  .controls button {
    font-size: 18px;
    padding: 10px 18px;
    border-radius: 10px;
  }

  .hint {
    font-size: 14px;
  }
}


/* модальное приветствие */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  max-width: 90vw;
  background: #222;
  color: #fff;
  padding: 20px 24px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  text-align: left;
  font-size: 16px;
  line-height: 1.5;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.modal-content button {
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #4caf50;
  color: #fff;
  font-size: 16px;
}

.modal-content button:hover {
  background: #45a047;
}

/* на мобилке текст чуть крупнее */
@media (max-width: 768px) {
  .modal-content {
    font-size: 18px;
  }

  .modal-content button {
    font-size: 18px;
    padding: 10px 18px;
  }
}

/* Разрешаем контекстное меню на превью для сохранения */
#save-preview-img {
  -webkit-touch-callout: default !important;
  -webkit-user-select: auto !important;
  user-select: auto !important;
  pointer-events: auto !important;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}