html {
  overflow-x: clip;
  overscroll-behavior-y: auto;
}

body,
body.game-page-body {
  overflow-x: clip;
}

html.nav-open {
  overflow: hidden;
}

body.nav-open,
body.game-page-body.nav-open {
  overflow: clip;
}

@media (max-width: 860px) {
  .mobile-nav-drawer {
    top: calc(var(--header-height) + var(--safe-area-top, 0px));
    max-height: calc(100svh - var(--header-height) - var(--safe-area-top, 0px));
    max-height: calc(100dvh - var(--header-height) - var(--safe-area-top, 0px));
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: calc(24px + var(--safe-area-bottom, 0px));
  }
}

/* Decorative layers scroll with their page instead of staying on the viewport. */
body::before,
.profile-page-wrapper::before,
.page-scenic-bg,
.rooms-background,
.lobby-background,
.join-background,
.create-room-background,
.auth-background,
.auth-background-shade,
.not-found-background,
.banned-background,
.banned-background-layer {
  position: absolute;
}

.banned-body {
  overflow-y: auto;
}

.page-wrapper {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
}

.page-wrapper > .main-header,
.page-wrapper > .main-footer {
  flex-shrink: 0;
}

.page-wrapper > main {
  flex: 1 0 auto;
  min-width: 0;
}

.main-footer {
  width: 100%;
  margin-top: auto;
  padding-bottom: calc(24px + var(--safe-area-bottom, 0px));
}

.footer-content > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.main-footer .rules-footer-link {
  display: inline-block;
}

.rooms-list-viewport {
  overscroll-behavior-y: auto;
}

.lobby-chat-toggle {
  bottom: calc(22px + var(--floating-footer-offset, 0px) + var(--safe-area-bottom, 0px));
}

.game-return-link {
  box-sizing: border-box;
  position: fixed;
  left: calc(22px + var(--safe-area-left, 0px));
  bottom: calc(22px + var(--floating-footer-offset, 0px) + var(--safe-area-bottom, 0px));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: calc(100% - 44px - var(--safe-area-left, 0px) - var(--safe-area-right, 0px));
  min-height: 46px;
  padding: 12px 18px;
  border: 1px solid var(--color-primary-border, var(--tone-a76c21));
  border-radius: var(--radius-md, 10px);
  background: var(--bg-body, var(--ink-800));
  color: var(--color-primary-light, var(--amber-400));
  box-shadow: 0 8px 24px var(--black-a45, var(--tone-000000-a45-098));
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}
.game-return-link > span:first-child { font-size: 22px; line-height: 1; }
.game-return-link:hover { border-color: var(--color-primary, var(--amber-500)); background: var(--surface-control, var(--tone-1c1c1c)); }
.game-return-link:focus-visible { outline: 2px solid var(--color-primary, var(--amber-500)); outline-offset: 3px; }

@media (max-width: 640px) {
  .footer-content {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    line-height: 1.8;
  }
}
