* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #ffffff;
  color: #333;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#welcomeScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.welcome-content {
  background: white;
  padding: 20px 25px;
  border-radius: 20px;
  max-width: 450px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.welcome-content h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: #1a1a1a;
}

.welcome-content > p {
  color: #666;
  margin-bottom: 15px;
  font-size: 0.85rem;
}

.rules {
  background: #f8f9fa;
  padding: 15px 18px;
  border-radius: 12px;
  margin: 15px 0;
  text-align: left;
}

.rules h3 {
  margin-bottom: 15px;
  color: #1a1a1a;
}

.rules ul {
  margin-left: 20px;
}

.rules li {
  margin: 6px 0;
  line-height: 1.4;
  color: #444;
  font-size: 0.85rem;
}

.vpn-notice {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 10px 0;
  text-align: center;
}

.vpn-notice p {
  color: #92400e;
  font-size: 0.75rem;
  line-height: 1.3;
  margin: 0;
}

.vpn-notice strong {
  font-weight: 700;
}

/* === ГЛОБАЛЬНЫЕ СТИЛИ (для ПК и телефонов) === */
.social-links {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 15px 20px;
  border-radius: 12px;
  margin: 15px 0;
  text-align: center;
}

.social-links h3 {
  color: white;
  font-size: 0.9rem;
  margin-bottom: 12px;
  font-weight: 500;
}

.social-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.social-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 0.2s, box-shadow 0.2s;
  color: white;
}

.social-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.social-btn.telegram {
  background: #229ED9;
}

.social-btn.tiktok {
  background: #000000;
}

.social-btn span {
  font-size: 1.2rem;
}

.warning {
  color: #dc2626;
  font-weight: 600;
  margin: 15px 0;
  font-size: 0.85rem;
}

.btn-primary {
  background: #2563eb;
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #6b7280;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
}

.btn-share {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-share:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
  background: #dc2626;
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  margin: 10px 0;
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px 10px;
  color: #666;
}

header {
  background: white;
  padding: 15px 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  z-index: 10;
}

header h1 {
  font-size: 1.4rem;
  margin-bottom: 5px;
  color: #1a1a1a;
}

#counter {
  font-weight: 700;
  color: #2563eb;
}

#viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
  background: #ffffff;
}

#viewport:active {
  cursor: grabbing;
}

#grid {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.cell {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.cell:hover {
  background: rgba(37, 99, 235, 0.1);
}

.cell.touch-highlight {
  background: rgba(37, 99, 235, 0.2) !important;
}

/* 🔧 ПОДСВЕТКА ДЛЯ ТЕЛЕФОНА */
.cell:active, .cell.touch-active {
  background: rgba(37, 99, 235, 0.3) !important;
}

.cell.occupied:active, .cell.occupied.touch-active {
  background: rgba(0, 0, 0, 0.2) !important;
}

.cell.occupied {
  cursor: default;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.cell.occupied:hover {
  background: transparent;
}

#toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
  padding: 20px;
  z-index: 100;
  border-radius: 20px 20px 0 0;
}

.toolbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

#cellInfo {
  font-weight: 600;
  color: #333;
}

.toolbar-middle {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
}

.tool-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tool-section label {
  font-size: 0.8rem;
  color: #888;
  font-weight: 500;
}

.tool-buttons, .size-buttons {
  display: flex;
  gap: 8px;
}

.tool-btn, .size-btn {
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.tool-btn.active, .size-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  transform: scale(1.05);
}

.size-btn {
  width: 36px;
  height: 36px;
  font-weight: 600;
  font-size: 0.95rem;
}

#colorPalette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 250px;
  justify-content: center;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: #333;
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.toolbar-bottom {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 15px;
}

.toolbar-bottom button {
  flex: 1;
  max-width: 150px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
}

#drawCanvas {
  display: block;
  margin: 0 auto;
  background: #ffffff;
  border: 3px solid #e5e7eb;
  border-radius: 8px;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: optimizeSpeed;
  touch-action: none;
  width: 256px;
  height: 256px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  /* 🔧 ИСПРАВЛЕНИЕ ДЛЯ ТЕЛЕФОНА */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  position: relative;
  z-index: 100;
  max-width: 100%;
  touch-action: none !important;  /* Принудительно */
}

.hidden {
  display: none !important;
}

#reportModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

#reportModal .modal-content {
  background: white;
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  max-width: 380px;
  width: 90%;
}

#reportModal h2 {
  margin-bottom: 15px;
  color: #1a1a1a;
}

#reportModal p {
  color: #666;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* === ТОЛЬКО ДЛЯ ТЕЛЕФОНОВ === */
@media (max-width: 600px) {
  .welcome-content {
    padding: 15px 12px;
    max-width: 95%;
  }
  
  .welcome-content h1 {
    font-size: 1.3rem;
  }
  
  .rules {
    padding: 12px;
    margin: 10px 0;
  }
  
  .rules li {
    font-size: 0.75rem;
    margin: 4px 0;
  }
  
  .vpn-notice {
    padding: 6px 8px;
    margin: 8px 0;
  }
  
  .social-links {
    padding: 12px;
    margin: 10px 0;
  }
  
  .social-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
  }
  
  .btn-primary {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
  
  .toolbar-middle {
    gap: 12px;
  }
  
  .tool-section {
    min-width: 70px;
  }
  
  #colorPalette {
    max-width: 100%;
  }
  
  .color-btn {
    width: 26px;
    height: 26px;
  }
  
  .toolbar-bottom button {
    max-width: 110px;
    padding: 12px;
    font-size: 0.85rem;
  }
  
  #drawCanvas {
    width: 180px;
    height: 180px;
  }
}

/* ============================================ */
/* МУЗЫКА НЕДЕЛИ (АУДИО) */
/* ============================================ */

.music-widget {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 15px 20px;
  margin: 0 auto 15px auto;
  max-width: 700px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.music-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  margin-bottom: 8px;
  text-align: center;
}

.music-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.music-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.music-track {
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
}

.music-artist {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin-top: 2px;
}

.music-play-btn {
  background: white;
  color: #667eea;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.music-play-btn:active {
  transform: scale(0.95);
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .music-widget {
    margin: 0 10px 15px 10px;
    padding: 12px 15px;
  }
  
  .music-track {
    font-size: 1rem;
  }
  
  .music-artist {
    font-size: 0.8rem;
  }
  
  .music-play-btn {
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
}

/* ============================================ */
/* КНОПКА СКАЧАТЬ РИСУНОК */
/* ============================================ */

.download-btn {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
}

.download-btn:active {
  transform: translateY(0);
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .download-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
  }
}

