:root {
  --app-viewport-height: 100vh;
  --app-viewport-width: 100vw;
  --app-tetris-board-height: min(49vh, 470px);
  --app-safe-viewport-height: calc(
    var(--app-viewport-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
}

html,
body {
  width: 100%;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: var(--app-viewport-height);
}

.site-shell {
  min-height: var(--app-viewport-height) !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

html.is-harmonyos body {
  font-family: "HarmonyOS Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background-attachment: scroll;
}

button,
[role="button"],
input[type="button"],
input[type="submit"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.assessment66-overlay,
.community-overlay,
.share-overlay,
.profile-overlay,
.games-overlay,
.assistant-overlay,
.wellbeing-overlay,
.crush-overlay {
  box-sizing: border-box;
  height: var(--app-viewport-height);
  max-height: var(--app-viewport-height);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.assessment66-shell {
  min-height: min(780px, calc(var(--app-viewport-height) - 56px));
}

.community-drawer {
  max-height: var(--app-viewport-height);
  padding-bottom: max(64px, calc(32px + env(safe-area-inset-bottom)));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.profile-shell {
  max-height: min(900px, calc(var(--app-viewport-height) - 48px));
}

.profile-body {
  max-height: calc(min(900px, calc(var(--app-viewport-height) - 48px)) - 170px);
}

.games-shell {
  height: min(840px, calc(var(--app-viewport-height) - 32px));
  max-height: calc(var(--app-viewport-height) - 20px);
}

.assistant-shell {
  height: min(780px, calc(var(--app-viewport-height) - 44px));
}

.wellbeing-shell {
  min-height: min(760px, calc(var(--app-viewport-height) - 40px));
}

.wellbeing-content {
  max-height: calc(var(--app-viewport-height) - 250px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.crush-shell {
  max-height: min(calc(var(--app-viewport-height) - 36px), 980px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.compact-nav-panel {
  max-height: min(620px, calc(var(--app-viewport-height) - 100px));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.games-body,
.profile-body,
.assistant-body,
.assistant-messages,
.wellbeing-content {
  scrollbar-gutter: stable;
}

.games-quick-button,
.profile-quick-button {
  bottom: max(68px, calc(52px + env(safe-area-inset-bottom)));
}

.assistant-quick-button {
  bottom: max(14px, env(safe-area-inset-bottom));
}

.wellbeing-launcher {
  bottom: max(82px, calc(66px + env(safe-area-inset-bottom)));
}

.crush-launcher {
  bottom: max(164px, calc(148px + env(safe-area-inset-bottom)));
}

@media (max-width: 820px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .assessment66-overlay,
  .community-overlay,
  .share-overlay,
  .profile-overlay,
  .games-overlay,
  .assistant-overlay,
  .wellbeing-overlay,
  .crush-overlay {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }

  .assessment66-shell,
  .profile-shell,
  .games-shell,
  .assistant-shell,
  .wellbeing-shell,
  .crush-shell {
    width: 100%;
    height: var(--app-safe-viewport-height);
    min-height: 0;
    max-height: var(--app-safe-viewport-height);
  }

  .profile-body {
    max-height: none;
    min-height: 0;
  }

  .games-body,
  .assistant-body,
  .profile-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .wellbeing-shell {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  .wellbeing-content {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .tetris-board {
    height: var(--app-tetris-board-height);
  }
}

@media (max-width: 420px) {
  .games-header,
  .assistant-header,
  .profile-header,
  .wellbeing-header,
  .crush-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .compact-nav-panel {
    width: min(390px, calc(var(--app-viewport-width) - 16px));
  }
}
