
/* ========== ОСНОВНЫЕ СТИЛИ ========== */
.body,
.game-wrapper,
.puzzle-container,
.game-container,
canvas,
.catalog-container,
.puzzle-card {
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none;   /* Safari */
  -khtml-user-select: none;    /* Konqueror HTML */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* Internet Explorer/Edge */
  user-select: none;           /* Стандартное свойство */
  touch-action: manipulation;  /* Оптимизация для сенсорных экранов */
}

/* Отключаем контекстное меню для всей игровой области */
.game-wrapper,
.puzzle-container,
.body,
.catalog-container {
  -webkit-tap-highlight-color: transparent; /* Убираем подсветку при тапе на iOS */
}

/* Для анимированных изображений завершенного пазла */
.puzzle-complete {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

:root {
  --primary-color: #0099FF;
  --primary-light: #67C1FF;
  --primary-dark: #0077CC;
  --secondary-color: #00C9A7;
  --accent-color: #845EC2;
  --bg-gradient-start: #F0F7FF;
  --bg-gradient-end: #E1F0FF;
  --shadow-color: rgba(0, 153, 255, 0.15);
  --shadow-hover: rgba(0, 153, 255, 0.25);
  --puzzle-bg: #FFFFFF;
  --board-color: #F0FAFF;
  --success-color: #38B000;
}
body {
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: #333;
  margin: 0;
  padding: 20px;
  text-align: center;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  box-sizing: border-box;
}

/* ========== КОНТЕЙНЕРЫ ИГРЫ ========== */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 920px;
  max-height: 95vh;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  transition: all 0.4s ease;
}

.game-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 10px;
  width: 100%;
  flex: 1;
}

.puzzle-container {
  width: 100%;
  aspect-ratio: 1/1;
  max-height: 78vh;
  margin: 0;
  padding: 0;
  position: relative;
  background-color: var(--puzzle-bg);
  border-radius: 20px;
  box-shadow: 0 15px 35px var(--shadow-color);
  overflow: hidden;
  transition: all 0.5s ease;
  border: 8px solid white;
}

.puzzle-container:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  padding: 4px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), var(--accent-color));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 5;
}

.puzzle-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

/* ========== СТИЛИ КНОПОК ========== */
.buttons-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-size: 1.2rem;
  box-shadow: 0 10px 20px rgba(72, 52, 212, 0.3);
  position: relative;
  overflow: hidden;
}

.icon-button img {
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1); /* Делаем иконку белой */
  transition: transform 0.3s;
}

.icon-button:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: all 0.4s ease;
}

.icon-button:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 15px 25px rgba(72, 52, 212, 0.4);
}

.icon-button:hover:before {
  left: 100%;
}

.icon-button:active {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 5px 10px rgba(72, 52, 212, 0.3);
}

.icon-button:hover img {
  transform: scale(1.2);
}

#next-level-button {
  background: linear-gradient(135deg, var(--success-color), #00cec9);
  box-shadow: 0 10px 20px rgba(0, 184, 148, 0.3);
  animation: pulse-glow 2s infinite;
}

#next-level-button:hover {
  box-shadow: 0 15px 25px rgba(0, 184, 148, 0.4);
}

#catalog-button {
  background: linear-gradient(135deg, var(--secondary-color), #fd79a8);
  box-shadow: 0 10px 20px rgba(255, 118, 117, 0.3);
}

#catalog-button:hover {
  box-shadow: 0 15px 25px rgba(255, 118, 117, 0.4);
}

/* ========== АНИМАЦИОННЫЕ ЭФФЕКТЫ ========== */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  display: none;
}

.star {
  position: absolute;
  display: block;
  width: 20px;
  height: 20px;
  background-image: url('images/icons/star-icon.svg');
  background-size: contain;
  opacity: 0;
  filter: drop-shadow(0 0 5px gold);
  animation: fall 3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-20px) scale(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(calc(100vh - 20px)) scale(1) rotate(360deg);
    opacity: 0;
  }
}

/* Анимированное изображение при завершении */
.puzzle-complete {
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 15px;
  overflow: hidden;
  filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.25));
  transform: scale(0.95);
  opacity: 0;
  animation: popIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Стили для анимации успеха */
