/* ==============================================================
   ОБЩИЕ СТИЛИ
   ============================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #1e1e1e;
  color: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  touch-action: none;
  overflow: hidden;
}


/* ==============================================================
   АВТОРИЗАЦИЯ
   ============================================================== */

#auth {
  background: #2a2a2a;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  width: 360px;
  text-align: center;
}
#auth h2 {
  margin-top: 0;
}
#auth input,
#auth select {
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  border: 1px solid #555;
  border-radius: 4px;
  background: #1a1a1a;
  color: #fff;
}
#auth select option {
  background: #1a1a1a;
}
#auth button {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border: none;
  border-radius: 4px;
  background: #4caf50;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}
#auth button:hover {
  background: #45a049;
}
#auth .error {
  color: #ff6b6b;
  font-size: 14px;
  margin-top: 8px;
}
#auth .switch {
  margin-top: 12px;
  font-size: 14px;
  cursor: pointer;
  color: #66b0ff;
}
#auth .switch:hover {
  text-decoration: underline;
}

/* ==============================================================
   ПРИЛОЖЕНИЕ (основной контейнер и холст)
   ============================================================== */

#app {
  display: none;
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
}
#app canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #2a2a2a;
  cursor: default;
  touch-action: none;
}
#app canvas:active {
  cursor: none;
}

/* Курсор на холсте – для режима "рука" */
canvas {
  cursor: grab;
  touch-action: none;
}
canvas:active {
  cursor: grabbing;
}


/* ==============================================================
   КОМПАКТНЫЙ ТУЛБАР (слева сверху)
   ============================================================== */

#toolbar {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 400px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
#toolbar .row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
#toolbar .row > * {
  margin: 2px 0;
}
#toolbar button,
#toolbar .mode-btn {
  font-size: 12px;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: #444;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
#toolbar button:hover,
#toolbar .mode-btn:hover {
  background: #555;
}
#toolbar .mode-btn.active {
  background: #007bff;
}
#toolbar .neutral-colors {
  display: flex;
  gap: 2px;
}
#toolbar .neutral-color {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #666;
  transition: transform 0.1s;
}
#toolbar .neutral-color:hover {
  transform: scale(1.1);
}
#toolbar .neutral-color.active {
  border: 2px solid #fff;
  box-shadow: 0 0 8px #fff;
}

/* Сворачиваемые блоки внутри тулбара (новости, правила, улучшения) */
#newsContainer,
#rulesContainer,
#upgradesContainer {
  margin-top: 4px;
  width: 100%;
}
#newsHeader,
#rulesHeader,
#upgradesHeader {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #90caf9;
  font-size: 12px;
  padding: 2px 0;
}
#upgradesHeader {
  color: #ffd700;
}
#newsContent,
#rulesContent,
#upgradesContent {
  color: #ccc;
  font-size: 12px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  margin-top: 4px;
  max-width: 280px;
  overflow-y: auto;
  display: none;
  line-height: 1.6;
}
#newsContent {
  color: #90caf9;
  max-height: 200px;
}
#rulesContent {
  max-height: 150px;
}
#upgradesContent {
  max-height: 250px;
}

/* Блок улучшений (прогресс-бар и пр.) */
#upgradesContent .collector-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#upgradesContent .collector-info .progress-bar {
  width: 100%;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}
#upgradesContent .collector-info .progress-bar .fill {
  height: 100%;
  background: #ffd700;
  transition: width 0.5s;
}
#upgradesContent .collector-info .timer {
  color: #ff6b6b;
  font-weight: bold;
}
#upgradesContent .buy-btn-small {
  padding: 4px 10px;
  background: #6c5ce7;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  transition: 0.2s;
  margin-top: 4px;
  width: 100%;
}
#upgradesContent .buy-btn-small:hover {
  background: #5a4bd1;
}
#upgradesContent .buy-btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.upgrades-toggle {
  color: #ffd700;
  font-size: 12px;
}
.help-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #555;
  color: #fff;
  text-align: center;
  line-height: 16px;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  margin-left: 6px;
  transition: 0.2s;
}
.help-icon:hover {
  background: #777;
}