/* ============================================ */
/* КОМПАКТНОЕ МЕНЮ - МАКСИМУМ МЕСТА */
/* ============================================ */

/* Header - меньше отступы */
header {
  padding: 8px 15px !important;
  margin: 0 0 10px 0 !important;
}

/* Музыкальный виджет - компактный */
.music-widget {
  padding: 8px 15px !important;
  margin: 0 auto 8px auto !important;
  max-width: 400px !important;
}

.music-label {
  font-size: 0.7rem !important;
  margin-bottom: 3px !important;
}

.music-track {
  font-size: 0.85rem !important;
}

.music-artist {
  font-size: 0.75rem !important;
}

.music-play-btn {
  width: 35px !important;
  height: 35px !important;
  font-size: 1rem !important;
}

/* Заголовок - меньше */
header h1 {
  font-size: 1.2rem !important;
  margin: 3px 0 !important;
}

/* Счётчик - меньше */
header p {
  font-size: 0.8rem !important;
  margin: 3px 0 !important;
}

/* Кнопка скачать - компактная */
.download-btn {
  padding: 5px 12px !important;
  font-size: 0.8rem !important;
  margin-top: 5px !important;
}

/* На телефоне ещё меньше */
@media (max-width: 600px) {
  header {
    padding: 6px 10px !important;
  }
  
  .music-widget {
    padding: 6px 12px !important;
    max-width: 100% !important;
  }
  
  .music-track {
    font-size: 0.8rem !important;
  }
  
  .music-artist {
    font-size: 0.7rem !important;
  }
  
  .music-play-btn {
    width: 32px !important;
    height: 32px !important;
  }
  
  header h1 {
    font-size: 1.1rem !important;
  }
  
  header p {
    font-size: 0.75rem !important;
  }
  
  .download-btn {
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
  }
}

/* ============================================ */
/* КНОПКА "МОЯ ПОЗИЦИЯ" */
/* ============================================ */

.my-pos-btn {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin: 5px auto 0 auto;
  display: inline-block;
}

.my-pos-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

.my-pos-btn:active {
  transform: translateY(0);
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .my-pos-btn {
    width: 100%;
    margin-top: 5px;
  }
}

.game-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(124, 58, 237, 0.4);
}

.game-btn:active {
  transform: translateY(0);
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .game-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
  }
}

/* ============================================ */
/* ПРЕДПРОСМОТР ПРИ НАВЕДЕНИИ */
/* ============================================ */

.cell-preview {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  display: none;
}

.preview-content {
  background: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  border: 3px solid #667eea;
  text-align: center;
}

.preview-image {
  width: 120px;
  height: 120px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  margin: 0 auto 8px auto;
  border-radius: 8px;
  background: #f5f5f5;
}

.preview-coords {
  font-size: 0.8rem;
  color: #666;
  font-weight: 600;
  background: rgba(102, 126, 234, 0.1);
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
}

/* Анимация появления */
.cell-preview {
  animation: previewFadeIn 0.2s ease-out;
}

@keyframes previewFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* На телефоне скрываем (там нет hover) */
@media (max-width: 600px) {
  .cell-preview {
    display: none !important;
  }
}


/* ============================================ */
/* МИНИ-КАРТА ПОЛОТНА (ИСПРАВЛЕННАЯ) */
/* ============================================ */

#minimap-container {
  position: fixed;
  bottom: 80px;  /* ↑ Подняли выше от низа */
  right: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9998;  /* ↓ Ниже чем welcome screen (10000) */
  overflow: hidden;
  transition: all 0.3s ease;
  max-width: 350px;
}

.minimap-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.minimap-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.minimap-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.minimap-wrapper {
  padding: 10px;
  overflow: auto;
  max-height: 350px;
}

.minimap-grid {
  position: relative;
  background: #f5f5f5;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
}

.minimap-cell {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #e0e0e0;
  cursor: pointer;
  transition: background 0.1s;
}

.minimap-cell:hover {
  background: #667eea;
  z-index: 10;
}

.minimap-cell.occupied {
  background: #667eea;
}

.minimap-legend {
  padding: 8px 15px;
  background: #f9f9f9;
  display: flex;
  gap: 15px;
  font-size: 0.75rem;
  color: #666;
  border-top: 1px solid #e0e0e0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-dot.empty {
  background: #e0e0e0;
}

.legend-dot.occupied {
  background: #667eea;
}

#minimap-count {
  font-size: 0.75rem;
  color: #999;
  text-align: center;
  padding: 5px;
  background: #f9f9f9;
}

/* Адаптив для телефона — ИСПРАВЛЕНО! */
@media (max-width: 600px) {
  #minimap-container {
    bottom: 100px;  /* ↑ Ещё выше на телефоне */
    right: 10px;
    left: auto;     /* ← Не на всю ширину */
    max-width: 200px;  /* ← Меньше размер */
    transform: scale(0.85);  /* ← Уменьшаем */
    transform-origin: bottom right;
  }
  
  .minimap-wrapper {
    max-height: 250px;
    padding: 8px;
  }
  
  .minimap-grid {
    transform: scale(0.9);
    transform-origin: top left;
  }
  
  .minimap-header span {
    font-size: 0.8rem;
  }
  
  .minimap-legend {
    flex-direction: column;
    gap: 5px;
    font-size: 0.7rem;
  }
}

/* На очень маленьких экранах — скрываем по умолчанию */
@media (max-width: 400px) {
  #minimap-container {
    display: none;  /* Скрываем на совсем маленьких */
  }
}

/* Скроллбар */
.minimap-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.minimap-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.minimap-wrapper::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 3px;
}

.minimap-wrapper::-webkit-scrollbar-thumb:hover {
  background: #764ba2;
}

/* ============================================ */
/* ГЕНЕРАТОР ПАТТЕРНОВ */
/* ============================================ */

/* Кнопка открытия */
.pattern-toggle-btn {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin: 10px auto;
  display: block;
}

.pattern-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

/* Панель паттернов */
#patternPanel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  padding: 20px;
  min-width: 320px;
  max-width: 90%;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

#patternPanel:not(.hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

#patternPanel.hidden {
  display: none;
}

.pattern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
}

