body { 
  margin: 0; 
  background: #111; 
  overflow-x: hidden;  /* чтобы горизонтального скролла не было */
  overflow-y: auto;
  color: #eee; 
  font-family: sans-serif; 
}

/* Предотвращение скролла фона при открытом модальном окне */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  max-width: 1000px;
  margin: auto;
}

/* Стили для заголовка и описания проекта */
.project-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 20px;
  background: linear-gradient(135deg, #111 0%, #222 100%);
  border-radius: 15px;
  border: 2px solid #333;
}

.project-title {
  font-size: 48px;
  font-weight: bold;
  color: #3ddc84;
  margin-bottom: 15px;
  text-shadow: 0 2px 10px rgba(61, 220, 132, 0.3);
}

.project-subtitle {
  font-size: 18px;
  color: #cccccc;
  margin-bottom: 25px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.project-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.project-links {
  display: flex;
  align-items: center;
  gap: 15px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3ddc84;
  text-decoration: none;
  padding: 8px 15px;
  border: 2px solid #3ddc84;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-weight: bold;
}

.github-link:hover {
  background: #3ddc84;
  color: #111;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(61, 220, 132, 0.3);
}

.university-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cccccc;
  font-size: 14px;
}

.university-logo {
  height: 40px;
  width: auto;
  border-radius: 5px;
}

.divider {
  height: 30px;
  width: 1px;
  background: #444;
}

/* Стили для footer */
.project-footer {
  text-align: center;
  margin-top: 50px;
  padding: 20px;
  color: #666;
  font-size: 12px;
  border-top: 1px solid #333;
}

.card {
  display: flex;
  background: #111;
  border-radius: 12px;
  border: 2px solid #333;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
  height: 350px;
}

.card:hover {
  transform: scale(1.02);
}

.card canvas {
  width: 66.6%;
  height: 100%;
  display: block;
  background: #111;
  transition: opacity 0.3s ease;
}

.card:hover canvas {
  opacity: 1;
}

.card canvas:not(:hover) {
  opacity: 0.8;
}

.card .desc {
  width: 33.3%;
  padding: 20px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: #222;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.4;
  overflow: visible;
  word-wrap: break-word;
}

.card .desc .title {
  text-align: center;
  font-weight: bold;
  font-size: 18px;
  color: #3ddc84;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 40px;
}

.card .desc .description {
  text-align: justify;
  color: #cccccc;
  display: flex;
  align-items: center;
  font-size: 16px;
  padding: 30px;
  padding-top: 20px;
}

/* Мобильная адаптивность для карточек */
@media (max-width: 768px) {
  .container {
    padding: 10px;
    gap: 15px;
  }

  .card {
    flex-direction: column;
    height: auto;
    min-height: 400px;
  }

  .card:hover {
    transform: scale(1.01);
  }

  .card canvas {
    width: 100%;
    height: 250px;
    flex-shrink: 0;
  }

  .card .desc {
    width: 100%;
    text-align: center;
    padding: 15px;
    min-height: 150px;
    justify-content: center;
  }

  .card .desc .title {
    font-size: 16px;
    padding-top: 10px;
    margin-bottom: 10px;
  }

  .card .desc .description {
    font-size: 14px;
    padding: 10px;
    text-align: center;
    line-height: 1.5;
  }
}

/* Улучшенная адаптивность для очень маленьких экранов */
@media (max-width: 480px) {
  .container {
    padding: 5px;
    gap: 10px;
  }

  .card {
    min-height: 350px;
  }

  .card canvas {
    height: 200px;
  }

  .card .desc {
    min-height: 120px;
    padding: 10px;
  }

  .card .desc .title {
    font-size: 15px;
  }

  .card .desc .description {
    font-size: 13px;
    padding: 8px;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay.active {
  display: flex;
}

.modal {
  position: relative;
  width: 90%;
  height: 90%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.modal iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  background: #222;
  color: #eee;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  z-index: 1001;
  font-size: 16px;
}

.close-btn:hover {
  background: #444;
}

/* Мобильная кнопка закрытия - убираем обводку */
.mobile-close-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: rgba(34, 34, 34, 0.95);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  z-index: 1002;
  font-size: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.mobile-close-btn:hover {
  background: #3ddc84;
  color: #111;
  transform: scale(1.05);
}

.mobile-close-btn:active {
  transform: scale(0.95);
}

/* Мобильная адаптивность для модального окна - ИЗМЕНЕН БРЕЙКПОИНТ С 768 НА 770 */
@media (max-width: 770px) {
  .modal {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* Показывать мобильную кнопку только на мобильных устройствах */
  .mobile-close-btn {
    display: flex;
  }
  
  /* Скрываем обычную кнопку закрытия на мобильных */
  .close-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .mobile-close-btn {
    width: 45px;
    height: 45px;
    font-size: 20px;
    top: 15px;
    right: 15px;
  }
}

canvas { 
  width: 100vw; 
  height: 100vh; 
  display: block; 
}

.controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* Boids */
#advancedBtn {
  background: #222;
  border: none;
  color: white;
  border-radius: 5px;
  width: 100%;
  font-size: 13px;
  padding: 5px 5px;
}

#advancedBtn:hover {
  background: #555;
}

#advancedCG {
  margin: 0;
}