/* ==============================================================
   АВАТАР В ТУЛБАРЕ (увеличенный)
   ============================================================== */

#userAvatar {
  display: none; /* будет показан через JS */
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  color: #000;
  cursor: pointer;
  border: 2px solid #fff;
  background: #555;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  user-select: none;
}
#userAvatar:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

/* ==============================================================
   ВЫБОР ИКОНОК В ПРОФИЛЕ
   ============================================================== */

.icon-options-wrapper {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.icon-option {
  font-size: 30px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  border: 2px solid transparent;
  user-select: none;
  line-height: 1;
}
.icon-option:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.1);
}
.icon-option.active {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.15);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}


/* ==============================================================
   ИНФОРМАЦИОННЫЕ ПАНЕЛИ (нижние)
   ============================================================== */

#info {
  position: fixed;
  bottom: 20px;
  left: 20px;
  color: #ccc;
  font: 14px monospace;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 14px;
  border-radius: 6px;
  user-select: none;
  pointer-events: none;
  z-index: 10;
  max-width: 80%;
}
#status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: #aaa;
  font: 12px monospace;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 4px;
  z-index: 10;
}

/* ---- НИЖНЯЯ СТРОКА (playerInfo) ---- */
#playerInfo {
  position: fixed;
  bottom: 150px;        /* для десктопа */
  left: 20px;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 12px;
  border-radius: 20px;
  z-index: 20;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #eee;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
#playerInfo .pi-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 12px;
  transition: background 0.2s;
}
#playerInfo .pi-item:hover {
  background: rgba(255, 255, 255, 0.1);
}
#playerInfo .pi-avatar {
  font-size: 20px;
  font-weight: bold;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #000;
}
#playerInfo .pi-login {
  font-weight: bold;
  color: #66b0ff;
}
#playerInfo .pi-points {
  color: #ffd700;
}
#playerInfo .pi-base {
  font-size: 18px;
  color: #fff;
}
#playerInfo .pi-diamonds {
  font-size: 18px;
  color: #FFD700;
}
#playerInfo .pi-sep {
  color: #555;
  margin: 0 2px;
}

/* ---- Метка кракена ---- */
.kraken-label {
  position: fixed;
  bottom: 100px;
  left: 20px;
  color: #ff6666;
  font: 14px Arial;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 10;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  transition: 0.2s;
}
.kraken-label:hover {
  background: rgba(255, 0, 0, 0.3);
  transform: scale(1.05);
}

/* ---- Метка озеленителя ---- */
.gardener-label {
  position: fixed;
  bottom: 60px;
  left: 20px;
  color: #00cc44;
  font: 14px Arial;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 10;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  transition: 0.2s;
}
.gardener-label:hover {
  background: rgba(0, 204, 68, 0.3);
  transform: scale(1.05);
}


/* ==============================================================
   МОБИЛЬНЫЕ УСТРОЙСТВА (ширина < 768px) – минимальный зазор 1px
   ============================================================== */