.pattern-header span {
  font-weight: 700;
  font-size: 1rem;
  color: #333;
}

.pattern-close {
  background: #f0f0f0;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.pattern-close:hover {
  background: #e0e0e0;
}

/* Сетка паттернов */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 15px;
}

.pattern-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pattern-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.pattern-btn:active {
  transform: scale(0.95);
}

.pattern-btn.applied {
  animation: patternApplied 0.3s ease;
}

@keyframes patternApplied {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Предпросмотр */
.pattern-preview {
  text-align: center;
  padding-top: 15px;
  border-top: 2px solid #f0f0f0;
}

#patternPreview {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin-bottom: 10px;
}

.pattern-hint {
  font-size: 0.75rem;
  color: #999;
  margin: 0;
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  #patternPanel {
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    min-width: auto;
  }
  
  #patternPanel:not(.hidden) {
    transform: none;
  }
  
  .pattern-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
  
  .pattern-btn {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }
  
  .pattern-toggle-btn {
    width: 100%;
  }
}

/* ============================================ */
/* ЧАСТИЦЫ ПРИ РИСОВАНИИ */
/* ============================================ */

/* Canvas для частиц */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Эффект свечения для частиц */
#particleCanvas {
  filter: blur(0.5px) drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

/* На слабых устройствах можно отключить эффекты */
@media (prefers-reduced-motion: reduce) {
  #particleCanvas {
    display: none;
  }
}

/* Кнопка включения/выключения частиц */
.particles-toggle {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #667eea;
  color: #667eea;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 10000;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.particles-toggle:hover {
  background: #667eea;
  color: white;
  transform: scale(1.1);
}

.particles-toggle.disabled {
  opacity: 0.5;
  border-color: #999;
  color: #999;
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .particles-toggle {
    bottom: 70px;
    right: 10px;
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
}

/* ============================================ */
/* ЭФФЕКТ ПРИ СОХРАНЕНИИ (CELEBRATION) */
/* ============================================ */

/* Конфетти */
.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 10001;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Сообщение о праздновании */
.celebration-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: white;
  border-radius: 20px;
  padding: 30px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 10002;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.celebration-message.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.celebration-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
}

.celebration-icon {
  font-size: 4rem;
  animation: celebrationIconBounce 0.6s ease infinite;
}

@keyframes celebrationIconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.celebration-text h3 {
  margin: 0;
  font-size: 1.5rem;
  color: #667eea;
  font-weight: 700;
}

.celebration-text p {
  margin: 5px 0 0 0;
  font-size: 0.9rem;
  color: #666;
}

.celebration-stars {
  font-size: 2rem;
  animation: celebrationStarsSpin 2s linear infinite;
}

@keyframes celebrationStarsSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Подсветка клетки */
.cell.celebration-highlight {
  animation: cellCelebrate 0.6s ease 3;
}

@keyframes cellCelebrate {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(255, 215, 0, 0);
  }
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .celebration-message {
    left: 50%;
    right: 20px;
    left: auto;
    transform: translate(0, -50%) scale(0.9);
    padding: 20px 25px;
    min-width: 280px;
  }
  
  .celebration-message.show {
    transform: translate(0, -50%) scale(1);
  }
  
  .celebration-icon {
    font-size: 3rem;
  }
  
  .celebration-text h3 {
    font-size: 1.2rem;
  }
  
  .celebration-text p {
    font-size: 0.8rem;
  }
  
  .confetti {
    /* Меньше конфетти на телефоне для производительности */
  }
}

/* Отключение анимаций для пользователей с prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .confetti,
  .celebration-message,
  .celebration-icon,
  .celebration-stars,
  .cell.celebration-highlight {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================ */
/* ГЕНЕРАТОР ПАЛИТР (ВСТРОЕННЫЙ) */
/* ============================================ */

.palette-generator {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin: 10px auto;
  max-width: 400px;
  transition: all 0.3s ease;
}

.palette-generator.collapsed {
  padding: 10px 15px;
}

.palette-generator.collapsed .generator-types,
.palette-generator.collapsed .generated-palette,
.palette-generator.collapsed .apply-palette-btn {
  display: none;
}

.generator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.generator-header span {
  font-weight: 700;
  font-size: 0.95rem;
  color: #333;
}

.generator-toggle {
  background: #f0f0f0;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s;
}

.generator-toggle:hover {
  background: #e0e0e0;
}

/* Типы палитр */
.generator-types {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.gen-type-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-type-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Сгенерированная палитра */
.generated-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 15px;
  min-height: 50px;
}

.generated-color-btn {
  width: 45px;
  height: 45px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.generated-color-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.generated-color-btn.active {
  box-shadow: 0 0 0 3px #667eea;
  transform: scale(1.05);
}

.palette-hint {
  font-size: 0.8rem;
  color: #999;
  text-align: center;
  margin: 15px 0;
}

/* Кнопка применения */
.apply-palette-btn {
  width: 100%;
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.apply-palette-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
}

/* Анимация применения */
#colorPalette.palette-applied {
  animation: paletteApplied 0.5s ease;
}