#controlPanel {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  border-radius: 10px;
  font-size: 14px;
  max-width: 300px;
  transition: all 0.3s ease;
  z-index: 1001;
  padding: 0;
}

/* Мобильная адаптивность для панели управления - выравнивание с кнопкой закрытия и повышение z-index - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  #controlPanel {
    top: 20px;
    left: 20px;
    right: auto;
    max-width: none;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  #controlPanel {
    top: 15px;
    left: 15px;
    font-size: 12px;
  }
}

#controlPanel.collapsed {
  width: 30px; 
  height: 21px;
  border-radius: 5px;
  padding: 0;
}

/* Мобильная адаптивность для свернутой панели - тот же размер что и кнопка закрытия - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  #controlPanel.collapsed {
    width: 50px;
    height: 50px;
    border-radius: 8px;
  }
}

@media (max-width: 480px) {
  #controlPanel.collapsed {
    width: 45px;
    height: 45px;
    border-radius: 8px;
  }
}

#controlPanel {
  padding: 15px;
  z-index: 1003; /* Перекрываем кнопку закрытия при развертывании */
}

/* Мобильная адаптивность для развернутой панели - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  #controlPanel {
    padding: 10px;
    z-index: 1005; /* Перекрываем кнопку закрытия при развертывании на мобильных */
  }
}

#toggleBtn {
  background: #222;
  border: none;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 5px 5px;
  margin-bottom: 10px;
}

#controlPanel.collapsed #toggleBtn {
  border-radius: 5px;
  margin: 0;
  font-size: 17px;
  padding-top: 3px;
  padding-bottom: 2px;
}

/* Мобильная адаптивность для кнопки в свернутой панели - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  #controlPanel.collapsed #toggleBtn {
    border-radius: 8px;
    font-size: 20px;
    padding: 0;
    width: 100%;
    height: 100%;
  }
}

@media (max-width: 480px) {
  #controlPanel.collapsed #toggleBtn {
    font-size: 18px;
  }
}

#controlPanel:not(.collapsed) #toggleBtn {
  border-radius: 5px;
  margin-bottom: 10px;
  font-size: 20px;
  padding-top: 0px;
  padding-bottom: 5px;
}

/* Мобильная адаптивность для кнопки переключения - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  #toggleBtn {
    font-size: 14px;
    padding: 8px;
  }

  #controlPanel:not(.collapsed) #toggleBtn {
    font-size: 18px;
  }
}

#toggleBtn:hover {
  background: #555;
}

#mainControls {
  display: block;
}

#controlPanel.collapsed #mainControls {
  display: none !important;
}

.control-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Мобильная адаптивность для групп управления - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .control-group {
    margin-bottom: 12px;
    gap: 6px;
  }
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

/* Мобильная адаптивность для строк управления - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .control-row {
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
  }
}

.button-group {
  display: flex;
  background: #222;
  border-radius: 5px;
  flex-wrap: wrap; 
  padding: 4px;
  min-height: 35px;
  justify-content: space-around;
}

/* Мобильная адаптивность для групп кнопок - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .button-group {
    min-height: 40px;
    padding: 6px;
  }
}

.control-row label {
  min-width: 135px;
  font-size: 12px;
}

/* Мобильная адаптивность для меток - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .control-row label {
    min-width: 100px;
    font-size: 11px;
  }
}

.control-row input[type="range"] {
  flex: 1;
  min-width: 100px;
}

/* Мобильная адаптивность для слайдеров - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .control-row input[type="range"] {
    min-width: 80px;
  }
}

.control-row button, .button-group button {
  background: transparent;
  border: 0px;
  min-width: 70px;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
}

/* Мобильная адаптивность для кнопок - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .control-row button, .button-group button {
    min-width: 60px;
    padding: 6px 8px;
    font-size: 10px;
  }
}

.control-row button:hover, .button-group button:hover {
  background: #444;
}

.control-row button.active {
  background: #0066cc;
}

#advancedControls {
  display: none;
  margin-top: 15px;
}

#advancedControls.show {
  display: block;
}

.value-display {
  min-width: 40px;
  text-align: center;
  font-size: 11px;
  color: #ccc;
}

/* Мобильная адаптивность для отображения значений - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .value-display {
    min-width: 35px;
    font-size: 10px;
  }
}

#k_topo, #damp {
  display: none;
}

#k_topo.show, #damp.show {
  display: block;
}

#neighborBtn, #dampBtn {
  background: #222;
  border: none;
  color: white;
  border-radius: 5px;
  width: 100%;
  font-size: 10px;
  margin-bottom: 3px;
}

#neighborBtn:hover, #dampBtn:hover {
  background: #555;
}

/* ACO */
#visualBtn, #graphTypeBtn, #startDistBtn, #funcBtn, #annealBtn, #initHeadingsBtn, #initPositionsBtn {
  background: #222;
  border: none;
  color: white;
  border-radius: 5px;
  width: 100%;
  font-size: 10px;
  margin-bottom: 3px;
}

