:root {
  color-scheme: dark;
}

/* Legal pages are long documents. The landing page intentionally locks the
   viewport in main.css, so explicitly restore normal document scrolling here. */
html {
  width: 100%;
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}

body.legal_page {
  margin: 0;
  width: 100%;
  height: auto;
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: visible;
  color: #fff;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, .16), transparent 30%),
    linear-gradient(145deg, #5c4ad6, #8b70ee 58%, #d43b91);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-overflow-scrolling: touch;
}

.legal_header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px;
}

.legal_header_inner {
  width: min(980px, 100%);
  min-width: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 22px;
  background: rgba(54, 35, 142, .60);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 18px 60px rgba(27, 12, 72, .18);
}

.legal_back {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 16px;
  color: #fff;
  background: rgba(255, 255, 255, .10);
  font-weight: 800;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}

.legal_back:hover {
  background: rgba(255, 255, 255, .18);
  transform: translateY(-1px);
}

.legal_back_arrow {
  position: relative;
  display: inline-flex;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
}

.legal_back_arrow::before {
  content: "";
  width: 9px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(2px) rotate(45deg);
}

.legal_back_arrow::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  width: 13px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.legal_brand {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.legal_brand img {
  display: block;
  width: 92px;
  max-width: 24vw;
  height: auto;
}

.legal_title_short {
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legal_main {
  width: min(980px, calc(100% - 32px));
  margin: 14px auto 48px;
}

.legal_card {
  min-width: 0;
  max-width: 100%;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid rgba(255, 255, 255, .20);
  border-radius: 30px;
  background: rgba(255, 255, 255, .94);
  color: #211a3d;
  box-shadow: 0 30px 90px rgba(35, 20, 86, .24);
}

/* Long German/Kazakh words must never widen the document. */
.legal_card h3,
.legal_card p,
.legal_card li,
.legal_card a {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.legal_card h2 {
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  -webkit-hyphens: none;
}

.legal_card h2 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 46px);
  line-height: 1.08;
  color: #241a55;
}

.legal_card h3 {
  margin: 30px 0 10px;
  font-size: 20px;
  line-height: 1.25;
  color: #31236f;
}

.legal_card p,
.legal_card li {
  font-size: 15px;
  line-height: 1.65;
}

.legal_card ul,
.legal_card ol {
  max-width: 100%;
  margin-right: 0;
  padding-left: 22px;
}

.legal_card a {
  color: #5d45c7;
  font-weight: 800;
}

.legal_footer {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  font-size: 13px;
  opacity: .9;
  text-align: center;
}

.legal_page .translate_wrapper {
  flex: 0 0 auto;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
}

.legal_page .more_lang {
  bottom: auto;
  top: calc(100% + 10px);
}

@media (max-width: 620px) {
  .legal_header {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 6px;
  }

  .legal_header_inner {
    position: relative;
    min-height: 56px;
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
  }

  .legal_back {
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
  }

  .legal_back span:last-child,
  .legal_title_short {
    display: none;
  }

  .legal_brand {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
  }

  .legal_back,
  .legal_page .translate_wrapper {
    position: relative;
    z-index: 1;
  }

  .legal_page .translate_wrapper {
    margin-left: auto;
  }

  .legal_brand img {
    width: 84px;
    max-width: 100%;
  }

  .legal_main {
    width: min(calc(100% - 16px), 980px);
    margin-top: 8px;
    margin-bottom: 32px;
  }

  .legal_card {
    padding: 22px 18px 24px;
    border-radius: 22px;
  }

  .legal_card > p:first-of-type {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 14px;
    opacity: .72;
  }

  .legal_card h2 {
    margin-bottom: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(49, 35, 111, .12);
    font-size: clamp(24px, 7.2vw, 31px);
    line-height: 1.02;
    letter-spacing: -0.035em;
    text-wrap: balance;
  }

  html[lang="de"] .legal_card h2 {
    font-size: clamp(20px, 6vw, 26px);
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
  }

  .legal_card h3 {
    margin-top: 26px;
    font-size: 19px;
  }

  .legal_page .more_lang {
    position: fixed;
    top: calc(74px + env(safe-area-inset-top, 0px));
    right: 8px;
    bottom: auto;
    width: min(220px, calc(100vw - 16px));
    max-height: calc(100svh - 90px - env(safe-area-inset-top, 0px));
    overflow-y: auto;
  }

  .legal_page .current_lang {
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .legal_header_inner {
    gap: 6px;
  }

  .legal_back {
    flex-basis: 42px;
    width: 42px;
    min-height: 42px;
  }

  .legal_brand img {
    width: 76px;
  }

  .legal_main {
    width: calc(100% - 12px);
  }

  .legal_card {
    padding: 18px 14px;
    border-radius: 20px;
  }

  .legal_card h2 {
    font-size: 22px;
    line-height: 1.04;
    letter-spacing: -0.03em;
  }

  html[lang="de"] .legal_card h2 {
    font-size: 19px;
    line-height: 1.06;
  }

  .legal_card h3 {
    font-size: 18px;
  }

  .legal_card p,
  .legal_card li {
    font-size: 14.5px;
    line-height: 1.6;
  }

  .legal_card ul,
  .legal_card ol {
    padding-left: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.legal_page {
    animation: none;
  }

  .legal_back {
    transition: none;
  }
}
