/* Scrolly / WKWebView — same touch contract as grid-blitz (touch-action none, safe areas) */

:root {
  --scrolly-bg: #07070f;
  --scrolly-text: #ffffff;
  --scrolly-safe-left: env(safe-area-inset-left, 0px);
  --scrolly-safe-right: env(safe-area-inset-right, 0px);
  --scrolly-safe-top: max(env(safe-area-inset-top, 0px), 56px);
  --scrolly-safe-bottom: max(env(safe-area-inset-bottom, 0px), 20px);
  --scrolly-host-back-gutter: 56px;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  background: var(--scrolly-bg) !important;
  color: var(--scrolly-text) !important;
  min-height: 100vh;
  width: 100%;
  overflow: hidden !important;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none !important;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  padding-top: max(8px, calc(var(--scrolly-safe-top) + 2px));
  padding-bottom: max(8px, calc(var(--scrolly-safe-bottom) + 2px));
  padding-left: max(8px, calc(var(--scrolly-safe-left) + var(--scrolly-host-back-gutter)));
  padding-right: max(8px, calc(var(--scrolly-safe-right) + 8px));
  box-sizing: border-box;
}

.container {
  width: 100% !important;
  max-width: min(640px, calc(100vw - 16px - var(--scrolly-safe-left) - var(--scrolly-safe-right)));
  margin: 0 auto !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center !important;
  min-height: min(100vh, 100dvh) !important;
  padding: clamp(54px, 8dvh, 82px) 0 0 !important;
  box-sizing: border-box;
}

#qs-grid {
  touch-action: none !important;
  -webkit-user-select: none;
}

.qs-cell {
  touch-action: none;
}

/* Match planet-destroyer: full-width grid HUD below native header */
#hud {
  top: 48px !important;
  left: calc(12px + var(--scrolly-safe-left)) !important;
  right: calc(12px + var(--scrolly-safe-right)) !important;
  transform: none !important;
  text-align: center !important;
}

@media (max-height: 860px) {
  .container {
    padding-top: clamp(44px, 6.4dvh, 66px) !important;
  }
}

@media (max-height: 760px) {
  .container {
    padding-top: clamp(34px, 4.6dvh, 52px) !important;
  }

  #hud {
    top: 42px !important;
  }
}