.success-checkmark {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  z-index: 35;
}

.checkmark-svg {
  width: 100%;
  height: 100%;
}

.checkmark-svg path.checkmark {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 6;
  stroke-miterlimit: 10;
  stroke: var(--success-color);
  filter: drop-shadow(0 0 10px rgba(0, 184, 148, 0.6));
  fill: none;
  animation: stroke 0.8s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-svg circle.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 6;
  stroke-miterlimit: 10;
  stroke: var(--success-color);
  fill: none;
  animation: stroke 0.8s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

/* Анимация разблокировки */
.unlock-animation {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  z-index: 40;
}

.unlock-animation .lock {
  width: 100%;
  height: 100%;
  background-image: url('images/icons/lock-icon.svg');
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.6));
  animation: unlockAnimation 1.5s ease-in-out forwards;
}

@keyframes unlockAnimation {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.6));
  }
  50% {
    transform: scale(1.2) rotate(0deg);
    filter: drop-shadow(0 0 15px rgba(108, 92, 231, 0.8));
  }
  100% {
    transform: scale(0) rotate(360deg);
    filter: drop-shadow(0 0 20px rgba(108, 92, 231, 1));
  }
}

.catalog-grid {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  background-image: url('images/icons/catalog-grid-icon.svg');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  z-index: 39;
  filter: drop-shadow(0 0 12px rgba(108, 92, 231, 0.7));
  animation: showCatalog 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 1s;
}

@keyframes showCatalog {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) rotate(-45deg);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.2) rotate(10deg);
  }
  80% {
    transform: translate(-50%, -50%) scale(0.9) rotate(-5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0);
  }
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 25px rgba(0, 184, 148, 0.8);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.5);
    transform: scale(1);
  }
}

/* Анимация появления */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.fade-in {
  animation: fadeIn 0.5s forwards;
}

/* ========== КАТАЛОГ ПАЗЛОВ ========== */
.catalog-container {
  width: 85%;
  max-width: 1000px;
  margin: 20px auto;
  padding: 30px;
  background: white;
  border-radius: 25px;
  box-shadow: 0 20px 40px var(--shadow-color);
  text-align: center;
  position: relative;
  max-height: 85vh;
  overflow: hidden;
  animation: fadeInScale 0.5s forwards;
  border: 8px solid white;
}

.catalog-container:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 17px;
  padding: 4px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), var(--accent-color));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 5;
}

.scrollable-container {
  max-height: calc(85vh - 180px);
  overflow-y: auto;
  padding-right: 20px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollable-container::-webkit-scrollbar {
  display: none;
}

.custom-scrollbar {
  width: 10px;
  position: absolute;
  right: 20px;
  top: 70px;
  bottom: 90px;
  background-color: rgba(230, 230, 250, 0.5);
  border-radius: 10px;
  transition: all 0.3s;
}

.scrollbar-thumb {
  width: 10px;
  background: linear-gradient(to bottom, var(--primary-color), var(--primary-dark));
  border-radius: 10px;
  position: absolute;
  cursor: pointer;
  transition: background-color 0.3s;
}

.scrollbar-thumb:hover {
  background: linear-gradient(to bottom, var(--primary-light), var(--primary-color));
}

/* Сетка пазлов */
.puzzles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 25px;
  margin: 20px 0;
}

.puzzle-card {
  background-color: white;
  border-radius: 18px;
  padding: 15px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
}

.puzzle-card:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  opacity: 0;
  transition: opacity 0.4s;
  z-index: -1;
  border-radius: 16px;
}

.puzzle-card:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
  border-color: rgba(108, 92, 231, 0.3);
}

.puzzle-card:hover:before {
  opacity: 0.05;
}

.puzzle-thumb {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.4s;
  transform: translateY(0);
}

.puzzle-card:hover .puzzle-thumb {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.12);
}

.puzzle-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #666;
  font-size: 16px;
  transition: all 0.3s;
}

.puzzle-card:hover .puzzle-info {
  color: var(--primary-color);
  transform: scale(1.1);
}