@keyframes paletteApplied {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .palette-generator {
    margin: 10px;
    padding: 12px;
  }
  
  .generator-types {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  
  .gen-type-btn {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }
  
  .generated-palette {
    gap: 6px;
  }
  
  .generated-color-btn {
    width: 40px;
    height: 40px;
  }
}

/* ============================================ */
/* СПИДРАН РИСУНОК */
/* ============================================ */

/* Модальное окно результатов */
.speedrun-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10003;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.speedrun-modal.show {
  opacity: 1;
  visibility: visible;
}

.speedrun-content {
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.speedrun-modal.show .speedrun-content {
  transform: scale(1);
}

.speedrun-header {
  margin-bottom: 25px;
}

.speedrun-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

.speedrun-header h2 {
  margin: 0;
  color: #333;
  font-size: 1.5rem;
}

.new-record-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 10px;
  animation: badgePulse 1s infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Статистика */
.speedrun-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.stat-item {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 15px 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.75rem;
  color: #666;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
}

/* Лучший результат */
.speedrun-best {
  background: linear-gradient(135deg, #fff9e6 0%, #ffeaa7 100%);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.best-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
}

.best-value {
  font-size: 1rem;
  color: #d63031;
  font-weight: 700;
}

/* Кнопки */
.speedrun-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.speedrun-btn {
  padding: 12px 25px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.speedrun-btn.primary {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: white;
}

.speedrun-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
}

.speedrun-btn.secondary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.speedrun-btn.secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* Кнопка статистики */
.speedrun-stats-btn {
  position: fixed;
  bottom: 180px;
  right: 20px;
  background: white;
  border: 2px solid #f093fb;
  color: #f093fb;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 9999;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(240, 147, 251, 0.3);
}

.speedrun-stats-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(240, 147, 251, 0.5);
}

/* Адаптив для телефона */
@media (max-width: 600px) {
  .speedrun-content {
    padding: 20px;
    width: 95%;
  }
  
  .speedrun-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  
  .stat-item {
    padding: 10px 5px;
  }
  
  .stat-value {
    font-size: 0.95rem;
  }
  
  .speedrun-actions {
    flex-direction: column;
  }
  
  .speedrun-btn {
    width: 100%;
  }
  
  .speedrun-stats-btn {
    bottom: 160px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
}

/* 🔧 КРИТИЧЕСКИ ВАЖНО: Виджеты не должны перехватывать тач на canvas */

/* Все виджеты внизу экрана */
#minimap-container,
#predictionWidget,
.symmetry-quick-btn,
.speedrun-stats-btn,
.particles-toggle,
.palette-generator,
#patternPanel,
#symmetryPanel {
  pointer-events: none !important;  /* Не перехватывают клики/тач */
}

/* Но кнопки внутри виджетов должны работать */
#minimap-container *,
#predictionWidget *,
.symmetry-quick-btn,
.speedrun-stats-btn,
.particles-toggle,
.palette-generator *,
#patternPanel *,
#symmetryPanel * {
  pointer-events: auto !important;  /* Кнопки работают */
}

/* Canvas должен быть выше всего */
#drawCanvas {
  pointer-events: auto !important;
  z-index: 10000 !important;  /* Выше всех виджетов */
}

/* Toolbar тоже должен работать */
#toolbar {
  z-index: 10001 !important;
  pointer-events: auto !important;
}

/* ============================================ */
/* МАСКИ И ФИЛЬТРЫ (КОМПАКТНО ДЛЯ ТЕЛЕФОНА) */
/* ============================================ */

.filters-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  padding: 15px;
  margin: 10px auto;
  max-width: 400px;
  transition: all 0.3s ease;
}

.filters-panel.collapsed {
  padding: 10px 15px;
}

.filters-panel.collapsed .filters-grid,
.filters-panel.collapsed .filters-actions {
  display: none;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;  /* Уменьшил */
}

.filters-header span {
  font-weight: 700;
  font-size: 0.9rem;  /* Чуть меньше */
  color: #333;
}

.filters-toggle {
  background: #f0f0f0;
  border: none;
  width: 26px;  /* Чуть меньше */
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.filters-toggle:hover {
  background: #e0e0e0;
}

/* Сетка фильтров */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);  /* 5 колонок */
  gap: 6px;  /* Меньше отступы */
  margin-bottom: 10px;
}

.filter-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;  /* Чуть меньше скругление */
  width: 42px;  /* КОМПАКТНО: было 50px */
  height: 42px; /* КОМПАКТНО: было 50px */
  font-size: 1.2rem;  /* Чуть меньше иконки */
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.filter-btn.applied {
  animation: filterApplied 0.5s ease;
}

@keyframes filterApplied {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Кнопка сброса */
.filters-actions {
  text-align: center;
}

.filter-reset-btn {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  padding: 8px 16px;  /* Меньше */
  border-radius: 8px;
  font-size: 0.8rem;  /* Меньше текст */
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 12px rgba(245, 87, 108, 0.4);
}

/* ============================================ */
/* ТЕЛЕФОН: ЕЩЁ КОМПАКТНЕЕ */
/* ============================================ */

@media (max-width: 600px) {
  .filters-panel {
    margin: 8px;  /* Меньше отступы */
    padding: 10px;
  }
  
  .filters-header {
    margin-bottom: 8px;
  }
  
  .filters-header span {
    font-size: 0.85rem;
  }
  
  .filters-grid {
    grid-template-columns: repeat(5, 1fr);  /* 5 в ряд */
    gap: 4px;  /* Минимальные отступы */
    margin-bottom: 8px;
  }
  
  .filter-btn {
    width: 38px;  /* ЕЩЁ КОМПАКТНЕЕ */
    height: 38px;
    font-size: 1.1rem;
  }
  
  .filter-reset-btn {
    width: 100%;
    padding: 8px;
    font-size: 0.75rem;
  }
  
  /* Если всё равно много — показываем только первые 5 */
  .filter-btn:nth-child(n+6) {
    /* display: none; */  /* Раскомментируй если нужно скрыть */
  }
}

/* Горизонтальный скролл для фильтров на телефоне */
@media (max-width: 600px) {
  .filters-grid {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;  /* Плавный скролл на iOS */
    scrollbar-width: none;  /* Скрыть скроллбар Firefox */
  }
  
  .filters-grid::-webkit-scrollbar {
    display: none;  /* Скрыть скроллбар Chrome/Safari */
  }
  
  .filter-btn {
    flex: 0 0 45px;  /* Фиксированная ширина */
    width: 45px;
    height: 45px;
  }
}

/* ============================================ */
/* Z-INDEX ДЛЯ ПАНЕЛЕЙ (ПОРЯДОК СЛОЁВ) */
/* ============================================ */

/* Паттерны должны быть ВЫШЕ фильтров */
#patternPanel {
  z-index: 1001 !important;  /* Выше фильтров */
}

/* Фильтры ниже паттернов */
#filtersPanel {
  z-index: 1000 !important;
}

/* Палитры ещё ниже */
#paletteGenerator {
  z-index: 999 !important;
}

/* Все панели должны быть относительно позиционированы */
#patternPanel,
#filtersPanel,
#paletteGenerator {
  position: relative;  /* Важно для z-index! */
}

/* Модальные окна выше всего */
.modal-overlay {
  z-index: 10000 !important;
}

/* Все панели инструментов в одном месте */
#paletteGenerator,
#filtersPanel,
#patternPanel {
  position: relative !important;
  z-index: 100 !important;
  margin: 8px auto;
  max-width: 400px;
}


/* Паттерны - компактная панель */
#patternPanel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  padding: 15px;
  margin: 8px auto;
  max-width: 400px;
  transition: all 0.3s ease;
  position: relative !important;
  z-index: 1001 !important;
}