@media (max-width: 768px) {
  /* Все панели расположены с зазором ~1px друг от друга */
  #info {
    bottom: 10px;
  }
  .gardener-label {
    bottom: 40px;          /* 10 + высота info (~20px) + 1px зазор */
  }
  .kraken-label {
    bottom: 72px;          /* 40 + высота gardener (~30px) + 1px зазор */
  }
  #playerInfo {
    bottom: 110px;         /* 72 + высота kraken (~30px) + 1px зазор */
    font-size: 12px;
    padding: 2px 8px;
    gap: 4px;
    flex-wrap: wrap;
  }
  #playerInfo .pi-avatar {
    width: 24px;
    height: 24px;
    font-size: 16px;
  }
  #playerInfo .pi-base,
  #playerInfo .pi-diamonds {
    font-size: 14px;
  }

  #footer {
    font-size: 8px !important;
    padding: 2px 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
  }
  #footer a,
  #footer span {
    font-size: 8px !important;
  }

  #scoreBoard {
    padding: 4px 6px 6px 6px;
    min-width: 60px;
    top: 8px;
    right: 8px;
  }
  #scoreBoard .label {
    font-size: 8px;
    margin-top: 2px;
    line-height: 1.2;
  }
  #teamChart {
    width: 70px;
    height: 70px;
  }

  #notification {
    bottom: 80px;
    right: 10px;
    font-size: 12px;
    padding: 8px 12px;
    max-width: 200px;
  }
}


/* ==============================================================
   Остальные стили (круговая диаграмма, палитра, модалки, футер и т.д.)
   ============================================================== */

#scoreBoard {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 8px 8px 8px;
  border-radius: 8px;
  z-index: 100;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  user-select: none;
}
#scoreBoard:hover {
  background: rgba(0, 0, 0, 0.9);
}
#scoreBoard .label {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
  letter-spacing: 0.3px;
}
#teamChart {
  display: block;
  margin: 0 auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
}


/* ==============================================================
   ПАЛИТРА (выбор цвета)
   ============================================================== */

#colorPicker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#teamColorBtn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transform: translateY(0);
}
#teamColorBtn:active:not(.active) {
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
}
#teamColorBtn.active {
  box-shadow: 0 0 0 2px #fff, 0 0 24px rgba(255, 255, 255, 0.25),
    inset 0 -2px 0 rgba(0, 0, 0, 0.4);
  transform: scale(1.05);
  filter: brightness(1.15);
}

.neutral-colors {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.neutral-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.2);
  transform: translateY(0);
}
.neutral-color:active:not(.active) {
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
}
.neutral-color.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 24px rgba(255, 255, 255, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  transform: scale(1.12);
  filter: brightness(1.1);
}
.neutral-color:hover {
  transform: scale(1.06);
  border-color: rgba(255, 255, 255, 0.4);
}
.neutral-color.active:hover {
  transform: scale(1.12);
}


/* ==============================================================
   МОДАЛЬНЫЕ ОКНА (общие стили)
   ============================================================== */

#profileModal,
#playersModal,
#msRulesModal,
#collectorModal,
#kakashkaModal,
#feedbackModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-content {
  background: #2a2a2a;
  padding: 30px;
  border-radius: 12px;
  min-width: 320px;
  max-width: 90%;
  text-align: center;
  color: #eee;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 {
  margin-top: 0;
  color: #ffd700;
  font-weight: 400;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}
.modal-content .close-btn {
  margin-top: 15px;
  background: #444;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
}
.modal-content .close-btn:hover {
  background: #555;
}
.modal-content .close-modal {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  cursor: pointer;
  color: #aaa;
  background: none;
  border: none;
}
.modal-content .close-modal:hover {
  color: #fff;
}

/* Специфичные модалки */
#profileModal .modal-content .avatar-big {
  width: 80px;
  height: 80px;
  margin: 0 auto 10px;
}
#profileModal .modal-content .avatar-big canvas {
  border-radius: 50%;
}
#profileModal .modal-content .logout-btn {
  background: #d9534f;
  color: #fff;
  margin-top: 8px;
}
#profileModal .modal-content .logout-btn:hover {
  background: #c9302c;
}

#collectorModal .modal-content .price {
  font-size: 24px;
  font-weight: bold;
  color: #ffd700;
  text-align: center;
  margin: 16px 0;
}
#collectorModal .modal-content .description {
  font-size: 14px;
  line-height: 1.6;
  color: #ccc;
  margin: 16px 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}
#collectorModal .modal-content .buy-btn {
  width: 100%;
  padding: 12px;
  background: #6c5ce7;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
