#analytics-choice[hidden], #analytics-preferences[hidden] { display: none; }
#analytics-choice {
  position: fixed; inset: auto 1rem max(1rem, env(safe-area-inset-bottom)) auto; z-index: 20;
  width: min(26rem, calc(100% - 2rem)); box-sizing: border-box; padding: 1rem;
  color: #f4f6f8; background: #121d29; border: 1px solid #445563; border-radius: .8rem;
  box-shadow: 0 .35rem 1.5rem #0006; font: 1rem/1.4 system-ui, sans-serif;
}
#analytics-choice p { margin: 0 0 .65rem; }
#analytics-choice div { display: flex; flex-wrap: wrap; gap: .5rem; }
#analytics-choice button, #analytics-preferences {
  color: #f5cf68; background: #192633; border: 1px solid #556571; border-radius: .4rem;
  font: inherit; cursor: pointer; padding: .55rem .8rem;
}
#analytics-choice button:focus-visible, #analytics-preferences:focus-visible { outline: 2px solid #ffd060; outline-offset: 2px; }
#analytics-preferences { display: block; margin: 1rem auto; font: .86rem/1.35 system-ui, sans-serif; }
/* Keep the community controls and the consent card in separate rows. */
body:has(#room[hidden]) {
  --consent-bottom: max(1rem, env(safe-area-inset-bottom));
  --community-bottom: calc(var(--consent-bottom) + var(--consent-height, 0px) + 8px);
}
body:has(#room[hidden]):has(#analytics-choice:not([hidden])) :is(.general-chat-widget, .online-widget) {
  bottom: var(--community-bottom);
}
body:has(#room[hidden]):has(#analytics-choice:not([hidden])) :is(#general-chat-panel, #online-panel) {
  max-height: calc(100dvh - var(--community-bottom) - 78px - env(safe-area-inset-top));
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 760px), (pointer: coarse) and (max-height: 520px) {
  #analytics-choice {
    --consent-bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: var(--consent-bottom);
    margin-inline: auto;
    width: auto;
    max-width: 32rem;
    max-height: 46dvh;
    overflow-y: auto;
    padding: .75rem;
  }
  #analytics-choice div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #analytics-choice button { min-height: 44px; }
  body:has(#room[hidden]) {
    --consent-bottom: max(12px, env(safe-area-inset-bottom));
  }
  body:has(#room[hidden]) #analytics-preferences {
    margin-bottom: calc(var(--community-bottom) + 64px + .5rem);
  }
}
@media (max-width: 600px) {
  /* The bottom clearance is after the last control, below the footer links. */
  body:has(#room[hidden]) footer { padding-bottom: 1.25rem !important; }
}