#patternPanel.collapsed {
  padding: 10px 15px;
}

#patternPanel.collapsed .pattern-content,
#patternPanel.collapsed .pattern-grid,
#patternPanel.collapsed .pattern-preview {
  display: none !important;  ← ВАЖНО!
}

.pattern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
}

.pattern-header span {
  font-weight: 700;
  font-size: 0.9rem;
  color: #333;
}

.pattern-toggle {
  background: #f0f0f0;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.pattern-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 8px;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pattern-btn:hover { transform: scale(1.1); }
.pattern-btn.applied { animation: filterApplied 0.5s ease; }

@keyframes filterApplied {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.pattern-preview {
  text-align: center;
  padding-top: 10px;
  border-top: 2px solid #f0f0f0;
}

#patternPreview {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  image-rendering: pixelated;
  margin-bottom: 8px;
}

.pattern-hint {
  font-size: 0.7rem;
  color: #999;
  margin: 0;
}

/* Телефон */
@media (max-width: 600px) {
  #patternPanel { margin: 8px; padding: 10px; }
  .pattern-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .pattern-btn { width: 38px; height: 38px; font-size: 1.1rem; }
}

/* Все панели вертикально */
#paletteGenerator, #filtersPanel, #patternPanel {
  position: static !important;
  display: block !important;
  margin: 8px auto !important;
  max-width: 400px !important;
  clear: both !important;
}

/* 🔧 СРОЧНЫЙ ФИКС ДЛЯ ТЕЛЕФОНА */
@media (max-width: 600px) {
  
  /* Все панели по ширине экрана */
  #paletteGenerator,
  #filtersPanel,
  #patternPanel {
    width: calc(100% - 16px) !important;  /* Чуть меньше 100% */
    max-width: calc(100% - 16px) !important;
    margin: 8px !important;
    padding: 10px !important;
    box-sizing: border-box !important;  /* Важно! */
  }
  
  /* Заголовок панели не сжимается */
  .filters-header,
  .pattern-header,
  .generator-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;  /* Позволяет сжиматься */
  }
  
  /* Кнопка закрытия всегда видна */
  .filters-toggle,
  .pattern-toggle,
  .generator-toggle {
    min-width: 26px !important;
    min-height: 26px !important;
    margin-left: auto !important;  /* Прижимает вправо */
    flex-shrink: 0 !important;  /* Не сжимается */
  }
  
  /* Текст заголовка не вылезает */
  .filters-header span,
  .pattern-header span,
  .generator-header span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 200px !important;
  }
  
  /* Сетка фильтров - скролл если не влезает */
  .filters-grid,
  .pattern-grid,
  .generator-types {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;  /* Горизонтальный скролл */
    gap: 6px !important;
    padding-bottom: 8px !important;
    -webkit-overflow-scrolling: touch !important;  /* Плавный скролл iOS */
  }
  
  /* Кнопки в сетке не сжимаются */
  .filter-btn,
  .pattern-btn,
  .gen-type-btn {
    min-width: 45px !important;
    max-width: 45px !important;
    flex: 0 0 45px !important;  /* Фиксированная ширина */
  }
  
  /* Кнопка сброса на всю ширину */
  .filter-reset-btn {
    width: 100% !important;
  }
}

/* ============================================ */
/* 🔥 МАКСИМАЛЬНО КОМПАКТНО - ДЛЯ ТЕЛЕФОНА! */
/* ============================================ */

/* ВСЕ ПАНЕЛИ */
#paletteGenerator,
#filtersPanel,
#patternPanel {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin: 4px auto;
  padding: 6px 10px;
  width: 95%;
  max-width: 350px;
  box-sizing: border-box;
}

/* СВЁРНУТАЯ ПАНЕЛЬ - МИНИМАЛЬНЫЙ РАЗМЕР */
#paletteGenerator.collapsed,
#filtersPanel.collapsed,
#patternPanel.collapsed {
  padding: 4px 8px;
  margin: 3px auto;
}

/* Заголовок */
.filters-header,
.pattern-header,
.generator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 4px 0;
  min-height: 32px;
}

.filters-header span,
.pattern-header span,
.generator-header span {
  font-weight: 700;
  font-size: 0.8rem;
  margin: 0;
}

/* Кнопка закрыть - МАЛЕНЬКАЯ */
.filters-toggle,
.pattern-toggle,
.generator-toggle {
  background: #f0f0f0;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* СЕТКА КНОПОК */
.filters-grid,
.pattern-grid,
.generator-types {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 6px 0;
  margin: 6px 0;
}

/* КНОПКИ */
.filter-btn,
.pattern-btn,
.gen-type-btn,
.generated-color-btn {
  min-width: 36px;
  max-width: 36px;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

/* Кнопка сброса */
.filter-reset-btn {
  width: 100%;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  margin: 4px 0;
}

/* Предпросмотр */
.pattern-preview {
  text-align: center;
  padding: 6px 0 0 0;
  margin: 6px 0 0 0;
  border-top: 1px solid #f0f0f0;
}

#patternPreview {
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  width: 60px;
  height: 60px;
}

.pattern-hint {
  font-size: 0.6rem;
  color: #999;
  margin: 4px 0 0 0;
}

/* СКРЫТЬ КОГДА СВЁРНУТО */
#filtersPanel.collapsed .filters-grid,
#filtersPanel.collapsed .filters-actions,
#patternPanel.collapsed .pattern-content,
#patternPanel.collapsed .pattern-grid,
#patternPanel.collapsed .pattern-preview,
#paletteGenerator.collapsed .generator-types,
#paletteGenerator.collapsed .generated-palette,
#paletteGenerator.collapsed .apply-palette-btn {
  display: none !important;
}

/* Скроллбар */
.filters-grid::-webkit-scrollbar,
.pattern-grid::-webkit-scrollbar {
  height: 3px;
}

.filters-grid::-webkit-scrollbar-track,
.pattern-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.filters-grid::-webkit-scrollbar-thumb,
.pattern-grid::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 2px;
}

/* ============================================ */
/* ТЕЛЕФОН - МАКСИМАЛЬНО КОМПАКТНО */
/* ============================================ */

