/* MJ SCORE v1235
 * The app header is always fixed at the top.
 * The admin header is a separate long-press panel and the only ZIP drop target.
 * The title image shrinks inside the width left by the visible header icons.
 */

:root {
  --mj-app-header-height: calc(env(safe-area-inset-top, 0px) + 86px);
  --mj-admin-header-gap: 8px;
  --mj-admin-header-reserved-space: 58px;
}

html body.has-fixed-app-header {
  padding-top: var(--mj-app-header-height) !important;
}

html body.has-fixed-app-header.is-admin-menu-open {
  padding-top: calc(var(--mj-app-header-height) + var(--mj-admin-header-reserved-space)) !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area {
  position: fixed !important;
  inset: 0 0 auto 0 !important;
  z-index: 12000 !important;
  width: 100% !important;
  max-width: none !important;
  height: var(--mj-app-header-height) !important;
  min-height: var(--mj-app-header-height) !important;
  margin: 0 !important;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px)) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  background: rgba(255, 255, 255, .97) !important;
  border-bottom: 1px solid rgba(0, 80, 255, .14) !important;
  box-shadow: 0 8px 20px rgba(0, 80, 255, .10) !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-user-drag: none !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area .app-header-title-area {
  position: relative !important;
  inset: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
html body.has-fixed-app-header.has-achievement-button #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
html body.has-fixed-app-header.has-current-player-icon #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
html body.has-fixed-app-header.has-visible-share-icon #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
html body.has-fixed-app-header.has-game-photo-button #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image {
  position: static !important;
  inset: auto !important;
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-width: min(310px, 100%) !important;
  max-height: 100% !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: left center !important;
  margin: 0 !important;
  transform: none !important;
  flex: 1 1 0 !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area .app-header-title-area > .app-version-label {
  position: absolute !important;
  inset: auto auto 0 4px !important;
  margin: 0 !important;
  transform: none !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area > #icons_header.icons-header {
  position: static !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex: 0 0 auto !important;
  flex-wrap: nowrap !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 0 0 auto !important;
  transform: none !important;
  gap: 8px !important;
}

/* v1235: v1229の公開HTMLには .app-header-title-area がまだない。
   旧DOMでもロゴとアイコンを同じ通常flex行へ置き、残り幅をロゴへ渡す。 */
html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area > .app-header-logo-image.app-header-logo-image {
  position: static !important;
  inset: auto !important;
  display: block !important;
  flex: 1 1 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: min(310px, 100%) !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: left center !important;
  margin: 0 !important;
  transform: none !important;
}

html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area > .app-version-label {
  position: absolute !important;
  inset: auto auto 4px 18px !important;
  margin: 0 !important;
  transform: none !important;
}

html body.has-fixed-app-header #app-title-home-link.is-long-pressing {
  background: #f3f8ff !important;
  box-shadow: inset 0 -3px 0 rgba(0, 80, 255, .22), 0 8px 20px rgba(0, 80, 255, .10) !important;
}

html body.has-fixed-app-header #app-title-home-link[data-mj-zip-drop-target="1"]::before {
  content: none !important;
  display: none !important;
}

html body.has-fixed-app-header #admin-toolbar.admin-toolbar {
  position: fixed !important;
  top: calc(var(--mj-app-header-height) + var(--mj-admin-header-gap)) !important;
  left: 50% !important;
  right: auto !important;
  z-index: 12100 !important;
  transform: translateX(-50%) !important;
  max-width: calc(100vw - 20px) !important;
  box-sizing: border-box !important;
}

html body.has-fixed-app-header.is-admin-user #admin-toolbar.admin-toolbar {
  display: none !important;
}

html body.has-fixed-app-header.is-admin-menu-open #admin-toolbar.admin-toolbar {
  display: flex !important;
}

html body.has-fixed-app-header.mj-admin-file-dragging #admin-toolbar[data-mj-zip-drop-target="1"],
html body.has-fixed-app-header #admin-toolbar[data-mj-zip-drop-target="1"].is-zip-dragover {
  border-color: #0050ff !important;
  background: #eef6ff !important;
  box-shadow: 0 0 0 4px rgba(0, 80, 255, .16), 0 14px 30px rgba(0, 80, 255, .20) !important;
}

html body.has-fixed-app-header.mj-admin-file-dragging #app-title-home-link,
html body.has-fixed-app-header #app-title-home-link.is-zip-dragover {
  outline: none !important;
}

@media (max-width: 640px) {
  :root {
    --mj-app-header-height: calc(env(safe-area-inset-top, 0px) + 74px);
    --mj-admin-header-gap: 6px;
    --mj-admin-header-reserved-space: 66px;
  }

  html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area {
    height: var(--mj-app-header-height) !important;
    min-height: var(--mj-app-header-height) !important;
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px) !important;
    padding-bottom: 6px !important;
  }

  html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
  html body.has-fixed-app-header.has-achievement-button #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
  html body.has-fixed-app-header.has-current-player-icon #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
  html body.has-fixed-app-header.has-visible-share-icon #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image,
  html body.has-fixed-app-header.has-game-photo-button #app-title-home-link.top-logo-area.top-logo-area .app-header-logo-image.app-header-logo-image {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
    max-width: min(310px, 100%) !important;
    max-height: 100% !important;
    aspect-ratio: auto !important;
  }

  html body.has-fixed-app-header #app-title-home-link.top-logo-area.top-logo-area.top-logo-area > #icons_header.icons-header {
    gap: 7px !important;
  }

  html body.has-fixed-app-header #admin-toolbar.admin-toolbar {
    width: calc(100% - 20px) !important;
    min-height: 48px !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.has-fixed-app-header #admin-toolbar .admin-toolbar-label,
  html body.has-fixed-app-header #admin-toolbar .admin-toolbar-actions {
    flex: 0 0 auto !important;
  }
}

/* v1235: keep the member-count pictogram in sync with its 3/4-player label.
   The bundled rule used `calc(50%+8px)`, which browsers reject because the
   + operator must be surrounded by whitespace.  That hid the right player,
   so a four-player badge looked like a three-player badge. */
html .mj-member-count-badge .mj-member-dot.dot-2 {
  left: calc(50% + 8px) !important;
}