/* Стили для индикатора загрузки */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #f8f8f8;
  z-index: 1000;
}
/* ========== прогресс загрузки ========== */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #3498db;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}


@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== АДАПТИВНОСТЬ ========== */
/* Изменил медиа-запросы для лучшей адаптивности на средних экранах */
@media (max-width: 900px) {
  body {
    padding: 15px;
  }
  
  .game-wrapper {
    width: 100%;
    padding: 0 15px;
  }
  
  .puzzle-container {
				
    max-height: 70vh;
    border-width: 6px;
  }
  
  .catalog-container {
    width: 90%;
    padding: 20px;
    border-width: 6px;
  }
  
  .icon-button {
    width: 55px;
    height: 55px;
  }
  
  .icon-button img {
    width: 24px;
    height: 24px;
  }
}

/* Модифицированный медиа-запрос для средней высоты окна */
@media (min-height: 700px) and (max-height: 900px) {
  .puzzle-container {
    max-height: 65vh;
  }
  
  .buttons-container {
    margin-top: 10px;
  }
  
  .icon-button {
    width: 50px;
    height: 50px;
  }
  
  .icon-button img {
    width: 22px;
    height: 22px;
  }
}

/* Горизонтальное расположение при низкой высоте экрана */
@media (max-height: 700px) and (min-width: 500px) {
  .game-wrapper {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
  }
  
  .game-container {
    width: calc(100% - 80px);
    margin-right: 10px;
  }
  
  .puzzle-container {
    max-height: 70vh;
    width: 100%;
    aspect-ratio: 1/1;
  }
  
  .buttons-container {
  flex-direction: column;
  margin-top: 0;
  margin-left: 10px;
  height: 70vh;
  justify-content: center;
}
  
.custom-scrollbar {
  top: 60px;
  bottom: 60px;
}
}

@media (max-width: 600px) {
  .puzzles-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .icon-button {
    width: 50px;
    height: 50px;
  }
  
  .icon-button img {
    width: 22px;
    height: 22px;
  }
  
  .game-wrapper {
    margin-top: 0;
  }
  
  .puzzle-card {
    padding: 8px;
  }
  
  .puzzle-thumb {
    margin-bottom: 8px;
  }
  
  .success-checkmark {
    width: 100px;
    height: 100px;
  }
  
  .catalog-container {
    padding: 15px 10px;
  }
}

@media (max-width: 400px) {
  body {
    padding: 10px;
  }
  
  .game-wrapper {
    padding: 0 10px;
  }
  
  .puzzles-grid {
    grid-template-columns: repeat(2, 1fr); /* Гарантируем 2 колонки */
    gap: 10px;
  }
  
  .puzzle-thumb {
    border-radius: 8px;
  }
  
  /* Уменьшаем размер текста в информации о пазле */
  .puzzle-info {
    font-size: 14px;
  }
  
  .puzzle-container {
    max-height: 70vh;
    border-radius: 15px;
    border-width: 4px;
    aspect-ratio: 1/1; /* Поддерживает квадратную форму */
  }
  
  .icon-button {
    width: 45px;
    height: 45px;
    margin: 3px;
  }
  
  .icon-button img {
    width: 20px;
    height: 20px;
  }
  
  .success-checkmark, .unlock-animation {
    width: 80px;
    height: 80px;
  }
  
  .catalog-container {
    width: 95%;
    border-width: 4px;
  }
}

@media (max-height: 330px) {
  body {
    padding: 3px;
  }
  
  .game-wrapper {
    padding: 0 5px;
  }
  
  .puzzle-container {
    max-height: 85vh;
    border-width: 3px;
  }
  
  .icon-button {
    width: 36px; /* Значительно уменьшаем размер */
    height: 36px;
    margin: 3px;
  }
  
  .icon-button img {
    width: 16px; /* Меньшие иконки */
    height: 16px;
  }
  
  .buttons-container {
    gap: 10px; /* Уменьшаем расстояние между кнопками */
  }
  
  .game-container {
    margin-bottom: 5px;
  }
  
  .success-checkmark, .unlock-animation {
    width: 60px; /* Уменьшаем размер анимаций */
    height: 60px;
  }
}		 