/* === БАЗОВАЯ ЗАЩИТА === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
 
  touch-action: manipulation;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  min-width: 320px;
  min-height: 570px;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  cursor: default;
  background: linear-gradient(135deg, #005f2b, #008000b7, #2a7703);
  transition: background 0.5s ease;
  overscroll-behavior: none;
}

/* === КОНТЕЙНЕР ИГРЫ === */
.container {
  text-align: center;
  background: rgba(0, 10, 5, 0.85);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 0 20px var(--neon-glow);
  max-width: 96vw;
  max-height: 96vh;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  backdrop-filter: blur(4px);
  border: 1px solid var(--neon-secondary);
}

h1 {
  margin-bottom: 12px;
  font-size: 1.8rem;
  text-shadow: 0 0 12px var(--neon-glow-strong);
  color: var(--neon-primary);
  white-space: nowrap;
}

.settings-btn {
  align-self: flex-end;
  margin-left: auto;
  margin-bottom: 8px;
  background: rgba(0, 20, 10, 0.7);
  border: 2px solid var(--neon-secondary);
  color: var(--neon-primary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 0 8px var(--neon-glow);
  position: static; /* ← ВАЖНО: убираем absolute */
}

.settings-btn:hover {
  border-color: var(--neon-primary);
  box-shadow: 0 0 12px var(--neon-glow-strong);
  background: rgba(0, 30, 15, 0.8);
}

/* === ИГРОВОЕ ПОЛЕ === */
#gameCanvas {
  border: 2px solid var(--neon-primary);
  background-color: rgba(0, 15, 5, 0.6);
  display: block;
  margin: 2 auto 12px auto;
  box-shadow: 0 0 18px var(--neon-glow);
  max-width: 94vw;
  max-height: 60vh;
  width: auto;
  height: auto;
}

/* === СЕНСОРНЫЕ КНОПКИ === */
.touch-controls {
 display: none !important;
  margin: 10px auto;
  max-width: 220px;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}





/* === КНОПКИ УПРАВЛЕНИЯ === */
.action-buttons {
  margin: 10px 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-buttons button {
  height: 36px;
  padding: 0 16px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 2px solid var(--neon-secondary);
  border-radius: 7px;
  cursor: pointer;
  outline: none;
  transition: all 0.25s ease;
  box-shadow: 0 0 9px var(--neon-glow);
  background: rgba(0, 20, 10, 0.7);
  color: var(--neon-primary);
  min-width: 100px;
}

.action-buttons button:hover {
  border-color: var(--neon-primary);
  box-shadow: 0 0 14px var(--neon-glow-strong);
  background: rgba(0, 30, 15, 0.8);
  color: white;
}

#pauseBtn {
  border-color: #ffaa00;
  background: rgba(30, 20, 0, 0.7);
  box-shadow: 0 0 9px rgba(255, 170, 0, 0.5);
}

#pauseBtn:hover {
  border-color: #ffcc00;
  box-shadow: 0 0 14px rgba(255, 204, 0, 0.7);
  background: rgba(40, 25, 0, 0.8);
  color: #fff9aa;
}

#score {
  margin-top: 8px;
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--neon-primary);
  text-shadow: 0 0 8px var(--neon-glow);
}

/* === МОДАЛЬНЫЕ ОКНА === */
.modal {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center;
  display: flex;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: rgba(5, 15, 5, 0.92);
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 0 25px var(--neon-glow);
  border: 1px solid var(--neon-secondary);
  max-width: 90vw;
  width: 320px;
  text-align: center;
}

.modal-content h2 {
  color: var(--neon-primary);
  margin-bottom: 16px;
  text-shadow: 0 0 10px var(--neon-glow);
}

.modal-content p {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

#finalScore {
  color: #ffcc00;
  font-weight: bold;
}

.close-btn, #restartBtn {
  background: rgba(0, 20, 10, 0.7);
  border: 2px solid var(--neon-secondary);
  color: var(--neon-primary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 0 10px var(--neon-glow);
}

.close-btn:hover, #restartBtn:hover {
  border-color: var(--neon-primary);
  box-shadow: 0 0 15px var(--neon-glow-strong);
  background: rgba(0, 30, 15, 0.8);
}

/* === НАСТРОЙКИ В МОДАЛЬНОМ ОКНЕ === */
.setting {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.setting label {
  margin-bottom: 6px;
  font-weight: bold;
  color: var(--neon-primary);
  text-shadow: 0 0 6px var(--neon-glow);
  font-size: 0.95rem;
}

select {
  height: 36px;
  padding: 0 12px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 2px solid var(--neon-secondary);
  border-radius: 7px;
  background: rgba(0, 20, 10, 0.7);
  color: var(--neon-primary);
  cursor: pointer;
  outline: none;
  box-shadow: 0 0 9px var(--neon-glow);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2300cc66'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 34px;
  min-width: 110px;
}

.snake-style-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

.style-btn {
  width: 48px;
  height: 24px;
  background: rgba(0, 20, 10, 0.5);
  border: 2px solid var(--neon-secondary);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  outline: none;
}

.style-btn.active {
  border-color: var(--neon-primary);
  box-shadow: 0 0 10px var(--neon-glow-strong);
  transform: scale(1.08);
}

.preview-head, .preview-body {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

/* === НЕОНОВЫЕ ПЕРЕМЕННЫЕ === */
:root {
  --neon-primary: #00ffcc;
  --neon-secondary: #00cc66;
  --neon-glow: rgba(0, 255, 204, 0.6);
  --neon-glow-strong: rgba(0, 255, 204, 0.8);
}

/* === МОБИЛЬНЫЙ ВИД === */
@media (max-width: 768px) {
  .touch-controls {
      display: none ;
  }

  h1 {
    font-size: 1.6rem;
  }

  .container {
   padding: 12px 12px 12px 12px;
    max-height: 97vh;
  }

  #gameCanvas {
    max-height: 50vh;
  }
}

.hidden {
  display: none;
}

/* Запрет масштабирования на десктопе */
@media screen and (min-width: 768px) {
  body {
    zoom: 1 !important;
    transform: scale(1);
    transform-origin: 0 0;
  }
}


/* Поддержка RTL (арабский, иврит, персидский) */
[dir="rtl"] .container {
  text-align: right;
}

[dir="rtl"] .touch-row {
  flex-direction: row-reverse;
}

[dir="rtl"] .settings-btn {
  margin-left: 0;
  margin-right: auto;
}

/* Скрыть сенсорные кнопки на мобильных 
@media (max-width: 768px) {
  #touchControls {
    display: none !important;
  }
}*/