@media (max-width: 600px) {
  #paletteGenerator,
  #filtersPanel,
  #patternPanel {
    width: 98%;
    max-width: 98%;
    padding: 4px 8px;
    margin: 2px auto;
  }
  
  /* СВЁРНУТАЯ - ЕЩЁ МЕНЬШЕ */
  #paletteGenerator.collapsed,
  #filtersPanel.collapsed,
  #patternPanel.collapsed {
    padding: 3px 6px;
    margin: 2px auto;
  }
  
  .filters-header,
  .pattern-header,
  .generator-header {
    min-height: 28px;
    padding: 2px 0;
  }
  
  .filters-header span,
  .pattern-header span,
  .generator-header span {
    font-size: 0.75rem;
  }
  
  .filters-toggle,
  .pattern-toggle,
  .generator-toggle {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }
  
  .filter-btn,
  .pattern-btn,
  .gen-type-btn {
    min-width: 32px;
    max-width: 32px;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 0.9rem;
  }
  
  .filter-reset-btn {
    padding: 5px;
    font-size: 0.7rem;
    margin: 3px 0;
  }
  
  #patternPreview {
    width: 50px;
    height: 50px;
  }
  
  .pattern-hint {
    font-size: 0.55rem;
  }
}

/* ОЧЕНЬ МАЛЕНЬКИЙ ЭКРАН */
@media (max-width: 350px) {
  .filter-btn,
  .pattern-btn,
  .gen-type-btn {
    min-width: 28px;
    max-width: 28px;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    font-size: 0.8rem;
  }
  
  .filters-header span,
  .pattern-header span {
    font-size: 0.7rem;
  }
}

/* 🔧 ИСПРАВЛЕНИЕ: цвета палитры показываются */
.generated-color-btn {
  background: none !important;  /* Убираем градиент! */
  border: 2px solid rgba(0,0,0,0.1);
}

.generated-color-btn.active {
  border: 2px solid #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

/* 🔧 ИСПРАВЛЕНИЕ: ПОКАЗЫВАЕМ ЦВЕТА ПАЛИТРЫ */
.generated-color-btn {
  background: var(--btn-color, #fff) !important;  /* Используем переменную */
  border: 2px solid rgba(0,0,0,0.2);
}

.generated-color-btn.active {
  border: 3px solid #667eea;
  transform: scale(1.1);
}

/* 🔧 ВОССТАНАВЛИВАЕМ СВЁРТЫВАНИЕ ПАНЕЛЕЙ */

/* По умолчанию панели развёрнуты */
#paletteGenerator .generator-types,
#paletteGenerator .generated-palette,
#paletteGenerator .apply-palette-btn,
#filtersPanel .filters-grid,
#filtersPanel .filters-actions,
#patternPanel .pattern-content,
#patternPanel .pattern-grid,
#patternPanel .pattern-preview {
  /* 🔧 ИСПРАВЛЕНИЕ: ГОРИЗОНТАЛЬНЫЙ СКРОЛЛ */

/* Сетка кнопок - ГОРИЗОНТАЛЬНО */
.filters-grid,
.pattern-grid,
.generator-types {
  display: flex !important;
  flex-direction: row !important;  /* ← Горизонтально! */
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 6px !important;
  padding: 6px 0 !important;
}

/* Кнопки не сжимаются */
.filter-btn,
.pattern-btn,
.gen-type-btn {
  flex: 0 0 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
}

/* Свёрнутое состояние */
#paletteGenerator.collapsed .generator-types,
#paletteGenerator.collapsed .generated-palette,
#paletteGenerator.collapsed .apply-palette-btn,
#filtersPanel.collapsed .filters-grid,
#filtersPanel.collapsed .filters-actions,
#patternPanel.collapsed .pattern-content,
#patternPanel.collapsed .pattern-grid,
#patternPanel.collapsed .pattern-preview {
  display: none !important;
}

/* 🔧 ВЕРНУТЬ ПАНЕЛИ НА ЭКРАН! */

#paletteGenerator,
#filtersPanel,
#patternPanel {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  margin: 10px auto !important;
  padding: 12px !important;
  background: white !important;
  border-radius: 10px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
  width: 95% !important;
  max-width: 400px !important;
  z-index: 100 !important;
}

/* Сетка кнопок горизонтально */
.filters-grid,
.pattern-grid,
.generator-types {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 6px !important;
  padding: 8px 0 !important;
  margin: 8px 0 !important;
}

/* Кнопки */
.filter-btn,
.pattern-btn,
.gen-type-btn,
.generated-color-btn {
  display: inline-flex !important;
  flex: 0 0 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  border: none !important;
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  color: white !important;
  font-size: 1.1rem !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Заголовки */
.filters-header,
.pattern-header,
.generator-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 10px !important;
  padding-bottom: 8px !important;
  border-bottom: 1px solid #f0f0f0 !important;
}

.filters-header span,
.pattern-header span,
.generator-header span {
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  color: #333 !important;
}

/* Кнопка закрыть */
.filters-toggle,
.pattern-toggle,
.generator-toggle {
  background: #f0f0f0 !important;
  border: none !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 0.8rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Кнопка сброса */
.filter-reset-btn {
  width: 100% !important;
  padding: 8px !important;
  border: none !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #f093fb, #f5576c) !important;
  color: white !important;
  font-size: 0.8rem !important;
  cursor: pointer !important;
  margin-top: 8px !important;
}

/* Предпросмотр */
.pattern-preview {
  text-align: center !important;
  padding: 10px 0 0 0 !important;
  margin: 10px 0 0 0 !important;
  border-top: 1px solid #f0f0f0 !important;
}

#patternPreview {
  border: 2px solid #e0e0e0 !important;
  border-radius: 8px !important;
  width: 80px !important;
  height: 80px !important;
}

.pattern-hint {
  font-size: 0.7rem !important;
  color: #999 !important;
  margin: 5px 0 0 0 !important;
}

/* Свёрнутое состояние */
#paletteGenerator.collapsed .generator-types,
#paletteGenerator.collapsed .generated-palette,
#paletteGenerator.collapsed .apply-palette-btn,
#filtersPanel.collapsed .filters-grid,
#filtersPanel.collapsed .filters-actions,
#patternPanel.collapsed .pattern-content,
#patternPanel.collapsed .pattern-grid,
#patternPanel.collapsed .pattern-preview {
  display: none !important;
}

/* Панели внутри toolbar */
#toolbar #paletteGenerator,
#toolbar #filtersPanel,
#toolbar #patternPanel {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
  margin: 10px auto !important;
  padding: 12px !important;
  background: white !important;
  border-radius: 10px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
  width: 95% !important;
  max-width: 400px !important;
}

