/* V1.112 — rules and its linked codices form one modal domain with exact state restoration. */
html body.rules-modal-open:not(.maintenance-mode) {
  overflow: hidden;
  overscroll-behavior: none;
}

html body.rules-modal-open:not(.maintenance-mode) > [data-rules-modal-inert="true"] {
  pointer-events: none !important;
  user-select: none !important;
  touch-action: none !important;
}

html body.rules-modal-open:not(.maintenance-mode) #rulesDialog.rules-dialog:not([hidden]) {
  pointer-events: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

html body.rules-modal-open:not(.maintenance-mode) #rulesDialog .rules-box {
  max-height: min(92dvh, 920px);
  overflow: auto;
  overscroll-behavior: contain;
}

html body.rules-modal-open:not(.maintenance-mode) #closeRules:focus-visible {
  outline: 2px solid #8edcff !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(73, 178, 225, 0.18), 0 0 18px rgba(69, 184, 231, 0.2) !important;
}

@media (max-width: 720px) {
  html body.rules-modal-open:not(.maintenance-mode) #rulesDialog .rules-box {
    max-height: calc(100dvh - max(14px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom)));
  }
}

@media (prefers-reduced-motion: reduce) {
  html body.rules-modal-open:not(.maintenance-mode) #rulesDialog,
  html body.rules-modal-open:not(.maintenance-mode) #rulesDialog .rules-box {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  html body.rules-modal-open:not(.maintenance-mode) #rulesDialog .rules-box,
  html body.rules-modal-open:not(.maintenance-mode) #closeRules:focus-visible {
    border: 2px solid CanvasText !important;
    outline: 2px solid Highlight !important;
    box-shadow: none !important;
  }
}
