.umodal {
  width: 92%;
  max-width: 1100px; /* чуть шире */
  max-height: calc(100vh - 120px); /* 40-60px сверху/снизу + исключаем header/footer */
  overflow: hidden;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.92);
  color: #ecf0f1;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7), 0 0 40px rgba(59, 204, 168, 0.18);
  border: 1px solid rgba(59, 204, 168, 0.28);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
}

/* Фиксированная высота модалки (чтобы контент не менял размер окна) */
.umodal--fixed {
  height: calc(100vh - 120px);
}

/* Чуть шире для больших страниц (tos/account protection) */
.umodal--wide {
  max-width: 1280px;
  --umodal-inner-max: 1280px;
}

/* Специально для страницы правил: шире и с большим отступом от header/footer */
.umodal--tos {
  max-width: 1380px;
  --umodal-inner-max: 1380px;
  max-height: calc(100vh - 160px);
  justify-content: flex-start;
}

/* Фиксированная высота именно для правил */
.umodal--fixed.umodal--tos {
  height: calc(100vh - 160px);
}

/* Страница защиты аккаунта: фиксированная высота + больше воздуха сверху/снизу */
.umodal--ap {
  max-height: calc(100vh - 180px);
  justify-content: flex-start;
}

.umodal--fixed.umodal--ap {
  height: calc(100vh - 180px);
}

/* Monitoring: окно чуть ниже по высоте, чтобы не подпирало header */
.umodal--monitoring {
  max-height: calc(100vh - 180px);
  justify-content: flex-start;
}

.umodal--fixed.umodal--monitoring {
  height: calc(100vh - 180px);
}

@supports (height: 100dvh) {
  .umodal {
    max-height: calc(100dvh - 120px);
  }
  .umodal--fixed {
    height: calc(100dvh - 120px);
  }
  .umodal--tos {
    max-height: calc(100dvh - 160px);
  }
  .umodal--fixed.umodal--tos {
    height: calc(100dvh - 160px);
  }
  .umodal--ap {
    max-height: calc(100dvh - 180px);
  }
  .umodal--fixed.umodal--ap {
    height: calc(100dvh - 180px);
  }
  .umodal--monitoring {
    max-height: calc(100dvh - 180px);
  }
  .umodal--fixed.umodal--monitoring {
    height: calc(100dvh - 180px);
  }
}

.umodal__inner {
  width: 100%;
  max-width: var(--umodal-inner-max, 1100px);
  margin-left: auto;
  margin-right: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

@media (max-width: 576px) {
  .umodal {
    width: 96%;
    border-radius: 14px;
    max-height: calc(100vh - 84px);
  }

  @supports (height: 100dvh) {
    .umodal {
      max-height: calc(100dvh - 84px);
    }
  }

  .umodal--fixed {
    height: calc(100vh - 84px);
  }

  @supports (height: 100dvh) {
    .umodal--fixed {
      height: calc(100dvh - 84px);
    }
  }

  .umodal__inner {
    padding: 18px 14px;
  }

  .umodal__close {
    top: 10px;
    right: 12px;
    font-size: 1.6rem;
  }

  .umodal__header {
    padding-bottom: 10px;
    margin-bottom: 12px;
  }

  .umodal__title {
    font-size: 1.1rem;
  }

  .umodal__subtitle {
    font-size: 0.88rem;
  }

  /* Мобилки: убираем "супер-отступы" у специальных модалок */
  .umodal--tos,
  .umodal--ap,
  .umodal--monitoring {
    max-height: calc(100vh - 84px);
  }
  .umodal--fixed.umodal--tos,
  .umodal--fixed.umodal--ap,
  .umodal--fixed.umodal--monitoring {
    height: calc(100vh - 84px);
  }

  @supports (height: 100dvh) {
    .umodal--tos,
    .umodal--ap,
    .umodal--monitoring {
      max-height: calc(100dvh - 84px);
    }
    .umodal--fixed.umodal--tos,
    .umodal--fixed.umodal--ap,
    .umodal--fixed.umodal--monitoring {
      height: calc(100dvh - 84px);
    }
  }
}

.umodal__close {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 1.8rem;
  cursor: pointer;
  color: #c0392b;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
  user-select: none;
  text-decoration: none;
}

.umodal__close:hover {
  transform: scale(1.08);
  color: #e74c3c;
}

.umodal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(59, 204, 168, 0.35);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.umodal__title {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #3bcca8;
}

.umodal__subtitle {
  margin-top: 4px;
  color: #9aa5b1;
  font-size: 0.9rem;
}

.umodal__body {
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
  flex: 1;
  overscroll-behavior: contain; /* не прокручивать страницу под модалкой */
}

/* Центрирование внутреннего контента модалки (опционально) */
.umodal--content-centered {
  --umodal-content-max: 800px;
}

.umodal--content-centered .umodal__body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.umodal--content-centered .umodal__body > * {
  width: 100%;
  max-width: var(--umodal-content-max);
  margin-left: auto;
  margin-right: auto;
}

.umodal--content-centered .umodal-card {
  width: 100%;
  max-width: var(--umodal-content-max);
  margin-left: auto;
  margin-right: auto;
}

.umodal__body::-webkit-scrollbar {
  width: 8px;
}
.umodal__body::-webkit-scrollbar-thumb {
  background: #3bcca8;
  border-radius: 4px;
}
.umodal__body::-webkit-scrollbar-track {
  background: #161a1f;
}

.umodal a {
  color: #3bcca8;
}
.umodal a:hover {
  text-decoration: underline;
}

/* Layout helpers (used by tos/donate) */
.umodal-grid {
  display: flex;
  gap: 16px;
  min-height: 0;
}

.umodal-sidebar {
  width: 260px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.umodal-sidebar-btn {
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #d3cebc;
  font-weight: 600;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.umodal-sidebar-btn:hover {
  background: rgba(59, 204, 168, 0.08);
  border-color: rgba(59, 204, 168, 0.4);
  color: #ffffff;
}
.umodal-sidebar-btn.active {
  background: rgba(59, 204, 168, 0.18);
  border-color: #3bcca8;
  color: #ffffff;
}

.umodal-card {
  background: rgba(27, 30, 36, 0.95);
  border-radius: 10px;
  border: 1px solid rgba(59, 204, 168, 0.16);
  padding: 14px 14px;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .umodal {
    width: 94%;
  }
  .umodal__inner {
    padding: 20px 16px;
  }
  .umodal-grid {
    flex-direction: column;
  }
  .umodal-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }
  .umodal-sidebar-btn {
    white-space: nowrap;
    font-size: 0.85rem;
  }
}