/* Горизонтальный скролл */
#toolbar .generator-types,
#toolbar .filters-grid,
#toolbar .pattern-grid {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  gap: 6px !important;
  padding: 8px 0 !important;
}

/* Кнопки */
#toolbar .gen-type-btn,
#toolbar .filter-btn,
#toolbar .pattern-btn,
#toolbar .generated-color-btn {
  flex: 0 0 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  border: none !important;
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  color: white !important;
  font-size: 1.1rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Заголовки */
#toolbar .generator-header,
#toolbar .filters-header,
#toolbar .pattern-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 10px !important;
}

/* Кнопка закрыть */
#toolbar .generator-toggle,
#toolbar .filters-toggle,
#toolbar .pattern-toggle {
  background: #f0f0f0 !important;
  border: none !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 0.8rem !important;
  flex-shrink: 0 !important;
}

/* Свёрнутое состояние */
#toolbar #paletteGenerator.collapsed .generator-types,
#toolbar #paletteGenerator.collapsed .generated-palette,
#toolbar #paletteGenerator.collapsed .apply-palette-btn,
#toolbar #filtersPanel.collapsed .filters-grid,
#toolbar #filtersPanel.collapsed .filters-actions,
#toolbar #patternPanel.collapsed .pattern-content {
  display: none !important;
}

/* Кнопка сброса */
#toolbar .filter-reset-btn {
  width: 100% !important;
  padding: 8px !important;
  border: none !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #f093fb, #f5576c) !important;
  color: white !important;
  font-size: 0.8rem !important;
  cursor: pointer !important;
  margin-top: 8px !important;
}

/* Кнопка применить палитру */
#toolbar .apply-palette-btn {
  width: 100% !important;
  padding: 10px !important;
  border: none !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #11998e, #38ef7d) !important;
  color: white !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
  margin-top: 10px !important;
}

/* Предпросмотр */
#toolbar .pattern-preview {
  text-align: center !important;
  padding: 10px 0 0 0 !important;
  margin: 10px 0 0 0 !important;
  border-top: 1px solid #f0f0f0 !important;
}

#toolbar #patternPreview {
  border: 2px solid #e0e0e0 !important;
  border-radius: 8px !important;
  width: 80px !important;
  height: 80px !important;
}

#toolbar .pattern-hint {
  font-size: 0.7rem !important;
  color: #999 !important;
  margin: 5px 0 0 0 !important;
}

/* Телефон */
@media (max-width: 600px) {
  #toolbar #paletteGenerator,
  #toolbar #filtersPanel,
  #toolbar #patternPanel {
    width: 98% !important;
    padding: 10px !important;
    margin: 8px auto !important;
  }
  
  #toolbar .gen-type-btn,
  #toolbar .filter-btn,
  #toolbar .pattern-btn {
    flex: 0 0 36px !important;
    min-width: 36px !important;
    height: 36px !important;
  }
}

/* 🔧 ИСПРАВЛЕНИЕ: ЦВЕТА ПАЛИТРЫ ПОКАЗЫВАЮТСЯ ПРАВИЛЬНО */

.generated-color-btn {
  background: var(--color-bg, #fff) !important;  /* Убираем градиент */
  border: 2px solid rgba(0,0,0,0.2) !important;
}

/* Когда цвет установлен через JS */
.generated-color-btn[style*="background-color"] {
  background: inherit !important;
}

/* Активная кнопка */
.generated-color-btn.active {
  border: 3px solid #667eea !important;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3) !important;
  transform: scale(1.1) !important;
}

/* Убираем градиент с кнопок цветов */
#toolbar .generated-color-btn {
  background-image: none !important;
  background-color: inherit !important;
}

/* 🔧 ФИНАЛЬНОЕ ИСПРАВЛЕНИЕ ЦВЕТОВ */

.generated-color-btn {
  background-color: #ffffff !important;  /* По умолчанию белый */
  background-image: none !important;      /* Убираем градиент */
  border: 2px solid rgba(0,0,0,0.2) !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Когда цвет установлен - используем его */
.generated-color-btn[style*="background-color"] {
  /* Цвет уже установлен inline */
}

/* Активная кнопка */
.generated-color-btn.active {
  border: 3px solid #667eea !important;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3) !important;
  transform: scale(1.1) !important;
}

/* Убираем все эффекты */
.generated-color-btn:hover {
  background-image: none !important;
}

/* ========== АНИМАЦИЯ МОДАЛКА ========== */
#animModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0,0,0,0.9) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 999999 !important;
}

.anim-box {
  background: white !important;
  border-radius: 16px !important;
  padding: 20px !important;
  max-width: 500px !important;
  width: 90% !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5) !important;
}

.anim-head {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 15px !important;
  padding-bottom: 10px !important;
  border-bottom: 2px solid #eee !important;
}

.anim-head span {
  font-weight: bold !important;
  font-size: 1.1rem !important;
}

.anim-head button {
  background: #eee !important;
  border: none !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 1.2rem !important;
}

.anim-canvas-wrap {
  position: relative !important;
  width: 256px !important;
  height: 256px !important;
  margin: 0 auto !important;
  border: 2px solid #ddd !important;
  border-radius: 8px !important;
  background: white !important;
}

#animCanvas, #onionCanvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 256px !important;
  height: 256px !important;
  border-radius: 8px !important;
}

#animCanvas { z-index: 5 !important; }
#onionCanvas { z-index: 10 !important; pointer-events: none !important; opacity: 0 !important; }

.anim-info {
  text-align: center !important;
  margin: 10px 0 !important;
  color: #666 !important;
}

.anim-btns {
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  margin: 10px 0 !important;
}

.anim-btns button {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  color: white !important;
  border: none !important;
  padding: 8px 15px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-size: 1rem !important;
}

.anim-btns button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

.anim-actions {
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  margin-top: 15px !important;
  padding-top: 15px !important;
  border-top: 2px solid #eee !important;
}

.anim-cell {
  border: 2px solid #667eea !important;
  box-shadow: 0 0 10px rgba(102,126,234,0.5) !important;
}

@media (max-width: 600px) {
  .anim-box { padding: 15px !important; width: 95% !important; }
  .anim-canvas-wrap { width: 100% !important; max-width: 256px !important; }
  #animCanvas, #onionCanvas { width: 100% !important; }
  .anim-actions { flex-direction: column !important; }
  .anim-actions button { width: 100% !important; }
}