#visualBtn:hover, #graphTypeBtn:hover, #startDistBtn:hover, #funcBtn:hover, #annealBtn:hover, #initPositionsBtn:hover, #initHeadingsBtn:hover {
  background: #555;
}

.info-display {
  width: 100%;
  margin-bottom: 10px;
}

.id-lables, .id-values {
  text-align: center;
}

table, th, td {
  border: 1px solid;
  border-color: #333;
}

/* Мобильная адаптивность для таблиц - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  table {
    font-size: 12px;
  }

  th, td {
    padding: 4px;
  }
}

/* Стили для всплывающих подсказок */
.tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  max-width: 350px;
  z-index: 10000;
  display: none;
  pointer-events: none;
  line-height: 1.5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Мобильная адаптивность для подсказок - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .tooltip {
    max-width: 280px;
    font-size: 12px;
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .tooltip {
    max-width: 250px;
    font-size: 11px;
    padding: 8px;
  }
}

.tooltip strong {
  color: #3ddc84;
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

/* Мобильная адаптивность для заголовков подсказок - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .tooltip strong {
    font-size: 13px;
    margin-bottom: 6px;
  }
}

.tooltip-label {
  cursor: help;
  position: relative;
  transition: color 0.2s ease;
}

.tooltip-label:hover {
  color: #3ddc84;
}

/* Стили для MathJax в подсказках */
.tooltip .MathJax {
  font-size: 12px !important;
}

.tooltip mjx-container {
  margin: 2px 0 !important;
}

/* Убираем подчёркивание у tooltip-label */
.tooltip-label {
  text-decoration: none;
  border-bottom: none;
}

#seed, #rngSeed {
  background: #222;
  color: white;
  border-radius: 3px;
  border: none;
  width: 100%;
  text-align: center;
  outline: none;
}

#seed_container {
  margin-top: 5px;
  margin-bottom: 5px;
}

#seed::-webkit-outer-spin-button,
#seed::-webkit-inner-spin-button,
#rngSeed::-webkit-outer-spin-button,
#rngSeed::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#seed, #rngSeed {
  -moz-appearance: textfield;
}

.algorithm {
    margin: 30px 0;
    padding: 20px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #1a1a1a;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* Мобильная адаптивность для алгоритмов - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .algorithm {
    margin: 20px 0;
    padding: 15px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .algorithm {
    margin: 15px 0;
    padding: 10px;
    font-size: 12px;
  }
}

.algorithm-caption {
    font-size: 16px;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    font-family: 'Times New Roman', Times, serif;
}

/* Мобильная адаптивность для заголовков алгоритмов - ИЗМЕНЕН БРЕЙКПОИНТ НА 770 */
@media (max-width: 770px) {
  .algorithm-caption {
    font-size: 15px;
    margin-bottom: 12px;
    padding-bottom: 8px;
  }
}

.algorithm-input, .algorithm-output {
    margin: 10px 0;
    padding: 5px 0;
    font-family: 'Times New Roman', Times, serif;
}

.algorithm-body {
    margin-top: 15px;
}

.algorithm-line {
    margin: 5px 0;
    line-height: 1.4;
}

.algorithm-init {
    font-weight: bold;
    margin: 10px 0;
    color: #81c784;
}

.algorithm-for, .algorithm-while, .algorithm-foreach {
    font-weight: bold;
    margin: 10px 0 5px 0;
    color: #4CAF50;
}

.algorithm-comment {
    color: #888;
    font-style: italic;
    margin: 5px 0;
}

.algorithm-return {
    font-weight: bold;
    color: #ff9800;
    margin: 10px 0;
}

/* Адаптивность для проектного заголовка */
@media (max-width: 768px) {
  .project-header {
    padding: 20px 15px !important;
    margin-bottom: 30px !important;
  }

  .project-title {
    font-size: 36px !important;
  }

  .project-subtitle {
    font-size: 16px !important;
    margin-bottom: 20px !important;
  }

  .project-info {
    flex-direction: column !important;
    gap: 15px !important;
  }

  .divider {
    width: 100% !important;
    height: 1px !important;
  }

  .github-link {
    padding: 10px 20px !important;
    font-size: 14px !important;
  }

  .university-info {
    text-align: center;
    font-size: 13px !important;
  }

  .university-logo {
    height: 35px !important;
  }
}

@media (max-width: 480px) {
  .project-header {
    padding: 15px 10px !important;
    margin-bottom: 20px !important;
  }

  .project-title {
    font-size: 28px !important;
  }

  .project-subtitle {
    font-size: 14px !important;
  }

  .github-link {
    padding: 8px 16px !important;
    font-size: 13px !important;
  }

  .university-info {
    font-size: 12px !important;
  }

  .university-logo {
    height: 30px !important;
  }
}
