:root {
  --rules-max: 860px;
  --radius: 26px;
  --border: rgba(179, 179, 179, 0.12);
  --bg: rgba(0, 0, 0, 0.09);
  --soft: rgba(255, 255, 255, 0.06);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.68);

  /* чуть быстрее + “поуже” */
  --anim: 420ms;
  --ease: cubic-bezier(0.2, 0.9, 0.25, 1);
  --shift: 14px;
}
html,
body {
  width: 100%;
  overflow-x: hidden; /* или clip, но hidden универсальнее */
}

.glass {
  background: var(--bg);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.rules-wrap {
  width: 100%;
  max-width: var(--rules-max);
  margin: 150px auto 90px auto;
  padding: 0 16px;
  color: #ddd;
  font-family: var(--main-font, "Nata Sans", sans-serif);
}

.rules-frame {
  padding: 18px;
}

.rules-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 12px 14px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--soft), transparent);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rules-top__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.badge {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}

.title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.title b {
  font-size: 16px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.93);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title span {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.rules-top__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.counter {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 900;
  font-size: 13px;
  user-select: none;
}

.viewport {
  position: relative;
  margin-top: 14px;
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-height: 360px;

  transition: height var(--anim) var(--ease);
}

.pane {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: grid;
  gap: 12px;
  color: var(--text);
  will-change: transform, opacity;
}

.rule-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.rule-header__left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.rule-ico {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}

.rule-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rule-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 900;
  font-size: 12px;
  width: max-content;
  user-select: none;
}

.rule-meta h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 950;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.2px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 560px;
}

.rule-meta p {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.35;
}

.content {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 1.7;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.88);
  min-height: 180px;
  display: flex;
  align-items: flex-start;
  user-select: text;

  overflow-wrap: anywhere;
  word-break: break-word;
}

.content p {
  margin: 0;
}

.nav {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.03)
  );
  color: rgba(255, 255, 255, 0.92);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease,
    border-color 180ms ease, box-shadow 180ms ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.07),
    rgba(255, 255, 255, 0.04)
  );
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.nav-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) inset;
}

.nav-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* animations */
.anim {
  transition: transform var(--anim) var(--ease), opacity var(--anim) var(--ease);
}
.enter-r {
  transform: translateX(var(--shift));
  opacity: 0;
}
.enter-l {
  transform: translateX(calc(var(--shift) * -1));
  opacity: 0;
}
.leave-l {
  transform: translateX(calc(var(--shift) * -1));
  opacity: 0;
}
.leave-r {
  transform: translateX(var(--shift));
  opacity: 0;
}
/* важно для grid + скролла */
.pane {
  display: grid;
  grid-template-rows: auto 1fr; /* header + content */
  min-height: 0;
}

.content {
  min-height: 0; /* критично: иначе не будет нормально ужиматься */
  overflow: auto; /* теперь длинный текст можно скроллить */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;

  overflow-wrap: anywhere; /* на всякий случай от длинных слов/ссылок */
  word-break: break-word;
}

@media (max-width: 560px) {
  .rule-meta h2 {
    max-width: 70vw;
  }
  .viewport {
    min-height: 410px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 560px) {
  .rules-wrap {
    margin: 90px auto 40px; /* 150px на мобиле обычно слишком */
    padding: 0 12px;
  }

  .rules-frame {
    padding: 14px;
  }
  .pane {
    padding: 12px;
  }

  .rules-top {
    align-items: stretch;
  }

  .rules-top__right {
    justify-content: flex-end;
  }

  .rule-header {
    flex-direction: column;
    align-items: stretch;
  }

  .rule-header__left {
    align-items: flex-start;
  }

  .rule-meta h2 {
    white-space: normal; /* ВАЖНО: иначе заголовок может раздувать ширину */
    max-width: 100%;
  }

  .rule-pill {
    width: 100%;
    justify-content: center;
  }

  .nav {
    flex-direction: column; /* чтобы “Назад” не уезжал */
    align-items: stretch;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .rules-wrap {
    margin: 90px auto 40px; /* на телефоне 150px сверху обычно слишком */
    padding: 0 12px;
  }

  .rules-frame {
    padding: 14px;
  }

  .rules-top {
    padding: 10px;
    gap: 10px;
    align-items: center; /* чтобы counter был по центру относительно текста */
  }

  .badge {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .title b {
    font-size: 15px;
  }

  .title span,
  .hint {
    font-size: 12px;
    line-height: 1.25;
  }

  .counter {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* заголовок правила: пусть переносится, а не давится в одну строку */
  .rule-meta h2 {
    white-space: normal;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .hint-kbd {
    display: none;
  }
}