/* ========== АНИМАЦИЯ ========== */
#animModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0,0,0,0.9) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 999999 !important;
}

.anim-box {
  background: white !important;
  border-radius: 16px !important;
  padding: 20px !important;
  max-width: 500px !important;
  width: 90% !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5) !important;
}

.anim-head {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 15px !important;
  padding-bottom: 10px !important;
  border-bottom: 2px solid #eee !important;
}

.anim-head span {
  font-weight: bold !important;
  font-size: 1.1rem !important;
}

.anim-head button {
  background: #eee !important;
  border: none !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 1.2rem !important;
}

.anim-canvas-wrap {
  position: relative !important;
  width: 256px !important;
  height: 256px !important;
  margin: 0 auto !important;
  border: 2px solid #ddd !important;
  border-radius: 8px !important;
  background: white !important;
}

#animCanvas, #onionCanvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 256px !important;
  height: 256px !important;
  border-radius: 8px !important;
}

#animCanvas { z-index: 5 !important; }
#onionCanvas { z-index: 10 !important; pointer-events: none !important; opacity: 0 !important; }

.anim-info {
  text-align: center !important;
  margin: 10px 0 !important;
  color: #666 !important;
}

.anim-btns {
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  margin: 10px 0 !important;
}

.anim-btns button {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  color: white !important;
  border: none !important;
  padding: 8px 15px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-size: 1rem !important;
}

.anim-btns button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

.anim-actions {
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  margin-top: 15px !important;
  padding-top: 15px !important;
  border-top: 2px solid #eee !important;
  flex-wrap: wrap !important;
}

.anim-actions button {
  padding: 10px 20px !important;
  border: none !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  color: white !important;
  font-weight: 600 !important;
}

.anim-cell {
  border: 2px solid #667eea !important;
  box-shadow: 0 0 10px rgba(102,126,234,0.5) !important;
}

@media (max-width: 600px) {
  .anim-box { padding: 15px !important; width: 95% !important; }
  .anim-canvas-wrap { width: 100% !important; max-width: 256px !important; }
  #animCanvas, #onionCanvas { width: 100% !important; }
  .anim-actions { flex-direction: column !important; }
  .anim-actions button { width: 100% !important; }
}

/* ========== ЧЕЛЛЕНДЖИ И ДОСТИЖЕНИЯ ========== */

.challenge-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin: 15px auto;
  max-width: 600px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  transition: transform 0.3s;
}

.challenge-card:hover {
  transform: translateY(-3px);
}

.challenge-card.completed {
  border: 2px solid #11998e;
  opacity: 0.7;
}

.challenge-card button {
  background: #667eea;
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 10px;
}

.challenge-card button:disabled {
  background: #11998e;
  cursor: not-allowed;
}

.difficulty-easy { border-left: 4px solid #11998e; }
.difficulty-normal { border-left: 4px solid #667eea; }
.difficulty-hard { border-left: 4px solid #FF4444; }
.difficulty-impossible { border-left: 4px solid #000; }

.timer-display {
  font-size: 2.5rem;
  font-weight: bold;
  color: #FF4444;
  text-align: center;
  margin: 15px 0;
}

.attempts-left {
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  margin: 15px 0;
}

.achievement-popup {
  position: fixed;
  bottom: -200px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 25px 50px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  transition: bottom 0.5s ease;
  z-index: 100000;
}

.achievement-popup.show {
  bottom: 50px;
}

.achievement-popup-content {
  text-align: center;
}

.achievement-popup-content .icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 10px;
}

.achievement-popup-content h3 {
  margin: 10px 0 5px 0;
  font-size: 1.3rem;
}

.achievement-popup-content p {
  margin: 0;
  opacity: 0.9;
}

@media (max-width: 600px) {
  .challenge-card {
    margin: 10px;
    padding: 15px;
  }
  
  .achievement-popup {
    width: 90%;
    padding: 20px;
  }
}

/* Кнопки Челленджи и Достижения */
.challenges-button,
.achievements-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.challenges-button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.achievements-button {
  background: linear-gradient(135deg, #11998e, #38ef7d);
  color: white;
}

.challenges-button:hover,
.achievements-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.challenges-button:active,
.achievements-button:active {
  transform: translateY(0);
}

/* Контейнер для кнопок */
.navigation-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 15px;
  flex-wrap: wrap;
}

/* МОБИЛЬНАЯ ВЕРСИЯ */
@media (max-width: 600px) {
  .navigation-buttons {
    display: flex;
    flex-direction: row;  /* В ряд на телефоне */
    gap: 10px;
    padding: 10px;
    flex-wrap: nowrap;  /* Не переносить */
  }
  
  .challenges-button,
  .achievements-button {
    flex: 1;  /* Растягиваются равномерно */
    min-width: 0;  /* Разрешить сжиматься */
    padding: 10px 15px;
    font-size: 0.9rem;
    white-space: nowrap;  /* Не переносить текст */
  }
  
  /* Иконки на мобильном меньше */
  .challenges-button::before,
  .achievements-button::before {
    font-size: 1.2rem;
  }
}

/* Очень маленькие экраны */
@media (max-width: 350px) {
  .challenges-button,
  .achievements-button {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  .navigation-buttons {
    gap: 8px;
    padding: 8px;
  }
}

/* ============================================ */
/* 🔥 ФИНАЛЬНЫЕ КНОПКИ - ЧЕЛЛЕНДЖИ + ДОСТИЖЕНИЯ */
/* ============================================ */

.nav-container {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 20px 15px !important;
  margin: 20px auto !important;
  max-width: 500px !important;
}

.nav-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 14px 24px !important;
  border-radius: 12px !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
  transition: transform 0.2s !important;
  white-space: nowrap !important;
}

.nav-btn.challenges {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
}

.nav-btn.achievements {
  background: linear-gradient(135deg, #11998e, #38ef7d) !important;
}

.nav-btn:hover {
  transform: translateY(-2px) !important;
}

/* ТЕЛЕФОН - ИСПРАВЛЕНИЕ */
@media screen and (max-width: 600px) {
  .nav-container {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding: 15px 10px !important;
    width: 95% !important;
  }
  
  .nav-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 48% !important;
    padding: 12px 10px !important;
    font-size: 0.85rem !important;
  }
}

@media screen and (max-width: 350px) {
  .nav-btn {
    padding: 10px 8px !important;
    font-size: 0.75rem !important;
  }
}
  