#collectorModal .modal-content .buy-btn:hover {
  background: #5a4bd1;
  transform: scale(1.02);
}
#collectorModal .modal-content .buy-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
#collectorModal .modal-content .info-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #555;
  color: #fff;
  text-align: center;
  line-height: 20px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 8px;
  font-size: 14px;
  transition: 0.2s;
}
#collectorModal .modal-content .info-icon:hover {
  background: #777;
}

#kakashkaModal .modal-content .list-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ==============================================================
   КАКАШКА НА КАРТЕ (анимация)
   ============================================================== */

@keyframes kakashkaPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.kakashka-pulse {
  animation: kakashkaPulse 1.5s infinite ease-in-out;
}

/* ==============================================================
   ДОПОЛНИТЕЛЬНО: ЭЛЕМЕНТ ДЛЯ КНОПКИ СБОРЩИКА НА БАЗЕ (не используется)
   ============================================================== */

#baseCollectorBtn {
  position: absolute;
  z-index: 30;
  cursor: pointer;
  font-size: 28px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 2px solid #ffd700;
  transition: 0.2s;
  pointer-events: auto;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
  line-height: 44px;
  text-align: center;
  user-select: none;
}
#baseCollectorBtn:hover {
  transform: scale(1.15);
  background: rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 40;
  display: none;
  border: 1px solid rgba(255, 215, 0, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Эффекты наведения для кнопок тулбара */
#toolbar button:hover,
#toolbar .mode-btn:hover {
    transform: scale(1.05);
    transition: 0.15s;
}
#toolbar button:active,
#toolbar .mode-btn:active {
    transform: scale(0.95);
}

/* ==============================================================
   МОДАЛЬНОЕ ОКНО ОБРАТНОЙ СВЯЗИ
   ============================================================== */
#feedbackModal .modal-content {
  max-width: 450px;
  width: 90%;
}
#feedbackModal .modal-content label {
  font-size: 13px;
  color: #ccc;
  display: block;
  text-align: left;
}
#feedbackModal .modal-content input,
#feedbackModal .modal-content select,
#feedbackModal .modal-content textarea {
  width: 100%;
  padding: 8px;
  background: #1a1a1a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  margin-top: 4px;
  font-size: 13px;
}
#feedbackModal .modal-content textarea {
  resize: vertical;
}
#feedbackModal .modal-content button {
  cursor: pointer;
  transition: 0.2s;
}
#feedbackModal .modal-content button:hover {
  opacity: 0.9;
}
#feedbackModal .modal-content .close-btn {
  background: #444;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
}
#feedbackModal .modal-content .close-btn:hover {
  background: #555;
}

/* ==============================================================
   ФУТЕР (копирайт, ссылки)
   ============================================================== */
#footer {
  position: fixed;
  bottom: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #888;
  z-index: 10;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 0;
}
#footer a {
  color: #66b0ff;
  text-decoration: none;
}
#footer a:hover {
  text-decoration: underline;
}
#footer span {
  pointer-events: auto;
}

/* ==============================================================
   УВЕДОМЛЕНИЯ (справа снизу)
   ============================================================== */
#notification {
  display: none;
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  z-index: 1000;
  font-size: 14px;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: opacity 0.3s;
  font-weight: 500;
  line-height: 1.4;
}
#notification.show {
  opacity: 1;
}
#notification.hide {
  opacity: 0;
}

/* ==============================================================
   АДАПТАЦИЯ ОКНА ВХОДА ДЛЯ МОБИЛЬНЫХ
   ============================================================== */
@media (max-width: 768px) {
  #auth {
    width: 90%;
    padding: 20px;
  }
  #auth input,
  #auth select,
  #auth button {
    font-size: 18px !important;
    padding: 14px !important;
    margin: 10px 0 !important;
  }
  #auth h2 {
    font-size: 24px;
  }
  #auth .switch {
    font-size: 16px;
  }
}